2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to you under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
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  
18  package org.apache.shale.tiger.managed.rules;
19  
20  import org.apache.commons.digester.Digester;
21  import org.apache.commons.digester.RuleSetBase;
22  import org.apache.shale.tiger.config.FacesConfigConfig;
23  
24  /***
25   * <p>Digester <code>RuleSet</code> for parsing managed bean declarations
26   * from a JavaServer Faces configuration file.</p>
27   *
28   * <p><strong>ASSERTION</strong> - The <code>Digester</code> stack is
29   * preinitialized with an instance of {@link FacesConfigConfig} prior
30   * to parsing being initiated.</p>
31   */
32  public class ManagedBeansRuleSet extends RuleSetBase {
33  
34      /*** Creates a new instance of ManagedBeansRuleSet. */
35      public ManagedBeansRuleSet() {
36      }
37  
38  
39      /***
40       * <p>Add the required <code>Rule</code> instances to parse
41       * managed bean declaration metadata.</p>
42       *
43       * @param digester Digester instance to which rules should be added
44       */
45      public void addRuleInstances(Digester digester) {
46  
47          digester.addRule
48                  ("faces-config/managed-bean",
49                   new ManagedBeanRule());
50          digester.addCallMethod
51                  ("faces-config/managed-bean/managed-bean-name",
52                   "setName", 0);
53          digester.addCallMethod
54                  ("faces-config/managed-bean/managed-bean-class",
55                   "setType", 0);
56          digester.addCallMethod
57                  ("faces-config/managed-bean/managed-bean-scope",
58                   "setScope", 0);
59  
60          digester.addRule
61                  ("faces-config/managed-bean/managed-property",
62                   new ManagedPropertyRule());
63          digester.addCallMethod
64                  ("faces-config/managed-bean/managed-property/property-name",
65                   "setName", 0);
66          digester.addCallMethod
67                  ("faces-config/managed-bean/managed-property/property-class",
68                   "setType", 0);
69          digester.addCallMethod
70                  ("faces-config/managed-bean/managed-property/value",
71                   "setValue", 0);
72          digester.addRule
73                  ("faces-config/managed-bean/managed-property/null-value",
74                   new NullValueRule());
75  
76          digester.addRule
77                  ("faces-config/managed-bean/list-entries",
78                   new ListEntriesRule());
79          digester.addCallMethod
80                  ("faces-config/managed-bean/list-entries/value-class",
81                   "setValueType", 0);
82          digester.addRule
83                  ("faces-config/managed-bean/list-entries/null-value",
84                   new ListEntryRule());
85          digester.addRule
86                  ("faces-config/managed-bean/list-entries/null-value",
87                   new NullValueRule());
88          digester.addRule
89                  ("faces-config/managed-bean/list-entries/value",
90                   new ListEntryRule());
91          digester.addCallMethod
92                  ("faces-config/managed-bean/list-entries/value",
93                   "setValue", 0);
94  
95          digester.addRule
96                  ("faces-config/managed-bean/managed-property/list-entries",
97                   new ListEntriesRule());
98          digester.addCallMethod
99                  ("faces-config/managed-bean/managed-property/list-entries/value-class",
100                  "setValueType", 0);
101         digester.addRule
102                 ("faces-config/managed-bean/managed-property/list-entries/null-value",
103                  new ListEntryRule());
104         digester.addRule
105                 ("faces-config/managed-bean/managed-property/list-entries/null-value",
106                  new NullValueRule());
107         digester.addRule
108                 ("faces-config/managed-bean/managed-property/list-entries/value",
109                  new ListEntryRule());
110         digester.addCallMethod
111                 ("faces-config/managed-bean/managed-property/list-entries/value",
112                  "setValue", 0);
113 
114         digester.addRule
115                 ("faces-config/managed-bean/map-entries",
116                  new MapEntriesRule());
117         digester.addCallMethod
118                 ("faces-config/managed-bean/map-entries/key-class",
119                  "setKeyType", 0);
120         digester.addCallMethod
121                 ("faces-config/managed-bean/map-entries/value-class",
122                  "setValueType", 0);
123         digester.addRule
124                 ("faces-config/managed-bean/map-entries/map-entry",
125                  new MapEntryRule());
126         digester.addCallMethod
127                 ("faces-config/managed-bean/map-entries/map-entry/key",
128                  "setKey", 0);
129         digester.addRule
130                 ("faces-config/managed-bean/map-entries/map-entry/null-value",
131                  new NullValueRule());
132         digester.addCallMethod
133                 ("faces-config/managed-bean/map-entries/map-entry/value",
134                  "setValue", 0);
135 
136         digester.addRule
137                 ("faces-config/managed-bean/managed-property/map-entries",
138                  new MapEntriesRule());
139         digester.addCallMethod
140                 ("faces-config/managed-bean/managed-property/map-entries/key-class",
141                  "setKeyType", 0);
142         digester.addCallMethod
143                 ("faces-config/managed-bean/managed-property/map-entries/value-class",
144                  "setValueType", 0);
145         digester.addRule
146                 ("faces-config/managed-bean/managed-property/map-entries/map-entry",
147                  new MapEntryRule());
148         digester.addCallMethod
149                 ("faces-config/managed-bean/managed-property/map-entries/map-entry/key",
150                  "setKey", 0);
151         digester.addRule
152                 ("faces-config/managed-bean/managed-property/map-entries/map-entry/null-value",
153                  new NullValueRule());
154         digester.addCallMethod
155                 ("faces-config/managed-bean/managed-property/map-entries/map-entry/value",
156                  "setValue", 0);
157 
158     }
159 
160 
161 }