1 7 package org.jboss.webservice.metadata; 8 9 11 import java.net.URLClassLoader ; 12 import org.jboss.logging.Logger; 13 import org.jboss.webservice.metadata.serviceref.HandlerMetaData; 14 import org.jboss.webservice.metadata.serviceref.InitParamMetaData; 15 import org.jboss.xb.binding.ObjectModelFactory; 16 import org.jboss.xb.binding.UnmarshallingContext; 17 import org.xml.sax.Attributes ; 18 19 25 public class WebservicesFactory 26 implements ObjectModelFactory 27 { 28 private static final Logger log = Logger.getLogger(WebservicesFactory.class); 30 31 private URLClassLoader resourceLoader; 33 34 public WebservicesFactory(URLClassLoader resourceLoader) 35 { 36 this.resourceLoader = resourceLoader; 37 } 38 39 public Object completeRoot(Object root, UnmarshallingContext ctx, 40 String uri, String name) 41 { 42 return root; 43 } 44 49 public Object newRoot(Object root, 50 UnmarshallingContext navigator, 51 String namespaceURI, 52 String localName, 53 Attributes attrs) 54 { 55 return new WebservicesMetaData(resourceLoader); 56 } 57 58 61 public Object newChild(WebservicesMetaData webservices, UnmarshallingContext navigator, String namespaceURI, String localName, 62 Attributes attrs) 63 { 64 if ("webservice-description".equals(localName)) 65 return new WebserviceDescriptionMetaData(webservices); 66 else 67 return null; 68 } 69 70 73 public void addChild(WebservicesMetaData webservices, 74 WebserviceDescriptionMetaData webserviceDescription, 75 UnmarshallingContext navigator, String namespaceURI, String localName) 76 { 77 webservices.addWebserviceDescription(webserviceDescription); 78 } 79 80 83 public Object newChild(WebserviceDescriptionMetaData webserviceDescription, UnmarshallingContext navigator, String namespaceURI, String localName, 84 Attributes attrs) 85 { 86 if ("port-component".equals(localName)) 87 return new PortComponentMetaData(webserviceDescription); 88 else 89 return null; 90 } 91 92 95 public void addChild(WebserviceDescriptionMetaData webserviceDescription, 96 PortComponentMetaData portComponent, 97 UnmarshallingContext navigator, String namespaceURI, String localName) 98 { 99 webserviceDescription.addPortComponent(portComponent); 100 } 101 102 105 public Object newChild(PortComponentMetaData portComponent, UnmarshallingContext navigator, String namespaceURI, String localName, 106 Attributes attrs) 107 { 108 if ("handler".equals(localName)) 109 return new HandlerMetaData(); 110 else 111 return null; 112 } 113 114 117 public void addChild(PortComponentMetaData portComponent, HandlerMetaData handler, UnmarshallingContext navigator, String namespaceURI, String localName) 118 { 119 portComponent.addHandler(handler); 120 } 121 122 125 public Object newChild(HandlerMetaData handler, UnmarshallingContext navigator, String namespaceURI, String localName, 126 Attributes attrs) 127 { 128 if ("init-param".equals(localName)) 129 return new InitParamMetaData(); 130 else 131 return null; 132 } 133 134 137 public void addChild(HandlerMetaData handler, InitParamMetaData param, UnmarshallingContext navigator, String namespaceURI, String localName) 138 { 139 handler.addInitParam(param); 140 } 141 142 145 public void setValue(WebserviceDescriptionMetaData webserviceDescription, UnmarshallingContext navigator, String namespaceURI, String localName, String value) 146 { 147 if (log.isTraceEnabled()) 148 log.trace("WebserviceDescriptionMetaData setValue: nuri=" + namespaceURI + " localName=" + localName + " value=" + value); 149 150 if (localName.equals("webservice-description-name")) 151 webserviceDescription.setWebserviceDescriptionName(value); 152 else if (localName.equals("wsdl-file")) 153 webserviceDescription.setWsdlFile(value); 154 else if (localName.equals("jaxrpc-mapping-file")) 155 webserviceDescription.setJaxrpcMappingFile(value); 156 } 157 158 161 public void setValue(PortComponentMetaData portComponent, UnmarshallingContext navigator, String namespaceURI, String localName, String value) 162 { 163 if (log.isTraceEnabled()) 164 log.trace("PortComponentMetaData setValue: nuri=" + namespaceURI + " localName=" + localName + " value=" + value); 165 166 if (localName.equals("port-component-name")) 167 portComponent.setPortComponentName(value); 168 else if (localName.equals("wsdl-port")) 169 portComponent.setWsdlPort(navigator.resolveQName(value)); 170 else if (localName.equals("service-endpoint-interface")) 171 portComponent.setServiceEndpointInterface(value); 172 else if (localName.equals("ejb-link")) 173 portComponent.setEjbLink(value); 174 else if (localName.equals("servlet-link")) 175 portComponent.setServletLink(value); 176 } 177 178 181 public void setValue(HandlerMetaData handler, UnmarshallingContext navigator, String namespaceURI, String localName, String value) 182 { 183 if (log.isTraceEnabled()) 184 log.trace("HandlerMetaData setValue: nuri=" + namespaceURI + " localName=" + localName + " value=" + value); 185 186 if (localName.equals("handler-name")) 187 handler.setHandlerName(value); 188 else if (localName.equals("handler-class")) 189 handler.setHandlerClass(value); 190 else if (localName.equals("soap-header")) 191 handler.addSoapHeader(navigator.resolveQName(value)); 192 else if (localName.equals("soap-role")) 193 handler.addSoapRole(value); 194 } 195 196 199 public void setValue(InitParamMetaData param, UnmarshallingContext navigator, String namespaceURI, String localName, String value) 200 { 201 if (log.isTraceEnabled()) 202 log.trace("InitParamMetaData setValue: nuri=" + namespaceURI + " localName=" + localName + " value=" + value); 203 204 if (localName.equals("param-name")) 205 param.setParamName(value); 206 else if (localName.equals("param-value")) 207 param.setParamValue(value); 208 } 209 } 210 | Popular Tags |