org.universAAL.container.JUnit
Class JUnitModuleContext

Package class diagram package JUnitModuleContext
java.lang.Object
  extended by org.universAAL.container.JUnit.JUnitModuleContext
All Implemented Interfaces:
ModuleContext

public class JUnitModuleContext
extends Object
implements ModuleContext

Author:
amedrano

Constructor Summary
JUnitModuleContext()
           
JUnitModuleContext(ModuleActivator ma)
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JUnitModuleContext

public JUnitModuleContext(ModuleActivator ma)

JUnitModuleContext

public JUnitModuleContext()
Method Detail

canBeStarted

public 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.

Specified by:
canBeStarted in interface ModuleContext

canBeStopped

public 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.

Specified by:
canBeStopped in interface ModuleContext

canBeUninstalled

public 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.

Specified by:
canBeUninstalled in interface ModuleContext

getAttribute

public 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.

Specified by:
getAttribute in interface ModuleContext

getContainer

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

Specified by:
getContainer in interface ModuleContext

getID

public String getID()

Specified by:
getID in interface ModuleContext

listConfigFiles

public 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.

Specified by:
listConfigFiles in interface ModuleContext

logDebug

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

Specified by:
logDebug in interface ModuleContext
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

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

Specified by:
logError in interface ModuleContext
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

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

Specified by:
logInfo in interface ModuleContext
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

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

Specified by:
logWarn in interface ModuleContext
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

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

Specified by:
logTrace in interface ModuleContext
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

public 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.

Specified by:
registerConfigFile in interface ModuleContext

setAttribute

public 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.

Specified by:
setAttribute in interface ModuleContext

start

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

Specified by:
start in interface ModuleContext

stop

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

Specified by:
stop in interface ModuleContext

uninstall

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

Specified by:
uninstall in interface ModuleContext

getProperty

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

Specified by:
getProperty in interface ModuleContext
Parameters:
name - the name of the property requested
Returns:
the current value of the requested property, it returns null if no property set

getProperty

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

Specified by:
getProperty in interface ModuleContext
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

getManifestEntry

public String getManifestEntry(String name)
Description copied from interface: ModuleContext
Get the value of an entry from the manifest of this module.

Specified by:
getManifestEntry in interface ModuleContext
Parameters:
name - the name of the manifest entry.
Returns:
the value of the manifest entry.

getManifestEntry

public String getManifestEntry(String manifest,
                               String name)
Description copied from interface: ModuleContext
Get the value of an entry from a custom manifest of this module.

Specified by:
getManifestEntry in interface ModuleContext
Parameters:
manifest - identification of the custom manifest.
name - the name of the manifest entry.
Returns:
the value of the manifest entry.


Copyright © 2014 universAAL Consortium. All Rights Reserved.