public abstract class ApplicationHandle
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
APPLICATION_DESCRIPTOR
The property key for the pid of the corresponding application descriptor.
|
static java.lang.String |
APPLICATION_PID
The property key for the unique identifier (PID) of the application
instance.
|
static java.lang.String |
APPLICATION_STATE
The property key for the state of this application instance.
|
static java.lang.String |
APPLICATION_SUPPORTS_EXITVALUE
The property key for the supports exit value property of this application
instance.
|
static java.lang.String |
RUNNING
The application instance is running.
|
static java.lang.String |
STOPPING
The application instance is being stopped.
|
Modifier | Constructor and Description |
---|---|
protected |
ApplicationHandle(java.lang.String instanceId,
ApplicationDescriptor descriptor)
Application instance identifier is specified by the container when the
instance is created.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
The application instance's lifecycle state can be influenced by this
method.
|
protected abstract void |
destroySpecific()
Called by the destroy() method to perform application model specific
steps to stop and destroy an application instance safely.
|
ApplicationDescriptor |
getApplicationDescriptor()
Retrieves the
ApplicationDescriptor to which this
ApplicationHandle belongs. |
java.lang.Object |
getExitValue(long timeout)
Returns the exit value for the application instance.
|
java.lang.String |
getInstanceId()
Returns the unique identifier of this instance.
|
abstract java.lang.String |
getState()
Get the state of the application instance.
|
public static final java.lang.String APPLICATION_PID
public static final java.lang.String APPLICATION_DESCRIPTOR
public static final java.lang.String APPLICATION_STATE
public static final java.lang.String APPLICATION_SUPPORTS_EXITVALUE
public static final java.lang.String RUNNING
public static final java.lang.String STOPPING
destroy()
method.protected ApplicationHandle(java.lang.String instanceId, ApplicationDescriptor descriptor)
service.pid
service property of this application handle.
The instance identifier should follow the following scheme:
<application descriptor PID>.<index> where
<application descriptor PID> is the PID of the corresponding
ApplicationDescriptor
and <index> is a unique
integer index assigned by the application container. Even after
destroying the application index the same index value should not be
reused in a reasonably long timeframe.
instanceId
- the instance identifier of the represented application
instance. It must not be null.descriptor
- the ApplicationDescriptor
of the represented
application instance. It must not be null.java.lang.NullPointerException
- if any of the arguments is null.public final ApplicationDescriptor getApplicationDescriptor()
ApplicationDescriptor
to which this
ApplicationHandle
belongs.ApplicationDescriptor
public abstract java.lang.String getState()
java.lang.IllegalStateException
- if the application handle is unregisteredpublic java.lang.Object getExitValue(long timeout) throws ApplicationException, java.lang.InterruptedException
ApplicationException
is
thrown.ApplicationException
is thrown.
The default implementation throws an
UnsupportedOperationException
. The application model should
override this method if exit values are supported.
timeout
- The maximum time in milliseconds to wait for the
application to timeout.java.lang.UnsupportedOperationException
- If the application model does not
support exit values.java.lang.InterruptedException
- If the thread is interrupted while waiting
for the timeout.ApplicationException
- If the application has not terminated. The
error code will be
ApplicationException.APPLICATION_EXITVALUE_NOT_AVAILABLE
.public final java.lang.String getInstanceId()
public final void destroy()
The method must check if the lifecycle transition is valid; a STOPPING application cannot be stopped. If it is invalid then the method must exit. Otherwise the lifecycle state of the application instance must be set to STOPPING. Then the destroySpecific() method must be called to perform any application model specific steps for safe stopping of the represented application instance.
At the end the ApplicationHandle
must be unregistered. This
method should free all the resources related to this
ApplicationHandle
.
When this method is completed the application instance has already made its operations for safe stopping, the ApplicationHandle has been unregistered and its related resources has been freed. Further calls on this application should not be made because they may have unexpected results.
java.lang.SecurityException
- if the caller doesn't have "lifecycle"
ApplicationAdminPermission
for the corresponding
application.java.lang.IllegalStateException
- if the application handle is unregisteredprotected abstract void destroySpecific()
java.lang.IllegalStateException
- if the application handle is unregisteredCopyright © OSGi Alliance (2000, 2018). All Rights Reserved. Licensed under the OSGi Specification License, Version 2.0