KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > webservice > metadata > WebservicesFactory


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.webservice.metadata;
8
9 // $Id: WebservicesFactory.java,v 1.17.2.3 2005/06/19 10:07:15 bill Exp $
10

11 import java.net.URLClassLoader JavaDoc;
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 JavaDoc;
18
19 /**
20  * A JBossXB factory for {@link WebservicesMetaData}
21  *
22  * @author Thomas.Diesler@jboss.org
23  * @since 16-Apr-2004
24  */

25 public class WebservicesFactory
26         implements ObjectModelFactory
27 {
28    // provide logging
29
private static final Logger log = Logger.getLogger(WebservicesFactory.class);
30
31    // The url class loader for resources
32
private URLClassLoader JavaDoc resourceLoader;
33
34    public WebservicesFactory(URLClassLoader JavaDoc resourceLoader)
35    {
36       this.resourceLoader = resourceLoader;
37    }
38
39    public Object JavaDoc completeRoot(Object JavaDoc root, UnmarshallingContext ctx,
40          String JavaDoc uri, String JavaDoc name)
41    {
42       return root;
43    }
44    /**
45     * This method is called on the factory by the object model builder when the parsing starts.
46     *
47     * @return the root of the object model.
48     */

49    public Object JavaDoc newRoot(Object JavaDoc root,
50                                UnmarshallingContext navigator,
51                                String JavaDoc namespaceURI,
52                                String JavaDoc localName,
53                                Attributes JavaDoc attrs)
54    {
55       return new WebservicesMetaData(resourceLoader);
56    }
57
58    /**
59     * Called when parsing of a new element started.
60     */

61    public Object JavaDoc newChild(WebservicesMetaData webservices, UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
62                           Attributes JavaDoc attrs)
63    {
64       if ("webservice-description".equals(localName))
65          return new WebserviceDescriptionMetaData(webservices);
66       else
67          return null;
68    }
69
70    /**
71     * Called when parsing character is complete.
72     */

73    public void addChild(WebservicesMetaData webservices,
74                         WebserviceDescriptionMetaData webserviceDescription,
75                         UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
76    {
77       webservices.addWebserviceDescription(webserviceDescription);
78    }
79
80    /**
81     * Called when parsing of a new element started.
82     */

83    public Object JavaDoc newChild(WebserviceDescriptionMetaData webserviceDescription, UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
84                           Attributes JavaDoc attrs)
85    {
86       if ("port-component".equals(localName))
87          return new PortComponentMetaData(webserviceDescription);
88       else
89          return null;
90    }
91
92    /**
93     * Called when parsing character is complete.
94     */

95    public void addChild(WebserviceDescriptionMetaData webserviceDescription,
96                         PortComponentMetaData portComponent,
97                         UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
98    {
99       webserviceDescription.addPortComponent(portComponent);
100    }
101
102    /**
103     * Called when parsing of a new element started.
104     */

105    public Object JavaDoc newChild(PortComponentMetaData portComponent, UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
106                           Attributes JavaDoc attrs)
107    {
108       if ("handler".equals(localName))
109          return new HandlerMetaData();
110       else
111          return null;
112    }
113
114    /**
115     * Called when parsing character is complete.
116     */

117    public void addChild(PortComponentMetaData portComponent, HandlerMetaData handler, UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
118    {
119       portComponent.addHandler(handler);
120    }
121
122    /**
123     * Called when parsing of a new element started.
124     */

125    public Object JavaDoc newChild(HandlerMetaData handler, UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
126                           Attributes JavaDoc attrs)
127    {
128       if ("init-param".equals(localName))
129          return new InitParamMetaData();
130       else
131          return null;
132    }
133
134    /**
135     * Called when parsing character is complete.
136     */

137    public void addChild(HandlerMetaData handler, InitParamMetaData param, UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
138    {
139       handler.addInitParam(param);
140    }
141
142    /**
143     * Called when a new simple child element with text value was read from the XML content.
144     */

145    public void setValue(WebserviceDescriptionMetaData webserviceDescription, UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc 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    /**
159     * Called when a new simple child element with text value was read from the XML content.
160     */

161    public void setValue(PortComponentMetaData portComponent, UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc 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    /**
179     * Called when a new simple child element with text value was read from the XML content.
180     */

181    public void setValue(HandlerMetaData handler, UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc 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    /**
197     * Called when a new simple child element with text value was read from the XML content.
198     */

199    public void setValue(InitParamMetaData param, UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc 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