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 AsyncCommand

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

All Implemented Interfaces:
  java.lang.Runnable

Direct Known Subclasses:
  PingMe, PyAsyncCommand

    public abstract class AsyncCommand

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

Individual command to be executed. Each command is also registered with a druplet. A command doesn't necessarily know a DrupalConnection. If needed, it can get from druplet. The Record inner class needs to know a DrupalConnection in order to do database operations. f Subclass can also write a initialize(...) function, which initialize parameters for the app and is used for CLI evaluation.

Nested Class Summary
`static class` | `AsyncCommand.Control`
`static class` | `AsyncCommand.Status`

Field Summary
`protected java.lang.String` | `commandMessage` Command message.
`protected AsyncCommand.Status` | `commandStatus` The command status.
`protected Druplet` | `druplet` The druplet this command is associated with.
`protected static java.util.logging.Logger` | `logger`
`protected CommandRecord` | `record` The database record this command is associated with.

Constructor Summary
`protected` | `AsyncCommand()`
`` | `AsyncCommand(CommandRecord record, Druplet druplet)` Constructor should prepare the command to run "run()".

Method Summary
`protected void` | `afterExecute()` Usually save results back to 'record'
`protected void` | `beforeExecute()` Usually initialize the command from 'record'
`protected void` | `execute()` Execute this command.
`protected DrupalConnection` | `getDrupalConnection()`
`protected Druplet` | `getDruplet()`
`java.lang.String` | `getIdentifier()` Specifies the name this command is known as.
`CommandRecord` | `getRecord()`
`void` | `run()` Run this command.
`protected void` | `setDruplet(Druplet druplet)`
`protected void` | `setRecord(CommandRecord record)`

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

Field Detail

### logger

    protected static java.util.logging.Logger logger

### druplet

    protected Druplet druplet

  The druplet this command is associated with. Should be "final", but since we have the default constructor, it can't be final. Use the default constructor in order to accommodate PyAsyncCommand

### record

    protected CommandRecord record

  The database record this command is associated with. Should be "final", but since we have the default constructor, it can't be final. Use the default constructor in order to accommodate PyAsyncCommand

### commandStatus

    protected AsyncCommand.Status commandStatus

  The command status. Will be set directly into CommandRecord.setStatus()

### commandMessage

    protected java.lang.String commandMessage

  Command message. Will be set directly into CommandRecord.setMessage().

Constructor Detail

### AsyncCommand

    public AsyncCommand(CommandRecord record,
                        Druplet druplet)

  Constructor should prepare the command to run "run()". Set member fields by using data in "record"; don't use record directly in execution.

  Parameters:
    `record` -
    `druplet` -

### AsyncCommand

    protected AsyncCommand()

Method Detail

### getDrupalConnection

    protected DrupalConnection getDrupalConnection()

### getDruplet

    protected Druplet getDruplet()

### setRecord

    protected void setRecord(CommandRecord record)

### getRecord

    public CommandRecord getRecord()

### setDruplet

    protected void setDruplet(Druplet druplet)

### getIdentifier

    public java.lang.String getIdentifier()

  Specifies the name this command is known as. By default is the class name. You can override default value too. Deprecated because we don't want to use the default identifier. Instead, when register the command with an app, you can specify the identifier for this command on that specific

  Returns:
    The identifier of the command.

### run

    public void run()

  Run this command. Attention: as of now, please override run() directly rather than using the execute() logic, which is unstable. Before running the command, all input information is in 'record'. After running the command, all output should also be in 'record'. This method is not responsible to save status results back to the database. It's only responsible to run the command and set the command record. This method is not responsible to handle exceptions. Exceptions should be handled by the enclosing druplet.

  Specified by:
    `run` in interface `java.lang.Runnable`

### beforeExecute

    protected void beforeExecute()

  Usually initialize the command from 'record'

### afterExecute

    protected void afterExecute()

  Usually save results back to 'record'

### execute

    protected void execute()

  Execute this command. All parameters should be set before executing this command, preferably in the beforeExecute(). After execution, the results could be handled in afterExecute(). Either override this one, or the "run()" method.

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