1 55 package org.jboss.axis.deployment.wsdd; 56 57 import org.jboss.axis.Chain; 58 import org.jboss.axis.ConfigurationException; 59 import org.jboss.axis.EngineConfiguration; 60 import org.jboss.axis.Handler; 61 import org.jboss.axis.encoding.SerializationContext; 62 import org.w3c.dom.Element ; 63 import org.xml.sax.helpers.AttributesImpl ; 64 65 import javax.xml.namespace.QName ; 66 import java.io.IOException ; 67 import java.util.Vector ; 68 69 70 73 public class WSDDChain 74 extends WSDDHandler 75 { 76 private Vector handlers = new Vector (); 77 78 81 public WSDDChain() 82 { 83 } 84 85 89 public WSDDChain(Element e) 90 throws WSDDException 91 { 92 super(e); 93 94 if (type != null) 97 return; 98 99 Element [] elements = getChildElements(e, ELEM_WSDD_HANDLER); 100 if (elements.length != 0) 101 { 102 for (int i = 0; i < elements.length; i++) 103 { 104 WSDDHandler handler = new WSDDHandler(elements[i]); 105 addHandler(handler); 106 } 107 } 108 109 elements = getChildElements(e, ELEM_WSDD_CHAIN); 110 if (elements.length != 0) 111 { 112 for (int i = 0; i < elements.length; i++) 113 { 114 WSDDChain chain = new WSDDChain(elements[i]); 115 addHandler(chain); 116 } 117 } 118 119 } 120 121 protected QName getElementName() 122 { 123 return WSDDConstants.QNAME_CHAIN; 124 } 125 126 129 public void addHandler(WSDDHandler handler) 130 { 131 handlers.add(handler); 132 } 133 134 139 public Vector getHandlers() 140 { 141 return handlers; 142 } 143 144 147 public void removeHandler(WSDDHandler victim) 148 { 149 handlers.remove(victim); 150 } 151 152 159 public Handler makeNewInstance(EngineConfiguration registry) 160 throws ConfigurationException 161 { 162 Chain c = new org.jboss.axis.SimpleChain(); 163 164 for (int n = 0; n < handlers.size(); n++) 165 { 166 WSDDHandler handler = (WSDDHandler)handlers.get(n); 167 Handler h = handler.getInstance(registry); 168 if (h != null) 169 c.addHandler(h); 170 else 171 throw new ConfigurationException("Can't find handler name:'" + 172 handler.getQName() + "' type:'" + 173 handler.getType() + 174 "' in the registry"); 175 } 176 177 return c; 178 } 179 180 183 public void writeToContext(SerializationContext context) 184 throws IOException 185 { 186 AttributesImpl attrs = new AttributesImpl (); 187 QName name = getQName(); 188 if (name != null) 189 { 190 attrs.addAttribute("", ATTR_NAME, ATTR_NAME, 191 "CDATA", context.qName2String(name)); 192 } 193 if (getType() != null) 194 { 195 attrs.addAttribute("", ATTR_TYPE, ATTR_TYPE, 196 "CDATA", context.qName2String(getType())); 197 } 198 199 context.startElement(getElementName(), attrs); 200 for (int n = 0; n < handlers.size(); n++) 201 { 202 WSDDHandler handler = (WSDDHandler)handlers.get(n); 203 handler.writeToContext(context); 204 } 205 context.endElement(); 206 } 207 208 public void deployToRegistry(WSDDDeployment registry) 209 { 210 if (getQName() != null) 211 registry.addHandler(this); 212 213 for (int n = 0; n < handlers.size(); n++) 214 { 215 WSDDHandler handler = (WSDDHandler)handlers.get(n); 216 if (handler.getQName() != null) 217 handler.deployToRegistry(registry); 218 } 219 } 220 } 221 | Popular Tags |