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


Java UnicastRemoteObject.exportObject方法代码示例

本文整理汇总了Java中java.rmi.server.UnicastRemoteObject.exportObject方法的典型用法代码示例。如果您正苦于以下问题:Java UnicastRemoteObject.exportObject方法的具体用法?Java UnicastRemoteObject.exportObject怎么用?Java UnicastRemoteObject.exportObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.rmi.server.UnicastRemoteObject的用法示例。


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

示例1: export

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的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: main

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 6275081\n");

    Remote impl = new Remote() { };
    long start = System.currentTimeMillis();
    for (int i = 0; i < REPS; i++) {
        System.err.println(i);
        UnicastRemoteObject.exportObject(impl, 0);
        UnicastRemoteObject.unexportObject(impl, true);
        Thread.sleep(1);    // work around BindException (bug?)
    }
    long delta = System.currentTimeMillis() - start;
    System.err.println(REPS + " export/unexport operations took " +
                       delta + "ms");
    if (delta > TIMEOUT) {
        throw new Error("TEST FAILED: took over " + TIMEOUT + "ms");
    }
    System.err.println("TEST PASSED");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:RapidExportUnexport.java

示例3: ActivationGroupImpl

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
/**
 * Creates a default activation group implementation.
 *
 * @param id the group's identifier
 * @param data ignored
 */
