Software AG Products 10.7 | CentraSite for Developers | API for JAXR | Creating a JAXR-based Connection
 
Creating a JAXR-based Connection
*To create a JAXR-based connection
1. Ensure that the CLASSPATH includes directories that contain all JAR files in the CentraSite redist folder.
Note:
If you have activated an e-mail policy, the CLASSPATH must additionally include the file mail.jar, which you can find in the rts/bin folder.
2. Do one of the following:
*Start your client program with the parameter:
-Djavax.xml.registry.ConnectionFactoryClass=com.centrasite.jaxr.
ConnectionFactoryImpl
*Set this property during program startup:
System.setProperty("javax.xml.registry.ConnectionFactoryClass",
"com.centrasite.jaxr.ConnectionFactoryImpl");
3. Create a factory by running the command connFactory, along with the appropriate code snippet:
ConnectionFactory connFactory = ConnectionFactory.newInstance();
4. Supply the queryManagerURL to the connection.
Properties p = new Properties();
p.setProperty("javax.xml.registry.queryManagerURL",
"http://localhost:53307/CentraSite/CentraSite");
Note: 
*In CentraSite, the lifeCycleManagerURL is always the same as the queryManagerURL, hence it need not be specified.
*The port number, in the example above specified as 53307, may need to be changed to suit your local configuration.
5. Set the BrowserBehaviour option.
p.setProperty("com.centrasite.jaxr.BrowserBehaviour", "yes");
connFactory.setProperties(p);
Enabling BrowserBehaviour mode is the preferred way of creating a JAXR-based connection. This is beneficial for several reasons. The BrowserBehaviour mode uses a less strict locking pattern, and this can result in an increased number of parallel read and update operations. For example in CentraSite Control, while one user is looking at some asset, another user can update the same asset in parallel. In the same scenario without BrowserBehaviour, the update would fail as the necessary lock cannot not be granted.
Moreover, with BrowserBehaviour mode, the assets cached on the client side are refreshed often. After an asset is read, it is refreshed in the cache if it is returned as the result of a subsequent query with a newer timestamp.
6. Create the connection and set the user credentials. The setCredentials() method expects a Set containing a java.net.PasswordAuthentication object.
Connection connection = connFactory.createConnection();
 
HashSet credentials = new HashSet(1);
credentials.add(new PasswordAuthentication("userid",
"password".toCharArray()));
 
connection.setCredentials(credentials);
7. Construct the other objects once the connection is created.
RegistryService regService = connection.getRegistryService();
BusinessLifeCycleManager lcManager =
regService.getBusinessLifeCycleManager();
BusinessQueryManager bqManager = regService.getBusinessQueryManager();