1 55 package org.jboss.axis.deployment.wsdd; 56 57 import org.jboss.axis.ConfigurationException; 58 import org.jboss.axis.EngineConfiguration; 59 import org.jboss.axis.Handler; 60 import org.jboss.axis.encoding.SerializationContext; 61 import org.jboss.axis.utils.ClassUtils; 62 import org.jboss.axis.utils.Messages; 63 import org.jboss.axis.utils.XMLUtils; 64 import org.w3c.dom.Element ; 65 66 import javax.xml.namespace.QName ; 67 import java.io.IOException ; 68 69 70 73 public abstract class WSDDTargetedChain 74 extends WSDDDeployableItem 75 { 76 private WSDDRequestFlow requestFlow; 77 private WSDDResponseFlow responseFlow; 78 private QName pivotQName; 79 80 protected WSDDTargetedChain() 81 { 82 } 83 84 88 protected WSDDTargetedChain(Element e) 89 throws WSDDException 90 { 91 super(e); 92 Element reqEl = getChildElement(e, ELEM_WSDD_REQFLOW); 93 if (reqEl != null && reqEl.getElementsByTagName("*").getLength() > 0) 94 { 95 requestFlow = new WSDDRequestFlow(reqEl); 96 } 97 Element respEl = getChildElement(e, ELEM_WSDD_RESPFLOW); 98 if (respEl != null && respEl.getElementsByTagName("*").getLength() > 0) 99 { 100 responseFlow = new WSDDResponseFlow(respEl); 101 } 102 103 String pivotStr = e.getAttribute(ATTR_PIVOT); 105 if (pivotStr != null && !pivotStr.equals("")) 106 pivotQName = XMLUtils.getQNameFromString(pivotStr, e); 107 108 } 109 110 public WSDDRequestFlow getRequestFlow() 111 { 112 return requestFlow; 113 } 114 115 public void setRequestFlow(WSDDRequestFlow flow) 116 { 117 requestFlow = flow; 118 } 119 120 public WSDDResponseFlow getResponseFlow() 121 { 122 return responseFlow; 123 } 124 125 public void setResponseFlow(WSDDResponseFlow flow) 126 { 127 responseFlow = flow; 128 } 129 130 133 public WSDDFaultFlow[] getFaultFlows() 134 { 135 return null; 136 } 137 138 142 public WSDDFaultFlow getFaultFlow(QName name) 143 { 144 145 WSDDFaultFlow[] t = getFaultFlows(); 146 147 for (int n = 0; n < t.length; n++) 148 { 149 if (t[n].getQName().equals(name)) 150 { 151 return t[n]; 152 } 153 } 154 155 return null; 156 } 157 158 161 public void setType(String type) throws WSDDException 162 { 163 throw new WSDDException(Messages.getMessage("noTypeSetting", getElementName().getLocalPart())); 164 } 165 166 public QName getPivotQName() 167 { 168 return pivotQName; 169 } 170 171 public void setPivotQName(QName pivotQName) 172 { 173 this.pivotQName = pivotQName; 174 } 175 176 182 public Handler makeNewInstance(EngineConfiguration registry) 183 throws ConfigurationException 184 { 185 Handler reqHandler = null; 186 187 WSDDChain req = getRequestFlow(); 188 if (req != null) 189 reqHandler = req.getInstance(registry); 190 191 Handler pivot = null; 192 if (pivotQName != null) 193 { 194 if (URI_WSDD_JAVA.equals(pivotQName.getNamespaceURI())) 195 { 196 try 197 { 198 pivot = (Handler)ClassUtils.forName(pivotQName.getLocalPart()).newInstance(); 199 } 200 catch (InstantiationException e) 201 { 202 throw new ConfigurationException(e); 203 } 204 catch (IllegalAccessException e) 205 { 206 throw new ConfigurationException(e); 207 } 208 catch (ClassNotFoundException e) 209 { 210 throw new ConfigurationException(e); 211 } 212 } 213 else 214 { 215 pivot = registry.getHandler(pivotQName); 216 } 217 } 218 219 Handler respHandler = null; 220 WSDDChain resp = getResponseFlow(); 221 if (resp != null) 222 respHandler = resp.getInstance(registry); 223 224 return new org.jboss.axis.SimpleTargetedChain(reqHandler, pivot, 225 respHandler); 226 } 227 228 231 public final void writeFlowsToContext(SerializationContext context) 232 throws IOException 233 { 234 if (requestFlow != null) 235 { 236 requestFlow.writeToContext(context); 237 } 238 if (responseFlow != null) 239 { 240 responseFlow.writeToContext(context); 241 } 242 243 } 244 245 public void deployToRegistry(WSDDDeployment registry) 246 { 247 if (requestFlow != null) 249 { 250 requestFlow.deployToRegistry(registry); 251 } 252 253 if (responseFlow != null) 254 { 255 responseFlow.deployToRegistry(registry); 256 } 257 } 258 } 259 | Popular Tags |