public class DummyService extends 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 String |
extensionId |
private long |
interval |
private boolean |
running |
private TimerTask |
timer |
Constructor and Description |
---|
DummyService() |
Modifier and Type | Method and Description |
---|---|
ServiceControllerAction[] |
getActions(InvokationContext<? super ServiceControllerAction> context)
This method may be called one or several times for each request.
|
boolean |
isRunning()
Is the service running or not?
|
boolean |
prepareContext(InvokationContext<? super ServiceControllerAction> 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(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.
|
String |
toString() |
private boolean running
private TimerTask timer
private long interval
private String extensionId
public ServiceControllerAction[] getActions(InvokationContext<? super ServiceControllerAction> context)
ActionFactory
getActions
in interface ActionFactory<ServiceControllerAction>
context
- The current invokation contextpublic boolean prepareContext(InvokationContext<? super ServiceControllerAction> 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(String seconds)
seconds
- The interval in seconds