Thursday, December 13, 2007

communicate between two app servers

Properties propsB = new Properties();
propsB.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
propsB.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
propsB.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
propsB.setProperty("org.omg.CORBA.ORBInitialHost","192.168.0.81"); // IP of server B
propsB.setProperty("org.omg.CORBA.ORBInitialPort", "3700"); // port on server B

InitialContext ctx = null;
try {
ctx = new InitialContext(propsB);
} catch (NamingException ex) {
ex.printStackTrace();
}

ServerManagerRemote serverManager = null;

try {
serverManager = (ServerManagerRemote) ctx.lookup(ServerManagerRemote.class.getName());
} catch (NamingException ex) {
ex.printStackTrace();
}

No comments: