Search in sources :

Example 1 with RMIListener

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);
    }
}
Also used : RMIListener(com.centurylink.mdw.model.listener.RMIListener) Registry(java.rmi.registry.Registry) LocateRegistry(java.rmi.registry.LocateRegistry) RemoteException(java.rmi.RemoteException) JSONException(org.json.JSONException) SQLException(java.sql.SQLException) MDWException(com.centurylink.mdw.common.exception.MDWException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) MbengException(com.qwest.mbeng.MbengException) XmlException(org.apache.xmlbeans.XmlException) PropertyException(com.centurylink.mdw.common.exception.PropertyException) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) NamingException(javax.naming.NamingException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) CreateException(javax.ejb.CreateException)

Example 2 with RMIListener

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());
            }
        }
    }
}
Also used : InitialContext(javax.naming.InitialContext) Context(javax.naming.Context) RMIListener(com.centurylink.mdw.model.listener.RMIListener) Hashtable(java.util.Hashtable) PortableRemoteObject(javax.rmi.PortableRemoteObject) JSONObject(org.json.JSONObject) NamingException(javax.naming.NamingException) RemoteException(java.rmi.RemoteException) InitialContext(javax.naming.InitialContext) JSONException(org.json.JSONException) SQLException(java.sql.SQLException) MDWException(com.centurylink.mdw.common.exception.MDWException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) MbengException(com.qwest.mbeng.MbengException) XmlException(org.apache.xmlbeans.XmlException) PropertyException(com.centurylink.mdw.common.exception.PropertyException) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) NamingException(javax.naming.NamingException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) CreateException(javax.ejb.CreateException)

Aggregations

DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)2 MDWException (com.centurylink.mdw.common.exception.MDWException)2 PropertyException (com.centurylink.mdw.common.exception.PropertyException)2 ActionCancelledException (com.centurylink.mdw.common.utilities.timer.ActionCancelledException)2 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)2 RMIListener (com.centurylink.mdw.model.listener.RMIListener)2 MbengException (com.qwest.mbeng.MbengException)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 ConnectException (java.net.ConnectException)2 RemoteException (java.rmi.RemoteException)2 SQLException (java.sql.SQLException)2 CreateException (javax.ejb.CreateException)2 NamingException (javax.naming.NamingException)2 XmlException (org.apache.xmlbeans.XmlException)2 JSONException (org.json.JSONException)2 LocateRegistry (java.rmi.registry.LocateRegistry)1 Registry (java.rmi.registry.Registry)1 Hashtable (java.util.Hashtable)1 Context (javax.naming.Context)1