001: /*
002: * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.soap.jaxrpc;
030:
031: import com.caucho.log.Log;
032: import com.caucho.soap.wsdl.WSDLDefinitions;
033: import com.caucho.soap.wsdl.WSDLParser;
034: import com.caucho.util.L10N;
035:
036: import javax.xml.namespace.QName;
037: import javax.xml.rpc.Service;
038: import javax.xml.rpc.ServiceException;
039: import javax.xml.rpc.ServiceFactory;
040: import java.io.InputStream;
041: import java.net.URL;
042: import java.util.Properties;
043: import java.util.logging.Logger;
044:
045: /**
046: * Service factory.
047: */
048: public class ServiceFactoryImpl extends ServiceFactory {
049: private final static Logger log = Log
050: .open(ServiceFactoryImpl.class);
051: private final static L10N L = new L10N(ServiceFactoryImpl.class);
052:
053: /**
054: * Creates a service given a qname.
055: */
056: public Service createService(QName serviceName) {
057: return new ServiceImpl(serviceName);
058: }
059:
060: /**
061: * Creates a service given a WSDL location and a service name.
062: */
063: public Service createService(URL wsdl, QName serviceName)
064: throws ServiceException {
065: /*
066: WSDLDefinitions defs = parseWSDL(wsdl);
067:
068: WSDLService service = defs.getService(serviceName);
069:
070: if (service == null)
071: throw new ServiceException(L.l("'{0}' is an unknown service in {1}.",
072: serviceName, wsdl));
073:
074: return new ServiceImpl(service);
075: */
076: throw new UnsupportedOperationException();
077: }
078:
079: /**
080: * Creates a service given an interface.
081: */
082: public Service loadService(Class serviceInterface) {
083: throw new UnsupportedOperationException();
084: }
085:
086: /**
087: * Creates a service given an interface.
088: */
089: public Service loadService(URL wsdl, Class serviceInterface,
090: Properties properties) throws ServiceException {
091: parseWSDL(wsdl);
092:
093: return new ServiceImpl((QName) null);
094: }
095:
096: /**
097: * Creates a service given an interface.
098: */
099: public Service loadService(URL wsdl, QName serviceName,
100: Properties properties) throws ServiceException {
101: parseWSDL(wsdl);
102:
103: return new ServiceImpl(serviceName);
104: }
105:
106: /**
107: * Parses the wsdl.
108: */
109: private WSDLDefinitions parseWSDL(URL wsdl) throws ServiceException {
110: try {
111: InputStream is = wsdl.openStream();
112: try {
113: return WSDLParser.parse(is);
114: } finally {
115: is.close();
116: }
117: } catch (Exception e) {
118: throw new ServiceException(e);
119: }
120: }
121:
122: /**
123: * Returns the id.
124: */
125: public String toString() {
126: return "ServiceFactoryImpl[]";
127: }
128: }
|