class BundleContextImpl extends java.lang.Object implements FelixBundleContext
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
BundleContextImpl.ServiceObjectsImpl<S> |
| Modifier and Type | Field and Description |
|---|---|
private BundleImpl |
m_bundle |
private Felix |
m_felix |
private Logger |
m_logger |
private boolean |
m_valid |
| Modifier | Constructor and Description |
|---|---|
protected |
BundleContextImpl(Logger logger,
Felix felix,
BundleImpl bundle) |
| Modifier and Type | Method and Description |
|---|---|
void |
addBundleListener(BundleListener l)
Adds the specified
BundleListener object to the context bundle's
list of listeners if not already present. |
void |
addCapability() |
void |
addFrameworkListener(FrameworkListener l)
Adds the specified
FrameworkListener object to the context
bundle's list of listeners if not already present. |
void |
addRequirement(java.lang.String s) |
void |
addServiceListener(ServiceListener l)
Adds the specified
ServiceListener object to the context bundle's
list of listeners. |
void |
addServiceListener(ServiceListener l,
java.lang.String s)
Adds the specified
ServiceListener object with the specified
filter to the context bundle's list of listeners. |
private void |
checkValidity() |
Filter |
createFilter(java.lang.String expr)
Creates a
Filter object. |
ServiceReference<?>[] |
getAllServiceReferences(java.lang.String clazz,
java.lang.String filter)
Returns an array of
ServiceReference objects. |
private ServiceReference |
getBestServiceReference(ServiceReference[] refs) |
Bundle |
getBundle()
Returns the
Bundle object associated with this
BundleContext. |
Bundle |
getBundle(long id)
Returns the bundle with the specified identifier.
|
Bundle |
getBundle(java.lang.String location)
Returns the bundle with the specified location.
|
Bundle[] |
getBundles()
Returns a list of all installed bundles.
|
java.io.File |
getDataFile(java.lang.String s)
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 name)
Returns the value of the specified property.
|
<S> S |
getService(ServiceReference<S> ref)
Returns the service object for the service referenced by the specified
ServiceReference object. |
<S> ServiceObjects<S> |
getServiceObjects(ServiceReference<S> ref)
Returns the
ServiceObjects object for the service referenced by
the specified ServiceReference object. |
<S> ServiceReference<S> |
getServiceReference(java.lang.Class<S> clazz)
Returns a
ServiceReference object for a service that implements
and was registered under the name of the specified class. |
ServiceReference<?> |
getServiceReference(java.lang.String clazz)
Returns a
ServiceReference object for a service that implements
and was registered under the specified class. |
<S> java.util.Collection<ServiceReference<S>> |
getServiceReferences(java.lang.Class<S> clazz,
java.lang.String filter)
Returns a collection of
ServiceReference objects. |
ServiceReference<?>[] |
getServiceReferences(java.lang.String clazz,
java.lang.String filter)
Returns an array of
ServiceReference objects. |
Bundle |
installBundle(java.lang.String location)
Installs a bundle from the specified
location identifier. |
Bundle |
installBundle(java.lang.String location,
java.io.InputStream is)
Installs a bundle from the specified
InputStream object. |
protected void |
invalidate() |
<S> ServiceRegistration<S> |
registerService(java.lang.Class<S> clazz,
S svcObj,
java.util.Dictionary<java.lang.String,?> dict)
Registers the specified service object with the specified properties
under the name of the specified class with the Framework.
|
<S> ServiceRegistration<S> |
registerService(java.lang.Class<S> clazz,
ServiceFactory<S> factory,
java.util.Dictionary<java.lang.String,?> properties)
Registers the specified service factory object with the specified
properties under the name of the specified class with the Framework.
|
ServiceRegistration<?> |
registerService(java.lang.String[] clazzes,
java.lang.Object svcObj,
java.util.Dictionary<java.lang.String,?> dict)
Registers the specified service object with the specified properties
under the specified class names into the Framework.
|
ServiceRegistration<?> |
registerService(java.lang.String clazz,
java.lang.Object svcObj,
java.util.Dictionary<java.lang.String,?> dict)
Registers the specified service object with the specified properties
under the specified class name with the Framework.
|
void |
removeBundleListener(BundleListener l)
Removes the specified
BundleListener object from the context
bundle's list of listeners. |
void |
removeCapability() |
void |
removeFrameworkListener(FrameworkListener l)
Removes the specified
FrameworkListener object from the context
bundle's list of listeners. |
void |
removeRequirement() |
void |
removeServiceListener(ServiceListener l)
Removes the specified
ServiceListener object from the context
bundle's list of listeners. |
boolean |
ungetService(ServiceReference<?> ref)
Releases the service object for the service referenced by the specified
ServiceReference object. |
private Logger m_logger
private Felix m_felix
private BundleImpl m_bundle
private boolean m_valid
protected BundleContextImpl(Logger logger, Felix felix, BundleImpl bundle)
protected void invalidate()
public void addRequirement(java.lang.String s)
throws BundleException
addRequirement in interface FelixBundleContextBundleExceptionpublic void removeRequirement()
throws BundleException
removeRequirement in interface FelixBundleContextBundleExceptionpublic void addCapability()
throws BundleException
addCapability in interface FelixBundleContextBundleExceptionpublic void removeCapability()
throws BundleException
removeCapability in interface FelixBundleContextBundleExceptionpublic java.lang.String getProperty(java.lang.String name)
BundleContextnull if the property is not found.
All bundles must have permission to read properties whose names start with "org.osgi.".
getProperty in interface BundleContextname - The name of the requested property.null if the
property is undefined.public Bundle getBundle()
BundleContextBundle object associated with this
BundleContext. This bundle is called the context bundle.getBundle in interface BundleContextgetBundle in interface BundleReferenceBundle object associated with this
BundleContext.public Filter createFilter(java.lang.String expr) throws InvalidSyntaxException
BundleContextFilter object. This Filter object may be used
to match a ServiceReference object or a Dictionary
object.
If the filter cannot be parsed, an InvalidSyntaxException will be
thrown with a human readable message where the filter became unparsable.
createFilter in interface BundleContextexpr - The filter string.Filter object encapsulating the filter string.InvalidSyntaxException - If filter contains an invalid
filter string that cannot be parsed.FrameworkUtil.createFilter(String)public Bundle installBundle(java.lang.String location) throws BundleException
BundleContextlocation identifier.
This method performs the same function as calling
BundleContext.installBundle(String,InputStream) with the specified
location identifier and a null InputStream.
installBundle in interface BundleContextlocation - The location identifier of the bundle to install.Bundle object of the installed bundle.BundleException - If the installation failed. BundleException types
thrown by this method include: BundleException.READ_ERROR
, BundleException.DUPLICATE_BUNDLE_ERROR,
BundleException.MANIFEST_ERROR, and
BundleException.REJECTED_BY_HOOK.BundleContext.installBundle(String, InputStream)public Bundle installBundle(java.lang.String location, java.io.InputStream is) throws BundleException
BundleContextInputStream object.
If the specified InputStream is null, the Framework must
create the InputStream from which to read the bundle by
interpreting, in an implementation dependent manner, the specified
location.
The specified location identifier will be used as the identity of
the bundle. Every installed bundle is uniquely identified by its location
identifier which is typically in the form of a URL.
The following steps are required to install a bundle:
Bundle object for that bundle is returned.BundleException is thrown.BundleException is thrown.INSTALLED.BundleEvent.INSTALLED is fired.Bundle object for the newly or previously installed
bundle is returned.getState() in { INSTALLED, RESOLVED
}.installBundle in interface BundleContextlocation - The location identifier of the bundle to install.is - The InputStream object from which this bundle will
be read or null to indicate the Framework must create the
input stream from the specified location identifier. The input
stream must always be closed when this method completes, even if
an exception is thrown.Bundle object of the installed bundle.BundleException - If the installation failed. BundleException types
thrown by this method include: BundleException.READ_ERROR
, BundleException.DUPLICATE_BUNDLE_ERROR,
BundleException.MANIFEST_ERROR, and
BundleException.REJECTED_BY_HOOK.public Bundle getBundle(long id)
BundleContextgetBundle in interface BundleContextid - The identifier of the bundle to retrieve.Bundle object or null if the identifier does
not match any installed bundle.public Bundle getBundle(java.lang.String location)
BundleContextgetBundle in interface BundleContextlocation - The location of the bundle to retrieve.Bundle object or null if the location does not
match any installed bundle.public Bundle[] getBundles()
BundleContextThis method returns a list of all bundles installed in the OSGi environment at the time of the call to this method. However, since the Framework is a very dynamic environment, bundles can be installed or uninstalled at anytime.
getBundles in interface BundleContextBundle objects, one object per installed
bundle.public void addBundleListener(BundleListener l)
BundleContextBundleListener object to the context bundle's
list of listeners if not already present. BundleListener objects are
notified when a bundle has a lifecycle state change.
If the context bundle's list of listeners already contains a listener
l such that (l==listener), this method does nothing.
addBundleListener in interface BundleContextl - The BundleListener to be added.BundleEvent,
BundleListenerpublic void removeBundleListener(BundleListener l)
BundleContextBundleListener object from the context
bundle's list of listeners.
If listener is not contained in the context bundle's list of
listeners, this method does nothing.
removeBundleListener in interface BundleContextl - The BundleListener object to be removed.public void addServiceListener(ServiceListener l)
BundleContextServiceListener object to the context bundle's
list of listeners.
This method is the same as calling
BundleContext.addServiceListener(ServiceListener listener,
String filter) with filter set to null.
addServiceListener in interface BundleContextl - The ServiceListener object to be added.BundleContext.addServiceListener(ServiceListener, String)public void addServiceListener(ServiceListener l, java.lang.String s) throws InvalidSyntaxException
BundleContextServiceListener object with the specified
filter to the context bundle's list of listeners. See
Filter for a description of the filter syntax.
ServiceListener objects are notified when a service has a
lifecycle state change.
If the context bundle's list of listeners already contains a listener
l such that (l==listener), then this method replaces that
listener's filter (which may be null) with the specified one
(which may be null).
The listener is called if the filter criteria is met. To filter based
upon the class of the service, the filter should reference the
Constants.OBJECTCLASS property. If filter is null
, all services are considered to match the filter.
When using a filter, it is possible that the ServiceEvent
s for the complete lifecycle of a service will not be delivered to the
listener. For example, if the filter only matches when the
property x has the value 1, the listener will not be
called if the service is registered with the property x not set
to the value 1. Subsequently, when the service is modified
setting property x to the value 1, the filter will match
and the listener will be called with a ServiceEvent of type
MODIFIED. Thus, the listener will not be called with a
ServiceEvent of type REGISTERED.
If the Java Runtime Environment supports permissions, the
ServiceListener object will be notified of a service event only
if the bundle that is registering it has the ServicePermission to
get the service using at least one of the named classes the service was
registered under.
addServiceListener in interface BundleContextl - The ServiceListener object to be added.s - The filter criteria.InvalidSyntaxException - If filter contains an invalid
filter string that cannot be parsed.ServiceEvent,
ServiceListener,
ServicePermissionpublic void removeServiceListener(ServiceListener l)
BundleContextServiceListener object from the context
bundle's list of listeners.
If listener is not contained in this context bundle's list of
listeners, this method does nothing.
removeServiceListener in interface BundleContextl - The ServiceListener to be removed.public void addFrameworkListener(FrameworkListener l)
BundleContextFrameworkListener object to the context
bundle's list of listeners if not already present. FrameworkListeners are
notified of general Framework events.
If the context bundle's list of listeners already contains a listener
l such that (l==listener), this method does nothing.
addFrameworkListener in interface BundleContextl - The FrameworkListener object to be added.FrameworkEvent,
FrameworkListenerpublic void removeFrameworkListener(FrameworkListener l)
BundleContextFrameworkListener object from the context
bundle's list of listeners.
If listener is not contained in the context bundle's list of
listeners, this method does nothing.
removeFrameworkListener in interface BundleContextl - The FrameworkListener object to be removed.public ServiceRegistration<?> registerService(java.lang.String clazz, java.lang.Object svcObj, java.util.Dictionary<java.lang.String,?> dict)
BundleContext
This method is otherwise identical to
BundleContext.registerService(String[], Object, Dictionary) and is provided as
a convenience when service will only be registered under a single
class name. Note that even in this case the value of the service's
Constants.OBJECTCLASS property will be an array of string, rather
than just a single string.
registerService in interface BundleContextclazz - The class name under which the service can be located.svcObj - The service object or an object implementing
ServiceFactory.dict - 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(String[], Object, Dictionary)public ServiceRegistration<?> registerService(java.lang.String[] clazzes, java.lang.Object svcObj, java.util.Dictionary<java.lang.String,?> dict)
BundleContextServiceRegistration object is returned. The
ServiceRegistration 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. Other bundles can
locate the service by using one of the
BundleContext.getServiceReferences(Class, String),
BundleContext.getServiceReferences(String, String),
BundleContext.getServiceReference(Class) or
BundleContext.getServiceReference(String) methods.
A bundle can register a service object that implements the
ServiceFactory interface to have more flexibility in providing
service objects to other bundles.
The following steps are required to register a service:
service does not implement ServiceFactory, an
IllegalArgumentException is thrown if service is not an
instanceof all the specified class names.Dictionary (which may be
null):
Constants.SERVICE_ID identifying the
registration number of the serviceConstants.OBJECTCLASS containing all the
specified classes.Constants.SERVICE_SCOPE identifying the
scope of the service.Constants.SERVICE_BUNDLEID identifying the
the context bundle.Dictionary will be
ignored.ServiceEvent.REGISTERED is fired.ServiceRegistration object for this registration is
returned.registerService in interface BundleContextclazzes - 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.svcObj - The service object or an object implementing
ServiceFactory.dict - 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(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.ServiceRegistration,
PrototypeServiceFactory,
ServiceFactorypublic <S> ServiceRegistration<S> registerService(java.lang.Class<S> clazz, S svcObj, java.util.Dictionary<java.lang.String,?> dict)
BundleContext
This method is otherwise identical to
BundleContext.registerService(String, Object, Dictionary) and is provided to
return a type safe ServiceRegistration.
registerService in interface BundleContextS - Type of Service.clazz - The class under whose name the service can be located.svcObj - The service object or an object implementing
ServiceFactory.dict - 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(String, Object, Dictionary)public ServiceReference<?> getServiceReference(java.lang.String clazz)
BundleContextServiceReference object for a service that implements
and was registered under the specified class.
The returned ServiceReference object 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 any time.
This method is the same as calling
BundleContext.getServiceReferences(String, String) with a null filter
expression and then finding the reference with the highest priority. It
is provided as a convenience for when the caller is interested in any
service that implements the specified class.
If multiple such services exist, the service with the highest priority is
selected. This priority is defined as the service reference with the
highest ranking (as specified in its Constants.SERVICE_RANKING
property) is returned.
If there is a tie in ranking, the service with the lowest service id (as
specified in its Constants.SERVICE_ID property); that is, the
service that was registered first is returned.
getServiceReference in interface BundleContextclazz - The class name with which the service was registered.ServiceReference object, or null if no services
are registered which implement the named class.BundleContext.getServiceReferences(String, String)public <S> ServiceReference<S> getServiceReference(java.lang.Class<S> clazz)
BundleContextServiceReference object for a service that implements
and was registered under the name of the specified class.
The returned ServiceReference object 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 any time.
This method is the same as calling
BundleContext.getServiceReferences(Class, String) with a null filter
expression. It is provided as a convenience for when the caller is
interested in any service that implements the specified class.
If multiple such services exist, the service with the highest ranking (as
specified in its Constants.SERVICE_RANKING property) is returned.
If there is a tie in ranking, the service with the lowest service id (as
specified in its Constants.SERVICE_ID property); that is, the
service that was registered first is returned.
getServiceReference in interface BundleContextS - Type of Service.clazz - The class under whose name the service was registered. Must
not be null.ServiceReference object, or null if no services
are registered which implement the specified class.BundleContext.getServiceReferences(Class, String)private ServiceReference getBestServiceReference(ServiceReference[] refs)
public ServiceReference<?>[] getAllServiceReferences(java.lang.String clazz, java.lang.String filter) throws InvalidSyntaxException
BundleContextServiceReference objects. The returned array
of ServiceReference objects contains services that were
registered under the specified class and match the specified filter
expression.
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 any time.
The specified filter expression is used to select the registered
services whose service properties contain keys and values which satisfy
the filter expression. See Filter for a description of the filter
syntax. If the specified filter is null, all registered
services are considered to match the filter. If the specified
filter expression cannot be parsed, an
InvalidSyntaxException will be thrown with a human readable
message where the filter became unparsable.
The result is an array of ServiceReference objects for all
services that meet all of the following conditions:
clazz, is not null, the
service must have been registered with the specified class name. The
complete list of class names with which a service was registered is
available from the service's objectClass
property.filter is not null, the filter
expression must match the service.ServicePermission with the GET action for at least
one of the class names under which the service was registered.getAllServiceReferences in interface BundleContextclazz - The class name with which the service was registered or
null for all services.filter - The filter expression or null for all services.ServiceReference objects or null if
no services are registered which satisfy the search.InvalidSyntaxException - If the specified filter contains
an invalid filter expression that cannot be parsed.public ServiceReference<?>[] getServiceReferences(java.lang.String clazz, java.lang.String filter) throws InvalidSyntaxException
BundleContextServiceReference objects. The returned array
of ServiceReference objects contains services that were
registered under the specified class, match the specified filter
expression, and the packages for the class names under which the services
were registered match the context bundle's packages as defined in
ServiceReference.isAssignableTo(Bundle, String).
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 any time.
The specified filter expression is used to select the registered
services whose service properties contain keys and values which satisfy
the filter expression. See Filter for a description of the filter
syntax. If the specified filter is null, all registered
services are considered to match the filter. If the specified
filter expression cannot be parsed, an
InvalidSyntaxException will be thrown with a human readable
message where the filter became unparsable.
The result is an array of ServiceReference objects for all
services that meet all of the following conditions:
clazz, is not null, the
service must have been registered with the specified class name. The
complete list of class names with which a service was registered is
available from the service's objectClass
property.filter is not null, the filter
expression must match the service.ServicePermission with the GET action for at least
one of the class names under which the service was registered.ServiceReference.isAssignableTo(Bundle, String) with the context
bundle and the class name on the service's ServiceReference
object must return truegetServiceReferences in interface BundleContextclazz - The class name with which the service was registered or
null for all services.filter - The filter expression or null for all services.ServiceReference objects or null if
no services are registered which satisfy the search.InvalidSyntaxException - If the specified filter contains
an invalid filter expression that cannot be parsed.public <S> java.util.Collection<ServiceReference<S>> getServiceReferences(java.lang.Class<S> clazz, java.lang.String filter) throws InvalidSyntaxException
BundleContextServiceReference objects. The returned
collection of ServiceReference objects contains services that
were registered under the name of the specified class, match the
specified filter expression, and the packages for the class names under
which the services were registered match the context bundle's packages as
defined in ServiceReference.isAssignableTo(Bundle, String).
The collection 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 any time.
The specified filter expression is used to select the registered
services whose service properties contain keys and values which satisfy
the filter expression. See Filter for a description of the filter
syntax. If the specified filter is null, all registered
services are considered to match the filter. If the specified
filter expression cannot be parsed, an
InvalidSyntaxException will be thrown with a human readable
message where the filter became unparsable.
The result is a collection of ServiceReference objects for all
services that meet all of the following conditions:
objectClass property.filter is not null, the filter
expression must match the service.ServicePermission with the GET action for at least
one of the class names under which the service was registered.ServiceReference.isAssignableTo(Bundle, String) with the context
bundle and the class name on the service's ServiceReference
object must return truegetServiceReferences in interface BundleContextS - Type of Serviceclazz - The class under whose name the service was registered. Must
not be null.filter - The filter expression or null for all services.ServiceReference objects. May be empty if
no services are registered which satisfy the search.InvalidSyntaxException - If the specified filter contains
an invalid filter expression that cannot be parsed.public <S> S getService(ServiceReference<S> ref)
BundleContextServiceReference object.
A bundle's use of a service object obtained from this method is tracked
by the bundle's use count of that service. Each time the service object
is returned by BundleContext.getService(ServiceReference) the context bundle's
use count for the service is incremented by one. Each time the service
object is released by BundleContext.ungetService(ServiceReference) the context
bundle's use count for the service is decremented by one.
When a bundle's use count for the service drops to zero, the bundle should no longer use the service object.
This method will always return null when the service associated
with the specified reference has been unregistered.
The following steps are required to get the service object:
null is returned.bundle or
prototype scope, the
ServiceFactory.getService(Bundle, ServiceRegistration) method is
called to supply the service object for the context bundle. If the
service object returned by the ServiceFactory object is
null, not an instanceof all the classes named when the
service was registered or the ServiceFactory object throws an
exception or will be recursively called for the context bundle,
null is returned and a Framework event of type
FrameworkEvent.ERROR containing a ServiceException
describing the error is fired. The supplied 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 service object for the
context bundle will return the cached service object.getService in interface BundleContextS - Type of Service.ref - A reference to the service.reference or null if the service is not
registered, the service object returned by a
ServiceFactory does not implement the classes under which
it was registered or the ServiceFactory threw an
exception.BundleContext.ungetService(ServiceReference),
ServiceFactorypublic boolean ungetService(ServiceReference<?> ref)
BundleContextServiceReference object. 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.
The service object must 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 required to release the service object:
false is returned.bundle or
prototype scope, the
ServiceFactory.ungetService(Bundle, ServiceRegistration, Object)
method is called to release the service object for the context bundle.true is returned.ungetService in interface BundleContextref - 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.getService(ServiceReference),
ServiceFactorypublic java.io.File getDataFile(java.lang.String s)
BundleContextFile object for a file in the persistent storage area
provided for the bundle by the Framework. This method will return
null if the platform does not have file system support.
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 an empty string as filename.
If the Java Runtime Environment supports permissions, the Framework will
ensure that the bundle has the java.io.FilePermission with
actions read,write,delete for all files
(recursively) in the persistent storage area provided for the context
bundle.
getDataFile in interface BundleContexts - 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.private void checkValidity()
public <S> ServiceRegistration<S> registerService(java.lang.Class<S> clazz, ServiceFactory<S> factory, java.util.Dictionary<java.lang.String,?> properties)
BundleContext
This method is otherwise identical to
BundleContext.registerService(Class, Object, Dictionary) and is provided to
return a type safe ServiceRegistration when registering a
ServiceFactory.
registerService in interface BundleContextS - Type of Service.clazz - The class under whose name the service can be located.factory - The 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.Class, org.osgi.framework.ServiceFactory, java.util.Dictionary)public <S> ServiceObjects<S> getServiceObjects(ServiceReference<S> ref)
BundleContextServiceObjects object for the service referenced by
the specified ServiceReference object.
The ServiceObjects object can be used to obtain multiple service
objects for services with prototype
scope.
For services with singleton or
bundle scope, the
ServiceObjects.getService() method behaves the same as the
BundleContext.getService(ServiceReference) method and the
ServiceObjects.ungetService(Object) method behaves the same as
the BundleContext.ungetService(ServiceReference) method. That is, only one,
use-counted service object is available from the ServiceObjects
object.
This method will always return null when the service associated
with the specified reference has been unregistered.
getServiceObjects in interface BundleContextS - Type of Service.ref - A reference to the service.ServiceObjects object for the service associated with
the specified reference or null if the service is
not registered.BundleContext.getServiceObjects(org.osgi.framework.ServiceReference)