1 /* |
1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
36 import com.sun.xml.internal.ws.api.message.Packet; |
36 import com.sun.xml.internal.ws.api.message.Packet; |
37 import com.sun.xml.internal.ws.api.model.MEP; |
37 import com.sun.xml.internal.ws.api.model.MEP; |
38 import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation; |
38 import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation; |
39 import com.sun.xml.internal.ws.api.pipe.Tube; |
39 import com.sun.xml.internal.ws.api.pipe.Tube; |
40 import com.sun.xml.internal.ws.api.pipe.Fiber; |
40 import com.sun.xml.internal.ws.api.pipe.Fiber; |
|
41 import com.sun.xml.internal.ws.api.server.Container; |
|
42 import com.sun.xml.internal.ws.api.server.ContainerResolver; |
41 import com.sun.xml.internal.ws.binding.BindingImpl; |
43 import com.sun.xml.internal.ws.binding.BindingImpl; |
42 import com.sun.xml.internal.ws.client.AsyncResponseImpl; |
|
43 import com.sun.xml.internal.ws.client.*; |
44 import com.sun.xml.internal.ws.client.*; |
44 import com.sun.xml.internal.ws.model.JavaMethodImpl; |
45 import com.sun.xml.internal.ws.model.JavaMethodImpl; |
45 import com.sun.xml.internal.ws.model.SOAPSEIModel; |
46 import com.sun.xml.internal.ws.model.SOAPSEIModel; |
46 import com.sun.xml.internal.ws.wsdl.OperationDispatcher; |
47 import com.sun.xml.internal.ws.wsdl.OperationDispatcher; |
47 |
48 |
129 * a {@link MethodHandler} that processes it. |
130 * a {@link MethodHandler} that processes it. |
130 */ |
131 */ |
131 private final Map<Method, MethodHandler> methodHandlers = new HashMap<Method, MethodHandler>(); |
132 private final Map<Method, MethodHandler> methodHandlers = new HashMap<Method, MethodHandler>(); |
132 |
133 |
133 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { |
134 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { |
134 MethodHandler handler = methodHandlers.get(method); |
135 Container old = ContainerResolver.getDefault().enterContainer(owner.getContainer()); |
135 if (handler != null) { |
136 try { |
136 return handler.invoke(proxy, args); |
137 MethodHandler handler = methodHandlers.get(method); |
137 } else { |
138 if (handler != null) { |
138 // we handle the other method invocations by ourselves |
139 return handler.invoke(proxy, args); |
139 try { |
140 } else { |
140 return method.invoke(this, args); |
141 // we handle the other method invocations by ourselves |
141 } catch (IllegalAccessException e) { |
142 try { |
142 // impossible |
143 return method.invoke(this, args); |
143 throw new AssertionError(e); |
144 } catch (IllegalAccessException e) { |
144 } catch (IllegalArgumentException e) { |
145 // impossible |
145 throw new AssertionError(e); |
146 throw new AssertionError(e); |
146 } catch (InvocationTargetException e) { |
147 } catch (IllegalArgumentException e) { |
147 throw e.getCause(); |
148 throw new AssertionError(e); |
|
149 } catch (InvocationTargetException e) { |
|
150 throw e.getCause(); |
|
151 } |
148 } |
152 } |
|
153 } finally { |
|
154 ContainerResolver.getDefault().exitContainer(old); |
149 } |
155 } |
150 } |
156 } |
151 |
157 |
152 public final Packet doProcess(Packet request, RequestContext rc, ResponseContextReceiver receiver) { |
158 public final Packet doProcess(Packet request, RequestContext rc, ResponseContextReceiver receiver) { |
153 return super.process(request, rc, receiver); |
159 return super.process(request, rc, receiver); |