KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > soap > jaxws > ServiceDelegateImpl


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.soap.jaxws;
31
32 import com.caucho.soap.reflect.WebServiceIntrospector;
33 import com.caucho.soap.skeleton.Skeleton;
34 import com.caucho.util.L10N;
35
36 import javax.xml.bind.JAXBContext;
37 import javax.xml.namespace.QName JavaDoc;
38 import javax.xml.ws.BindingProvider;
39 import javax.xml.ws.Dispatch;
40 import javax.xml.ws.Service;
41 import javax.xml.ws.handler.HandlerResolver;
42 import javax.xml.ws.spi.ServiceDelegate;
43 import java.lang.reflect.Proxy JavaDoc;
44 import java.net.URL JavaDoc;
45 import java.util.Iterator JavaDoc;
46 import java.util.concurrent.Executor JavaDoc;
47 import java.util.logging.Logger JavaDoc;
48
49 /**
50  * ServiceDelegate
51  */

52 public class ServiceDelegateImpl extends ServiceDelegate {
53   private final static Logger JavaDoc log
54     = Logger.getLogger(ServiceDelegateImpl.class.getName());
55   private final static L10N L = new L10N(ServiceDelegateImpl.class);
56
57   private final ClassLoader JavaDoc _classLoader;
58
59   private final URL JavaDoc _wsdl;
60   private final QName JavaDoc _serviceName;
61   private final Class JavaDoc _serviceClass;
62
63   ServiceDelegateImpl(URL JavaDoc wsdl, QName JavaDoc serviceName, Class JavaDoc serviceClass)
64   {
65     _classLoader = Thread.currentThread().getContextClassLoader();
66     
67     _wsdl = wsdl;
68     _serviceName = serviceName;
69     _serviceClass = serviceClass;
70   }
71
72   public void addPort(QName JavaDoc portName,
73               String JavaDoc bindingId,
74               String JavaDoc endpointAddress)
75   {
76     throw new UnsupportedOperationException JavaDoc();
77   }
78
79   public <T> Dispatch<T> createDispatch(QName JavaDoc portName,
80                     Class JavaDoc<T> type,
81                     Service.Mode mode)
82   {
83     throw new UnsupportedOperationException JavaDoc();
84   }
85
86
87   public Dispatch<Object JavaDoc> createDispatch(QName JavaDoc portName,
88                      JAXBContext context,
89                      Service.Mode mode)
90   {
91     throw new UnsupportedOperationException JavaDoc();
92   }
93
94   public Executor JavaDoc getExecutor()
95   {
96     throw new UnsupportedOperationException JavaDoc();
97   }
98
99   public HandlerResolver getHandlerResolver()
100   {
101     throw new UnsupportedOperationException JavaDoc();
102   }
103
104   public <T> T getPort(Class JavaDoc<T> serviceEndpointInterface)
105   {
106     return getPort(null, serviceEndpointInterface);
107   }
108
109   public <T> T getPort(QName JavaDoc portName, Class JavaDoc<T> api)
110   {
111     try {
112       String JavaDoc url = null;
113
114       if (portName != null)
115     url = portName.getNamespaceURI();
116
117       if (url == null)
118         url = _serviceName.getNamespaceURI();
119       
120       Skeleton skeleton = new WebServiceIntrospector().introspect(api, url);
121
122       //System.out.println("PROXY: PORT:" + portName + " SERV:" + _serviceName + " " + _wsdl);
123

124       PortProxyHandler handler = new PortProxyHandler(skeleton, url);
125
126       return (T) Proxy.newProxyInstance(_classLoader,
127                     new Class JavaDoc[] { api,
128                               BindingProvider.class },
129                     handler);
130     } catch (RuntimeException JavaDoc e) {
131       throw e;
132     } catch (Exception JavaDoc e) {
133       // XXX:
134
throw new RuntimeException JavaDoc(e);
135     }
136   }
137
138   public Iterator JavaDoc<QName JavaDoc> getPorts()
139   {
140     throw new UnsupportedOperationException JavaDoc();
141   }
142
143   public QName JavaDoc getServiceName()
144   {
145     return _serviceName;
146   }
147
148
149   public URL JavaDoc getWSDLDocumentLocation()
150   {
151     return _wsdl;
152   }
153
154   public void setExecutor(Executor JavaDoc executor)
155   {
156   }
157
158   public void setHandlerResolver(HandlerResolver handlerResolver)
159   {
160   }
161
162   public String JavaDoc toString()
163   {
164     return ("ServiceDelegateImpl[" + getServiceName().getNamespaceURI()
165         + "," + getServiceName().getLocalPart() + "]");
166   }
167 }
168
Popular Tags