org.eclipse.osgi.framework.internal.core
Class BundleContextImpl

java.lang.Object
  extended by org.eclipse.osgi.framework.internal.core.BundleContextImpl
All Implemented Interfaces:
EventDispatcher, BundleContext

public class BundleContextImpl
extends java.lang.Object
implements BundleContext, EventDispatcher

Bundle's execution context. This object is given out to bundles and wraps the internal BundleContext object. It is destroyed when a bundle is stopped.


Field Summary
protected  BundleActivator activator
          The current instantiation of the activator.
protected  BundleHost bundle
          Bundle object this context is associated with.
protected  EventListeners bundleEvent
          Listener list for bundle's BundleListeners
protected  EventListeners bundleEventSync
          Listener list for bundle's SynchronousBundleListeners
protected  java.lang.Object contextLock
          private object for locking
protected  Framework framework
          Internal framework object.
protected  EventListeners frameworkEvent
          Listener list for bundle's FrameworkListeners
static java.lang.String PROP_SCOPE_SERVICE_EVENTS
           
static boolean scopeEvents
           
protected  EventListeners serviceEvent
          Listener list for bundle's ServiceListeners
protected  java.util.Hashtable servicesInUse
          Services that bundle has used.
 
Constructor Summary
protected BundleContextImpl(BundleHost bundle)
          Construct a BundleContext which wrappers the framework for a bundle
 
Method Summary
 void addBundleListener(BundleListener listener)
          Add a bundle listener.
 void addFrameworkListener(FrameworkListener listener)
          Add a general 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.
protected  void checkValid()
          This method checks that the context is still valid.
protected  void close()
          Destroy the wrapper.
 Filter createFilter(java.lang.String filter)
          Construct a Filter object.
protected  ServiceRegistrationImpl createServiceRegistration(java.lang.String[] clazzes, java.lang.Object service, java.util.Dictionary properties)
          Create a new ServiceRegistration object.
 void dispatchEvent(java.lang.Object originalListener, java.lang.Object l, int action, java.lang.Object object)
          Bottom level event dispatcher for the BundleContext.
 ServiceReference[] getAllServiceReferences(java.lang.String clazz, java.lang.String filter)
          Returns an array of ServiceReference objects.
 Bundle getBundle()
          Retrieve the Bundle object for the context bundle.
 Bundle getBundle(long id)
          Retrieve the bundle that has the given unique identifier.
 AbstractBundle getBundleByLocation(java.lang.String location)
          Retrieve the bundle that has the given location.
 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 by the framework.
 java.lang.String getProperty(java.lang.String key)
          Retrieve the value of the named environment property.
protected  ServiceReference[] getRegisteredServices()
          Provides a list of ServiceReferences for the services registered by this bundle or null if the bundle has no registered services.
 java.lang.Object getService(ServiceReference reference)
          Get a service's service object.
 ServiceReference getServiceReference(java.lang.String clazz)
          Get a service reference.
 ServiceReference[] getServiceReferences(java.lang.String clazz, java.lang.String filter)
          Returns a list of ServiceReference objects.
protected  ServiceReferenceImpl[] getServicesInUse()
          Provides a list of ServiceReferenceImpls for the services this bundle is using, or null if the bundle is not using any services.
protected  boolean hasListenServicePermission(ServiceEvent event)
          Check for permission to listen to a service.
 Bundle installBundle(java.lang.String location)
          Install a bundle from a location.
 Bundle installBundle(java.lang.String location, java.io.InputStream in)
          Install a bundle from an InputStream.
protected  boolean isValid()
          This method checks that the context is still valid.
 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.
protected  void start()
          Call bundle's BundleActivator.start() This method is called by Bundle.startWorker to start the bundle.
protected  void startActivator(BundleActivator bundleActivator)
          Calls the start method of a BundleActivator.
protected  void stop()
          Call bundle's BundleActivator.stop() This method is called by Bundle.stopWorker to stop the bundle.
 boolean ungetService(ServiceReference reference)
          Unget a service's service object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_SCOPE_SERVICE_EVENTS

public static final java.lang.String PROP_SCOPE_SERVICE_EVENTS
See Also:
Constant Field Values

scopeEvents

public static final boolean scopeEvents

bundle

