|
SAP NetWeaver '04 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.sapportals.wcm.crt.component.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 java.lang.Class |
cc
|
protected ConfigurationException |
configException
|
protected long |
configurationTime
|
protected boolean |
configured
|
protected boolean |
contextualized
|
protected java.util.Date |
creationDate
|
protected boolean |
isConfigurable
|
protected boolean |
isContextualizable
|
protected boolean |
isReconfigurable
|
protected boolean |
isStartable
|
protected boolean |
isSuspendable
|
protected boolean |
isThreadSafe
|
protected java.util.Date |
nextAutoRestartDate
|
protected int |
numWorkers
|
protected java.util.Date |
reconfigDate
|
protected boolean |
started
|
protected long |
startTime
|
protected StartupException |
startupException
|
protected ComponentState |
state
|
protected boolean |
stopped
|
protected boolean |
suspended
|
protected java.lang.Thread |
suspender
|
| Constructor Summary | |
ComponentStateHandler(java.lang.Object component)
Constructs a new state handler instance. |
|
| Method Summary | |
protected void |
aquireWorker()
|
long |
getConfigurationTime()
|
java.util.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). |
java.util.Date |
getLastReconfigurationDate()
Returns the date and time of the last reconfiguration of this component. |
java.util.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 java.lang.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 java.util.Date creationDate
protected java.util.Date reconfigDate
protected java.util.Date nextAutoRestartDate
protected long startTime
protected long configurationTime
protected transient int numWorkers
protected transient java.lang.Thread suspender
| Constructor Detail |
public ComponentStateHandler(java.lang.Object component)
component - the object of the component| Method Detail |
public java.util.Date getCreationDate()
ILifecycleInfonull . This property usually makes sense only for components
that implement the IThreadSafe interface.
- Specified by:
getCreationDate in interface ILifecycleInfo
- Following copied from interface:
com.sapportals.wcm.crt.component.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
- Following copied from interface:
com.sapportals.wcm.crt.component.ILifecycleInfo
- Returns:
- the current life-cycle state of the component. Can be
null
.
public void preContextualize()
public ContextException postContextualize(ContextException x)
throws ContextException
public 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 java.lang.IllegalStateException
public 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 .
postService()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 ILifecycleInfocom.sapportals.wcm.crt.component.ILifecycleInfopublic StartupException getStartupException()
ILifecycleInfoIStartable.start(),
Can be null .getStartupException in interface ILifecycleInfocom.sapportals.wcm.crt.component.ILifecycleInfopublic java.util.Date getLastReconfigurationDate()
ILifecycleInfonull .
- Specified by:
getLastReconfigurationDate in interface ILifecycleInfo
- Following copied from interface:
com.sapportals.wcm.crt.component.ILifecycleInfo
- Returns:
- the date and time of the last reconfiguration of this component.
Can be
null .
public java.util.Date getNextAutoRestartDate()
ILifecycleInfonull .
- Specified by:
getNextAutoRestartDate in interface ILifecycleInfo
- Following copied from interface:
com.sapportals.wcm.crt.component.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()
|
SAP NetWeaver '04 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||