Class BaseInitableBroker

  • All Implemented Interfaces:
    InitableBroker

    public abstract class BaseInitableBroker
    extends Object
    implements InitableBroker
    A generic implementation of InitableBroker. Functionality provided by the broker includes:
    • Maintaining single instance of each Initable in the system.
    • Early initialization of Initables during system startup.
    • Late initialization of Initables before they are used.
    • Providing instances of Initables to requesting parties.
    • Maintaining dependencies between Initables during early initialization phases, including circular dependencies detection.
    Version:
    $Id$
    Author:
    Kevin Burton, Rafal Krzewski, Henning P. Schmiedehausen
    • Field Detail

      • stack

        protected Stack<String> stack
        Names of classes being early-initialized are pushed onto this stack. A name appearing twice indicates a circular dependency chain.
    • Constructor Detail

      • BaseInitableBroker

        protected BaseInitableBroker()
        Default constructor of InitableBroker. This constructor does nothing. Your brokers should be singletons, therefore their constructors should be private. They should also have public YourBroker getInstance() methods.
    • Method Detail

      • shutdownClass

        public void shutdownClass​(String className)
        Shuts down an Initable. This method is used to release resources allocated by an Initable, and return it to its initial (uninitialized) state.
        Specified by:
        shutdownClass in interface InitableBroker
        Parameters:
        className - The name of the class to be uninitialized.
      • getInitable

        public Initable getInitable​(String className)
                             throws InstantiationException
        Provides an instance of Initable class ready to work. If the requested class couldn't be instantiated or initialized, an InstantiationException will be thrown. You needn't handle this exception in your code, since it indicates fatal misconfiguration of the system.
        Specified by:
        getInitable in interface InitableBroker
        Parameters:
        className - The name of the Initable requested.
        Returns:
        An instance of the requested Initable.
        Throws:
        InstantiationException - if there was a problem during instantiation or initialization of the Initable.
      • getInitableInstance

        protected Initable getInitableInstance​(String className)
                                        throws InstantiationException
        Retrieves an instance of an Initable from the repository. If the requested class is not present in the repository, it is instantiated and passed a reference to the broker, saved and then returned.
        Parameters:
        className - The name of the class to be instantiated.
        Returns:
        an instance of the requested class
        Throws:
        InstantiationException - if the requested class can't be instantiated.