KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ws > deployment > api > PortComponentRefDesc


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial Developer : Delplanque Xavier & Sauthier Guillaume
22  * --------------------------------------------------------------------------
23  * $Id: PortComponentRefDesc.java,v 1.6 2005/01/03 14:57:14 sauthieg Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas_ws.deployment.api;
28
29 import java.util.Iterator JavaDoc;
30 import java.util.Properties JavaDoc;
31
32 import javax.xml.namespace.QName JavaDoc;
33
34 import org.objectweb.jonas_lib.I18n;
35 import org.objectweb.jonas_lib.deployment.xml.JonasCallProperty;
36 import org.objectweb.jonas_lib.deployment.xml.JonasPortComponentRef;
37 import org.objectweb.jonas_lib.deployment.xml.JonasStubProperty;
38 import org.objectweb.jonas_lib.deployment.xml.PortComponentRef;
39
40 /**
41  * The PortComponentRefDesc associate a service-endpoint-interface with a
42  * port-component in the same application unit.
43  * @author Guillaume Sauthier
44  * @author Xavier Delplanque
45  */

46 public class PortComponentRefDesc {
47
48     /** The service-endpoint-interface matching the WSDL port */
49     private Class JavaDoc sei;
50
51     /** The PortComponent link Name */
52     private String JavaDoc pcLink = null;
53
54     /** The PortComponent link */
55     private PortComponentDesc pcDesc = null;
56
57     /**
58      * Stub properties
59      */

60     private Properties JavaDoc stubProperties = null;
61
62     /**
63      * Call properties
64      */

65     private Properties JavaDoc callProperties = null;
66
67     /**
68      * wsdl:port to be used when invoking Service.getPort(Class sei)
69      */

70     private QName JavaDoc wsdlPort = null;
71
72     /**
73      * Internationalization
74      */

75     private static I18n i18n = I18n.getInstance(PortComponentRefDesc.class);
76
77     /**
78      * Creates a new PortComponentRefDesc object.
79      * @param classLoader module class loader (web or ejb)
80      * @param pcr port component ref generate by Zeus, defined in web deployment
81      * desc
82      * @param jpcr jonas port component ref generate by Zeus, defined in web deployment
83      * desc
84      * @throws WSDeploymentDescException if service endpoint class doesn't exist
85      */

86     public PortComponentRefDesc(ClassLoader JavaDoc classLoader, PortComponentRef pcr, JonasPortComponentRef jpcr) throws WSDeploymentDescException {
87
88         String JavaDoc className = null;
89         stubProperties = new Properties JavaDoc();
90         callProperties = new Properties JavaDoc();
91
92         try {
93             // load service endpoint interface
94
className = pcr.getServiceEndpointInterface().trim();
95             sei = classLoader.loadClass(className);
96
97             // get port link if any
98
if (pcr.getPortComponentLink() != null) {
99                 pcLink = pcr.getPortComponentLink().trim();
100             }
101
102             // load properties
103
if (jpcr != null) {
104                 for (Iterator JavaDoc i = jpcr.getJonasCallPropertyList().iterator(); i.hasNext();) {
105                     JonasCallProperty jp = (JonasCallProperty) i.next();
106                     callProperties.setProperty(jp.getParamName(), jp.getParamValue());
107                 }
108                 for (Iterator JavaDoc i = jpcr.getJonasStubPropertyList().iterator(); i.hasNext();) {
109                     JonasStubProperty jp = (JonasStubProperty) i.next();
110                     stubProperties.setProperty(jp.getParamName(), jp.getParamValue());
111                 }
112                 if (jpcr.getWsdlPort() != null) {
113                     wsdlPort = jpcr.getWsdlPort().getQName();
114                 }
115             }
116         } catch (ClassNotFoundException JavaDoc e) {
117             throw new WSDeploymentDescException(getI18n().getMessage("PortComponentRefDesc.seiNotFound", className), e); //$NON-NLS-1$
118
}
119     }
120
121     /**
122      * Return the port Component Link Object. May be null if not defined
123      * @return the port Component Link Object.
124      */

125     public String JavaDoc getPortComponentLink() {
126         return pcLink;
127     }
128
129     /**
130      * Set the pcLink port component desc
131      * @param pcd the portComponentDesc linked with this PortcompRef.
132      */

133     public void setPortComponentDesc(PortComponentDesc pcd) {
134         pcDesc = pcd;
135     }
136
137     /**
138      * Return the linked port component desc (can be null if no pcLink).
139      * @return the linked port component desc. (null if no pcLink)
140      */

141     public PortComponentDesc getPortComponentDesc() {
142         return pcDesc;
143     }
144
145     /**
146      * Return the Service Endpoint Interface of the Port Component.
147      * @return the Service Endpoint Interface of the Port Component.
148      */

149     public Class JavaDoc getSEI() {
150         return sei;
151     }
152
153     /**
154      * @see java.lang.String#hashCode()
155      */

156     public int hashCode() {
157         return sei.getName().hashCode();
158     }
159
160     /**
161      * Return true if the 2 objects are equals in value.
162      * @param other the object to compare.
163      * @return true if the 2 objects are equals in value, else false.
164      */

165     public boolean equals(Object JavaDoc other) {
166         if (other == null) {
167             return false;
168         }
169
170         if (!(other instanceof PortComponentRefDesc)) {
171             return false;
172         }
173
174         PortComponentRefDesc ref = (PortComponentRefDesc) other;
175
176         if (!sei.getName().equals(ref.getSEI().getName())) {
177             return false;
178         }
179
180         if (!pcLink.equals(ref.getPortComponentLink())) {
181             return false;
182         }
183
184         // After all theses tests, the 2 objects are equals in value
185
return true;
186     }
187
188     /**
189      * @return Returns the i18n.
190      */

191     protected static I18n getI18n() {
192         return i18n;
193     }
194
195     /**
196      * @return Returns the callProperties.
197      */

198     public Properties JavaDoc getCallProperties() {
199         return callProperties;
200     }
201
202     /**
203      * @return Returns the stubProperties.
204      */

205     public Properties JavaDoc getStubProperties() {
206         return stubProperties;
207     }
208
209     /**
210      * @return Returns the wsdlPort.
211      */

212     public QName JavaDoc getWsdlPort() {
213         return wsdlPort;
214     }
215 }
Popular Tags