Top Description Methods
org.osgi.service.component.runtime

public Interface ServiceComponentRuntime

Annotations
@ProviderType
Imports
java.util.Collection, org.osgi.annotation.versioning.ProviderType, org.osgi.framework.Bundle, .Constants, org.osgi.service.component.ComponentContext, org.osgi.service.component.runtime.dto.ComponentConfigurationDTO, .ComponentDescriptionDTO, org.osgi.util.promise.Promise

The ServiceComponentRuntime service represents the Declarative Services actor, known as Service Component Runtime (SCR), that manages the service components and their life cycle. The ServiceComponentRuntime service allows introspection of the components managed by Service Component Runtime.

This service differentiates between a ComponentDescriptionDTO and a ComponentConfigurationDTO. A ComponentDescriptionDTO is a representation of a declared component description. A ComponentConfigurationDTO is a representation of an actual instance of a declared component description parameterized by component properties.

This service must be registered with a Constants#SERVICE_CHANGECOUNT service property that must be updated each time the SCR DTOs available from this service change.

Access to this service requires the ServicePermission[ServiceComponentRuntime, GET] permission. It is intended that only administrative bundles should be granted this permission to limit access to the potentially intrusive methods provided by this service.

Author
$Id: 28014e32a90b2bdecc1236af2e815f6230811bf4 $
Since
1.3

Method Summary

Modifier and TypeMethod and Description
public Promise<Void>

Returns:

A promise that will be resolved when the actions that result from changing the enabled state of the specified component have completed. If the provided description does not belong to an active bundle, a failed promise is returned.
disableComponent
(ComponentDescriptionDTO
The component description to disable. Must not be null.
description
)

Disables the specified component description.

public Promise<Void>

Returns:

A promise that will be resolved when the actions that result from changing the enabled state of the specified component have completed. If the provided description does not belong to an active bundle, a failed promise is returned.
enableComponent
(ComponentDescriptionDTO
The component description to enable. Must not be null.
description
)

Enables the specified component description.

public Collection<ComponentConfigurationDTO>

Returns:

A collection containing a snapshot of the current component configurations for the specified component description. An empty collection is returned if there are none or if the provided component description does not belong to an active bundle.
getComponentConfigurationDTOs
(ComponentDescriptionDTO
The component description. Must not be null.
description
)

Returns the component configurations for the specified component description.

public ComponentDescriptionDTO

Returns:

The declared component description or null if the specified bundle is not active or does not declare a component description with the specified name.
getComponentDescriptionDTO
(Bundle
The bundle declaring the component description. Must not be null.
bundle
,
String
The name of the component description. Must not be null.
name
)

Returns the ComponentDescriptionDTO declared with the specified name by the specified bundle.

public Collection<ComponentDescriptionDTO>

Returns:

The declared component descriptions of the specified active bundles. An empty collection is returned if there are no component descriptions for the specified active bundles.
getComponentDescriptionDTOs
(Bundle...
The bundles whose declared component descriptions are to be returned. Specifying no bundles, or the equivalent of an empty Bundle array, will return the declared component descriptions from all active bundles.
bundles
)

Returns the component descriptions declared by the specified active bundles.

public boolean

Returns:

true if the specified component description is currently enabled. Otherwise, false.
isComponentEnabled
(ComponentDescriptionDTO
The component description. Must not be null.
description
)

Returns whether the specified component description is currently enabled.

Method Detail

disableComponentback to summary
public Promise<Void> disableComponent(ComponentDescriptionDTO description)

Disables the specified component description.

If the specified component description is currently disabled, this method has no effect.

This method must return after changing the enabled state of the specified component description. Any actions that result from this, such as activating or deactivating a component configuration, must occur asynchronously to this method call.

Parameters
description:ComponentDescriptionDTO

The component description to disable. Must not be null.

Returns:Promise<Void>

A promise that will be resolved when the actions that result from changing the enabled state of the specified component have completed. If the provided description does not belong to an active bundle, a failed promise is returned.

See Also
isComponentEnabled(ComponentDescriptionDTO)
enableComponentback to summary
public Promise<Void> enableComponent(ComponentDescriptionDTO description)

Enables the specified component description.

If the specified component description is currently enabled, this method has no effect.

This method must return after changing the enabled state of the specified component description. Any actions that result from this, such as activating or deactivating a component configuration, must occur asynchronously to this method call.

Parameters
description:ComponentDescriptionDTO

The component description to enable. Must not be null.

Returns:Promise<Void>

A promise that will be resolved when the actions that result from changing the enabled state of the specified component have completed. If the provided description does not belong to an active bundle, a failed promise is returned.

See Also
isComponentEnabled(ComponentDescriptionDTO)
getComponentConfigurationDTOsback to summary
public Collection<ComponentConfigurationDTO> getComponentConfigurationDTOs(ComponentDescriptionDTO description)

Returns the component configurations for the specified component description.

Parameters
description:ComponentDescriptionDTO

The component description. Must not be null.

Returns:Collection<ComponentConfigurationDTO>

A collection containing a snapshot of the current component configurations for the specified component description. An empty collection is returned if there are none or if the provided component description does not belong to an active bundle.

getComponentDescriptionDTOback to summary
public ComponentDescriptionDTO getComponentDescriptionDTO(Bundle bundle, String name)

Returns the ComponentDescriptionDTO declared with the specified name by the specified bundle.

Only component descriptions from active bundles are returned. null if no such component is declared by the given bundle or the bundle is not active.

Parameters
bundle:Bundle

The bundle declaring the component description. Must not be null.

name:String

The name of the component description. Must not be null.

Returns:ComponentDescriptionDTO

The declared component description or null if the specified bundle is not active or does not declare a component description with the specified name.

getComponentDescriptionDTOsback to summary
public Collection<ComponentDescriptionDTO> getComponentDescriptionDTOs(Bundle... bundles)

Returns the component descriptions declared by the specified active bundles.

Only component descriptions from active bundles are returned. If the specified bundles have no declared components or are not active, an empty collection is returned.

Parameters
bundles:Bundle[]

The bundles whose declared component descriptions are to be returned. Specifying no bundles, or the equivalent of an empty Bundle array, will return the declared component descriptions from all active bundles.

Returns:Collection<ComponentDescriptionDTO>

The declared component descriptions of the specified active bundles. An empty collection is returned if there are no component descriptions for the specified active bundles.

isComponentEnabledback to summary
public boolean isComponentEnabled(ComponentDescriptionDTO description)

Returns whether the specified component description is currently enabled.

The enabled state of a component description is initially set by the enabled attribute of the component description.

Parameters
description:ComponentDescriptionDTO

The component description. Must not be null.

Returns:boolean

true if the specified component description is currently enabled. Otherwise, false.

See Also
enableComponent(ComponentDescriptionDTO), disableComponent(ComponentDescriptionDTO), ComponentContext#disableComponent(String), ComponentContext#enableComponent(String)