View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package javax.xml.rpc;
17  
18  import javax.xml.namespace.QName;
19  import java.net.URL;
20  
21  /**
22   * The <code>javax.xml.rpc.ServiceFactory</code> is an abstract class
23   * that provides a factory for the creation of instances of the type
24   * <code>javax.xml.rpc.Service</code>. This abstract class follows the
25   * abstract static factory design pattern. This enables a J2SE based
26   * client to create a <code>Service instance</code> in a portable manner
27   * without using the constructor of the <code>Service</code>
28   * implementation class.
29   * <p>
30   * The ServiceFactory implementation class is set using the
31   * system property <code>SERVICEFACTORY_PROPERTY</code>.
32   *
33   * @version 1.0
34   */
35  public abstract class ServiceFactory {
36  
37      /** Protected constructor. */
38      protected ServiceFactory() {}
39  
40      /**
41       * A constant representing the property used to lookup the
42       * name of a <code>ServiceFactory</code> implementation
43       * class.
44       */
45      public static final java.lang.String SERVICEFACTORY_PROPERTY =
46          "javax.xml.rpc.ServiceFactory";
47  
48      /**
49       * Gets an instance of the <code>ServiceFactory</code>
50       *
51       * <p>Only one copy of a factory exists and is returned to the
52       * application each time this method is called.
53       *
54       * <p> The implementation class to be used can be overridden by
55       * setting the javax.xml.rpc.ServiceFactory system property.
56       *
57       * @return  ServiceFactory.
58       * @throws  ServiceException
59       */
60      public static ServiceFactory newInstance() throws ServiceException {
61  
62          try {
63              return (ServiceFactory) FactoryFinder.find(
64                  /* The default property name according to the JAXRPC spec */
65                  SERVICEFACTORY_PROPERTY,
66                  /* The fallback implementation class name */
67                  "org.apache.axis.client.ServiceFactory");
68          } catch (FactoryFinder.ConfigurationError e) {
69              throw new ServiceException(e.getException());
70          }
71      }
72  
73      /**
74       * Create a <code>Service</code> instance.
75       *
76       * @param   wsdlDocumentLocation URL for the WSDL document location
77       * @param   serviceName  QName for the service.
78       * @return  Service.
79       * @throws  ServiceException If any error in creation of the
80       *                specified service
81       */
82      public abstract Service createService(
83          URL wsdlDocumentLocation, QName serviceName) throws ServiceException;
84  
85      /**
86       * Create a <code>Service</code> instance.
87       *
88       * @param   serviceName QName for the service
89       * @return  Service.
90       * @throws  ServiceException If any error in creation of the specified service
91       */
92      public abstract Service createService(QName serviceName)
93          throws ServiceException;
94      
95      public abstract Service loadService(java.lang.Class class1)
96                               throws ServiceException;
97      
98      public abstract Service loadService(java.net.URL url,
99                                      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