Example usage for java.rmi RemoteException RemoteException

List of usage examples for java.rmi RemoteException RemoteException

Introduction

In this page you can find the example usage for java.rmi RemoteException RemoteException.

Prototype

public RemoteException(String s) 

Source Link

Document

Constructs a RemoteException with the specified detail message.

Usage

From source file:org.kchine.r.server.impl.DefaultAssignInterfaceImpl.java

public long setFactorLevels(final long rObjectId, final String slotsPath, final String[] levels)
        throws RemoteException {

    final long[] result = new long[1];
    final Exception[] exceptionHolder = new Exception[1];
    DirectJNI.getInstance().runR(new org.kchine.r.server.ExecutionUnit() {
        public void run(Rengine e) {
            try {
                String rootvar = DirectJNI.getInstance().newTemporaryVariableName();
                String argvar = DirectJNI.getInstance().newTemporaryVariableName();
                e.rniAssign(rootvar, rObjectId, 0);
                if (levels != null) {
                    e.rniAssign(argvar, e.rniPutStringArray(levels), 0);
                } else {
                    e.rniEval(e.rniParse(argvar + "<-NULL", 1), 0);
                }/*w  w  w  . java2 s .c  o m*/
                e.rniEval(e.rniParse("levels(" + rootvar + slotsPath + ")<-" + argvar, 1), 0);
                result[0] = e.rniEval(e.rniParse(rootvar, 1), 0);
                e.rniEval(e.rniParse("rm(" + rootvar + "," + argvar + ")", 1), 0);
            } catch (Exception ex) {
                exceptionHolder[0] = ex;
            }
        }
    });
    if (exceptionHolder[0] != null)
        throw new RemoteException(Utils.getStackTraceAsString(exceptionHolder[0]));

    return result[0];
}

From source file:org.kchine.r.server.impl.DefaultAssignInterfaceImpl.java

public RList getDataframeData(final long rObjectId, final String slotsPath) throws RemoteException {

    final RList[] result = new RList[1];
    final Exception[] exceptionHolder = new Exception[1];
    DirectJNI.getInstance().runR(new org.kchine.r.server.ExecutionUnit() {
        public void run(Rengine e) {
            try {
                String rootvar = DirectJNI.getInstance().newTemporaryVariableName();
                e.rniAssign(rootvar, rObjectId, 0);
                result[0] = ((RDataFrame) DirectJNI.getInstance().getObjectFrom(rootvar + slotsPath, true))
                        .getData();/* w  ww .j a  v  a2  s. c o  m*/
                e.rniEval(e.rniParse("rm(" + rootvar + ")", 1), 0);
            } catch (Exception ex) {
                exceptionHolder[0] = ex;
            }
        }
    });
    if (exceptionHolder[0] != null)
        throw new RemoteException(Utils.getStackTraceAsString(exceptionHolder[0]));
    return result[0];

}

From source file:org.kchine.r.server.impl.DefaultAssignInterfaceImpl.java

public String[] getDataframeRowNames(final long rObjectId, final String slotsPath) throws RemoteException {
    final String[][] result = new String[1][];
    final Exception[] exceptionHolder = new Exception[1];
    DirectJNI.getInstance().runR(new org.kchine.r.server.ExecutionUnit() {
        public void run(Rengine e) {
            try {
                String rootvar = DirectJNI.getInstance().newTemporaryVariableName();
                e.rniAssign(rootvar, rObjectId, 0);

                result[0] = e.rniGetStringArray(
                        e.rniEval(e.rniParse("row.names(" + rootvar + slotsPath + ")", 1), 0));

                e.rniEval(e.rniParse("rm(" + rootvar + ")", 1), 0);
            } catch (Exception ex) {
                exceptionHolder[0] = ex;
            }//  ww w.  ja v  a  2 s  . c om
        }
    });
    if (exceptionHolder[0] != null)
        throw new RemoteException(Utils.getStackTraceAsString(exceptionHolder[0]));
    return result[0];
}

From source file:org.kchine.r.server.impl.DefaultAssignInterfaceImpl.java

