Source Code Cross Referenced for InterceptorInfo.java in  » Portal » stringbeans-3.5 » com » nabhinc » ws » server » 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 » Portal » stringbeans 3.5 » com.nabhinc.ws.server 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * (C) Copyright 2000 - 2005 Nabh Information Systems, Inc.
003:         *
004:         * This program is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU General Public License 
006:         * as published by the Free Software Foundation; either version 2
007:         * of the License, or (at your option) any later version.
008:         * 
009:         * This program is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of 
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
012:         * GNU General Public License for more details.
013:         * 
014:         * You should have received a copy of the GNU General Public License
015:         * along with this program; if not, write to the Free Software 
016:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:         * 
018:         */
019:
020:        package com.nabhinc.ws.server;
021:
022:        import java.io.IOException;
023:        import java.io.Writer;
024:
025:        import javax.servlet.ServletException;
026:
027:        import org.w3c.dom.Element;
028:
029:        import com.nabhinc.util.XMLUtil;
030:        import com.nabhinc.ws.core.PropertyInfo;
031:        import com.nabhinc.ws.core.WebServiceException;
032:        import com.nabhinc.ws.core.WebServiceUtil;
033:
034:        /**
035:         * This class maintains all configuration information related to an
036:         * interceptor. In addition it takes care of managing interceptor life-cycle.
037:         * 
038:         * @author Padmanabh Dabke
039:         * (c) 2005 Nabh Information Systems, Inc. All Rights Reserved.
040:         */
041:        public class InterceptorInfo {
042:
043:            // Configuration Attributes
044:
045:            /**
046:             * Interceptor name
047:             */
048:            public String name = null;
049:
050:            /**
051:             * Interceptor display name
052:             */
053:            public String displayName = null;
054:
055:            /**
056:             * Interceptor class
057:             */
058:            public String interceptorClass = null;
059:
060:            /**
061:             * Interceptor description
062:             */
063:            public String description = null;
064:
065:            /**
066:             * Interceptor properties
067:             */
068:            public PropertyInfo[] propertiesInfo = null;
069:
070:            /**
071:             * Flag indicating if the interceptor is critical to
072:             * the Web service invocation. If an interceptor is marked
073:             * critical, the service invocation will fail if the interceptor
074:             * throws an exception. 
075:             */
076:            public boolean isCritical = false;
077:
078:            /**
079:             * Flag indicating if this interceptor should be automatically
080:             * loaded.
081:             */
082:            public boolean manualLoad = false;
083:
084:            /**
085:             * "Run-as" this user.
086:             */
087:            public String owner = null;
088:
089:            // Computed attributes
090:
091:            /**
092:             * Server context
093:             */
094:            public WebServiceContext webServiceContext = null;
095:
096:            /**
097:             * Interceptor load status
098:             */
099:            public int status = WebServiceServerConstants.LOAD_STATUS_UNLOADED;
100:
101:            /**
102:             * Error encountered during interceptor loading/invocation
103:             */
104:            public Throwable loadError = null;
105:
106:            /**
107:             * Time at which the interceptor was loaded/started.
108:             */
109:            public long startTime = 0;
110:
111:            /**
112:             * Interceptor instance. Non-null if loaded.
113:             */
114:            public Interceptor interceptor = null;
115:
116:            public void init(Element config, WebServiceContext wsContext)
117:                    throws WebServiceException {
118:                webServiceContext = wsContext;
119:                name = XMLUtil.getSubElementText(config, "name");
120:                displayName = XMLUtil.getSubElementText(config, "display-name");
121:                interceptorClass = XMLUtil.getSubElementText(config, "class");
122:                description = XMLUtil.getSubElementText(config, "description");
123:                owner = XMLUtil.getSubElementText(config, "owner");
124:                try {
125:                    propertiesInfo = WebServiceUtil
126:                            .deserializePropertiesInfo(config);
127:                } catch (Exception ex) {
128:                    throw new WebServiceException(
129:                            "Failed to deserialize web services properties.",
130:                            ex);
131:                }
132:                isCritical = XMLUtil.getSubElement(config, "critical") != null;
133:                manualLoad = XMLUtil.getSubElement(config, "manual-load") != null;
134:
135:                if (name == null)
136:                    throw new WebServiceException("Missing interceptor name.");
137:                if (interceptorClass == null)
138:                    throw new WebServiceException(
139:                            "Missing class name for interceptor " + name + ".");
140:            }
141:
142:            /**
143:             * Constructs an XML representation of the interceptor configuratin and
144:             * writes it to the provided writer
145:             * @param indent Base indent for formatting the XML
146:             * @param delta Increment added to go to the next indent level
147:             * @param w Writer to which the serialized config is written
148:             * @throws IOException
149:             */
150:            public void serialize(String indent, String delta, Writer w)
151:                    throws IOException {
152:                XMLUtil.writeElementStart(indent, "interceptor", w);
153:                String indent1 = indent + delta;
154:                XMLUtil.writeElement(indent1, "name", name, w);
155:                XMLUtil.writeElement(indent1, "class", interceptorClass, w);
156:                XMLUtil.writeElement(indent1, "display-name", displayName, w);
157:                XMLUtil.writeElement(indent1, "description", description, w);
158:                XMLUtil.writeElement(indent1, "owner", owner, w);
159:                if (isCritical)
160:                    XMLUtil.writeEmptyElement(indent1, "critical", w);
161:                if (manualLoad)
162:                    XMLUtil.writeEmptyElement(indent1, "manual-load", w);
163:                WebServiceUtil.serializePropertiesInfo(propertiesInfo, indent1,
164:                        delta, w);
165:                XMLUtil.writeElementEnd(indent, "interceptor", w);
166:            }
167:
168:            /**
169:             * Stores the new interceptor properties. If the interceptor is running,
170:             * it attempts to set the properties on the running instance.
171:             * @param newProps New interceptor properties
172:             * @throws ServletException
173:             */
174:            public void setPropertiesInfo(PropertyInfo[] newProps)
175:                    throws WebServiceException {
176:                if (interceptor != null) {
177:                    interceptor.setProperties(newProps);
178:                }
179:                propertiesInfo = newProps;
180:
181:            }
182:
183:            /**
184:             * Attempts to load the interceptor if it is not already loaded.
185:             * @throws ServletException Interceptor loading exception
186:             */
187:            public void load() throws WebServiceException {
188:
189:                // If interceptor is not null, assume that it is successfully
190:                // loaded. Just return;
191:                if (interceptor != null)
192:                    return;
193:
194:                try {
195:                    // Set the status to error here. If things go smoothly, it will be
196:                    // set to loaded at the end of the try block.
197:                    status = WebServiceServerConstants.LOAD_STATUS_INIT_ERROR;
198:                    Interceptor intc = (Interceptor) Class.forName(
199:                            interceptorClass).newInstance();
200:                    intc.init(new ServerObjectConfigImpl(webServiceContext,
201:                            propertiesInfo));
202:                    interceptor = intc;
203:                    status = WebServiceServerConstants.LOAD_STATUS_LOADED;
204:                    loadError = null;
205:                    startTime = System.currentTimeMillis();
206:                } catch (ClassNotFoundException ex) {
207:                    loadError = ex;
208:                    throw new WebServiceException("Invalid class "
209:                            + interceptorClass + " for interceptor " + name
210:                            + ".", ex);
211:                } catch (InstantiationException ex) {
212:                    loadError = ex;
213:                    throw new WebServiceException(
214:                            "Instantiation error in creating instance of class "
215:                                    + interceptorClass + " for interceptor "
216:                                    + name + ".", ex);
217:                } catch (ClassCastException ex) {
218:                    loadError = ex;
219:                    throw new WebServiceException(
220:                            "Class must implement WebServiceInterceptor interface.",
221:                            ex);
222:                } catch (IllegalAccessException ex) {
223:                    loadError = ex;
224:                    throw new WebServiceException(
225:                            "Illegal access error in creating instance of class "
226:                                    + interceptorClass + " for Web service "
227:                                    + name + ".", ex);
228:                } catch (Exception ex) {
229:                    loadError = ex;
230:                    throw new WebServiceException(
231:                            "Failed to create interceptor " + name + ".", ex);
232:                }
233:            }
234:
235:            /**
236:             * Unload the interceptor and load again.
237:             * @throws ServletException
238:             */
239:            public void reload() throws WebServiceException {
240:                unload();
241:                load();
242:            }
243:
244:            /**
245:             * Destroys the interceptor if running and resets load state.
246:             *
247:             */
248:            public void unload() {
249:                if (interceptor != null) {
250:                    status = WebServiceServerConstants.LOAD_STATUS_UNLOADED;
251:                    interceptor.destroy();
252:                    interceptor = null;
253:                }
254:
255:            }
256:
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.