Forum

Forum Navigation
You need to log in to create posts and topics.

How to configure ComponentContainer?

How to do this?

The configuration of this type of container can be done via Properties file or programmatically via a Properties object. If you use the singleton instance obtained via ComponentContainer.getInstance() method, you must create a burningwave.properties file and put it on base path of your classpath project. The default configuration automatically loaded if no configuration file is found is the following:

paths.main-class-paths.extension=//${system.properties:java.home}/lib//children:.*\.jar|.*\.jmod;//${system.properties:java.home}/lib/ext//children:.*\.jar|.*\.jmod;//${system.properties:java.home}/jmods//children:.*\.jar|.*\.jmod;
paths.class-factory.default-class-loader.class-repositories=${paths.class-factory.java-memory-compiler.class-repositories};
paths.class-factory.java-memory-compiler.class-repositories=${classPaths};${paths.main-class-paths.extension};
class-factory.default-class-loader=Thread.currentThread().getContextClassLoader()
class-hunter.path-scanner-class-loader.parent=Thread.currentThread().getContextClassLoader()

If in your custom burningwave.properties file one of this four default properties is not found, the relative default value is assumed.

If you create a component container instance through method ComponentContainer.create(String relativeConfigFileName), you can specify the file name of your properties file and you can locate it everywhere in your classpath project but remember to use a relative path in this case, i.e.: if you name your file “custom-config-file.properties” and put it in package “org.burningwave” you must create the component container as follow: ComponentContainer.create("org/burningwave/custom-config-file.properties")

Here an example of a burningwave.properties file with all settable properties with all configurable properties:

paths.main-class-paths.extension=//${system.properties:java.home}/lib//children:.*\.jar|.*\.jmod;//${system.properties:java.home}/lib/ext//children:.*\.jar|.*\.jmod;//${system.properties:java.home}/jmods//children:.*\.jar|.*\.jmod;
class-hunter.path-scanner-class-loader.parent=Thread.currentThread().getContextClassLoader()
#this is the default class loader used by method
#org.burningwave.core.classes.ClassFactory.buildAndLoadOrUpload(UnitSourceGenerator... unitsCode)
#(see "Generating classes at runtime and invoking their methods with and without use of the reflection" example)
class-factory.default-class-loader=Thread.currentThread().getContextClassLoader()
paths.class-factory.java-memory-compiler.class-repositories=${classPaths};${paths.main-class-paths.extension};
paths.class-factory.default-class-loader.class-repositories=${paths.class-factory.java-memory-compiler.class-repositories};
#other possible values are: checkFileSignature, checkFileName|checkFileSignature, checkFileName&checkFileSignature
java-memory-compiler.class-path-hunter.search-config.check-file-options=checkFileName
#other possible values are: checkFileSignature, checkFileName|checkFileSignature, checkFileName&checkFileSignature
class-hunter.path-scanner-class-loader.byte-code-hunter.search-config.check-file-options=checkFileName
#other possible values are: checkFileSignature, checkFileName|checkFileSignature, checkFileName&checkFileSignature
class-factory.byte-code-hunter.search-config.check-file-options=checkFileName
#The resources below can be retrieved through PathHelper component getPaths method. In this case you must call
#ComponentContainer.getInstance().getPathHelper().getPaths("your-custom-path1")
paths.your-custom-path1=C:/some-folder;C:/another-folder;