public long setDataframeData(final long rObjectId, final String slotsPath, final RList data)
        throws RemoteException {
    final long[] result = new long[1];
    final Exception[] exceptionHolder = new Exception[1];
    DirectJNI.getInstance().runR(new org.kchine.r.server.ExecutionUnit() {
        public void run(Rengine e) {
            try {
                String rootvar = DirectJNI.getInstance().newTemporaryVariableName();
                String argvar = DirectJNI.getInstance().newTemporaryVariableName();
                e.rniAssign(rootvar, rObjectId, 0);
                e.rniAssign(argvar,//  w ww  . j a  va2  s  .  com
                        DirectJNI.getInstance()
                                .putObject(new RDataFrame(data instanceof ReferenceInterface
                                        ? (RList) ((ReferenceInterface) data).extractRObject()
                                        : data, null)),
                        0);
                e.rniEval(
                        e.rniParse("row.names(" + argvar + ")<-" + "row.names(" + rootvar + slotsPath + ")", 1),
                        0);
                result[0] = e.rniEval(e.rniParse(argvar, 1), 0);
                e.rniEval(e.rniParse("rm(" + rootvar + "," + argvar + ")", 1), 0);
            } catch (Exception ex) {
                exceptionHolder[0] = ex;
            }
        }
    });
    if (exceptionHolder[0] != null)
        throw new RemoteException(Utils.getStackTraceAsString(exceptionHolder[0]));

    return result[0];
}

From source file:org.kchine.r.server.impl.DefaultAssignInterfaceImpl.java

public long setDataframeRowNames(final long rObjectId, final String slotsPath, final String[] rowNames)
        throws RemoteException {
    final long[] result = new long[1];
    final Exception[] exceptionHolder = new Exception[1];
    DirectJNI.getInstance().runR(new org.kchine.r.server.ExecutionUnit() {
        public void run(Rengine e) {
            try {
                String rootvar = DirectJNI.getInstance().newTemporaryVariableName();
                String argvar = DirectJNI.getInstance().newTemporaryVariableName();
                e.rniAssign(rootvar, rObjectId, 0);
                if (rowNames != null) {
                    e.rniAssign(argvar, e.rniPutStringArray(rowNames), 0);
                } else {
                    e.rniEval(e.rniParse(argvar + "<-NULL", 1), 0);
                }/*ww w. ja v a2 s .  c om*/
                e.rniEval(e.rniParse("row.names(" + rootvar + slotsPath + ")<-" + argvar, 1), 0);
                result[0] = e.rniEval(e.rniParse(rootvar, 1), 0);
                e.rniEval(e.rniParse("rm(" + rootvar + "," + argvar + ")", 1), 0);

            } catch (Exception ex) {
                exceptionHolder[0] = ex;
            }
        }
    });
    if (exceptionHolder[0] != null)
        throw new RemoteException(Utils.getStackTraceAsString(exceptionHolder[0]));

    return result[0];
}

From source file:org.kchine.r.server.impl.DefaultAssignInterfaceImpl.java

public RObject[] getListValue(final long rObjectId, final String slotsPath) throws RemoteException {
    final RObject[][] result = new RObject[1][];
    final Exception[] exceptionHolder = new Exception[1];
    DirectJNI.getInstance().runR(new org.kchine.r.server.ExecutionUnit() {
        public void run(Rengine e) {
            try {
                String rootvar = DirectJNI.getInstance().newTemporaryVariableName();
                e.rniAssign(rootvar, rObjectId, 0);
                result[0] = ((RList) DirectJNI.getInstance().getObjectFrom(rootvar + slotsPath, true))
                        .getValue();// w  ww .j  a  v  a 2s.c o  m
                e.rniEval(e.rniParse("rm(" + rootvar + ")", 1), 0);
            } catch (Exception ex) {
                exceptionHolder[0] = ex;
            }
        }
    });
    if (exceptionHolder[0] != null)
        throw new RemoteException(Utils.getStackTraceAsString(exceptionHolder[0]));
    return result[0];
}

From source file:org.kchine.r.server.impl.DefaultAssignInterfaceImpl.java

public long setListValue(final long rObjectId, final String slotsPath, final RObject[] value)
        throws RemoteException {
    final long[] result = new long[1];
    final Exception[] exceptionHolder = new Exception[1];
    DirectJNI.getInstance().runR(new org.kchine.r.server.ExecutionUnit() {
        public void run(Rengine e) {
            try {
                String rootvar = DirectJNI.getInstance().newTemporaryVariableName();
                String argvar = DirectJNI.getInstance().newTemporaryVariableName();
                e.rniAssign(rootvar, rObjectId, 0);
                RObject[] plainvalue = new RObject[value.length];
                for (int i = 0; i < value.length; ++i) {
                    if (value[i] instanceof ReferenceInterface) {
                        plainvalue[i] = ((ReferenceInterface) value[i]).extractRObject();
                    } else {
                        plainvalue[i] = value[i];
                    }/* www.  j  a v  a  2  s.  c o  m*/
                }

                e.rniAssign(argvar, DirectJNI.getInstance().putObject(new RList(plainvalue, null)), 0);
                e.rniEval(e.rniParse("names(" + argvar + ")<-" + "names(" + rootvar + slotsPath + ")", 1), 0);
                result[0] = e.rniEval(e.rniParse(argvar, 1), 0);
                e.rniEval(e.rniParse("rm(" + rootvar + "," + argvar + ")", 1), 0);
            } catch (Exception ex) {
                exceptionHolder[0] = ex;
            }
        }
    });
    if (exceptionHolder[0] != null)
        throw new RemoteException(Utils.getStackTraceAsString(exceptionHolder[0]));

    return result[0];
}

