In the example for the magnolia module configuration in the documentation I am not sure why the private boolean colorsEnabled;
for the FooBar class is not in the YAML configuration. Where does the module configuration get the colorsEnabled
property from?
maxSize: 25
welcomeMessage: Hello world
fooBar:
colors: [red, green, blue]
Also the when I programmatically retrieve the List<String> list = fooBar.getColors();
I get null
for the list.
I am running Magnolia 5.7.9.
UPDATE:
My module class is done the same way as described in the documentation and the example described above.
public class XxxVersioning implements ModuleLifecycle {
private Excludes excludes;
public Excludes getExcludes() {
return excludes;
}
public void setExcludes(Excludes excludes) {
this.excludes = excludes;
}
public class Excludes {
private String red;
private String green;
public String getRed() {
return red;
}
public void setRed(String red) {
this.red = red;
}
public String getGreen() {
return green;
}
public void setGreen(String green) {
this.green = green;
}
}
I have a class that programmatically inquires if a string value is in the list. The the list appears to be null
.
/**
* Find if template name for the component in the module exception list
* @param String templateName
* @return Boolean true if templateName in the module exception-list
*/
public Boolean isComponentException(String templateName) {
// get the (singleton) instance of the module
// On the module class instance call the getter methods of the module bean properties.
XxxVersioning moduleInstance = xxxVersionProvider.get();
// access the modules RenderingExcludes bean
XxxVersioning.Excludes excludes = moduleInstance.getExcludes();
String green = excludes.getGreen();
return true;
}
SOLUTION: For bootstrapping I found the document [here][5] According to this document
All bootstrap files are only imported once!
Webapp-based bootstrap files are imported during the first run of the webapp when the Magnolia instance gets installed.
Module-based bootstrap files are imported during the installation of the module.
If you want to import bootstrap files on every start up of the Magnolia instance or of a module, you must use custom installation tasks which are executed by the Module version handler or Module start up classes.
FooBar class is not in the YAML configuration. Where does the module configuration get the colorsEnabled property from?
First YAML/FS is checked, then from the JCR configuration (config
workspace in the repo). Or if property of that name doesn't exist it would take the default value.
More on the order in which resources are checked here.
The list appears to be always null.
yes, because you override the value from yaml with the one in config workspace (or you have just one in the workspace and nothing in yaml?) and there you still write the property list in yaml format instead of using syntax appropriate for jcr (which would be contentNode
called excludes
with 4 properties under that node each being name/value pair representing the individual colors. Unfortunately documentation doesn't show how that differs so clearly so it's easy to make a mistake there.
Anyway, as a good practice you should choose where you will store your configuration - either in repo or in yaml. I would suggest yaml config in FS as it allows you to change the configuration from outside even if your app gets corrupted. Plus it's easier to keep that file in git or other VCS and have proper history of changes on it tracked.