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


Java UnicastRemoteObject类代码示例

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


UnicastRemoteObject类属于java.rmi.server包,在下文中一共展示了UnicastRemoteObject类的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:lamsfoundation,项目名称:lams,代码行数:26,代码来源:QuartzScheduler.java

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

示例3: run

import java.rmi.server.UnicastRemoteObject; //导入依赖的package包/类
@Override
public void run() {
    //напишите тут ваш код
    try {
        //создание объекта для удаленного доступа
        final Animal cat = new Cat("Barsik");
        final Animal dog = new Dog("Palkan");

        //создание реестра расшареных объетов
        registry = LocateRegistry.createRegistry(2099);

        //создание "заглушки" – приемника удаленных вызовов
        Remote stubCat = UnicastRemoteObject.exportObject(cat, 0);
        Remote stubDog = UnicastRemoteObject.exportObject(dog, 0);

        //регистрация "заглушки" в реесте
        registry.bind(BINDING_NAME1, stubCat);
        registry.bind(BINDING_NAME2, stubDog);

    } catch (RemoteException | AlreadyBoundException e) {
        e.printStackTrace();
    }
}
 
开发者ID:avedensky,项目名称:JavaRushTasks,代码行数:24,代码来源:Solution.java

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

示例5: 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:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:ActivationGroupImpl.java

示例6: checkInactiveGroup

import java.rmi.server.UnicastRemoteObject; //导入依赖的package包/类
private void checkInactiveGroup() {
    boolean groupMarkedInactive = false;
    synchronized (this) {
        if (active.size() == 0 && lockedIDs.size() == 0 &&
            groupInactive == false)
        {
            groupInactive = true;
            groupMarkedInactive = true;
        }
    }

    if (groupMarkedInactive) {
        try {
            super.inactiveGroup();
        } catch (Exception ignoreDeactivateFailure) {
        }

        try {
            UnicastRemoteObject.unexportObject(this, true);
        } catch (NoSuchObjectException allowUnexportedGroup) {
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:ActivationGroupImpl.java

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

示例8: 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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:ExportObjs.java

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

示例10: 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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:ShutdownImpl.java

示例11: main

import java.rmi.server.UnicastRemoteObject; //导入依赖的package包/类
public static void main(String[] args) {
    try {
        int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port"));
        Registry registry =
            LocateRegistry.getRegistry("", registryPort);
        ShutdownMonitor monitor = (ShutdownMonitor)
            registry.lookup(KeepAliveDuringCall.BINDING);
        System.err.println("(ShutdownImpl) retrieved shutdown monitor");

        impl = new ShutdownImpl(monitor);
        Shutdown stub = (Shutdown) UnicastRemoteObject.exportObject(impl);
        System.err.println("(ShutdownImpl) exported shutdown object");

        monitor.submitShutdown(stub);
        System.err.println("(ShutdownImpl) submitted shutdown object");

    } catch (Exception e) {
        System.err.println("(ShutdownImpl) TEST SUBPROCESS FAILURE:");
        e.printStackTrace();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:ShutdownImpl.java

示例12: main

import java.rmi.server.UnicastRemoteObject; //导入依赖的package包/类
public static void main(String args[]) {
    try {
        Hello obj = new Server();
        Hello stub = (Hello) UnicastRemoteObject.exportObject(obj, 0);

        Client client = new Client(stub);
        String testStubReturn = client.testStub();
        System.out.println("Stub is: " + testStubReturn);
        if (!testStubReturn.equals(obj.sayHello())) {
            throw new RuntimeException("Unexpected string from stub call, expected \""
                    + testStubReturn + "\", actual \"" + obj.sayHello() + "\"");
        } else {
            System.out.println("Test passed");
        }

        System.exit(0);
    } catch (Throwable e) {
        e.printStackTrace();
        System.exit(-1);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:DummyApp.java

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

示例14: create

import java.rmi.server.UnicastRemoteObject; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions")
@Override
@NotNull
protected synchronized MavenServer create() throws RemoteException {
  MavenServer result;
  try {
    result = mySupport.acquire(this, "");
  }
  catch (Exception e) {
    throw new RemoteException("Cannot start maven service", e);
  }

  myLoggerExported = UnicastRemoteObject.exportObject(myLogger, 0) != null;
  if (!myLoggerExported) throw new RemoteException("Cannot export logger object");

  myDownloadListenerExported = UnicastRemoteObject.exportObject(myDownloadListener, 0) != null;
  if (!myDownloadListenerExported) throw new RemoteException("Cannot export download listener object");

  result.set(myLogger, myDownloadListener);

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:MavenServerManager.java

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


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