PortComponentDesc.java

00001 
00027 package org.objectweb.jonas_ws.deployment.api;
00028 
00029 import java.net.URL;
00030 import java.util.Iterator;
00031 import java.util.List;
00032 import java.util.Vector;
00033 
00034 import javax.xml.namespace.QName;
00035 
00036 import org.objectweb.jonas_lib.I18n;
00037 import org.objectweb.jonas_lib.deployment.api.DeploymentDescException;
00038 import org.objectweb.jonas_lib.deployment.api.HandlerDesc;
00039 import org.objectweb.jonas_lib.deployment.xml.Handler;
00040 
00041 import org.objectweb.jonas_ws.deployment.xml.JonasPortComponent;
00042 import org.objectweb.jonas_ws.deployment.xml.PortComponent;
00043 
00044 
00045 
00053 public abstract class PortComponentDesc {
00054 
00058     private static I18n i18n = I18n.getInstance(PortComponentDesc.class);
00059 
00063     private String name;
00064 
00068     private Class sei;
00069 
00073     private String sibLink;
00074 
00078     private String sib;
00079 
00083     private List handlers = new Vector();
00084 
00088     private QName portQName;
00089 
00093     private URL endpoint = null;
00094 
00098     private ServiceDesc parent = null;
00099 
00103     private String endpointURI = null;
00104 
00108     private String mapping = null;
00109 
00113     private String serviceName = null;
00114 
00125     protected PortComponentDesc(ClassLoader jarCL,
00126                                 PortComponent pc,
00127                                 JonasPortComponent jpc,
00128                                 ServiceDesc parent)
00129         throws WSDeploymentDescException {
00130 
00131         this.parent = parent;
00132 
00133         // set name
00134         name = pc.getPortComponentName();
00135         if ("".equals(name)) { //$NON-NLS-1$
00136             String err = getI18n().getMessage("PortComponentDesc.noPCName"); //$NON-NLS-1$
00137             throw new WSDeploymentDescException(err);
00138         }
00139 
00140         // set sei
00141         String seiClassName = pc.getServiceEndpointInterface();
00142         if ("".equals(seiClassName)) { //$NON-NLS-1$
00143             String err = getI18n().getMessage("PortComponentDesc.noInterfaceName"); //$NON-NLS-1$
00144             throw new WSDeploymentDescException(err);
00145         }
00146 
00147         try {
00148             sei = jarCL.loadClass(seiClassName);
00149         } catch (ClassNotFoundException e) {
00150             String err = getI18n().getMessage("PortComponentDesc.loadError", seiClassName); //$NON-NLS-1$
00151             System.out.println("***** used ClassLoader : " + jarCL);
00152             throw new WSDeploymentDescException(err, e);
00153         }
00154 
00155         // set and init handlers
00156         List hl = pc.getHandlerList();
00157         Handler h = null;
00158 
00159         for (int i = 0; i < hl.size(); i++) {
00160             // for each reference, build and add a HandlerDesc Object
00161             if (hl.get(i) != null) {
00162                 // get the standard dd handler
00163                 h = (Handler) hl.get(i);
00164                 // build and add a new handler
00165                 try {
00166                     handlers.add(new HandlerDesc(jarCL, h));
00167                 } catch (DeploymentDescException dde) {
00168                     throw new WSDeploymentDescException(dde);
00169                 }
00170             }
00171         }
00172 
00173         // set portQName
00174         portQName = pc.getWsdlPort().getQName();
00175 
00176         // we have jonas specific infos
00177         if (jpc != null) {
00178             // endpoint URI
00179             endpointURI = jpc.getEndpointURI();
00180 
00181             int lastSlash = endpointURI.lastIndexOf("/"); //$NON-NLS-1$
00182             // create /<mapping>/*
00183             mapping = endpointURI.substring(0, lastSlash + 1) + "*"; //$NON-NLS-1$
00184 
00185             String[] parts = endpointURI.split("/"); //$NON-NLS-1$
00186             // create service-name
00187             serviceName = parts[parts.length - 1];
00188         } else {
00189             // TODO Check this
00190             serviceName = portQName.getLocalPart();
00191         }
00192 
00193 
00194     }
00195 
00201     public ServiceDesc getServiceDesc() {
00202         return parent;
00203     }
00204 
00210     public String getName() {
00211         return name;
00212     }
00213 
00219     public Class getServiceEndpointInterface() {
00220         return sei;
00221     }
00222 
00229     public String getSIBClassname() {
00230         return sib;
00231     }
00232 
00241     protected void setSIBClassname(String sibClassName) {
00242         this.sib = sibClassName;
00243     }
00244 
00250     public QName getQName() {
00251         return portQName;
00252     }
00253 
00259     public List getHandlers() {
00260         return handlers;
00261     }
00262 
00268     public String getSibLink() {
00269         return sibLink;
00270     }
00271 
00277     public abstract boolean hasBeanImpl();
00278 
00284     public abstract boolean hasJaxRpcImpl();
00285 
00291     public URL getEndpointURL() {
00292         return endpoint;
00293     }
00294 
00300     public void setEndpointURL(URL url) {
00301         endpoint = url;
00302     }
00303 
00307     public String getMapping() {
00308         return mapping;
00309     }
00310 
00314     public String getServiceName() {
00315         return serviceName;
00316     }
00317 
00323     public abstract void setDesc(Object desc) throws WSDeploymentDescException;
00324 
00328     public String toString() {
00329 
00330         StringBuffer sb = new StringBuffer();
00331 
00332         sb.append("\n" + getClass().getName()); //$NON-NLS-1$
00333         sb.append("\ngetName()=" + getName()); //$NON-NLS-1$
00334         sb.append("\ngetServiceEndpointInterface()=" + getServiceEndpointInterface()); //$NON-NLS-1$
00335         sb.append("\ngetSibLink()=" + getSibLink()); //$NON-NLS-1$
00336         sb.append("\ngetSIBClassname()=" + getSIBClassname()); //$NON-NLS-1$
00337         sb.append("\ngetQName()=" + getQName()); //$NON-NLS-1$
00338 
00339         for (Iterator i = getHandlers().iterator(); i.hasNext();) {
00340             sb.append("\ngetHandlers()=" + ((Handler) i.next()).toString()); //$NON-NLS-1$
00341         }
00342 
00343         return sb.toString();
00344 
00345     }
00346 
00350     public String getSib() {
00351         return sib;
00352     }
00353 
00357     public void setSib(String sib) {
00358         this.sib = sib;
00359     }
00360 
00364     public void setSibLink(String sibLink) {
00365         this.sibLink = sibLink;
00366     }
00367 
00371     public static I18n getI18n() {
00372         return i18n;
00373     }
00374 
00378     public String getEndpointURI() {
00379         return endpointURI;
00380     }
00381 }

Generated on Tue Feb 15 15:05:59 2005 for JOnAS by  doxygen 1.3.9.1