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;
20:
21: import org.apache.axis2.Constants;
22: import org.apache.axis2.jaxws.core.MessageContext;
23: import org.apache.axis2.jaxws.handler.MEPContext;
24: import org.apache.axis2.jaxws.spi.migrator.ApplicationContextMigrator;
25: import org.apache.commons.logging.Log;
26: import org.apache.commons.logging.LogFactory;
27:
28: import java.util.Map;
29:
30: /**
31: * The PropertyMigrator implements the ApplicationContextMigrator in order to perform the necessary
32: * manipulations of properties during a request or response flow.
33: */
34: public class PropertyMigrator implements ApplicationContextMigrator {
35: private static final Log log = LogFactory
36: .getLog(PropertyMigrator.class);
37:
38: public void migratePropertiesFromMessageContext(
39: Map<String, Object> userContext,
40: MessageContext messageContext) {
41:
42: if (log.isDebugEnabled()) {
43: log.debug("Starting migratePropertyFromMessageContext");
44: }
45: MEPContext mepContext = messageContext.getMEPContext();
46: if (mepContext != null) {
47: if (log.isDebugEnabled()) {
48: log
49: .debug("Reading ApplicationScopedProperties from MEPContext");
50: }
51: userContext.putAll(mepContext
52: .getApplicationScopedProperties());
53: }
54: if (log.isDebugEnabled()) {
55: log.debug("migratePropertyFromMessageContext Complete");
56: }
57: }
58:
59: public void migratePropertiesToMessageContext(
60: Map<String, Object> userContext,
61: MessageContext messageContext) {
62:
63: // Avoid using putAll as this causes copies of the propery set
64: if (userContext != null) {
65: for (String key : userContext.keySet()) {
66: Object value = userContext.get(key);
67: // Make sure mtom state in the user context, the message context,
68: // the MEP context are the same.
69: if (key
70: .equalsIgnoreCase(Constants.Configuration.ENABLE_MTOM)) {
71: value = messageContext.getMessage().isMTOMEnabled();
72: messageContext.getMEPContext().put(key, value);
73: }
74: messageContext.setProperty(key, value);
75: }
76: }
77: }
78:
79: }
|