Package org.kie.internal.command

# Class CommandFactory

java.lang.Object
org.kie.internal.command.CommandFactory

public class CommandFactory extends Object

The CommandFactory returns Commands that can be used by classes that implement CommandExecutor. Typically more than one Command will want to be executed, where is where the BatchExecution comes in, which takes a List of commands, think of it as CompositeCommand.

Out of the box marshalling to XML is support for the Commands, specifically the BatchExecution command and ExecutionResults, using the Drools Pipeline. If the drools-pipeline module is added then the PipelineFactory can be used in conjunction with the BatchExecutionHelper to marshall to and from XML. BatchExecutionHelper also provides additional documentation on the supported XML format.

`

This api is experimental and thus the classes and the interfaces returned are subject to change.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CommandFactory()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Command<FactHandle>`
  `fromExternalFactHandleCommand(String factHandleExternalForm)`
  `static Command<FactHandle>`
  `fromExternalFactHandleCommand(String factHandleExternalForm, boolean disconnected)`
  `static Command`
  `newAbortWorkItem(long workItemId)`
  `static BatchExecutionCommand`
  `newBatchExecution(List<? extends Command> commands)`
  This is a special composite command and will execute all the supplied commands in turn.
  `static BatchExecutionCommand`
  `newBatchExecution(List<? extends Command> commands, String lookup)`
  `static Command`
  `newCompleteWorkItem(long workItemId, Map<String,Object> results)`
  `static Command`
  `newDelete(FactHandle factHandle)`
  `static Command`
  `newDeleteObject(Object object, String entryPoint)`
  `static Command`
  `newDispose()`
  `static Command`
  `newEnableAuditLog(String filename)`
  `static Command`
  `newEnableAuditLog(String directory, String filename)`
  `static Command`
  `newFireAllRules()`
  `static Command`
  `newFireAllRules(int max)`
  `static Command`
  `newFireAllRules(String outidentifier)`
  `static Command`
  `newGetFactHandle(Object object)`
  `static Command`
  `newGetFactHandleInEntryPoint(Object object, String entryPoint)`
  `static Command`
  `newGetGlobal(String identifier)`
  Gets the global and adds it to the ExecutionResults
  `static Command`
  `newGetGlobal(String identifier, String outIdentifier)`
  Gets the global and adds it ot the BatchExecutionresults using the alternative outIdentifier.
  `static Command`
  `newGetObject(FactHandle factHandle)`
  `static Command`
  `newGetObject(FactHandle factHandle, String outIdentifier)`
  `static Command`
  `newGetObjects()`
  `static Command`
  `newGetObjects(String outIdentifier)`
  `static Command`
  `newGetObjects(ObjectFilter filter)`
  `static Command`
  `newGetObjects(ObjectFilter filter, String outIdentifier)`
  `static Command`
  `newInsert(Object object)`
  Inserts a new instance
  `static Command`
  `newInsert(Object object, String outIdentifier)`
  Inserts a new instance but references via the outIdentifier, which is returned as part of the ExecutionResults
  `static Command`
  `newInsert(Object object, String outIdentifier, boolean returnObject, String entryPoint)`
  Inserts a new instance but references via the outIdentifier, which is returned as part of the ExecutionResults The outIdentifier can be null.
  `static Command`
  `newInsertElements(Collection objects)`
  Iterate and insert each of the elements of the Collection.
  `static Command`
  `newInsertElements(Collection objects, String outIdentifier, boolean returnObject, String entryPoint)`
  Iterate and insert each of the elements of the Collection.
  `static Command`
  `newModify(FactHandle factHandle, List<Setter> setters)`
  `static Command`
  `newQuery(String identifier, String name)`
  Executes a query.
  `static Command`
  `newQuery(String identifier, String name, Object[] arguments)`
  Executes a query using the given parameters.
  `static Command`
  `newRegisterWorkItemHandlerCommand(WorkItemHandler handler, String workItemName)`
  `static Command`
  `newSetGlobal(String identifier, Object object)`
  Sets the global.
  `static Command`
  `newSetGlobal(String identifier, Object object, boolean out)`
  Sets the global but also when the out parameter is true specifies that the global is added to the ExecutionResults.
  `static Command`
  `newSetGlobal(String identifier, Object object, String outIdentifier)`
  Sets the global but also specifies that the global is added to the ExecutionResults.
  `static Setter`
  `newSetter(String accessor, String value)`
  `static Command`
  `newSignalEvent(String type, Object event)`
  `static Command`
  `newSignalEvent(String processInstanceId, String type, Object event)`
  `static Command`
  `newStartProcess(String processId)`
  Start a process
  `static Command`
  `newStartProcess(String processId, Map<String,Object> parameters)`
  Start a process using the given parameters.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### CommandFactory

    public CommandFactory()

