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:
org.jboss.dna.graph.commands.executor.CommandExecutor

@NotThreadSafe
public class FederatingCommandExecutor
extends org.jboss.dna.graph.commands.executor.AbstractCommandExecutor

Author:
Randall Hauch

Constructor Summary
FederatingCommandExecutor(org.jboss.dna.graph.ExecutionContext context, String sourceName, List<Projection> sourceProjections, org.jboss.dna.graph.connectors.RepositoryConnectionFactory connectionFactory)
          Create a command executor that federates (merges) the information from multiple sources described by the source projections.
FederatingCommandExecutor(org.jboss.dna.graph.ExecutionContext context, String sourceName, Projection cacheProjection, org.jboss.dna.graph.cache.CachePolicy defaultCachePolicy, List<Projection> sourceProjections, org.jboss.dna.graph.connectors.RepositoryConnectionFactory connectionFactory)
          Create a command executor that federates (merges) the information from multiple sources described by the source projections.
 
Method Summary
 void close()
          
protected  FederatedNode createFederatedNode(org.jboss.dna.graph.commands.basic.BasicGetNodeCommand fromCache, org.jboss.dna.graph.properties.Path path, List<Contribution> contributions, boolean updateCache)
           
 void execute(org.jboss.dna.graph.commands.GetChildrenCommand command)
          
 void execute(org.jboss.dna.graph.commands.GetNodeCommand command)
           This class overrides the default behavior and instead processes the command in a more efficient manner.
 void execute(org.jboss.dna.graph.commands.GetPropertiesCommand command)
          
 Projection getCacheProjection()
          Get the projection defining the cache.
protected  org.jboss.dna.graph.connectors.RepositoryConnection getConnection(Projection projection)
           
protected  org.jboss.dna.graph.connectors.RepositoryConnection getConnectionToCache()
           
protected  MergePlan getMergePlan(org.jboss.dna.graph.commands.basic.BasicGetNodeCommand command)
           
protected  org.jboss.dna.graph.commands.basic.BasicGetNodeCommand getNode(org.jboss.dna.graph.properties.Path path)
          Get the node information from the underlying sources or, if possible, from the cache.
protected  Set<String> getOpenConnections()
           
 List<Projection> getSourceProjections()
          Get an unmodifiable list of the immutable source projections.
protected  void loadContributionsFromSources(org.jboss.dna.graph.properties.Path path, Set<String> sourceNames, List<Contribution> contributions)
          Load the node at the supplied path from the sources with the supplied name, returning the information.
 void setMergingStrategy(MergeStrategy mergingStrategy)
           
protected  void updateCache(FederatedNode mergedNode)
           
 
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FederatingCommandExecutor

public FederatingCommandExecutor(org.jboss.dna.graph.ExecutionContext context,
                                 String sourceName,
                                 List<Projection> sourceProjections,
                                 org.jboss.dna.graph.connectors.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(org.jboss.dna.graph.ExecutionContext context,
                                 String sourceName,
                                 Projection cacheProjection,
                                 org.jboss.dna.graph.cache.CachePolicy defaultCachePolicy,
                                 List<Projection> sourceProjections,
                                 org.jboss.dna.graph.connectors.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()

Specified by:
close in interface org.jboss.dna.graph.commands.executor.CommandExecutor
Overrides:
close in class org.jboss.dna.graph.commands.executor.AbstractCommandExecutor
See Also:
AbstractCommandExecutor.close()

getConnectionToCache

protected org.jboss.dna.graph.connectors.RepositoryConnection getConnectionToCache()
                                                                            throws org.jboss.dna.graph.connectors.RepositorySourceException
Throws:
org.jboss.dna.graph.connectors.RepositorySourceException

getConnection

protected org.jboss.dna.graph.connectors.RepositoryConnection getConnection(Projection projection)
                                                                     throws org.jboss.dna.graph.connectors.RepositorySourceException
Throws:
org.jboss.dna.graph.connectors.RepositorySourceException

getOpenConnections

protected Set<String> getOpenConnections()

execute

public void execute(org.jboss.dna.graph.commands.GetNodeCommand command)
             throws org.jboss.dna.graph.connectors.RepositorySourceException

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

Specified by:
execute in interface org.jboss.dna.graph.commands.executor.CommandExecutor
Overrides:
execute in class org.jboss.dna.graph.commands.executor.AbstractCommandExecutor
Throws:
org.jboss.dna.graph.connectors.RepositorySourceException
See Also:
AbstractCommandExecutor.execute(org.jboss.dna.graph.commands.GetNodeCommand)

execute

public void execute(org.jboss.dna.graph.commands.GetPropertiesCommand command)
             throws org.jboss.dna.graph.connectors.RepositorySourceException

Specified by:
execute in interface org.jboss.dna.graph.commands.executor.CommandExecutor
Overrides:
execute in class org.jboss.dna.graph.commands.executor.AbstractCommandExecutor
Throws:
org.jboss.dna.graph.connectors.RepositorySourceException
See Also:
AbstractCommandExecutor.execute(org.jboss.dna.graph.commands.GetPropertiesCommand)

execute

public void execute(org.jboss.dna.graph.commands.GetChildrenCommand command)
             throws org.jboss.dna.graph.connectors.RepositorySourceException

Specified by:
execute in interface org.jboss.dna.graph.commands.executor.CommandExecutor
Overrides:
execute in class org.jboss.dna.graph.commands.executor.AbstractCommandExecutor
Throws:
org.jboss.dna.graph.connectors.RepositorySourceException
See Also:
AbstractCommandExecutor.execute(org.jboss.dna.graph.commands.GetChildrenCommand)

getNode

protected org.jboss.dna.graph.commands.basic.BasicGetNodeCommand getNode(org.jboss.dna.graph.properties.Path path)
                                                                  throws org.jboss.dna.graph.connectors.RepositorySourceException
Get the node information from the underlying sources or, if possible, from the cache.

Parameters:
path - the path of the node to be returned
Returns:
the node information
Throws:
org.jboss.dna.graph.connectors.RepositorySourceException

createFederatedNode

protected FederatedNode createFederatedNode(org.jboss.dna.graph.commands.basic.BasicGetNodeCommand fromCache,
                                            org.jboss.dna.graph.properties.Path path,
                                            List<Contribution> contributions,
                                            boolean updateCache)
                                     throws org.jboss.dna.graph.connectors.RepositorySourceException
Throws:
org.jboss.dna.graph.connectors.RepositorySourceException

loadContributionsFromSources

protected void loadContributionsFromSources(org.jboss.dna.graph.properties.Path path,
                                            Set<String> sourceNames,
                                            List<Contribution> contributions)
                                     throws org.jboss.dna.graph.connectors.RepositorySourceException
Load the node at the supplied path from the sources with the supplied name, returning the information. This method always obtains the information from the sources and does not use or update the cache.

Parameters:
path - the path of the node that is to be loaded
sourceNames - the names of the sources from which contributions are to be loaded; may be empty or null if all contributions from all sources are to be loaded
contributions - the list into which the contributions are to be placed
Throws:
org.jboss.dna.graph.connectors.RepositorySourceException

getMergePlan

protected MergePlan getMergePlan(org.jboss.dna.graph.commands.basic.BasicGetNodeCommand command)

updateCache

protected void updateCache(FederatedNode mergedNode)
                    throws org.jboss.dna.graph.connectors.RepositorySourceException
Throws:
org.jboss.dna.graph.connectors.RepositorySourceException


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