org.universAAL.middleware.container.osgi
Class uAALBundleContext

Package class diagram package uAALBundleContext
java.lang.Object
  extended by org.universAAL.middleware.container.osgi.uAALBundleContext
All Implemented Interfaces:
ModuleContext

public class uAALBundleContext
extends Object
implements ModuleContext

An implementation of the concept of ModuleContext for OSGi.

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 fetchObject(String className)
           
 Object[] fetchObject(String className, String filter)
           
 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
 uAALBundleContext installBundle(String location)
           
 uAALBundleContext installBundle(String location, InputStream is)
           
 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 removesharedObject(String[] xface, Object obj, Dictionary props)
           
 void removeSharedObject(String xface, Object obj, Dictionary props)
           
 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.
 void shareObject(String[] xface, Object obj, Dictionary props)
           
 void shareObject(String xface, Object obj, Dictionary props)
           
 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
 

Method Detail

canBeStarted

public boolean canBeStarted(ModuleContext requester)
Description copied from interface: ModuleContext
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
See Also:
ModuleContext.canBeStarted(org.universAAL.middleware.container.ModuleContext)

canBeStopped

public boolean canBeStopped(ModuleContext requester)
Description copied from interface: ModuleContext
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
See Also:
ModuleContext.canBeStopped(org.universAAL.middleware.container.ModuleContext)

canBeUninstalled

public boolean canBeUninstalled(ModuleContext requester)
Description copied from interface: ModuleContext
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
See Also:
ModuleContext.canBeUninstalled(org.universAAL.middleware.container.ModuleContext)

fetchObject

public Object fetchObject(String className)

fetchObject

public Object[] fetchObject(String className,
                            String filter)

getAttribute

public Object getAttribute(String attrName)
Description copied from interface: ModuleContext
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
See Also:
ModuleContext.getAttribute(java.lang.String)

getContainer

public Container getContainer()
Description copied from interface: ModuleContext
Returns the Container object that conatin the module associated with this ModuleContext.

Specified by:
getContainer in interface ModuleContext
See Also:
ModuleContext.getContainer()

getID

public String getID()
Specified by:
getID in interface ModuleContext

installBundle

public uAALBundleContext installBundle(String location)

installBundle

public uAALBundleContext installBundle(String location,
                                       InputStream is)

listConfigFiles

public File[] listConfigFiles(ModuleContext requester)
Description copied from interface: ModuleContext
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
See Also:
ModuleContext.listConfigFiles(org.universAAL.middleware.container.ModuleContext)

logDebug

public void logDebug(String tag,
                     String message,
                     Throwable t)
Description copied from interface: ModuleContext
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
See Also:
org.universAAL.middleware.container.ModuleContext#logDebug(java.lang.String, java.lang.Throwable)

logError

public void logError(String tag,
                     String message,
                     Throwable t)
Description copied from interface: ModuleContext
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
See Also:
org.universAAL.middleware.container.ModuleContext#logError(java.lang.String, java.lang.Throwable)

logInfo

public void logInfo(String tag,
                    String message,
                    Throwable t)
Description copied from interface: ModuleContext
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
See Also:
org.universAAL.middleware.container.ModuleContext#logInfo(java.lang.String, java.lang.Throwable)

logWarn

public void logWarn(String tag,
                    String message,
                    Throwable t)
Description copied from interface: ModuleContext
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
See Also:
org.universAAL.middleware.container.ModuleContext#logWarn(java.lang.String, java.lang.Throwable)

logTrace

public void logTrace(String tag,
                     String message,
                     Throwable t)
Description copied from interface: ModuleContext
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
See Also:
org.universAAL.middleware.container.ModuleContext#logTrace(java.lang.String, java.lang.Throwable)

registerConfigFile

public void registerConfigFile(Object[] configFileParams)
Description copied from interface: ModuleContext
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
See Also:
ModuleContext.registerConfigFile(java.lang.Object[])

setAttribute

public void setAttribute(String attrName,
                         Object attrValue)
Description copied from interface: ModuleContext
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
See Also:
ModuleContext.setAttribute(java.lang.String, java.lang.Object)

shareObject

public void shareObject(String xface,
                        Object obj,
                        Dictionary props)

shareObject

public void shareObject(String[] xface,
                        Object obj,
                        Dictionary props)

removesharedObject

public void removesharedObject(String[] xface,
                               Object obj,
                               Dictionary props)

removeSharedObject

public void removeSharedObject(String xface,
                               Object obj,
                               Dictionary props)

start

public boolean start(ModuleContext requester)
Description copied from interface: ModuleContext
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
See Also:
ModuleContext.start(org.universAAL.middleware.container.ModuleContext)

stop

public boolean stop(ModuleContext requester)
Description copied from interface: ModuleContext
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
See Also:
ModuleContext.stop(org.universAAL.middleware.container.ModuleContext)

uninstall

public boolean uninstall(ModuleContext requester)
Description copied from interface: ModuleContext
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
See Also:
ModuleContext.uninstall(org.universAAL.middleware.container.ModuleContext)

getProperty

public Object getProperty(String name)
Description copied from interface: ModuleContext
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)
Description copied from interface: ModuleContext
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.