public ActivationGroupImpl(ActivationGroupID id, MarshalledObject<?> data)
    throws RemoteException
{
    super(id);
    groupID = id;

    /*
     * Unexport activation group impl and attempt to export it on
     * an unshared anonymous port.  See 4692286.
     */
    unexportObject(this, true);
    RMIServerSocketFactory ssf = new ServerSocketFactoryImpl();
    UnicastRemoteObject.exportObject(this, 0, null, ssf);

    if (System.getSecurityManager() == null) {
        try {
            // Provide a default security manager.
            System.setSecurityManager(new SecurityManager());

        } catch (Exception e) {
            throw new RemoteException("unable to set security manager", e);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:ActivationGroupImpl.java

示例4: run

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
/**
 * Export remote objects.
 * Arguments: <# objects>
 */
public long run(String[] args) throws Exception {
    int size = Integer.parseInt(args[0]);
    Remote[] objs = new Remote[size];
    for (int i = 0; i < size; i++)
        objs[i] = new RemoteObj();

    long start = System.currentTimeMillis();
    for (int i = 0; i < size; i++)
        UnicastRemoteObject.exportObject(objs[i],0);
    long time = System.currentTimeMillis() - start;

    for (int i = 0; i < size; i++)
        UnicastRemoteObject.unexportObject(objs[i], true);
    return time;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:ExportObjs.java

示例5: main

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 6275081\n");

    Remote impl = new Remote() { };
    long start = System.currentTimeMillis();
    for (int i = 0; i < REPS; i++) {
        System.err.println(i);
        UnicastRemoteObject.exportObject(impl, PORT);
        UnicastRemoteObject.unexportObject(impl, true);
        Thread.sleep(1);    // work around BindException (bug?)
    }
    long delta = System.currentTimeMillis() - start;
    System.err.println(REPS + " export/unexport operations took " +
                       delta + "ms");
    if (delta > TIMEOUT) {
        throw new Error("TEST FAILED: took over " + TIMEOUT + "ms");
    }
    System.err.println("TEST PASSED");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:RapidExportUnexport.java

示例6: main

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
public static void main(String[] args) {
    map_filename_blocks = new HashMap<>();
    block_number = 0;
    map_block_datanode = new HashMap<>();
    /* Write the existing data */
    restoreFilelist();
    setDatanodeIps();
    String myip = getMyIp();
    if (myip.equals("")) {
        System.err.println("Error in Getting My ip");
        System.exit(-1);
    }
    System.setProperty("java.rmi.server.hostname", myip);
    try {
        Namenode obj = new Namenode();
        Namenodedef stub = (Namenodedef) UnicastRemoteObject.exportObject(obj, 0);
        Registry reg = LocateRegistry.getRegistry("0.0.0.0", 1099);
        reg.rebind("NameNode", stub);
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
开发者ID:harry-7,项目名称:HDFS-Implementation,代码行数:23,代码来源:Namenode.java

示例7: getInstance

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
public String getInstance(IStochModelFactory.OutputLevel outputLevel)  {
    String instanceID=null;

 try {
        nModels++;
        instanceID= FactoryBindingID+"_IRmiIStochModel_"+nModels;

        // Create a new model instance
        IStochModelInstance newStochModel = stochModelFactory.getInstance(outputLevel);
        // Create a new server instance and set the new model for this instance
        Server obj = new Server();
        obj.setModel(newStochModel);

        IRmiIStochModel stub = (IRmiIStochModel) UnicastRemoteObject.exportObject(obj, 0);

        // Register this insntance such that it will not be deleted.
        allStochModels.add(stub);

       // Bind the remote object's stub in the registry
     Registry registry = LocateRegistry.getRegistry();
     registry.bind(instanceID, stub);

     System.err.println("Server has created model "+instanceID);
 } catch (Exception e) {
     System.err.println("Server exception when creating new model: " + e.toString());
     e.printStackTrace();
 }
    return instanceID;
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:30,代码来源:Server.java

示例8: main

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 6269166\n");
    RMISocketFactory.setSocketFactory(new SF());
    Remote impl = new ReuseDefaultPort();
    Remote stub = UnicastRemoteObject.exportObject(impl, 0);
    System.err.println("- exported object: " + stub);
    try {
        Registry registry = LocateRegistry.createRegistry(rmiPort);
        System.err.println("- exported registry: " + registry);
        System.err.println("TEST PASSED");
    } finally {
        UnicastRemoteObject.unexportObject(impl, true);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:ReuseDefaultPort.java

示例9: main

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 6332349\n");

    Ping impl = new PingImpl();
    Reference<?> ref = new WeakReference<Ping>(impl);
    try {
        Ping stub = (Ping) UnicastRemoteObject.exportObject(impl, 0);
        Object notSerializable = new Object();
        stub.ping(impl, null);
        try {
            stub.ping(impl, notSerializable);
        } catch (MarshalException e) {
            if (e.getCause() instanceof NotSerializableException) {
                System.err.println("ping invocation failed as expected");
            } else {
                throw e;
            }
        }
    } finally {
        UnicastRemoteObject.unexportObject(impl, true);
    }
    impl = null;

    // Might require multiple calls to System.gc() for weak-references
    // processing to be complete. If the weak-reference is not cleared as
    // expected we will hang here until timed out by the test harness.
    while (true) {
        System.gc();
        Thread.sleep(20);
        if (ref.get() == null) {
            break;
        }
    }

    System.err.println("TEST PASSED");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:PinLastArguments.java

示例10: tryWith

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
private static void tryWith(Throwable t) throws Exception {
    Remote impl = new Remote() { };
    try {
        CountDownLatch latch = new CountDownLatch(1);
        UnicastRemoteObject.exportObject(impl, 0, null, new SSF(t, latch));
        if (!latch.await(TIMEOUT, TimeUnit.MILLISECONDS)) {
            throw new Error("server socket not closed");
        }
    } finally {
        UnicastRemoteObject.unexportObject(impl, true);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:CloseServerSocketOnTermination.java

示例11: export

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
@Contract("!null->!null")
public synchronized <T extends Remote> T export(@Nullable T child) throws RemoteException {
  if (child == null) return null;
  @SuppressWarnings("unchecked") final T result = (T)UnicastRemoteObject.exportObject(child, 0);
  myChildren.put((RemoteObject)child, result);
  ((RemoteObject)child).myParent = this;
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:RemoteObject.java

示例12: createEmbedder

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
public MavenServerEmbedder createEmbedder(MavenServerSettings settings) throws RemoteException {
  try {
    Maven32ServerEmbedderImpl result = new Maven32ServerEmbedderImpl(settings);
    UnicastRemoteObject.exportObject(result, 0);
    return result;
  }
  catch (RemoteException e) {
    throw rethrowException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:Maven32ServerImpl.java

示例13: main

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
    try {
        testPkg.Server obj = new testPkg.Server();
        testPkg.Hello stub = (testPkg.Hello) UnicastRemoteObject.exportObject(obj, 0);
        // Bind the remote object's stub in the registry
        Registry registry =
            LocateRegistry.getRegistry(TestLibrary.READTEST_REGISTRY_PORT);
        registry.bind("Hello", stub);

        System.err.println("Server ready");

        // now, let's test client
        testPkg.Client client =
            new testPkg.Client(TestLibrary.READTEST_REGISTRY_PORT);
        String testStubReturn = client.testStub();
        if(!testStubReturn.equals(obj.hello)) {
            throw new RuntimeException("Test Fails : unexpected string from stub call");
        } else {
            System.out.println("Test passed");
        }
        registry.unbind("Hello");

    } catch (Exception e) {
        System.err.println("Server exception: " + e.toString());
        e.printStackTrace();
    }

}
 
开发者ID:JetBrains,项目名称:jdk8u_jdk,代码行数:29,代码来源:readTest.java

示例14: exportObject

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
public Remote exportObject(Remote obj,
                           int port,
                           RMIClientSocketFactory csf,
                           RMIServerSocketFactory ssf)
    throws RemoteException {
    System.out.println("CustomRMIExporter::exportObject():: " +
                       "Remote = " + obj);
    if (obj.toString().startsWith(
            "javax.management.remote.rmi.RMIJRMPServerImpl"))
        rmiServerExported = true;
    if (obj.toString().startsWith(
            "javax.management.remote.rmi.RMIConnectionImpl"))
        rmiConnectionExported = true;
    return UnicastRemoteObject.exportObject(obj, port, csf, ssf);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:16,代码来源:RMIExporterTest.java

示例15: main

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 6269166\n");
    RMISocketFactory.setSocketFactory(new SF());
    Remote impl = new ReuseDefaultPort();
    Remote stub = UnicastRemoteObject.exportObject(impl, 0);
    System.err.println("- exported object: " + stub);
    try {
        Registry registry = LocateRegistry.createRegistry(PORT);
        System.err.println("- exported registry: " + registry);
        System.err.println("TEST PASSED");
    } finally {
        UnicastRemoteObject.unexportObject(impl, true);
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:15,代码来源:ReuseDefaultPort.java


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