Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.drupal.project.async_command
Class Druplet

    java.lang.Object
      org.drupal.project.async_command.Druplet

All Implemented Interfaces:
  java.lang.Runnable

Direct Known Subclasses:
  DefaultDruplet, PyDruplet

    public class Druplet

extends java.lang.Object
implements java.lang.Runnable

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

Nested Class Summary
`static class` | `Druplet.AccessMode`
`static class` | `Druplet.RunningMode` Various running mode of the Druplet

Field Summary
`protected java.util.Map<java.lang.String,java.lang.Class>` | `acceptableCommandClass` Class name: the class object.
`protected Druplet.AccessMode` | `accessMode`
`protected java.util.Properties` | `config` Deprecated.
`protected DrupalConnection` | `drupalConnection`
`protected DrupletConfig` | `drupletConfig`
`protected java.util.concurrent.ExecutorService` | `executor` Default executor, run single thread.
`protected static java.util.logging.Logger` | `logger`

Constructor Summary
`protected` | `Druplet()` This constructor requires manually set DrupalConnection.
`` | `Druplet(DrupalConnection drupalConnection)` Deprecated.
`` | `Druplet(DrupletConfig drupletConfig)` This should be the default constructor to initiate Druplet with the configuration.
`` | `Druplet(java.util.Properties config)` Deprecated.

Method Summary
`java.util.Properties` | `getConfig()` Deprecated.
`DrupalConnection` | `getDrupalConnection()`
`DrupletConfig` | `getDrupletConfig()`
`java.lang.String` | `getIdentifier()` Specifies the name this Druplet is known as.
`protected void` | `handleException(CommandRecord record, java.lang.Throwable exception)` Handle any exception (Throwable) occurred during command execution.
`(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 Druplet.
`void` | `registerCommandClass(java.lang.String identifier, java.lang.Class commandClass)` Register a command with arbitrary identifier.
`void` | `run()`
`protected void` | `runOnce()`
`protected void` | `runParallel()`
`protected void` | `runSerial()` Run in serial mode.
`protected void` | `setDrupalConnection(DrupalConnection drupalConnection)` Only derived class can change drupal connection.
`void` | `setRunningMode(Druplet.RunningMode runningMode)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### accessMode

    protected Druplet.AccessMode accessMode

### drupalConnection

    protected DrupalConnection drupalConnection

### config

    @Deprecated
    protected java.util.Properties config

  Deprecated.

### drupletConfig

    protected DrupletConfig drupletConfig

### logger

    protected static java.util.logging.Logger logger

### executor

    protected java.util.concurrent.ExecutorService executor

  Default executor, run single thread. This is useful for command that will create another command to run (either in 1 thread or in multiple thread)

### acceptableCommandClass

    protected java.util.Map<java.lang.String,java.lang.Class> acceptableCommandClass

  Class name: the class object.

Constructor Detail

### Druplet

    @Deprecated
    public Druplet(DrupalConnection drupalConnection)

  Deprecated.

  Any Druplet should have at least one drupal database connection. Otherwise it's not "Druplet" anymore. Use Druplet(Properties config) instead.

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

### Druplet

    protected Druplet()

  This constructor requires manually set DrupalConnection. Access is "protected".

### Druplet

    @Deprecated
    public Druplet(java.util.Properties config)

  Deprecated.

### Druplet

    public Druplet(DrupletConfig drupletConfig)

  This should be the default constructor to initiate Druplet with the configuration. Register acceptable AsyncCommand classes in constructor. By default, this registers PingMe command.

  Parameters:
    `drupletConfig` -

Method Detail

### setRunningMode

    public void setRunningMode(Druplet.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 Druplet 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 Druplet.

  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`

### runOnce

    protected void runOnce()

### handleException

    protected void handleException(CommandRecord record,
                                   java.lang.Throwable exception)

  Handle any exception (Throwable) occurred during command execution. AsyncCommand should delegate exception handling to Druplet.

  Parameters:
    `record` -
    `exception` -

### runSerial

    protected void runSerial()

  Run in serial mode. We don't use the single thread "executor" here to have more simplicity.

### runParallel

    protected void runParallel()

### getConfig

    @Deprecated
    public java.util.Properties getConfig()

  Deprecated.

### getDrupletConfig

    public DrupletConfig getDrupletConfig()

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD