public class DummyService extends java.lang.Object implements ServiceControllerAction, ActionFactory<ServiceControllerAction>
System.out
every x seconds (default = 10) when
the service is running. It will also print out messages when the service
is started and stopped and in some other places.
The service is it's own action factory and controller.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
extensionId |
private long |
interval |
private boolean |
running |
private java.util.TimerTask |
timer |
Constructor and Description |
---|
DummyService() |
Modifier and Type | Method and Description |
---|---|
ServiceControllerAction[] |
getActions(InvokationContext context)
This method may be called one or several times for each request.
|
boolean |
isRunning()
Is the service running or not?
|
boolean |
prepareContext(InvokationContext context)
This method is called once for each request/use of an
extension and have two purposes:
The factory should decide if the extension should be enabled or
not.
|
void |
setInterval(java.lang.String seconds)
Set the interval between writes to stdout.
|
void |
start()
Start the service if it is not already running.
|
void |
stop()
Stop the service if it is running.
|
java.lang.String |
toString() |
private boolean running
private java.util.TimerTask timer
private long interval
private java.lang.String extensionId
public ServiceControllerAction[] getActions(InvokationContext context)
ActionFactory
getActions
in interface ActionFactory<ServiceControllerAction>
context
- The current invokation contextpublic boolean prepareContext(InvokationContext context)
ActionFactory
JspContext
.
prepareContext
in interface ActionFactory<ServiceControllerAction>
context
- The current invokation contextpublic boolean isRunning()
ServiceControllerAction
isRunning
in interface ServiceControllerAction
public void start()
ServiceControllerAction
start
in interface ServiceControllerAction
public void stop()
ServiceControllerAction
stop
in interface ServiceControllerAction
public void setInterval(java.lang.String seconds)
seconds
- The interval in secondspublic java.lang.String toString()
toString
in class java.lang.Object