public abstract class ApplicationHandle extends Object
Modifier and Type | Field and Description |
---|---|
static String |
APPLICATION_DESCRIPTOR
The property key for the pid of the corresponding application descriptor.
|
static String |
APPLICATION_PID
The property key for the unique identifier (PID) of the application
instance.
|
static String |
APPLICATION_STATE
The property key for the state of this application instance.
|
static String |
APPLICATION_SUPPORTS_EXITVALUE
The property key for the supports exit value property of this application
instance.
|
static String |
RUNNING
The application instance is running.
|
static String |
STOPPING
The application instance is being stopped.
|
Modifier | Constructor and Description |
---|---|
protected |
ApplicationHandle(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. |
Object |
getExitValue(long timeout)
Returns the exit value for the application instance.
|
String |
getInstanceId()
Returns the unique identifier of this instance.
|
abstract String |
getState()
Get the state of the application instance.
|
public static final String APPLICATION_PID
public static final String APPLICATION_DESCRIPTOR
public static final String APPLICATION_STATE
public static final String APPLICATION_SUPPORTS_EXITVALUE
public static final String RUNNING
public static final String STOPPING
destroy()
method.protected ApplicationHandle(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.NullPointerException
- if any of the arguments is null.public final ApplicationDescriptor getApplicationDescriptor()
ApplicationDescriptor
to which this
ApplicationHandle
belongs.ApplicationDescriptor
public abstract String getState()
IllegalStateException
- if the application handle is unregisteredpublic Object getExitValue(long timeout) throws ApplicationException, 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.UnsupportedOperationException
- If the application model does not
support exit values.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 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.
SecurityException
- if the caller doesn't have "lifecycle"
ApplicationAdminPermission
for the corresponding
application.IllegalStateException
- if the application handle is unregisteredprotected abstract void destroySpecific()
IllegalStateException
- if the application handle is unregisteredCopyright © OSGi Alliance (2000, 2015). All Rights Reserved. Licensed under the OSGi Specification License, Version 2.0