org.drupal.project.computing
Class DApplication

java.lang.Object
  extended by org.drupal.project.computing.DApplication
Direct Known Subclasses:
CommonApplication, DJyApplication

public abstract class DApplication
extends java.lang.Object

This is the application class. Additional thoughts: It'll be nice to have "site" and "config" as "final". But that means they have to be set in constructors, and launchFromShell() would have to be static factory method, and then it'll increase complexity. This design combines DApplication and DLauncher. Pro: simple. Con: Can't use other launcher easily.


Nested Class Summary
static class DApplication.RunningMode
          Various running mode of the Druplet
 
Field Summary
protected  java.util.Map<java.lang.String,java.lang.Class<? extends DCommand>> commandRegistry
          acceptable command registry in the format of: Class name => the class object.
protected  DConfig config
          Configuration for this application
protected  DSite drupalSite
          Drupal site for this application
protected  java.util.logging.Logger logger
           
protected  java.lang.String[] pushOptions
          Extra options when running in "push" mode.
 
Constructor Summary
DApplication()
          Default constructor.
 
Method Summary
protected abstract  void buildCommandRegistry()
          Register acceptable command here.
 DSite getDrupalSite()
           
 java.lang.String getIdentifier()
          Specifies the name this Druplet is known as.
protected  void initDrupalSite()
          In your sub-class, you can override this method to initialized different drupal site.
 void launch()
          launch the DApplication.
 void launchFromShell(java.lang.String[] args)
          Launches the DApplication from shell.
 void registerCommand(java.lang.Class<? extends DCommand> commandClass)
          Register a command with the DApplication.
 void registerCommand(java.lang.String identifier, java.lang.Class commandClass)
          Register a command with arbitrary identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected java.util.logging.Logger logger

config

protected DConfig config
Configuration for this application


drupalSite

protected DSite drupalSite
Drupal site for this application


pushOptions

protected java.lang.String[] pushOptions
Extra options when running in "push" mode.


commandRegistry

protected java.util.Map<java.lang.String,java.lang.Class<? extends DCommand>> commandRegistry
acceptable command registry in the format of: Class name => the class object.

Constructor Detail

DApplication

public DApplication()
Default constructor. There are no other constructors. In your sub-class, you can set this.config in this constructor.

Method Detail

getDrupalSite

public DSite getDrupalSite()

launchFromShell

public void launchFromShell(java.lang.String[] args)
Launches the DApplication from shell. users of the class should call this function.

Parameters:
args - arguments from main()

initDrupalSite

protected void initDrupalSite()
In your sub-class, you can override this method to initialized different drupal site.


launch

public void launch()
launch the DApplication.


getIdentifier

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

Returns:
The identifier of the app.

registerCommand

public void registerCommand(java.lang.Class<? extends DCommand> commandClass)
Register a command with the DApplication.

Parameters:
commandClass -

registerCommand

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

Parameters:
identifier -
commandClass -

buildCommandRegistry

protected abstract void buildCommandRegistry()
Register acceptable command here.