Class 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 Factoryinterface and the implementations must implement the FactoryObjectImplementation.

    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 Detail

      • CompositionManager

        public CompositionManager()
    • 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 call setConfigurationFile(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 for build().
      • setConfigurationFile

        public void setConfigurationFile​(String pathComposition)