Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BaseRuleSet |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright 1999-2001,2004 The Apache Software Foundation. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | ||
18 | package org.apache.commons.workflow.base; | |
19 | ||
20 | ||
21 | import org.apache.commons.digester.Digester; | |
22 | import org.apache.commons.digester.Rule; | |
23 | import org.apache.commons.digester.RuleSet; | |
24 | import org.apache.commons.digester.RuleSetBase; | |
25 | ||
26 | ||
27 | /** | |
28 | * <p><strong>RuleSet</strong> for the basic Activity definitions of the | |
29 | * Workflow Management System, typically associated with the <em>base</em> | |
30 | * prefix. This library is normally associated with the namespace URI:</p> | |
31 | * <pre> | |
32 | * http://commons.apache.org/workflow/base | |
33 | * </pre> | |
34 | * | |
35 | * <p>This class also serves as a convenience base class for the | |
36 | * <code>RuleSet</code> implementations for Step libraries. Subclasses | |
37 | * MUST override the no-arguments constructor to set the correct | |
38 | * namespace URI, and MUST override (and replace) the | |
39 | * <code>addRuleInstances()</code> method to add the relevant rules | |
40 | * for that particular library. | |
41 | * | |
42 | * @author Craig R. McClanahan | |
43 | * @version $Revision: 561366 $ $Date: 2007-07-31 16:58:29 +0100 (Tue, 31 Jul 2007) $ | |
44 | */ | |
45 | ||
46 | public class BaseRuleSet extends RuleSetBase { | |
47 | ||
48 | ||
49 | // ------------------------------------------------------------ Constructor | |
50 | ||
51 | ||
52 | /** | |
53 | * Construct a default instance of the <code>RuleSet</code>. | |
54 | */ | |
55 | public BaseRuleSet() { | |
56 | ||
57 | 0 | super(); |
58 | 0 | setNamespaceURI("http://commons.apache.org/workflow/base"); |
59 | ||
60 | 0 | } |
61 | ||
62 | ||
63 | // ------------------------------------------------------------- Properties | |
64 | ||
65 | ||
66 | /** | |
67 | * Set the namespace URI that these rules apply to. This is only needed | |
68 | * if you want to reset the default value created by a subclass. | |
69 | * | |
70 | * @param namespaceURI The new namespace URI | |
71 | */ | |
72 | public void setNamespaceURI(String namespaceURI) { | |
73 | 0 | this.namespaceURI = namespaceURI; |
74 | 0 | } |
75 | ||
76 | ||
77 | // --------------------------------------------------------- Public Methods | |
78 | ||
79 | ||
80 | /** | |
81 | * <p>Add the set of Rule instances defined in this RuleSet to the | |
82 | * specified <code>Digester</code> instance, associating them with | |
83 | * our namespace URI (if any). This method should only be called | |
84 | * by a Digester instance.</p> | |
85 | * | |
86 | * @param digester Digester instance to which the new Rule instances | |
87 | * should be added. | |
88 | */ | |
89 | public void addRuleInstances(Digester digester) { | |
90 | ||
91 | 0 | digester.addObjectCreate("activity", |
92 | "org.apache.commons.workflow.base.BaseActivity"); | |
93 | 0 | digester.addSetProperties("activity"); |
94 | ||
95 | 0 | } |
96 | ||
97 | ||
98 | // ------------------------------------------------------ Protected Methods | |
99 | ||
100 | ||
101 | /** | |
102 | * Add the standard set of rules for a new Descriptor that should be | |
103 | * recognized. | |
104 | * | |
105 | * @param digester Digester to which we are adding new rules | |
106 | * @param element Element name to be matched | |
107 | */ | |
108 | protected void addStandardDescriptor(Digester digester, String element) { | |
109 | ||
110 | 0 | String pattern = "*/" + element; |
111 | 0 | digester.addObjectCreate(pattern, |
112 | "org.apache.commons.workflow.base.BaseDescriptor"); | |
113 | 0 | digester.addSetProperties(pattern); |
114 | 0 | digester.addSetNext(pattern, "addDescriptor", |
115 | "org.apache.commons.workflow.Descriptor"); | |
116 | ||
117 | 0 | } |
118 | ||
119 | ||
120 | /** | |
121 | * Add the standard set of rules for a new Step that should be recognized. | |
122 | * | |
123 | * @param digester Digester to which we are adding new rules | |
124 | * @param element Element name to be matched | |
125 | * @param name Fully qualified class name of the implementation class | |
126 | */ | |
127 | protected void addStandardStep(Digester digester, String element, | |
128 | String name) { | |
129 | ||
130 | 0 | String pattern = "*/" + element; |
131 | 0 | digester.addObjectCreate(pattern, name); |
132 | 0 | digester.addSetProperties(pattern); |
133 | 0 | digester.addSetNext(pattern, "addStep", |
134 | "org.apache.commons.workflow.Step"); | |
135 | ||
136 | 0 | } |
137 | ||
138 | ||
139 | } |