org.universAAL.middleware.container
Interface ModuleContext

Package class diagram package ModuleContext
All Known Implementing Classes:
JUnitModuleContext, uAALBundleContext

public interface ModuleContext

Represents the container-specific context of modules that either build up the universAAL platform or use this platform. Its design is inspired by the OSGi life-cycle as well as container-specific general-purpose code in the alpha release of the universAAL middleware, and the requirements of the AAL Space Admin Gateway with regard to node-level admin.

Version:
$LastChangedRevision$ ( $LastChangedDate$ )
Author:
mtazari, Stefano Lenzi

Method Summary
 boolean canBeStarted(ModuleContext requester)
          Returns true if (1) the associated module has a status equivalent to the OSGi ACTIVE , (2) it fulfills all prerequisites for being started, and (3) the given requester is allowed to start it.
 boolean canBeStopped(ModuleContext requester)
          Returns true if (1) the associated module would respond to a stop request (cf. the OSGi Bundle State ACTIVE ), and (2) the given requester is allowed to stop it.
 boolean canBeUninstalled(ModuleContext requester)
          Returns true if (1) the associated module is in a state equivalent to the OSGi Bundle States INSTALLED or RESOLVED, and (2) the given requester is allowed to uninstall it.
 Object getAttribute(String attrName)
          Returns the value associated with a certain attribute that has been set previously by a component that has access to this module context.
 Container getContainer()
          Returns the Container object that conatin the module associated with this ModuleContext.
 String getID()
           
 String getManifestEntry(String name)
          Get the value of an entry from the manifest of this module.
 String getManifestEntry(String manifest, String name)
          Get the value of an entry from a custom manifest of this module.
 Object getProperty(String name)
          Return the current value of an property or properties that is defined in this container
 Object getProperty(String name, Object def)
          Return the current value of an attribute or properties that is defined in this container
 File[] listConfigFiles(ModuleContext requester)
          Returns the list of all config files associated with this module that follow the container conventions and have been registered previously, if the given requester is allowed to access them.
 void logDebug(String tag, String message, Throwable t)
          Provides a standard way for using container-specific loggers, in this case for logging debug messages.
 void logError(String tag, String message, Throwable t)
          Provides a standard way for using container-specific loggers, in this case for logging error messages.
 void logInfo(String tag, String message, Throwable t)
          Provides a standard way for using container-specific loggers, in this case for logging info messages.
 void logTrace(String tag, String message, Throwable t)
          Provides a standard way for using container-specific loggers, in this case for logging trace messages.
 void logWarn(String tag, String message, Throwable t)
          Provides a standard way for using container-specific loggers, in this case for logging warnings.
 void registerConfigFile(Object[] configFileParams)
          Modules can use this method of their context to enrich it with info about those config files of them that follow the container conventions.
 void setAttribute(String attrName, Object attrValue)
          Concrete containers can use this possibility to enrich the module context with container-specific additional info that has not been introduced by this interface.
 boolean start(ModuleContext requester)
          An authorized requester can use this method to start the current module.
 boolean stop(ModuleContext requester)
          An authorized requester can use this method to stop the current module.
 boolean uninstall(ModuleContext requester)
          An authorized requester can use this method to uninstall the current module.
 

Method Detail

canBeStarted

boolean canBeStarted(ModuleContext requester)
Returns true if (1) the associated module has a status equivalent to the OSGi ACTIVE , (2) it fulfills all prerequisites for being started, and (3) the given requester is allowed to start it. Otherwise, it returns false. Note: Confer the OSGi Bundle State RESOLVED with regard to the first two conditions above.


canBeStopped

boolean canBeStopped(ModuleContext requester)
Returns true if (1) the associated module would respond to a stop request (cf. the OSGi Bundle State ACTIVE ), and (2) the given requester is allowed to stop it. Otherwise, it returns false.


canBeUninstalled

boolean canBeUninstalled(ModuleContext requester)
Returns true if (1) the associated module is in a state equivalent to the OSGi Bundle States INSTALLED or RESOLVED, and (2) the given requester is allowed to uninstall it. Otherwise, it returns false.


