org.universAAL.middleware.container.osgi
Class uAALBundleContainer

Package class diagram package uAALBundleContainer
java.lang.Object
  extended by org.universAAL.middleware.container.osgi.uAALBundleContainer
All Implemented Interfaces:
EventListener, org.osgi.framework.ServiceListener, Container

public class uAALBundleContainer
extends Object
implements Container, org.osgi.framework.ServiceListener

An implementation of the concept of Container for OSGi.

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

Field Summary
static uAALBundleContainer THE_CONTAINER
           
 
Method Summary
 Object fetchSharedObject(ModuleContext requester, Object[] fetchParams)
          Returns an object previously shared by another module for usage within this container.
 Object[] fetchSharedObject(ModuleContext requester, Object[] fetchParams, SharedObjectListener listener)
          Returns an object previously shared by another module for usage within this container.
 ModuleContext installModule(ModuleContext requester, Object[] installParams)
          Provides possibility for programmatically installing (downloaded) modules.
 Iterator logListeners()
          Returns an Iterator object over all registered instances of LogListener.
 ModuleContext registerModule(Object[] regParams)
          Provides possibility for wrapping container-specific context for a module in terms of an instance of the universAAL ModuleContext.
 void removeSharedObject(ModuleContext requester, Object objToRemove, Object[] shareParams)
           
 void removeSharedObjectListener(SharedObjectListener listener)
          This method allows a SharedObjectListener instance to be removed from the list of listeners managed by this container
 void serviceChanged(org.osgi.framework.ServiceEvent se)
           
 void shareObject(ModuleContext requester, Object objToShare, Object[] shareParams)
          Makes a given object accessible for the other modules hosted by this container.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THE_CONTAINER

public static final uAALBundleContainer THE_CONTAINER
Method Detail

fetchSharedObject

public Object fetchSharedObject(ModuleContext requester,
                                Object[] fetchParams)
Description copied from interface: Container
Returns an object previously shared by another module for usage within this container.

Specified by:
fetchSharedObject in interface Container
Parameters:
fetchParams -
  • min length = 1, max used length is 2 (elements @ index 2+ are ignored)
  • type of both elements must be String
  • if element @ index 0 is null, there must be a not-null String object @ index 1
  • if length = 1, then element @ index 0 must be not-null
  • if length = 1, then BundleContext.getServiceReference(String) will be used to fetch a service object
  • if length > 1, then BundleContext.getServiceReferences(String, String) will be used to fetch the first service object from the returned array
requester - The module in the context of which the shared object is going to be used.
Returns:
if the given requester is an instance of uAALBundleContext and a ServiceReference has been found according to the explanations given for fetchParams, then the result of calling BundleContext.getService(ServiceReference) will be returned.
See Also:
Container.fetchSharedObject(ModuleContext, Object[], SharedObjectListener)

fetchSharedObject

public Object[] fetchSharedObject(ModuleContext requester,
                                  Object[] fetchParams,
                                  SharedObjectListener listener)
Description copied from interface: Container
Returns an object previously shared by another module for usage within this container.

Specified by:
fetchSharedObject in interface Container
Parameters:
requester - The module in the context of which the shared object is going to be used.
fetchParams - Container-specific parameters for fetching shared objects.
listener - If not null, the listener will be notified asynchronously each time a new matching object is shared within this container.

installModule

public ModuleContext installModule(ModuleContext requester,
                                   Object[] installParams)
Description copied from interface: Container
Provides possibility for programmatically installing (downloaded) modules.

Specified by:
installModule in interface Container
Parameters:
installParams -
  • min length = 1, max used length is 2 (elements @ index 2+ are ignored)
  • type of element @ index 0 must be String (mandatory)
  • if existing, type of element @ index 1 must be InputStream
  • if length = 1, then BundleContext.installBundle(String) will be used to install the given bundle
  • if length > 1, then BundleContext.installBundle(String, java.io.InputStream) will be used to install the given bundle
requester - The module requesting the installation; only an certain modules should be allowed to install modules on the fly
Returns:
a newly created instance of uAALBundleContext that wraps the newly installed bundle if the given requester is an instance of uAALBundleContext, the conditions on installParams hold, and the installation is successful, null otherwise.
See Also:
Container.installModule(org.universAAL.middleware.container.ModuleContext, java.lang.Object[])

logListeners

public Iterator logListeners()
Description copied from interface: Container
Returns an Iterator object over all registered instances of LogListener.

Specified by:
logListeners in interface Container
See Also:
Container.logListeners()

registerModule

public ModuleContext registerModule(Object[] regParams)
Description copied from interface: Container
Provides possibility for wrapping container-specific context for a module in terms of an instance of the universAAL ModuleContext.

Specified by:
registerModule in interface Container
Parameters:
regParams - element @ index 0 must exist and be an instance of BundleContext
Returns:
an instance of uAALBundleContext if the conditions for regParams hold, null otherwise
See Also:
Container.registerModule(java.lang.Object[])

serviceChanged

public void serviceChanged(org.osgi.framework.ServiceEvent se)
Specified by:
serviceChanged in interface org.osgi.framework.ServiceListener
See Also:
ServiceListener.serviceChanged(org.osgi.framework.ServiceEvent)

shareObject

public void shareObject(ModuleContext requester,
                        Object objToShare,
                        Object[] shareParams)
Description copied from interface: Container
Makes a given object accessible for the other modules hosted by this container.

Specified by:
shareObject in interface Container
Parameters:
shareParams -
  • min length = 1, no upper limit
  • all elements (except for an optional last one - see next bullet) must be instances of String; these strings specify the interfaces that the objToShare has implemented (cf. BundleContext.registerService(String[], Object, java.util.Dictionary) ).
  • optionally, a last element can be an instance of Dictionary; it can be used for property-based search of shared objects (cf. BundleContext.registerService(String[], Object, java.util.Dictionary) ).
requester - The module in the context of which the shared object is going to be used.
objToShare - The actual object to be shared.
See Also:
Container.shareObject(org.universAAL.middleware.container.ModuleContext, java.lang.Object, java.lang.Object[])

removeSharedObject

public void removeSharedObject(ModuleContext requester,
                               Object objToRemove,
                               Object[] shareParams)

removeSharedObjectListener

public void removeSharedObjectListener(SharedObjectListener listener)
Description copied from interface: Container
This method allows a SharedObjectListener instance to be removed from the list of listeners managed by this container

Specified by:
removeSharedObjectListener in interface Container
Parameters:
listener - the SharedObjectListener to be removed


Copyright © 2014 universAAL Consortium. All Rights Reserved.