i3.dragos.core.runmode
Class RunModeController

java.lang.Object
  extended by i3.dragos.core.runmode.RunModeController
All Implemented Interfaces:
KernelModule

public class RunModeController
extends java.lang.Object
implements KernelModule

The RunModeController enables the user to ponder between safety and speed of the DRAGOS system. This class provides a number of switches which may be switched on and off by applications. In general, disabling all switches results in a 'safe' system with many runtime checks. When enabling switches, Dragos waives some saftey checks and in general performs better. However, inconsistencies may occur in the runimte graph. Users should only use this module when they are perfectly sure about the consequences. For performance reasons, the number of switches available is thightly limited. From the 32 switches totally availabe, the 12 lowest ones are reserved for system use. Extensions may reserve switches above for their own purposes.

Author:
Erhard Weinell <Weinell@cs.rwth-aachen.de>

Field Summary
static int MAX_RUNMODE
          maximal runmode switch identifier overall
static int MIN_SYSTEM_RUNMODE
          minimal runmode switch identifier overall
static int MIN_USER_RUNMODE
          minimal runmode switch identifier for use by extensions
 
Constructor Summary
RunModeController()
           
 
Method Summary
static RunModeController getInstance()
          Returns the one and only instance of the RunModeController.
 java.lang.String getRole()
          Returns the kernel module's role.
 RunMode getRunMode()
          retreives the actual run mode instance.
 void initialize()
          Initializes the kernel module.
 boolean isRunModeSwitchReserved(int runModeSwitchID)
          Tests whether a certain RunModeSwitch is already reserved.
static boolean isValueEnabledDefault(int value)
          Conveinence methd, short for RunModeController.getInstance().getRunMode().isValueEnabled(int).
 boolean releaseRunModeSwitch(int runModeSwitchID, java.lang.Class<? extends ExtensionDescriptor> requester)
          Releases a previously reserved switch given by its identifier.
 boolean reserveRunModeSwitch(int runModeSwitchID, java.lang.Class<? extends ExtensionDescriptor> requester)
          Reserves a switch given by its identifier for a certain class,e.g. a VersionDescriptor.
 void uninitialize()
          Uninitializes the kernel module and releases all resources used by it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_SYSTEM_RUNMODE

public static final int MIN_SYSTEM_RUNMODE
minimal runmode switch identifier overall

See Also:
Constant Field Values

MIN_USER_RUNMODE

public static final int MIN_USER_RUNMODE
minimal runmode switch identifier for use by extensions

See Also:
Constant Field Values

MAX_RUNMODE

public static final int MAX_RUNMODE
maximal runmode switch identifier overall

See Also:
Constant Field Values
Constructor Detail

RunModeController

public RunModeController()
Method Detail

getInstance

public static RunModeController getInstance()
Returns the one and only instance of the RunModeController. As looking up the controller by its role name is quite expensive and the Dragos Kernel is a singleton object, the RunModeController is a singleton object as well. This method does not create a new instance if none is active. Instead, the controller has to be started using the ModuleManager. This module is automatically loaded by the Dragos Kernel.

Returns:
The only instance of the RunModeController, or null if not active

getRole

public java.lang.String getRole()
Returns the kernel module's role.

Specified by:
getRole in interface KernelModule
Returns:
the kernel module's role.

initialize

public void initialize()
Initializes the kernel module.

Specified by:
initialize in interface KernelModule

uninitialize

public void uninitialize()
Uninitializes the kernel module and releases all resources used by it.

Specified by:
uninitialize in interface KernelModule

getRunMode

public RunMode getRunMode()
retreives the actual run mode instance.

Returns:
the actual run mode instance.

reserveRunModeSwitch

public boolean reserveRunModeSwitch(int runModeSwitchID,
                                    java.lang.Class<? extends ExtensionDescriptor> requester)
Reserves a switch given by its identifier for a certain class,e.g. a VersionDescriptor.

Parameters:
runModeSwitchID - the switch to reserve
requester - the class to reserve the switch for, e.g. a VersionDescriptor
Returns:
true if the switch has been reserved or was already reserved for the given requester. false if the switch is reserved to another class.

releaseRunModeSwitch

public boolean releaseRunModeSwitch(int runModeSwitchID,
                                    java.lang.Class<? extends ExtensionDescriptor> requester)
Releases a previously reserved switch given by its identifier.

Parameters:
runModeSwitchID - the switch to release
requester - the class to reserve the switch for, e.g. an ExtensionDescriptor
Returns:
true if the switch had been reserved for the requester and therefore has been released. false if the switch had been reserved by another class or not at all.

isRunModeSwitchReserved

public boolean isRunModeSwitchReserved(int runModeSwitchID)
Tests whether a certain RunModeSwitch is already reserved.

Parameters:
runModeSwitchID - the runmode switch to test, must be >= MIN_USER_RUNMODE and <= MAX_RUNMODE.
Returns:
true if the switch is reserved by an extension or belongs to system space, false otherwise.

isValueEnabledDefault

public static boolean isValueEnabledDefault(int value)
Conveinence methd, short for RunModeController.getInstance().getRunMode().isValueEnabled(int).

Parameters:
value - switch to test
Returns:
true if the switch is enabled, false otherwise.


Copyright © 2002-2008 RWTH Aachen, Department of Computer Science 3 (Software Engineering). All Rights Reserved.