001    /*
002     * Copyright 2001-2004 The Apache Software Foundation.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package javax.xml.rpc;
017    
018    import javax.xml.namespace.QName;
019    import java.net.URL;
020    
021    /**
022     * The <code>javax.xml.rpc.ServiceFactory</code> is an abstract class
023     * that provides a factory for the creation of instances of the type
024     * <code>javax.xml.rpc.Service</code>. This abstract class follows the
025     * abstract static factory design pattern. This enables a J2SE based
026     * client to create a <code>Service instance</code> in a portable manner
027     * without using the constructor of the <code>Service</code>
028     * implementation class.
029     * <p>
030     * The ServiceFactory implementation class is set using the
031     * system property <code>SERVICEFACTORY_PROPERTY</code>.
032     *
033     * @version 1.0
034     */
035    public abstract class ServiceFactory {
036    
037        /** Protected constructor. */
038        protected ServiceFactory() {}
039    
040        /**
041         * A constant representing the property used to lookup the
042         * name of a <code>ServiceFactory</code> implementation
043         * class.
044         */
045        public static final java.lang.String SERVICEFACTORY_PROPERTY =
046            "javax.xml.rpc.ServiceFactory";
047    
048        /**
049         * Gets an instance of the <code>ServiceFactory</code>
050         *
051         * <p>Only one copy of a factory exists and is returned to the
052         * application each time this method is called.
053         *
054         * <p> The implementation class to be used can be overridden by
055         * setting the javax.xml.rpc.ServiceFactory system property.
056         *
057         * @return  ServiceFactory.
058         * @throws  ServiceException
059         */
060        public static ServiceFactory newInstance() throws ServiceException {
061    
062            try {
063                return (ServiceFactory) FactoryFinder.find(
064                    /* The default property name according to the JAXRPC spec */
065                    SERVICEFACTORY_PROPERTY,
066                    /* The fallback implementation class name */
067                    "org.apache.axis.client.ServiceFactory");
068            } catch (FactoryFinder.ConfigurationError e) {
069                throw new ServiceException(e.getException());
070            }
071        }
072    
073        /**
074         * Create a <code>Service</code> instance.
075         *
076         * @param   wsdlDocumentLocation URL for the WSDL document location
077         * @param   serviceName  QName for the service.
078         * @return  Service.
079         * @throws  ServiceException If any error in creation of the
080         *                specified service
081         */
082        public abstract Service createService(
083            URL wsdlDocumentLocation, QName serviceName) throws ServiceException;
084    
085        /**
086         * Create a <code>Service</code> instance.
087         *
088         * @param   serviceName QName for the service
089         * @return  Service.
090         * @throws  ServiceException If any error in creation of the specified service
091         */
092        public abstract Service createService(QName serviceName)
093            throws ServiceException;
094        
095        public abstract Service loadService(java.lang.Class class1)
096                                 throws ServiceException;
097        
098        public abstract Service loadService(java.net.URL url,
099                                        java.lang.Class class1,
100                                        java.util.Properties properties)
101                                 throws ServiceException;
102        
103        public abstract Service loadService(java.net.URL url,
104                                        QName qname,
105                                        java.util.Properties properties)
106                                 throws ServiceException;
107    }
108