1 55 package org.jboss.axis.deployment.wsdd; 56 57 import org.jboss.axis.ConfigurationException; 58 import org.jboss.axis.encoding.SerializationContext; 59 import org.jboss.axis.utils.Messages; 60 import org.w3c.dom.Element ; 61 import org.xml.sax.helpers.AttributesImpl ; 62 63 import javax.xml.namespace.QName ; 64 import java.io.IOException ; 65 import java.util.Iterator ; 66 import java.util.Vector ; 67 68 69 74 public class WSDDUndeployment 75 extends WSDDElement 76 implements WSDDTypeMappingContainer 77 { 78 private Vector handlers = new Vector (); 79 private Vector chains = new Vector (); 80 private Vector services = new Vector (); 81 private Vector transports = new Vector (); 82 private Vector typeMappings = new Vector (); 83 84 public void addHandler(QName handler) 85 { 86 handlers.add(handler); 87 } 88 89 public void addChain(QName chain) 90 { 91 chains.add(chain); 92 } 93 94 public void addTransport(QName transport) 95 { 96 transports.add(transport); 97 } 98 99 public void addService(QName service) 100 { 101 services.add(service); 102 } 103 104 public void deployTypeMapping(WSDDTypeMapping typeMapping) 105 throws WSDDException 106 { 107 typeMappings.add(typeMapping); 108 } 109 110 113 public WSDDUndeployment() 114 { 115 } 116 117 private QName getQName(Element el) throws WSDDException 118 { 119 String attr = el.getAttribute(ATTR_NAME); 120 if (attr == null || "".equals(attr)) 121 throw new WSDDException(Messages.getMessage("badNameAttr00")); 122 return new QName ("", attr); 123 } 124 125 131 public WSDDUndeployment(Element e) 132 throws WSDDException 133 { 134 super(e); 135 136 Element [] elements = getChildElements(e, ELEM_WSDD_HANDLER); 137 int i; 138 139 for (i = 0; i < elements.length; i++) 140 { 141 addHandler(getQName(elements[i])); 142 } 143 144 elements = getChildElements(e, ELEM_WSDD_CHAIN); 145 for (i = 0; i < elements.length; i++) 146 { 147 addChain(getQName(elements[i])); 148 } 149 150 elements = getChildElements(e, ELEM_WSDD_TRANSPORT); 151 for (i = 0; i < elements.length; i++) 152 { 153 addTransport(getQName(elements[i])); 154 } 155 156 elements = getChildElements(e, ELEM_WSDD_SERVICE); 157 for (i = 0; i < elements.length; i++) 158 { 159 addService(getQName(elements[i])); 160 } 161 162 177 } 178 179 protected QName getElementName() 180 { 181 return QNAME_UNDEPLOY; 182 } 183 184 public void undeployFromRegistry(WSDDDeployment registry) 185 throws ConfigurationException 186 { 187 QName qname; 188 for (int n = 0; n < handlers.size(); n++) 189 { 190 qname = (QName )handlers.get(n); 191 registry.undeployHandler(qname); 192 } 193 194 for (int n = 0; n < chains.size(); n++) 195 { 196 qname = (QName )chains.get(n); 197 registry.undeployHandler(qname); 198 } 199 200 for (int n = 0; n < transports.size(); n++) 201 { 202 qname = (QName )transports.get(n); 203 registry.undeployTransport(qname); 204 } 205 206 for (int n = 0; n < services.size(); n++) 207 { 208 qname = (QName )services.get(n); 209 registry.undeployService(qname); 210 } 211 } 212 213 private void writeElement(SerializationContext context, 214 QName elementQName, 215 QName qname) 216 throws IOException 217 { 218 AttributesImpl attrs = new org.xml.sax.helpers.AttributesImpl (); 219 attrs.addAttribute("", ATTR_NAME, ATTR_NAME, "CDATA", 220 context.qName2String(qname)); 221 222 context.startElement(elementQName, attrs); 223 context.endElement(); 224 } 225 226 public void writeToContext(SerializationContext context) 227 throws IOException 228 { 229 context.registerPrefixForURI(NS_PREFIX_WSDD, URI_WSDD); 230 context.startElement(WSDDConstants.QNAME_UNDEPLOY, null); 231 232 Iterator i = handlers.iterator(); 233 QName qname; 234 while (i.hasNext()) 235 { 236 qname = (QName )i.next(); 237 writeElement(context, QNAME_HANDLER, qname); 238 } 239 240 i = chains.iterator(); 241 while (i.hasNext()) 242 { 243 qname = (QName )i.next(); 244 writeElement(context, QNAME_CHAIN, qname); 245 } 246 247 i = services.iterator(); 248 while (i.hasNext()) 249 { 250 qname = (QName )i.next(); 251 writeElement(context, QNAME_SERVICE, qname); 252 } 253 254 i = transports.iterator(); 255 while (i.hasNext()) 256 { 257 qname = (QName )i.next(); 258 writeElement(context, QNAME_TRANSPORT, qname); 259 } 260 261 i = typeMappings.iterator(); 262 while (i.hasNext()) 263 { 264 WSDDTypeMapping mapping = (WSDDTypeMapping)i.next(); 265 mapping.writeToContext(context); 266 } 267 268 context.endElement(); 269 } 270 271 274 public WSDDTypeMapping[] getTypeMappings() 275 { 276 WSDDTypeMapping[] t = new WSDDTypeMapping[typeMappings.size()]; 277 typeMappings.toArray(t); 278 return t; 279 } 280 281 } 282 | Popular Tags |