1 package org.apache.axis2.description; 2 3 import org.apache.axis2.context.*; 4 import org.apache.axis2.engine.AxisError; 5 import org.apache.axis2.engine.AxisFault; 6 import org.apache.axis2.engine.MessageReceiver; 7 import org.apache.axis2.engine.Phase; 8 import org.apache.axis2.phaseresolver.PhaseMetadata; 9 import org.apache.axis2.phaseresolver.PhaseResolver; 10 import org.apache.wsdl.WSDLConstants; 11 import org.apache.wsdl.WSDLOperation; 12 import org.apache.wsdl.impl.WSDLOperationImpl; 13 14 import javax.xml.namespace.QName ; 15 import java.util.ArrayList ; 16 import java.util.Collection ; 17 import java.util.Iterator ; 18 19 22 public class OperationDescription extends WSDLOperationImpl implements 23 ParameterInclude, WSDLOperation, DescriptionConstants, 24 WSDLConstants { 25 26 private MessageReceiver messageReceiver; 27 private ArrayList remainingPhasesInFlow; 28 private ArrayList phasesOutFlow; 29 private ArrayList phasesInFaultFlow; 30 private ArrayList phasesOutFaultFlow; 31 32 private int mep = MEP_CONSTANT_INVALID; 33 34 private ArrayList modulerefs; 36 37 public OperationDescription() { 38 this.setMessageExchangePattern(MEP_URI_IN_OUT); 39 this.setComponentProperty(PARAMETER_KEY, new ParameterIncludeImpl()); 40 this.setComponentProperty(MODULEREF_KEY, new ArrayList ()); 41 42 remainingPhasesInFlow = new ArrayList (); 43 remainingPhasesInFlow.add(new Phase(PhaseMetadata.PHASE_POLICY_DETERMINATION)); 44 45 phasesOutFlow = new ArrayList (); 46 phasesOutFlow.add(new Phase(PhaseMetadata.PHASE_POLICY_DETERMINATION)); 47 phasesOutFlow.add(new Phase(PhaseMetadata.PHASE_MESSAGE_OUT)); 48 49 phasesInFaultFlow = new ArrayList (); 50 phasesOutFaultFlow = new ArrayList (); 51 modulerefs = new ArrayList (); 52 } 53 54 public OperationDescription(QName name) { 55 this(); 56 this.setName(name); 57 } 58 59 65 public void engageModule(ModuleDescription moduleref) throws AxisFault { 66 if (moduleref == null) { 67 return; 68 } 69 if (moduleref != null) { 70 Collection collectionModule = (Collection ) this.getComponentProperty(MODULEREF_KEY); 71 for (Iterator iterator = collectionModule.iterator(); iterator.hasNext();) { 72 ModuleDescription modu = (ModuleDescription) iterator.next(); 73 if(modu.getName().equals(moduleref.getName())){ 74 throw new AxisFault(moduleref.getName().getLocalPart()+ " module has alredy engaged to the operation" + 75 " operation terminated !!!"); 76 } 77 78 } 79 } 80 new PhaseResolver().engageModuleToOperation(this, moduleref); 81 Collection collectionModule = (Collection ) this.getComponentProperty(MODULEREF_KEY); 82 collectionModule.add(moduleref); 83 } 84 85 public void addToEngageModuleList(ModuleDescription moduleName){ 86 Collection collectionModule = (Collection ) this.getComponentProperty(MODULEREF_KEY); 87 for (Iterator iterator = collectionModule.iterator(); iterator.hasNext();) { 88 ModuleDescription moduleDescription = (ModuleDescription) iterator.next(); 89 if(moduleName.getName().equals(moduleDescription.getName())){ 90 return; 91 } 92 } 93 collectionModule.add(moduleName); 94 } 95 96 97 98 99 104 105 110 public Collection getModules() { 111 return (Collection ) this.getComponentProperty(MODULEREF_KEY); 112 } 113 114 119 public void addParameter(Parameter param) { 120 if (param == null) { 121 return; 122 } 123 ParameterIncludeImpl paramInclude = (ParameterIncludeImpl) this 124 .getComponentProperty(PARAMETER_KEY); 125 paramInclude.addParameter(param); 126 } 127 128 134 public Parameter getParameter(String name) { 135 ParameterIncludeImpl paramInclude = (ParameterIncludeImpl) this 136 .getComponentProperty(PARAMETER_KEY); 137 return (Parameter) paramInclude.getParameter(name); 138 } 139 140 162 public OperationContext findOperationContext(MessageContext msgContext, 163 ServiceContext serviceContext) throws AxisFault { 164 OperationContext operationContext = null; 165 166 if (null == msgContext.getRelatesTo()) { 167 operationContext = OperationContextFactory.createMEPContext(getAxisSpecifMEPConstant(), this, 170 serviceContext); 171 172 } else { 173 ConfigurationContext configContext = msgContext.getSystemContext(); 176 operationContext = configContext.getOperationContext(msgContext.getRelatesTo().getValue()); 177 178 if (null == operationContext) { 179 throw new AxisFault("Cannot relate the message in the operation :" 180 + this.getName() 181 + " :Unrelated RelatesTO value " 182 + msgContext.getRelatesTo().getValue()); 183 } 184 185 } 186 187 msgContext.getSystemContext().registerOperationContext(msgContext.getMessageID(), operationContext); 188 operationContext.addMessageContext(msgContext); 189 msgContext.setOperationContext(operationContext); 190 if (operationContext.isComplete()) { 191 operationContext.cleanup(); 192 } 193 194 return operationContext; 195 196 } 197 198 public MessageReceiver getMessageReciever() { 199 return messageReceiver; 200 } 201 202 public void setMessageReciever(MessageReceiver messageReceiver) { 203 this.messageReceiver = messageReceiver; 204 } 205 206 207 214 public int getAxisSpecifMEPConstant() { 215 if (this.mep != MEP_CONSTANT_INVALID) { 216 return this.mep; 217 } 218 219 int temp = MEP_CONSTANT_INVALID; 220 221 if (MEP_URI_IN_OUT.equals(getMessageExchangePattern())) { 222 temp = MEP_CONSTANT_IN_OUT; 223 } else if (MEP_URI_IN_ONLY.equals(getMessageExchangePattern())) { 224 temp = MEP_CONSTANT_IN_ONLY; 225 } else if (MEP_URI_IN_OPTIONAL_OUT.equals(getMessageExchangePattern())) { 226 temp = MEP_CONSTANT_IN_OPTIONAL_OUT; 227 } else if (MEP_URI_OUT_IN.equals(getMessageExchangePattern())) { 228 temp = MEP_CONSTANT_OUT_IN; 229 } else if (MEP_URI_OUT_ONLY.equals(getMessageExchangePattern())) { 230 temp = MEP_CONSTANT_OUT_ONLY; 231 } else if (MEP_URI_OUT_OPTIONAL_IN.equals(getMessageExchangePattern())) { 232 temp = MEP_CONSTANT_OUT_OPTIONAL_IN; 233 } else if (MEP_URI_ROBUST_IN_ONLY.equals(getMessageExchangePattern())) { 234 temp = MEP_CONSTANT_ROBUST_IN_ONLY; 235 } else if (MEP_URI_ROBUST_OUT_ONLY.equals(getMessageExchangePattern())) { 236 temp = MEP_CONSTANT_ROBUST_OUT_ONLY; 237 } 238 239 if (temp == MEP_CONSTANT_INVALID) { 240 throw new AxisError("Could not Map the MEP URI to a axis MEP constant value"); 241 } 242 this.mep = temp; 243 return this.mep; 244 245 } 246 247 248 251 public ArrayList getPhasesInFaultFlow() { 252 return phasesInFaultFlow; 253 } 254 255 258 public ArrayList getPhasesOutFaultFlow() { 259 return phasesOutFaultFlow; 260 } 261 262 265 public ArrayList getPhasesOutFlow() { 266 return phasesOutFlow; 267 } 268 269 272 public ArrayList getRemainingPhasesInFlow() { 273 return remainingPhasesInFlow; 274 } 275 276 279 public void setPhasesInFaultFlow(ArrayList list) { 280 phasesInFaultFlow = list; 281 } 282 283 286 public void setPhasesOutFaultFlow(ArrayList list) { 287 phasesOutFaultFlow = list; 288 } 289 290 293 public void setPhasesOutFlow(ArrayList list) { 294 phasesOutFlow = list; 295 } 296 297 300 public void setRemainingPhasesInFlow(ArrayList list) { 301 remainingPhasesInFlow = list; 302 } 303 304 public void addModule(QName moduleName) { 305 modulerefs.add(moduleName); 306 } 307 308 public ArrayList getModuleRefs() { 309 return modulerefs; 310 } 311 312 313 } 314 315 | Popular Tags |