Source Code Cross Referenced for PropertiesBuilder.java in  » Web-Framework » Strecks » org » strecks » builder » 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 » Web Framework » Strecks » org.strecks.builder 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2006 the original author or authors.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005:         * in compliance with the License. You may obtain a copy of the License at
006:         * 
007:         * http://www.apache.org/licenses/LICENSE-2.0
008:         * 
009:         * Unless required by applicable law or agreed to in writing, software distributed under the License
010:         * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011:         * or implied. See the License for the specific language governing permissions and limitations under
012:         * the License.
013:         */
014:
015:        package org.strecks.builder;
016:
017:        import java.util.Properties;
018:
019:        import org.strecks.context.ActionContextFactory;
020:        import org.strecks.controller.ActionCreator;
021:        import org.strecks.controller.ControllerProcessorDelegate;
022:        import org.strecks.form.handler.FormPopulateSource;
023:        import org.strecks.form.handler.FormValidationHandler;
024:        import org.strecks.form.handler.FormWrapper;
025:        import org.strecks.preprocess.RequestPreprocessor;
026:        import org.strecks.util.ReflectHelper;
027:
028:        /**
029:         * The default <code>Builder</code> implementation, which loads configuration information from the
030:         * <code>strecks.properties</code> file located on the class path
031:         * @author Phil Zoio
032:         */
033:        public class PropertiesBuilder implements  Builder {
034:
035:            private ActionCreator actionCreator;
036:
037:            private ControllerProcessorDelegate delegate;
038:
039:            private ActionContextFactory actionContextFactory;
040:
041:            private FormWrapper formHandler;
042:
043:            private FormValidationHandler formValidationHandler;
044:
045:            private FormPopulateSource formPopulateSource;
046:
047:            private RequestPreprocessor requestPreprocessor;
048:
049:            private ImplementationConfig implementationConfig;
050:
051:            private InterceptorBuilder interceptorBuilder;
052:
053:            public void build(String prefix) {
054:                String name = getFileName(prefix);
055:                Properties properties = ConfigUtils.loadProperties(name);
056:                this .implementationConfig = getImplementationConfig(properties);
057:                setActionCreator(ReflectHelper.createInstance(
058:                        implementationConfig.getActionCreatorClassName(),
059:                        ActionCreator.class));
060:                setDelegate(ReflectHelper.createInstance(implementationConfig
061:                        .getDelegateClassName(),
062:                        ControllerProcessorDelegate.class));
063:                setFormHandler(ReflectHelper.createInstance(
064:                        implementationConfig.getFormHandlerClassName(),
065:                        FormWrapper.class));
066:                setActionContextFactory(ReflectHelper.createInstance(
067:                        implementationConfig.getContextFactoryClassName(),
068:                        ActionContextFactory.class));
069:                setFormHandler(ReflectHelper.createInstance(
070:                        implementationConfig.getFormHandlerClassName(),
071:                        FormWrapper.class));
072:                setFormValidationHandler(ReflectHelper.createInstance(
073:                        implementationConfig
074:                                .getFormValidationHandlerClassName(),
075:                        FormValidationHandler.class));
076:                setFormPopulateSource(ReflectHelper.createInstance(
077:                        implementationConfig.getFormPopulateSourceClassName(),
078:                        FormPopulateSource.class));
079:                setRequestPreprocessor(ReflectHelper.createInstance(
080:                        implementationConfig.getRequestPreprocessorClassName(),
081:                        RequestPreprocessor.class));
082:
083:                this .interceptorBuilder = new InterceptorBuilderImpl();
084:                interceptorBuilder.build(prefix);
085:
086:                this .delegate.setBeforeInterceptors(interceptorBuilder
087:                        .getBeforeInterceptors());
088:                this .delegate.setAfterInterceptors(interceptorBuilder
089:                        .getAfterInterceptors());
090:            }
091:
092:            protected String getFileName(String prefix) {
093:                return ConfigUtils.getPropertiesFileName(prefix);
094:            }
095:
096:            ImplementationConfig getImplementationConfig(Properties properties) {
097:
098:                ImplementationConfig config = new ImplementationConfig();
099:
100:                String builderImpl = properties.getProperty("builder.impl");
101:                if (builderImpl != null) {
102:                    config.setBuilderClassName(builderImpl);
103:                }
104:
105:                String actionCreatorImpl = properties
106:                        .getProperty("action.creator.impl");
107:                if (actionCreatorImpl != null) {
108:                    config.setActionCreatorClassName(actionCreatorImpl);
109:                }
110:
111:                String delegateImpl = properties.getProperty("delegate.impl");
112:                if (delegateImpl != null) {
113:                    config.setDelegateClassName(delegateImpl);
114:                }
115:
116:                String contextFactoryImpl = properties
117:                        .getProperty("context.factory.impl");
118:                if (contextFactoryImpl != null) {
119:                    config.setContextFactoryClassName(contextFactoryImpl);
120:                }
121:
122:                String formHandlerImpl = properties
123:                        .getProperty("form.wrapper.impl");
124:                if (formHandlerImpl != null) {
125:                    config.setFormHandlerClassName(formHandlerImpl);
126:                }
127:
128:                String formValidationHandlerImpl = properties
129:                        .getProperty("form.validation.handler.impl");
130:                if (formValidationHandlerImpl != null) {
131:                    config
132:                            .setFormValidationHandlerClassName(formValidationHandlerImpl);
133:                }
134:
135:                String formPopulationSourceImpl = properties
136:                        .getProperty("form.populate.source.impl");
137:                if (formPopulationSourceImpl != null) {
138:                    config
139:                            .setFormPopulateSourceClassName(formPopulationSourceImpl);
140:                }
141:
142:                String requestPreprocessorImpl = properties
143:                        .getProperty("request.preprocessor.impl");
144:                if (requestPreprocessorImpl != null) {
145:                    config
146:                            .setRequestPreprocessorClassName(requestPreprocessorImpl);
147:                }
148:
149:                return config;
150:
151:            }
152:
153:            public InterceptorConfig getInterceptorConfig(Properties properties) {
154:                InterceptorConfig config = new InterceptorConfig();
155:                int index = 1;
156:                String beforeInterceptor;
157:
158:                while ((beforeInterceptor = properties
159:                        .getProperty("before.interceptor." + index)) != null) {
160:                    config.addBeforeInterceptor(beforeInterceptor);
161:                    index++;
162:                }
163:
164:                index = 1;
165:                String afterInterceptor;
166:
167:                while ((afterInterceptor = properties
168:                        .getProperty("after.interceptor." + index)) != null) {
169:                    config.addAfterInterceptor(afterInterceptor);
170:                    index++;
171:                }
172:
173:                return config;
174:            }
175:
176:            public ImplementationConfig getConfig() {
177:                return implementationConfig;
178:            }
179:
180:            public ActionCreator getActionCreator() {
181:                return actionCreator;
182:            }
183:
184:            public ControllerProcessorDelegate getControllerDelegate() {
185:                return delegate;
186:            }
187:
188:            public FormWrapper getFormHandler() {
189:                return formHandler;
190:            }
191:
192:            public ActionContextFactory getActionContextFactory() {
193:                return actionContextFactory;
194:            }
195:
196:            public FormPopulateSource getFormPopulateSource() {
197:                return formPopulateSource;
198:            }
199:
200:            public FormValidationHandler getFormValidationHandler() {
201:                return formValidationHandler;
202:            }
203:
204:            public RequestPreprocessor getRequestPreprocessor() {
205:                return requestPreprocessor;
206:            }
207:
208:            ControllerProcessorDelegate getDelegate() {
209:                return delegate;
210:            }
211:
212:            void setDelegate(ControllerProcessorDelegate delegate) {
213:                this .delegate = delegate;
214:            }
215:
216:            void setActionContextFactory(
217:                    ActionContextFactory actionContextFactory) {
218:                this .actionContextFactory = actionContextFactory;
219:            }
220:
221:            void setActionCreator(ActionCreator actionCreator) {
222:                this .actionCreator = actionCreator;
223:            }
224:
225:            void setFormHandler(FormWrapper formHandler) {
226:                this .formHandler = formHandler;
227:            }
228:
229:            void setFormPopulateSource(FormPopulateSource formPopulateSource) {
230:                this .formPopulateSource = formPopulateSource;
231:            }
232:
233:            void setFormValidationHandler(
234:                    FormValidationHandler formValidationHandler) {
235:                this .formValidationHandler = formValidationHandler;
236:            }
237:
238:            void setRequestPreprocessor(RequestPreprocessor requestPreprocessor) {
239:                this.requestPreprocessor = requestPreprocessor;
240:            }
241:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.