1 16 package org.apache.axis.deployment.wsdd; 17 18 import org.apache.axis.components.logger.LogFactory; 19 import org.apache.axis.encoding.SerializationContext; 20 import org.apache.axis.handlers.HandlerInfoChainFactory; 21 import org.apache.axis.utils.ClassUtils; 22 import org.apache.axis.utils.Messages; 23 import org.apache.commons.logging.Log; 24 import org.w3c.dom.Element ; 25 import org.xml.sax.helpers.AttributesImpl ; 26 27 import javax.xml.namespace.QName ; 28 import javax.xml.rpc.handler.HandlerInfo ; 29 import java.io.IOException ; 30 import java.util.ArrayList ; 31 import java.util.Iterator ; 32 import java.util.List ; 33 import java.util.Map ; 34 35 38 public class WSDDJAXRPCHandlerInfoChain extends WSDDHandler { 39 protected static Log log = 40 LogFactory.getLog(WSDDJAXRPCHandlerInfoChain.class.getName()); 41 42 private ArrayList _hiList; 43 private HandlerInfoChainFactory _hiChainFactory; 44 private String [] _roles; 45 46 49 public WSDDJAXRPCHandlerInfoChain() { 50 } 51 52 57 public WSDDJAXRPCHandlerInfoChain(Element e) throws WSDDException { 58 super(e); 59 60 ArrayList infoList = new ArrayList (); 61 _hiList = new ArrayList (); 62 Element [] elements = getChildElements(e, ELEM_WSDD_JAXRPC_HANDLERINFO); 63 if (elements.length != 0) { 64 for (int i = 0; i < elements.length; i++) { 65 WSDDJAXRPCHandlerInfo handlerInfo = 66 new WSDDJAXRPCHandlerInfo(elements[i]); 67 _hiList.add(handlerInfo); 68 69 String handlerClassName = handlerInfo.getHandlerClassName(); 70 Class handlerClass = null; 71 try { 72 handlerClass = ClassUtils.forName(handlerClassName); 73 } catch (ClassNotFoundException cnf) { 74 log.error(Messages.getMessage("handlerInfoChainNoClass00", handlerClassName), cnf); 75 } 76 77 Map handlerMap = handlerInfo.getHandlerMap(); 78 QName [] headers = handlerInfo.getHeaders(); 79 80 if (handlerClass != null) { 81 HandlerInfo hi = 82 new HandlerInfo (handlerClass, handlerMap, headers); 83 infoList.add(hi); 84 } 85 } 86 } 87 _hiChainFactory = new HandlerInfoChainFactory(infoList); 88 89 elements = getChildElements(e, ELEM_WSDD_JAXRPC_ROLE); 90 if (elements.length != 0) { 91 ArrayList roleList = new ArrayList (); 92 for (int i = 0; i < elements.length; i++) { 93 String role = elements[i].getAttribute( ATTR_SOAPACTORNAME); 94 roleList.add(role); 95 } 96 _roles =new String [roleList.size()]; 97 _roles = (String []) roleList.toArray(_roles); 98 _hiChainFactory.setRoles(_roles); 99 } 100 101 } 102 103 public HandlerInfoChainFactory getHandlerChainFactory() { 104 return _hiChainFactory; 105 } 106 107 public void setHandlerChainFactory(HandlerInfoChainFactory handlerInfoChainFactory) { 108 _hiChainFactory = handlerInfoChainFactory; 109 } 110 111 protected QName getElementName() { 112 return WSDDConstants.QNAME_JAXRPC_HANDLERINFOCHAIN; 113 } 114 115 118 public void writeToContext(SerializationContext context) 119 throws IOException { 120 context.startElement(QNAME_JAXRPC_HANDLERINFOCHAIN,null); 121 122 List his = _hiList; 123 Iterator iter = his.iterator(); 124 while (iter.hasNext()) { 125 WSDDJAXRPCHandlerInfo hi = (WSDDJAXRPCHandlerInfo) iter.next(); 126 hi.writeToContext(context); 127 } 128 129 if (_roles != null) { 130 for (int i=0; i < _roles.length ; i++) { 131 AttributesImpl attrs1 = new AttributesImpl (); 132 attrs1.addAttribute("", ATTR_SOAPACTORNAME, ATTR_SOAPACTORNAME, 133 "CDATA", _roles[i]); 134 context.startElement(QNAME_JAXRPC_ROLE,attrs1); 135 context.endElement(); 136 } 137 } 138 139 context.endElement(); 140 } 141 142 public ArrayList getHandlerInfoList() { 143 return _hiList; 144 } 145 146 public void setHandlerInfoList(ArrayList hiList) { 147 _hiList = hiList; 148 } 149 150 public String [] getRoles() { 151 return _roles; 152 } 153 154 public void setRoles(String [] roles) { 155 _roles = roles; 156 } 157 } 158 | Popular Tags |