Framework Professional Edition Package


org.mbs.services.cu.generator
Class TokenControlUnit

java.lang.Object
  extended by org.mbs.services.cu.generator.ServiceObject
      extended by org.mbs.services.cu.generator.DefaultControlUnit
          extended by org.mbs.services.cu.generator.TokenControlUnit
All Implemented Interfaces:
TimerListener, ControlConstants, ControlUnit, ManagedControlUnit

public class TokenControlUnit
extends DefaultControlUnit
implements TimerListener

This class extends the DefaultControlUnit to implement Access Token Mechanism for concurrent access to the control unit.

Since:
$Date: 2006/04/18 13:16:34 $
Author:
Stoyan Zoubev

Field Summary
static java.lang.String ACTION_CHECK
           
static java.lang.String ACTION_LOCK
           
static java.lang.String ACTION_UNLOCK
           
static java.lang.Integer MIN_PRIORITY
           
static java.lang.String SVAR_TOKEN_ID
           
static java.lang.String SVAR_TOKEN_PRIORITY
           
static long TOKEN_EXPIRATION_VALUE
           
protected  java.lang.String tokenId
           
protected  java.lang.Integer tokenPriority
           
 
Fields inherited from class org.mbs.services.cu.generator.DefaultControlUnit
ACTION_PREFIX, CHECK_INPUT, controller, controllerMethods, model
 
Fields inherited from interface org.mbs.services.cu.ControlConstants
CONSTRUCTOR_PREFIX, DESTRUCTOR, EVENT_FILTER, EVENT_SYNC, EVENT_TYPE, FINDER_PREFIX, ID, PARENT_ID, PARENT_ROOT, PARENT_TYPE, STATE_VARIABLE_ID, SV_LIST_SV_ID, TYPE, VERSION
 
Constructor Summary
TokenControlUnit(ControlUnitModel model, java.lang.Object controller)
           
 
Method Summary
 boolean check(java.lang.String lockId, int lockPriority)
           
 java.lang.Object invokeAction(java.lang.String actionId, java.lang.Object args)
          Executes the specified action over this control unit.
 void lock(java.lang.String tokenId, java.lang.Integer tokenPriority)
           
static void setTimer(Timer timer)
           
static void setTokenExpiration(long millis)
           
 void timer(int event)
          Token timer has expired, so unlock the control unit.
 void unlock(java.lang.String tokenId, java.lang.Integer tokenPriority)
           
 
Methods inherited from class org.mbs.services.cu.generator.DefaultControlUnit
checkActionInputArguments, fillDefaultProperties, getId, getType, queryStateVariable, release, setControlUnitCallback
 
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

TOKEN_EXPIRATION_VALUE

public static final long TOKEN_EXPIRATION_VALUE
See Also:
Constant Field Values

MIN_PRIORITY

public static final java.lang.Integer MIN_PRIORITY

SVAR_TOKEN_ID

public static final java.lang.String SVAR_TOKEN_ID
See Also:
Constant Field Values

SVAR_TOKEN_PRIORITY

public static final java.lang.String SVAR_TOKEN_PRIORITY
See Also:
Constant Field Values

ACTION_CHECK

public static final java.lang.String ACTION_CHECK
See Also:
Constant Field Values

ACTION_LOCK

public static final java.lang.String ACTION_LOCK
See Also:
Constant Field Values

ACTION_UNLOCK

public static final java.lang.String ACTION_UNLOCK
See Also:
Constant Field Values

tokenId

protected java.lang.String tokenId

tokenPriority

protected java.lang.Integer tokenPriority
Constructor Detail

TokenControlUnit

public TokenControlUnit(ControlUnitModel model,
                        java.lang.Object controller)
Method Detail

invokeAction

public java.lang.Object invokeAction(java.lang.String actionId,
                                     java.lang.Object args)
                              throws java.lang.Exception
Description copied from interface: ControlUnit
Executes the specified action over this control unit. Actions supported by a control unit and the number and types of the input and output arguments of each action are defined by the metadata of the control unit.

Specified by:
invokeAction in interface ControlUnit
Overrides:
invokeAction in class DefaultControlUnit
Parameters:
actionId - the id of the action
args - 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 occurs while executing action.
java.lang.IllegalArgumentException - if this control unit does not have action with the supplied Id or the arguments number and/or types do not match the action arguments.
See Also:
org.msb.services.cu.ControlUnit#invokeAction(java.lang.String, java.lang.Object)

check

public boolean check(java.lang.String lockId,
                     int lockPriority)

lock

public void lock(java.lang.String tokenId,
                 java.lang.Integer tokenPriority)

unlock

public void unlock(java.lang.String tokenId,
                   java.lang.Integer tokenPriority)

setTimer

public static void setTimer(Timer timer)

setTokenExpiration

public static void setTokenExpiration(long millis)

timer

public void timer(int event)
Token timer has expired, so unlock the control unit.

Specified by:
timer in interface TimerListener
Parameters:
event - the event code which is supplied when this listener had been registered
See Also:
TimerListener.timer(int)

Framework Professional Edition Package


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