1 16 package org.apache.axis2.engine; 17 18 import org.apache.axis2.deployment.DeploymentEngine; 19 import org.apache.axis2.deployment.repository.util.ArchiveReader; 20 import org.apache.axis2.description.*; 21 import org.apache.axis2.phaseresolver.PhaseMetadata; 22 import org.apache.axis2.phaseresolver.PhaseResolver; 23 24 import javax.xml.namespace.QName ; 25 import java.io.File ; 26 import java.util.*; 27 28 31 public class AxisConfigurationImpl implements AxisConfiguration { 32 35 private Hashtable errornesServices; 36 37 private Hashtable errornesModules; 38 39 42 private final HashMap modules = new HashMap(); 43 44 47 private final HashMap services = new HashMap(); 48 49 50 51 private final HashMap transportsIn = new HashMap(); 52 53 private final HashMap transportsOut = new HashMap(); 54 55 58 private ArrayList inPhases; 59 private ArrayList outPhases; 60 private ArrayList inFaultPhases; 61 private ArrayList outFaultPhases; 62 63 private ArrayList inPhasesUptoAndIncludingPostDispatch; 64 65 66 67 71 protected final ParameterInclude paramInclude; 72 73 76 protected final List engagedModules; 77 78 protected HashMap messagRecievers; 79 83 public AxisConfigurationImpl() { 84 paramInclude = new ParameterIncludeImpl(); 85 engagedModules = new ArrayList(); 86 messagRecievers = new HashMap(); 87 88 inPhases = new ArrayList(); 89 outPhases = new ArrayList(); 90 inFaultPhases = new ArrayList(); 91 outFaultPhases = new ArrayList(); 92 errornesServices = new Hashtable(); 93 errornesModules = new Hashtable(); 94 95 inPhasesUptoAndIncludingPostDispatch = new ArrayList(); 96 inPhasesUptoAndIncludingPostDispatch.add(new Phase(PhaseMetadata.PHASE_TRANSPORTIN)); 97 inPhasesUptoAndIncludingPostDispatch.add(new Phase(PhaseMetadata.PHASE_PRE_DISPATCH)); 98 99 Phase dispatch = new Phase(PhaseMetadata.PHASE_DISPATCH); 100 dispatch.addHandler(new AddressingBasedDispatcher(), 0); 101 dispatch.addHandler(new RequestURIBasedDispatcher(), 1); 102 dispatch.addHandler(new SOAPActionBasedDispatcher(), 2); 103 dispatch.addHandler(new SOAPMessageBodyBasedDispatcher(),3); 104 inPhasesUptoAndIncludingPostDispatch.add(dispatch); 105 106 Phase postDispatch = new Phase(PhaseMetadata.PHASE_POST_DISPATCH); 107 postDispatch.addHandler(new DispatchPostConditionsEvaluator()); 108 inPhasesUptoAndIncludingPostDispatch.add(postDispatch); 109 } 110 111 116 public HashMap getServices() { 117 return services; 118 } 119 120 public Hashtable getFaulytServices() { 121 return errornesServices; 122 } 123 124 public Hashtable getFaulytModules() { 125 return errornesModules; 126 } 127 128 134 public synchronized void addMdoule(ModuleDescription module) throws AxisFault { 135 modules.put(module.getName(), module); 136 } 137 138 144 public synchronized void addService(ServiceDescription service) throws AxisFault { 145 services.put(service.getName(), service); 146 PhaseResolver handlerResolver = new PhaseResolver(this,service); 147 handlerResolver.buildchains(); 148 } 149 150 157 public ModuleDescription getModule(QName name) throws AxisFault { 158 return (ModuleDescription) modules.get(name); 159 } 160 161 164 public HashMap getModules() { 165 return modules; 166 } 167 168 169 176 public ServiceDescription getService(QName name) throws AxisFault { 177 return (ServiceDescription) services.get(name); 178 } 179 180 186 public synchronized void removeService(QName name) throws AxisFault { 187 services.remove(name); 188 } 189 190 191 public TransportInDescription getTransportIn(QName name) throws AxisFault { 192 return (TransportInDescription) transportsIn.get(name); 193 } 194 195 201 public synchronized void addTransportIn(TransportInDescription transport) 202 throws AxisFault { 203 transportsIn.put(transport.getName(), transport); 204 } 205 206 public TransportOutDescription getTransportOut(QName name) throws AxisFault { 207 return (TransportOutDescription) transportsOut.get(name); 208 } 209 210 216 public synchronized void addTransportOut(TransportOutDescription transport) 217 throws AxisFault { 218 transportsOut.put(transport.getName(), transport); 219 } 220 221 public HashMap getTransportsIn() { 222 return transportsIn; 223 } 224 225 public HashMap getTransportsOut() { 226 return transportsOut; 227 } 228 229 230 public void setInPhases(ArrayList inPhases) { 231 this.inPhases = inPhases; 232 } 233 234 public void setOutPhases(ArrayList outPhases) { 235 this.outPhases = outPhases; 236 } 237 238 239 public ArrayList getInPhasesUptoAndIncludingPostDispatch() { 240 return inPhasesUptoAndIncludingPostDispatch; 241 } 242 243 public ArrayList getOutFlow() { 244 return outPhases; 245 } 246 247 248 251 public ArrayList getInFaultFlow() { 252 return inFaultPhases; 253 } 254 255 258 public ArrayList getOutFaultFlow() { 259 return outFaultPhases; 260 } 261 262 265 public void setInFaultPhases(ArrayList list) { 266 inFaultPhases = list; 267 } 268 269 272 public void setOutFaultPhases(ArrayList list) { 273 outFaultPhases = list; 274 } 275 276 278 public void addMessageReceiver(String key, MessageReceiver messageReceiver) { 279 messagRecievers.put(key, messageReceiver); 280 } 281 282 public MessageReceiver getMessageReceiver(String key) { 283 return (MessageReceiver) messagRecievers.get(key); 284 } 285 286 292 public Parameter getParameter(String name) { 293 return paramInclude.getParameter(name); 294 } 295 296 301 public void addParameter(Parameter param) { 302 paramInclude.addParameter(param); 303 } 304 309 public Collection getEngadgedModules() { 310 return engagedModules; 311 } 312 313 public void engageModule(QName moduleref) throws AxisFault { 314 ModuleDescription module = getModule(moduleref); 315 boolean isNewmodule = false; 316 if(module == null ) { 317 File file = new ArchiveReader().creatModuleArchivefromResource(moduleref.getLocalPart()); 318 module = new DeploymentEngine().buildModule(file); 319 isNewmodule = true; 320 } 321 if (module != null) { 322 for (Iterator iterator = engagedModules.iterator(); iterator.hasNext();) { 323 QName qName = (QName ) iterator.next(); 324 if(moduleref.equals(qName)){ 325 throw new AxisFault(moduleref.getLocalPart()+ " module has alredy engaged globally" + 326 " operation terminated !!!"); 327 } 328 } 329 new PhaseResolver(this).engageModuleGlobally(module); 330 } else { 331 throw new AxisFault(this + " Refer to invalid module " 332 + moduleref.getLocalPart() + " has not bean deployed yet !"); 333 } 334 engagedModules.add(moduleref); 335 if(isNewmodule){ 336 addMdoule(module); 337 } 338 } 339 340 public boolean isEngaged(QName moduleName){ 341 return engagedModules.contains(moduleName); 342 } 343 344 } 345 | Popular Tags |