From source file:org.kchine.r.server.impl.DefaultAssignInterfaceImpl.java

public HashMap getEnvData(final long rObjectId, final String slotsPath) throws RemoteException {
    final HashMap[] result = new HashMap[1];
    final Exception[] exceptionHolder = new Exception[1];
    DirectJNI.getInstance().runR(new org.kchine.r.server.ExecutionUnit() {
        public void run(Rengine e) {
            try {
                String rootvar = DirectJNI.getInstance().newTemporaryVariableName();
                e.rniAssign(rootvar, rObjectId, 0);
                result[0] = ((REnvironment) DirectJNI.getInstance().getObjectFrom(rootvar + slotsPath, true))
                        .getData();//from w ww  . j a  v a 2 s.c o m
                e.rniEval(e.rniParse("rm(" + rootvar + ")", 1), 0);
            } catch (Exception ex) {
                exceptionHolder[0] = ex;
            }
        }
    });
    if (exceptionHolder[0] != null)
        throw new RemoteException(Utils.getStackTraceAsString(exceptionHolder[0]));
    return result[0];
}

From source file:org.kchine.r.server.impl.DefaultAssignInterfaceImpl.java

public long putEnv(final long rObjectId, final String slotsPath, final String theKey, final RObject theValue)
        throws RemoteException {
    final long[] result = new long[1];
    final Exception[] exceptionHolder = new Exception[1];
    DirectJNI.getInstance().runR(new org.kchine.r.server.ExecutionUnit() {
        public void run(Rengine e) {
            try {
                String rootvar = DirectJNI.getInstance().newTemporaryVariableName();
                String argvar = DirectJNI.getInstance().newTemporaryVariableName();
                e.rniAssign(rootvar, rObjectId, 0);
                e.rniAssign(argvar,//w ww.  j ava  2  s.  com
                        DirectJNI.getInstance()
                                .putObject(theValue instanceof ReferenceInterface
                                        ? ((ReferenceInterface) theValue).extractRObject()
                                        : theValue),
                        0);
                e.rniEval(e.rniParse("assign('" + theKey + "'," + argvar + ", env=" + rootvar + slotsPath + ")",
                        1), 0);
                result[0] = e.rniEval(e.rniParse(rootvar, 1), 0);
                e.rniEval(e.rniParse("rm(" + rootvar + "," + argvar + ")", 1), 0);
            } catch (Exception ex) {
                exceptionHolder[0] = ex;
            }
        }
    });
    if (exceptionHolder[0] != null)
        throw new RemoteException(Utils.getStackTraceAsString(exceptionHolder[0]));

    return result[0];
}

From source file:org.kchine.r.server.impl.DefaultAssignInterfaceImpl.java

public long setEnvData(final long rObjectId, final String slotsPath, final HashMap<String, RObject> data)
        throws RemoteException {
    final long[] result = new long[1];
    final Exception[] exceptionHolder = new Exception[1];
    DirectJNI.getInstance().runR(new org.kchine.r.server.ExecutionUnit() {
        public void run(Rengine e) {
            try {
                HashMap<String, RObject> plaindata = new HashMap<String, RObject>();
                for (String key : data.keySet()) {
                    RObject o = data.get(key);
                    if (o instanceof ReferenceInterface)
                        plaindata.put(key, ((ReferenceInterface) o).extractRObject());
                    else
                        plaindata.put(key, o);
                }/*from   ww  w .  ja v  a2 s.  c o  m*/
                REnvironment env = new REnvironment();
                env.setData(plaindata);
                result[0] = DirectJNI.getInstance().putObject(env);
            } catch (Exception ex) {
                exceptionHolder[0] = ex;
            }
        }
    });
    if (exceptionHolder[0] != null)
        throw new RemoteException(Utils.getStackTraceAsString(exceptionHolder[0]));

    return result[0];
}