1 16 package org.apache.axis.deployment.wsdd; 17 18 import java.io.IOException ; 19 import java.util.Vector ; 20 21 import javax.xml.namespace.QName ; 22 23 import org.apache.axis.Chain; 24 import org.apache.axis.ConfigurationException; 25 import org.apache.axis.EngineConfiguration; 26 import org.apache.axis.Handler; 27 import org.apache.axis.encoding.SerializationContext; 28 import org.w3c.dom.Element ; 29 import org.xml.sax.helpers.AttributesImpl ; 30 31 32 36 public class WSDDChain 37 extends WSDDHandler 38 { 39 private Vector handlers = new Vector (); 40 41 44 public WSDDChain() 45 { 46 } 47 48 53 public WSDDChain(Element e) 54 throws WSDDException 55 { 56 super(e); 57 58 if (type != null) 61 return; 62 63 Element [] elements = getChildElements(e, ELEM_WSDD_HANDLER); 64 if (elements.length != 0) { 65 for (int i = 0; i < elements.length; i++) { 66 WSDDHandler handler = new WSDDHandler(elements[i]); 67 addHandler(handler); 68 } 69 } 70 71 elements = getChildElements(e, ELEM_WSDD_CHAIN); 72 if (elements.length != 0) { 73 for (int i = 0; i < elements.length; i++) { 74 WSDDChain chain = new WSDDChain(elements[i]); 75 addHandler(chain); 76 } 77 } 78 79 } 80 81 protected QName getElementName() 82 { 83 return WSDDConstants.QNAME_CHAIN; 84 } 85 86 89 public void addHandler(WSDDHandler handler) 90 { 91 handlers.add(handler); 92 } 93 94 99 public Vector getHandlers() 100 { 101 return handlers; 102 } 103 104 107 public void removeHandler(WSDDHandler victim) 108 { 109 handlers.remove(victim); 110 } 111 112 118 public Handler makeNewInstance(EngineConfiguration registry) 119 throws ConfigurationException 120 { 121 Chain c = new org.apache.axis.SimpleChain(); 122 123 for (int n = 0; n < handlers.size(); n++) { 124 WSDDHandler handler = (WSDDHandler)handlers.get(n); 125 Handler h = handler.getInstance(registry); 126 if ( h != null ) 127 c.addHandler(h); 128 else 129 throw new ConfigurationException("Can't find handler name:'" + 130 handler.getQName() + "' type:'"+ 131 handler.getType() + 132 "' in the registry"); 133 } 134 135 return c; 136 } 137 138 141 public void writeToContext(SerializationContext context) 142 throws IOException 143 { 144 AttributesImpl attrs = new AttributesImpl (); 145 QName name = getQName(); 146 if (name != null) { 147 attrs.addAttribute("", ATTR_NAME, ATTR_NAME, 148 "CDATA", context.qName2String(name)); 149 } 150 if (getType() != null) { 151 attrs.addAttribute("", ATTR_TYPE, ATTR_TYPE, 152 "CDATA", context.qName2String(getType())); 153 } 154 155 context.startElement(getElementName(), attrs); 156 for (int n = 0; n < handlers.size(); n++) { 157 WSDDHandler handler = (WSDDHandler)handlers.get(n); 158 handler.writeToContext(context); 159 } 160 context.endElement(); 161 } 162 163 public void deployToRegistry(WSDDDeployment registry) 164 { 165 if (getQName() != null) 166 registry.addHandler(this); 167 168 for (int n = 0; n < handlers.size(); n++) { 169 WSDDHandler handler = (WSDDHandler)handlers.get(n); 170 if (handler.getQName() != null) 171 handler.deployToRegistry(registry); 172 } 173 } 174 } 175 | Popular Tags |