当前位置: 首页>>代码示例>>Java>>正文


Java ServerRef类代码示例

本文整理汇总了Java中java.rmi.server.ServerRef的典型用法代码示例。如果您正苦于以下问题:Java ServerRef类的具体用法?Java ServerRef怎么用?Java ServerRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServerRef类属于java.rmi.server包,在下文中一共展示了ServerRef类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeCall

import java.rmi.server.ServerRef; //导入依赖的package包/类
/**
 * Receives a dispatch request from the Transport Layer and forwards it to
 * the appropriate dispatcher object.
 * 
 * @param objID
 *            The <code>ObjID</code> received in the request
 * @param hash
 *            The method identificator received in the request
 * @param args
 *            The arguments received in the request
 * @return The result of the invocation in the remote object
 * @throws Exception
 *             If the invocation of the method throws an exception
 */
public final Object executeCall(ObjID objID, long hash, Object[] args)
        throws Exception {
    if (objID == null) {
        throw new NoSuchObjectException(
                "Remote server not available (ObjID == null).");
    }
    ServerRef sref = serverRefsMap.get(objID);
    if (sref == null) {
        throw new NoSuchObjectException(
                "Remote server not available (ObjID not found in lookup).");
    }

    /*
     * REVIEW: For call execution the instance of ServerRef needed is of
     * type UnicastServerRefImpl, instead of ServerRef... (ServerRef doesn't
     * specify the dispach method) Review the casting or the type stored in
     * the container when the implementation of the Activation framework
     * takes place.
     */
    if (sref instanceof UnicastServerRefImpl) {
        return ((UnicastServerRefImpl) sref).executeCall(args, hash);
    }
    throw new NoSuchObjectException(
            "Remote server not available (No UnicastServerImpl reference).");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:40,代码来源:RemoteReferenceManager.java

示例2: getArgsCount

import java.rmi.server.ServerRef; //导入依赖的package包/类
/**
 * Returns the number of arguments received by the method represented by
 * <code>methodHash</code> in the remote object referenced by
 * <code>objID</code>
 * 
 * @param objID
 *            The <code>ObjID</code> received in the request
 * @param methodHash
 *            The method identificator received in the request
 * @return the number of arguments of the method
 * @throws NoSuchObjectException
 *             if there isn't any exported object with the received
 *             <code>ObjID</code>
 */
public final int getArgsCount(ObjID objID, long methodHash)
        throws NoSuchObjectException {
    if (objID == null) {
        throw new NoSuchObjectException(
                "Remote server not available (ObjID == null).");
    }
    ServerRef sref = serverRefsMap.get(objID);
    if (sref == null) {
        throw new NoSuchObjectException(
                "Remote server not available (ObjID not found in lookup).");
    }

    /*
     * REVIEW: For call execution the instance of ServerRef needed is of
     * type UnicastServerRefImpl, instead of ServerRef... (ServerRef doesn't
     * specify the getArgsCount method) Review the casting or the type
     * stored in the container when the implementation of the Activation
     * framework takes place.
     */
    if (sref instanceof UnicastServerRefImpl) {
        return ((UnicastServerRefImpl) sref).getArgsCount(methodHash);
    } 
    throw new NoSuchObjectException(
                "Remote server not available (No UnicastServerImpl reference).");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:40,代码来源:RemoteReferenceManager.java

示例3: sendReturnValue

import java.rmi.server.ServerRef; //导入依赖的package包/类
/**
 * Returns true if the method represented by <code>methodHash</code> in
 * the remote object referenced by <code>objID</code> returns any value.
 * (the return type of the method is different than <code>void</code>)
 * 
 * @param objID
 *            The <code>ObjID</code> received in the request
 * @param methodHash
 *            The method identificator received in the request
 * @return true if the return type of the method is different than
 *         <code>void</code>, otherwise returns false
 * @throws NoSuchObjectException
 *             if there isn't any exported object with the received
 *             <code>ObjID</code>
 */
public final boolean sendReturnValue(ObjID objID, long methodHash)
        throws NoSuchObjectException {
    if (objID == null) {
        throw new NoSuchObjectException(
                "Remote server not available (ObjID == null).");
    }
    ServerRef sref = serverRefsMap.get(objID);
    if (sref == null) {
        throw new NoSuchObjectException(
                "Remote server not available (ObjID not found in lookup).");
    }

    /*
     * REVIEW: For call execution the instance of ServerRef needed is of
     * type UnicastServerRefImpl, instead of ServerRef... (ServerRef doesn't
     * specify the sendReturnValue method) Review the casting or the type
     * stored in the container when the implementation of the Activation
     * framework takes place.
     */
    if (sref instanceof UnicastServerRefImpl) {
        return ((UnicastServerRefImpl) sref).sendReturnValue(methodHash);
    } 
    throw new NoSuchObjectException(
                "Remote server not available (No UnicastServerImpl reference).");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:41,代码来源:RemoteReferenceManager.java

示例4: RemoteReferenceManager

import java.rmi.server.ServerRef; //导入依赖的package包/类
/**
 * Creates a new instance of <code>RemoteReferenceManager</code>. This
 * created instance should be the one and only. (<code>RemoteReferenceManager</code>
 * is a Singleton object)
 */
private RemoteReferenceManager() {
    // Initialize internal tables
    serverRefsMap = new Hashtable<ObjID, ServerRef>();
    exportedRemotes = Collections
            .synchronizedMap(new WeakHashMap<Remote, Pair<Remote, ObjID>>());

    // Export the Distributed Garbage Collector
    dgc = new DGCImpl();
    ObjID objID = new ObjID(ObjID.DGC_ID);
    UnicastServerRefImpl sref = new UnicastServerRefImpl(dgc, objID, null);
    storeExportData(null, objID, sref, null);
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:18,代码来源:RemoteReferenceManager.java

示例5: exportObject

import java.rmi.server.ServerRef; //导入依赖的package包/类
/**
 * Exports the registry implementation in the received port, with the
 * received socket factories. The exportation procedure is similar to the
 * procedure implemented for <code>UnicastRemoteObject</code>, but using
 * the special well-known <code>ObjID</code> for the registry.
 * 
 * @param port
 *            The port where the registry will listen requests
 * @param csf
 *            The <code>ClientSocketFactory</code> that will be used to
 *            contact this registry
 * @param ssf
 *            The <code>ServerSocketFactory</code> used for exportation
 * @param useType2Ref
 *            Indicates whether the references created during object
 *            exportation should be "UnicastRef" or "UnicastRef2"
 * @return A stub for this registry implementation
 * @throws RemoteException
 */
public final Remote exportObject(int port, RMIClientSocketFactory csf,
        RMIServerSocketFactory ssf, boolean useType2Ref)
        throws RemoteException {

    if (port == 0) {
        port = Registry.REGISTRY_PORT;
    }
    RemoteReferenceManager rrm = RemoteReferenceManager
            .getRemoteReferenceManager();
    if (rrm.isExported(this)) {
        throw new RemoteException("Object already exported.");
    }
    TransportManager tm = TransportManager.getTransportManager();
    ObjID objID = new ObjID(ObjID.REGISTRY_ID);
    Endpoint ep = tm.export(objID, port, ssf, csf);
    ServerRef sref;
    Remote stub;
    if (useType2Ref) {
        sref = new UnicastServerRef2Impl(this, objID, ep);
        stub = rrm.createStub(new UnicastRemoteRef2Impl(objID, ep), this);
    } else {
        sref = new UnicastServerRefImpl(this, objID, ep);
        stub = rrm.createStub(new UnicastRemoteRefImpl(objID, ep), this);
    }
    rrm.storeExportData(this, objID, sref, stub);
    return stub;
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:47,代码来源:RegistryImpl.java

示例6: RemoteReferenceManager

import java.rmi.server.ServerRef; //导入依赖的package包/类
/**
 * Creates a new instance of <code>RemoteReferenceManager</code>. This
 * created instance should be the one and only. (<code>RemoteReferenceManager</code>
 * is a Singleton object)
 */
private RemoteReferenceManager() {
    // Initialize internal tables
    serverRefsMap = new ConcurrentHashMap<ObjID, ServerRef>();
    exportedRemotes = Collections
            .synchronizedMap(new WeakHashMap<Remote, Pair<Remote, ObjID>>());

    // Export the Distributed Garbage Collector
    dgc = new DGCImpl();
    ObjID objID = new ObjID(ObjID.DGC_ID);
    UnicastServerRefImpl sref = new UnicastServerRefImpl(dgc, objID, null);
    storeExportData(null, objID, sref, null);
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:18,代码来源:RemoteReferenceManager.java

示例7: storeExportData

import java.rmi.server.ServerRef; //导入依赖的package包/类
/**
 * Stores the data generated during object exportation into the
 * <code>RemoteReferenceManager</code> internal tables
 * 
 * @param obj
 *            The remote object being exported
 * @param objID
 *            The <code>ObjID</code> generated for <code>obj</code>
 * @param sref
 *            The <code>ServerRef</code> generated for <code>obj</code>
 * @param stub
 *            The stub generated for <code>obj</code>
 */
public final void storeExportData(Remote obj, ObjID objID, ServerRef sref,
        Remote stub) {
    serverRefsMap.put(objID, sref);
    exportedRemotes.put(obj, new Pair<Remote, ObjID>(stub, objID));
    dgc.register(objID, obj);
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:20,代码来源:RemoteReferenceManager.java


注:本文中的java.rmi.server.ServerRef类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。