org.jboss.dna.connector.federation.executor
Class FederatingCommandExecutor

java.lang.Object
  extended by org.jboss.dna.graph.commands.executor.AbstractCommandExecutor
      extended by org.jboss.dna.connector.federation.executor.FederatingCommandExecutor
All Implemented Interfaces:
CommandExecutor

@NotThreadSafe
public class FederatingCommandExecutor
extends AbstractCommandExecutor

Author:
Randall Hauch

Constructor Summary
FederatingCommandExecutor(ExecutionContext context, String sourceName, List<Projection> sourceProjections, RepositoryConnectionFactory connectionFactory)
          Create a command executor that federates (merges) the information from multiple sources described by the source projections.
FederatingCommandExecutor(ExecutionContext context, String sourceName, Projection cacheProjection, CachePolicy defaultCachePolicy, List<Projection> sourceProjections, RepositoryConnectionFactory connectionFactory)
          Create a command executor that federates (merges) the information from multiple sources described by the source projections.
 
Method Summary
 void close()
          Close this executor, allowing it to clean up any open resources.
 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. 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 AbstractCommandExecutor.execute(GetPropertiesCommand) and AbstractCommandExecutor.execute(GetChildrenCommand) methods, and should be overridden by subclasses that can process GetNodeCommand more efficiently as a single command. This class overrides the default behavior and instead processes the command in a more efficient manner.

 void execute(GetPropertiesCommand command)
          Execute a command to get the properties of a node.
 Projection getCacheProjection()
          Get the projection defining the cache.
 List<Projection> getSourceProjections()
          Get an unmodifiable list of the immutable source projections.
 void setMergingStrategy(MergeStrategy mergingStrategy)
           
 
Methods inherited from class org.jboss.dna.graph.commands.executor.AbstractCommandExecutor
execute, execute, execute, execute, execute, execute, execute, execute, execute, getCurrentTimeInUtc, getExecutionContext, getSourceName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FederatingCommandExecutor

public FederatingCommandExecutor(ExecutionContext context,
                                 String sourceName,
                                 List<Projection> sourceProjections,
                                 RepositoryConnectionFactory connectionFactory)
Create a command executor that federates (merges) the information from multiple sources described by the source projections. The resulting command executor does not first consult a cache for the merged information; if a cache is desired, see constructor that takes a cache projection.

Parameters:
context - the execution context in which the executor will be run; may not be null
sourceName - the name of the RepositorySource that is making use of this executor; may not be null or empty
sourceProjections - the source projections; may not be null
connectionFactory - the factory for RepositoryConnection instances

FederatingCommandExecutor

public FederatingCommandExecutor(ExecutionContext context,
                                 String sourceName,
                                 Projection cacheProjection,
                                 CachePolicy defaultCachePolicy,
                                 List<Projection> sourceProjections,
                                 RepositoryConnectionFactory connectionFactory)
Create a command executor that federates (merges) the information from multiple sources described by the source projections. The resulting command executor will use the supplied cache projection to identify the repository source for the cache as well as the rules for how the paths are mapped in the cache. This cache will be consulted first for the requested information, and will be kept up to date as changes are made to the federated information.

Parameters:
context - the execution context in which the executor will be run; may not be null
sourceName - the name of the RepositorySource that is making use of this executor; may not be null or empty
cacheProjection - the projection used for the cached information; may be null if there is no cache
defaultCachePolicy - the default caching policy that outlines the length of time that information should be cached, or null if there is no cache or no specific cache policy
sourceProjections - the source projections; may not be null
connectionFactory - the factory for RepositoryConnection instances
Method Detail

setMergingStrategy

public void setMergingStrategy(MergeStrategy mergingStrategy)
Parameters:
mergingStrategy - Sets mergingStrategy to the specified value.

getSourceProjections

public List<Projection> getSourceProjections()
Get an unmodifiable list of the immutable source projections.

Returns:
the set of projections used as sources; never null

getCacheProjection

public Projection getCacheProjection()
Get the projection defining the cache.

Returns:
the cache projection

close

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

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

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 AbstractCommandExecutor.execute(GetPropertiesCommand) and AbstractCommandExecutor.execute(GetChildrenCommand) methods, and should be overridden by subclasses that can process GetNodeCommand more efficiently as a single command.

This class overrides the default behavior and instead processes the command in a more efficient manner.

Specified by:
execute in interface CommandExecutor
Overrides:
execute in class AbstractCommandExecutor
Parameters:
command - the command to be executed; may not be null
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
AbstractCommandExecutor.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
Overrides:
execute in class AbstractCommandExecutor
Parameters:
command - the command to be executed; may not be null
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
AbstractCommandExecutor.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
Overrides:
execute in class AbstractCommandExecutor
Parameters:
command - the command to be executed; may not be null
Throws:
RepositorySourceException - if there is an error executing the command
See Also:
AbstractCommandExecutor.execute(org.jboss.dna.graph.commands.GetChildrenCommand)


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