01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.engine;
18:
19: import org.kuali.rice.definition.ObjectDefinition;
20: import org.kuali.rice.resourceloader.GlobalResourceLoader;
21:
22: import edu.iu.uis.eden.engine.node.BasicJoinEngine;
23: import edu.iu.uis.eden.engine.node.DynamicNode;
24: import edu.iu.uis.eden.engine.node.JoinEngine;
25: import edu.iu.uis.eden.engine.node.JoinNode;
26: import edu.iu.uis.eden.engine.node.Node;
27: import edu.iu.uis.eden.engine.node.RequestActivationNode;
28: import edu.iu.uis.eden.engine.node.RequestsNode;
29: import edu.iu.uis.eden.engine.node.RouteNode;
30: import edu.iu.uis.eden.engine.node.SimpleNode;
31: import edu.iu.uis.eden.engine.node.SplitNode;
32: import edu.iu.uis.eden.engine.node.SubProcessNode;
33: import edu.iu.uis.eden.util.ClassLoaderUtils;
34:
35: /**
36: * A helper class which provides some useful utilities for examining and generating nodes.
37: * Provides access to the {@link JoinEngine} and the {@link RoutingNodeFactory}.
38: *
39: * @author ewestfal
40: */
41: public class RouteHelper {
42:
43: private JoinEngine joinEngine = new BasicJoinEngine();
44: private RoutingNodeFactory nodeFactory = new RoutingNodeFactory();
45:
46: public JoinEngine getJoinEngine() {
47: return joinEngine;
48: }
49:
50: public RoutingNodeFactory getNodeFactory() {
51: return nodeFactory;
52: }
53:
54: public boolean isSimpleNode(RouteNode routeNode) {
55: return ClassLoaderUtils.isInstanceOf(getNode(routeNode),
56: SimpleNode.class);
57: }
58:
59: public boolean isJoinNode(RouteNode routeNode) {
60: return ClassLoaderUtils.isInstanceOf(getNode(routeNode),
61: JoinNode.class);
62: }
63:
64: public boolean isSplitNode(RouteNode routeNode) {
65: return ClassLoaderUtils.isInstanceOf(getNode(routeNode),
66: SplitNode.class);
67: }
68:
69: public boolean isDynamicNode(RouteNode routeNode) {
70: return ClassLoaderUtils.isInstanceOf(getNode(routeNode),
71: DynamicNode.class);
72: }
73:
74: public boolean isSubProcessNode(RouteNode routeNode) {
75: return ClassLoaderUtils.isInstanceOf(getNode(routeNode),
76: SubProcessNode.class);
77: }
78:
79: public boolean isRequestActivationNode(RouteNode routeNode) {
80: return ClassLoaderUtils.isInstanceOf(getNode(routeNode),
81: RequestActivationNode.class);
82: }
83:
84: public boolean isRequestsNode(RouteNode routeNode) {
85: return getNode(routeNode) instanceof RequestsNode;
86: }
87:
88: public Node getNode(RouteNode routeNode) {
89: return (Node) GlobalResourceLoader
90: .getObject(new ObjectDefinition(
91: routeNode.getNodeType(), routeNode
92: .getDocumentType().getMessageEntity()));
93: }
94: }
|