Example usage for java.rmi.server UnicastRemoteObject exportObject

List of usage examples for java.rmi.server UnicastRemoteObject exportObject

Introduction

In this page you can find the example usage for java.rmi.server UnicastRemoteObject exportObject.

Prototype

public static Remote exportObject(Remote obj, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
        throws RemoteException 

Source Link

Document

Exports the remote object to make it available to receive incoming calls, using a transport specified by the given socket factory.

Usage

From source file:xbird.xquery.func.ext.RemoteEval.java

private static ShippedVariable wrapVariableToShip(QueryRequest request, VarRef ref, ValueSequence contextSeq,
        DynamicContext dynEnv) throws XQueryException {
    QualifiedName varname = ref.getName();
    Variable var = ref.getValue();
    Sequence result = var.getResult();
    if (result == null) {
        result = var.eval(contextSeq, dynEnv);
    }/*from   w w  w .  j a v a2 s  .co m*/
    ReturnType rettype = request.getReturnType();
    final ShippedVariable shiped;
    if (ENV_NOWRAP_VARSHIP || !rettype.isRemoteSequnece()) {
        shiped = new ShippedVariable(varname, new MarshalledSequence(result, dynEnv));
    } else {
        final RemoteSequenceProxy proxy = new RemoteSequenceProxy(result, request);
        try {
            UnicastRemoteObject.exportObject(proxy, 0, TimeoutSocketProdiver.createClientSocketFactory(),
                    TimeoutSocketProdiver.createServerSocketFactory());
        } catch (RemoteException e) {
            throw new XQueryException("failed exporting variable: " + varname, e);
        }
        RemoteSequence remote = new RemoteSequence(proxy, result.getType());
        shiped = new ShippedVariable(varname, remote);
    }
    return shiped;
}