org.jboss.dna.repository.rules
Class RuleSetRepositoryMonitor

java.lang.Object
  extended by org.jboss.dna.repository.rules.RuleSetRepositoryMonitor
All Implemented Interfaces:
NodeChangeListener

@ThreadSafe
public class RuleSetRepositoryMonitor
extends Object
implements NodeChangeListener

A component that can listen to a JCR repository and keep the RuleSet instances of a RuleService synchronized with that repository.

This class is a NodeChangeListener that can subscribe to changes in one or more JCR repositories being monitored by an ObservationService. As changes under the rule sets branch are discovered, they are processed asynchronously. This ensure that the processing of the repository contents does not block the other listeners of the ObservationService.

Author:
Randall Hauch

Field Summary
static String DEFAULT_JCR_ABSOLUTE_PATH
           
protected static String JCR_PATH_DELIM
           
 
Constructor Summary
RuleSetRepositoryMonitor(RuleService ruleService, String jcrAbsolutePath, JcrExecutionContext executionContext)
          Create an instance that can listen to the RuleSet definitions stored in a JCR repository and ensure that the RuleSet instances of a RuleService reflect the definitions in the repository.
 
Method Summary
protected  RuleSet buildRuleSet(String name, javax.jcr.Node ruleSetNode, JcrTools tools)
          Create a rule set from the supplied node.
 String getAbsolutePathToRuleSets()
           
 org.jboss.dna.common.util.Logger getLogger()
           
 RuleService getRuleService()
           
 void onNodeChanges(NodeChanges changes)
          
protected  void processRuleSets(Map<String,Set<String>> ruleSetNamesByWorkspaceName)
          Process the rule sets given by the supplied names, keyed by the repository workspace name.
 void setLogger(org.jboss.dna.common.util.Logger logger)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_JCR_ABSOLUTE_PATH

public static final String DEFAULT_JCR_ABSOLUTE_PATH
See Also:
Constant Field Values

JCR_PATH_DELIM

protected static final String JCR_PATH_DELIM
See Also:
Constant Field Values
Constructor Detail

RuleSetRepositoryMonitor

public RuleSetRepositoryMonitor(RuleService ruleService,
                                String jcrAbsolutePath,
                                JcrExecutionContext executionContext)
Create an instance that can listen to the RuleSet definitions stored in a JCR repository and ensure that the RuleSet instances of a RuleService reflect the definitions in the repository.

Parameters:
ruleService - the rule service that should be kept in sync with the JCR repository.
jcrAbsolutePath - the absolute path to the branch where the rule sets are defined; if null or empty, the default path is used
executionContext - the context in which this monitor is to execute
Throws:
IllegalArgumentException - if the rule service or execution context is null, or if the supplied jcrAbsolutePath is invalid
Method Detail

getRuleService

public RuleService getRuleService()
Returns:
ruleService

getAbsolutePathToRuleSets

public String getAbsolutePathToRuleSets()
Returns:
jcrAbsolutePath

getLogger

public org.jboss.dna.common.util.Logger getLogger()
Returns:
logger

setLogger

public void setLogger(org.jboss.dna.common.util.Logger logger)
Parameters:
logger - Sets logger to the specified value.

onNodeChanges

public void onNodeChanges(NodeChanges changes)

Specified by:
onNodeChanges in interface NodeChangeListener

processRuleSets

protected void processRuleSets(Map<String,Set<String>> ruleSetNamesByWorkspaceName)
Process the rule sets given by the supplied names, keyed by the repository workspace name.

Parameters:
ruleSetNamesByWorkspaceName - the set of rule set names keyed by the repository workspace name

buildRuleSet

protected RuleSet buildRuleSet(String name,
                               javax.jcr.Node ruleSetNode,
                               JcrTools tools)
Create a rule set from the supplied node. This is called whenever a branch of the repository is changed.

This implementation expects a node of type 'dna:ruleSet' and the following properties (expressed as XPath statements relative to the supplied node):

Parameters:
name - the name of the rule set; never null
ruleSetNode - the node representing the rule set; null if the rule set doesn't exist
tools -
Returns:
the rule set for the information stored in the repository, or null if the rule set does not exist or has errors


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