Framework Professional Edition Package


org.mbs.services.cu.generator
Class DefaultControlUnitFactory

java.lang.Object
  extended by org.mbs.services.cu.generator.ServiceObject
      extended by org.mbs.services.cu.generator.DefaultControlUnitFactory
All Implemented Interfaces:
ControlUnitFactory

public class DefaultControlUnitFactory
extends ServiceObject
implements ControlUnitFactory

This is the default implementation of ControlUnitFactory interface.

Since:
$Date: 2005/07/28 12:10:19 $
Author:
Stoyan Zoubev

Field Summary
protected  CUAdminCallback callback
           
protected  java.lang.String type
           
 
Constructor Summary
DefaultControlUnitFactory(java.lang.String type)
           
 
Method Summary
protected  void addControlUnit(ControlUnit controlUnit)
          This method should be called if a new control unit should be provided by the factory.
 java.lang.String createControlUnit(java.lang.String constructorId, java.lang.Object arguments)
          Always returns null.
 void destroyControlUnit(java.lang.String controlUnitId)
          Does nothing.
protected  void fillDefaultProperties(java.util.Dictionary props)
          This method is invoked when service is registed.
protected  ControlUnit findControlUnit(java.lang.String controlUnitId)
          Returns the control unit object with the given id.
 java.lang.String[] findControlUnits(java.lang.String finderId, java.lang.Object arguments)
          Returns always null.
 ControlUnit getControlUnit(java.lang.String controlUnitId)
          Returns the ControlUnit object, identified by the given id.
 java.lang.String[] getControlUnits(java.lang.String parentType, java.lang.String parentId)
          Returns ids of the control unit instances which are children of a control unit with a given type and id.
 java.lang.String[] getParents(java.lang.String childId, java.lang.String parentType)
          Returns the ids of the parents of a given control unit specified by its id.
 java.lang.String[] getParentTypes(java.lang.String childId)
           
 java.lang.String getType()
           
 java.lang.Object invokeAction(java.lang.String controlUnitId, java.lang.String actionId, java.lang.Object arguments)
          Executes the specified action over a control unit with specified id.
 java.lang.String[] listControlUnits()
          Returns the ids of all control units currently exported by this factory.
 java.lang.Object queryStateVariable(java.lang.String controlUnitId, java.lang.String varId)
          Queries a control unit with a specified id for the value of the specified state variable.
protected  void removeControlUnit(ControlUnit controlUnit)
          This method should be called if a control unit should be provided no more by the factory.
protected  void removeControlUnit(java.lang.String controlUnitId)
          This method should be called if a control unit should be provided no more by the factory.
 void setControlUnitCallback(CUAdminCallback callback)
          Supplies the Control Unit admin callback interface to the implementation of the ControlUnitFactory service.
 
Methods inherited from class org.mbs.services.cu.generator.ServiceObject
registerService, unregisterService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

protected java.lang.String type

callback

protected CUAdminCallback callback
Constructor Detail

DefaultControlUnitFactory

public DefaultControlUnitFactory(java.lang.String type)
Method Detail

setControlUnitCallback

public void setControlUnitCallback(CUAdminCallback callback)
Description copied from interface: ControlUnitFactory
Supplies the Control Unit admin callback interface to the implementation of the ControlUnitFactory service.
This method is invoked by the Control Unit Admin bundle with a non-null argument after registration of the ControlUnitFactory service or after startup of the Control Unit Admin for already registered factories.
It is supposed that the Control Unit Factory will assign this reference to a instance variable and use it later to notify the Control Unit Admin for creation or removal or Control Unit instances, attaching/detaching of Control Units to/from given parent and for changes in state variables.
The method is invoked with a null argument during unregistration of the ControlUnitFactory service or when the Control Unit Admin is stopped.

Specified by:
setControlUnitCallback in interface ControlUnitFactory
Parameters:
callback - reference to the control unit callback interface or null if previously set reference is not longer valid.
See Also:
org.msb.services.cu.spi.ControlUnitFactory#setControlUnitCallback(org.msb.services.cu.spi.CUAdminFactoryCallback)

getType

public java.lang.String getType()
See Also:
org.msb.services.cu.spi.ControlUnitFactory#getType()

getControlUnit

public ControlUnit getControlUnit(java.lang.String controlUnitId)
Description copied from interface: ControlUnitFactory
Returns the ControlUnit object, identified by the given id. If there is no such control unit maintained by this factory, null is returned.

Specified by:
getControlUnit in interface ControlUnitFactory
Parameters:
controlUnitId - the id of the requested control unit
Returns:
ControlUnit object with the given id.
See Also:
ControlUnitFactory.getControlUnit(java.lang.String)

getControlUnits

public java.lang.String[] getControlUnits(java.lang.String parentType,
                                          java.lang.String parentId)
Description copied from interface: ControlUnitFactory
Returns ids of the control unit instances which are children of a control unit with a given type and id. Supplying null as arguments to this method results in returning only control units exported by this factory which have no parent.

Specified by:
getControlUnits in interface ControlUnitFactory
Parameters:
parentType - type of the parent control unit
parentId - id of the parent control unit
Returns:
the sub-control units of the specified control unit.
See Also:
org.msb.services.cu.spi.ControlUnitFactory#getControlUnits(java.lang.String, java.lang.String)

queryStateVariable

public java.lang.Object queryStateVariable(java.lang.String controlUnitId,
                                           java.lang.String varId)
