Skip to content

Commit 5141045

Browse files
committed
Add properties class to bind to in SpringApplication
Closes gh-40592
1 parent 16347a7 commit 5141045

File tree

4 files changed

+203
-65
lines changed

4 files changed

+203
-65
lines changed
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/*
2+
* Copyright 2012-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot;
18+
19+
import java.util.LinkedHashSet;
20+
import java.util.Set;
21+
22+
import org.springframework.boot.Banner.Mode;
23+
24+
/**
25+
* Spring application properties.
26+
*
27+
* @author Moritz Halbritter
28+
*/
29+
class ApplicationProperties {
30+
31+
/**
32+
* Whether bean definition overriding, by registering a definition with the same name
33+
* as an existing definition, is allowed.
34+
*/
35+
private boolean allowBeanDefinitionOverriding;
36+
37+
/**
38+
* Whether to allow circular references between beans and automatically try to resolve
39+
* them.
40+
*/
41+
private boolean allowCircularReferences;
42+
43+
/**
44+
* Mode used to display the banner when the application runs.
45+
*/
46+
private Banner.Mode bannerMode = Banner.Mode.CONSOLE;
47+
48+
/**
49+
* Whether to keep the application alive even if there are no more non-daemon threads.
50+
*/
51+
private boolean keepAlive;
52+
53+
/**
54+
* Whether initialization should be performed lazily.
55+
*/
56+
private boolean lazyInitialization = false;
57+
58+
/**
59+
* Whether to log information about the application when it starts.
60+
*/
61+
private boolean logStartupInfo = true;
62+
63+
/**
64+
* Whether the application should have a shutdown hook registered.
65+
*/
66+
private boolean registerShutdownHook = true;
67+
68+
/**
69+
* Sources (class names, package names, or XML resource locations) to include in the
70+
* ApplicationContext.
71+
*/
72+
private Set<String> sources = new LinkedHashSet<>();
73+
74+
/**
75+
* Flag to explicitly request a specific type of web application. If not set,
76+
* auto-detected based on the classpath.
77+
*/
78+
private WebApplicationType webApplicationType;
79+
80+
boolean isAllowBeanDefinitionOverriding() {
81+
return this.allowBeanDefinitionOverriding;
82+
}
83+
84+
void setAllowBeanDefinitionOverriding(boolean allowBeanDefinitionOverriding) {
85+
this.allowBeanDefinitionOverriding = allowBeanDefinitionOverriding;
86+
}
87+
88+
boolean isAllowCircularReferences() {
89+
return this.allowCircularReferences;
90+
}
91+
92+
void setAllowCircularReferences(boolean allowCircularReferences) {
93+
this.allowCircularReferences = allowCircularReferences;
94+
}
95+
96+
Mode getBannerMode() {
97+
return this.bannerMode;
98+
}
99+
100+
void setBannerMode(Mode bannerMode) {
101+
this.bannerMode = bannerMode;
102+
}
103+
104+
boolean isKeepAlive() {
105+
return this.keepAlive;
106+
}
107+
108+
void setKeepAlive(boolean keepAlive) {
109+
this.keepAlive = keepAlive;
110+
}
111+
112+
boolean isLazyInitialization() {
113+
return this.lazyInitialization;
114+
}
115+
116+
void setLazyInitialization(boolean lazyInitialization) {
117+
this.lazyInitialization = lazyInitialization;
118+
}
119+
120+
boolean isLogStartupInfo() {
121+
return this.logStartupInfo;
122+
}
123+
124+
void setLogStartupInfo(boolean logStartupInfo) {
125+
this.logStartupInfo = logStartupInfo;
126+
}
127+
128+
boolean isRegisterShutdownHook() {
129+
return this.registerShutdownHook;
130+
}
131+
132+
void setRegisterShutdownHook(boolean registerShutdownHook) {
133+
this.registerShutdownHook = registerShutdownHook;
134+
}
135+
136+
Set<String> getSources() {
137+
return this.sources;
138+
}
139+
140+
void setSources(Set<String> sources) {
141+
this.sources = new LinkedHashSet<>(sources);
142+
}
143+
144+
WebApplicationType getWebApplicationType() {
145+
return this.webApplicationType;
146+
}
147+
148+
void setWebApplicationType(WebApplicationType webApplicationType) {
149+
this.webApplicationType = webApplicationType;
150+
}
151+
152+
}

0 commit comments

Comments
 (0)