2.17.2: 2011-06-17

net.sf.basedb.clients.web.extensions.service
Class DummyService

java.lang.Object
  extended by net.sf.basedb.clients.web.extensions.service.DummyService
All Implemented Interfaces:
ServiceControllerAction, Action, ActionFactory<ServiceControllerAction>

public class DummyService
extends Object
implements ServiceControllerAction, ActionFactory<ServiceControllerAction>

A dummy service implementation that prints out the current time on 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.

Version:
2.8
Author:
nicklas
Last modified
$Date: 2008-09-11 22:05:50 +0200 (Thu, 11 Sep 2008) $

Field Summary
private  String extensionId
           
private  long interval
           
private  boolean running
           
private  TimerTask timer
           
 
Constructor Summary
DummyService()
           
 
Method Summary
 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(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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

running

private boolean running

timer

private TimerTask timer

interval

private long interval

extensionId

private String extensionId
Constructor Detail

DummyService

public DummyService()
Method Detail

getActions

public ServiceControllerAction[] getActions(InvokationContext context)
Description copied from interface: ActionFactory
This method may be called one or several times for each request. This is decided by the extension point. If, for example, the extension point is a pure single-item extension point then this method is probably only called once. If the extension point is a per-item extension point in a list context, then this method may be called once for every item in the list. The context parameter contains all information about the context of the extension point, including the current item, if any.

Specified by:
getActions in interface ActionFactory<ServiceControllerAction>
Parameters:
context - The current invokation context
Returns:
An array of actions that should be added to the extension point. Returns null or an empty array if there are no actions in the current context.

prepareContext

public boolean prepareContext(InvokationContext context)
Description copied from interface: ActionFactory
This method is called once for each request/use of an extension and have two purposes:

Specified by:
prepareContext in interface ActionFactory<ServiceControllerAction>
Parameters:
context - The current invokation context
Returns:
TRUE if the extension should be enabled, FALSE if the extension should be disabled

isRunning

public boolean isRunning()
Description copied from interface: ServiceControllerAction
Is the service running or not?

Specified by:
isRunning in interface ServiceControllerAction

start

public void start()
Description copied from interface: ServiceControllerAction
Start the service if it is not already running. If this method is called on a running service it should do nothing. If the service can't be started it may throw an exception.

Specified by:
start in interface ServiceControllerAction

stop

public void stop()
Description copied from interface: ServiceControllerAction
Stop the service if it is running. If this method is called on a service that is not running, it should do nothing. If the service can't be stopped it may throw an exception.

Specified by:
stop in interface ServiceControllerAction

setInterval

public void setInterval(String seconds)
Set the interval between writes to stdout.

Parameters:
seconds - The interval in seconds

toString

public String toString()
Overrides:
toString in class Object

2.17.2: 2011-06-17