applied copyright 2008
[jalview.git] / src / ext / vamsas / JpredServiceLocator.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3  * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  * 
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18  */
19 package ext.vamsas;
20
21 public class JpredServiceLocator
22     extends org.apache.axis.client.Service implements ext.vamsas.JpredService
23 {
24
25   public JpredServiceLocator()
26   {
27   }
28
29   public JpredServiceLocator(org.apache.axis.EngineConfiguration config)
30   {
31     super(config);
32   }
33
34   // Use to get a proxy class for jpred
35   private java.lang.String jpred_address =
36       "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred";
37
38   public java.lang.String getjpredAddress()
39   {
40     return jpred_address;
41   }
42
43   // The WSDD service name defaults to the port name.
44   private java.lang.String jpredWSDDServiceName = "jpred";
45
46   public java.lang.String getjpredWSDDServiceName()
47   {
48     return jpredWSDDServiceName;
49   }
50
51   public void setjpredWSDDServiceName(java.lang.String name)
52   {
53     jpredWSDDServiceName = name;
54   }
55
56   public ext.vamsas.Jpred getjpred()
57       throws javax.xml.rpc.ServiceException
58   {
59     java.net.URL endpoint;
60     try
61     {
62       endpoint = new java.net.URL(jpred_address);
63     }
64     catch (java.net.MalformedURLException e)
65     {
66       throw new javax.xml.rpc.ServiceException(e);
67     }
68     return getjpred(endpoint);
69   }
70
71   public ext.vamsas.Jpred getjpred(java.net.URL portAddress)
72       throws javax.xml.rpc.ServiceException
73   {
74     try
75     {
76       ext.vamsas.JpredSoapBindingStub _stub = new ext.vamsas.
77           JpredSoapBindingStub(portAddress, this);
78       _stub.setPortName(getjpredWSDDServiceName());
79       return _stub;
80     }
81     catch (org.apache.axis.AxisFault e)
82     {
83       return null;
84     }
85   }
86
87   public void setjpredEndpointAddress(java.lang.String address)
88   {
89     jpred_address = address;
90   }
91
92   /**
93    * For the given interface, get the stub implementation.
94    * If this service has no port for the given interface,
95    * then ServiceException is thrown.
96    */
97   public java.rmi.Remote getPort(Class serviceEndpointInterface)
98       throws javax.xml.rpc.ServiceException
99   {
100     try
101     {
102       if (ext.vamsas.Jpred.class.isAssignableFrom(serviceEndpointInterface))
103       {
104         ext.vamsas.JpredSoapBindingStub _stub = new ext.vamsas.
105             JpredSoapBindingStub(new java.net.URL(jpred_address), this);
106         _stub.setPortName(getjpredWSDDServiceName());
107         return _stub;
108       }
109     }
110     catch (java.lang.Throwable t)
111     {
112       throw new javax.xml.rpc.ServiceException(t);
113     }
114     throw new javax.xml.rpc.ServiceException(
115         "There is no stub implementation for the interface:  " +
116         (serviceEndpointInterface == null ? "null" :
117          serviceEndpointInterface.getName()));
118   }
119
120   /**
121    * For the given interface, get the stub implementation.
122    * If this service has no port for the given interface,
123    * then ServiceException is thrown.
124    */
125   public java.rmi.Remote getPort(javax.xml.namespace.QName portName,
126                                  Class serviceEndpointInterface)
127       throws javax.xml.rpc.ServiceException
128   {
129     if (portName == null)
130     {
131       return getPort(serviceEndpointInterface);
132     }
133     java.lang.String inputPortName = portName.getLocalPart();
134     if ("jpred".equals(inputPortName))
135     {
136       return getjpred();
137     }
138     else
139     {
140       java.rmi.Remote _stub = getPort(serviceEndpointInterface);
141       ( (org.apache.axis.client.Stub) _stub).setPortName(portName);
142       return _stub;
143     }
144   }
145
146   public javax.xml.namespace.QName getServiceName()
147   {
148     return new javax.xml.namespace.QName("vamsas", "jpredService");
149   }
150
151   private java.util.HashSet ports = null;
152
153   public java.util.Iterator getPorts()
154   {
155     if (ports == null)
156     {
157       ports = new java.util.HashSet();
158       ports.add(new javax.xml.namespace.QName("vamsas", "jpred"));
159     }
160     return ports.iterator();
161   }
162
163   /**
164    * Set the endpoint address for the specified port name.
165    */
166   public void setEndpointAddress(java.lang.String portName,
167                                  java.lang.String address)
168       throws javax.xml.rpc.ServiceException
169   {
170     if ("jpred".equals(portName))
171     {
172       setjpredEndpointAddress(address);
173     }
174     else
175     { // Unknown Port Name
176       throw new javax.xml.rpc.ServiceException(
177           " Cannot set Endpoint Address for Unknown Port" + portName);
178     }
179   }
180
181   /**
182    * Set the endpoint address for the specified port name.
183    */
184   public void setEndpointAddress(javax.xml.namespace.QName portName,
185                                  java.lang.String address)
186       throws javax.xml.rpc.ServiceException
187   {
188     setEndpointAddress(portName.getLocalPart(), address);
189   }
190
191 }