|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.aries.subsystem.core.internal.BasicSubsystem
public class BasicSubsystem
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.osgi.service.subsystem.Subsystem |
---|
Subsystem.State |
Field Summary | |
---|---|
static String |
ROOT_LOCATION
|
static String |
ROOT_SYMBOLIC_NAME
|
static org.osgi.framework.Version |
ROOT_VERSION
|
Constructor Summary | |
---|---|
BasicSubsystem(File file)
|
|
BasicSubsystem(org.apache.aries.util.filesystem.IDirectory directory)
|
|
BasicSubsystem(SubsystemResource resource)
|
Method Summary | |
---|---|
void |
addRequirements(Collection<org.osgi.resource.Requirement> requirements)
Adds the specified requirements to this subsystem's sharing policy. |
boolean |
equals(Object o)
|
org.osgi.framework.BundleContext |
getBundleContext()
Returns the bundle context of the region within which this subsystem resides. |
List<org.osgi.resource.Capability> |
getCapabilities(String namespace)
|
Collection<Subsystem> |
getChildren()
Returns the child subsystems of this subsystem. |
Collection<org.osgi.resource.Resource> |
getConstituents()
Returns the constituent resources of this subsystem. |
String |
getLocation()
Returns the location identifier of this subsystem. |
Collection<Subsystem> |
getParents()
Returns the parent subsystems of this subsystem. |
List<org.osgi.resource.Requirement> |
getRequirements(String namespace)
|
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. |
org.osgi.framework.Version |
getVersion()
Returns the version of this
subsystem. |
int |
hashCode()
|
AriesSubsystem |
install(String location)
Installs a subsystem from the specified location identifier. |
AriesSubsystem |
install(String location,
org.apache.aries.util.filesystem.IDirectory content)
Installs a subsystem from the specified location identifier and content. |
AriesSubsystem |
install(String location,
InputStream content)
Installs a subsystem from the specified content. |
void |
start()
Starts this subsystem. |
void |
stop()
Stops this subsystem. |
void |
uninstall()
Uninstalls this subsystem. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ROOT_SYMBOLIC_NAME
public static final org.osgi.framework.Version ROOT_VERSION
public static final String ROOT_LOCATION
Constructor Detail |
---|
public BasicSubsystem(SubsystemResource resource) throws URISyntaxException, IOException, org.osgi.framework.BundleException, org.osgi.framework.InvalidSyntaxException
URISyntaxException
IOException
org.osgi.framework.BundleException
org.osgi.framework.InvalidSyntaxException
public BasicSubsystem(File file) throws IOException, URISyntaxException, org.osgi.service.resolver.ResolutionException
IOException
URISyntaxException
org.osgi.service.resolver.ResolutionException
public BasicSubsystem(org.apache.aries.util.filesystem.IDirectory directory) throws IOException, URISyntaxException, org.osgi.service.resolver.ResolutionException
IOException
URISyntaxException
org.osgi.service.resolver.ResolutionException
Method Detail |
---|
public boolean equals(Object o)
equals
in interface org.osgi.resource.Resource
equals
in class Object
public List<org.osgi.resource.Capability> getCapabilities(String namespace)
getCapabilities
in interface org.osgi.resource.Resource
public List<org.osgi.resource.Requirement> getRequirements(String namespace)
getRequirements
in interface org.osgi.resource.Resource
public int hashCode()
hashCode
in interface org.osgi.resource.Resource
hashCode
in class Object
public org.osgi.framework.BundleContext getBundleContext()
Subsystem
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.
getBundleContext
in interface Subsystem
null
if this subsystem's state is in
INSTALL_FAILED
,
UNINSTALLED
.public Collection<Subsystem> getChildren()
Subsystem
getChildren
in interface Subsystem
public Map<String,String> getSubsystemHeaders(Locale locale)
Subsystem
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.
getSubsystemHeaders
in interface Subsystem
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.
public String getLocation()
Subsystem
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.
getLocation
in interface Subsystem
public Collection<Subsystem> getParents()
Subsystem
getParents
in interface Subsystem
public Collection<org.osgi.resource.Resource> getConstituents()
Subsystem
getConstituents
in interface Subsystem
public Subsystem.State getState()
Subsystem
This method must continue to return this subsystem's state while this
subsystem is in the INSTALL_FAILED
or
UNINSTALLED
states.
getState
in interface Subsystem
public long getSubsystemId()
Subsystem
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.
getSubsystemId
in interface Subsystem
public String getSymbolicName()
Subsystem
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.
getSymbolicName
in interface Subsystem
public String getType()
Subsystem
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.
getType
in interface Subsystem
public org.osgi.framework.Version getVersion()
Subsystem
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.
getVersion
in interface Subsystem
public AriesSubsystem install(String location)
Subsystem
This method performs the same function as calling
Subsystem.install(String, InputStream)
with the specified location
identifier and null
as the content.
install
in interface AriesSubsystem
install
in interface Subsystem
location
- The location identifier of the subsystem to install.
Subsystem.install(String, InputStream)
public AriesSubsystem install(String location, InputStream content)
Subsystem
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.
install
in interface AriesSubsystem
install
in interface Subsystem
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.
public void start()
Subsystem
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.
STARTING
then change
the state to STOPPING
and stop all resources that
were started as part of this operation.INSTALLED
or
RESOLVED
.
start
in interface Subsystem
public void stop()
Subsystem
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.
stop
in interface Subsystem
public void uninstall()
Subsystem
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.
uninstall
in interface Subsystem
public void addRequirements(Collection<org.osgi.resource.Requirement> requirements)
AriesSubsystem
The sharing policy of this subsystem's region is updated with the specified requirements (i.e. imports). Requirements already part of the sharing policy are ignored. Upon return, constituents of this subsystem will be allowed to resolve against matching capabilities that are visible to the parent subsystems.
addRequirements
in interface AriesSubsystem
public AriesSubsystem install(String location, org.apache.aries.util.filesystem.IDirectory content)
AriesSubsystem
This method performs the same function as calling
AriesSubsystem.install(String, InputStream)
except the content is retrieved
from the specified IDirectory
instead.
install
in interface AriesSubsystem
location
- The location identifier of the subsystem to install.content
- The directory from which this subsystem will be read or
null
to indicate the directory must be created from the
specified location identifier.
AriesSubsystem.install(String, InputStream)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |