org.opensubsystems.core.logic
Class ControllerManager

java.lang.Object
  extended by org.opensubsystems.core.logic.ControllerManager
Direct Known Subclasses:
J2EEControllerManager

public class ControllerManager
extends java.lang.Object

Class responsible for instantiation of controllers. This class determines what controller should be used based on currently used component model, creates the controller instance if it wasn't created yet and caches created instances. This of course assumes that the controllers are implemented to be stateless and reentrant.

Version:
$Id: ControllerManager.java,v 1.11 2007/01/07 06:15:14 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
1.9 2006/04/05 04:58:16 bastafidli

Field Summary
protected  ClassFactory m_controllerClassFactory
          Class factory used to instantiate controller.
 
Constructor Summary
ControllerManager()
          Default constructor.
 
Method Summary
 java.lang.Object getControllerInstance(java.lang.Class controller)
          Method to create actual controllers based on specified class.
static java.lang.Object getInstance(java.lang.Class controller)
          Create controller for specified class.
static ControllerManager getManagerInstance()
          Get the default instance.
static void setManagerInstance(ControllerManager defaultInstance)
          Set default instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_controllerClassFactory

protected ClassFactory m_controllerClassFactory
Class factory used to instantiate controller.

Constructor Detail

ControllerManager

public ControllerManager()
Default constructor.

Method Detail

getInstance

public static java.lang.Object getInstance(java.lang.Class controller)
                                    throws OSSException
Create controller for specified class.

Parameters:
controller - - the controller interface for which we want applicable controller. This is usually component model independent class and we will try to create dependent class.
Returns:
DataFactory - the controller to use for given interface
Throws:
OSSException - - an error has occured

getManagerInstance

public static ControllerManager getManagerInstance()
                                            throws OSSException
Get the default instance. This method is here to make the controller manager configurable. Once can specify in configuration file derived class to used instead of this one [ControllerManager.class]=new class to use.

Returns:
ControllerManager
Throws:
OSSException - - cannot get current database

setManagerInstance

public static void setManagerInstance(ControllerManager defaultInstance)
Set default instance. This instance will be returned by getInstance method until it is changed.

Parameters:
defaultInstance - - new default instance
See Also:
getInstance(java.lang.Class)

getControllerInstance

public java.lang.Object getControllerInstance(java.lang.Class controller)
                                       throws OSSException
Method to create actual controllers based on specified class. This method can be overriden and new manager can be setup either through setManagerInstance or through configuration file if different strategy is desired.

Parameters:
controller - - the controller interface for which we want applicable controller. This is usually component model independent class and we will try to create dependent class.
Returns:
DataFactory - the data factory to use for given interface
Throws:
OSSException - - an error has occured


Copyright © 2003 - 2006 OpenSubsystems s.r.o.