protected BundleHost bundle
Bundle object this context is associated with.


framework

protected Framework framework
Internal framework object.


servicesInUse

protected java.util.Hashtable servicesInUse
Services that bundle has used. Key is ServiceReference, Value is ServiceUse


bundleEvent

protected EventListeners bundleEvent
Listener list for bundle's BundleListeners


bundleEventSync

protected EventListeners bundleEventSync
Listener list for bundle's SynchronousBundleListeners


serviceEvent

protected EventListeners serviceEvent
Listener list for bundle's ServiceListeners


frameworkEvent

protected EventListeners frameworkEvent
Listener list for bundle's FrameworkListeners


activator

protected BundleActivator activator
The current instantiation of the activator.


contextLock

protected java.lang.Object contextLock
private object for locking

Constructor Detail

BundleContextImpl

protected BundleContextImpl(BundleHost bundle)
Construct a BundleContext which wrappers the framework for a bundle

Parameters:
bundle - The bundle we are wrapping.
Method Detail

close

protected void close()
Destroy the wrapper. This is called when the bundle is stopped.


getProperty

public java.lang.String getProperty(java.lang.String key)
Retrieve the value of the named environment property.

Specified by:
getProperty in interface BundleContext
Parameters:
key - The name of the requested property.
Returns:
The value of the requested property, or null if the property is undefined.

getBundle

public Bundle getBundle()
Retrieve the Bundle object for the context bundle.

Specified by:
getBundle in interface BundleContext
Returns:
The context bundle's Bundle object.

installBundle

public Bundle installBundle(java.lang.String location)
                     throws BundleException
Install a bundle from a location. The bundle is obtained from the location parameter as interpreted by the framework in an implementation dependent way. Typically, location will most likely be a URL.

Specified by:
installBundle in interface BundleContext
Parameters:
location - The location identifier of the bundle to install.
Returns:
The Bundle object of the installed bundle.
Throws:
BundleException - If the installation failed.

installBundle

public Bundle installBundle(java.lang.String location,
                            java.io.InputStream in)
                     throws BundleException
Install a bundle from an InputStream.

This method performs all the steps listed in installBundle(java.lang.String), except the bundle's content will be read from the InputStream. The location identifier specified will be used as the identity of the bundle.

Specified by:
installBundle in interface BundleContext
Parameters:
location - The location identifier of the bundle to install.
in - The InputStream from which the bundle will be read.
Returns:
The Bundle of the installed bundle.
Throws:
BundleException - If the provided stream cannot be read or the installation failed.
See Also:
BundleContext.installBundle(java.lang.String)

getBundle

public Bundle getBundle(long id)
Retrieve the bundle that has the given unique identifier.

Specified by:
getBundle in interface BundleContext
Parameters:
id - The identifier of the bundle to retrieve.
Returns:
A Bundle object, or null if the identifier doesn't match any installed bundle.

getBundleByLocation

public AbstractBundle getBundleByLocation(java.lang.String location)
Retrieve the bundle that has the given location.

Parameters:
location - The location string of the bundle to retrieve.
Returns:
A Bundle object, or null if the location doesn't match any installed bundle.

getBundles

public Bundle[] getBundles()
Retrieve a list of all installed bundles. The list is valid at the time of the call to getBundles, but the framework is a very dynamic environment and bundles can be installed or uninstalled at anytime.

Specified by:
getBundles in interface BundleContext
Returns:
An array of AbstractBundle objects, one object per installed bundle.

addServiceListener

public void addServiceListener(ServiceListener listener,
                               java.lang.String filter)
                        throws InvalidSyntaxException
Add a service listener with a filter. ServiceListeners are notified when a service has a lifecycle state change. See getServiceReferences for a description of the filter syntax. The listener is added to the context bundle's list of listeners. See getBundle() for a definition of context bundle.

The listener is called if the filter criteria is met. To filter based upon the class of the service, the filter should reference the "objectClass" property. If the filter paramater is null, all services are considered to match the filter.

If the Java runtime environment supports permissions, then additional filtering is done. Bundle.hasPermission is called for the bundle which defines the listener to validate that the listener has the ServicePermission permission to "get" the service using at least one of the named classes the service was registered under.