getAttribute

Object getAttribute(String attrName)
Returns the value associated with a certain attribute that has been set previously by a component that has access to this module context. It provides means for specifying container-specific additional info that has not been introduced by this interface.


getContainer

Container getContainer()
Returns the Container object that conatin the module associated with this ModuleContext.


getID

String getID()

listConfigFiles

File[] listConfigFiles(ModuleContext requester)
Returns the list of all config files associated with this module that follow the container conventions and have been registered previously, if the given requester is allowed to access them.


logDebug

void logDebug(String tag,
              String message,
              Throwable t)
Provides a standard way for using container-specific loggers, in this case for logging debug messages.

Parameters:
tag - the log tag, for example the tag of android.util.Log
message - the log message
t - An optional Throwable object like an exception that might have caused the log request

logError

void logError(String tag,
              String message,
              Throwable t)
Provides a standard way for using container-specific loggers, in this case for logging error messages.

Parameters:
tag - the log tag, for example the tag of android.util.Log
message - the log message
t - An optional Throwable object like an exception that might have caused the log request

logInfo

void logInfo(String tag,
             String message,
             Throwable t)
Provides a standard way for using container-specific loggers, in this case for logging info messages.

Parameters:
tag - the log tag, for example the tag of android.util.Log
message - the log message
t - An optional Throwable object like an exception that might have caused the log request

logWarn

void logWarn(String tag,
             String message,
             Throwable t)
Provides a standard way for using container-specific loggers, in this case for logging warnings.

Parameters:
tag - the log tag, for example the tag of android.util.Log
message - the log message
t - An optional Throwable object like an exception that might have caused the log request

logTrace

void logTrace(String tag,
              String message,
              Throwable t)
Provides a standard way for using container-specific loggers, in this case for logging trace messages.

Parameters:
tag - the log tag, for example the tag of android.util.Log
message - the log message
t - An optional Throwable object like an exception that might have caused the log request

registerConfigFile

void registerConfigFile(Object[] configFileParams)
Modules can use this method of their context to enrich it with info about those config files of them that follow the container conventions. Only registered config files are supposed to be editable by standard admin tools that are planned to be developed by universAAL.


setAttribute

void setAttribute(String attrName,
                  Object attrValue)
Concrete containers can use this possibility to enrich the module context with container-specific additional info that has not been introduced by this interface.


start

boolean start(ModuleContext requester)
An authorized requester can use this method to start the current module. Returns true if canBeStarted(ModuleContext) returns true AND the start action does not lead to any unexpected problem, otherwise false.


stop

boolean stop(ModuleContext requester)
An authorized requester can use this method to stop the current module. Returns true if canBeStopped(ModuleContext) returns true AND the stop action does not lead to any unexpected problem, otherwise false.


uninstall

boolean uninstall(ModuleContext requester)
An authorized requester can use this method to uninstall the current module. Returns true if canBeUninstalled(ModuleContext) returns true AND the uninstall action does not lead to any unexpected problem, otherwise false.


getProperty

Object getProperty(String name)
Return the current value of an property or properties that is defined in this container

Parameters:
name - the name of the property requested
Returns:
the current value of the requested property, it returns null if no property set
Since:
1.3.2

getProperty

Object getProperty(String name,
                   Object def)
Return the current value of an attribute or properties that is defined in this container

Parameters:
name - the name of the property requested
def - the default value to return in case that the property is not set
Returns:
the current value of the requested property
Since:
1.3.2

getManifestEntry

String getManifestEntry(String name)
Get the value of an entry from the manifest of this module.

Parameters:
name - the name of the manifest entry.
Returns:
the value of the manifest entry.
Since:
2.0.1

getManifestEntry

String getManifestEntry(String manifest,
                        String name)
Get the value of an entry from a custom manifest of this module.

Parameters:
manifest - identification of the custom manifest.
name - the name of the manifest entry.
Returns:
the value of the manifest entry.
Since:
2.0.1


Copyright © 2014 universAAL Consortium. All Rights Reserved.