Accessing Act! from Java |
This example demonstrates how to access Act! from Java. J-Integra® for COM is a Java interoperability component that bridges Java and Act!. It provides bi-directional access of Java objects and COM components.
// A pure Java client which lists all Act! contacts. // // This is a simple Java Client which accesses Act! This client will run on any // machine that has a standard JVM, including UNIX. It requires no native code. All that // is needed is a TCP/IP link to the machine running Act. It works with Java 2. // // This example uses the J-Integra® pure Java-COM bridge, available from // http://j-integra.intrinsyc.com/ // // Prior to building this example, create an 'act' subdirectory and run the J-Integra® // 'com2java' tool to generate the pure Java proxies that can be used to acccess Act! // as though it were a Java application. Specify \Program Files\Symantec\ACT\act.tlb // as the input type library, 'act' as the package name, and the act subdirectory you // created as the output directory. This step need only be done once -- the 'com2java' // tool is not used at runtime. // // Questions & comments to: support@linar.com public class ActClient { public static void main(String args[]) throws Exception { try { // If running this client under Windows then put the J-Integra® 'bin' directory in your path // and leave the following line commented, otherwise run dcomcnfg (Start|Run|DCOMCNFG) // on the machine running Act! and grant a specific user default launch and access permissions, // and then uncomment the following line, specifying the appropriate domain/user/password: // com.linar.jintegra.AuthInfo.setDefault("NT DOMAIN", "USER", "PASSWORD"); // Start Act! If you are not running this client on the same machine as Act! (for example // if you are running it on a UNIX box) then pass the host name of the Act! machine as a // parameter act.CActAppObj actApp = new act.CActAppObj(); // Wait for Act! to initialize while (!actApp.isDBOpen()) { Thread.sleep(2000); } // What version are we accessing? System.out.println("Act! version is " + actApp.getActVersion()); // Get hold of the views act.IAIViews views = new act.IAIViewsProxy(actApp.views()); // Create the Contact List view. short type = 2; String name = "contact list"; act.IAIContactListView cl = new act.IAIContactListViewProxy(views.create(type, name)); // Create the Contact Grid act.IAIGrid grid = new act.IAIGridProxy(cl.getGrid()); // Get all the column names String colNames[] = new String[grid.getColumnCount()]; for (int i = 0; i < colNames.length; i++) { colNames[i] = grid.getColumnName(i); } // For each row for (int row = 0; row < grid.getRowCount(); row++) { System.out.println("Row: " + row); // For each column for (int col = 0; col < colNames.length; col++) { // Print out the column value System.out.println(" " + colNames[col] + ": " + grid.getField(col, row)); } } } finally { // Release all COM object references that have not been garbage collected. Call this // just once, prior to exiting the JVM. com.linar.jintegra.Cleaner.releaseAll(); } } } |