SAS 9.1.3 Integration Technologies » Developer's Guide


Developing Java Clients
Installation and JRE Requirements
Security
Using the IOM Server
Using the Java Connection Factory
Connecting with Directly Supplied Server Attributes
Connecting with Server Attributes Read from a SAS Metadata Server
Connecting with Server Attributes Read from an LDAP Server
Connecting with Server Attributes Read from the Information Service
Language Service Example
Logging Java Connection Factory Activities
Using Failover
Using Load Balancing
Using Connection Pooling
Pooling with Directly Supplied Server Attributes
Pooling with Server Attributes Read from a Metadata Server
Pooling with Server Attributes Read from the Information Service
Returning Connections to the Java Connection Factory
Using Java CORBA Stubs for IOM Objects
Getting a JDBC Connection Object
Using the Java Workspace Factory
Using SAS Foundation Services
IOM and CORBA Class Documentation
Java Clients

Pooling with Server Attributes Read from the Information Service

The process of creating a pooling server by using the Information Service is basically the same as the process that is described at Connecting with Server Attributes Read from the Information Service, but the following additional steps are required when you create a pooling server:

  • create a user context for the pooling administrator user, who can access the metadata for the puddle logins. For more information about the pooling administrator, see Planning the Pooling Security in SAS Integration Technologies: Server Administrator's Guide.

  • specify the name or the user context for the pooling administrator in the constructor method for PlatformConnectionFactoryConnection.

Example

The following example code shows how to create a pooling server using the Information Service. For information about how to use the object reference, see Language Service Example. The example code performs the following steps:
  1. Creates a user context for the pooling administrator, which is used to create the connection factory
  2. Creates a user context for the user "user1", which is used to access the metadata repository
  3. Gets an interface to a metadata repository "repos"
  4. Retrieves the logical server definition through the Information Service
  5. Creates a connection factory configuration using the logical server definition
  6. Gets a connection factory manager
  7. Gets a connection factory using the connection factory configuration
  8. Connects to the server
  9. Narrows the server connection
  10. Closes the connection and connection factory

The last three statements in the example code show how to dispose of object references. For details about this procedure, see Returning Connections to the Java Connection Factory.

import com.sas.iom.SAS.IWorkspace;
import com.sas.iom.SAS.IWorkspaceHelper;
import com.sas.services.connection.ConnectionFactoryConfiguration;
import com.sas.services.connection.ConnectionInterface;
import com.sas.services.connection.platform.PlatformConnectionFactoryInterface;
import com.sas.services.connection.platform.PlatformConnectionFactoryConfiguration;
import com.sas.services.information.RepositoryInterface;
import com.sas.services.information.metadata.LogicalServerInterface;
import com.sas.services.user.UserContextInterface;
import com.sas.services.user.UserServiceInterface;

< set up the User Service and create a UserServiceInterface uService >

// Step 1. Create a user context for the pool administrator
UserContextInterface poolUser = uService.newUser("pooladm","pooladmpw",
  "pooladmdomain");

// Step 2. Create a user context for a connection factory user
UserContextInterface cxfUser = uService.newUser("user1","user1pw",
  "user1domain");

< set up the Information Service and define a repository repos >

// Step 3. Identify the repository
RepositoryInterface cxfRepos = cxfUser.getRepository("repos");

// Step 4. Identify the IOM service
LogicalServerInterface logicalServer =
   cxfRepos.fetch("A50IFJQG.AQ000002/LogicalServer");

// Step 5. Create a connection factory configuration
String poolUserName = poolUser.getName();
ConnectionFactoryConfiguration cxfConfig = new
   PlatformConnectionFactoryConfiguration(logicalServer, poolUserName);

// Step 6. Get a connection factory manager
PlatformConnectionFactoryManager cxfManager = new
   PlatformConnectionFactoryManager();

// Step 7. Get a connection factory using the configuration
PlatformConnectionFactoryInterface cxf =
   cxfManager.getPlatformFactory(cxfConfig);

// Step 8. Get a connection
ConnectionInterface cx = cxf.getConnection(cxfUser);

// Step 9. Narrow the connection
org.omg.CORBA.Object obj = cx.getObject();
IWorkspace iWorkspace = IWorkspaceHelper.narrow(obj);

< insert iWorkspace workspace usage code here >

// Step 10. Close the connection when finished
cx.close();
cxf.getAdminInterface().destroy();

In an effort to make the previous example more readable, we have removed most of the code structuring elements. The example will not compile as it is shown.