branch develop updated (3f837ce -> 1a761ed)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository nuiton-config. See https://gitlab.nuiton.org/nuiton/nuiton-config.git from 3f837ce Be able to read/write other formats (ini, toml, ...) (Fixes #4059) Merge branch 'feature/4059' into develop new 6fc83ee Add more nice methods on generated config new ee84c4f Improve example new 5177df6 Report for actions are not complete (Fixes #4060) new 0267486 Depreciates Property change support in ApplicationConfig new 59442b9 Add generatePropertyChangeSupport on generate mojo new c58a81a Add propertyChangeSupport on generated configurations and depreciates PropertyChangeSupport on ApplicationConfig (Fixes #4061)" Merge branch 'feature/4061' into develop new 5b49291 Add missing license headers new 1a761ed Remove guava from api dependency + optimize dependencies The 8 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 1a761edcc299da3af1e3862d493f50db3cedbcb9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 18:58:53 2016 +0200 Remove guava from api dependency + optimize dependencies commit 5b492912039a50d2af0ab9b5ac707ec7e7860db9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 18:52:26 2016 +0200 Add missing license headers commit c58a81a26c958e1f7bf15c1b90dcdeaaa1644e42 Merge: 5177df6 59442b9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 18:33:56 2016 +0200 Add propertyChangeSupport on generated configurations and depreciates PropertyChangeSupport on ApplicationConfig (Fixes #4061)" Merge branch 'feature/4061' into develop commit 59442b95ec7351a940e4b35ac703d6105485529c Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 18:33:52 2016 +0200 Add generatePropertyChangeSupport on generate mojo commit 0267486eb865e039cf07cf71299d7c83a2d29be9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 18:09:05 2016 +0200 Depreciates Property change support in ApplicationConfig commit 5177df67ec219d82548a293e8d25daab54975fbe Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 18:04:40 2016 +0200 Report for actions are not complete (Fixes #4060) commit ee84c4f6c9658344545016f7a9370c594ff56134 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 17:31:28 2016 +0200 Improve example commit 6fc83ee05ae89a58eb5b8bc0043795e693792de0 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 17:31:12 2016 +0200 Add more nice methods on generated config Summary of changes: .../nuiton/config/example/NuitonConfigExample.java | 15 +- nuiton-config-io-ini/pom.xml | 11 +- .../config/io/ini/ApplicationConfigIOIni.java | 22 +++ .../config/io/ini/ApplicationConfigIOIniTest.java | 22 +++ .../org/nuiton/config/plugin/GenerateMojo.java | 11 ++ .../nuiton/config/plugin/ReportMojoSupport.java | 19 +-- .../org/nuiton/config/plugin/ReportRenderer.java | 178 +++------------------ .../templates/ApplicationConfigTransformer.java | 140 ++++++++++++++-- .../ApplicationConfigTransformerConfig.java | 2 + .../src/main/resources/config-report.properties | 4 + .../src/main/resources/config-report_fr.properties | 5 + .../java/org/nuiton/config/ApplicationConfig.java | 44 +++-- .../org/nuiton/config/SubApplicationConfig.java | 4 + .../org/nuiton/config/io/ApplicationConfigIO.java | 22 +++ .../config/io/ApplicationConfigIOHelper.java | 30 +++- .../config/io/ApplicationConfigReadFormat.java | 22 +++ .../ApplicationConfigReadPropertiesException.java | 22 +++ .../ApplicationConfigWritePropertiesException.java | 22 +++ .../properties/ApplicationConfigIOProperties.java | 22 +++ .../ApplicationConfigIOPropertiesTest.java | 22 +++ .../test/resources/NuitonConfigExample.properties | 21 +++ 21 files changed, 443 insertions(+), 217 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository nuiton-config. See https://gitlab.nuiton.org/nuiton/nuiton-config.git commit 6fc83ee05ae89a58eb5b8bc0043795e693792de0 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 17:31:12 2016 +0200 Add more nice methods on generated config --- .../templates/ApplicationConfigTransformer.java | 49 ++++++++++++++++++---- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/templates/ApplicationConfigTransformer.java b/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/templates/ApplicationConfigTransformer.java index f86297d..fa3ab97 100644 --- a/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/templates/ApplicationConfigTransformer.java +++ b/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/templates/ApplicationConfigTransformer.java @@ -46,6 +46,9 @@ import org.nuiton.eugene.models.object.ObjectModelJavaModifier; import org.nuiton.eugene.models.object.ObjectModelOperation; import org.nuiton.i18n.I18n; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Locale; import java.util.Set; @@ -481,13 +484,7 @@ public class ApplicationConfigTransformer extends ObjectModelTransformerToJava { addImport(output, actionClassName); String actionClassSimpleName = GeneratorUtil.getSimpleName(actionClassName); builder.append("" - /*{ - for (<%=actionClassSimpleName%> a : <%=actionClassSimpleName%>.values()) { - - for (String alias : a.getAliases()) { - applicationConfig.addActionAlias(alias, a.getAction()); - } - } + /*{ this.applicationConfig.loadActions(<%=actionClassSimpleName%>.class); }*/ ); } @@ -527,6 +524,44 @@ public class ApplicationConfigTransformer extends ObjectModelTransformerToJava { } + ObjectModelOperation getConfigurationDescription = addOperation( + output, "getConfigurationDescription", String.class, ObjectModelJavaModifier.PUBLIC + ); + setOperationBody(getConfigurationDescription , "" + /*{ + StringBuilder builder = new StringBuilder(); + builder.append("\\n====================================================================================================================="); + builder.append("\\n=== Configuration ==================================================================================================="); + builder.append("\\n====================================================================================================================="); + builder.append(String.format("\\n=== %1$-40s = %2$s", "Filename", get().getConfigFileName())); + for (<%=optionClassSimpleName%> option : orderedByKey()) { + builder.append(String.format("\\n=== %1$-40s = %2$s", option.getKey(), get().getOption(option))); + } + builder.append("\\n====================================================================================================================="); + return builder.toString(); + }*/ + ); + + ObjectModelOperation orderedByKey = addOperation( + output, "orderedByKey", "List<" + optionClassSimpleName + ">", ObjectModelJavaModifier.PROTECTED + ); + addImport(output, List.class); + addImport(output, Arrays.class); + addImport(output, Collections.class); + addImport(output, Comparator.class); + setOperationBody(orderedByKey, "" + /*{ + List<<%=optionClassSimpleName%>> values = Arrays.asList(<%=optionClassSimpleName%>.values()); + Collections.sort(values, new Comparator<<%=optionClassSimpleName%>>() { + @Override + public int compare(<%=optionClassSimpleName%> o1, <%=optionClassSimpleName%> o2) { + return o1.getKey().compareTo(o2.getKey()); + } + }); + return Collections.unmodifiableList(values); + }*/ + ); + } private void generateConfigClass(String packageName, String className, String abstractClassName) { -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository nuiton-config. See https://gitlab.nuiton.org/nuiton/nuiton-config.git commit ee84c4f6c9658344545016f7a9370c594ff56134 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 17:31:28 2016 +0200 Improve example --- .../org/nuiton/config/example/NuitonConfigExample.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/nuiton-config-example/src/main/java/org/nuiton/config/example/NuitonConfigExample.java b/nuiton-config-example/src/main/java/org/nuiton/config/example/NuitonConfigExample.java index d646d59..b51b478 100644 --- a/nuiton-config-example/src/main/java/org/nuiton/config/example/NuitonConfigExample.java +++ b/nuiton-config-example/src/main/java/org/nuiton/config/example/NuitonConfigExample.java @@ -34,18 +34,15 @@ public class NuitonConfigExample { NuitonConfigExampleConfig config = new NuitonConfigExampleConfig(); config.get().parse( - "--option", "identity.lastName", "Bloch", - "--option", "identity.firstName", "Joshua" + "--option", "identity.lastName", "Kent", + "--option", "identity.firstName", "Dick" ); - config.setAge(55); - config.setTwitter("joshbloch"); + config.setAge(26); + config.setTwitter("kdick"); + config.setEmail("kdick@gmail.com"); - System.out.println("Last name : " + config.getLastName()); - System.out.println("First name : " + config.getFirstName()); - System.out.println("Email : " + config.getEmail()); - System.out.println("Twitter : " + config.getTwitter()); - System.out.println("Age : " + config.getAge()); + System.out.println(config.getConfigurationDescription()); } -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository nuiton-config. See https://gitlab.nuiton.org/nuiton/nuiton-config.git commit 5177df67ec219d82548a293e8d25daab54975fbe Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 18:04:40 2016 +0200 Report for actions are not complete (Fixes #4060) --- .../nuiton/config/plugin/ReportMojoSupport.java | 19 +-- .../org/nuiton/config/plugin/ReportRenderer.java | 178 +++------------------ .../src/main/resources/config-report.properties | 4 + .../src/main/resources/config-report_fr.properties | 5 + 4 files changed, 35 insertions(+), 171 deletions(-) diff --git a/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/ReportMojoSupport.java b/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/ReportMojoSupport.java index bb6a9d9..0fbaa93 100644 --- a/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/ReportMojoSupport.java +++ b/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/ReportMojoSupport.java @@ -108,12 +108,6 @@ abstract class ReportMojoSupport extends AbstractMavenReport { private boolean verbose; /** - * Flag to render option in detail (add a section for each option). - */ - @Parameter(property = "config.showOptionDetail", defaultValue = "true") - private boolean showOptionDetail; - - /** * Skip to generate the report. */ @Parameter(property = "config.skip") @@ -202,12 +196,11 @@ abstract class ReportMojoSupport extends AbstractMavenReport { } ReportRenderer renderer = new ReportRenderer(getSink(), - i18n, - locale, - getOutputName(), - getOutputName(), - configProviders, - showOptionDetail); + i18n, + locale, + getOutputName(), + getOutputName(), + configProviders); renderer.render(); } @@ -227,7 +220,7 @@ abstract class ReportMojoSupport extends AbstractMavenReport { I18nInitializer initializer; if (StringUtils.isNotEmpty(i18nBundleName)) { initializer = new DefaultI18nInitializer(i18nBundleName, - newClassLoader); + newClassLoader); } else { initializer = new ClassPathI18nInitializer(newClassLoader); } diff --git a/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/ReportRenderer.java b/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/ReportRenderer.java index cfa1476..3ee2990 100644 --- a/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/ReportRenderer.java +++ b/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/ReportRenderer.java @@ -22,9 +22,9 @@ package org.nuiton.config.plugin; * #L% */ +import com.google.common.base.Joiner; import org.apache.commons.collections4.CollectionUtils; import org.apache.maven.doxia.sink.Sink; -import org.apache.maven.doxia.sink.SinkEventAttributes; import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; import org.apache.maven.reporting.AbstractMavenReportRenderer; import org.codehaus.plexus.i18n.I18N; @@ -33,12 +33,6 @@ import org.nuiton.config.ApplicationConfigProvider; import org.nuiton.config.ConfigActionDef; import org.nuiton.config.ConfigOptionDef; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; import java.util.Locale; import java.util.Set; @@ -77,18 +71,12 @@ class ReportRenderer extends AbstractMavenReportRenderer { */ private final Set<ApplicationConfigProvider> configProviders; - /** - * To show option in detail. - */ - private final boolean optionWithDetail; - ReportRenderer(Sink sink, I18N i18n, Locale locale, String reportName, String bundleName, - Set<ApplicationConfigProvider> configProviders, - boolean optionWithDetail) { + Set<ApplicationConfigProvider> configProviders) { super(sink); this.i18n = i18n; this.locale = locale; @@ -96,7 +84,6 @@ class ReportRenderer extends AbstractMavenReportRenderer { this.bundleName = bundleName; this.sink = sink; this.configProviders = configProviders; - this.optionWithDetail = optionWithDetail; } @Override @@ -181,12 +168,10 @@ class ReportRenderer extends AbstractMavenReportRenderer { sink.section2(); sink.sectionTitle2(); sink.anchor("detail_" + configProvider.getName()); - sink.text(getText("report.detail.configuration.title") + " " + - configProvider.getName()); + sink.text(getText("report.detail.configuration.title") + " " + configProvider.getName()); sink.anchor_(); sink.sectionTitle2_(); - sink.lineBreak(); sink.paragraph(); sink.text(getText("report.config.name") + " : "); sink.bold(); @@ -194,7 +179,6 @@ class ReportRenderer extends AbstractMavenReportRenderer { sink.bold_(); sink.paragraph_(); - sink.lineBreak(); sink.paragraph(); sink.text(getText("report.config.description") + " : "); sink.bold(); @@ -211,24 +195,15 @@ class ReportRenderer extends AbstractMavenReportRenderer { sink.sectionTitle3_(); sink.lineBreak(); - Collection<ConfigOptionDef> options = - getOptions(configProvider); - - renderOptionDefsTable(configProvider, options); - - if (optionWithDetail) { - - for (ConfigOptionDef option : options) { - - renderProviderOptionDetail(configProvider, option); - } - } + renderOptionDefsTable(configProvider.getOptions()); sink.section3_(); sink.section3(); sink.sectionTitle3(); + sink.anchor("detail_actions_" + configProvider.getName()); sink.text(getText("report.detail.actions.title")); + sink.anchor_(); sink.sectionTitle3_(); sink.lineBreak(); @@ -239,9 +214,9 @@ class ReportRenderer extends AbstractMavenReportRenderer { sink.section2_(); } - private void renderOptionDefsTable(ApplicationConfigProvider configProvider, Collection<ConfigOptionDef> options) { + private void renderOptionDefsTable(ConfigOptionDef... options) { - if (options.isEmpty()) { + if (options.length == 0) { sink.paragraph(); sink.bold(); @@ -256,36 +231,22 @@ class ReportRenderer extends AbstractMavenReportRenderer { sinkHeaderCellText(getText("report.config.option.key")); sinkHeaderCellText(getText("report.config.option.description")); - if (!optionWithDetail) { - sinkHeaderCellText(getText("report.config.option.type")); - } sinkHeaderCellText(getText("report.config.option.defaultValue")); - - if (!optionWithDetail) { - sinkHeaderCellText(getText("report.config.option.final")); - sinkHeaderCellText(getText("report.config.option.transient")); - } + sinkHeaderCellText(getText("report.config.option.final")); + sinkHeaderCellText(getText("report.config.option.transient")); + sinkHeaderCellText(getText("report.config.option.type")); sink.tableRow_(); for (ConfigOptionDef option : options) { sink.tableRow(); - if (optionWithDetail) { - sinkCellLink( - option.getKey(), - "detail_" + configProvider.getName() + "_" + option.getKey()); - } else { - sinkCellText(option.getKey()); - } + sinkCellText(option.getKey()); sinkCellText(l(locale, option.getDescription())); - if (!optionWithDetail) { - sinkCellText(option.getType().getName()); - } sinkCellVerbatimText(getDefaultValue(option)); - if (!optionWithDetail) { - sinkCellText(getText(!option.isFinal())); - sinkCellText(getText(!option.isTransient())); - } + sinkCellText(getText(!option.isFinal())); + sinkCellText(getText(!option.isTransient())); + sinkCellVerbatimText(option.getType().getName()); + sink.tableRow_(); } @@ -309,14 +270,16 @@ class ReportRenderer extends AbstractMavenReportRenderer { sink.table(); sink.tableRow(); - sinkHeaderCellText(getText("report.config.action.action")); + sinkHeaderCellText(getText("report.config.action.description")); sinkHeaderCellText(getText("report.config.action.aliases")); + sinkHeaderCellText(getText("report.config.action.action")); sink.tableRow_(); for (ConfigActionDef action : actions) { sink.tableRow(); + sinkCellText(l(locale, action.getDescription())); + sinkCellText(Joiner.on(",").join(action.getAliases())); sinkCellText(action.getAction()); - sinkCellText(l(locale, Arrays.toString(action.getAliases()))); sink.tableRow_(); } @@ -324,90 +287,6 @@ class ReportRenderer extends AbstractMavenReportRenderer { } } - private void renderProviderOptionDetail(ApplicationConfigProvider configProvider, - ConfigOptionDef option) { - - final SinkEventAttributes cellWidth = new SinkEventAttributeSet(); - cellWidth.addAttribute(SinkEventAttributes.WIDTH, "80%"); - - final SinkEventAttributes headerWidth = new SinkEventAttributeSet(); - headerWidth.addAttribute(SinkEventAttributes.WIDTH, "20%"); -// final String cellWidth = "80%"; -// final String headerWidth = "20%"; - - sink.section4(); - sink.sectionTitle4(); - sink.anchor("detail_" + configProvider.getName() + "_" + option.getKey()); - sink.text(getText("report.config.option.detail") + " '" + option.getKey() - + "'"); - sink.sectionTitle4_(); - sink.lineBreak(); - - sink.table(); - sink.tableRows(new int[]{Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false); - - sink.tableRow(); - sinkHeaderCellText(headerWidth, getText("report.config.option.key")); - sink.tableCell(cellWidth); - sink.nonBreakingSpace(); - sink.bold(); - sink.text(option.getKey()); - sink.bold_(); - sink.tableCell_(); - sink.tableRow_(); - - sink.tableRow(); - sinkHeaderCellText(headerWidth, getText("report.config.option.description")); - sink.tableCell(cellWidth); - sink.nonBreakingSpace(); - sink.text(l(locale, option.getDescription())); - sink.tableCell_(); - sink.tableRow_(); - - sink.tableRow(); - sinkHeaderCellText(headerWidth, getText("report.config.option.defaultValue")); - sink.tableCell(cellWidth); - sink.nonBreakingSpace(); - sink.bold(); - sink.text(getDefaultValue(option)); - sink.bold_(); - sink.tableCell_(); - sink.tableRow_(); - - sink.tableRow(); - sinkHeaderCellText(headerWidth, getText("report.config.option.type")); - sink.tableCell(cellWidth); - sink.nonBreakingSpace(); - sink.text(option.getType().getName()); - sink.tableCell_(); - sink.tableRow_(); - - sink.tableRow(); - sinkHeaderCellText(headerWidth, getText("report.config.option.final")); - sink.tableCell(cellWidth); - sink.nonBreakingSpace(); - sink.text(getText(!option.isFinal())); - sink.tableCell_(); - sink.tableRow_(); - - sink.tableRow(); - sinkHeaderCellText(headerWidth, getText("report.config.option.transient")); - sink.tableCell(cellWidth); - sink.nonBreakingSpace(); - sink.text(getText(!option.isTransient())); - sink.tableCell_(); - sink.tableRow_(); - - sink.table_(); - - sink.paragraph(); - sinkLinkToAnchor(getText("report.back.options.table"), "detail_options_" + configProvider.getName()); - sink.paragraph_(); - - sink.section4_(); - - } - private String getText(boolean key) { return getText("report." + String.valueOf(key)); } @@ -430,12 +309,6 @@ class ReportRenderer extends AbstractMavenReportRenderer { sink.tableHeaderCell_(); } - private void sinkHeaderCellText(SinkEventAttributes width, String text) { - sink.tableHeaderCell(width); - sink.text(text); - sink.tableHeaderCell_(); - } - private void sinkCellText(String text) { sink.tableCell(); sink.text(text); @@ -462,15 +335,4 @@ class ReportRenderer extends AbstractMavenReportRenderer { sink.link_(); } - private Collection<ConfigOptionDef> getOptions(ApplicationConfigProvider configProvider) { - List<ConfigOptionDef> result = new ArrayList<>(Arrays.asList(configProvider.getOptions())); - Collections.sort(result, new Comparator<ConfigOptionDef>() { - @Override - public int compare(ConfigOptionDef o1, - ConfigOptionDef o2) { - return o1.getKey().compareTo(o2.getKey()); - } - }); - return result; - } } diff --git a/nuiton-config-maven-plugin/src/main/resources/config-report.properties b/nuiton-config-maven-plugin/src/main/resources/config-report.properties index 6301781..7db4cd5 100644 --- a/nuiton-config-maven-plugin/src/main/resources/config-report.properties +++ b/nuiton-config-maven-plugin/src/main/resources/config-report.properties @@ -44,8 +44,12 @@ report.detail.title=Detail of configurations report.detail.text=We give details of each configuration of the project report.detail.configuration.title=Configuration report.detail.options.title=Configuration options +report.detail.options.details.title=Details of configuration's options report.detail.actions.title=Configuration actions report.detail.options.noOptions=No option found for this configuration report.detail.actions.noActions=No action found for this configuration +report.config.action.description=Description +report.config.action.aliases=Aliases +report.config.action.action=Action diff --git a/nuiton-config-maven-plugin/src/main/resources/config-report_fr.properties b/nuiton-config-maven-plugin/src/main/resources/config-report_fr.properties index 4d39419..5d01c59 100644 --- a/nuiton-config-maven-plugin/src/main/resources/config-report_fr.properties +++ b/nuiton-config-maven-plugin/src/main/resources/config-report_fr.properties @@ -44,6 +44,11 @@ report.detail.title=D\u00E9tail des configurations report.detail.text=On d\u00E9taille ici une par une les configurations d\u00E9finies pour le projet report.detail.configuration.title=Configuration report.detail.options.title=Options de la configuration +report.detail.options.details.title=Détails des options de la configuration report.detail.actions.title=Actions de la configuration report.detail.options.noOptions=Aucune option d\u00E9finie pour cette configuration report.detail.actions.noActions=Aucune action d\u00E9finie pour cette configuration + +report.config.action.description=Description +report.config.action.aliases=Aliases +report.config.action.action=Action -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository nuiton-config. See https://gitlab.nuiton.org/nuiton/nuiton-config.git commit 0267486eb865e039cf07cf71299d7c83a2d29be9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 18:09:05 2016 +0200 Depreciates Property change support in ApplicationConfig --- .../main/java/org/nuiton/config/ApplicationConfig.java | 17 +++++++++++++---- .../java/org/nuiton/config/SubApplicationConfig.java | 4 ++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java b/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java index 86411da..003e481 100644 --- a/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java +++ b/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java @@ -400,12 +400,16 @@ public class ApplicationConfig { * * @see #saveUserAction * @since 1.3 + * @deprecated since 3.1, we should no more use property change support on ApplicationConfig */ + @Deprecated private boolean adjusting; /** * suport of config modification. + * @deprecated since 3.1, we should no more use property change support on ApplicationConfig */ + @Deprecated protected PropertyChangeSupport pcs = new PropertyChangeSupport(this); /** @@ -2391,33 +2395,38 @@ public class ApplicationConfig { pcs.firePropertyChange(propertyName, oldValue, newValue); } + @Deprecated public void addPropertyChangeListener(PropertyChangeListener listener) { pcs.addPropertyChangeListener(listener); } - public void addPropertyChangeListener(String propertyName, - PropertyChangeListener listener) { + @Deprecated + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { pcs.addPropertyChangeListener(propertyName, listener); } + @Deprecated public void removePropertyChangeListener(PropertyChangeListener listener) { pcs.removePropertyChangeListener(listener); } - public void removePropertyChangeListener(String propertyName, - PropertyChangeListener listener) { + @Deprecated + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { pcs.removePropertyChangeListener(propertyName, listener); } + @Deprecated public boolean hasListeners(String propertyName) { return pcs.hasListeners(propertyName); } + @Deprecated public PropertyChangeListener[] getPropertyChangeListeners( String propertyName) { return pcs.getPropertyChangeListeners(propertyName); } + @Deprecated public PropertyChangeListener[] getPropertyChangeListeners() { return pcs.getPropertyChangeListeners(); } diff --git a/nuiton-config/src/main/java/org/nuiton/config/SubApplicationConfig.java b/nuiton-config/src/main/java/org/nuiton/config/SubApplicationConfig.java index 2d9590e..2d19bcd 100644 --- a/nuiton-config/src/main/java/org/nuiton/config/SubApplicationConfig.java +++ b/nuiton-config/src/main/java/org/nuiton/config/SubApplicationConfig.java @@ -158,6 +158,7 @@ public class SubApplicationConfig extends ApplicationConfig { return result; } + @Deprecated @Override protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { if (propertyName.startsWith(getPrefix())) { @@ -166,16 +167,19 @@ public class SubApplicationConfig extends ApplicationConfig { } // else not fire event } + @Deprecated @Override public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { getParent().addPropertyChangeListener(getPrefix() + propertyName, listener); } + @Deprecated @Override public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { getParent().removePropertyChangeListener(getPrefix() + propertyName, listener); } + @Deprecated @Override public boolean hasListeners(String propertyName) { return getParent().hasListeners(getPrefix() + propertyName); -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository nuiton-config. See https://gitlab.nuiton.org/nuiton/nuiton-config.git commit 59442b95ec7351a940e4b35ac703d6105485529c Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 18:33:52 2016 +0200 Add generatePropertyChangeSupport on generate mojo --- .../org/nuiton/config/plugin/GenerateMojo.java | 11 +++ .../templates/ApplicationConfigTransformer.java | 101 +++++++++++++++++++-- .../ApplicationConfigTransformerConfig.java | 2 + 3 files changed, 104 insertions(+), 10 deletions(-) diff --git a/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/GenerateMojo.java b/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/GenerateMojo.java index 2f2ae93..0b3e9b6 100644 --- a/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/GenerateMojo.java +++ b/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/GenerateMojo.java @@ -113,6 +113,12 @@ public class GenerateMojo extends ConfigMojoSupport implements ApplicationConfig private boolean generateProvider; /** + * To generate property change support on generated configuration class. + */ + @Parameter(property = "config.generatePropertyChangeSupport", defaultValue = "false") + private boolean generatePropertyChangeSupport; + + /** * To use nuiton-i18n API to translate descriptions in generate code. */ @Parameter(property = "config.useNuitonI18n") @@ -295,6 +301,11 @@ public class GenerateMojo extends ConfigMojoSupport implements ApplicationConfig } @Override + public boolean isGeneratePropertyChangeSupport() { + return generatePropertyChangeSupport; + } + + @Override public String getConfigProviderClassName() { return configProviderClassName; } diff --git a/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/templates/ApplicationConfigTransformer.java b/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/templates/ApplicationConfigTransformer.java index fa3ab97..34997d8 100644 --- a/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/templates/ApplicationConfigTransformer.java +++ b/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/templates/ApplicationConfigTransformer.java @@ -46,6 +46,8 @@ import org.nuiton.eugene.models.object.ObjectModelJavaModifier; import org.nuiton.eugene.models.object.ObjectModelOperation; import org.nuiton.i18n.I18n; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; @@ -142,7 +144,7 @@ public class ApplicationConfigTransformer extends ObjectModelTransformerToJava { if (log.isInfoEnabled()) { log.info("Generate " + output.getQualifiedName()); } - + for (OptionModel option : options) { String literalName = GeneratorUtil.convertVariableNameToConstantName(option.getName()); @@ -510,6 +512,7 @@ public class ApplicationConfigTransformer extends ObjectModelTransformerToJava { }*/ ); + boolean generatePropertyChangeSupport = config.isGeneratePropertyChangeSupport(); for (OptionModel option : options) { String attrName = option.getName(); @@ -520,14 +523,13 @@ public class ApplicationConfigTransformer extends ObjectModelTransformerToJava { addImport(output, attrType); createGetMethod(output, attrName, simpleType, constantName); - createSetMethod(output, attrName, simpleType, constantName); + createSetMethod(output, attrName, simpleType, constantName, generatePropertyChangeSupport); } ObjectModelOperation getConfigurationDescription = addOperation( - output, "getConfigurationDescription", String.class, ObjectModelJavaModifier.PUBLIC - ); - setOperationBody(getConfigurationDescription , "" + output, "getConfigurationDescription", String.class, ObjectModelJavaModifier.PUBLIC); + setOperationBody(getConfigurationDescription, "" /*{ StringBuilder builder = new StringBuilder(); builder.append("\\n====================================================================================================================="); @@ -542,9 +544,71 @@ public class ApplicationConfigTransformer extends ObjectModelTransformerToJava { }*/ ); + if (generatePropertyChangeSupport) { + + addAttribute(output, "pcs", PropertyChangeSupport.class, "new PropertyChangeSupport(this);", + ObjectModelJavaModifier.PROTECTED, ObjectModelJavaModifier.FINAL); + + ObjectModelOperation addPropertyChangeListener = addOperation( + output, "addPropertyChangeListener", "void", ObjectModelJavaModifier.PUBLIC); + addParameter(addPropertyChangeListener, PropertyChangeListener.class, "listener"); + setOperationBody(addPropertyChangeListener, "" + /*{ + pcs.addPropertyChangeListener(listener); + }*/ + ); + ObjectModelOperation addPropertyChangeListener2 = addOperation( + output, "addPropertyChangeListener", "void", ObjectModelJavaModifier.PUBLIC); + addParameter(addPropertyChangeListener2, String.class, "propertyName"); + addParameter(addPropertyChangeListener2, PropertyChangeListener.class, "listener"); + setOperationBody(addPropertyChangeListener2, "" + /*{ + pcs.addPropertyChangeListener(propertyName, listener); + }*/ + ); + + ObjectModelOperation removePropertyChangeListener = addOperation( + output, "removePropertyChangeListener", "void", ObjectModelJavaModifier.PUBLIC); + addParameter(removePropertyChangeListener, PropertyChangeListener.class, "listener"); + setOperationBody(removePropertyChangeListener, "" + /*{ + pcs.removePropertyChangeListener(listener); + }*/ + ); + ObjectModelOperation removePropertyChangeListener2 = addOperation( + output, "removePropertyChangeListener", "void", ObjectModelJavaModifier.PUBLIC); + addParameter(removePropertyChangeListener2, String.class, "propertyName"); + addParameter(removePropertyChangeListener2, PropertyChangeListener.class, "listener"); + setOperationBody(removePropertyChangeListener2, "" + /*{ + pcs.removePropertyChangeListener(propertyName, listener); + }*/ + ); + + ObjectModelOperation firePropertyChange = addOperation( + output, "firePropertyChange", "void", ObjectModelJavaModifier.PROTECTED); + addParameter(firePropertyChange, String.class, "propertyName"); + addParameter(firePropertyChange, Object.class, "oldValue"); + addParameter(firePropertyChange, Object.class, "newValue"); + setOperationBody(firePropertyChange, "" + /*{ + pcs.firePropertyChange(propertyName, oldValue, newValue); + }*/ + ); + + ObjectModelOperation firePropertyChange2 = addOperation( + output, "firePropertyChange", "void", ObjectModelJavaModifier.PROTECTED); + addParameter(firePropertyChange2, String.class, "propertyName"); + addParameter(firePropertyChange2, Object.class, "newValue"); + setOperationBody(firePropertyChange2, "" + /*{ + pcs.firePropertyChange(propertyName, null, newValue); + }*/ + ); + } + ObjectModelOperation orderedByKey = addOperation( - output, "orderedByKey", "List<" + optionClassSimpleName + ">", ObjectModelJavaModifier.PROTECTED - ); + output, "orderedByKey", "List<" + optionClassSimpleName + ">", ObjectModelJavaModifier.PROTECTED); addImport(output, List.class); addImport(output, Arrays.class); addImport(output, Collections.class); @@ -678,7 +742,8 @@ public class ApplicationConfigTransformer extends ObjectModelTransformerToJava { private void createSetMethod(ObjectModelClass output, String attrName, String simpleType, - String constantName) { + String constantName, + boolean generatePropertyChangeSupport) { boolean booleanProperty = GeneratorUtil.isBooleanPrimitive(simpleType); ObjectModelOperation operation = addOperation( output, @@ -690,11 +755,27 @@ public class ApplicationConfigTransformer extends ObjectModelTransformerToJava { String methodPrefix = booleanProperty ? JavaGeneratorUtil.OPERATION_GETTER_BOOLEAN_PREFIX : JavaGeneratorUtil.OPERATION_GETTER_DEFAULT_PREFIX; String methodName = getJavaBeanMethodName(methodPrefix, attrName); - setOperationBody(operation, "" + StringBuilder bodyContent = new StringBuilder(); + if (generatePropertyChangeSupport) { + bodyContent.append("" /*{ - setOption(<%=constantName%>.getKey(), <%=attrName%>); + Object oldValue = <%=methodName%>(); + }*/ + + ); + } + bodyContent.append("" + /*{ setOption(<%=constantName%>.getKey(), <%=attrName%>); }*/ ); + if (generatePropertyChangeSupport) { + bodyContent.append("" + /*{ firePropertyChange("<%=attrName%>", oldValue, <%=attrName%>); + }*/ + ); + } + + setOperationBody(operation, bodyContent.toString()); if ("Boolean".equals(simpleType)) { operation = addOperation( diff --git a/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/templates/ApplicationConfigTransformerConfig.java b/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/templates/ApplicationConfigTransformerConfig.java index 6571c2e..b21c86a 100644 --- a/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/templates/ApplicationConfigTransformerConfig.java +++ b/nuiton-config-maven-plugin/src/main/java/org/nuiton/config/plugin/templates/ApplicationConfigTransformerConfig.java @@ -42,6 +42,8 @@ public interface ApplicationConfigTransformerConfig { boolean isGenerateProvider(); + boolean isGeneratePropertyChangeSupport(); + boolean isUseNuitonI18n(); String getConfigProviderClassName(); -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository nuiton-config. See https://gitlab.nuiton.org/nuiton/nuiton-config.git commit c58a81a26c958e1f7bf15c1b90dcdeaaa1644e42 Merge: 5177df6 59442b9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 18:33:56 2016 +0200 Add propertyChangeSupport on generated configurations and depreciates PropertyChangeSupport on ApplicationConfig (Fixes #4061)" Merge branch 'feature/4061' into develop .../org/nuiton/config/plugin/GenerateMojo.java | 11 +++ .../templates/ApplicationConfigTransformer.java | 101 +++++++++++++++++++-- .../ApplicationConfigTransformerConfig.java | 2 + .../java/org/nuiton/config/ApplicationConfig.java | 17 +++- .../org/nuiton/config/SubApplicationConfig.java | 4 + 5 files changed, 121 insertions(+), 14 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository nuiton-config. See https://gitlab.nuiton.org/nuiton/nuiton-config.git commit 5b492912039a50d2af0ab9b5ac707ec7e7860db9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 18:52:26 2016 +0200 Add missing license headers --- .../config/io/ini/ApplicationConfigIOIni.java | 22 ++++++++++++++++++++++ .../config/io/ini/ApplicationConfigIOIniTest.java | 22 ++++++++++++++++++++++ .../org/nuiton/config/io/ApplicationConfigIO.java | 22 ++++++++++++++++++++++ .../config/io/ApplicationConfigIOHelper.java | 22 ++++++++++++++++++++++ .../config/io/ApplicationConfigReadFormat.java | 22 ++++++++++++++++++++++ .../ApplicationConfigReadPropertiesException.java | 22 ++++++++++++++++++++++ .../ApplicationConfigWritePropertiesException.java | 22 ++++++++++++++++++++++ .../properties/ApplicationConfigIOProperties.java | 22 ++++++++++++++++++++++ .../ApplicationConfigIOPropertiesTest.java | 22 ++++++++++++++++++++++ .../test/resources/NuitonConfigExample.properties | 21 +++++++++++++++++++++ 10 files changed, 219 insertions(+) diff --git a/nuiton-config-io-ini/src/main/java/org/nuiton/config/io/ini/ApplicationConfigIOIni.java b/nuiton-config-io-ini/src/main/java/org/nuiton/config/io/ini/ApplicationConfigIOIni.java index fd0ed9e..b4c33d6 100644 --- a/nuiton-config-io-ini/src/main/java/org/nuiton/config/io/ini/ApplicationConfigIOIni.java +++ b/nuiton-config-io-ini/src/main/java/org/nuiton/config/io/ini/ApplicationConfigIOIni.java @@ -1,5 +1,27 @@ package org.nuiton.config.io.ini; +/*- + * #%L + * Nuiton Config :: IO Ini + * %% + * Copyright (C) 2016 Code Lutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + import com.google.common.base.Joiner; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; diff --git a/nuiton-config-io-ini/src/test/java/org/nuiton/config/io/ini/ApplicationConfigIOIniTest.java b/nuiton-config-io-ini/src/test/java/org/nuiton/config/io/ini/ApplicationConfigIOIniTest.java index 024311c..5e9b9f5 100644 --- a/nuiton-config-io-ini/src/test/java/org/nuiton/config/io/ini/ApplicationConfigIOIniTest.java +++ b/nuiton-config-io-ini/src/test/java/org/nuiton/config/io/ini/ApplicationConfigIOIniTest.java @@ -1,5 +1,27 @@ package org.nuiton.config.io.ini; +/*- + * #%L + * Nuiton Config :: IO Ini + * %% + * Copyright (C) 2016 Code Lutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + import org.junit.Assert; import org.junit.Test; import org.nuiton.config.io.ApplicationConfigIO; diff --git a/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigIO.java b/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigIO.java index 25e9d24..859bc1e 100644 --- a/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigIO.java +++ b/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigIO.java @@ -1,5 +1,27 @@ package org.nuiton.config.io; +/*- + * #%L + * Nuiton Config :: API + * %% + * Copyright (C) 2016 Code Lutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + import java.io.File; import java.net.URL; import java.util.Properties; diff --git a/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigIOHelper.java b/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigIOHelper.java index ade5445..a81bf3b 100644 --- a/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigIOHelper.java +++ b/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigIOHelper.java @@ -1,5 +1,27 @@ package org.nuiton.config.io; +/*- + * #%L + * Nuiton Config :: API + * %% + * Copyright (C) 2016 Code Lutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + import com.google.common.base.Preconditions; import java.io.File; diff --git a/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigReadFormat.java b/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigReadFormat.java index d68d3af..12c8fe7 100644 --- a/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigReadFormat.java +++ b/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigReadFormat.java @@ -1,5 +1,27 @@ package org.nuiton.config.io; +/*- + * #%L + * Nuiton Config :: API + * %% + * Copyright (C) 2016 Code Lutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + /** * Le format de lecture des ficiers de configuration. */ diff --git a/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigReadPropertiesException.java b/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigReadPropertiesException.java index 113cef8..207599c 100644 --- a/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigReadPropertiesException.java +++ b/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigReadPropertiesException.java @@ -1,5 +1,27 @@ package org.nuiton.config.io; +/*- + * #%L + * Nuiton Config :: API + * %% + * Copyright (C) 2016 Code Lutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + /** * Created by tchemit on 07/10/16. * diff --git a/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigWritePropertiesException.java b/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigWritePropertiesException.java index 63d4195..57be719 100644 --- a/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigWritePropertiesException.java +++ b/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigWritePropertiesException.java @@ -1,5 +1,27 @@ package org.nuiton.config.io; +/*- + * #%L + * Nuiton Config :: API + * %% + * Copyright (C) 2016 Code Lutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + /** * Created by tchemit on 07/10/16. * diff --git a/nuiton-config/src/main/java/org/nuiton/config/io/properties/ApplicationConfigIOProperties.java b/nuiton-config/src/main/java/org/nuiton/config/io/properties/ApplicationConfigIOProperties.java index b0d6127..65c7b32 100644 --- a/nuiton-config/src/main/java/org/nuiton/config/io/properties/ApplicationConfigIOProperties.java +++ b/nuiton-config/src/main/java/org/nuiton/config/io/properties/ApplicationConfigIOProperties.java @@ -1,5 +1,27 @@ package org.nuiton.config.io.properties; +/*- + * #%L + * Nuiton Config :: API + * %% + * Copyright (C) 2016 Code Lutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + import org.nuiton.config.io.ApplicationConfigIO; import org.nuiton.config.io.ApplicationConfigReadFormat; import org.nuiton.config.io.ApplicationConfigReadPropertiesException; diff --git a/nuiton-config/src/test/java/org/nuiton/config/io/properties/ApplicationConfigIOPropertiesTest.java b/nuiton-config/src/test/java/org/nuiton/config/io/properties/ApplicationConfigIOPropertiesTest.java index 94436d7..e8577e7 100644 --- a/nuiton-config/src/test/java/org/nuiton/config/io/properties/ApplicationConfigIOPropertiesTest.java +++ b/nuiton-config/src/test/java/org/nuiton/config/io/properties/ApplicationConfigIOPropertiesTest.java @@ -1,5 +1,27 @@ package org.nuiton.config.io.properties; +/*- + * #%L + * Nuiton Config :: API + * %% + * Copyright (C) 2016 Code Lutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + import org.junit.Assert; import org.junit.Test; import org.nuiton.config.io.ApplicationConfigIO; diff --git a/nuiton-config/src/test/resources/NuitonConfigExample.properties b/nuiton-config/src/test/resources/NuitonConfigExample.properties index 3161b89..448d416 100644 --- a/nuiton-config/src/test/resources/NuitonConfigExample.properties +++ b/nuiton-config/src/test/resources/NuitonConfigExample.properties @@ -1,3 +1,24 @@ +### +# #%L +# Nuiton Config :: API +# %% +# Copyright (C) 2016 Code Lutin, Tony Chemit +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Lesser Public License for more details. +# +# You should have received a copy of the GNU General Lesser Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/lgpl-3.0.html>. +# #L% +### identity.firstName=Joshua identity.lastName=Bloch identity.age=56 -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository nuiton-config. See https://gitlab.nuiton.org/nuiton/nuiton-config.git commit 1a761edcc299da3af1e3862d493f50db3cedbcb9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Oct 7 18:58:53 2016 +0200 Remove guava from api dependency + optimize dependencies --- nuiton-config-io-ini/pom.xml | 11 +++++---- .../java/org/nuiton/config/ApplicationConfig.java | 27 +++++++++++----------- .../config/io/ApplicationConfigIOHelper.java | 10 ++++---- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/nuiton-config-io-ini/pom.xml b/nuiton-config-io-ini/pom.xml index ee920a3..e435d62 100644 --- a/nuiton-config-io-ini/pom.xml +++ b/nuiton-config-io-ini/pom.xml @@ -15,14 +15,10 @@ <description>Nuiton Config IO Ini</description> <inceptionYear>2016</inceptionYear> - <properties> - - </properties> - <dependencies> <dependency> - <groupId>org.nuiton</groupId> + <groupId>${project.groupId}</groupId> <artifactId>nuiton-config</artifactId> <version>${project.version}</version> </dependency> @@ -33,6 +29,11 @@ </dependency> <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> diff --git a/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java b/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java index 003e481..f594eb5 100644 --- a/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java +++ b/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java @@ -22,7 +22,6 @@ package org.nuiton.config; * #L% */ -import com.google.common.base.Preconditions; import org.apache.commons.beanutils.ConstructorUtils; import org.apache.commons.collections4.EnumerationUtils; import org.apache.commons.io.FileUtils; @@ -407,6 +406,7 @@ public class ApplicationConfig { /** * suport of config modification. + * * @deprecated since 3.1, we should no more use property change support on ApplicationConfig */ @Deprecated @@ -419,6 +419,7 @@ public class ApplicationConfig { /** * Pour gérer la lecture/écriture des properties. + * * @since 3.1 */ protected ApplicationConfigIOHelper applicationIOHelper; @@ -488,8 +489,8 @@ public class ApplicationConfig { */ protected void init(ApplicationConfigInit init) { - Preconditions.checkNotNull(init,"Can't init ApplicationConfig without an init paramter"); - Preconditions.checkNotNull(init.getReadFormat(), "Can't init Application without an init.readFormat parameter"); + if (init == null) throw new NullPointerException("Can't init ApplicationConfig without an init paramter"); + applicationIOHelper = new ApplicationConfigIOHelper(init.getReadFormat()); Set<ApplicationConfigScope> scopes = init.getScopes(); @@ -1957,7 +1958,7 @@ public class ApplicationConfig { // add a listener if (log.isDebugEnabled()) { log.debug("register saveUserAction on property [" + - propertyKey + ']'); + propertyKey + ']'); } addPropertyChangeListener(propertyKey, saveUserAction); } @@ -2181,7 +2182,7 @@ public class ApplicationConfig { for (URL inClasspath : urlsInClasspath) { if (log.isInfoEnabled()) { log.info("Loading configuration file (classpath) : " + - inClasspath); + inClasspath); } loadResource(inClasspath.toURI(), classpath); } @@ -2200,7 +2201,7 @@ public class ApplicationConfig { } else { if (log.isDebugEnabled()) { log.debug("No configuration file found in system : " + - etcConfig.getAbsolutePath()); + etcConfig.getAbsolutePath()); } } @@ -2217,13 +2218,13 @@ public class ApplicationConfig { if (homeConfig.exists()) { if (log.isInfoEnabled()) { log.info("Loading configuration file (home) : " + - homeConfig); + homeConfig); } loadResource(homeConfig.toURI(), homefile); } else { if (log.isDebugEnabled()) { log.debug("No configuration file found in user home : " + - homeConfig.getAbsolutePath()); + homeConfig.getAbsolutePath()); } } } @@ -2240,7 +2241,7 @@ public class ApplicationConfig { } else { if (log.isDebugEnabled()) { log.debug("No configuration file found in current" + - " directory : " + config.getAbsolutePath()); + " directory : " + config.getAbsolutePath()); } } } @@ -2460,8 +2461,8 @@ public class ApplicationConfig { } if (log.isDebugEnabled()) { log.debug("Saving configuration fired by property [" + - evt.getPropertyName() + "] at " + - new Date()); + evt.getPropertyName() + "] at " + + new Date()); } saveForUser(); } @@ -2545,8 +2546,8 @@ public class ApplicationConfig { protected <T> List<T> convertListOption(Class<T> type) { List<T> result = (List<T>) config.convertOption(type, key, - value, - true + value, + true ); return result; } diff --git a/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigIOHelper.java b/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigIOHelper.java index a81bf3b..92880e5 100644 --- a/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigIOHelper.java +++ b/nuiton-config/src/main/java/org/nuiton/config/io/ApplicationConfigIOHelper.java @@ -22,8 +22,6 @@ package org.nuiton.config.io; * #L% */ -import com.google.common.base.Preconditions; - import java.io.File; import java.net.URL; import java.util.Properties; @@ -40,7 +38,9 @@ public class ApplicationConfigIOHelper implements ApplicationConfigIO { private final ApplicationConfigIO delegate; public ApplicationConfigIOHelper(ApplicationConfigReadFormat readFormat) { - Preconditions.checkNotNull(readFormat, "Can't init with null readFormat"); + if (readFormat == null) { + throw new NullPointerException("Can't init with null readFormat"); + } ServiceLoader<ApplicationConfigIO> loader = ServiceLoader.load(ApplicationConfigIO.class); ApplicationConfigIO delegate = null; for (ApplicationConfigIO applicationConfigIO : loader) { @@ -48,7 +48,9 @@ public class ApplicationConfigIOHelper implements ApplicationConfigIO { delegate = applicationConfigIO; } } - Preconditions.checkState(delegate != null, "Could not find ApplicationConfigIO implementation for format: " + readFormat); + if (delegate == null) { + throw new IllegalStateException("Could not find ApplicationConfigIO implementation for format: " + readFormat); + } this.delegate = delegate; } -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm