|
SAP NetWeaver 7.40 SP 07 KMC | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sapportals.wcm.crt.component.ComponentStateHandler
public class ComponentStateHandler
This class must be used for state and life-cycle handling in component implementations. All of the relevant pre and post methods MUST be called.
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| Field Summary | |
|---|---|
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 Summary | |
|---|---|
ComponentStateHandler(Object component)
Constructs a new state handler instance. |
|
| Method Summary | |
|---|---|
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()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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
| Constructor Detail |
|---|
public ComponentStateHandler(Object component)
component - the object of the component| Method Detail |
|---|
public Date getCreationDate()
ILifecycleInfonull . This property usually makes sense only for components
that implement the IThreadSafe interface.
- Specified by:
getCreationDate in interface ILifecycleInfo
- Returns:
- the date and time of the creation of the component instance. Can be
null .
public ComponentState getState()
ILifecycleInfonull
.
- Specified by:
getState in interface ILifecycleInfo
- Returns:
- the current life-cycle state of the component. Can be
null
.
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 .
- Specified by:
getLastReconfigurationDate in interface ILifecycleInfo
- Returns:
- the date and time of the last reconfiguration of this component.
Can be
null .
public Date getNextAutoRestartDate()
ILifecycleInfonull .
- Specified by:
getNextAutoRestartDate in interface ILifecycleInfo
- Returns:
- the date and time of the next automatic restart of the component.
Can be
null .- See Also:
AutoRestartException
public 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
|
|
SAP NetWeaver 7.40 SP 07 KMC | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||