Package org.apache.turbine.services
Class BaseInitableBroker
- java.lang.Object
-
- org.apache.turbine.services.BaseInitableBroker
-
- All Implemented Interfaces:
InitableBroker
public abstract class BaseInitableBroker extends Object implements InitableBroker
A generic implementation ofInitableBroker
. 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
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseInitableBroker()
Default constructor of InitableBroker.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Initable
getInitable(String className)
Provides an instance of Initable class ready to work.protected Initable
getInitableInstance(String className)
Retrieves an instance of an Initable from the repository.void
initClass(String className, Object data)
Performs early initialization of an Initable class.void
shutdownClass(String className)
Shuts down anInitable
.
-
-
-
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
-
initClass
public void initClass(String className, Object data) throws InitializationException
Performs early initialization of an Initable class.- Specified by:
initClass
in interfaceInitableBroker
- Parameters:
className
- The name of the class to be initialized.data
- An Object to be used for initialization activities.- Throws:
InitializationException
- Initialization was not successful.
-
shutdownClass
public void shutdownClass(String className)
Shuts down anInitable
. This method is used to release resources allocated by anInitable
, and return it to its initial (uninitialized) state.- Specified by:
shutdownClass
in interfaceInitableBroker
- 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 interfaceInitableBroker
- 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.
-
-