Accessing eXcelon from Java |
This example demonstrates how to access eXcelon from Java. J-Integra® for COM is a Java interoperability component that bridges Java and eXcelon. It provides bi-directional access of Java objects and COM components.
// Example of talking to ODI's eXcelon XML data server from Java. Built for eXcelon 1.1. // // Uses the J-Integra® pure Java-COM bridge. See http://j-integra.intrinsyc.com/ for kit and doc. // // To run this example: // Create an 'excelon' subdirectory. Run 'com2java' on \ODI\excelon1.1\bin\xlnpapi.dll // specifying 'excelon' as the package name, and the 'excelon' subdirectory as the output // directory. Set the "Attempt non-duals" option in the "Options" dialog. // // Configure a surrogate for the XlnProxyDispenser by running the SETDLLHOST tool, // specifying \ODI\excelon1.1\bin\xlnpapi.dll "eXcelon Class" as parameters. public class ExcelonClient { public static void main(String args[]) throws Exception { try { // This line can be left commented if you are running this Java client under Windows and the J-Integra® 'bin' // directory is in your PATH. // com.linar.jintegra.AuthInfo.setDefault("NT DOMAIN", "NT USER", "NT PASSWORD"); // If not accessing Excelon locally then run DCOMCNFG on the machine running Excelon // and grant default launch and access permissions to the above user (if you uncomment that // line), or the NT user you are running the Java client as. // Uncomment this line to get the J-Integra® runtime to log to a file // com.linar.jintegra.Log.logImmediately(3, new java.io.PrintStream(new java.io.FileOutputStream("jintegra.log"))); // Optional parameter specifies name of machine running the Excelon server you want // to talk to. excelon.IXlnDispenser eXcelon = new excelon.XlnProxyDispenser(); String bindstr = "localhost"; excelon.IXlnSession session = eXcelon.getSession(bindstr, 0); excelon.IXlnSystem system = eXcelon.getSystem(bindstr, 0); Object[] stores = (Object[]) system.getStoreInfo(); for (int i = 0; i < stores.length; i++) { excelon.IXlnStoreInfo storeInfo = new excelon.IXlnStoreInfoProxy(stores[i]); println(0, "Store: " + storeInfo.getName()); // println is below - for indented output displayDirectory(session, storeInfo.getName() + ":", 1); } } finally { com.linar.jintegra.Cleaner.releaseAll(); } } static void displayDirectory(excelon.IXlnSession session, String directoryName, int level) throws java.io.IOException { println(level, "Directory: " + directoryName); Object[] directoryContent = (Object[]) session.getDirectoryContents(directoryName); for (int i = 0; i < directoryContent.length; i++) { excelon.IXlnItemInfo itemInfo = new excelon.IXlnItemInfoProxy(directoryContent[i]); // Ugly name, but it is what is in the eXcelon type library if (itemInfo.getType() == excelon. __MIDL___MIDL_itf_intclient_0000_0004.XLN_DIRECTORY) { displayDirectory(session, directoryName + "/" + itemInfo.getName(), level + 1); } else { println(level + 1, "Item: " + itemInfo.getName()); println(level + 2, "Mime Type: " + itemInfo.getMimetype()); println(level + 2, "Last Modified: " + itemInfo.getModificationDate()); println(level + 2, "Size: " + itemInfo.getSize()); } } } static void println(int level, String item) { for (int i = 0; i < level * 2; i++) { System.out.print(" "); } System.out.println(item); } } |