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

Connecting with Directly Supplied Server Attributes

In order to make a connection to an IOM server, you must give the Java Connection Factory specific information about the server and about the desired connection. The quickest and simplest method of providing this information is to place it directly into the client program when creating the BridgeServer object. The following attributes can be provided:

host
specifies the IP address of the machine hosting the IOM server or object spawner. This attribute is required.

port
specifies the TCP port that the IOM server or object spawner is listening on for connections. This attribute is required.

encryptionPolicy
specifies whether IOM Bridge for Java should attempt to negotiate with the server over which encryption algorithm to use and what to do if the negotiations fail. This attribute is optional. Possible values are as follows:

none
specifies not to use encryption. This is the default.
optional
specifies to attempt to use encryption but, if algorithm negotiation fails, continue with an unencrypted connection.
required
specifies to attempt to use encryption but, if algorithm negotiation fails, fail the connection.

encryptionAlgorithms
specifies the list of algorithms you are willing to use in order of preference. Values in the list should be separated by commas and chosen from SASPROPRIETARY, RC2, RC4, DES, or TRIPLEDES. This attribute is optional. If no value is specified, then one of the server's preferred algorithms will be used. It is ignored entirely if the value for encryptionPolicy is none.

Note: If you do not have a license for SAS/SECURE software, only the SASPROPRIETARY algorithm is available.

encryptionContent
specifies which messages should be encrypted if encryption is used. This attribute is optional, and it is ignored entirely if the value for encryptionPolicy is none. Possible values are as follows:

all
encrypts all messages. This is the default.
authentication
encrypts only messages that contain user name and password information.

Example

The Java code in this example demonstrates how to create a BridgeServer object to provide information to the Java Connection Factory and obtain a connection. For an example showing how to use a connection, see Language Service Example.

The last two statements in this example show how to dispose of a connection. For details about this procedure, see Returning a Connection to the Java Connection Factory.

import com.sas.iom.SAS.IWorkspace;
import com.sas.iom.SAS.IWorkspaceHelper;
import com.sas.services.connection.BridgeServer;
import com.sas.services.connection.ConnectionFactoryAdminInterface;
import com.sas.services.connection.ConnectionFactoryConfiguration;
import com.sas.services.connection.ConnectionFactoryInterface;
import com.sas.services.connection.ConnectionFactoryManager;
import com.sas.services.connection.ConnectionInterface;
import com.sas.services.connection.ManualConnectionFactoryConfiguration;
import com.sas.services.connection.Server;


// identify the IOM server
String classID = Server.CLSID_SAS;
String host = "rnd.fyi.sas.com";
int port = 5310;
Server server = new BridgeServer(classID,host,port);

// make a connection factory configuration with the server
ConnectionFactoryConfiguration cxfConfig =
   new ManualConnectionFactoryConfiguration(server);

// get a connection factory manager
ConnectionFactoryManager cxfManager = new ConnectionFactoryManager();

// get a connection factory that matches the configuration
ConnectionFactoryInterface cxf = cxfManager.getFactory(cxfConfig);

// get the administrator interface
ConnectionFactoryAdminInterface admin = cxf.getAdminInterface();

// get a connection
String userName = "abcserv";
String password = "abcpass";
ConnectionInterface cx = cxf.getConnection(userName,password);
org.omg.CORBA.Object obj = cx.getObject();
IWorkspace iWorkspace = IWorkspaceHelper.narrow(obj);

< insert iWorkspace workspace usage code here >
cx.close(); // tell the factory that it can destroy unused connections admin.shutdown();

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.