KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > webservice > metadata > serviceref > PortComponentRefMetaData


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.webservice.metadata.serviceref;
23
24 // $Id: PortComponentRefMetaData.java 45951 2006-06-28 11:47:56Z tdiesler $
25

26 import org.jboss.deployment.DeploymentException;
27 import org.jboss.metadata.MetaData;
28 import org.w3c.dom.Element JavaDoc;
29
30 import javax.xml.rpc.JAXRPCException JavaDoc;
31 import java.io.Serializable JavaDoc;
32 import java.util.Properties JavaDoc;
33 import java.util.Iterator JavaDoc;
34
35 /** The metdata data from service-ref/port-component-ref element in web.xml, ejb-jar.xml, and application-client.xml.
36  *
37  * @author Thomas.Diesler@jboss.org
38  * @version $Revision: 45951 $
39  */

40 public class PortComponentRefMetaData implements Serializable JavaDoc
41 {
42    static final long serialVersionUID = 3856598615591044263L;
43    // The parent service-ref
44
private ServiceRefMetaData serviceRefMetaData;
45
46    // The required <service-endpoint-interface> element
47
private String JavaDoc serviceEndpointInterface;
48    // The optional <port-component-link> element
49
private String JavaDoc portComponentLink;
50
51    /** Arbitrary proxy properties given by <call-property> */
52    private Properties JavaDoc callProperties;
53
54    public PortComponentRefMetaData(ServiceRefMetaData serviceRefMetaData)
55    {
56       this.serviceRefMetaData = serviceRefMetaData;
57    }
58
59    public ServiceRefMetaData getServiceRefMetaData()
60    {
61       return serviceRefMetaData;
62    }
63
64    /**
65     * The port-component-link element links a port-component-ref
66     * to a specific port-component required to be made available
67     * by a service reference.
68     *
69     * The value of a port-component-link must be the
70     * port-component-name of a port-component in the same module
71     * or another module in the same application unit. The syntax
72     * for specification follows the syntax defined for ejb-link
73     * in the EJB 2.0 specification.
74     */

75    public String JavaDoc getPortComponentLink()
76    {
77       return portComponentLink;
78    }
79
80    public String JavaDoc getServiceEndpointInterface()
81    {
82       return serviceEndpointInterface;
83    }
84
85    public Class JavaDoc getServiceEndpointInterfaceClass()
86    {
87       try
88       {
89          ClassLoader JavaDoc cl = serviceRefMetaData.getResourceCL();
90          return cl.loadClass(serviceEndpointInterface);
91       }
92       catch (ClassNotFoundException JavaDoc e)
93       {
94          throw new JAXRPCException JavaDoc("Cannot load service endpoint interface: " + serviceEndpointInterface);
95       }
96    }
97
98    public Properties JavaDoc getCallProperties()
99    {
100       return callProperties;
101    }
102
103    public void importStandardXml(Element JavaDoc element)
104            throws DeploymentException
105    {
106       serviceEndpointInterface = MetaData.getUniqueChildContent(element, "service-endpoint-interface");
107
108       portComponentLink = MetaData.getOptionalChildContent(element, "port-component-link");
109    }
110
111    public void importJBossXml(Element JavaDoc element) throws DeploymentException
112    {
113       // Look for call-property elements
114
Iterator JavaDoc iterator = MetaData.getChildrenByTagName(element, "call-property");
115       while (iterator.hasNext())
116       {
117          Element JavaDoc propElement = (Element JavaDoc) iterator.next();
118          String JavaDoc name = MetaData.getUniqueChildContent(propElement, "prop-name");
119          String JavaDoc value = MetaData.getUniqueChildContent(propElement, "prop-value");
120          if( callProperties == null )
121             callProperties = new Properties JavaDoc();
122          callProperties.setProperty(name, value);
123       }
124
125    }
126 }
127
Popular Tags