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


Java UnicastRemoteObject.unexportObject方法代码示例

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


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

示例1: unBind

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
/**
 * <p>
 * Un-bind the scheduler from an RMI registry.
 * </p>
 */
private void unBind() throws RemoteException {
    String host = resources.getRMIRegistryHost();
    // don't un-export if we're not configured to do so...
    if (host == null || host.length() == 0) {
        return;
    }

    Registry registry = LocateRegistry.getRegistry(resources
            .getRMIRegistryHost(), resources.getRMIRegistryPort());

    String bindName = resources.getRMIBindName();
    
    try {
        registry.unbind(bindName);
        UnicastRemoteObject.unexportObject(this, true);
    } catch (java.rmi.NotBoundException nbe) {
    }

    getLog().info("Scheduler un-bound from name '" + bindName + "' in RMI registry");
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:26,代码来源:QuartzScheduler.java

示例2: unexportObject

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
/**
 * Deregisters a server object from the runtime, allowing the object to become
 * available for garbage collection.
 * @param obj the object to unexport.
 * @exception NoSuchObjectException if the remote object is not
 * currently exported.
 */
public void unexportObject(Remote obj)
    throws NoSuchObjectException {

    if (obj == null) {
        throw new NullPointerException("invalid argument");
    }

    if (StubAdapter.isStub(obj) ||
        obj instanceof java.rmi.server.RemoteStub) {
        throw new NoSuchObjectException(
            "Can only unexport a server object.");
    }

    Tie theTie = Util.getTie(obj);
    if (theTie != null) {
        Util.unexportObject(obj);
    } else {
        if (Utility.loadTie(obj) == null) {
            UnicastRemoteObject.unexportObject(obj,true);
        } else {
            throw new NoSuchObjectException("Object not exported.");
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:PortableRemoteObject.java

示例3: shutdown

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
public void shutdown() {
    try {
        System.err.println(
            "(ShutdownImpl.shutdown) shutdown method invoked:");

        UnicastRemoteObject.unexportObject(this, true);
        System.err.println(
            "(ShutdownImpl.shutdown) shutdown object unexported");

        Thread.sleep(500);
        System.err.println("(ShutDownImpl.shutdown) FEE");
        Thread.sleep(500);
        System.err.println("(ShutDownImpl.shutdown) FIE");
        Thread.sleep(500);
        System.err.println("(ShutDownImpl.shutdown) FOE");
        Thread.sleep(500);
        System.err.println("(ShutDownImpl.shutdown) FOO");

        monitor.declareStillAlive();
        System.err.println("(ShutDownImpl.shutdown) still alive!");
    } catch (Exception e) {
        throw new RuntimeException(
            "unexpected exception occurred in shutdown method", e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:ShutdownImpl.java

示例4: 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

示例5: stopAgent

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
public synchronized void stopAgent() {
  stopHttpService();

  if (!this.running) {
    return;
  }

  if (logger.isDebugEnabled()) {
    logger.debug("Stopping jmx manager agent");
  }
  try {
    jmxConnectorServer.stop();
    UnicastRemoteObject.unexportObject(registry, true);
  } catch (Exception e) {
    throw new ManagementException(e);
  }

  this.running = false;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:20,代码来源:ManagementAgent.java

示例6: 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

示例7: main

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
/**
 * Entry point for the JVM forked by {@link #testSeparateJVMs()}.
 */
public static void main(String[] arguments) throws IOException, AlreadyBoundException, NotBoundException {
    LocalController localController = new LocalController();

    Registry registry = LocateRegistry.createRegistry(REGISTRY_PORT);
    Controller controller = (Controller) UnicastRemoteObject.exportObject(localController, 0);
    registry.bind(CONTROLLER, controller);

    Path lockFile = Paths.get(arguments[0]);
    RepositorySystemSession repositorySystemSession = Mockito.mock(RepositorySystemSession.class);
    try (FileLockSyncContextFactory syncContextFactory = new FileLockSyncContextFactory(lockFile)) {
        new SyncTask(syncContextFactory, localController, repositorySystemSession).run();
    }

    UnicastRemoteObject.unexportObject(localController, true);
    UnicastRemoteObject.unexportObject(registry, true);
}
 
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:20,代码来源:ITFileLockSyncContextFactory.java

示例8: main

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        InetAddress localAddress = InetAddress.getLocalHost();
        String[] hostlist = new String[] {
            localAddress.getHostAddress(), localAddress.getHostName() };

        for (int i = 0; i < hostlist.length; i++) {

            System.setProperty("java.rmi.server.hostname", hostlist[i]);
            Remote impl = new ChangeHostName();
            System.err.println("\ncreated impl extending URO: " + impl);

            Receiver stub = (Receiver) RemoteObject.toStub(impl);
            System.err.println("stub for impl: " + stub);

            System.err.println("invoking method on stub");
            stub.receive(stub);

            UnicastRemoteObject.unexportObject(impl, true);
            System.err.println("unexported impl");

            if (stub.toString().indexOf(hostlist[i]) >= 0) {
                System.err.println("stub's ref contains hostname: " +
                                   hostlist[i]);
            } else {
                throw new RuntimeException(
                    "TEST FAILED: stub's ref doesn't contain hostname: " +
                    hostlist[i]);
            }
        }
        System.err.println("TEST PASSED");
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:33,代码来源:ChangeHostName.java

示例9: main

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

        verifyPortFree(PORT);
        Registry registry = LocateRegistry.createRegistry(PORT);
        System.err.println("- exported registry: " + registry);
        verifyPortInUse(PORT);
        UnicastRemoteObject.unexportObject(registry, true);
        System.err.println("- unexported registry");
        Thread.sleep(1000);        // work around BindException (bug?)
        verifyPortFree(PORT);

        /*
         * The follow portion of this test is disabled temporarily
         * because 4457683 was partially backed out because of
         * 6269166; for now, only server sockets originally opened for
         * exports on non-anonymous ports will be closed when all of
         * the corresponding remote objects have been exported.  A
         * separate bug will be filed to represent the remainder of
         * 4457683 for anonymous-port exports.
         */

//      SSF ssf = new SSF();
//      Remote impl = new CloseServerSocket();
//      Remote stub = UnicastRemoteObject.exportObject(impl, 0, null, ssf);
//      System.err.println("- exported object: " + stub);
//      UnicastRemoteObject.unexportObject(impl, true);
//      System.err.println("- unexported object");
//      synchronized (ssf) {
//          if (!ssf.serverSocketClosed) {
//              throw new RuntimeException("TEST FAILED: " +
//                                         "server socket not closed");
//          }
//      }

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

示例10: 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:PinLastArguments.java

示例11: unexport

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
/**
 * Unexports the specified remote object.  Returns true if successful,
 * false otherwise.
 */
public boolean unexport(Remote obj, boolean force) throws RemoteException {
    WeakReference iref = (WeakReference) implTable.get(obj);
    if (iref == null)
        return false;
    Remote impl = (Remote) iref.get();
    if (impl == null)
        return false;
    return UnicastRemoteObject.unexportObject(impl, force);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:BenchServerImpl.java

示例12: unexport

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
/** routine to unexport an object */
public static void unexport(Remote obj) {
    if (obj != null) {
        try {
            mesg("unexporting object...");
            UnicastRemoteObject.unexportObject(obj, true);
        } catch (NoSuchObjectException munch) {
        } catch (Exception e) {
            e.getMessage();
            e.printStackTrace();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:TestLibrary.java

示例13: main

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        System.err.println("\nRegression test for bug 4513223\n");

        Remote impl2 = null;
        try {
            Remote impl = new MarshalAfterUnexport2();
            System.err.println(
                "created impl extending URO (with a UnicastServerRef2): " +
                impl);

            Receiver stub = (Receiver) RemoteObject.toStub(impl);
            System.err.println("stub for impl: " + stub);

            UnicastRemoteObject.unexportObject(impl, true);
            System.err.println("unexported impl");

            impl2 = new MarshalAfterUnexport2();
            Receiver stub2 = (Receiver) RemoteObject.toStub(impl2);

            System.err.println("marshalling unexported object:");
            MarshalledObject mobj = new MarshalledObject(impl);

            System.err.println("passing unexported object via RMI-JRMP:");
            stub2.receive(stub);

            System.err.println("TEST PASSED");
        } finally {
            if (impl2 != null) {
                try {
                    UnicastRemoteObject.unexportObject(impl2, true);
                } catch (Throwable t) {
                }
            }
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:MarshalAfterUnexport2.java

示例14: unexport

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
private void unexport(Remote obj, boolean force)
        throws NoSuchObjectException {
    RMIExporter exporter =
        (RMIExporter) env.get(RMIExporter.EXPORTER_ATTRIBUTE);
    if (exporter == null)
        UnicastRemoteObject.unexportObject(obj, force);
    else
        exporter.unexportObject(obj, force);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:RMIJRMPServerImpl.java

示例15: unexport

import java.rmi.server.UnicastRemoteObject; //导入方法依赖的package包/类
private static void unexport(Remote obj) {
    for (;;) {
        try {
            if (UnicastRemoteObject.unexportObject(obj, false) == true) {
                break;
            } else {
                Thread.sleep(100);
            }
        } catch (Exception e) {
            continue;
        }
    }
}
 
开发者ID:JetBrains,项目名称:jdk8u_jdk,代码行数:14,代码来源:Activation.java


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