Source Code Cross Referenced for EndpointIFInvocationHandler.java in  » 6.0-JDK-Modules-com.sun » xml » com » sun » xml » internal » ws » client » 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 » 6.0 JDK Modules com.sun » xml » com.sun.xml.internal.ws.client 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Portions Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:        package com.sun.xml.internal.ws.client;
026:
027:        import com.sun.xml.internal.ws.pept.ept.MessageInfo;
028:        import com.sun.xml.internal.ws.pept.presentation.MessageStruct;
029:        import com.sun.xml.internal.ws.encoding.soap.internal.DelegateBase;
030:        import com.sun.xml.internal.ws.model.JavaMethod;
031:        import com.sun.xml.internal.ws.server.RuntimeContext;
032:        import com.sun.xml.internal.ws.wsdl.WSDLContext;
033:        import com.sun.xml.internal.ws.wsdl.parser.PortType;
034:
035:        import javax.xml.namespace.QName;
036:        import javax.xml.ws.AsyncHandler;
037:        import javax.xml.ws.BindingProvider;
038:        import javax.xml.ws.WebServiceException;
039:        import javax.xml.ws.Service;
040:        import java.lang.reflect.InvocationHandler;
041:        import java.lang.reflect.InvocationTargetException;
042:        import java.lang.reflect.Method;
043:        import java.net.URL;
044:        import java.util.concurrent.Executor;
045:
046:        public class EndpointIFInvocationHandler extends EndpointIFBase
047:                implements  InvocationHandler,
048:                com.sun.xml.internal.ws.client.BindingProviderProperties {
049:
050:            Object _proxy;
051:            DelegateBase _delegate;
052:
053:            EndpointIFContext _endpointContext;
054:
055:            Class _portInterface;
056:            QName _serviceQName;
057:
058:            RuntimeContext _rtcontext;
059:            WSDLContext _wsdlContext;
060:            boolean failure;
061:            URL wsdlDocumentLocation;
062:            WSServiceDelegate _service;
063:
064:            /**
065:             * public constructor
066:             */
067:
068:            public EndpointIFInvocationHandler(Class portInterface,
069:                    EndpointIFContext eif, WSServiceDelegate service,
070:                    QName serviceName) {
071:
072:                if ((eif.getBindingID() == null)
073:                        || (eif.getRuntimeContext() == null)) {
074:                    failure = true;
075:                    return;
076:                }
077:                _endpointContext = eif;
078:                _portInterface = portInterface;
079:                _rtcontext = eif.getRuntimeContext();
080:                _bindingId = eif.getBindingID();
081:                _service = service;
082:
083:                if (serviceName != null) {
084:                    if (eif.contains(serviceName))
085:                        _serviceQName = serviceName;
086:                    else
087:                        throw new WebServiceException("Supplied service QName "
088:                                + serviceName + " does not exist in this wsdl.");
089:                } else
090:                    _serviceQName = eif.getServiceName();
091:
092:                if (eif.getEndpointAddress() != null) //temp workaround for local transport kw
093:                    getRequestContext().put(
094:                            BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
095:                            eif.getEndpointAddress());
096:
097:                ContactInfoListImpl cil = new ContactInfoListImpl();
098:                //not sure I need this service argument
099:                _delegate = new DelegateBase(cil, service);
100:            }
101:
102:            public void setModel(RuntimeContext rtcontext) {
103:                _rtcontext = rtcontext;
104:            }
105:
106:            public void setProxy(Object p) {
107:                _proxy = p;
108:            }
109:
110:            public Object invoke(Object proxy, Method method, Object[] args)
111:                    throws WebServiceException, Throwable {
112:
113:                try {
114:                    if (isSEIMethod(method, _portInterface)) {
115:                        return implementSEIMethod(method, args);
116:                    } else {
117:                        return method.invoke(this , args);
118:                    }
119:                } catch (InvocationTargetException e) {
120:                    throw e.getCause();
121:                }
122:            }
123:
124:            /**
125:             * Gets a new {@link com.sun.xml.internal.ws.pept.presentation.MessageStruct} from the Delegate, copies
126:             * the data and metadata into the newly created MessageStruct, invokes Delegate.send, and
127:             * returns the response.
128:             */
129:            public Object implementSEIMethod(Method method, Object[] parameters)
130:                    throws Throwable {
131:
132:                MessageStruct messageStruct = _delegate.getMessageStruct();
133:                int mmep = 0;
134:                if (_rtcontext != null) {
135:                    JavaMethod jmethod = _rtcontext.getModel().getJavaMethod(
136:                            method);
137:                    if (jmethod != null) {
138:                        int mep = jmethod.getMEP();
139:                        mmep = (mep == MessageStruct.REQUEST_RESPONSE_MEP) ? MessageStruct.REQUEST_RESPONSE_MEP
140:                                : (mep == MessageStruct.ONE_WAY_MEP) ? MessageStruct.ONE_WAY_MEP
141:                                        : ((mep == MessageStruct.ASYNC_POLL_MEP) ? MessageStruct.ASYNC_POLL_MEP
142:                                                : MessageStruct.ASYNC_CALLBACK_MEP);
143:                    } else
144:                        throw new WebServiceException(
145:                                "runtime model information for java Method "
146:                                        + method.getName() + " is not known .");
147:                } //need to check if this is dispatch invocation
148:
149:                if (mmep == MessageStruct.ASYNC_CALLBACK_MEP) {
150:                    for (Object param : parameters) {
151:                        if (param != null
152:                                && AsyncHandler.class.isAssignableFrom(param
153:                                        .getClass())) {
154:                            //messageStruct.setMetaData(BindingProviderProperties.JAXWS_CLIENT_ASYNC_HANDLER, param);
155:                            messageStruct
156:                                    .setMetaData(
157:                                            BindingProviderProperties.JAXWS_CLIENT_ASYNC_HANDLER,
158:                                            new AsyncHandlerService(
159:                                                    (AsyncHandler) param,
160:                                                    getCurrentExecutor()));
161:                        }
162:                    }
163:                }
164:
165:                messageStruct.setMethod(method);
166:                messageStruct.setData(parameters);
167:                RequestContext requestContext = (RequestContext) (java.util.Map) ((BindingProvider) _proxy)
168:                        .getRequestContext();
169:                requestContext.put(JAXWS_CLIENT_HANDLE_PROPERTY, _proxy);
170:                messageStruct.setMetaData(JAXWS_RUNTIME_CONTEXT, _rtcontext);
171:                messageStruct.setMetaData(JAXWS_CONTEXT_PROPERTY,
172:                        requestContext);
173:
174:                //set mtom threshold value to
175:                Object mtomThreshold = requestContext
176:                        .get(MTOM_THRESHOLOD_VALUE);
177:                messageStruct.setMetaData(MTOM_THRESHOLOD_VALUE, mtomThreshold);
178:
179:                messageStruct.setMEP(mmep);
180:
181:                // Initialize content negotiation property
182:                ContentNegotiation.initialize(requestContext, messageStruct);
183:
184:                // Set MTOM processing for XML requests only
185:                if (_rtcontext != null && _rtcontext.getModel() != null) {
186:                    javax.xml.ws.soap.SOAPBinding sb = (binding instanceof  javax.xml.ws.soap.SOAPBinding) ? (javax.xml.ws.soap.SOAPBinding) binding
187:                            : null;
188:                    if (sb != null) {
189:                        _rtcontext.getModel().enableMtom(sb.isMTOMEnabled());
190:                    }
191:                }
192:
193:                _delegate.send(messageStruct);
194:                updateResponseContext((MessageInfo) messageStruct);
195:                switch (messageStruct.getResponseType()) {
196:                case MessageStruct.NORMAL_RESPONSE:
197:                    break;
198:                case MessageStruct.CHECKED_EXCEPTION_RESPONSE:
199:                    if (_rtcontext.getModel().isCheckedException(method,
200:                            messageStruct.getResponse().getClass()))
201:                        throw (Throwable) messageStruct.getResponse();
202:                    throw (Exception) messageStruct.getResponse();
203:                case MessageStruct.UNCHECKED_EXCEPTION_RESPONSE:
204:                    throw (RuntimeException) messageStruct.getResponse();
205:                }
206:                return messageStruct.getResponse();
207:            }
208:
209:            boolean isSEIMethod(Method method, Class sei) {
210:                return (sei.equals(method.getDeclaringClass())) ? true : false;
211:            }
212:
213:            public EndpointIFContext getEndpointContext() {
214:                return _endpointContext;
215:            }
216:
217:            public QName getServiceQName() {
218:                return _serviceQName;
219:            }
220:
221:            public Class getPortInterface() {
222:                return _portInterface;
223:            }
224:
225:            Executor getCurrentExecutor() {
226:                return _service.getExecutor();
227:            }
228:
229:            public QName getWSDLPortTypeQName() {
230:                return _service.getWSDLBinding(_endpointContext.getPortName())
231:                        .getPortTypeName();
232:            }
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.