org.jboss.dna.graph.commands.executor
Class AbstractCommandExecutor

java.lang.Object
  extended by org.jboss.dna.graph.commands.executor.AbstractCommandExecutor
All Implemented Interfaces:
CommandExecutor
Direct Known Subclasses:
FederatingCommandExecutor, NoOpCommandExecutor, SingleProjectionCommandExecutor, SingleSourceCommandExecutor

public abstract class AbstractCommandExecutor
extends Object
implements CommandExecutor

Abstract implementation of the CommandExecutor interface that provides implementations for all methods, making this a useful base class for all CommandExecutor implementations. Because all methods are implemented, subclasses only need to override methods that are appropriate or applicable, and all other commands will be processed correctly (even if new command interfaces are added in later versions). In some cases, as with CompositeCommand and GetNodeCommand, these implementations attempt to process the command. In other cases (e.g., GetPropertiesCommand, and DeleteBranchCommand), the methods do nothing and should be overridden if the command is to be processed.

The implementation is also designed to be instantated as needed. This may be once per call to RepositoryConnection.execute(ExecutionContext, GraphCommand...), or may be once per transaction. Either way, this class is designed to allow subclasses to store additional state that may otherwise be expensive or undesirable to obtain repeatedly. However, this state should be independent of the commands that are processed, meaning that implementations should generally not change state as a result of processing specific commands.

Author:
Randall Hauch

Method Summary
 void close()
          Close this executor, allowing it to clean up any open resources.
 void execute(CompositeCommand command)
          Execute a composite command that contains other commands.
 void execute(CopyBranchCommand command)
          Execute a command to copy an entire branch to a new location.
 void execute(CopyNodeCommand command)
          Execute a command to copy a node to a new location.
 void execute(CreateNodeCommand command)
          Execute a command to create a node and set the node's properties.
 void execute(DeleteBranchCommand command)
          Execute a command to delete an entire branch.
 void execute(GetChildrenCommand command)
          Execute a command to get the children of a node.
 void execute(GetNodeCommand command)
          Execute a command to get the properties and children of a node. This method implementation simply delegates to both the execute(GetPropertiesCommand) and execute(GetChildrenCommand) methods, and should be overridden by subclasses that can process GetNodeCommand more efficiently as a single command.
 void execute(GetPropertiesCommand command)
          Execute a command to get the properties of a node.
 void execute(GraphCommand command)
          Execute a graph command. This implementation examines the instance to see which command interfaces are implemented by the command, and delegates to the appropriate methods.
 void execute(MoveBranchCommand command)
          Execute a command to move a branch from one location to another.
 void execute(RecordBranchCommand command)
          Execute a command to record the structure of a branch.
 void execute(SetPropertiesCommand command)
          Execute a command to set some (or all) of the properties on a node.
 DateTime getCurrentTimeInUtc()
          Get the current time associated with this executor.
 ExecutionContext getExecutionContext()
          Get the environment in which these commands are being executed.
 String getSourceName()
          Get the name of the repository source.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getExecutionContext

public ExecutionContext getExecutionContext()
Get the environment in which these commands are being executed.

Returns:
the execution context; never null

getSourceName

public String getSourceName()
Get the name of the repository source.

Returns:
the source name; never null or empty

getCurrentTimeInUtc

public DateTime getCurrentTimeInUtc()
Get the current time associated with this executor. All calls to this method will result in the same time.

Returns:
the current time expressed in UTC

execute

public void execute(GraphCommand command)
             throws RepositorySourceException
Execute a graph command. This method should examine the command's types to determine which other execute methods should be called, and should then call those methods. This method should also do nothing if the command is null.

This implementation examines the instance to see which command interfaces are implemented by the command, and delegates to the appropriate methods.

Specified by:
execute in interface CommandExecutor
Parameters:
command - the command to be executed
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
CommandExecutor.execute(org.jboss.dna.graph.commands.GraphCommand)

execute

public void execute(CompositeCommand command)
             throws RepositorySourceException
Execute a composite command that contains other commands. This method should simply obtain and execute each of the nested commands.

