Can someone give me a code snippet in which I could perform an RMI call to my session bean (written in Java and deployed on Weblogic) in Groovy?
Edit 1
This is my java code. Is there any easier way to do it in Groovy?
Properties props = new Properties();
props.put("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
props.put("java.naming.provider.url",”t3://127.0.0.1:7001”); // url+port format
props.put("java.naming.security.principal", “weblogic_username”));
props.put("java.naming.security.credentials", “weblogic_password”);
try
{
String simpleName = MyRemoteClass.class.getSimpleName();
String fullName = MyRemoteClass.class.getName();
String name = simpleName + "#" + fullName;
initContext = new InitialContext(props);
MyRemoteClass remoteClass = (MyRemoteClass)initContext.lookup(name);
remoteClass.doSomething();
}
catch (Throwable ex)
{
}
I don’t know about any library to wrap/ease RMI calls from Groovy. If there’s none, you can at least benefit from syntactic sugar, coercion and implicit casting:
Groovy 🙂