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.description;
20:
21: import org.apache.axiom.om.util.UUIDGenerator;
22: import org.apache.axis2.AxisFault;
23: import org.apache.axis2.context.MessageContext;
24: import org.apache.axis2.context.OperationContext;
25: import org.apache.axis2.i18n.Messages;
26:
27: import javax.xml.namespace.QName;
28: import java.util.HashMap;
29:
30: public class InOutAxisOperation extends TwoChannelAxisOperation {
31:
32: public InOutAxisOperation() {
33: super ();
34: //setup a temporary name
35: QName tmpName = new QName(this .getClass().getName() + "_"
36: + UUIDGenerator.getUUID());
37: this .setName(tmpName);
38: }
39:
40: public InOutAxisOperation(QName name) {
41: super (name);
42: }
43:
44: public void addMessageContext(MessageContext msgContext,
45: OperationContext opContext) throws AxisFault {
46: HashMap mep = opContext.getMessageContexts();
47: MessageContext inMsgContext = (MessageContext) mep
48: .get(MESSAGE_LABEL_IN_VALUE);
49: MessageContext outmsgContext = (MessageContext) mep
50: .get(MESSAGE_LABEL_OUT_VALUE);
51:
52: if ((inMsgContext != null) && (outmsgContext != null)) {
53: throw new AxisFault(Messages.getMessage("mepcompleted"));
54: }
55:
56: if (inMsgContext == null) {
57: mep.put(MESSAGE_LABEL_IN_VALUE, msgContext);
58: } else {
59: mep.put(MESSAGE_LABEL_OUT_VALUE, msgContext);
60: opContext.setComplete(true);
61: opContext.cleanup();
62: }
63: }
64: }
|