Java Clients
Connecting with Directly Supplied Server AttributesIn 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
ExampleThe 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 > 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. |