JAXR Programming
So
far in this chapter, you have seen the JAXR registry information
model, which is mapped to the
javax.xml.registry.infomodel
package. This section
looks at the API that allows you to search or update a registry,
which is defined in the package
javax.xml.registry
. The examples shown in this
section assume that you have installed the sample registry data in
either a UDDI or ebXML registry, as described in Section 7.3, earlier in this chapter.
Connecting to the Registry
In order to use a registry, you first have to create a connection to it. This process requires two steps:
Obtain a
ConnectionFactory
object and optionally set properties that determine how it will behave.Use the
ConnectionFactory
object to obtain aConnection
orFederatedConnection
to the target registry.
There are two ways to get a
ConnectionFactory
object. In a J2EE environment, the preferred way is to use the JNDI
API to look up a preconfigured ConnectionFactory
:
InitialContext ctx = new InitialContext( ); ConnectionFactory factory = (ConnectionFactory)ctx.lookup("pathToFactory");
J2SE-based registry clients that do not have a preconfigured JNDI
environment can instead use the static newInstance( )
method:
ConnectionFactory factory = ConnectionFactory.newInstance( );
ConnectionFactory
is an abstract class. The actual
class of the object returned by the newInstance( )
method is determined by the property
javax.xml.registry.ConnectionFactoryClass
, which can be set in either of the following locations (in ...
Get Java Web Services in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.