Source Code Cross Referenced for ZServiceRepositoryImpl.java in  » Web-Framework » ztemplates » org » ztemplates » web » impl » 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 » ztemplates » org.ztemplates.web.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.ztemplates.web.impl;
002:
003:        import java.util.HashMap;
004:        import java.util.Map;
005:
006:        import javax.servlet.ServletContext;
007:        import javax.servlet.http.HttpServletRequest;
008:        import javax.servlet.http.HttpServletResponse;
009:
010:        import org.apache.log4j.Logger;
011:        import org.ztemplates.web.ZIActionService;
012:        import org.ztemplates.web.ZIClasspathService;
013:        import org.ztemplates.web.ZIEncryptionService;
014:        import org.ztemplates.web.ZIExceptionService;
015:        import org.ztemplates.web.ZIRenderService;
016:        import org.ztemplates.web.ZISecurityService;
017:        import org.ztemplates.web.ZIService;
018:        import org.ztemplates.web.ZIServiceFactory;
019:        import org.ztemplates.web.ZIServiceRepository;
020:        import org.ztemplates.web.ZIServletService;
021:
022:        public class ZServiceRepositoryImpl implements  ZIServiceRepository {
023:            static final Logger log = Logger
024:                    .getLogger(ZServiceRepositoryImpl.class);
025:
026:            private HttpServletRequest request;
027:
028:            private HttpServletResponse response;
029:
030:            private ServletContext servletContext;
031:
032:            private ZIServiceFactory serviceFactory;
033:
034:            private ZIServletService servletService;
035:
036:            private ZIRenderService renderService;
037:
038:            private ZIActionService actionService;
039:
040:            private ZIClasspathService classpathService;
041:
042:            private ZIEncryptionService encryptionService;
043:
044:            private ZISecurityService securityService;
045:
046:            private ZIExceptionService exceptionService;
047:
048:            private final Map<Class, Object> services = new HashMap<Class, Object>();
049:
050:            /*
051:             * (non-Javadoc)
052:             * 
053:             * @see org.ztemplates.web.impl.ZIServiceRepository#init(javax.servlet.http.HttpServletRequest,
054:             *      javax.servlet.http.HttpServletResponse)
055:             */
056:            public void init(HttpServletRequest req, HttpServletResponse resp)
057:                    throws Exception {
058:                // use default implementation
059:                this .request = req;
060:                this .response = resp;
061:                this .servletContext = req.getSession().getServletContext();
062:                serviceFactory = new ZServiceFactoryImpl();
063:            }
064:
065:            public ZIServiceFactory getServiceFactory() {
066:                return serviceFactory;
067:            }
068:
069:            public void setServiceFactory(ZIServiceFactory serviceFactory) {
070:                this .serviceFactory = serviceFactory;
071:                // clear cached services
072:                servletService = null;
073:                renderService = null;
074:                classpathService = null;
075:                encryptionService = null;
076:                securityService = null;
077:                exceptionService = null;
078:                actionService = null;
079:                services.clear();
080:            }
081:
082:            /*
083:             * (non-Javadoc)
084:             * 
085:             * @see org.ztemplates.web.impl.ZIServiceRepository#getService(java.lang.Class)
086:             */
087:            public <T extends ZIService> T getService(Class<T> clazz) {
088:                T ret = (T) services.get(clazz);
089:                if (ret == null) {
090:                    ret = serviceFactory.createService(this , clazz, null);
091:                    services.put(clazz, ret);
092:                }
093:                return ret;
094:            }
095:
096:            /*
097:             * (non-Javadoc)
098:             * 
099:             * @see org.ztemplates.web.impl.ZIServiceRepository#getServletService()
100:             */
101:            public ZIServletService getServletService() {
102:                if (servletService == null) {
103:                    servletService = serviceFactory.createService(this ,
104:                            ZIServletService.class, ZServletServiceImpl.class);
105:                }
106:                return servletService;
107:            }
108:
109:            /*
110:             * (non-Javadoc)
111:             * 
112:             * @see org.ztemplates.web.impl.ZIServiceRepository#getRenderService()
113:             */
114:            public ZIRenderService getRenderService() {
115:                if (renderService == null) {
116:                    renderService = serviceFactory.createService(this ,
117:                            ZIRenderService.class, ZRenderServiceImpl.class);
118:                }
119:                return renderService;
120:            }
121:
122:            /*
123:             * (non-Javadoc)
124:             * 
125:             * @see org.ztemplates.web.impl.ZIServiceRepository#getClasspathService()
126:             */
127:            public ZIClasspathService getClasspathService() {
128:                if (classpathService == null) {
129:                    classpathService = serviceFactory.createService(this ,
130:                            ZIClasspathService.class,
131:                            ZClasspathServiceImpl.class);
132:                }
133:                return classpathService;
134:            }
135:
136:            /*
137:             * (non-Javadoc)
138:             * 
139:             * @see org.ztemplates.web.impl.ZIServiceRepository#getEncryptionService()
140:             */
141:            public ZIEncryptionService getEncryptionService() {
142:                if (encryptionService == null) {
143:                    encryptionService = serviceFactory.createService(this ,
144:                            ZIEncryptionService.class,
145:                            ZEncryptionServiceImpl.class);
146:                }
147:                return encryptionService;
148:            }
149:
150:            /*
151:             * (non-Javadoc)
152:             * 
153:             * @see org.ztemplates.web.impl.ZIServiceRepository#getSecurityService()
154:             */
155:            public ZISecurityService getSecurityService() {
156:                if (securityService == null) {
157:                    securityService = serviceFactory
158:                            .createService(this , ZISecurityService.class,
159:                                    ZSecurityServiceImpl.class);
160:                }
161:                return securityService;
162:            }
163:
164:            /*
165:             * (non-Javadoc)
166:             * 
167:             * @see org.ztemplates.web.impl.ZIServiceRepository#getExceptionService()
168:             */
169:            public ZIExceptionService getExceptionService() {
170:                if (exceptionService == null) {
171:                    exceptionService = serviceFactory.createService(this ,
172:                            ZIExceptionService.class,
173:                            ZExceptionServiceImpl.class);
174:                }
175:                return exceptionService;
176:            }
177:
178:            public ZIActionService getActionService() {
179:                if (actionService == null) {
180:                    actionService = serviceFactory.createService(this ,
181:                            ZIActionService.class, ZActionServiceImpl.class);
182:                }
183:                return actionService;
184:            }
185:
186:            public HttpServletRequest getRequest() {
187:                return request;
188:            }
189:
190:            public HttpServletResponse getResponse() {
191:                return response;
192:            }
193:
194:            public ServletContext getServletContext() {
195:                return servletContext;
196:            }
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.