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 Java Connection Factory Language Service Example.
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();
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.