- ## Method Details

  - ### newInsert

    public static Command newInsert(Object object)
    Inserts a new instance
    Parameters:
      `object` -
    Returns:

  - ### newDispose

    public static Command newDispose()

  - ### newInsert

    public static Command newInsert(Object object, String outIdentifier)
    Inserts a new instance but references via the outIdentifier, which is returned as part of the ExecutionResults
    Parameters:
      `object` -
      `outIdentifier` -
    Returns:

  - ### newInsert

    public static Command newInsert(Object object, String outIdentifier, boolean returnObject, String entryPoint)
    Inserts a new instance but references via the outIdentifier, which is returned as part of the ExecutionResults The outIdentifier can be null. The entryPoint, which can also be null, specifies the entrypoint the object is inserted into.
    Parameters:
      `object` -
      `outIdentifier` -
      `entryPoint` -
    Returns:

  - ### newInsertElements

    public static Command newInsertElements(Collection objects)
    Iterate and insert each of the elements of the Collection.
    Parameters:
      `objects` - The objects to insert
    Returns:

  - ### newInsertElements

    public static Command newInsertElements(Collection objects, String outIdentifier, boolean returnObject, String entryPoint)
    Iterate and insert each of the elements of the Collection.
    Parameters:
      `objects` - The objects to insert
      `outIdentifier` - Identifier to lookup the returned objects
      `returnObject` - boolean to specify whether the inserted Collection is part of the ExecutionResults
      `entryPoint` - Optional EntryPoint for the insertions
    Returns:

  - ### newDelete

    public static Command newDelete(FactHandle factHandle)

  - ### newDeleteObject

    public static Command newDeleteObject(Object object, String entryPoint)

  - ### newGetFactHandle

    public static Command newGetFactHandle(Object object)

  - ### newGetFactHandleInEntryPoint

    public static Command newGetFactHandleInEntryPoint(Object object, String entryPoint)

  - ### newSetter

    public static Setter newSetter(String accessor, String value)

  - ### newModify

    public static Command newModify(FactHandle factHandle, List<Setter> setters)

  - ### newGetObject

    public static Command newGetObject(FactHandle factHandle)

  - ### newGetObject

    public static Command newGetObject(FactHandle factHandle, String outIdentifier)

  - ### newGetObjects

    public static Command newGetObjects()

  - ### newGetObjects

    public static Command newGetObjects(String outIdentifier)

  - ### newGetObjects

    public static Command newGetObjects(ObjectFilter filter)

  - ### newGetObjects

    public static Command newGetObjects(ObjectFilter filter, String outIdentifier)

  - ### newSetGlobal

    public static Command newSetGlobal(String identifier, Object object)
    Sets the global. Does not add the global to the ExecutionResults.
    Parameters:
      `identifier` - The identifier of the global
      `object` - The instance to be set as the global.
    Returns:

  - ### newSetGlobal

    public static Command newSetGlobal(String identifier, Object object, boolean out)
    Sets the global but also when the out parameter is true specifies that the global is added to the ExecutionResults.
    Parameters:
      `identifier` - The identifier of the global
      `object` - The instance to be set as the global.
      `out` - When true the global will be added to the ExecutionResults using the global's identifier.
    Returns:

  - ### newSetGlobal

    public static Command newSetGlobal(String identifier, Object object, String outIdentifier)
    Sets the global but also specifies that the global is added to the ExecutionResults. Instead of using the global's identifier it uses the outIdentifier when being added to the ExecutionResults.
    Parameters:
      `identifier` - The identifier of the global
      `object` - The instance to be set as the global.
      `outIdentifier` - The identifier used to store the global in the ExecutionResults
    Returns:

  - ### newGetGlobal

    public static Command newGetGlobal(String identifier)
    Gets the global and adds it to the ExecutionResults
    Parameters:
      `identifier` -
    Returns:

  - ### newGetGlobal

    public static Command newGetGlobal(String identifier, String outIdentifier)
    Gets the global and adds it ot the BatchExecutionresults using the alternative outIdentifier.
    Parameters:
      `identifier` - The identifier of the global
      `outIdentifier` - The identifier used in the ExecutionResults to store the global.
    Returns:

  - ### newFireAllRules

    public static Command newFireAllRules()

  - ### newFireAllRules

    public static Command newFireAllRules(int max)

  - ### newFireAllRules

    public static Command newFireAllRules(String outidentifier)

  - ### newStartProcess

    public static Command newStartProcess(String processId)
    Start a process
    Parameters:
      `processId` -
    Returns:

  - ### newStartProcess

    public static Command newStartProcess(String processId, Map<String,Object> parameters)
    Start a process using the given parameters.
    Parameters:
      `processId` -
      `parameters` -
    Returns:

  - ### newSignalEvent

    public static Command newSignalEvent(String type, Object event)

  - ### newSignalEvent

    public static Command newSignalEvent(String processInstanceId, String type, Object event)

  - ### newRegisterWorkItemHandlerCommand

    public static Command newRegisterWorkItemHandlerCommand(WorkItemHandler handler, String workItemName)

  - ### newCompleteWorkItem

    public static Command newCompleteWorkItem(long workItemId, Map<String,Object> results)

  - ### newAbortWorkItem

    public static Command newAbortWorkItem(long workItemId)

  - ### newQuery

    public static Command newQuery(String identifier, String name)
    Executes a query. The query results will be added to the ExecutionResults using the given identifier.
    Parameters:
      `identifier` - The identifier to be used for the results when added to the ExecutionResults
      `name` - The name of the query to execute
    Returns:

  - ### newQuery

    public static Command newQuery(String identifier, String name, Object[] arguments)
    Executes a query using the given parameters. The query results will be added to the ExecutionResults using the given identifier.
    Parameters:
      `identifier` - The identifier to be used for the results when added to the ExecutionResults
      `name` - The name of the query to execute
      `arguments` - The arguments to be used for the query parameters
    Returns:

  - ### newBatchExecution

    public static BatchExecutionCommand newBatchExecution(List<? extends Command> commands)
    This is a special composite command and will execute all the supplied commands in turn.
    Parameters:
      `commands` -
    Returns:

  - ### newBatchExecution

    public static BatchExecutionCommand newBatchExecution(List<? extends Command> commands, String lookup)
    Returns:

  - ### fromExternalFactHandleCommand

    public static Command<FactHandle> fromExternalFactHandleCommand(String factHandleExternalForm)

  - ### fromExternalFactHandleCommand

    public static Command<FactHandle> fromExternalFactHandleCommand(String factHandleExternalForm, boolean disconnected)

  - ### newEnableAuditLog

    public static Command newEnableAuditLog(String directory, String filename)

  - ### newEnableAuditLog

    public static Command newEnableAuditLog(String filename)