01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.axis2.jaxws.client.async;
20:
21: import org.apache.axis2.client.async.AsyncResult;
22: import org.apache.axis2.jaxws.ExceptionFactory;
23: import org.apache.axis2.jaxws.core.MessageContext;
24: import org.apache.axis2.jaxws.util.Constants;
25: import org.apache.axis2.util.ThreadContextMigratorUtil;
26: import org.apache.commons.logging.Log;
27: import org.apache.commons.logging.LogFactory;
28:
29: import javax.xml.ws.WebServiceException;
30:
31: public class AsyncUtils {
32:
33: private static final Log log = LogFactory.getLog(AsyncUtils.class);
34: private static final boolean debug = log.isDebugEnabled();
35:
36: public static MessageContext createJAXWSMessageContext(
37: AsyncResult result) throws WebServiceException {
38: return AsyncUtils.createJAXWSMessageContext(result
39: .getResponseMessageContext());
40: }
41:
42: public static MessageContext createJAXWSMessageContext(
43: org.apache.axis2.context.MessageContext mc)
44: throws WebServiceException {
45: MessageContext response = null;
46:
47: if (debug) {
48: log.debug("Creating response MessageContext");
49: }
50:
51: // Create the JAX-WS response MessageContext from the Axis2 response
52: response = new MessageContext(mc);
53: // don't set the response.setMEPContext() here.
54:
55: // REVIEW: Are we on the final thread of execution here or does this get handed off to the executor?
56: // TODO: Remove workaround for WS-Addressing running in thin client (non-server) environment
57: try {
58: ThreadContextMigratorUtil.performMigrationToThread(
59: Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID, mc);
60: } catch (Throwable t) {
61: if (debug) {
62: log
63: .debug(mc.getLogIDString()
64: + " An error occurred in the ThreadContextMigratorUtil "
65: + t);
66: log.debug("...caused by " + t.getCause());
67: }
68: throw ExceptionFactory.makeWebServiceException(t);
69: }
70:
71: return response;
72: }
73: }
|