use of com.centurylink.mdw.model.listener.RMIListener in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method sendRmiMessage.
// really send RMI message through rmi registry
private String sendRmiMessage(String engineUrl, String request) throws RemoteException {
try {
Registry registry;
String host;
int port;
int k1 = engineUrl.indexOf("://");
int k2 = engineUrl.indexOf(':', k1 + 4);
int k3 = engineUrl.indexOf('/', k1 + 4);
if (k2 > 0) {
host = engineUrl.substring(k1 + 3, k2);
if (k3 > 0)
port = Integer.parseInt(engineUrl.substring(k2 + 1, k3));
else
port = Integer.parseInt(engineUrl.substring(k2 + 1));
port += RMIListener.PORT_DIFF;
} else {
// well-known RMI registry port
port = 1099;
if (k3 > 0)
host = engineUrl.substring(k1 + 3, k3);
else
host = engineUrl.substring(k1 + 3);
}
registry = LocateRegistry.getRegistry(host, port);
RMIListener server = (RMIListener) registry.lookup(RMIListener.JNDI_NAME);
return server.invoke(null, request);
} catch (Exception e) {
throw new RemoteException(e.getMessage(), e);
}
}
use of com.centurylink.mdw.model.listener.RMIListener in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method sendEjbMessage.
// really send RMI message through iiop now
private String sendEjbMessage(String engineUrl, String request) throws RemoteException {
Context context = null;
try {
Hashtable<String, String> h = new Hashtable<>();
h.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, engineUrl);
context = new InitialContext(h);
Object obj = context.lookup(RMIListener.JNDI_NAME);
RMIListener server;
if (obj instanceof RMIListener)
server = (RMIListener) obj;
else
server = (RMIListener) PortableRemoteObject.narrow(obj, RMIListener.class);
return server.invoke(null, request);
} catch (Exception e) {
throw new RemoteException(e.getMessage(), e);
} finally {
if (context != null) {
try {
context.close();
} catch (NamingException ex) {
System.err.println(ex.getMessage());
}
}
}
}
Aggregations