Specified by:
execute in interface CommandExecutor
Parameters:
command - the command to be executed; may not be null
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
CommandExecutor.execute(org.jboss.dna.graph.commands.CompositeCommand)

execute

public void execute(GetNodeCommand command)
             throws RepositorySourceException
Execute a command to get the properties and children of a node. GetNodeCommand is a subtype of both GetPropertiesCommand and GetChildrenCommand, so this method will be called in place of the CommandExecutor.execute(GetPropertiesCommand) and CommandExecutor.execute(GetChildrenCommand) methods.

This method implementation simply delegates to both the execute(GetPropertiesCommand) and execute(GetChildrenCommand) methods, and should be overridden by subclasses that can process GetNodeCommand more efficiently as a single command.

Specified by:
execute in interface CommandExecutor
Parameters:
command - the command to be executed; may not be null
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
CommandExecutor.execute(org.jboss.dna.graph.commands.GetNodeCommand)

execute

public void execute(GetPropertiesCommand command)
             throws RepositorySourceException
Execute a command to get the properties of a node.

Specified by:
execute in interface CommandExecutor
Parameters:
command - the command to be executed; may not be null
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
CommandExecutor.execute(org.jboss.dna.graph.commands.GetPropertiesCommand)

execute

public void execute(GetChildrenCommand command)
             throws RepositorySourceException
Execute a command to get the children of a node.

Specified by:
execute in interface CommandExecutor
Parameters:
command - the command to be executed; may not be null
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
CommandExecutor.execute(org.jboss.dna.graph.commands.GetChildrenCommand)

execute

public void execute(CreateNodeCommand command)
             throws RepositorySourceException
Execute a command to create a node and set the node's properties.

Specified by:
execute in interface CommandExecutor
Parameters:
command - the command to be executed; may not be null
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
CommandExecutor.execute(org.jboss.dna.graph.commands.CreateNodeCommand)

execute

public void execute(SetPropertiesCommand command)
             throws RepositorySourceException
Execute a command to set some (or all) of the properties on a node.

Specified by:
execute in interface CommandExecutor
Parameters:
command - the command to be executed; may not be null
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
CommandExecutor.execute(org.jboss.dna.graph.commands.SetPropertiesCommand)

execute

public void execute(CopyNodeCommand command)
             throws RepositorySourceException
Execute a command to copy a node to a new location.

Specified by:
execute in interface CommandExecutor
Parameters:
command - the command to be executed; may not be null
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
CommandExecutor.execute(org.jboss.dna.graph.commands.CopyNodeCommand)

execute

public void execute(CopyBranchCommand command)
             throws RepositorySourceException
Execute a command to copy an entire branch to a new location.

Specified by:
execute in interface CommandExecutor
Parameters:
command - the command to be executed; may not be null
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
CommandExecutor.execute(org.jboss.dna.graph.commands.CopyBranchCommand)

execute

public void execute(DeleteBranchCommand command)
             throws RepositorySourceException
Execute a command to delete an entire branch.

Specified by:
execute in interface CommandExecutor
Parameters:
command - the command to be executed; may not be null
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
CommandExecutor.execute(org.jboss.dna.graph.commands.DeleteBranchCommand)

execute

public void execute(MoveBranchCommand command)
             throws RepositorySourceException
Execute a command to move a branch from one location to another.

Specified by:
execute in interface CommandExecutor
Parameters:
command - the command to be executed; may not be null
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
CommandExecutor.execute(org.jboss.dna.graph.commands.MoveBranchCommand)

execute

public void execute(RecordBranchCommand command)
             throws RepositorySourceException
Execute a command to record the structure of a branch.

Specified by:
execute in interface CommandExecutor
Parameters:
command - the command to be executed; may not be null
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
CommandExecutor.execute(org.jboss.dna.graph.commands.RecordBranchCommand)

close

public void close()
Close this executor, allowing it to clean up any open resources.

Specified by:
close in interface CommandExecutor
See Also:
CommandExecutor.close()


Copyright © 2008-Present JBoss a division of Red Hat. All Rights Reserved.