Specified by:
addServiceListener in interface BundleContext
Parameters:
listener - The service listener to add.
filter - The filter criteria.
Throws:
InvalidSyntaxException - If the filter parameter contains an invalid filter string which cannot be parsed.
java.lang.IllegalStateException - If the bundle context has stopped.
See Also:
ServiceEvent, ServiceListener

addServiceListener

public void addServiceListener(ServiceListener listener)
Add a service listener.

This method is the same as calling addServiceListener(ServiceListener, String) with filter set to null.

Specified by:
addServiceListener in interface BundleContext
Parameters:
listener - The ServiceListener object to be added.
See Also:
addServiceListener(ServiceListener, String)

removeServiceListener

public void removeServiceListener(ServiceListener listener)
Remove a service listener. The listener is removed from the context bundle's list of listeners. See getBundle() for a definition of context bundle.

If this method is called with a listener which is not registered, then this method does nothing.

Specified by:
removeServiceListener in interface BundleContext
Parameters:
listener - The service listener to remove.
Throws:
java.lang.IllegalStateException - If the bundle context has stopped.

addBundleListener

public void addBundleListener(BundleListener listener)
Add a bundle listener. BundleListeners are notified when a bundle has a lifecycle state change. The listener is added to the context bundle's list of listeners. See getBundle() for a definition of context bundle.

Specified by:
addBundleListener in interface BundleContext
Parameters:
listener - The bundle listener to add.
Throws:
java.lang.IllegalStateException - If the bundle context has stopped.
See Also:
BundleEvent, BundleListener

removeBundleListener

public void removeBundleListener(BundleListener listener)
Remove a bundle listener. The listener is removed from the context bundle's list of listeners. See getBundle() for a definition of context bundle.

If this method is called with a listener which is not registered, then this method does nothing.

Specified by:
removeBundleListener in interface BundleContext
Parameters:
listener - The bundle listener to remove.
Throws:
java.lang.IllegalStateException - If the bundle context has stopped.

addFrameworkListener

public void addFrameworkListener(FrameworkListener listener)
Add a general framework listener. FrameworkListeners are notified of general framework events. The listener is added to the context bundle's list of listeners. See getBundle() for a definition of context bundle.

Specified by:
addFrameworkListener in interface BundleContext
Parameters:
listener - The framework listener to add.
Throws:
java.lang.IllegalStateException - If the bundle context has stopped.
See Also:
FrameworkEvent, FrameworkListener

removeFrameworkListener

public void removeFrameworkListener(FrameworkListener listener)
Remove a framework listener. The listener is removed from the context bundle's list of listeners. See getBundle() for a definition of context bundle.

If this method is called with a listener which is not registered, then this method does nothing.

Specified by:
removeFrameworkListener in interface BundleContext
Parameters:
listener - The framework listener to remove.
Throws:
java.lang.IllegalStateException - If the bundle context has stopped.

registerService

public ServiceRegistration registerService(java.lang.String[] clazzes,
                                           java.lang.Object service,
                                           java.util.Dictionary properties)
Register a service with multiple names. This method registers the given service object with the given properties under the given class names. A ServiceRegistrationImpl object is returned. The ServiceRegistrationImpl object is for the private use of the bundle registering the service and should not be shared with other bundles. The registering bundle is defined to be the context bundle. See getBundle() for a definition of context bundle. Other bundles can locate the service by using either the getServiceReferences or getServiceReference method.

A bundle can register a service object that implements the ServiceFactory interface to have more flexiblity in providing service objects to different bundles.

The following steps are followed to register a service:

  1. If the service parameter is not a ServiceFactory, an IllegalArgumentException is thrown if the service parameter is not an instanceof all the classes named.
  2. The service is added to the framework's service registry and may now be used by other bundles.
  3. A ServiceEvent of type ServiceEvent.REGISTERED is synchronously sent.
  4. A ServiceRegistrationImpl object for this registration is returned.

Specified by:
registerService in interface BundleContext
Parameters:
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 "objectClass".
service - The service object or a ServiceFactory object.
properties - The properties for this service. The keys in the properties object must all be Strings. Changes should not be made to this object after calling this method. To update the service's properties call the ServiceRegistration.setProperties method. This parameter may be null if the service has no properties.
Returns:
A ServiceRegistrationImpl object for use by the bundle registering the service to update the service's properties or to unregister the service.
Throws:
java.lang.IllegalArgumentException - If one of the following is true:
  • The service parameter is null.
  • The service parameter is not a ServiceFactory and is not an instanceof all the named classes in the clazzes parameter.
