C - The type of the component class.public interface ComponentContext<C>
| Modifier and Type | Method and Description |
|---|---|
org.osgi.framework.BundleContext |
getBundleContext()
The bundle context of the bundle that registered the component (normally it is the bundle that
contains the component implementation).
|
ComponentContainer<C> |
getComponentContainer()
The container of the component that is registered as an OSGi service and manages the lifecycle
of the component instance.
|
ComponentRevision<C> |
getComponentRevision()
A snapshot about the state of the component.
|
org.osgi.framework.ServiceReference<?> |
getComponentServiceReference()
Get the service that was registered when the component was opened.
|
Class<C> |
getComponentType()
The type of the component implementation.
|
C |
getInstance()
Returns the service instance that was instantiated by this component.
|
Map<String,Object> |
getProperties() |
<S> org.osgi.framework.ServiceRegistration<S> |
registerService(Class<S> clazz,
S service,
Dictionary<String,?> properties)
Registers the specified service object with the specified properties under the name of the
specified class with the Framework.
|
org.osgi.framework.ServiceRegistration<?> |
registerService(String[] clazzes,
Object service,
Dictionary<String,?> properties)
Registers the specified service object with the specified properties under the specified class
names into the Framework.
|
org.osgi.framework.ServiceRegistration<?> |
registerService(String clazz,
Object service,
Dictionary<String,?> properties)
Registers the specified service object with the specified properties under the specified class
name with the Framework.
|
org.osgi.framework.BundleContext getBundleContext()
ComponentContainer<C> getComponentContainer()
ComponentRevision<C> getComponentRevision()
org.osgi.framework.ServiceReference<?> getComponentServiceReference()
LogService.ServiceReference that offers the ComponentContainer and optionally
interfaces.C getInstance()
null if the component is not in
ComponentState.ACTIVE.<S> org.osgi.framework.ServiceRegistration<S> registerService(Class<S> clazz, S service, Dictionary<String,?> properties)
This method is otherwise identical to registerService(String, Object, Dictionary) and
is provided to return a type safe ServiceRegistration.
S - Type of Service.clazz - The class under whose name 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.IllegalStateException - If this BundleContext is no longer valid.registerService(String, Object, Dictionary)org.osgi.framework.ServiceRegistration<?> registerService(String clazz, Object service, Dictionary<String,?> properties)
This method is otherwise identical to 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.
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.IllegalStateException - If this BundleContext is no longer valid.registerService(String[], Object, Dictionary)org.osgi.framework.ServiceRegistration<?> registerService(String[] clazzes, Object service, Dictionary<String,?> properties)
ServiceRegistration 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
#getServiceReferences(Class, String), #getServiceReferences(String, String),
#getServiceReference(Class) or #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 is not a 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 service Constants.OBJECTCLASS containing all the specified
classes. Dictionary will be ignored.
ServiceEvent.REGISTERED is fired.
ServiceRegistration object for this registration is returned.
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(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.IllegalArgumentException - If one of the following is true:
service is null. service is not a
ServiceFactory object and is not an instance of all the named classes in
clazzes. properties contains case variants of the same key name.
SecurityException - If the caller does not have the ServicePermission to register the service for
all the named classes and the Java Runtime Environment supports permissions.IllegalStateException - If this BundleContext is no longer valid.ServiceRegistration,
ServiceFactoryCopyright © 2011–2015 Everit Kft.. All rights reserved.