1 55 package org.jboss.axis.deployment.wsdd; 56 57 import org.jboss.axis.encoding.SerializationContext; 58 import org.jboss.axis.handlers.HandlerInfoChainFactory; 59 import org.jboss.axis.utils.ClassUtils; 60 import org.w3c.dom.Element ; 61 import org.xml.sax.helpers.AttributesImpl ; 62 63 import javax.xml.namespace.QName ; 64 import javax.xml.rpc.handler.HandlerInfo ; 65 import java.io.IOException ; 66 import java.util.ArrayList ; 67 import java.util.Iterator ; 68 import java.util.List ; 69 import java.util.Map ; 70 71 74 public class WSDDJAXRPCHandlerInfoChain extends WSDDHandler 75 { 76 77 private ArrayList _hiList; 78 private HandlerInfoChainFactory _hiChainFactory; 79 private String [] _roles; 80 81 84 public WSDDJAXRPCHandlerInfoChain() 85 { 86 } 87 88 92 public WSDDJAXRPCHandlerInfoChain(Element e) throws WSDDException 93 { 94 super(e); 95 96 ArrayList infoList = new ArrayList (); 97 _hiList = new ArrayList (); 98 Element [] elements = getChildElements(e, ELEM_WSDD_JAXRPC_HANDLERINFO); 99 if (elements.length != 0) 100 { 101 for (int i = 0; i < elements.length; i++) 102 { 103 WSDDJAXRPCHandlerInfo handlerInfo = 104 new WSDDJAXRPCHandlerInfo(elements[i]); 105 _hiList.add(handlerInfo); 106 107 String handlerClassName = handlerInfo.getHandlerClassName(); 108 Class handlerClass = null; 109 try 110 { 111 handlerClass = ClassUtils.forName(handlerClassName); 112 } 113 catch (ClassNotFoundException cnf) 114 { 115 } 117 118 Map handlerMap = handlerInfo.getHandlerMap(); 119 QName [] headers = handlerInfo.getHeaders(); 120 121 if (handlerClass != null) 122 { 123 HandlerInfo hi = 124 new HandlerInfo (handlerClass, handlerMap, headers); 125 infoList.add(hi); 126 } 127 } 128 } 129 _hiChainFactory = new HandlerInfoChainFactory(infoList); 130 131 elements = getChildElements(e, ELEM_WSDD_JAXRPC_ROLE); 132 if (elements.length != 0) 133 { 134 ArrayList roleList = new ArrayList (); 135 for (int i = 0; i < elements.length; i++) 136 { 137 String role = elements[i].getAttribute(ATTR_SOAPACTORNAME); 138 roleList.add(role); 139 } 140 _roles = new String [roleList.size()]; 141 _roles = (String [])roleList.toArray(_roles); 142 _hiChainFactory.setRoles(_roles); 143 } 144 145 } 146 147 public HandlerInfoChainFactory getHandlerChainFactory() 148 { 149 return _hiChainFactory; 150 } 151 152 public void setHandlerChainFactory(HandlerInfoChainFactory handlerInfoChainFactory) 153 { 154 _hiChainFactory = handlerInfoChainFactory; 155 } 156 157 protected QName getElementName() 158 { 159 return WSDDConstants.QNAME_JAXRPC_HANDLERINFOCHAIN; 160 } 161 162 165 public void writeToContext(SerializationContext context) 166 throws IOException 167 { 168 context.startElement(QNAME_JAXRPC_HANDLERINFOCHAIN, null); 169 170 List his = _hiList; 171 Iterator iter = his.iterator(); 172 while (iter.hasNext()) 173 { 174 WSDDJAXRPCHandlerInfo hi = (WSDDJAXRPCHandlerInfo)iter.next(); 175 hi.writeToContext(context); 176 } 177 178 if (_roles != null) 179 { 180 for (int i = 0; i < _roles.length; i++) 181 { 182 AttributesImpl attrs1 = new AttributesImpl (); 183 attrs1.addAttribute("", ATTR_SOAPACTORNAME, ATTR_SOAPACTORNAME, 184 "CDATA", _roles[i]); 185 context.startElement(QNAME_JAXRPC_ROLE, attrs1); 186 context.endElement(); 187 } 188 } 189 190 context.endElement(); 191 } 192 193 public ArrayList getHandlerInfoList() 194 { 195 return _hiList; 196 } 197 198 public void setHandlerInfoList(ArrayList hiList) 199 { 200 _hiList = hiList; 201 } 202 203 public String [] getRoles() 204 { 205 return _roles; 206 } 207 208 public void setRoles(String [] roles) 209 { 210 _roles = roles; 211 } 212 } 213 | Popular Tags |