Source Code Cross Referenced for WebServiceContainerInvoker.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » webservices » 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 » EJB Server geronimo » plugins » org.apache.geronimo.webservices 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */package org.apache.geronimo.webservices;
017:
018:        import java.io.IOException;
019:        import java.io.InputStream;
020:        import java.io.OutputStream;
021:        import java.net.URISyntaxException;
022:        import java.util.HashMap;
023:        import java.util.Map;
024:        import javax.servlet.Servlet;
025:        import javax.servlet.ServletConfig;
026:        import javax.servlet.ServletContext;
027:        import javax.servlet.ServletException;
028:        import javax.servlet.ServletRequest;
029:        import javax.servlet.ServletResponse;
030:        import javax.servlet.http.HttpServletRequest;
031:        import javax.servlet.http.HttpServletResponse;
032:
033:        /**
034:         * @version $Rev: 550523 $ $Date: 2007-06-25 08:02:09 -0700 (Mon, 25 Jun 2007) $
035:         */
036:        public class WebServiceContainerInvoker implements  Servlet {
037:
038:            public static final String WEBSERVICE_CONTAINER = WebServiceContainerInvoker.class
039:                    .getName()
040:                    + "@WebServiceContainer";
041:
042:            private final Object pojo;
043:            private WebServiceContainer service;
044:            private ServletConfig config;
045:
046:            public WebServiceContainerInvoker(Object pojo) {
047:                this .pojo = pojo;
048:            }
049:
050:            public void init(ServletConfig config) throws ServletException {
051:                this .config = config;
052:                ServletContext context = config.getServletContext();
053:                String webServiceContainerID = config
054:                        .getInitParameter(WEBSERVICE_CONTAINER);
055:                service = (WebServiceContainer) context
056:                        .getAttribute(webServiceContainerID);
057:            }
058:
059:            public ServletConfig getServletConfig() {
060:                return config;
061:            }
062:
063:            public void service(ServletRequest req, ServletResponse res)
064:                    throws ServletException, IOException {
065:                res.setContentType("text/xml");
066:                RequestAdapter request = new RequestAdapter(
067:                        (HttpServletRequest) req);
068:                ResponseAdapter response = new ResponseAdapter(
069:                        (HttpServletResponse) res);
070:
071:                // This is the guy the WebServiceContainer should invoke
072:                req.setAttribute(WebServiceContainer.POJO_INSTANCE, pojo);
073:
074:                req.setAttribute(WebServiceContainer.SERVLET_REQUEST,
075:                        (HttpServletRequest) req);
076:                req.setAttribute(WebServiceContainer.SERVLET_RESPONSE,
077:                        (HttpServletResponse) res);
078:                req.setAttribute(WebServiceContainer.SERVLET_CONTEXT, config
079:                        .getServletContext());
080:
081:                if (req.getParameter("wsdl") != null
082:                        || req.getParameter("WSDL") != null) {
083:                    try {
084:                        service.getWsdl(request, response);
085:                    } catch (IOException e) {
086:                        throw e;
087:                    } catch (ServletException e) {
088:                        throw e;
089:                    } catch (Exception e) {
090:                        throw new ServletException("Could not fetch wsdl!", e);
091:                    }
092:                } else {
093:                    try {
094:                        service.invoke(request, response);
095:                    } catch (IOException e) {
096:                        throw e;
097:                    } catch (ServletException e) {
098:                        throw e;
099:                    } catch (Exception e) {
100:                        throw new ServletException(
101:                                "Could not process message!", e);
102:                    }
103:                }
104:            }
105:
106:            public String getServletInfo() {
107:                return null;
108:            }
109:
110:            public void destroy() {
111:                service.destroy();
112:            }
113:
114:            private static class RequestAdapter implements 
115:                    WebServiceContainer.Request {
116:                private final HttpServletRequest request;
117:
118:                public RequestAdapter(HttpServletRequest request) {
119:                    this .request = request;
120:                }
121:
122:                public String getHeader(String name) {
123:                    return request.getHeader(name);
124:                }
125:
126:                public java.net.URI getURI() {
127:                    try {
128:                        return new java.net.URI(request.getScheme(), null,
129:                                request.getServerName(), request
130:                                        .getServerPort(), request
131:                                        .getRequestURI(), request
132:                                        .getQueryString(), null);
133:                    } catch (URISyntaxException e) {
134:                        throw new IllegalStateException(e.getMessage(), e);
135:                    }
136:                }
137:
138:                public int getContentLength() {
139:                    return request.getContentLength();
140:                }
141:
142:                public String getContentType() {
143:                    return request.getContentType();
144:                }
145:
146:                public String getContextPath() {
147:                    return request.getContextPath();
148:                }
149:
150:                public InputStream getInputStream() throws IOException {
151:                    return request.getInputStream();
152:                }
153:
154:                public int getMethod() {
155:                    Integer method = (Integer) methods.get(request.getMethod());
156:                    return method == null ? UNSUPPORTED : method.intValue();
157:                }
158:
159:                public String getParameter(String name) {
160:                    return request.getParameter(name);
161:                }
162:
163:                public Map getParameters() {
164:                    return request.getParameterMap();
165:                }
166:
167:                private static final Map methods = new HashMap();
168:
169:                static {
170:                    methods.put("OPTIONS", new Integer(OPTIONS));
171:                    methods.put("GET", new Integer(GET));
172:                    methods.put("HEAD", new Integer(HEAD));
173:                    methods.put("POST", new Integer(POST));
174:                    methods.put("PUT", new Integer(PUT));
175:                    methods.put("DELETE", new Integer(DELETE));
176:                    methods.put("TRACE", new Integer(TRACE));
177:                    methods.put("CONNECT", new Integer(CONNECT));
178:                }
179:
180:                public Object getAttribute(String s) {
181:                    return request.getAttribute(s);
182:                }
183:
184:                public void setAttribute(String s, Object o) {
185:                    request.setAttribute(s, o);
186:                }
187:
188:                public String getRemoteAddr() {
189:                    return request.getRemoteAddr();
190:                }
191:
192:            }
193:
194:            private static class ResponseAdapter implements 
195:                    WebServiceContainer.Response {
196:                private final HttpServletResponse response;
197:
198:                public ResponseAdapter(HttpServletResponse response) {
199:                    this .response = response;
200:                }
201:
202:                public void setHeader(String name, String value) {
203:                    response.setHeader(name, value);
204:                }
205:
206:                public String getHeader(String name) {
207:                    throw new UnsupportedOperationException(
208:                            "Not possible to implement");
209:                }
210:
211:                public OutputStream getOutputStream() {
212:                    try {
213:                        return response.getOutputStream();
214:                    } catch (IOException e) {
215:                        throw (IllegalStateException) new IllegalStateException()
216:                                .initCause(e);
217:                    }
218:                }
219:
220:                public void setStatusCode(int code) {
221:                    response.setStatus(code);
222:                }
223:
224:                public int getStatusCode() {
225:                    throw new UnsupportedOperationException(
226:                            "Not possible to implement");
227:                }
228:
229:                public void setContentType(String type) {
230:                    response.setContentType(type);
231:                }
232:
233:                public String getContentType() {
234:                    return response.getContentType();
235:                }
236:
237:                public void setStatusMessage(String responseString) {
238:                    response.setStatus(getStatusCode(), responseString);
239:                }
240:
241:                public void flushBuffer() throws java.io.IOException {
242:                    response.flushBuffer();
243:                }
244:            }
245:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.