Skip to content

Commit

Permalink
Configuration properties must be defined and accessed using lower-cas…
Browse files Browse the repository at this point in the history
…e kebab format #239

Configuration properties names changed to kebab case in all *.properties files;
Configuration properties names changed to kebab case everywhere property value is accessed from the code;
application.properties in new project templates now use kebab case property names;
  • Loading branch information
gorbunkov committed Sep 30, 2021
1 parent f1cb812 commit 57820d6
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
@ConditionalOnBean(DataManager.class)
@ConditionalOnClass(JmixDataRepository.class)
@ConditionalOnMissingBean({JmixRepositoryFactoryBean.class, JmixRepositoryConfigurationExtension.class})
@ConditionalOnProperty(prefix = "jmix.core.dataRepositories", name = "enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnProperty(prefix = "jmix.core.data-repositories", name = "enabled", havingValue = "true", matchIfMissing = true)
@Import(BootJmixRepositoriesRegistrar.class)
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
public class JmixDataRepositoryAutoConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)

@Override
public void setEnvironment(Environment environment) {
String property = environment.getProperty("jmix.core.excludeBeans");
String property = environment.getProperty("jmix.core.exclude-beans");
if (property != null) {
beansToExclude = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(property);
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/io/jmix/core/MessageTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,11 @@ public String getMessageRef(MetaProperty property) {
}

/**
* Returns the first locale from the list defined in {@code jmix.core.availableLocales} app property.
* Returns the first locale from the list defined in {@code jmix.core.available-locales} app property.
*/
public Locale getDefaultLocale() {
if (properties.getAvailableLocales().isEmpty())
throw new DevelopmentException("Invalid jmix.core.availableLocales application property");
throw new DevelopmentException("Invalid jmix.core.available-locales application property");
return properties.getAvailableLocales().get(0);
}

Expand All @@ -368,7 +368,7 @@ public String getLocaleDisplayName(Locale locale) {
}

/**
* Returns locales set in the {@code jmix.core.availableLocales} property as a map of the locale display name
* Returns locales set in the {@code jmix.core.available-locales} property as a map of the locale display name
* to the locale object.
*/
public Map<String, Locale> getAvailableLocalesMap() {
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/io/jmix/core/Stores.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected void initialize() {

@Nullable
protected StoreDescriptor getStoreDescriptor(String storeName) {
String descriptorName = environment.getProperty("jmix.core.storeDescriptor_" + storeName);
String descriptorName = environment.getProperty("jmix.core.store-descriptor-" + storeName);
if (descriptorName != null) {
StoreDescriptor descriptor = descriptors.get(descriptorName);
if (descriptor != null) {
Expand Down Expand Up @@ -122,10 +122,10 @@ public List<String> getAll() {
}

/**
* @return the list of additional data store names registered in the {@code jmix.core.additionalStores} property
* @return the list of additional data store names registered in the {@code jmix.core.additional-stores} property
*/
public List<String> getAdditional() {
String property = environment.getProperty("jmix.core.additionalStores");
String property = environment.getProperty("jmix.core.additional-stores");
if (!Strings.isNullOrEmpty(property))
return SPLITTER.splitToList(property);
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected void init() {

Element rootElem = DocumentHelper.createDocument().addElement("fetchPlans");

for (String location : modules.getPropertyValues("jmix.core.fetchPlansConfig")) {
for (String location : modules.getPropertyValues("jmix.core.fetch-plans-config")) {
addFile(rootElem, location);
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/io/jmix/core/impl/ResourcesImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public Resource getResource(String location) {
} else {
if (location.startsWith("/"))
location = location.substring(1);
File file = new File(environment.getProperty("jmix.core.confDir"), location);
File file = new File(environment.getProperty("jmix.core.conf-dir"), location);
if (file.exists()) {
location = file.toURI().toString();
} else {
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/resources/io/jmix/core/module.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# limitations under the License.
#

jmix.core.workDir = ${user.dir}/.jmix/work
jmix.core.confDir = ${user.dir}/.jmix/conf
jmix.core.tempDir = ${user.dir}/.jmix/temp
jmix.core.work-dir = ${user.dir}/.jmix/work
jmix.core.conf-dir = ${user.dir}/.jmix/conf
jmix.core.temp-dir = ${user.dir}/.jmix/temp

spring.jmx.enabled = true
12 changes: 6 additions & 6 deletions core/src/test/groovy/jmix_modules/JmixModulesTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,28 @@ class JmixModulesTest extends Specification {
def addon1 = modules.get('test_support.addon1')
def app = modules.get('test_support.app')

base.getProperty('jmix.core.fetchPlansConfig') == 'test_support/base/fetch-plans.xml'
base.getProperty('jmix.core.fetch-plans-config') == 'test_support/base/fetch-plans.xml'

addon1.getProperty('jmix.core.fetchPlansConfig') == 'test_support/addon1/fetch-plans.xml'
addon1.getProperty('jmix.core.fetch-plans-config') == 'test_support/addon1/fetch-plans.xml'
addon1.getProperty('prop1') == 'addon1_prop1'
addon1.getProperty('prop2') == 'addon1_prop2'

// because @PropertySource has no name in TestAppConfiguration
app.getProperty('jmix.core.fetchPlansConfig') == null
app.getProperty('jmix.core.fetch-plans-config') == null
app.getProperty('prop2') == null
// app values
environment.getProperty('jmix.core.fetchPlansConfig') == 'test_support/app/fetch-plans.xml'
environment.getProperty('jmix.core.fetch-plans-config') == 'test_support/app/fetch-plans.xml'
environment.getProperty('prop2') == 'app_prop2'
}

def "resulting properties"() {
expect:

environment.getProperty('jmix.core.fetchPlansConfig') == 'test_support/app/fetch-plans.xml'
environment.getProperty('jmix.core.fetch-plans-config') == 'test_support/app/fetch-plans.xml'
environment.getProperty('prop1') == 'addon1_prop1'
environment.getProperty('prop2') == 'app_prop2'

modules.getPropertyValues('jmix.core.fetchPlansConfig') == [
modules.getPropertyValues('jmix.core.fetch-plans-config') == [
'test_support/base/fetch-plans.xml', 'test_support/addon1/fetch-plans.xml', 'test_support/app/fetch-plans.xml'
]
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/groovy/messages/MessageSourceTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class MessageSourceTest extends Specification {
properties.load(new InputStreamReader(getClass().getResourceAsStream(configurationFile), 'UTF-8'))

properties.setProperty(overrideAttribute , overrideValue)
def dir = new File(environment.getProperty('jmix.core.confDir'), 'test_support/app')
def dir = new File(environment.getProperty('jmix.core.conf-dir'), 'test_support/app')
dir.mkdirs()
def file = new File(dir, 'messages.properties')
def stream = new FileOutputStream(file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# limitations under the License.
#

jmix.core.fetchPlansConfig = test_support/addon1/fetch-plans.xml
jmix.core.fetch-plans-config = test_support/addon1/fetch-plans.xml
prop1 = addon1_prop1
prop2 = addon1_prop2
14 changes: 7 additions & 7 deletions core/src/test/resources/test_support/app/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
# limitations under the License.
#

jmix.core.confDir = ${user.dir}/build/test-home/conf
jmix.core.workDir = ${user.dir}/build/test-home/work
jmix.core.conf-dir = ${user.dir}/build/test-home/conf
jmix.core.work-dir = ${user.dir}/build/test-home/work

app.foo = foo_value
cuba.webContextName = app
cuba.web-context-name = app

jmix.core.fetchPlansConfig = test_support/app/fetch-plans.xml
jmix.core.fetch-plans-config = test_support/app/fetch-plans.xml
prop2 = app_prop2

jmix.core.defaultFileStorage = testFs
jmix.core.default-file-storage = testFs

jmix.core.excludeBeans = addonCacheManager,addonBarBean
jmix.core.exclude-beans = addonCacheManager,addonBarBean


jmix.core.availableLocales = en,ru
jmix.core.available-locales = en,ru
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# limitations under the License.
#

jmix.core.fetchPlansConfig = test_support/base/fetch-plans.xml
jmix.core.fetch-plans-config = test_support/base/fetch-plans.xml

0 comments on commit 57820d6

Please sign in to comment.