Description copied from interface: ControlUnitFactory
Queries a control unit with a specified id for the value of the specified state variable.

Specified by:
queryStateVariable in interface ControlUnitFactory
Parameters:
controlUnitId - the id of the control unit provided by this factory
varId - the id of the variable
Returns:
value of the variable
See Also:
org.msb.services.cu.spi.ControlUnitFactory#queryStateVariable(java.lang.String, java.lang.String)

invokeAction

public java.lang.Object invokeAction(java.lang.String controlUnitId,
                                     java.lang.String actionId,
                                     java.lang.Object arguments)
                              throws java.lang.Exception
Description copied from interface: ControlUnitFactory
Executes the specified action over a control unit with specified id.

Specified by:
invokeAction in interface ControlUnitFactory
Parameters:
controlUnitId - the id of the control unit
actionId - the id of the action
arguments - the input argument(s). If the argument is only one this is the argument itself. If the arguments are more then one, the value must be a Object[] and arguments are retrieved from that array.
Returns:
the output argument(s) or null if the action does not return value.
Throws:
java.lang.Exception - if an error occures while executing action.
java.lang.IllegalArgumentException - if this factory does not have action with the supplied Id or the arguments number and/or types do not match the action arguments.
See Also:
ControlUnitFactory.invokeAction(java.lang.String, java.lang.String, java.lang.Object)

createControlUnit

public java.lang.String createControlUnit(java.lang.String constructorId,
                                          java.lang.Object arguments)
Always returns null. Default implementation does not allow creation of control units.

Specified by:
createControlUnit in interface ControlUnitFactory
Parameters:
constructorId - the id of the constructors. Must start with "$create.".
arguments - - the 'constructors' argument(s). If the argument is only one this is the argument itself. If the arguments are more then one, the value must be a Object[] and arguments are retrieved from that array.
Returns:
the id of the newly created control unit.
See Also:
ControlUnitFactory.createControlUnit(java.lang.String, java.lang.Object)

destroyControlUnit

public void destroyControlUnit(java.lang.String controlUnitId)
Does nothing. Default implementation does not allow creation/destroying of control units.

Specified by:
destroyControlUnit in interface ControlUnitFactory
Parameters:
controlUnitId - control unit id.
See Also:
ControlUnitFactory.destroyControlUnit(java.lang.String)

findControlUnits

public java.lang.String[] findControlUnits(java.lang.String finderId,
                                           java.lang.Object arguments)
Returns always null.

Specified by:
findControlUnits in interface ControlUnitFactory
Parameters:
finderId - the id of the finder method. Must start with "$find.".
arguments - the finder argument(s). If the argument is only one this is the argument itself. If the arguments are more then one, the value must be a Object[] and arguments are retrieved from that array.
Returns:
the sub-control units of the specified control unit.
See Also:
org.msb.services.cu.spi.ControlUnitFactory#findControlUnits(java.lang.String, java.lang.Object)

findControlUnit

protected ControlUnit findControlUnit(java.lang.String controlUnitId)
Returns the control unit object with the given id. Throws IllegalArgumentException if such control unit is not found. So null is not possible return value.


addControlUnit

protected void addControlUnit(ControlUnit controlUnit)
This method should be called if a new control unit should be provided by the factory.

Parameters:
controlUnit - control unit to be registered to factory

removeControlUnit

protected void removeControlUnit(ControlUnit controlUnit)
This method should be called if a control unit should be provided no more by the factory.

Parameters:
controlUnit - control unit to be removed
IllegalArgumentException - thrown if given control unit is not provided by the factory

removeControlUnit

protected void removeControlUnit(java.lang.String controlUnitId)
This method should be called if a control unit should be provided no more by the factory.

Parameters:
controlUnitId - id of the control unit to be removed
IllegalArgumentException - thrown if given control unit is not provided by the factory

fillDefaultProperties

protected void fillDefaultProperties(java.util.Dictionary props)
Description copied from class: ServiceObject
This method is invoked when service is registed. The implementation of the method should put the necessary properties in the given props dictionary. For control units these default properties are type and id.

Specified by:
fillDefaultProperties in class ServiceObject
Parameters:
props - dictionary where default properties are stored.
See Also:
ServiceObject.fillDefaultProperties(java.util.Dictionary)

listControlUnits

public java.lang.String[] listControlUnits()
Description copied from interface: ControlUnitFactory
Returns the ids of all control units currently exported by this factory.

Specified by:
listControlUnits in interface ControlUnitFactory
Returns:
control unit ids or null, if the factory exports no units
See Also:
ControlUnitFactory.listControlUnits()

getParentTypes

public java.lang.String[] getParentTypes(java.lang.String childId)
See Also:
org.mbs.services.cu.spi.ControlUnitFactory#getParentTypes(java.lang.String)

getParents

public java.lang.String[] getParents(java.lang.String childId,
                                     java.lang.String parentType)
Description copied from interface: ControlUnitFactory
Returns the ids of the parents of a given control unit specified by its id. This method returns only ids of the control units for a specified parent type.

Specified by:
getParents in interface ControlUnitFactory
Parameters:
childId - id of the child unit
parentType - type of the returned parent units
Returns:
ids of parent units or null, if the given control unit has no parents of the specified type
See Also:
ControlUnitFactory.getParents(java.lang.String, java.lang.String)

Framework Professional Edition Package


Copyright © 1999-2007 ProSyst Software GmbH. All Rights Reserved