Service Registry 3 2005Q4 Developer's Guide

Creating or Looking Up a Connection Factory

A client creates a connection from a connection factory. This section describes how to obtain a connection factory in two ways:

Obtaining a ConnectionFactory Instance

To use JAXR in a stand-alone client program, you must obtain an instance of the abstract class ConnectionFactory. To do so, call the getConnectionFactory method in the JAXR provider’s JAXRUtility class.

import org.freebxml.omar.client.xml.registry.util.JAXRUtility;
...
ConnectionFactory factory = JAXRUtility.getConnectionFactory();

Looking Up a Connection Factory

A JAXR provider can supply one or more preconfigured connection factories for use in J2EE applications. To obtain these factories, clients look them up using the Java Naming and Directory Interface (JNDI) API.

To use JAXR in a deployed J2EE application, you use a connection factory supplied by the JAXR Resource Adapter (RA). To access the connection factory, you need to use a connector resource whose JNDI name is eis/MYSOAR. The Registry configuration process creates this resource. To look up the connection factory in a J2EE component, use code like the following:

import javax.xml.registry.*;
import javax.naming.*;
...
    Context context = new InitialContext();
    ConnectionFactory connFactory = (ConnectionFactory)
         context.lookup("java:comp/env/eis/MYSOAR");