[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/aop/test/propagation/impl ...
Manik Surtani
msurtani at jboss.com
Fri Jul 21 16:03:29 EDT 2006
User: msurtani
Date: 06/07/21 16:03:29
Added: tests/functional/org/jboss/cache/aop/test/propagation/impl
NodeImpl.java PropagationManagerImpl.java
PropagationRuleFactory.java StateItemImpl.java
Log:
Restored
Revision Changes Path
1.4 +0 -0 JBossCache/tests/functional/org/jboss/cache/aop/test/propagation/impl/NodeImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NodeImpl.java
===================================================================
RCS file: NodeImpl.java
diff -N NodeImpl.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ NodeImpl.java 21 Jul 2006 20:03:29 -0000 1.4
@@ -0,0 +1,103 @@
+package org.jboss.cache.aop.test.propagation.impl;
+
+import org.jboss.cache.aop.test.propagation.Node;
+import org.jboss.cache.aop.test.propagation.PropagationRule;
+import org.jboss.cache.aop.test.propagation.StateItem;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class NodeImpl implements Node {
+ private String rdn_;
+
+ private String fdn_;
+
+ private List childNodes_ = new ArrayList();
+
+ private Node parentNode_;
+
+ private List stateItems_ = new ArrayList();
+
+ private StateItem summaryItem_;
+
+ private transient PropagationRule rule_;
+
+ public NodeImpl() {
+ rule_ = PropagationRuleFactory.getPropagationRule();
+ }
+
+ public void setNodeRDN(String rdn) {
+ this.rdn_ = rdn;
+ }
+
+ public String getNodeRDN() {
+ return this.rdn_;
+ }
+
+ public void setNodeFDN(String fdn) {
+ this.fdn_ = fdn;
+ }
+
+ public String getNodeFDN() {
+ return this.fdn_;
+ }
+
+ public void addChildNode(Node child) {
+ childNodes_.add(child);
+ }
+
+ public List getChildren() {
+ return childNodes_;
+ }
+
+ public void setParentNode(Node parent) {
+ parentNode_ = parent;
+ }
+
+ public Node getParentNode() {
+ return this.parentNode_;
+ }
+
+ public void addStateItem(StateItem stateItem) {
+ stateItems_.add(stateItem);
+ }
+
+ public void setSummaryStateItem(StateItem stateItem) {
+ this.summaryItem_ = stateItem;
+ }
+
+ public StateItem getSummaryStateItem() {
+ return this.summaryItem_;
+ }
+
+ public void setPropagationRule(PropagationRule rule) {
+ this.rule_ = rule;
+ }
+
+ public PropagationRule getPropagationRule() {
+ return rule_;
+ }
+
+
+ public List getStateItems() {
+ return this.stateItems_;
+ }
+
+ public StateItem findStateItem(long itemId) {
+ StateItem retItem = null;
+ int size = stateItems_.size();
+ for (int idx = 0; idx < size; idx++) {
+ StateItem stateItem = (StateItem) stateItems_.get(idx);
+ if (stateItem.getItemId() == itemId) {
+ retItem = stateItem;
+ break;
+ }
+ }
+
+ return retItem;
+ }
+
+ public String toString() {
+ return getNodeFDN();
+ }
+}
1.4 +0 -0 JBossCache/tests/functional/org/jboss/cache/aop/test/propagation/impl/PropagationManagerImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PropagationManagerImpl.java
===================================================================
RCS file: PropagationManagerImpl.java
diff -N PropagationManagerImpl.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PropagationManagerImpl.java 21 Jul 2006 20:03:29 -0000 1.4
@@ -0,0 +1,150 @@
+package org.jboss.cache.aop.test.propagation.impl;
+
+import org.jboss.cache.aop.test.propagation.Node;
+import org.jboss.cache.aop.test.propagation.PropagationManager;
+import org.jboss.cache.aop.test.propagation.PropagationRule;
+import org.jboss.cache.aop.test.propagation.StateItem;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class PropagationManagerImpl implements PropagationManager {
+ private Node rootNode_;
+
+ private Map nodeMap_ = new HashMap();
+
+ private transient PropagationRule orRule_;
+
+ public PropagationManagerImpl() {
+ orRule_ = PropagationRuleFactory.getPropagationRule();
+ }
+
+ public void setRootNode(String rdn) {
+ this.rootNode_ = new NodeImpl();
+ rootNode_.setNodeFDN(rdn);
+ rootNode_.setNodeRDN(rdn);
+ rootNode_.setPropagationRule(orRule_);
+
+ StateItem summary = new StateItemImpl(0);
+ summary.setState(PropagationRule.STATE_CLEAR);
+ rootNode_.setSummaryStateItem(summary);
+
+ registMap(rootNode_);
+ }
+
+ public void addNode(String parentFdn, String rdn) {
+ Node parent = findNode(parentFdn);
+ if (parent != null) {
+ Node node = new NodeImpl();
+ node.setNodeFDN(parentFdn + "." + rdn);
+ node.setNodeRDN(rdn);
+ node.setPropagationRule(orRule_);
+
+ node.setParentNode(parent);
+ parent.addChildNode(node);
+
+ StateItem summary = new StateItemImpl(0);
+ summary.setState(PropagationRule.STATE_CLEAR);
+ node.setSummaryStateItem(summary);
+
+ registMap(node);
+
+ PropagationRule rule = node.getPropagationRule();
+ rule.summaryUpperPropagate(node);
+ }
+ }
+
+ public void addStateItem(String parentFdn, long itemId, long defaultState) {
+ Node node = findNode(parentFdn);
+ if (node != null) {
+ StateItem item = new StateItemImpl(itemId);
+ item.setState(defaultState);
+
+ node.addStateItem(item);
+
+ PropagationRule rule = node.getPropagationRule();
+ rule.summaryUpperPropagate(node);
+ }
+ }
+
+ public void stateChange(String parentFdn, long itemId, long newState) {
+ Node node = findNode(parentFdn);
+ if (node != null) {
+ PropagationRule rule = node.getPropagationRule();
+ rule.changeState(node, itemId, newState);
+ }
+ }
+
+ public Node findNode(String fdn) {
+ return (Node) nodeMap_.get(fdn);
+ }
+
+ private void registMap(Node node) {
+ this.nodeMap_.put(node.getNodeFDN(), node);
+ }
+
+ public void printNodes() {
+ printNode(rootNode_, "");
+ }
+
+ private void printNode(Node node, String prefix) {
+ System.out.println(prefix + node.getNodeRDN() + " (Summary : "
+ + node.getSummaryStateItem().getState() + ")");
+
+ String itemPrefix = prefix + " | ";
+ List items = node.getStateItems();
+ int size = items.size();
+ for (int idx = 0; idx < size; idx++) {
+ StateItem item = (StateItem) items.get(idx);
+ printStateItem(item, itemPrefix);
+ }
+
+ String childPrefix = prefix + " + ";
+ List children = node.getChildren();
+ size = children.size();
+ for (int idx = 0; idx < size; idx++) {
+ Node child = (Node) children.get(idx);
+ printNode(child, childPrefix);
+ }
+ }
+
+ private void printStateItem(StateItem item, String prefix) {
+ System.out.println(prefix + "(" + item.getItemId() + " : "
+ + item.getState() + ")");
+ }
+
+ private String toNodeString(Node node, String prefix) {
+ StringBuffer buf = new StringBuffer();
+
+ buf.append(prefix + node.getNodeRDN() + " (Summary : "
+ + node.getSummaryStateItem().getState() + ")");
+
+ String itemPrefix = prefix + " | ";
+ List items = node.getStateItems();
+ int size = items.size();
+ for (int idx = 0; idx < size; idx++) {
+ StateItem item = (StateItem) items.get(idx);
+ buf.append(toStateItemString(item, itemPrefix));
+ }
+
+ String childPrefix = prefix + " + ";
+ List children = node.getChildren();
+ size = children.size();
+ for (int idx = 0; idx < size; idx++) {
+ Node child = (Node) children.get(idx);
+ buf.append(toNodeString(child, childPrefix));
+ }
+
+ return buf.toString();
+ }
+
+ private String toStateItemString(StateItem item, String prefix) {
+ return (prefix + "(" + item.getItemId() + " : "
+ + item.getState() + ")");
+ }
+
+ public String toString() {
+ return toNodeString(rootNode_, "+");
+ }
+}
1.4 +0 -0 JBossCache/tests/functional/org/jboss/cache/aop/test/propagation/impl/PropagationRuleFactory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PropagationRuleFactory.java
===================================================================
RCS file: PropagationRuleFactory.java
diff -N PropagationRuleFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PropagationRuleFactory.java 21 Jul 2006 20:03:29 -0000 1.4
@@ -0,0 +1,9 @@
+package org.jboss.cache.aop.test.propagation.impl;
+
+import org.jboss.cache.aop.test.propagation.PropagationRule;
+
+public class PropagationRuleFactory {
+ public static PropagationRule getPropagationRule() {
+ return new ORSummaryRule();
+ }
+}
1.4 +0 -0 JBossCache/tests/functional/org/jboss/cache/aop/test/propagation/impl/StateItemImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: StateItemImpl.java
===================================================================
RCS file: StateItemImpl.java
diff -N StateItemImpl.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ StateItemImpl.java 21 Jul 2006 20:03:29 -0000 1.4
@@ -0,0 +1,39 @@
+package org.jboss.cache.aop.test.propagation.impl;
+
+import org.jboss.cache.aop.test.propagation.PropagationRule;
+import org.jboss.cache.aop.test.propagation.StateItem;
+
+public class StateItemImpl implements StateItem {
+ private long itemId_;
+ private long state_;
+
+ public StateItemImpl()
+ {
+ }
+
+ public StateItemImpl(long itemId) {
+ this.itemId_ = itemId;
+ this.state_ = PropagationRule.STATE_CLEAR;
+ }
+
+ public long getState() {
+ return this.state_;
+ }
+
+ public boolean setState(long state) {
+ if (this.state_ != state) {
+ state_ = state;
+ return STATE_CHANGED;
+ } else {
+ return STATE_NOT_CHANGED;
+ }
+ }
+
+ public long getItemId() {
+ return this.itemId_;
+ }
+
+ public String toString() {
+ return "Id: " + itemId_ + " state: " + state_ + "\n";
+ }
+}
More information about the jboss-cvs-commits
mailing list