Class CompositionManager
- java.lang.Object
-
- de.uni_trier.wi2.procake.utils.composition.CompositionManager
-
public class CompositionManager extends Object
The composition manager binds possible implementation of a factory to a factory. The definition is done in a XML file, defined by composition.dtd.The factories must implement the
Factory
interface and the implementations must implement theFactoryObjectImplementation
.Usage: The usage is quite simple:
CompositionManager compo = new CompositionManager(); compo.setConfigrationFile("application.comp"); compo.build();
An example definition file looks like this:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Composition SYSTEM "composition.dtd"> <Composition> <Factory name="logger" class="cake.logger.LoggerFactory"> <Implementation class="cake.logger.log4j_1_2_8.Log4JLogger"> <Parameter value="config" name="resources/jrelogger.conf"/> </Implementation> </Factory> <Factory name="util_multilanguag" class="cake.utils.multilanguage.MessageFormatterFactory"> <Implementation class="cake.utils.multilanguage.jdk1_4.MessageFormatter"> <Parameter value="locale" name="de"/> </Implementation> </Factory> </Composition>
- Author:
- rmaximi
- See Also:
FactoryObjectImplementation
,Factory
-
-
Constructor Summary
Constructors Constructor Description CompositionManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CakeInstanceCache
build()
Builds the system.CakeInstanceCache
build(FactoryConfiguration configuration)
Builds the system.void
setConfigurationFile(String pathComposition)
void
setConfigurationSource(InputSource configurationSource)
-
-
-
Method Detail
-
build
public CakeInstanceCache build()
Builds the system. First, the configuation file is loaded and second, the implementations are assigned to the factories. It is necessary to first callsetConfigurationFile(String)
.- Returns:
- A cache containing the built factories and the implementations
-
build
public CakeInstanceCache build(FactoryConfiguration configuration)
Builds the system. The given configuration is used to assign the specified implementations to the factories.- Parameters:
configuration
- The build configuration.- Returns:
- A cache containing the built factories and the implementations
-
setConfigurationSource
public void setConfigurationSource(InputSource configurationSource)
- Parameters:
configurationSource
- The configuration file that is necessary forbuild()
.
-
setConfigurationFile
public void setConfigurationFile(String pathComposition)
-
-