org.apache.turbine.services
Class BaseInitableBroker

java.lang.Object
  |
  +--org.apache.turbine.services.BaseInitableBroker
All Implemented Interfaces:
InitableBroker
Direct Known Subclasses:
BaseServiceBroker

public abstract class BaseInitableBroker
extends java.lang.Object
implements InitableBroker

A generic implementation of InitableBroker. Functionality provided by the broker includes:

Version:
$Id: BaseInitableBroker.java,v 1.2 2002/07/11 16:53:29 mpoeschl Exp $
Author:
Kevin Burton, Rafal Krzewski

Field Summary
protected  java.util.Hashtable initables
          A repository of Initable instances.
protected  java.util.Stack stack
          Names of classes being early-initialized are pushed onto this stack.
 
Constructor Summary
protected BaseInitableBroker()
          Default constructor of InitableBorker.
 
Method Summary
 void error(java.lang.Throwable t)
          Output an error message.
 Initable getInitable(java.lang.String className)
          Provides an instance of Initable class ready to work.
protected  Initable getInitableInstance(java.lang.String className)
          Retrieves an instance of an Initable from the repository.
 void initClass(java.lang.String className, java.lang.Object data)
          Performs early initialization of an Initable class.
 void notice(java.lang.String msg)
          Output a diagnostic notice.
 void shutdownClass(java.lang.String className)
          Shuts down an Initable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initables

protected java.util.Hashtable initables
A repository of Initable instances.

stack

protected java.util.Stack 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 InitableBorker. 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(java.lang.String className,
                      java.lang.Object data)
               throws InitializationException
Performs early initialization of an Initable class.
Specified by:
initClass in interface InitableBroker
Parameters:
className - The name of the class to be initailized.
data - An Object to be used for initialization activities.
Throws:
InitializationException - Initialization was not successful.

shutdownClass

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

getInitable

public Initable getInitable(java.lang.String className)
                     throws InstantiationException
Provides an instance of Initable class ready to work. If the requested class couldn't be instatiated or initialized, an InstantiationException will be thrown. You needn't handle this exception in your code, since it indicates fatal misconfigurtion 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(java.lang.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.
Throws:
InstantiationException, - if the requested class can't be instantiated.

notice

public void notice(java.lang.String msg)
Output a diagnostic notice. This method is used by the service framework classes for producing tracing mesages that might be useful for debugging (newline terminated).

The default implementation uses system error stream. When writing your own, remeber to direct that message to the proper logging mechanism.

Parameters:
msg - the message to print.

error

public void error(java.lang.Throwable t)
Output an error message. This method is used by the service framework classes for displaying stacktraces of any exceptions that might be caught during processing.

The default implementation uses system error stream. When writing your own, remeber to direct that message to the proper logging mechanism.

Parameters:
msg - the message to print.


Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.