KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > registry > ConnectionFactory


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package javax.xml.registry;
23
24 import java.util.Collection JavaDoc;
25 import java.util.Properties JavaDoc;
26
27 /** This is the abstract base class for factory classes for creating a JAXR
28  * connection. A JAXR ConnectionFactory object is configured in a
29  * provider-specific way to create connections with registry providers.
30  *
31  * Looking Up a ConnectionFactory Using the JNDI API
32  * The preferred way for a client to look up a JAXR ConnectionFactory is within
33  * the Java Naming and Directory InterfaceTM (JNDI) API. A ConnectionFactory
34  * object is registered with a naming service in a provider specific way, such
35  * as one based on the JNDI API. This registration associates the
36  * ConnectionFactory object with a logical name. When an application wants to
37  * establish a connection with the provider associated with that
38  * ConnectionFactory object, it does a lookup, providing the logical name.
39  * The application can then use the ConnectionFactory object that is returned
40  * to create a connection to the messaging provider.
41  *
42  * Looking Up a ConnectionFactory Without Using the JNDI API
43  * The JAXR API provides an alternative way to look up a JAXR ConnectionFactory
44  * that does not require the use of the JNDI API. This is done using the
45  * newInstance static method on the abstract class ConnectionFactory provided
46  * in the JAXR API. The newInstance method returns a JAXR ConnectionFactory.
47  * The client may indicate which factory class should be instantiated by the
48  * newInstance method by defining the system property
49  * javax.xml.registry.ConnectionFactoryClass. If this property is not set,
50  * the JAXR provider must return a default ConnectionFactory instance.
51  *
52  * @author Scott.Stark@jboss.org
53  * @author Farrukh S. Najmi (javadoc)
54  * @version $Revision: 37459 $
55  */

56 public abstract class ConnectionFactory
57 {
58    private static final String JavaDoc SYS_PROP_NAME =
59       "javax.xml.registry.ConnectionFactoryClass";
60
61    public static ConnectionFactory JavaDoc newInstance() throws JAXRException JavaDoc
62    {
63       String JavaDoc factoryName = null;
64       ConnectionFactory JavaDoc factory = null;
65       try
66       {
67          String JavaDoc defaultName = null;
68          factoryName = System.getProperty(SYS_PROP_NAME, defaultName);
69          ClassLoader JavaDoc loader = Thread.currentThread().getContextClassLoader();
70          Class JavaDoc factoryClass = loader.loadClass(factoryName);
71          factory = (ConnectionFactory JavaDoc) factoryClass.newInstance();
72       }
73       catch(Throwable JavaDoc e)
74       {
75          throw new JAXRException JavaDoc("Failed to create instance of: "+factoryName, e);
76       }
77       return factory;
78    }
79
80    public ConnectionFactory()
81    {
82    }
83
84    public abstract Connection JavaDoc createConnection()
85       throws JAXRException JavaDoc;
86    public abstract FederatedConnection JavaDoc createFederatedConnection(Collection JavaDoc connections)
87       throws JAXRException JavaDoc;
88
89    public abstract Properties JavaDoc getProperties()
90       throws JAXRException JavaDoc;
91    /** Sets the Properties used during createConnection and
92     * createFederatedConnection calls.
93     * Standard Connection Properties:
94     * javax.xml.registry.queryManagerURL - URL String for the query manager
95     * service within the target registry provider
96     * javax.xml.registry.lifeCycleManagerURL - URL String for the life cycle
97     * manager service within the target registry provider. If unspecified,
98     * must default to value of the queryManagerURL described above
99     * javax.xml.registry.semanticEquivalences - String that allows
100     * specification of semantic equivalences
101     * javax.xml.registry.security.authenticationMethod - string that provides
102     * a hint to the JAXR provider on the authentication method to be used when
103     * authenticating with the registry provider. Possible value include but
104     * are not limited to "UDDI_GET_AUTHTOKEN", "HTTP_BASIC",
105     * "CLIENT_CERTIFICATE", "MS_PASSPORT"
106     * javax.xml.registry.uddi.maxRows - integer that specifies the maximum
107     * number of rows to be returned for find operations. This property is
108     * specific for UDDI providers
109     * javax.xml.registry.postalAddressScheme - String that specifies the id of
110     * a ClassificationScheme that is used as the default postal address scheme
111     * for this connection
112     * @param factoryProps
113     * @throws JAXRException
114     */

115    public abstract void setProperties(Properties JavaDoc factoryProps)
116       throws JAXRException JavaDoc;
117
118 }
119
Popular Tags