Source Code Cross Referenced for InterceptorService.java in  » Forum » mvnforum-1.1 » net » myvietnam » mvncore » interceptor » 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 » Forum » mvnforum 1.1 » net.myvietnam.mvncore.interceptor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /cvsroot/mvnforum/myvietnam/src/net/myvietnam/mvncore/interceptor/InterceptorService.java,v 1.12 2007/07/04 03:05:46 phuongpdd Exp $
003:         * $Author: phuongpdd $
004:         * $Revision: 1.12 $
005:         * $Date: 2007/07/04 03:05:46 $
006:         *
007:         * ====================================================================
008:         *
009:         * Copyright (C) 2002-2007 by MyVietnam.net
010:         *
011:         * All copyright notices regarding MyVietnam and MyVietnam CoreLib
012:         * MUST remain intact in the scripts and source code.
013:         *
014:         * This library is free software; you can redistribute it and/or
015:         * modify it under the terms of the GNU Lesser General Public
016:         * License as published by the Free Software Foundation; either
017:         * version 2.1 of the License, or (at your option) any later version.
018:         *
019:         * This library is distributed in the hope that it will be useful,
020:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
021:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
022:         * Lesser General Public License for more details.
023:         *
024:         * You should have received a copy of the GNU Lesser General Public
025:         * License along with this library; if not, write to the Free Software
026:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
027:         *
028:         * Correspondence and Marketing Questions can be sent to:
029:         * info at MyVietnam net
030:         *
031:         * @author: Minh Nguyen  
032:         */
033:        package net.myvietnam.mvncore.interceptor;
034:
035:        import net.myvietnam.mvncore.MVNCoreConfig;
036:        import net.myvietnam.mvncore.exception.InterceptorException;
037:        import org.apache.commons.logging.Log;
038:        import org.apache.commons.logging.LogFactory;
039:
040:        public class InterceptorService {
041:
042:            private static Log log = LogFactory
043:                    .getLog(InterceptorService.class);
044:
045:            //private static final String OPTION_FILE_NAME = "mvncore.xml";
046:
047:            /** Singleton instance of this class */
048:            private static InterceptorService instance = new InterceptorService();
049:
050:            private MailInterceptor mailInterceptor = null;
051:
052:            private ContentInterceptor contentInterceptor = null;
053:
054:            private LoginIDInterceptor loginIDInterceptor = null;
055:
056:            private PasswordInterceptor passwordInterceptor = null;
057:
058:            /**
059:             * Private constructor to prevent instantiation
060:             */
061:            private InterceptorService() {
062:                loadInterceptorInfo();
063:            }
064:
065:            private void loadInterceptorInfo() {
066:                String mailInterceptorClassName = MVNCoreConfig
067:                        .getMailInterceptorClassName();
068:                loadMailInterceptor(mailInterceptorClassName);
069:
070:                String contentInterceptorClassName = MVNCoreConfig
071:                        .getContentInterceptorClassName();
072:                loadContentInterceptor(contentInterceptorClassName);
073:
074:                String loginIDInterceptorClassName = MVNCoreConfig
075:                        .getLoginIdInterceptorClassName();
076:                loadLoginIDInterceptor(loginIDInterceptorClassName);
077:
078:                String passwordInterceptorClassName = MVNCoreConfig
079:                        .getPasswordInterceptorClassName();
080:                loadPasswordInterceptor(passwordInterceptorClassName);
081:
082:            }
083:
084:            private void loadContentInterceptor(
085:                    String contentInterceptorClassName) {
086:
087:                try {
088:                    if (contentInterceptorClassName.length() > 0) {
089:                        Class contentInterceptorClass = Class
090:                                .forName(contentInterceptorClassName);
091:                        ContentInterceptor interceptor = (ContentInterceptor) contentInterceptorClass
092:                                .newInstance();
093:                        setContentInterceptor(interceptor);
094:                    }
095:                } catch (Exception ex) {
096:                    log.error("Cannot load ContentInterceptor", ex);
097:                }
098:            }
099:
100:            private void loadMailInterceptor(String mailInterceptorClassName) {
101:
102:                try {
103:                    if (mailInterceptorClassName.length() > 0) {
104:                        Class mailInterceptorClass = Class
105:                                .forName(mailInterceptorClassName);
106:                        MailInterceptor interceptor = (MailInterceptor) mailInterceptorClass
107:                                .newInstance();
108:                        setMailInterceptor(interceptor);
109:                    }
110:                } catch (Exception ex) {
111:                    log.error("Cannot load MailInterceptor", ex);
112:                }
113:            }
114:
115:            private void loadLoginIDInterceptor(
116:                    String loginIDInterceptorClassName) {
117:
118:                try {
119:                    if (loginIDInterceptorClassName.length() > 0) {
120:                        Class loginIDInterceptorClass = Class
121:                                .forName(loginIDInterceptorClassName);
122:                        LoginIDInterceptor interceptor = (LoginIDInterceptor) loginIDInterceptorClass
123:                                .newInstance();
124:                        setLoginIDInterceptor(interceptor);
125:                    }
126:                } catch (Exception ex) {
127:                    log.error("Cannot load LoginIDInterceptor", ex);
128:                }
129:            }
130:
131:            private void loadPasswordInterceptor(
132:                    String passwordInterceptorClassName) {
133:
134:                try {
135:                    if (passwordInterceptorClassName.length() > 0) {
136:                        Class passwordInterceptorClass = Class
137:                                .forName(passwordInterceptorClassName);
138:
139:                        PasswordInterceptor interceptor = (PasswordInterceptor) passwordInterceptorClass
140:                                .newInstance();
141:                        setPasswordInterceptor(interceptor);
142:                    }
143:                } catch (Exception ex) {
144:                    log.error("Cannot load PasswordInterceptor", ex);
145:                }
146:            }
147:
148:            /**
149:             * Return singleton instance of this class
150:             *
151:             * @return InterceptorService the singleton instance of this class
152:             */
153:            public static InterceptorService getInstance() {
154:                return instance;
155:            }
156:
157:            /**
158:             * Validate email if the MailInterceptor is present
159:             *
160:             * @param email String email to be validated
161:             * @throws InterceptorException if email is not valid for some reason
162:             */
163:            public void validateMail(String email) throws InterceptorException {
164:                if (mailInterceptor != null) {
165:                    mailInterceptor.validateEmail(email);
166:                }
167:            }
168:
169:            public MailInterceptor getMailInterceptor() {
170:                return mailInterceptor;
171:            }
172:
173:            public void setMailInterceptor(MailInterceptor interceptor) {
174:                log.info("Use MailInterceptor = " + interceptor);
175:                this .mailInterceptor = interceptor;
176:            }
177:
178:            /**
179:             * Validate content if the ContentInterceptor is present
180:             *
181:             * @param content String content to be validated
182:             * @return the new content
183:             * @throws InterceptorException if content is not valid for some reason
184:             */
185:            public String validateContent(String content)
186:                    throws InterceptorException {
187:                if (contentInterceptor != null) {
188:                    return contentInterceptor.validateContent(content);
189:                }
190:                return content;
191:            }
192:
193:            public ContentInterceptor getContentInterceptor() {
194:                return contentInterceptor;
195:            }
196:
197:            public void setContentInterceptor(ContentInterceptor interceptor) {
198:                log.info("Use ContentInterceptor = " + interceptor);
199:                this .contentInterceptor = interceptor;
200:            }
201:
202:            /**
203:             * Validate loginID if the LoginIDInterceptor is present
204:             *
205:             * @param loginID String loginID to be validated
206:             * @throws InterceptorException if loginID is not valid for some reason
207:             */
208:            public void validateLoginID(String loginID)
209:                    throws InterceptorException {
210:                if (loginIDInterceptor != null) {
211:                    loginIDInterceptor.validateLoginID(loginID);
212:                }
213:            }
214:
215:            public LoginIDInterceptor getLoginIDInterceptor() {
216:                return loginIDInterceptor;
217:            }
218:
219:            public void setLoginIDInterceptor(LoginIDInterceptor interceptor) {
220:                log.info("Use LoginIDInterceptor = " + interceptor);
221:                this .loginIDInterceptor = interceptor;
222:            }
223:
224:            /**
225:             * Validate password if the PasswordInterceptor is present
226:             *
227:             * @param password String password to be validated
228:             * @throws InterceptorException if password is not valid for some reason
229:             */
230:            public void validatePassword(String password)
231:                    throws InterceptorException {
232:                if (passwordInterceptor != null) {
233:                    passwordInterceptor.validatePassword(password);
234:                }
235:            }
236:
237:            public PasswordInterceptor getPasswordInterceptor() {
238:                return passwordInterceptor;
239:            }
240:
241:            public void setPasswordInterceptor(PasswordInterceptor interceptor) {
242:                log.info("Use PasswordInterceptor = " + interceptor);
243:                this.passwordInterceptor = interceptor;
244:            }
245:
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.