public class OSGiModuleContext extends Object implements ModuleContext
ModuleContext
for OSGi.Modifier and Type | Field and Description |
---|---|
static String |
CONF_ROOT_DIR
The root directory of the runtime configuration.
|
Modifier and Type | Method and Description |
---|---|
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. |
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.
|
File |
getConfigHome()
Get the Configuration Folder for this module.
|
Container |
getContainer()
Returns the
Container object that contains the module associated
with this ModuleContext. |
File |
getDataFolder()
Get the Data folder for this module, the general storage space where data
generated by the module should be stored.
|
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
|
OSGiModuleContext |
installBundle(String location) |
OSGiModuleContext |
installBundle(String location,
InputStream is) |
boolean |
isLogDebugEnabled()
Is the logger instance enabled for the DEBUG level?
|
boolean |
isLogErrorEnabled()
Is the logger instance enabled for the ERROR level?
|
boolean |
isLogInfoEnabled()
Is the logger instance enabled for the INFO level?
|
boolean |
isLogTraceEnabled()
Is the logger instance enabled for the TRACE level?
|
boolean |
isLogWarnEnabled()
Is the logger instance enabled for the WARN level?
|
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.
|
public static final String CONF_ROOT_DIR
public boolean canBeStarted(ModuleContext requester)
ModuleContext
RESOLVED
with regard to
the first two conditions above.canBeStarted
in interface ModuleContext
ModuleContext.canBeStarted(org.universAAL.middleware.container.ModuleContext)
public boolean canBeStopped(ModuleContext requester)
ModuleContext
stop
request (cf. the OSGi Bundle State ACTIVE
), and (2) the given requester is allowed to stop it. Otherwise, it
returns false.canBeStopped
in interface ModuleContext
ModuleContext.canBeStopped(org.universAAL.middleware.container.ModuleContext)
public boolean canBeUninstalled(ModuleContext requester)
ModuleContext
INSTALLED
or RESOLVED
, and
(2) the given requester is allowed to uninstall it. Otherwise, it returns
false.canBeUninstalled
in interface ModuleContext
ModuleContext.canBeUninstalled(org.universAAL.middleware.container.ModuleContext)
public Object getAttribute(String attrName)
ModuleContext
getAttribute
in interface ModuleContext
ModuleContext.getAttribute(java.lang.String)
public Container getContainer()
ModuleContext
Container
object that contains the module associated
with this ModuleContext.getContainer
in interface ModuleContext
ModuleContext.getContainer()
public String getID()
getID
in interface ModuleContext
public OSGiModuleContext installBundle(String location)
public OSGiModuleContext installBundle(String location, InputStream is)
public File[] listConfigFiles(ModuleContext requester)
ModuleContext
listConfigFiles
in interface ModuleContext
ModuleContext.listConfigFiles(org.universAAL.middleware.container.ModuleContext)
public void logDebug(String tag, String message, Throwable t)
ModuleContext
logDebug
in interface ModuleContext
tag
- the log tag, for example the tag of android.util.Logmessage
- the log messaget
- An optional Throwable
object like an exception that
might have caused the log requestorg.universAAL.middleware.container.ModuleContext#logDebug(java.lang.String,
java.lang.Throwable)
public void logError(String tag, String message, Throwable t)
ModuleContext
logError
in interface ModuleContext
tag
- the log tag, for example the tag of android.util.Logmessage
- the log messaget
- An optional Throwable
object like an exception that
might have caused the log requestorg.universAAL.middleware.container.ModuleContext#logError(java.lang.String,
java.lang.Throwable)
public void logInfo(String tag, String message, Throwable t)
ModuleContext
logInfo
in interface ModuleContext
tag
- the log tag, for example the tag of android.util.Logmessage
- the log messaget
- An optional Throwable
object like an exception that
might have caused the log requestorg.universAAL.middleware.container.ModuleContext#logInfo(java.lang.String,
java.lang.Throwable)
public void logWarn(String tag, String message, Throwable t)
ModuleContext
logWarn
in interface ModuleContext
tag
- the log tag, for example the tag of android.util.Logmessage
- the log messaget
- An optional Throwable
object like an exception that
might have caused the log requestorg.universAAL.middleware.container.ModuleContext#logWarn(java.lang.String,
java.lang.Throwable)
public void logTrace(String tag, String message, Throwable t)
ModuleContext
logTrace
in interface ModuleContext
tag
- the log tag, for example the tag of android.util.Logmessage
- the log messaget
- An optional Throwable
object like an exception that
might have caused the log requestorg.universAAL.middleware.container.ModuleContext#logTrace(java.lang.String,
java.lang.Throwable)
public void registerConfigFile(Object[] configFileParams)
ModuleContext
registerConfigFile
in interface ModuleContext
ModuleContext.registerConfigFile(java.lang.Object[])
public void setAttribute(String attrName, Object attrValue)
ModuleContext
setAttribute
in interface ModuleContext
ModuleContext.setAttribute(java.lang.String,
java.lang.Object)
public void shareObject(String xface, Object obj, Dictionary props)
public void shareObject(String[] xface, Object obj, Dictionary props)
public void removesharedObject(String[] xface, Object obj, Dictionary props)
public void removeSharedObject(String xface, Object obj, Dictionary props)
public boolean start(ModuleContext requester)
ModuleContext
ModuleContext.canBeStarted(ModuleContext)
returns true AND the
start action does not lead to any unexpected problem, otherwise false.start
in interface ModuleContext
ModuleContext.start(org.universAAL.middleware.container.ModuleContext)
public boolean stop(ModuleContext requester)
ModuleContext
ModuleContext.canBeStopped(ModuleContext)
returns true AND the
stop action does not lead to any unexpected problem, otherwise false.stop
in interface ModuleContext
ModuleContext.stop(org.universAAL.middleware.container.ModuleContext)
public boolean uninstall(ModuleContext requester)
ModuleContext
ModuleContext.canBeUninstalled(ModuleContext)
returns
true AND the uninstall action does not lead to any unexpected problem,
otherwise false.uninstall
in interface ModuleContext
ModuleContext.uninstall(org.universAAL.middleware.container.ModuleContext)
public Object getProperty(String name)
ModuleContext
getProperty
in interface ModuleContext
name
- the name of the property requestednull
if no property setpublic Object getProperty(String name, Object def)
ModuleContext
getProperty
in interface ModuleContext
name
- the name of the property requesteddef
- the default value to return in case that the property is not
setpublic String getManifestEntry(String name)
ModuleContext
getManifestEntry
in interface ModuleContext
name
- the name of the manifest entry.public String getManifestEntry(String manifest, String name)
ModuleContext
getManifestEntry
in interface ModuleContext
manifest
- identification of the custom manifest.name
- the name of the manifest entry.public File getConfigHome()
ModuleContext
getConfigHome
in interface ModuleContext
File
pointing to the correct configuration folder of
this module, The folder will be created for the module to use
directly.public File getDataFolder()
ModuleContext
getDataFolder
in interface ModuleContext
public boolean isLogErrorEnabled()
isLogErrorEnabled
in interface ModuleContext
public boolean isLogWarnEnabled()
isLogWarnEnabled
in interface ModuleContext
public boolean isLogInfoEnabled()
isLogInfoEnabled
in interface ModuleContext
public boolean isLogDebugEnabled()
isLogDebugEnabled
in interface ModuleContext
public boolean isLogTraceEnabled()
isLogTraceEnabled
in interface ModuleContext
Copyright © 2018 universAAL Consortium. All rights reserved.