1 16 package org.apache.axis.deployment.wsdd; 17 18 import org.apache.axis.ConfigurationException; 19 import org.apache.axis.EngineConfiguration; 20 import org.apache.axis.Handler; 21 import org.apache.axis.encoding.SerializationContext; 22 import org.apache.axis.utils.ClassUtils; 23 import org.apache.axis.utils.Messages; 24 import org.apache.axis.utils.XMLUtils; 25 import org.w3c.dom.Element ; 26 27 import javax.xml.namespace.QName ; 28 import java.io.IOException ; 29 30 31 34 public abstract class WSDDTargetedChain 35 extends WSDDDeployableItem 36 { 37 private WSDDRequestFlow requestFlow; 38 private WSDDResponseFlow responseFlow; 39 private QName pivotQName; 40 41 protected WSDDTargetedChain() 42 { 43 } 44 45 50 protected WSDDTargetedChain(Element e) 51 throws WSDDException 52 { 53 super(e); 54 Element reqEl = getChildElement(e, ELEM_WSDD_REQFLOW); 55 if (reqEl != null && reqEl.getElementsByTagName("*").getLength()>0) { 56 requestFlow = new WSDDRequestFlow(reqEl); 57 } 58 Element respEl = getChildElement(e, ELEM_WSDD_RESPFLOW); 59 if (respEl != null && respEl.getElementsByTagName("*").getLength()>0) { 60 responseFlow = new WSDDResponseFlow(respEl); 61 } 62 63 String pivotStr = e.getAttribute(ATTR_PIVOT); 65 if (pivotStr != null && !pivotStr.equals("")) 66 pivotQName = XMLUtils.getQNameFromString(pivotStr, e); 67 68 } 69 70 public WSDDRequestFlow getRequestFlow() 71 { 72 return requestFlow; 73 } 74 75 public void setRequestFlow(WSDDRequestFlow flow) 76 { 77 requestFlow = flow; 78 } 79 80 public WSDDResponseFlow getResponseFlow() 81 { 82 return responseFlow; 83 } 84 85 public void setResponseFlow(WSDDResponseFlow flow) 86 { 87 responseFlow = flow; 88 } 89 90 94 public WSDDFaultFlow[] getFaultFlows() 95 { 96 return null; 97 } 98 99 104 public WSDDFaultFlow getFaultFlow(QName name) 105 { 106 107 WSDDFaultFlow[] t = getFaultFlows(); 108 109 for (int n = 0; n < t.length; n++) { 110 if (t[n].getQName().equals(name)) { 111 return t[n]; 112 } 113 } 114 115 return null; 116 } 117 118 122 public void setType(String type) throws WSDDException 123 { 124 throw new WSDDException(Messages.getMessage( 125 "noTypeSetting", getElementName().getLocalPart())); 126 } 127 128 public QName getPivotQName() 129 { 130 return pivotQName; 131 } 132 133 public void setPivotQName(QName pivotQName) { 134 this.pivotQName = pivotQName; 135 } 136 137 144 public Handler makeNewInstance(EngineConfiguration registry) 145 throws ConfigurationException 146 { 147 Handler reqHandler = null; 148 149 WSDDChain req = getRequestFlow(); 150 if (req != null) 151 reqHandler = req.getInstance(registry); 152 153 Handler pivot = null; 154 if (pivotQName != null) { 155 if (URI_WSDD_JAVA.equals(pivotQName.getNamespaceURI())) { 156 try { 157 pivot = (Handler)ClassUtils.forName(pivotQName.getLocalPart()).newInstance(); 158 } catch (InstantiationException e) { 159 throw new ConfigurationException(e); 160 } catch (IllegalAccessException e) { 161 throw new ConfigurationException(e); 162 } catch (ClassNotFoundException e) { 163 throw new ConfigurationException(e); 164 } 165 } else { 166 pivot = registry.getHandler(pivotQName); 167 } 168 } 169 170 Handler respHandler = null; 171 WSDDChain resp = getResponseFlow(); 172 if (resp != null) 173 respHandler = resp.getInstance(registry); 174 175 Handler retVal = new org.apache.axis.SimpleTargetedChain(reqHandler, pivot, 176 respHandler); 177 retVal.setOptions(getParametersTable()); 178 return retVal; 179 } 180 181 184 public final void writeFlowsToContext(SerializationContext context) 185 throws IOException { 186 if (requestFlow != null) { 187 requestFlow.writeToContext(context); 188 } 189 if (responseFlow != null) { 190 responseFlow.writeToContext(context); 191 } 192 193 } 194 195 public void deployToRegistry(WSDDDeployment registry) 196 { 197 if (requestFlow != null) { 199 requestFlow.deployToRegistry(registry); 200 } 201 202 if (responseFlow != null) { 203 responseFlow.deployToRegistry(registry); 204 } 205 } 206 } 207 | Popular Tags |