Source Code Cross Referenced for SpringConfigurator.java in  » Ajax » dwr » org » directwebremoting » spring » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » dwr » org.directwebremoting.spring 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2006 Joe Walker
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.directwebremoting.spring;
018:
019:        import java.util.List;
020:        import java.util.Map;
021:        import java.util.Properties;
022:        import java.util.Map.Entry;
023:
024:        import org.directwebremoting.AjaxFilter;
025:        import org.directwebremoting.Container;
026:        import org.directwebremoting.extend.AccessControl;
027:        import org.directwebremoting.extend.AjaxFilterManager;
028:        import org.directwebremoting.extend.Configurator;
029:        import org.directwebremoting.extend.ConverterManager;
030:        import org.directwebremoting.extend.Creator;
031:        import org.directwebremoting.extend.CreatorManager;
032:        import org.directwebremoting.impl.SignatureParser;
033:        import org.directwebremoting.util.LocalUtil;
034:        import org.directwebremoting.util.Messages;
035:        import org.springframework.util.StringUtils;
036:
037:        /**
038:         * @author Joe Walker [joe at getahead dot ltd dot uk]
039:         */
040:        public class SpringConfigurator implements  Configurator {
041:            /* (non-Javadoc)
042:             * @see org.directwebremoting.Configurator#configure(org.directwebremoting.Container)
043:             */
044:            public void configure(Container container) {
045:                AccessControl accessControl = container
046:                        .getBean(AccessControl.class);
047:                AjaxFilterManager ajaxFilterManager = container
048:                        .getBean(AjaxFilterManager.class);
049:                ConverterManager converterManager = container
050:                        .getBean(ConverterManager.class);
051:                CreatorManager creatorManager = container
052:                        .getBean(CreatorManager.class);
053:
054:                // Configure the creator types
055:                if (creatorTypes != null) {
056:                    for (Entry<String, String> entry : creatorTypes.entrySet()) {
057:                        String typeName = entry.getKey();
058:                        String className = entry.getValue();
059:
060:                        creatorManager.addCreatorType(typeName, className);
061:                    }
062:                }
063:
064:                // Configure the converter types
065:                if (converterTypes != null) {
066:                    for (Entry<String, String> entry : converterTypes
067:                            .entrySet()) {
068:                        String typeName = entry.getKey();
069:                        String className = entry.getValue();
070:
071:                        converterManager.addConverterType(typeName, className);
072:                    }
073:                }
074:
075:                // Configure the creators
076:                if (creators != null) {
077:                    try {
078:                        for (Entry<String, CreatorConfig> entry : creators
079:                                .entrySet()) {
080:                            String scriptName = entry.getKey();
081:                            CreatorConfig creatorConfig = entry.getValue();
082:
083:                            if (creatorConfig.getCreator() != null) {
084:                                Creator creator = creatorConfig.getCreator();
085:                                creatorManager.addCreator(scriptName, creator);
086:                            } else {
087:                                String creatorName = creatorConfig
088:                                        .getCreatorType();
089:                                Map<String, String> params = creatorConfig
090:                                        .getParams();
091:                                creatorManager.addCreator(scriptName,
092:                                        creatorName, params);
093:                            }
094:
095:                            for (String exclude : creatorConfig.getExcludes()) {
096:                                accessControl.addExcludeRule(scriptName,
097:                                        exclude);
098:                            }
099:
100:                            for (String include : creatorConfig.getIncludes()) {
101:                                accessControl.addIncludeRule(scriptName,
102:                                        include);
103:                            }
104:
105:                            Properties auth = creatorConfig.getAuth();
106:                            for (Entry<Object, Object> aentry : auth.entrySet()) {
107:                                String methodName = (String) aentry.getKey();
108:                                String role = (String) aentry.getValue();
109:                                accessControl.addRoleRestriction(scriptName,
110:                                        methodName, role);
111:                            }
112:
113:                            List<?> filters = creatorConfig.getFilters();
114:                            for (Object obj : filters) {
115:                                if (obj instanceof  String) {
116:                                    String filterName = (String) obj;
117:
118:                                    AjaxFilter filter = LocalUtil
119:                                            .classNewInstance(filterName,
120:                                                    filterName,
121:                                                    AjaxFilter.class);
122:                                    if (filter != null) {
123:                                        ajaxFilterManager.addAjaxFilter(filter,
124:                                                scriptName);
125:                                    }
126:                                } else if (obj instanceof  AjaxFilter) {
127:                                    AjaxFilter filter = (AjaxFilter) obj;
128:                                    ajaxFilterManager.addAjaxFilter(filter,
129:                                            scriptName);
130:                                } else {
131:                                    throw new IllegalArgumentException(
132:                                            Messages
133:                                                    .getString(
134:                                                            "SpringConfigurator.InvalidFilter",
135:                                                            scriptName, obj));
136:                                }
137:                            }
138:                        }
139:                    } catch (Exception ex) {
140:                        throw new IllegalArgumentException(ex);
141:                    }
142:                }
143:
144:                // Configure the converters
145:                if (converters != null) {
146:                    try {
147:                        for (Entry<String, ConverterConfig> entry : converters
148:                                .entrySet()) {
149:                            String match = entry.getKey();
150:                            ConverterConfig converterConfig = entry.getValue();
151:
152:                            Map<String, String> params = converterConfig
153:                                    .getParams();
154:                            if (!converterConfig.getIncludes().isEmpty()) {
155:                                params
156:                                        .put(
157:                                                "include",
158:                                                StringUtils
159:                                                        .collectionToCommaDelimitedString(converterConfig
160:                                                                .getIncludes()));
161:                            }
162:
163:                            if (!converterConfig.getExcludes().isEmpty()) {
164:                                params
165:                                        .put(
166:                                                "exclude",
167:                                                StringUtils
168:                                                        .collectionToCommaDelimitedString(converterConfig
169:                                                                .getExcludes()));
170:                            }
171:
172:                            // params.put("force", Boolean.valueOf(converterConfig.isForce()));
173:                            if (StringUtils.hasText(converterConfig
174:                                    .getJavascriptClassName())) {
175:                                params.put("javascript", converterConfig
176:                                        .getJavascriptClassName());
177:                            }
178:                            converterManager.addConverter(match,
179:                                    converterConfig.getType(), params);
180:                        }
181:                    } catch (Exception ex) {
182:                        throw new IllegalArgumentException(
183:                                Messages
184:                                        .getString("SpringConfigurator.ConfigureConverterError"));
185:                    }
186:                }
187:
188:                // Configure the signatures
189:                if (StringUtils.hasText(signatures)) {
190:                    SignatureParser sigp = new SignatureParser(
191:                            converterManager, creatorManager);
192:                    sigp.parse(signatures);
193:                }
194:            }
195:
196:            /**
197:             * Setter for the map of Creator types
198:             * @param creatorTypes The new creator types map
199:             */
200:            public void setCreatorTypes(Map<String, String> creatorTypes) {
201:                this .creatorTypes = creatorTypes;
202:            }
203:
204:            /**
205:             * Setter for the map of Converter types
206:             * @param converterTypes The new creator types map
207:             */
208:            public void setConverterTypes(Map<String, String> converterTypes) {
209:                this .converterTypes = converterTypes;
210:            }
211:
212:            /**
213:             * Setter for the map of real Creators
214:             * @param creators The new creator map
215:             */
216:            public void setCreators(Map<String, CreatorConfig> creators) {
217:                this .creators = creators;
218:            }
219:
220:            /**
221:             * Setter for the map of real Converter
222:             * @param converters The new creator map
223:             */
224:            public void setConverters(Map<String, ConverterConfig> converters) {
225:                this .converters = converters;
226:            }
227:
228:            /**
229:             * @param signatures the signatures to set
230:             */
231:            public void setSignatures(String signatures) {
232:                this .signatures = signatures;
233:            }
234:
235:            /**
236:             * @return the signatures
237:             */
238:            public String getSignatures() {
239:                return signatures;
240:            }
241:
242:            /**
243:             * The map of Converter types
244:             */
245:            private Map<String, String> creatorTypes;
246:
247:            /**
248:             * The map of Converter types
249:             */
250:            private Map<String, String> converterTypes;
251:
252:            /**
253:             * The map of real Creators
254:             */
255:            private Map<String, CreatorConfig> creators;
256:
257:            /**
258:             * The map of real Converter
259:             */
260:            private Map<String, ConverterConfig> converters;
261:
262:            /**
263:             * The string of Signatures
264:             */
265:            private String signatures;
266:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.