Service Registry 3 2005Q4 Developer's Guide

Establishing a Connection to the Registry

The first task that a JAXR client must complete is to establish a connection to a registry. Establishment of a connection involves the following tasks:

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");

Creating a Connection

To create a connection, a client first creates a set of properties that specify the URL or URLs of the registry or registries to be accessed. The following code provides the URLs of the query service and publishing service for the Registry if the Registry is deployed on the local system. (The strings should have no line breaks.)

Properties props = new Properties();
props.setProperty("javax.xml.registry.queryManagerURL",
    "http://localhost:6060/soar/registry/soap");
props.setProperty("javax.xml.registry.lifeCycleManagerURL",
    "http://localhost:6060/soar/registry/soap");

The client then obtains the connection factory as described in Creating or Looking Up a Connection Factory, sets its properties, and creates the connection. The following code fragment performs these tasks:

ConnectionFactory factory =
     JAXRUtility.getConnectionFactory();
factory.setProperties(props);
Connection connection = factory.createConnection();

The makeConnection method in the sample programs shows the steps used to create a JAXR connection.

Creating a Connection lists and describes the two properties that you can set on a connection. These properties are defined in the JAXR specification.

Table 2–1 Standard JAXR Connection Properties

Property Name and Description 

Data Type 

Default Value 

javax.xml.registry.queryManagerURL

Specifies the URL of the query manager service within the target registry provider. 

String 

None 

javax.xml.registry.lifeCycleManagerURL

Specifies the URL of the life-cycle manager service within the target registry provider (for registry updates). 

String 

Same as the specified queryManagerURL value