public class ComponentStateHandler extends Object implements ILifecycleInfo
Example:
public class TestComponent implements IComponent, IConfigurable, IStartable, ILifecycleInfo {
private final ComponentStateHandler h;
public TestComponent() {
this.h = new ComponentStateHandler(TestComponent.class);
}
public ComponentState getState() {
return this.h.getState();
}
// ... other ILifecycleInfo methods ...
public configure(IConfiguration config) throws ConfigurationException {
this.h.preConfigure();
try {
// ...
throw new ConfigurationException("missing parameter");
}
catch (ConfigurationException ex) {
throw this.h.postConfigure(ex);
}
catch (Exception ex) {
throw new ConfigurationException(this.h.postConfigure(ex));
}
this.h.postConfigure();
}
public start() throws StartupException {
this.h.preStart();
try {
// ...
throw new StartupException("failed to start");
}
catch (StartupException ex) {
throw this.h.postStart(ex);
}
catch (Exception ex) {
throw new StartupException(this.h.postStartUp(ex));
}
this.h.postStart();
}
public someServiceMethod() throws ServiceException {
try {
if (!this.h.preService()) {
throw new ServiceException("Service not available");
}
// ...
}
finally {
this.h.postService();
}
}
}
Copyright (c) SAP AG 2001-2002
ComponentState| Modifier and Type | Field and Description |
|---|---|
protected Class |
cc |
protected ConfigurationException |
configException |
protected long |
configurationTime |
protected boolean |
configured |
protected boolean |
contextualized |
protected Date |
creationDate |
protected boolean |
isConfigurable |
protected boolean |
isContextualizable |
protected boolean |
isReconfigurable |
protected boolean |
isStartable |
protected boolean |
isSuspendable |
protected boolean |
isThreadSafe |
protected Date |
nextAutoRestartDate |
protected int |
numWorkers |
protected Date |
reconfigDate |
protected boolean |
started |
protected long |
startTime |
protected StartupException |
startupException |
protected ComponentState |
state |
protected boolean |
stopped |
protected boolean |
suspended |
protected Thread |
suspender |
| Constructor and Description |
|---|
ComponentStateHandler(Object component)
Constructs a new state handler instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
aquireWorker() |
long |
getConfigurationTime() |
Date |
getCreationDate()
Returns the date and time of the creation of the component instance.
|
ConfigurationException |
getLastConfigurationException()
Returns the exception thrown in the last call to
IConfigurable.configure(IConfiguration),
or IReconfigurable.reconfigure(IConfiguration). |
Date |
getLastReconfigurationDate()
Returns the date and time of the last reconfiguration of this component.
|
Date |
getNextAutoRestartDate()
Returns the date and time of the next automatic restart of the component.
|
long |
getStartTime() |
StartupException |
getStartupException()
Returns the exception thrown in the last call to
IStartable.start(),
Can be null . |
ComponentState |
getState()
Returns the current life-cycle state of the component.
|
void |
postConfigure() |
ConfigurationException |
postConfigure(ConfigurationException x) |
void |
postContextualize() |
ContextException |
postContextualize(ContextException x) |
void |
postReconfigure() |
ConfigurationException |
postReconfigure(ConfigurationException x) |
void |
postResume() |
void |
postService()
This method should be balanced with a
preService , and should
occur in a finally statement so that the balance is guaranteed. |
void |
postStart() |
StartupException |
postStart(ConfigurationException x) |
StartupException |
postStart(StartupException x) |
void |
postStop() |
void |
postSuspend() |
void |
preConfigure() |
void |
preContextualize() |
void |
preReconfigure() |
void |
preResume() |
boolean |
preService()
Returns true if a component specific service method can be called.
|
void |
preStart() |
void |
preStop() |
void |
preSuspend() |
protected void |
releaseWorker() |
protected void |
startMonitor() |
protected void |
stopMonitor() |
protected final Class cc
protected final boolean isContextualizable
protected final boolean isConfigurable
protected final boolean isStartable
protected final boolean isSuspendable
protected final boolean isReconfigurable
protected final boolean isThreadSafe
protected boolean contextualized
protected boolean configured
protected boolean started
protected boolean stopped
protected boolean suspended
protected ComponentState state
protected ConfigurationException configException
protected StartupException startupException
protected Date creationDate
protected Date reconfigDate
protected Date nextAutoRestartDate
protected long startTime
protected long configurationTime
protected transient int numWorkers
protected transient Thread suspender
public ComponentStateHandler(Object component)
component - the object of the componentpublic Date getCreationDate()
ILifecycleInfonull . This property usually makes sense only for components
that implement the IThreadSafe interface.getCreationDate in interface ILifecycleInfonull .public ComponentState getState()
ILifecycleInfonull
.getState in interface ILifecycleInfonull
.public void preContextualize()
public ContextException postContextualize(ContextException x) throws ContextException
ContextExceptionpublic void postContextualize()
public void preConfigure()
public ConfigurationException postConfigure(ConfigurationException x)
public void postConfigure()
public void preStart()
public StartupException postStart(StartupException x)
public StartupException postStart(ConfigurationException x)
public void postStart()
public void preStop()
public void postStop()
public void preSuspend()
public void postSuspend()
public void preResume()
throws IllegalStateException
IllegalStateExceptionpublic void postResume()
public void preReconfigure()
public ConfigurationException postReconfigure(ConfigurationException x)
public void postReconfigure()
public boolean preService()
This method should be used very carefully to avoid unintended compromise of
the service.It should always be balanced with a postService .
true if a component specific service method can be called,
otherwise return falsepostService()public void postService()
preService , and should
occur in a finally statement so that the balance is guaranteed. The
following is an example.
stateHandler.preService();
try {
// do something
}
finally {
stateHandler.postService();
}
preService()public ConfigurationException getLastConfigurationException()
ILifecycleInfoIConfigurable.configure(IConfiguration),
or IReconfigurable.reconfigure(IConfiguration). Can be
null .getLastConfigurationException in interface ILifecycleInfonull.public StartupException getStartupException()
ILifecycleInfoIStartable.start(),
Can be null .getStartupException in interface ILifecycleInfonull.public Date getLastReconfigurationDate()
ILifecycleInfonull .getLastReconfigurationDate in interface ILifecycleInfonull .public Date getNextAutoRestartDate()
ILifecycleInfonull .getNextAutoRestartDate in interface ILifecycleInfonull .AutoRestartExceptionpublic long getStartTime()
public long getConfigurationTime()
protected void startMonitor()
protected void stopMonitor()
protected void aquireWorker()
protected void releaseWorker()
| Access Rights |
|---|
| SC | DC | Public Part | ACH |
|---|---|---|---|
[sap.com] KMC-CM
|
[sap.com] tc/km/frwk
|
api
|
EP-KM-CM
|
[sap.com] KMC-WPC
|
[sap.com] tc/kmc/wpc/wpcfacade
|
api
|
EP-PIN-WPC-WCM
|
Copyright 2021 SAP SE Complete Copyright Notice