|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.knopflerfish.framework.BundleContextImpl
public class BundleContextImpl
Implementation of the BundleContext object.
BundleContext
Constructor Summary | |
---|---|
BundleContextImpl(BundleImpl bundle)
Create a BundleContext for specified bundle. |
Method Summary | |
---|---|
void |
addBundleListener(BundleListener listener)
Add a bundle listener. |
void |
addFrameworkListener(FrameworkListener listener)
Add a framework listener. |
void |
addServiceListener(ServiceListener listener)
Add a service listener. |
void |
addServiceListener(ServiceListener listener,
java.lang.String filter)
Add a service listener with a filter. |
Filter |
createFilter(java.lang.String filter)
Constructs a Filter object. |
ServiceReference[] |
getAllServiceReferences(java.lang.String clazz,
java.lang.String filter)
Get a list of service references. |
Bundle |
getBundle()
Retrieve the Bundle object for the calling bundle. |
Bundle |
getBundle(long id)
Retrieve the bundle that has the given unique identifier. |
Bundle[] |
getBundles()
Retrieve a list of all installed bundles. |
java.io.File |
getDataFile(java.lang.String filename)
Creates a File object for a file in the persistent storage area provided for the bundle. |
java.lang.String |
getProperty(java.lang.String key)
Retrieve the value of the named environment property. |
java.lang.Object |
getService(ServiceReference reference)
Get the service object. |
ServiceReference |
getServiceReference(java.lang.String clazz)
Get a service reference. |
ServiceReference[] |
getServiceReferences(java.lang.String clazz,
java.lang.String filter)
Get a list of service references. |
Bundle |
installBundle(java.lang.String location)
Install a bundle from location. |
Bundle |
installBundle(java.lang.String location,
java.io.InputStream in)
Install a bundle from an InputStream. |
ServiceRegistration |
registerService(java.lang.String[] clazzes,
java.lang.Object service,
java.util.Dictionary properties)
Register a service with multiple names. |
ServiceRegistration |
registerService(java.lang.String clazz,
java.lang.Object service,
java.util.Dictionary properties)
Register a service with a single name. |
void |
removeBundleListener(BundleListener listener)
Remove a bundle listener. |
void |
removeFrameworkListener(FrameworkListener listener)
Remove a framework listener. |
void |
removeServiceListener(ServiceListener listener)
Remove a service listener. |
boolean |
ungetService(ServiceReference reference)
Unget the service object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BundleContextImpl(BundleImpl bundle)
Method Detail |
---|
public java.lang.String getProperty(java.lang.String key)
getProperty
in interface BundleContext
key
- The name of the requested property.
null
if
the property is undefined.BundleContext.getProperty(java.lang.String)
public Bundle installBundle(java.lang.String location) throws BundleException
installBundle
in interface BundleContext
location
- The location identifier of the bundle to install.
Bundle
object of the installed bundle.
BundleException
- If the installation failed.BundleContext.installBundle(java.lang.String)
public Bundle installBundle(java.lang.String location, java.io.InputStream in) throws BundleException
installBundle
in interface BundleContext
location
- The location identifier of the bundle to install.in
- The InputStream
object from which this bundle
will be read.
Bundle
object of the installed bundle.
BundleException
- If the provided stream cannot be read or the
installation failed.BundleContext.installBundle(java.lang.String)
public Bundle getBundle()
getBundle
in interface BundleContext
Bundle
object associated with this
BundleContext
.BundleContext.getBundle()
public Bundle getBundle(long id)
getBundle
in interface BundleContext
id
- The identifier of the bundle to retrieve.
Bundle
object or null
if the
identifier does not match any installed bundle.BundleContext.getBundle()
public Bundle[] getBundles()
getBundles
in interface BundleContext
Bundle
objects, one object per
installed bundle.BundleContext.getBundles()
public void addServiceListener(ServiceListener listener, java.lang.String filter) throws InvalidSyntaxException
addServiceListener
in interface BundleContext
listener
- The ServiceListener
object to be added.filter
- The filter criteria.
InvalidSyntaxException
- If filter
contains an
invalid filter string that cannot be parsed.BundleContext.addServiceListener(org.osgi.framework.ServiceListener, java.lang.String)
public void addServiceListener(ServiceListener listener)
addServiceListener
in interface BundleContext
listener
- The ServiceListener
object to be added.BundleContext.addServiceListener(org.osgi.framework.ServiceListener, java.lang.String)
public void removeServiceListener(ServiceListener listener)
removeServiceListener
in interface BundleContext
listener
- The ServiceListener
to be removed.BundleContext.removeServiceListener(org.osgi.framework.ServiceListener)
public void addBundleListener(BundleListener listener)
addBundleListener
in interface BundleContext
listener
- The BundleListener
to be added.BundleContext.addBundleListener(org.osgi.framework.BundleListener)
public void removeBundleListener(BundleListener listener)
removeBundleListener
in interface BundleContext
listener
- The BundleListener
object to be removed.BundleContext.removeBundleListener(org.osgi.framework.BundleListener)
public void addFrameworkListener(FrameworkListener listener)
addFrameworkListener
in interface BundleContext
listener
- The FrameworkListener
object to be added.BundleContext.addFrameworkListener(org.osgi.framework.FrameworkListener)
public void removeFrameworkListener(FrameworkListener listener)
removeFrameworkListener
in interface BundleContext
listener
- The FrameworkListener
object to be
removed.BundleContext.removeFrameworkListener(org.osgi.framework.FrameworkListener)
public ServiceRegistration registerService(java.lang.String[] clazzes, java.lang.Object service, java.util.Dictionary properties)
registerService
in interface BundleContext
clazzes
- The class names under which the service can be located.
The class names in this array will be stored in the service's
properties under the key Constants.OBJECTCLASS
.service
- The service object or a ServiceFactory
object.properties
- The properties for this service. The keys in the
properties object must all be String
objects. See
Constants
for a list of standard service property keys.
Changes should not be made to this object after calling this
method. To update the service's properties the
ServiceRegistration.setProperties(java.util.Dictionary)
method must be called.
The set of properties may be null
if the service
has no properties.
ServiceRegistration
object for use by the bundle
registering the service to update the service's properties or to
unregister the service.BundleContext.registerService(java.lang.String[], java.lang.Object, java.util.Dictionary)
public ServiceRegistration registerService(java.lang.String clazz, java.lang.Object service, java.util.Dictionary properties)
registerService
in interface BundleContext
clazz
- The class name under which the service can be located.service
- The service object or a ServiceFactory
object.properties
- The properties for this service.
ServiceRegistration
object for use by the bundle
registering the service to update the service's properties or to
unregister the service.BundleContext.registerService(java.lang.String[], java.lang.Object, java.util.Dictionary)
public ServiceReference[] getServiceReferences(java.lang.String clazz, java.lang.String filter) throws InvalidSyntaxException
getServiceReferences
in interface BundleContext
clazz
- The class name with which the service was registered or
null
for all services.filter
- The filter criteria.
ServiceReference
objects or
null
if no services are registered which satisfy
the search.
InvalidSyntaxException
- If filter
contains an
invalid filter string that cannot be parsed.BundleContext.getServiceReferences(java.lang.String, java.lang.String)
public ServiceReference[] getAllServiceReferences(java.lang.String clazz, java.lang.String filter) throws InvalidSyntaxException
getAllServiceReferences
in interface BundleContext
clazz
- The class name with which the service was registered or
null
for all services.filter
- The filter criteria.
ServiceReference
objects or
null
if no services are registered which satisfy
the search.
InvalidSyntaxException
- If filter
contains an
invalid filter string that cannot be parsed.BundleContext.getAllServiceReferences(java.lang.String, java.lang.String)
public ServiceReference getServiceReference(java.lang.String clazz)
getServiceReference
in interface BundleContext
clazz
- The class name with which the service was registered.
ServiceReference
object, or null
if no services are registered which implement the named class.BundleContext.getServiceReference(java.lang.String)
public java.lang.Object getService(ServiceReference reference)
getService
in interface BundleContext
reference
- A reference to the service.
reference
or null
if the service is
not registered or does not implement the classes under which it
was registered in the case of a ServiceFactory
.BundleContext.getService(org.osgi.framework.ServiceReference)
public boolean ungetService(ServiceReference reference)
ungetService
in interface BundleContext
reference
- A reference to the service to be released.
false
if the context bundle's use count for the
service is zero or if the service has been unregistered;
true
otherwise.BundleContext.ungetService(org.osgi.framework.ServiceReference)
public java.io.File getDataFile(java.lang.String filename)
getDataFile
in interface BundleContext
filename
- A relative name to the file to be accessed.
File
object that represents the requested file
or null
if the platform does not have file system
support.BundleContext.getDataFile(java.lang.String)
public Filter createFilter(java.lang.String filter) throws InvalidSyntaxException
ServiceReference
or a Dictionary.
createFilter
in interface BundleContext
filter
- the filter string.
InvalidSyntaxException
- If the filter parameter contains
an invalid filter string which cannot be parsed.FrameworkUtil.createFilter(String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |