KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > soap > jaxrpc > ServiceFactoryImpl


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  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.soap.jaxrpc;
30
31 import com.caucho.log.Log;
32 import com.caucho.soap.wsdl.WSDLDefinitions;
33 import com.caucho.soap.wsdl.WSDLParser;
34 import com.caucho.util.L10N;
35
36 import javax.xml.namespace.QName JavaDoc;
37 import javax.xml.rpc.Service JavaDoc;
38 import javax.xml.rpc.ServiceException JavaDoc;
39 import javax.xml.rpc.ServiceFactory JavaDoc;
40 import java.io.InputStream JavaDoc;
41 import java.net.URL JavaDoc;
42 import java.util.Properties JavaDoc;
43 import java.util.logging.Logger JavaDoc;
44
45 /**
46  * Service factory.
47  */

48 public class ServiceFactoryImpl extends ServiceFactory JavaDoc {
49   private final static Logger JavaDoc log = Log.open(ServiceFactoryImpl.class);
50   private final static L10N L = new L10N(ServiceFactoryImpl.class);
51   
52   /**
53    * Creates a service given a qname.
54    */

55   public Service JavaDoc createService(QName JavaDoc serviceName)
56   {
57     return new ServiceImpl(serviceName);
58   }
59   
60   /**
61    * Creates a service given a WSDL location and a service name.
62    */

63   public Service JavaDoc createService(URL JavaDoc wsdl, QName JavaDoc serviceName)
64     throws ServiceException JavaDoc
65   {
66     /*
67     WSDLDefinitions defs = parseWSDL(wsdl);
68
69     WSDLService service = defs.getService(serviceName);
70
71     if (service == null)
72       throw new ServiceException(L.l("'{0}' is an unknown service in {1}.",
73                                      serviceName, wsdl));
74
75     return new ServiceImpl(service);
76     */

77     throw new UnsupportedOperationException JavaDoc();
78   }
79   
80   /**
81    * Creates a service given an interface.
82    */

83   public Service JavaDoc loadService(Class JavaDoc serviceInterface)
84   {
85     throw new UnsupportedOperationException JavaDoc();
86   }
87   
88   /**
89    * Creates a service given an interface.
90    */

91   public Service JavaDoc loadService(URL JavaDoc wsdl,
92                              Class JavaDoc serviceInterface,
93                              Properties JavaDoc properties)
94     throws ServiceException JavaDoc
95   {
96     parseWSDL(wsdl);
97
98     return new ServiceImpl((QName JavaDoc) null);
99   }
100   
101   /**
102    * Creates a service given an interface.
103    */

104   public Service JavaDoc loadService(URL JavaDoc wsdl,
105                              QName JavaDoc serviceName,
106                              Properties JavaDoc properties)
107     throws ServiceException JavaDoc
108   {
109     parseWSDL(wsdl);
110     
111     return new ServiceImpl(serviceName);
112   }
113
114   /**
115    * Parses the wsdl.
116    */

117   private WSDLDefinitions parseWSDL(URL JavaDoc wsdl)
118     throws ServiceException JavaDoc
119   {
120     try {
121       InputStream JavaDoc is = wsdl.openStream();
122       try {
123         return WSDLParser.parse(is);
124       } finally {
125         is.close();
126       }
127     } catch (Exception JavaDoc e) {
128       throw new ServiceException JavaDoc(e);
129     }
130   }
131
132   /**
133    * Returns the id.
134    */

135   public String JavaDoc toString()
136   {
137     return "ServiceFactoryImpl[]";
138   }
139 }
140
141
142
Popular Tags