@ProviderType public interface ComponentContext
A component instance may obtain its Component Context object through its activate, modified, and deactivate methods.
Modifier and Type | Method and Description |
---|---|
void |
disableComponent(String name)
Disables the specified component name.
|
void |
enableComponent(String name)
Enables the specified component name.
|
BundleContext |
getBundleContext()
Returns the
BundleContext of the bundle which declares this
component. |
<S> ComponentInstance<S> |
getComponentInstance()
Returns the Component Instance object for the component instance
associated with this Component Context.
|
Dictionary<String,Object> |
getProperties()
Returns the component properties for this Component Context.
|
ServiceReference<?> |
getServiceReference()
If the component instance is registered as a service using the
service element, then this method returns the service reference
of the service provided by this component instance. |
Bundle |
getUsingBundle()
If the component instance is registered as a service using the
servicescope="bundle" or servicescope="prototype"
attribute, then this method returns the bundle using the service provided
by the component instance. |
<S> S |
locateService(String name)
Returns the service object for the specified reference name.
|
<S> S |
locateService(String name,
ServiceReference<S> reference)
Returns the service object for the specified reference name and
ServiceReference . |
Object[] |
locateServices(String name)
Returns the service objects for the specified reference name.
|
Dictionary<String,Object> getProperties()
<S> S locateService(String name)
If the cardinality of the reference is 0..n
or 1..n
and
multiple services are bound to the reference, 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.
name
- The name of a reference as specified in a reference
element in this component's description.null
if
the reference cardinality is 0..1
or 0..n
and no
bound service is available.ComponentException
- If Service Component Runtime catches an
exception while activating the bound service.<S> S locateService(String name, ServiceReference<S> reference)
ServiceReference
.S
- Type of Service.name
- The name of a reference as specified in a reference
element in this component's description.reference
- The ServiceReference
to a bound service. This
must be a ServiceReference
provided to the component via
the bind or unbind method for the specified reference name.null
if
the specified ServiceReference
is not a bound service for
the specified reference name.ComponentException
- If Service Component Runtime catches an
exception while activating the bound service.Object[] locateServices(String name)
name
- The name of a reference as specified in a reference
element in this component's description.null
if the reference cardinality is 0..1
or
0..n
and no bound service is available. If the reference
cardinality is 0..1
or 1..1
and a bound service
is available, the array will have exactly one element.ComponentException
- If Service Component Runtime catches an
exception while activating a bound service.BundleContext getBundleContext()
BundleContext
of the bundle which declares this
component.BundleContext
of the bundle declares this component.Bundle getUsingBundle()
servicescope="bundle"
or servicescope="prototype"
attribute, then this method returns the bundle using the service provided
by the component instance.
This method will return null
if:
servicescope="bundle"
or servicescope="prototype"
attribute, then all bundles using the service provided by the component
instance will share the same component instance.null
.<S> ComponentInstance<S> getComponentInstance()
void enableComponent(String name)
This method must return after changing the enabled state of the specified component name. Any actions that result from this, such as activating or deactivating a component configuration, must occur asynchronously to this method call.
name
- The name of a component or null
to indicate all
components in the bundle.void disableComponent(String name)
This method must return after changing the enabled state of the specified component name. Any actions that result from this, such as activating or deactivating a component configuration, must occur asynchronously to this method call.
name
- The name of a component.ServiceReference<?> getServiceReference()
service
element, then this method returns the service reference
of the service provided by this component instance.
This method will return null
if the component instance is not
registered as a service.
ServiceReference
object for the component instance or
null
if the component instance is not registered as a
service.Copyright © Contributors to the Eclipse Foundation Licensed under the Eclipse Foundation Specification License – v1.0