1 package org.apache.axis2.context; 2 3 18 19 import org.apache.axis2.description.OperationDescription; 20 import org.apache.axis2.engine.AxisError; 21 import org.apache.axis2.engine.AxisFault; 22 import org.apache.wsdl.WSDLConstants; 23 24 import java.util.Map ; 25 26 40 public class OperationContext extends AbstractContext { 41 private MessageContext inMessageContext; 43 44 private MessageContext outMessageContext; 45 46 private OperationDescription axisOperation; 49 50 private int operationMEP; 51 52 private boolean isComplete = false; 53 54 private Map operationContextMap; 57 58 66 public OperationContext(OperationDescription axisOperation, 67 ServiceContext serviceContext) { 68 super(serviceContext); 69 this.axisOperation = axisOperation; 70 this.operationMEP = axisOperation.getAxisSpecifMEPConstant(); 71 this.operationContextMap = getServiceContext().getEngineContext() 72 .getOperationContextMap(); 73 } 74 75 78 public OperationDescription getAxisOperation() { 79 return axisOperation; 80 } 81 82 87 public ServiceContext getServiceContext() { 88 return (ServiceContext) parent; 89 } 90 91 96 public ConfigurationContext getEngineContext() { 97 return (ConfigurationContext) parent.parent; 98 } 99 100 108 public synchronized void addMessageContext(MessageContext msgContext) throws AxisFault { 109 if (WSDLConstants.MEP_CONSTANT_IN_OUT == operationMEP 113 || WSDLConstants.MEP_CONSTANT_IN_OPTIONAL_OUT == operationMEP 114 || WSDLConstants.MEP_CONSTANT_ROBUST_IN_ONLY == operationMEP) { 115 if (inMessageContext == null) { 116 inMessageContext = msgContext; 117 } else { 118 outMessageContext = msgContext; 119 isComplete = true; 120 } 121 } else if (WSDLConstants.MEP_CONSTANT_IN_ONLY == operationMEP) { 122 inMessageContext = msgContext; 123 isComplete = true; 124 } else if (WSDLConstants.MEP_CONSTANT_OUT_ONLY == operationMEP) { 125 outMessageContext = msgContext; 126 isComplete = true; 127 } else if (WSDLConstants.MEP_CONSTANT_OUT_IN == operationMEP 128 || WSDLConstants.MEP_CONSTANT_OUT_OPTIONAL_IN == operationMEP 129 || WSDLConstants.MEP_CONSTANT_ROBUST_IN_ONLY == operationMEP) { 130 if (outMessageContext == null) { 131 outMessageContext = msgContext; 132 } else { 133 inMessageContext = msgContext; 134 isComplete = true; 135 } 136 } else { 137 throw new AxisError("Invalid behavior of OperationContextFactory"); 139 } 140 } 141 142 147 public MessageContext getMessageContext(int messageLabel) throws AxisFault { 148 if (messageLabel == WSDLConstants.MESSAGE_LABEL_IN) { 149 return inMessageContext; 150 } else if (messageLabel == WSDLConstants.MESSAGE_LABEL_OUT) { 151 return outMessageContext; 152 } else { 153 throw new AxisFault("Unrecognized message label: '" + messageLabel 154 + "'"); 155 } 156 } 157 158 164 public boolean isComplete() { 165 return isComplete; 166 } 167 168 178 public void cleanup() { 179 if (null != this.inMessageContext) { 180 operationContextMap.remove(inMessageContext.getMessageID()); 181 } 182 if (null != this.outMessageContext) { 183 operationContextMap.remove(outMessageContext.getMessageID()); 184 } 185 } 186 187 188 192 } | Popular Tags |