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


Java UnicastServerRef类代码示例

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


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

示例1: export

import sun.rmi.server.UnicastServerRef; //导入依赖的package包/类
private void export(Remote obj) throws RemoteException {
    final RMIExporter exporter =
        (RMIExporter) env.get(RMIExporter.EXPORTER_ATTRIBUTE);
    final boolean daemon = EnvHelp.isServerDaemon(env);

    if (daemon && exporter != null) {
        throw new IllegalArgumentException("If "+EnvHelp.JMX_SERVER_DAEMON+
                " is specified as true, "+RMIExporter.EXPORTER_ATTRIBUTE+
                " cannot be used to specify an exporter!");
    }

    if (daemon) {
        if (csf == null && ssf == null) {
            new UnicastServerRef(port).exportObject(obj, null, true);
        } else {
            new UnicastServerRef2(port, csf, ssf).exportObject(obj, null, true);
        }
    } else if (exporter != null) {
        exporter.exportObject(obj, port, csf, ssf);
    } else {
        UnicastRemoteObject.exportObject(obj, port, csf, ssf);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:RMIJRMPServerImpl.java

示例2: getRegistryPort

import sun.rmi.server.UnicastServerRef; //导入依赖的package包/类
/**
 * Returns the port number the RMI {@link Registry} is running on.
 *
 * @param registry the registry to find the port of.
 * @return the port number the registry is using.
 * @throws RuntimeException if there was a problem getting the port number.
 */
public static int getRegistryPort(Registry registry) {
    int port = -1;

    try {
        RemoteRef remoteRef = ((RegistryImpl)registry).getRef();
        LiveRef liveRef = ((UnicastServerRef)remoteRef).getLiveRef();
        Endpoint endpoint = liveRef.getChannel().getEndpoint();
        TCPEndpoint tcpEndpoint = (TCPEndpoint) endpoint;
        port = tcpEndpoint.getPort();
    } catch (Exception ex) {
        throw new RuntimeException("Error getting registry port.", ex);
    }

    return port;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:TestLibrary.java

示例3: UnicastServerRef

import sun.rmi.server.UnicastServerRef; //导入依赖的package包/类
@Test(dataProvider = "bindData")
public void UnicastServerRef(String name, Object obj, int expectedFilterCount) throws RemoteException {
    try {
        RemoteImpl impl = RemoteImpl.create();
        UnicastServerRef ref = new UnicastServerRef(new LiveRef(0), impl.checker);

        Echo client = (Echo) ref.exportObject(impl, null, false);

        int count = client.filterCount(obj);
        System.out.printf("count: %d, obj: %s%n", count, obj);
        Assert.assertEquals(count, expectedFilterCount, "wrong number of filter calls");
    } catch (RemoteException rex) {
        if (expectedFilterCount == -1 &&
                UnmarshalException.class.equals(rex.getCause().getClass()) &&
                InvalidClassException.class.equals(rex.getCause().getCause().getClass())) {
            return; // normal expected exception
        }
        rex.printStackTrace();
        Assert.fail("unexpected remote exception", rex);
    } catch (Exception ex) {
        Assert.fail("unexpected exception", ex);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:FilterUSRTest.java

示例4: getObject

import sun.rmi.server.UnicastServerRef; //导入依赖的package包/类
public UnicastRemoteObject getObject ( final String command ) throws Exception {
    int jrmpPort = Integer.parseInt(command);
    UnicastRemoteObject uro = Reflections.createWithConstructor(ActivationGroupImpl.class, RemoteObject.class, new Class[] {
        RemoteRef.class
    }, new Object[] {
        new UnicastServerRef(jrmpPort)
    });

    Reflections.getField(UnicastRemoteObject.class, "port").set(uro, jrmpPort);
    return uro;
}
 
开发者ID:hucheat,项目名称:APacheSynapseSimplePOC,代码行数:12,代码来源:JRMPListener.java

示例5: exportObject

import sun.rmi.server.UnicastServerRef; //导入依赖的package包/类
/**
 * Exports the specified object using the specified server ref.
 */
private static Remote exportObject(Remote obj, UnicastServerRef sref)
    throws RemoteException
{
    // if obj extends UnicastRemoteObject, set its ref.
    if (obj instanceof UnicastRemoteObject) {
        ((UnicastRemoteObject) obj).ref = sref;
    }
    return sref.exportObject(obj, null, false);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:UnicastRemoteObject.java

示例6: run

import sun.rmi.server.UnicastServerRef; //导入依赖的package包/类
public Void run() {
    ClassLoader savedCcl =
        Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(
            ClassLoader.getSystemClassLoader());

        /*
         * Put remote collector object in table by hand to prevent
         * listen on port.  (UnicastServerRef.exportObject would
         * cause transport to listen.)
         */
        try {
            dgc = new DGCImpl();
            ObjID dgcID = new ObjID(ObjID.DGC_ID);
            LiveRef ref = new LiveRef(dgcID, 0);
            UnicastServerRef disp = new UnicastServerRef(ref);
            Remote stub =
                Util.createProxy(DGCImpl.class,
                                 new UnicastRef(ref), true);
            disp.setSkeleton(dgc);
            Target target =
                new Target(dgc, disp, stub, dgcID, true);
            ObjectTable.putTarget(target);
        } catch (RemoteException e) {
            throw new Error(
                "exception initializing server-side DGC", e);
        }
    } finally {
        Thread.currentThread().setContextClassLoader(savedCcl);
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:DGCImpl.java

示例7: ActivatorImpl

import sun.rmi.server.UnicastServerRef; //导入依赖的package包/类
/**
 * Construct a new Activator on a specified port.
 */
ActivatorImpl(int port, RMIServerSocketFactory ssf)
    throws RemoteException
{
    /* Server ref must be created and assigned before remote object
     * 'this' can be exported.
     */
    LiveRef lref =
        new LiveRef(new ObjID(ObjID.ACTIVATOR_ID), port, null, ssf);
    UnicastServerRef uref = new UnicastServerRef(lref);
    ref = uref;
    uref.exportObject(this, null, false);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:Activation.java

示例8: ActivationSystemImpl

import sun.rmi.server.UnicastServerRef; //导入依赖的package包/类
ActivationSystemImpl(int port, RMIServerSocketFactory ssf)
    throws RemoteException
{
    /* Server ref must be created and assigned before remote object
     * 'this' can be exported.
     */
    LiveRef lref = new LiveRef(new ObjID(4), port, null, ssf);
    UnicastServerRef uref = new UnicastServerRef(lref);
    ref = uref;
    uref.exportObject(this, null);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:Activation.java

示例9: setup

import sun.rmi.server.UnicastServerRef; //导入依赖的package包/类
private void setup(UnicastServerRef uref)
    throws RemoteException
{
    /* Server ref must be created and assigned before remote
     * object 'this' can be exported.
     */
    ref = uref;
    uref.exportObject(this, null, true);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:RegistryImpl.java

示例10: getObject

import sun.rmi.server.UnicastServerRef; //导入依赖的package包/类
public UnicastRemoteObject getObject ( String port ) throws Exception {
    int jrmpPort = Integer.parseInt(port);
    UnicastRemoteObject uro = Reflections.createWithConstructor(ActivationGroupImpl.class, RemoteObject.class, new Class[] {
        RemoteRef.class
    }, new Object[] {
        new UnicastServerRef(jrmpPort)
    });

    Reflections.getField(UnicastRemoteObject.class, "port").set(uro, jrmpPort);
    return uro;
}
 
开发者ID:pimps,项目名称:ysoserial-modified,代码行数:12,代码来源:JRMPListener.java

示例11: handleRMI

import sun.rmi.server.UnicastServerRef; //导入依赖的package包/类
/**
 * @param ois
 * @param out
 * @throws IOException
 * @throws ClassNotFoundException
 * @throws NamingException
 */
private boolean handleRMI ( ObjectInputStream ois, DataOutputStream out ) throws Exception {
    int method = ois.readInt(); // method
    ois.readLong(); // hash

    if ( method != 2 ) { // lookup
        return false;
    }

    String object = (String) ois.readObject();
    System.err.println("Is RMI.lookup call for " + object + " " + method);

    out.writeByte(TransportConstants.Return);// transport op
    try ( ObjectOutputStream oos = new MarshalOutputStream(out, this.classpathUrl) ) {

        oos.writeByte(TransportConstants.NormalReturn);
        new UID().write(oos);

        System.err.println(
            String.format(
                "Sending remote classloading stub targeting %s",
                new URL(this.classpathUrl, this.classpathUrl.getRef().replace('.', '/').concat(".class"))));

        ReferenceWrapper rw = Reflections.createWithoutConstructor(ReferenceWrapper.class);
        Reflections.setFieldValue(rw, "wrappee", new Reference("Foo", this.classpathUrl.getRef(), this.classpathUrl.toString()));
        Field refF = RemoteObject.class.getDeclaredField("ref");
        refF.setAccessible(true);
        refF.set(rw, new UnicastServerRef(12345));

        oos.writeObject(rw);

        oos.flush();
        out.flush();
    }
    return true;
}
 
开发者ID:mbechler,项目名称:marshalsec,代码行数:43,代码来源:RMIRefServer.java


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