@ProviderType public interface Subsystem
A subsystem may be scoped or unscoped. Scoped subsystems are
isolated by implicit or explicit sharing policies. Unscoped subsystems are
not isolated and, therefore, have no sharing policy. There are three standard
types
of subsystems.
Application
- An
implicitly scoped subsystem. Nothing is exported, and imports are computed
based on any unsatisfied content requirements.Composite
- An
explicitly scoped subsystem. The sharing policy is defined by metadata within
the subsystem archive.Feature
- An unscoped
subsystem.retrieved
from any subsystem within that region. This context may be used to monitor
activity occurring within the region.
A subsystem may have children
and, unless it's the
root subsystem, must have at least one parent
.
Subsystems become children of the subsystem in which they are installed.
Unscoped subsystems have more than one parent if they are installed in more
than one subsystem within the same region. The subsystem graph may be thought
of as an acyclic
digraph with one and only one source vertex, which is the root subsystem.
The edges have the child as the head and parent as the tail.
A subsystem has several identifiers.
Location
- An identifier specified by the client
as part of installation. It is guaranteed to be unique within the same
framework.ID
- An identifier generated by the
implementation as part of installation. It is guaranteed to be unique within
the same framework.Symbolic Name
/Version
-
The combination of symbolic name and version is guaranteed to be unique
within the same region. Although type
is not formally part
of the identity, two subsystems with the same symbolic names and versions but
different types are not considered to be equal.life cycle
. Which stage a
subsystem is in may be obtained from the subsystem's state
and is dependent on which life cycle operation is currently active or
was last invoked.
A subsystem archive is a ZIP file having an .esa
extension and
containing metadata describing the subsystem. The form of the metadata may be
a subsystem or deployment manifest, as well as any content resource files.
The manifests are optional and will be computed if not present. The subsystem
manifest headers may be retrieved
in raw
or localized forms. There are five standard
types
of resources that
may be included in a subsystem.
Bundle
- A bundle that is not a
fragment.Fragment
- A fragment bundle.Application
Subsystem
- An application subsystem.Composite Subsystem
-
A composite subsystem.Feature Subsystem
- A
feature subsystem.constituents
. There are several ways a resource may become a constituent of
a subsystem:
In addition to invoking one of the install methods, a subsystem instance may be obtained through the service registry. Each installed subsystem has a corresponding service registration. A subsystem service has the following properties.
ID
- The ID of the
subsystem.Symbolic Name
- The symbolic name of the subsystem.Version
- The
version of the subsystem.Type
- The type of the
subsystem.State
- The state of
the subsystem.Because a subsystem must be used to install other subsystems, a root subsystem is provided as a starting point. The root subsystem may only be obtained as a service and has the following characteristics.
0
.org.osgi.service.subsystem.root
.osgi.subsystem.application
with no imports.acceptDependencies
.Modifier and Type | Interface and Description |
---|---|
static class |
Subsystem.State
An enumeration of the possible states of a subsystem.
|
Modifier and Type | Method and Description |
---|---|
BundleContext |
getBundleContext()
Returns the bundle context of the region within which this subsystem
resides.
|
Collection<Subsystem> |
getChildren()
Returns the child subsystems of this subsystem.
|
Collection<Resource> |
getConstituents()
Returns the constituent resources of this subsystem.
|
Map<String,String> |
getDeploymentHeaders()
Returns the headers for this subsystem's deployment manifest.
|
String |
getLocation()
Returns the location identifier of this subsystem.
|
Collection<Subsystem> |
getParents()
Returns the parent subsystems of this subsystem.
|
Subsystem.State |
getState()
Returns the current state of this subsystem.
|
Map<String,String> |
getSubsystemHeaders(Locale locale)
Returns the headers for this subsystem's subsystem manifest.
|
long |
getSubsystemId()
Returns the identifier of this subsystem.
|
String |
getSymbolicName()
Returns the symbolic name of this subsystem.
|
String |
getType()
Returns the
type of this
subsystem. |
Version |
getVersion()
Returns the
version of this
subsystem. |
Subsystem |
install(String location)
Installs a subsystem from the specified location identifier.
|
Subsystem |
install(String location,
InputStream content)
Installs a subsystem from the specified content.
|
Subsystem |
install(String location,
InputStream content,
InputStream deploymentManifest)
Installs a subsystem from the specified content according to the
specified deployment manifest.
|
void |
start()
Starts this subsystem.
|
void |
stop()
Stops this subsystem.
|
void |
uninstall()
Uninstalls this subsystem.
|
BundleContext getBundleContext()
The bundle context offers the same perspective of any resource contained
by a subsystem within the region. It may be used, for example, to monitor
events internal to the region as well as external events visible to the
region. All subsystems within the same region have the same bundle
context. If this subsystem is in a state where the bundle context would
be invalid, null
is returned.
null
if this subsystem's state is in
INSTALL_FAILED
,
UNINSTALLED
.SecurityException
- If the caller does not have the appropriate
SubsystemPermission
[this,CONTEXT], and the runtime
supports permissions.Collection<Subsystem> getChildren()
IllegalStateException
- If this subsystem's state is in
INSTALL_FAILED
,
UNINSTALLED
.Map<String,String> getSubsystemHeaders(Locale locale)
Each key in the map is a header name and the value of the key is the
corresponding header value. Because header names are case-insensitive,
the methods of the map must treat the keys in a case-insensitive manner.
If the header name is not found, null
is returned. Both original
and derived headers will be included in the map.
This method must continue to return the headers while this subsystem is
in the INSTALL_FAILED
or
UNINSTALLED
states.
locale
- The locale for which translations are desired. The header
values are translated according to the specified locale. If the
specified locale is null
or not supported, the raw values
are returned. If the translation for a particular header is not
found, the raw value is returned.SecurityException
- If the caller does not have the appropriate
SubsystemPermission
[this,METADATA], and the runtime
supports permissions.String getLocation()
The location identifier is the location
that was passed to the
install
method of the
parent
subsystem. It is unique within the
framework.
This method must continue to return this subsystem's headers while this
subsystem is in the INSTALL_FAILED
or
UNINSTALLED
states.
SecurityException
- If the caller does not have the appropriate
SubsystemPermission
[this,METADATA], and the runtime
supports permissions.Collection<Subsystem> getParents()
IllegalStateException
- If this subsystem's state is in
INSTALL_FAILED
,
UNINSTALLED
.Collection<Resource> getConstituents()
IllegalStateException
- If this subsystem's state is in
INSTALL_FAILED
,
UNINSTALLED
.Map<String,String> getDeploymentHeaders()
Each key in the map is a header name and the value of the key is the
corresponding header value. Because header names are case-insensitive,
the methods of the map must treat the keys in a case-insensitive manner.
If the header name is not found, null
is returned. Both original
and derived headers will be included in the map.
This method must continue to return the headers while this subsystem is
in the INSTALL_FAILED
or
UNINSTALLED
states.
SecurityException
- If the caller does not have the appropriate
SubsystemPermission
[this,METADATA], and the runtime
supports permissions.Subsystem.State getState()
This method must continue to return this subsystem's state while this
subsystem is in the INSTALL_FAILED
or
UNINSTALLED
states.
long getSubsystemId()
The identifier is a monotonically increasing, non-negative integer automatically generated at installation time and guaranteed to be unique within the framework. The identifier of the root subsystem is zero.
This method must continue to return this subsystem's identifier while
this subsystem is in the INSTALL_FAILED
or
UNINSTALLED
states.
String getSymbolicName()
The subsystem symbolic name conforms to the same grammar rules as the bundle symbolic name and is derived from one of the following, in order.
Subsystem-SymbolicName
header, if specified.location
along with the
content
to the install
method.version
is unique within a region. The symbolic name of the root
subsystem is org.osgi.service.subsystem.root
.
This method must continue to return this subsystem's symbolic name while
this subsystem is in the INSTALL_FAILED
or
UNINSTALLED
states.
String getType()
type
of this
subsystem.
This method must continue to return this subsystem's type while this
subsystem is in the INSTALL_FAILED
or
UNINSTALLED
states.
Version getVersion()
version
of this
subsystem.
The subsystem version conforms to the same grammar rules as the bundle version and is derived from one of the following, in order.
Subsystem-Version
header, if specified.location
along with the
content
to the install
method.0.0.0
.symbolic name
and
version is unique within a region. The version of the root subsystem
matches this specification's version.
This method must continue to return this subsystem's version while this
subsystem is in the INSTALL_FAILED
or
UNINSTALLED
states.
Subsystem install(String location)
This method performs the same function as calling
install(String, InputStream)
with the specified location
identifier and null
as the content.
location
- The location identifier of the subsystem to install.IllegalStateException
- If this subsystem's state is in
INSTALLING
, INSTALL_FAILED
, UNINSTALLING
,
UNINSTALLED
.SubsystemException
- If the installation failed.SecurityException
- If the caller does not have the appropriate
SubsystemPermission
[installed subsystem,LIFECYCLE], and
the runtime supports permissions.install(String, InputStream)
Subsystem install(String location, InputStream content)
The specified location will be used as an identifier of the subsystem.
Every installed subsystem is uniquely identified by its location, which
is typically in the form of a URI. If the specified location conforms to
the subsystem-uri
grammar, the required symbolic name and
optional version information will be used as default values.
If the specified content is null
, a new input stream must be
created from which to read the subsystem by interpreting, in an
implementation dependent manner, the specified location.
A subsystem installation must be persistent. That is, an installed subsystem must remain installed across Framework and VM restarts.
All references to changing the state of this subsystem include both changing the state of the subsystem object as well as the state property of the subsystem service registration.
The following steps are required to install a subsystem.
INSTALLING
and register
a new subsystem service.ResolverHook
, disable runtime resolution
for the resources.INSTALLED
.
Implementations should be sensitive to the potential for long running
operations and periodically check the current thread for interruption. An
interrupted thread should result in a SubsystemException
with an
InterruptedException as the cause and be treated as an installation
failure.
All installation failure flows include the following, in order.
INSTALL_FAILED
.UNINSTALLING
.UNINSTALLED
.SubsystemException
with the cause of the installation
failure.location
- The location identifier of the subsystem to be installed.content
- The input stream from which this subsystem will be read or
null
to indicate the input stream must be created from the
specified location identifier. The input stream will always be
closed when this method completes, even if an exception is thrown.IllegalStateException
- If this subsystem's state is in
INSTALLING
, INSTALL_FAILED
, UNINSTALLING
,
UNINSTALLED
.SubsystemException
- If the installation failed.SecurityException
- If the caller does not have the appropriate
SubsystemPermission
[installed subsystem,LIFECYCLE], and
the runtime supports permissions.Subsystem install(String location, InputStream content, InputStream deploymentManifest)
This method installs a subsystem using the provided deployment manifest
instead of the one in the archive, if any, or a computed one. If the
deployment manifest is null
, the behavior is exactly the same as
in the install(String, InputStream)
method. Implementations must
support deployment manifest input streams in the format described by
section 134.2 of the Subsystem Service Specification. If the deployment
manifest does not conform to the subsystem manifest (see 134.15.2), the
installation fails.
location
- The location identifier of the subsystem to be installed.content
- The input stream from which this subsystem will be read or
null
to indicate the input stream must be created from the
specified location identifier. The input stream will always be
closed when this method completes, even if an exception is thrown.deploymentManifest
- The deployment manifest to use in lieu of the
one in the archive, if any, or a computed one.IllegalStateException
- If this subsystem's state is in
INSTALLING
, INSTALL_FAILED
, UNINSTALLING
,
UNINSTALLED
.SubsystemException
- If the installation failed.SecurityException
- If the caller does not have the appropriate
SubsystemPermission
[installed subsystem,LIFECYCLE], and
the runtime supports permissions.void start()
The following table shows which actions are associated with each state.
An action of Wait
means this method will block until a state
transition occurs, upon which the new state will be evaluated in order to
determine how to proceed. If a state transition does not occur in a
reasonable time while waiting then no action is taken and a
SubsystemException is thrown to indicate the subsystem was unable to be
started. An action of Return
means this method returns
immediately without taking any other action.
State | Action |
---|---|
INSTALLING |
Wait |
INSTALLED |
Resolve , Start |
INSTALL_FAILED |
IllegalStateException |
RESOLVING |
Wait |
RESOLVED |
Start |
STARTING |
Wait |
ACTIVE |
Return |
STOPPING |
Wait |
UNINSTALLING |
IllegalStateException |
UNINSTALLED |
IllegalStateException |
All references to changing the state of this subsystem include both changing the state of the subsystem object as well as the state property of the subsystem service registration.
A subsystem must be persistently started. That is, a started subsystem must be restarted across Framework and VM restarts, even if a start failure occurs.
The following steps are required to start this subsystem.
RESOLVED
state,
proceed to step 7.RESOLVING
.INSTALLED
.RESOLVED
.STARTING
.start order
. If an error
occurs while starting a resource, a start failure results with that error
as the cause.ACTIVE
.
Implementations should be sensitive to the potential for long running
operations and periodically check the current thread for interruption. An
interrupted thread should be treated as a start failure with an
InterruptedException
as the cause.
All start failure flows include the following, in order.
SubsystemException
- If this subsystem fails to start.IllegalStateException
- If this subsystem's state is in
INSTALL_FAILED
,
UNINSTALLING
, or
UNINSTALLED
, or if the state of at
least one of this subsystem's parents is not in
STARTING
, ACTIVE
.SecurityException
- If the caller does not have the appropriate
SubsystemPermission
[this,EXECUTE], and the runtime
supports permissions.void stop()
The following table shows which actions are associated with each state.
An action of Wait
means this method will block until a state
transition occurs, upon which the new state will be evaluated in order to
determine how to proceed. If a state transition does not occur in a
reasonable time while waiting then no action is taken and a
SubsystemException is thrown to indicate the subsystem was unable to be
stopped. An action of Return
means this method returns
immediately without taking any other action.
State | Action | |
---|---|---|
INSTALLING |
Wait |
|
INSTALLED |
Return |
|
INSTALL_FAILED |
IllegalStateException |
|
RESOLVING |
Wait |
|
RESOLVED |
Return |
|
STARTING |
Wait |
|
ACTIVE |
Stop |
|
STOPPING |
Wait |
|
UNINSTALLING |
IllegalStateException |
|
UNINSTALLED |
IllegalStateException |
A subsystem must be persistently stopped. That is, a stopped subsystem must remain stopped across Framework and VM restarts.
All references to changing the state of this subsystem include both changing the state of the subsystem object as well as the state property of the subsystem service registration.
The following steps are required to stop this subsystem.
STOPPING
.start
order
.RESOLVED
.STOPPING
state, every part of each step above
must be attempted. Errors subsequent to the first should be logged. Once
the stop process has completed, a SubsystemException must be thrown with
the initial error as the specified cause.
Implementations should be sensitive to the potential for long running
operations and periodically check the current thread for interruption, in
which case a SubsystemException with an InterruptedException as the cause
should be thrown. If an interruption occurs while waiting, this method
should terminate immediately. Once the transition to the
STOPPING
state has occurred, however, this method
must not terminate due to an interruption until the stop process has
completed.
SubsystemException
- If this subsystem fails to stop cleanly.IllegalStateException
- If this subsystem's state is in
INSTALL_FAILED
,
UNINSTALLING
, or
UNINSTALLED
.SecurityException
- If the caller does not have the appropriate
SubsystemPermission
[this,EXECUTE], and the runtime
supports permissions.void uninstall()
The following table shows which actions are associated with each state.
An action of Wait
means this method will block until a state
transition occurs, upon which the new state will be evaluated in order to
determine how to proceed. If a state transition does not occur in a
reasonable time while waiting then no action is taken and a
SubsystemException is thrown to indicate the subsystem was unable to be
uninstalled. An action of Return
means this method returns
immediately without taking any other action.
State | Action |
---|---|
INSTALLING |
Wait |
INSTALLED |
Uninstall |
INSTALL_FAILED |
Wait |
RESOLVING |
Wait |
RESOLVED |
Uninstall |
STARTING |
Wait |
ACTIVE |
Stop , Uninstall |
STOPPING |
Wait |
UNINSTALLING |
Wait |
UNINSTALLED |
Return |
All references to changing the state of this subsystem include both changing the state of the subsystem object as well as the state property of the subsystem service registration.
The following steps are required to uninstall this subsystem after being stopped if necessary.
INSTALLED
.UNINSTALLING
.UNINSTALLED
.UNINSTALLING
state, every part of each
step above must be attempted. Errors subsequent to the first should be
logged. Once the uninstall process has completed, a
SubsystemException
must be thrown with the specified cause.
Implementations should be sensitive to the potential for long running
operations and periodically check the current thread for interruption, in
which case a SubsystemException
with an
InterruptedException
as the cause should be thrown. If an
interruption occurs while waiting, this method should terminate
immediately. Once the transition to the UNINSTALLING
state has occurred, however, this method must not terminate
due to an interruption until the uninstall process has completed.
SubsystemException
- If this subsystem fails to uninstall cleanly.SecurityException
- If the caller does not have the appropriate
SubsystemPermission
[this,LIFECYCLE], and the runtime
supports permissions.Copyright © OSGi Alliance (2000, 2015). All Rights Reserved. Licensed under the OSGi Specification License, Version 2.0