java.lang.SecurityException - If the caller does not have ServicePermission permission to "register" the service for all the named classes and the Java runtime environment supports permissions.
java.lang.IllegalStateException - If the bundle context has stopped.
See Also:
ServiceRegistrationImpl, ServiceFactory

createServiceRegistration

protected ServiceRegistrationImpl createServiceRegistration(java.lang.String[] clazzes,
                                                            java.lang.Object service,
                                                            java.util.Dictionary properties)
Create a new ServiceRegistration object. This method is used so that it may be overridden by a secure implementation.

Parameters:
clazzes - The class names under which the service can be located.
service - The service object or a ServiceFactory object.
properties - The properties for this service.
Returns:
A ServiceRegistrationImpl object for use by the bundle.

registerService

public ServiceRegistration registerService(java.lang.String clazz,
                                           java.lang.Object service,
                                           java.util.Dictionary properties)
Register a service with a single name. This method registers the given service object with the given properties under the given class name.

This method is otherwise identical to registerService(java.lang.String[], java.lang.Object, java.util.Dictionary) and is provided as a convenience when the service parameter will only be registered under a single class name.

Specified by:
registerService in interface BundleContext
Parameters:
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.
Returns:
A ServiceRegistration object for use by the bundle registering the service to update the service's properties or to unregister the service.
See Also:
registerService(java.lang.String[], java.lang.Object, java.util.Dictionary)

getServiceReferences

public ServiceReference[] getServiceReferences(java.lang.String clazz,
                                               java.lang.String filter)
                                        throws InvalidSyntaxException
Returns a list of ServiceReference objects. This method returns a list of ServiceReference objects for services which implement and were registered under the specified class and match the specified filter criteria.

The list is valid at the time of the call to this method, however as the Framework is a very dynamic environment, services can be modified or unregistered at anytime.

filter is used to select the registered service whose properties objects contain keys and values which satisfy the filter. See FilterImplfor a description of the filter string syntax.

If filter is null, all registered services are considered to match the filter.

If filter cannot be parsed, an InvalidSyntaxExceptionwill be thrown with a human readable message where the filter became unparsable.

The following steps are required to select a service:

  1. If the Java Runtime Environment supports permissions, the caller is checked for the ServicePermission to get the service with the specified class. If the caller does not have the correct permission, null is returned.
  2. If the filter string is not null, the filter string is parsed and the set of registered services which satisfy the filter is produced. If the filter string is null, then all registered services are considered to satisfy the filter.
  3. If clazz is not null, the set is further reduced to those services which are an instanceof and were registered under the specified class. The complete list of classes of which a service is an instance and which were specified when the service was registered is available from the service's Constants.OBJECTCLASSproperty.
  4. An array of ServiceReference to the selected services is returned.

Specified by:
getServiceReferences in interface BundleContext
Parameters:
clazz - The class name with which the service was registered, or null for all services.
filter - The filter criteria.
Returns:
An array of ServiceReference objects, or null if no services are registered which satisfy the search.
Throws:
InvalidSyntaxException - If filter contains an invalid filter string which cannot be parsed.

getAllServiceReferences

public ServiceReference[] getAllServiceReferences(java.lang.String clazz,
                                                  java.lang.String filter)
                                           throws InvalidSyntaxException
Description copied from interface: BundleContext
Returns an array of ServiceReference objects. The returned array of ServiceReference objects contains services that were registered under the specified class and match the specified filter criteria.

The list is valid at the time of the call to this method, however since the Framework is a very dynamic environment, services can be modified or unregistered at anytime.

filter is used to select the registered service whose properties objects contain keys and values which satisfy the filter. See Filter for a description of the filter string syntax.

If filter is null, all registered services are considered to match the filter. If filter cannot be parsed, an InvalidSyntaxException will be thrown with a human readable message where the filter became unparsable.

