org.drupal.project.async_command
Class GenericDrupalApp

java.lang.Object
  extended by org.drupal.project.async_command.GenericDrupalApp
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
DefaultDrupalApp, PyDrupalApp

public class GenericDrupalApp
extends java.lang.Object
implements java.lang.Runnable

This is the new DrupalApp class. A launcher has a field to launch DrupalApp, rather than DrupalApp has a field of launcher.


Nested Class Summary
static class GenericDrupalApp.RunningMode
          Various running mode of the DrupalApp
 
Field Summary
protected  java.util.Map<java.lang.String,java.lang.Class> acceptableCommandClass
          Class name: the class object.
protected  DrupalConnection drupalConnection
           
protected static java.util.logging.Logger logger
           
 
Constructor Summary
protected GenericDrupalApp()
          This constructor requires manually set DrupalConnection.
  GenericDrupalApp(DrupalConnection drupalConnection)
          Register acceptable AsyncCommand classes in constructor.
 
Method Summary
 DrupalConnection getDrupalConnection()
           
 java.lang.String getIdentifier()
          Specifies the name this DrupalApp is known as.
(package private)  AsyncCommand parseCommand(CommandRecord record)
          Create an object of AsyncCommand based on the CommandRecord.
 void registerCommandClass(java.lang.Class<? extends AsyncCommand> commandClass)
          Register a command with the Drupal application.
 void registerCommandClass(java.lang.String identifier, java.lang.Class commandClass)
          Register a command with arbitrary identifier.
 void run()
           
protected  void runSerial()
           
protected  void setDrupalConnection(DrupalConnection drupalConnection)
          Only derived class can change drupal connection.
 void setRunningMode(GenericDrupalApp.RunningMode runningMode)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

drupalConnection

protected DrupalConnection drupalConnection

logger

protected static java.util.logging.Logger logger

acceptableCommandClass

protected java.util.Map<java.lang.String,java.lang.Class> acceptableCommandClass
Class name: the class object.

Constructor Detail

GenericDrupalApp

public GenericDrupalApp(DrupalConnection drupalConnection)
Register acceptable AsyncCommand classes in constructor. By default, this registers PingMe command. Any DrupalApp should have at least one drupal database connection. Otherwise it's not "DrupalApp" anymore.

Parameters:
drupalConnection - Connection to a Drupal database that has the {async_command} table.

GenericDrupalApp

protected GenericDrupalApp()
This constructor requires manually set DrupalConnection. Access is "protected".

Method Detail

setRunningMode

public void setRunningMode(GenericDrupalApp.RunningMode runningMode)

setDrupalConnection

protected void setDrupalConnection(DrupalConnection drupalConnection)
Only derived class can change drupal connection.

Parameters:
drupalConnection -

getDrupalConnection

public DrupalConnection getDrupalConnection()

getIdentifier

public java.lang.String getIdentifier()
Specifies the name this DrupalApp is known as. By default is the class name. You can override default value too.

Returns:
The identifier of the app.

parseCommand

AsyncCommand parseCommand(CommandRecord record)
                    throws CommandParseException
Create an object of AsyncCommand based on the CommandRecord. This function can't be moved into CommandRecord because CommandRecord is not award of different AsyncCommand classes.

Parameters:
record -
Returns:
Throws:
CommandParseException

registerCommandClass

public void registerCommandClass(java.lang.Class<? extends AsyncCommand> commandClass)
Register a command with the Drupal application.

Parameters:
commandClass -

registerCommandClass

public void registerCommandClass(java.lang.String identifier,
                                 java.lang.Class commandClass)
Register a command with arbitrary identifier.

Parameters:
identifier -
commandClass -

run

public void run()
Specified by:
run in interface java.lang.Runnable

runSerial

protected void runSerial()