001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * Initial Developer : Delplanque Xavier & Sauthier Guillaume
022: * --------------------------------------------------------------------------
023: * $Id: PortComponentRefDesc.java 6038 2005-01-03 14:57:14Z sauthieg $
024: * --------------------------------------------------------------------------
025: */package org.objectweb.jonas_ws.deployment.api;
026:
027: import java.util.Iterator;
028: import java.util.Properties;
029:
030: import javax.xml.namespace.QName;
031:
032: import org.objectweb.jonas_lib.I18n;
033: import org.objectweb.jonas_lib.deployment.xml.JonasCallProperty;
034: import org.objectweb.jonas_lib.deployment.xml.JonasPortComponentRef;
035: import org.objectweb.jonas_lib.deployment.xml.JonasStubProperty;
036: import org.objectweb.jonas_lib.deployment.xml.PortComponentRef;
037:
038: /**
039: * The PortComponentRefDesc associate a service-endpoint-interface with a
040: * port-component in the same application unit.
041: * @author Guillaume Sauthier
042: * @author Xavier Delplanque
043: */
044: public class PortComponentRefDesc {
045:
046: /** The service-endpoint-interface matching the WSDL port */
047: private Class sei;
048:
049: /** The PortComponent link Name */
050: private String pcLink = null;
051:
052: /** The PortComponent link */
053: private PortComponentDesc pcDesc = null;
054:
055: /**
056: * Stub properties
057: */
058: private Properties stubProperties = null;
059:
060: /**
061: * Call properties
062: */
063: private Properties callProperties = null;
064:
065: /**
066: * wsdl:port to be used when invoking Service.getPort(Class sei)
067: */
068: private QName wsdlPort = null;
069:
070: /**
071: * Internationalization
072: */
073: private static I18n i18n = I18n
074: .getInstance(PortComponentRefDesc.class);
075:
076: /**
077: * Creates a new PortComponentRefDesc object.
078: * @param classLoader module class loader (web or ejb)
079: * @param pcr port component ref generate by Zeus, defined in web deployment
080: * desc
081: * @param jpcr jonas port component ref generate by Zeus, defined in web deployment
082: * desc
083: * @throws WSDeploymentDescException if service endpoint class doesn't exist
084: */
085: public PortComponentRefDesc(ClassLoader classLoader,
086: PortComponentRef pcr, JonasPortComponentRef jpcr)
087: throws WSDeploymentDescException {
088:
089: String className = null;
090: stubProperties = new Properties();
091: callProperties = new Properties();
092:
093: try {
094: // load service endpoint interface
095: className = pcr.getServiceEndpointInterface().trim();
096: sei = classLoader.loadClass(className);
097:
098: // get port link if any
099: if (pcr.getPortComponentLink() != null) {
100: pcLink = pcr.getPortComponentLink().trim();
101: }
102:
103: // load properties
104: if (jpcr != null) {
105: for (Iterator i = jpcr.getJonasCallPropertyList()
106: .iterator(); i.hasNext();) {
107: JonasCallProperty jp = (JonasCallProperty) i.next();
108: callProperties.setProperty(jp.getParamName(), jp
109: .getParamValue());
110: }
111: for (Iterator i = jpcr.getJonasStubPropertyList()
112: .iterator(); i.hasNext();) {
113: JonasStubProperty jp = (JonasStubProperty) i.next();
114: stubProperties.setProperty(jp.getParamName(), jp
115: .getParamValue());
116: }
117: if (jpcr.getWsdlPort() != null) {
118: wsdlPort = jpcr.getWsdlPort().getQName();
119: }
120: }
121: } catch (ClassNotFoundException e) {
122: throw new WSDeploymentDescException(getI18n().getMessage(
123: "PortComponentRefDesc.seiNotFound", className), e); //$NON-NLS-1$
124: }
125: }
126:
127: /**
128: * Return the port Component Link Object. May be null if not defined
129: * @return the port Component Link Object.
130: */
131: public String getPortComponentLink() {
132: return pcLink;
133: }
134:
135: /**
136: * Set the pcLink port component desc
137: * @param pcd the portComponentDesc linked with this PortcompRef.
138: */
139: public void setPortComponentDesc(PortComponentDesc pcd) {
140: pcDesc = pcd;
141: }
142:
143: /**
144: * Return the linked port component desc (can be null if no pcLink).
145: * @return the linked port component desc. (null if no pcLink)
146: */
147: public PortComponentDesc getPortComponentDesc() {
148: return pcDesc;
149: }
150:
151: /**
152: * Return the Service Endpoint Interface of the Port Component.
153: * @return the Service Endpoint Interface of the Port Component.
154: */
155: public Class getSEI() {
156: return sei;
157: }
158:
159: /**
160: * @see java.lang.String#hashCode()
161: */
162: public int hashCode() {
163: return sei.getName().hashCode();
164: }
165:
166: /**
167: * Return true if the 2 objects are equals in value.
168: * @param other the object to compare.
169: * @return true if the 2 objects are equals in value, else false.
170: */
171: public boolean equals(Object other) {
172: if (other == null) {
173: return false;
174: }
175:
176: if (!(other instanceof PortComponentRefDesc)) {
177: return false;
178: }
179:
180: PortComponentRefDesc ref = (PortComponentRefDesc) other;
181:
182: if (!sei.getName().equals(ref.getSEI().getName())) {
183: return false;
184: }
185:
186: if (!pcLink.equals(ref.getPortComponentLink())) {
187: return false;
188: }
189:
190: // After all theses tests, the 2 objects are equals in value
191: return true;
192: }
193:
194: /**
195: * @return Returns the i18n.
196: */
197: protected static I18n getI18n() {
198: return i18n;
199: }
200:
201: /**
202: * @return Returns the callProperties.
203: */
204: public Properties getCallProperties() {
205: return callProperties;
206: }
207:
208: /**
209: * @return Returns the stubProperties.
210: */
211: public Properties getStubProperties() {
212: return stubProperties;
213: }
214:
215: /**
216: * @return Returns the wsdlPort.
217: */
218: public QName getWsdlPort() {
219: return wsdlPort;
220: }
221: }
|