The following steps are required to select a set of ServiceReference objects:

  1. If the filter string is not null, the filter string is parsed and the set ServiceReference objects of registered services that satisfy the filter is produced. If the filter string is null, then all registered services are considered to satisfy the filter.
  2. If the Java Runtime Environment supports permissions, the set of ServiceReference objects produced by the previous step is reduced by checking that the caller has the ServicePermission to get at least one of the class names under which the service was registered. If the caller does not have the correct permission for a particular ServiceReference object, then it is removed from the set.
  3. If clazz is not null, the set is further reduced to those services that are an instanceof and were registered under the specified class. The complete list of classes of which a service is an instance and which were specified when the service was registered is available from the service's Constants.OBJECTCLASS property.
  4. An array of the remaining ServiceReference objects is returned.

Specified by:
getAllServiceReferences in interface BundleContext
Parameters:
clazz - The class name with which the service was registered or null for all services.
filter - The filter criteria.
Returns:
An array of ServiceReference objects or null if no services are registered which satisfy the search.
Throws:
InvalidSyntaxException - If filter contains an invalid filter string that cannot be parsed.

getServiceReference

public ServiceReference getServiceReference(java.lang.String clazz)
Get a service reference. Retrieves a ServiceReferenceImpl for a service which implements the named class.

This reference is valid at the time of the call to this method, but since the framework is a very dynamic environment, services can be modified or unregistered at anytime.

This method is provided as a convenience for when the caller is interested in any service which implements a named class. This method is the same as calling getServiceReferences with a null filter string but only a single ServiceReferenceImpl is returned.

Specified by:
getServiceReference in interface BundleContext
Parameters:
clazz - The class name which the service must implement.
Returns:
A ServiceReferenceImpl object, or null if no services are registered which implement the named class.
See Also:
getServiceReferences(java.lang.String, java.lang.String)

getService

public java.lang.Object getService(ServiceReference reference)
Get a service's service object. Retrieves the service object for a service. A bundle's use of a service is tracked by a use count. Each time a service's service object is returned by getService(org.osgi.framework.ServiceReference), the context bundle's use count for the service is incremented by one. Each time the service is release by ungetService(org.osgi.framework.ServiceReference), the context bundle's use count for the service is decremented by one. When a bundle's use count for a service drops to zero, the bundle should no longer use the service. See getBundle() for a definition of context bundle.

This method will always return null when the service associated with this reference has been unregistered.

The following steps are followed to get the service object:

  1. If the service has been unregistered, null is returned.
  2. The context bundle's use count for this service is incremented by one.
  3. If the context bundle's use count for the service is now one and the service was registered with a ServiceFactory, the ServiceFactory.getService method is called to create a service object for the context bundle. This service object is cached by the framework. While the context bundle's use count for the service is greater than zero, subsequent calls to get the services's service object for the context bundle will return the cached service object.
    If the service object returned by the ServiceFactory is not an instanceof all the classes named when the service was registered or the ServiceFactory throws an exception, null is returned and a FrameworkEvent of type FrameworkEvent.ERROR is broadcast.
  4. The service object for the service is returned.

Specified by:
getService in interface BundleContext
Parameters:
reference - A reference to the service whose service object is desired.
Returns:
A service object for the service associated with this reference, or null if the service is not registered.
Throws:
java.lang.SecurityException - If the caller does not have ServicePermission permission to "get" the service using at least one of the named classes the service was registered under and the Java runtime environment supports permissions.
java.lang.IllegalStateException - If the bundle context has stopped.
See Also:
ungetService(org.osgi.framework.ServiceReference), ServiceFactory

ungetService

public boolean ungetService(ServiceReference reference)
Unget a service's service object. Releases the service object for a service. If the context bundle's use count for the service is zero, this method returns false. Otherwise, the context bundle's use count for the service is decremented by one. See getBundle() for a definition of context bundle.

The service's service object should no longer be used and all references to it should be destroyed when a bundle's use count for the service drops to zero.

The following steps are followed to unget the service object:

  1. If the context bundle's use count for the service is zero or the service has been unregistered, false is returned.
  2. The context bundle's use count for this service is decremented by one.
  3. If the context bundle's use count for the service is now zero and the service was registered with a ServiceFactory, the ServiceFactory.ungetService method is called to release the service object for the context bundle.
  4. true is returned.

