Connecting with Server Attributes Read from the Information Service

Overview of Connecting with Server Attributes from the Information Service

The Java Connection Factory enables you to obtain server connection information from a metadata server by using the Information Service component of SAS Foundation Services. The Information Service enables you to access multiple SAS Metadata Repositories simultaneously and perform searches across all metadata sources.
Before you use this method, you must do the following:
  • set up the User Service. For more information, see Understanding and Editing the User Service in SAS Foundation Services: Administrator's Guide in the SAS Foundation Services: Administrator's Guide and com.sas.services.user in the Foundation Services class documentation at http://support.sas.com/rnd/javadoc/93.
  • set up the Information Service. For more information, see Modifying the Information Service Configuration in SAS Foundation Services: Administrator's Guide in the SAS Foundation Services: Administrator's Guide and com.sas.services.information in the Foundation Services class documentation at http://support.sas.com/rnd/javadoc/93.
Note: The ConnectionFactory class that is used in the other connection methods is not integrated with SAS Foundation Services. To use the Information Service to connect, you must use the PlatformConnectionFactory class in com.sas.services.connection.platform.

Example of Connecting with Server Attributes from the Information Service

The following example code shows how to initialize and use the Java Connection Factory with information from the Information Service. For information about how to use the object reference, see Java Connection Factory Language Service Example.
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 using the User Service
UserContextInterface cxfUser = uService.newUser("user1","user1pw",
   "user1domain");

 set up the Information Service and define a repository repos >

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

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

// Step 4. Create a connection factory configuration
ConnectionFactoryConfiguration cxfConfig = new
   PlatformConnectionFactoryConfiguration(logicalServer);

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

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

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

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

< insert iWorkspace workspace usage code here >

// Step 9. Close the connection when finished
cx.close();
cxf.getAdminInterface().destroy();
Note: 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.