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 boolean[] getValueBoolArray(final long rObjectId, final String slotsPath) throws RemoteException {
    final boolean[][] result = new boolean[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);
                if (e.rniGetBoolArrayI(
                        e.rniEval(e.rniParse("is.null(" + rootvar + slotsPath + ")", 1), 0))[0] == 1) {
                    result[0] = null;//from   ww  w  . j a v a  2 s  .c o  m
                    return;
                }
                e.rniAssign(rootvar, rObjectId, 0);
                int[] bAsInt = e.rniGetBoolArrayI(e.rniEval(e.rniParse(rootvar + slotsPath, 1), 0));
                result[0] = new boolean[bAsInt.length];
                for (int i = 0; i < bAsInt.length; ++i)
                    result[0][i] = bAsInt[i] == 1;
                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 setValueBoolArray(final long rObjectId, final String slotsPath, final boolean[] 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();
                e.rniAssign(rootvar, rObjectId, 0);
                String argvar = DirectJNI.getInstance().newTemporaryVariableName();

                if (value != null) {
                    e.rniAssign(argvar, e.rniPutBoolArray(value), 0);
                } else {
                    e.rniEval(e.rniParse(argvar + "<-NULL", 1), 0);
                }/*from   w w  w. j a  va 2s. c o m*/

                e.rniEval(e.rniParse(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 double[] getValueDoubleArray(final long rObjectId, final String slotsPath) throws RemoteException {
    final double[][] result = new double[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);

                if (e.rniGetBoolArrayI(
                        e.rniEval(e.rniParse("is.null(" + rootvar + slotsPath + ")", 1), 0))[0] == 1) {
                    result[0] = null;//from   w w  w  .  j  av a 2s  . c o m
                    return;
                }

                e.rniAssign(rootvar, rObjectId, 0);
                result[0] = e.rniGetDoubleArray(e.rniEval(e.rniParse(rootvar + slotsPath, 1), 0));
                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 setValueDoubleArray(final long rObjectId, final String slotsPath, final double[] 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();
                e.rniAssign(rootvar, rObjectId, 0);
                String argvar = DirectJNI.getInstance().newTemporaryVariableName();

                if (value != null) {
                    e.rniAssign(argvar, e.rniPutDoubleArray(value), 0);
                } else {
                    e.rniEval(e.rniParse(argvar + "<-NULL", 1), 0);
                }/*from  ww w.  ja  va  2s  .  c  o  m*/

                e.rniEval(e.rniParse(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 int[] getValueIntArray(final long rObjectId, final String slotsPath) throws RemoteException {
    final int[][] result = new int[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);

                if (e.rniGetBoolArrayI(
                        e.rniEval(e.rniParse("is.null(" + rootvar + slotsPath + ")", 1), 0))[0] == 1) {
                    result[0] = null;// ww w .  ja v a2s .  c  o m
                    return;
                }

                e.rniAssign(rootvar, rObjectId, 0);
                result[0] = e.rniGetIntArray(e.rniEval(e.rniParse(rootvar + slotsPath, 1), 0));
                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 setValueIntArray(final long rObjectId, final String slotsPath, final int[] 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();
                e.rniAssign(rootvar, rObjectId, 0);
                String argvar = DirectJNI.getInstance().newTemporaryVariableName();

                if (value != null) {
                    e.rniAssign(argvar, e.rniPutIntArray(value), 0);
                } else {
                    e.rniEval(e.rniParse(argvar + "<-NULL", 1), 0);
                }/*  ww w. ja va  2  s.c o  m*/

                e.rniEval(e.rniParse(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 double[] getValueCPReal(final long rObjectId, final String slotsPath) throws RemoteException {
    final double[][] result = new double[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);

                if (e.rniGetBoolArrayI(
                        e.rniEval(e.rniParse("is.null(" + rootvar + slotsPath + ")", 1), 0))[0] == 1) {
                    result[0] = null;//from   w w w  .j ava 2 s . c o  m
                    return;
                }

                e.rniAssign(rootvar, rObjectId, 0);
                result[0] = e.rniGetDoubleArray(e.rniEval(e.rniParse("Re(" + rootvar + slotsPath + ")", 1), 0));
                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 double[] getValueCPImaginary(final long rObjectId, final String slotsPath) throws RemoteException {
    final double[][] result = new double[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);

                if (e.rniGetBoolArrayI(
                        e.rniEval(e.rniParse("is.null(" + rootvar + slotsPath + ")", 1), 0))[0] == 1) {
                    result[0] = null;/*w  w w.j a va 2 s . co  m*/
                    return;
                }

                e.rniAssign(rootvar, rObjectId, 0);
                result[0] = e.rniGetDoubleArray(e.rniEval(e.rniParse("Im(" + rootvar + slotsPath + ")", 1), 0));
                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 setValueCP(final long rObjectId, final String slotsPath, final double[] real,
        final double[] imaginary) 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();
                e.rniAssign(rootvar, rObjectId, 0);
                String argvar = DirectJNI.getInstance().newTemporaryVariableName();

                if (real != null && imaginary != null) {

                    String v_temp_1 = DirectJNI.getInstance().newTemporaryVariableName();
                    String v_temp_2 = DirectJNI.getInstance().newTemporaryVariableName();
                    e.rniAssign(v_temp_1, e.rniPutDoubleArray(real), 0);
                    e.rniAssign(v_temp_2, e.rniPutDoubleArray(imaginary), 0);
                    e.rniAssign(argvar, e.rniEval(e.rniParse(v_temp_1 + "+1i*" + v_temp_2, 1), 0), 0);
                    e.rniEval(e.rniParse("rm(" + v_temp_1 + "," + v_temp_2 + ")", 1), 0);

                } else {
                    e.rniEval(e.rniParse(argvar + "<-NULL", 1), 0);
                }/*www.  ja  v  a 2  s  . c  om*/
                e.rniEval(e.rniParse(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 int length(final long rObjectId, final String slotsPath) throws RemoteException {

    final int[] result = new int[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/*w  w  w. j  ava 2  s  .  c  om*/
                        .rniGetIntArray(e.rniEval(e.rniParse("length(" + rootvar + slotsPath + ")", 1), 0))[0];
                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];
}