Specified by:
ungetService in interface BundleContext
Parameters:
reference - A reference to the service to be released.
Returns:
false if the context bundle's use count for the service is zero or if the service has been unregistered, otherwise true.
Throws:
java.lang.IllegalStateException - If the bundle context has stopped.
See Also:
getService(org.osgi.framework.ServiceReference), ServiceFactory

getDataFile

public java.io.File getDataFile(java.lang.String filename)
Creates a File object for a file in the persistent storage area provided for the bundle by the framework. If the adaptor does not have file system support, this method will return null.

A File object for the base directory of the persistent storage area provided for the context bundle by the framework can be obtained by calling this method with the empty string ("") as the parameter. See getBundle() for a definition of context bundle.

If the Java runtime environment supports permissions, the framework the will ensure that the bundle has java.io.FilePermission with actions "read","write","execute","delete" for all files (recursively) in the persistent storage area provided for the context bundle by the framework.

Specified by:
getDataFile in interface BundleContext
Parameters:
filename - A relative name to the file to be accessed.
Returns:
A File object that represents the requested file or null if the adaptor does not have file system support.
Throws:
java.lang.IllegalStateException - If the bundle context has stopped.

start

protected void start()
              throws BundleException
Call bundle's BundleActivator.start() This method is called by Bundle.startWorker to start the bundle.

Throws:
BundleException - if the bundle has a class that implements the BundleActivator interface, but Framework couldn't instantiate it, or the BundleActivator.start() method failed

startActivator

protected void startActivator(BundleActivator bundleActivator)
                       throws BundleException
Calls the start method of a BundleActivator.

Parameters:
bundleActivator - that activator to start
Throws:
BundleException

stop

protected void stop()
             throws BundleException
Call bundle's BundleActivator.stop() This method is called by Bundle.stopWorker to stop the bundle.

Throws:
BundleException - if the bundle has a class that implements the BundleActivator interface, and the BundleActivator.stop() method failed

getRegisteredServices

protected ServiceReference[] getRegisteredServices()
Provides a list of ServiceReferences for the services registered by this bundle or null if the bundle has no registered services.

The list is valid at the time of the call to this method, but the framework is a very dynamic environment and services can be modified or unregistered at anytime.

Returns:
An array of ServiceReference or null.
Throws:
java.lang.IllegalStateException - If the bundle has been uninstalled.
See Also:
ServiceRegistrationImpl, ServiceReferenceImpl

getServicesInUse

protected ServiceReferenceImpl[] getServicesInUse()
Provides a list of ServiceReferenceImpls for the services this bundle is using, or null if the bundle is not using any services. A bundle is considered to be using a service if the bundle's use count for the service is greater than zero.

The list is valid at the time of the call to this method, but the framework is a very dynamic environment and services can be modified or unregistered at anytime.

Returns:
An array of ServiceReferenceImpl or null.
Throws:
java.lang.IllegalStateException - If the bundle has been uninstalled.
See Also:
ServiceReferenceImpl

dispatchEvent

public void dispatchEvent(java.lang.Object originalListener,
                          java.lang.Object l,
                          int action,
                          java.lang.Object object)
Bottom level event dispatcher for the BundleContext.

Specified by:
dispatchEvent in interface EventDispatcher
Parameters:
originalListener - listener object registered under.
l - listener to call (may be filtered).
action - Event class type
object - Event object

hasListenServicePermission

protected boolean hasListenServicePermission(ServiceEvent event)
Check for permission to listen to a service.


createFilter

public Filter createFilter(java.lang.String filter)
                    throws InvalidSyntaxException
Construct a Filter object. This filter object may be used to match a ServiceReference or a Dictionary. See Filter for a description of the filter string syntax.

Specified by:
createFilter in interface BundleContext
Parameters:
filter - The filter string.
Returns:
A Filter object encapsulating the filter string.
Throws:
InvalidSyntaxException - If the filter parameter contains an invalid filter string which cannot be parsed.
See Also:
"Framework specification for a description of the filter string syntax.", FrameworkUtil.createFilter(String)

checkValid

protected void checkValid()
This method checks that the context is still valid. If the context is no longer valid, an IllegalStateException is thrown.

Throws:
java.lang.IllegalStateException - If the context bundle has stopped.

isValid

protected boolean isValid()
This method checks that the context is still valid.

Returns:
true if the context is still valid; false otherwise