KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > directwebremoting > spring > CreatorConfig


1 /*
2  * Copyright 2005 Joe Walker
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 package org.directwebremoting.spring;
17
18 import java.util.List JavaDoc;
19 import java.util.Properties JavaDoc;
20 import java.util.ArrayList JavaDoc;
21
22 import org.directwebremoting.AjaxFilter;
23 import org.directwebremoting.extend.Creator;
24
25 /**
26  * The configuration for a creator. <br>
27  * You can either specify the creator directly or specify one of the build in creator types,
28  * for instance "new".
29  *
30  * It allows the specification of the following optional configuration parameters:
31  * <ul>
32  * <li>includes - the list of method names to include</li>
33  * <li>excludes - the list of method names to exclude</li>
34  * <li>auth - the <code>Properties</code> object containing method names and corresponding
35  * required role</li>
36  * <li>filters - the list of filter objects</li>
37  * </ul>
38  *
39  * @see org.directwebremoting.extend.AccessControl#addIncludeRule(String, String)
40  * @see org.directwebremoting.extend.AccessControl#addExcludeRule(String, String)
41  * @see org.directwebremoting.extend.AccessControl#addRoleRestriction(String, String, String)
42  * @see org.directwebremoting.AjaxFilter
43  * @see org.directwebremoting.extend.AjaxFilterManager#addAjaxFilter(org.directwebremoting.AjaxFilter, String)
44  *
45  * @author Bram Smeets
46  * @author Joe Walker [joe at getahead dot ltd dot uk]
47  */

48 public class CreatorConfig extends AbstractConfig
49 {
50     /**
51      * The creator type that will be used to create new objects for remoting
52      * @return Returns the creator type.
53      */

54     public String JavaDoc getCreatorType()
55     {
56         return creatorType;
57     }
58
59     /**
60      * The creator that will be used to create new objects for remoting
61      * @param creatorType The creator type to set.
62      */

63     public void setCreatorType(String JavaDoc creatorType)
64     {
65         this.creatorType = creatorType;
66     }
67
68     /**
69      * The creator that will be used to create new objects for remoting
70      * @return Returns the creator.
71      */

72     public Creator getCreator()
73     {
74         return creator;
75     }
76
77     /**
78      * The creator type that will be used to create new objects for remoting
79      * @param creator The creator to set.
80      */

81     public void setCreator(Creator creator)
82     {
83         this.creator = creator;
84     }
85
86     /**
87      * Sets the authentication parameters for this creator.
88      * @return the map containing the method name and the corrosponding required role
89      * @see org.directwebremoting.extend.AccessControl#addRoleRestriction(String, String, String)
90      */

91     public Properties JavaDoc getAuth()
92     {
93         return auth;
94     }
95
96     /**
97      * Sets the authentication parameters for this creator.
98      * @param auth the map containing the method name and the corrosponding required role
99      * @see org.directwebremoting.extend.AccessControl#addRoleRestriction(String, String, String)
100      */

101     public void setAuth(Properties JavaDoc auth)
102     {
103         this.auth = auth;
104     }
105
106     /**
107      * Gets the list of all filters for this creator.
108      * @return the list containing all filters
109      * @see org.directwebremoting.AjaxFilter
110      * @see org.directwebremoting.extend.AjaxFilterManager#addAjaxFilter(org.directwebremoting.AjaxFilter, String)
111      */

112     public List JavaDoc getFilters()
113     {
114         return filters;
115     }
116
117     /**
118      * Sets the list of all filters for this creator.
119      * @param filters the list containing all filters
120      * @see org.directwebremoting.AjaxFilter
121      * @see org.directwebremoting.extend.AjaxFilterManager#addAjaxFilter(org.directwebremoting.AjaxFilter, String)
122      */

123     public void setFilters(List JavaDoc filters)
124     {
125         this.filters = filters;
126     }
127
128     /**
129      * Convenience method for adding an authentication rule.
130      * @param method the method to add the authentication rule
131      * @param role the role to add the authentication constraint for
132      * @throws IllegalArgumentException in case the specified argument is null
133      */

134     public void addAuth(String JavaDoc method, String JavaDoc role)
135     {
136         auth.setProperty(method, role);
137     }
138
139     /**
140      * Convenience method for adding a filter.
141      * @param filter the filter to add for this creator
142      * @throws IllegalArgumentException in case the specified argument is null
143      */

144     public void addFilter(AjaxFilter filter)
145     {
146         filters.add(filter);
147     }
148
149     /**
150      * The creator type to use
151      */

152     private String JavaDoc creatorType;
153
154     /**
155      * The creator to use
156      */

157     private Creator creator;
158
159     /**
160      * The properties containing the method name and the corrosponding required role.
161      */

162     private Properties JavaDoc auth = new Properties JavaDoc();
163
164     /**
165      * The list of filter objects for this creator.
166      */

167     private List JavaDoc filters = new ArrayList JavaDoc();
168 }
169
Popular Tags