Java 类java.rmi.server.ExportException 实例源码

项目:OpenJSharp    文件:UnicastServerRef.java   
/**
 * Export this object, create the skeleton and stubs for this
 * dispatcher.  Create a stub based on the type of the impl,
 * initialize it with the appropriate remote reference. Create the
 * target defined by the impl, dispatcher (this) and stub.
 * Export that target via the Ref.
 */
public Remote exportObject(Remote impl, Object data,
                           boolean permanent)
    throws RemoteException
{
    Class<?> implClass = impl.getClass();
    Remote stub;

    try {
        stub = Util.createProxy(implClass, getClientRef(), forceStubUse);
    } catch (IllegalArgumentException e) {
        throw new ExportException(
            "remote object implements illegal remote interface", e);
    }
    if (stub instanceof RemoteStub) {
        setSkeleton(impl);
    }

    Target target =
        new Target(impl, this, stub, ref.getObjID(), permanent);
    ref.exportObject(target);
    hashToMethod_Map = hashToMethod_Maps.get(implClass);
    return stub;
}
项目:jdk8u-jdk    文件:UnicastServerRef.java   
/**
 * Export this object, create the skeleton and stubs for this
 * dispatcher.  Create a stub based on the type of the impl,
 * initialize it with the appropriate remote reference. Create the
 * target defined by the impl, dispatcher (this) and stub.
 * Export that target via the Ref.
 */
public Remote exportObject(Remote impl, Object data,
                           boolean permanent)
    throws RemoteException
{
    Class<?> implClass = impl.getClass();
    Remote stub;

    try {
        stub = Util.createProxy(implClass, getClientRef(), forceStubUse);
    } catch (IllegalArgumentException e) {
        throw new ExportException(
            "remote object implements illegal remote interface", e);
    }
    if (stub instanceof RemoteStub) {
        setSkeleton(impl);
    }

    Target target =
        new Target(impl, this, stub, ref.getObjID(), permanent);
    ref.exportObject(target);
    hashToMethod_Map = hashToMethod_Maps.get(implClass);
    return stub;
}
项目:openjdk-jdk10    文件:UnicastServerRef.java   
/**
 * Export this object, create the skeleton and stubs for this
 * dispatcher.  Create a stub based on the type of the impl,
 * initialize it with the appropriate remote reference. Create the
 * target defined by the impl, dispatcher (this) and stub.
 * Export that target via the Ref.
 */
public Remote exportObject(Remote impl, Object data,
                           boolean permanent)
    throws RemoteException
{
    Class<?> implClass = impl.getClass();
    Remote stub;

    try {
        stub = Util.createProxy(implClass, getClientRef(), forceStubUse);
    } catch (IllegalArgumentException e) {
        throw new ExportException(
            "remote object implements illegal remote interface", e);
    }
    if (stub instanceof RemoteStub) {
        setSkeleton(impl);
    }

    Target target =
        new Target(impl, this, stub, ref.getObjID(), permanent);
    ref.exportObject(target);
    hashToMethod_Map = hashToMethod_Maps.get(implClass);
    return stub;
}
项目:openjdk9    文件:UnicastServerRef.java   
/**
 * Export this object, create the skeleton and stubs for this
 * dispatcher.  Create a stub based on the type of the impl,
 * initialize it with the appropriate remote reference. Create the
 * target defined by the impl, dispatcher (this) and stub.
 * Export that target via the Ref.
 */
public Remote exportObject(Remote impl, Object data,
                           boolean permanent)
    throws RemoteException
{
    Class<?> implClass = impl.getClass();
    Remote stub;

    try {
        stub = Util.createProxy(implClass, getClientRef(), forceStubUse);
    } catch (IllegalArgumentException e) {
        throw new ExportException(
            "remote object implements illegal remote interface", e);
    }
    if (stub instanceof RemoteStub) {
        setSkeleton(impl);
    }

    Target target =
        new Target(impl, this, stub, ref.getObjID(), permanent);
    ref.exportObject(target);
    hashToMethod_Map = hashToMethod_Maps.get(implClass);
    return stub;
}
项目:jdk8u_jdk    文件:UnicastServerRef.java   
/**
 * Export this object, create the skeleton and stubs for this
 * dispatcher.  Create a stub based on the type of the impl,
 * initialize it with the appropriate remote reference. Create the
 * target defined by the impl, dispatcher (this) and stub.
 * Export that target via the Ref.
 */
public Remote exportObject(Remote impl, Object data,
                           boolean permanent)
    throws RemoteException
{
    Class<?> implClass = impl.getClass();
    Remote stub;

    try {
        stub = Util.createProxy(implClass, getClientRef(), forceStubUse);
    } catch (IllegalArgumentException e) {
        throw new ExportException(
            "remote object implements illegal remote interface", e);
    }
    if (stub instanceof RemoteStub) {
        setSkeleton(impl);
    }

    Target target =
        new Target(impl, this, stub, ref.getObjID(), permanent);
    ref.exportObject(target);
    hashToMethod_Map = hashToMethod_Maps.get(implClass);
    return stub;
}
项目:lookaside_java-1.8.0-openjdk    文件:UnicastServerRef.java   
/**
 * Export this object, create the skeleton and stubs for this
 * dispatcher.  Create a stub based on the type of the impl,
 * initialize it with the appropriate remote reference. Create the
 * target defined by the impl, dispatcher (this) and stub.
 * Export that target via the Ref.
 */
public Remote exportObject(Remote impl, Object data,
                           boolean permanent)
    throws RemoteException
{
    Class<?> implClass = impl.getClass();
    Remote stub;

    try {
        stub = Util.createProxy(implClass, getClientRef(), forceStubUse);
    } catch (IllegalArgumentException e) {
        throw new ExportException(
            "remote object implements illegal remote interface", e);
    }
    if (stub instanceof RemoteStub) {
        setSkeleton(impl);
    }

    Target target =
        new Target(impl, this, stub, ref.getObjID(), permanent);
    ref.exportObject(target);
    hashToMethod_Map = hashToMethod_Maps.get(implClass);
    return stub;
}
项目:infobip-open-jdk-8    文件:UnicastServerRef.java   
/**
 * Export this object, create the skeleton and stubs for this
 * dispatcher.  Create a stub based on the type of the impl,
 * initialize it with the appropriate remote reference. Create the
 * target defined by the impl, dispatcher (this) and stub.
 * Export that target via the Ref.
 */
public Remote exportObject(Remote impl, Object data,
                           boolean permanent)
    throws RemoteException
{
    Class<?> implClass = impl.getClass();
    Remote stub;

    try {
        stub = Util.createProxy(implClass, getClientRef(), forceStubUse);
    } catch (IllegalArgumentException e) {
        throw new ExportException(
            "remote object implements illegal remote interface", e);
    }
    if (stub instanceof RemoteStub) {
        setSkeleton(impl);
    }

    Target target =
        new Target(impl, this, stub, ref.getObjID(), permanent);
    ref.exportObject(target);
    hashToMethod_Map = hashToMethod_Maps.get(implClass);
    return stub;
}
项目:jdk8u-dev-jdk    文件:UnicastServerRef.java   
/**
 * Export this object, create the skeleton and stubs for this
 * dispatcher.  Create a stub based on the type of the impl,
 * initialize it with the appropriate remote reference. Create the
 * target defined by the impl, dispatcher (this) and stub.
 * Export that target via the Ref.
 */
public Remote exportObject(Remote impl, Object data,
                           boolean permanent)
    throws RemoteException
{
    Class<?> implClass = impl.getClass();
    Remote stub;

    try {
        stub = Util.createProxy(implClass, getClientRef(), forceStubUse);
    } catch (IllegalArgumentException e) {
        throw new ExportException(
            "remote object implements illegal remote interface", e);
    }
    if (stub instanceof RemoteStub) {
        setSkeleton(impl);
    }

    Target target =
        new Target(impl, this, stub, ref.getObjID(), permanent);
    ref.exportObject(target);
    hashToMethod_Map = hashToMethod_Maps.get(implClass);
    return stub;
}
项目:jdk7-jdk    文件:UnicastServerRef.java   
/**
 * Export this object, create the skeleton and stubs for this
 * dispatcher.  Create a stub based on the type of the impl,
 * initialize it with the appropriate remote reference. Create the
 * target defined by the impl, dispatcher (this) and stub.
 * Export that target via the Ref.
 */
public Remote exportObject(Remote impl, Object data,
                           boolean permanent)
    throws RemoteException
{
    Class implClass = impl.getClass();
    Remote stub;

    try {
        stub = Util.createProxy(implClass, getClientRef(), forceStubUse);
    } catch (IllegalArgumentException e) {
        throw new ExportException(
            "remote object implements illegal remote interface", e);
    }
    if (stub instanceof RemoteStub) {
        setSkeleton(impl);
    }

    Target target =
        new Target(impl, this, stub, ref.getObjID(), permanent);
    ref.exportObject(target);
    hashToMethod_Map = hashToMethod_Maps.get(implClass);
    return stub;
}
项目:openjdk-source-code-learn    文件:UnicastServerRef.java   
/**
 * Export this object, create the skeleton and stubs for this
 * dispatcher.  Create a stub based on the type of the impl,
 * initialize it with the appropriate remote reference. Create the
 * target defined by the impl, dispatcher (this) and stub.
 * Export that target via the Ref.
 */
public Remote exportObject(Remote impl, Object data,
                           boolean permanent)
    throws RemoteException
{
    Class implClass = impl.getClass();
    Remote stub;

    try {
        stub = Util.createProxy(implClass, getClientRef(), forceStubUse);
    } catch (IllegalArgumentException e) {
        throw new ExportException(
            "remote object implements illegal remote interface", e);
    }
    if (stub instanceof RemoteStub) {
        setSkeleton(impl);
    }

    Target target =
        new Target(impl, this, stub, ref.getObjID(), permanent);
    ref.exportObject(target);
    hashToMethod_Map = hashToMethod_Maps.get(implClass);
    return stub;
}
项目:OLD-OpenJDK8    文件:UnicastServerRef.java   
/**
 * Export this object, create the skeleton and stubs for this
 * dispatcher.  Create a stub based on the type of the impl,
 * initialize it with the appropriate remote reference. Create the
 * target defined by the impl, dispatcher (this) and stub.
 * Export that target via the Ref.
 */
public Remote exportObject(Remote impl, Object data,
                           boolean permanent)
    throws RemoteException
{
    Class<?> implClass = impl.getClass();
    Remote stub;

    try {
        stub = Util.createProxy(implClass, getClientRef(), forceStubUse);
    } catch (IllegalArgumentException e) {
        throw new ExportException(
            "remote object implements illegal remote interface", e);
    }
    if (stub instanceof RemoteStub) {
        setSkeleton(impl);
    }

    Target target =
        new Target(impl, this, stub, ref.getObjID(), permanent);
    ref.exportObject(target);
    hashToMethod_Map = hashToMethod_Maps.get(implClass);
    return stub;
}
项目:openjdk-jdk7u-jdk    文件:UnicastServerRef.java   
/**
 * Export this object, create the skeleton and stubs for this
 * dispatcher.  Create a stub based on the type of the impl,
 * initialize it with the appropriate remote reference. Create the
 * target defined by the impl, dispatcher (this) and stub.
 * Export that target via the Ref.
 */
public Remote exportObject(Remote impl, Object data,
                           boolean permanent)
    throws RemoteException
{
    Class<?> implClass = impl.getClass();
    Remote stub;

    try {
        stub = Util.createProxy(implClass, getClientRef(), forceStubUse);
    } catch (IllegalArgumentException e) {
        throw new ExportException(
            "remote object implements illegal remote interface", e);
    }
    if (stub instanceof RemoteStub) {
        setSkeleton(impl);
    }

    Target target =
        new Target(impl, this, stub, ref.getObjID(), permanent);
    ref.exportObject(target);
    hashToMethod_Map = hashToMethod_Maps.get(implClass);
    return stub;
}
项目:SORCER    文件:MonitorImplTest.java   
@Test
public void testRegistration() throws MonitorException, ExportException {
    MonitorRegistration registration = monitor.register("spacely-sprockets",
                                                        System.getProperty("user.name"),
                                                        TimeUnit.MINUTES.toMillis(5));
    assertNotNull(registration.getMonitor());
    assertNotNull(registration);
    MonitorListener monitorListener = new MonitorListener();
    EventRegistration eventRegistration = monitor.register(new MonitorEventFilter(System.getProperty("user.name")),
                                                           monitorListener.getRemoteEventListener(),
                                                           TimeUnit.MINUTES.toMillis(5));
    assertNotNull(eventRegistration);
    monitor.update(registration, Monitor.Status.SUBMITTED, null);
    monitor.update(registration, Monitor.Status.COMPLETED, null);

    registration = monitor.register("spacely-sprockets",
                                    System.getProperty("user.name"),
                                    TimeUnit.MINUTES.toMillis(5));
    monitor.update(registration, Monitor.Status.SUBMITTED, null);
    monitor.update(registration, Monitor.Status.FAILED, null);
    assertTrue(monitorListener.states.size()==4);
}
项目:SORCER    文件:MonitorImplTest.java   
@Test
public void testRegistrationWithNames() throws MonitorException, ExportException {
    MonitorRegistration registration = monitor.register("spacely-sprockets",
                                                        System.getProperty("user.name"),
                                                        TimeUnit.MINUTES.toMillis(5));
    assertNotNull(registration.getMonitor());
    assertNotNull(registration);
    MonitorListener monitorListener = new MonitorListener();
    List<String> names = new ArrayList<>();
    names.add(registration.getIdentifier());
    EventRegistration eventRegistration = monitor.register(new MonitorEventFilter(null, names),
                                                           monitorListener.getRemoteEventListener(),
                                                           TimeUnit.MINUTES.toMillis(5));
    assertNotNull(eventRegistration);
    monitor.update(registration, Monitor.Status.SUBMITTED, null);
    monitor.update(registration, Monitor.Status.COMPLETED, null);

    monitor.update(registration, Monitor.Status.SUBMITTED, null);
    monitor.update(registration, Monitor.Status.FAILED, null);
    assertTrue(monitorListener.states.size()==4);
}
项目:SORCER    文件:MonitorImplTest.java   
@Test
public void testRegistrationWithBadNames() throws MonitorException, ExportException {
    MonitorRegistration registration = monitor.register("spacely-sprockets",
                                                        System.getProperty("user.name"),
                                                        TimeUnit.MINUTES.toMillis(5));
    assertNotNull(registration.getMonitor());
    assertNotNull(registration);
    MonitorListener monitorListener = new MonitorListener();
    List<String> names = new ArrayList<>();
    names.add(registration.getIdentifier()+"foo");
    EventRegistration eventRegistration = monitor.register(new MonitorEventFilter(System.getProperty("user.name"), names),
                                                           monitorListener.getRemoteEventListener(),
                                                           TimeUnit.MINUTES.toMillis(5));
    assertNotNull(eventRegistration);
    monitor.update(registration, Monitor.Status.SUBMITTED, null);
    monitor.update(registration, Monitor.Status.COMPLETED, null);

    monitor.update(registration, Monitor.Status.SUBMITTED, null);
    monitor.update(registration, Monitor.Status.FAILED, null);
    assertTrue(monitorListener.states.size()==0);
}
项目:openjdk-icedtea7    文件:UnicastServerRef.java   
/**
 * Export this object, create the skeleton and stubs for this
 * dispatcher.  Create a stub based on the type of the impl,
 * initialize it with the appropriate remote reference. Create the
 * target defined by the impl, dispatcher (this) and stub.
 * Export that target via the Ref.
 */
public Remote exportObject(Remote impl, Object data,
                           boolean permanent)
    throws RemoteException
{
    Class<?> implClass = impl.getClass();
    Remote stub;

    try {
        stub = Util.createProxy(implClass, getClientRef(), forceStubUse);
    } catch (IllegalArgumentException e) {
        throw new ExportException(
            "remote object implements illegal remote interface", e);
    }
    if (stub instanceof RemoteStub) {
        setSkeleton(impl);
    }

    Target target =
        new Target(impl, this, stub, ref.getObjID(), permanent);
    ref.exportObject(target);
    hashToMethod_Map = hashToMethod_Maps.get(implClass);
    return stub;
}
项目:OpenJSharp    文件:ObjectTable.java   
/**
 * Add target to object table.  If it is not a permanent entry, then
 * make sure that reaper thread is running to remove collected entries
 * and keep VM alive.
 */
static void putTarget(Target target) throws ExportException {
    ObjectEndpoint oe = target.getObjectEndpoint();
    WeakRef weakImpl = target.getWeakImpl();

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "add object " + oe);
    }

    synchronized (tableLock) {
        /**
         * Do nothing if impl has already been collected (see 6597112). Check while
         * holding tableLock to ensure that Reaper cannot process weakImpl in between
         * null check and put/increment effects.
         */
        if (target.getImpl() != null) {
            if (objTable.containsKey(oe)) {
                throw new ExportException(
                    "internal error: ObjID already in use");
            } else if (implTable.containsKey(weakImpl)) {
                throw new ExportException("object already exported");
            }

            objTable.put(oe, target);
            implTable.put(weakImpl, target);

            if (!target.isPermanent()) {
                incrementKeepAliveCount();
            }
        }
    }
}
项目:jdk8u-jdk    文件:ObjectTable.java   
/**
 * Add target to object table.  If it is not a permanent entry, then
 * make sure that reaper thread is running to remove collected entries
 * and keep VM alive.
 */
static void putTarget(Target target) throws ExportException {
    ObjectEndpoint oe = target.getObjectEndpoint();
    WeakRef weakImpl = target.getWeakImpl();

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "add object " + oe);
    }

    synchronized (tableLock) {
        /**
         * Do nothing if impl has already been collected (see 6597112). Check while
         * holding tableLock to ensure that Reaper cannot process weakImpl in between
         * null check and put/increment effects.
         */
        if (target.getImpl() != null) {
            if (objTable.containsKey(oe)) {
                throw new ExportException(
                    "internal error: ObjID already in use");
            } else if (implTable.containsKey(weakImpl)) {
                throw new ExportException("object already exported");
            }

            objTable.put(oe, target);
            implTable.put(weakImpl, target);

            if (!target.isPermanent()) {
                incrementKeepAliveCount();
            }
        }
    }
}
项目:jdk8u-jdk    文件:Server.java   
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
项目:openjdk-jdk10    文件:ObjectTable.java   
/**
 * Add target to object table.  If it is not a permanent entry, then
 * make sure that reaper thread is running to remove collected entries
 * and keep VM alive.
 */
static void putTarget(Target target) throws ExportException {
    ObjectEndpoint oe = target.getObjectEndpoint();
    WeakRef weakImpl = target.getWeakImpl();

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "add object " + oe);
    }

    synchronized (tableLock) {
        /**
         * Do nothing if impl has already been collected (see 6597112). Check while
         * holding tableLock to ensure that Reaper cannot process weakImpl in between
         * null check and put/increment effects.
         */
        if (target.getImpl() != null) {
            if (objTable.containsKey(oe)) {
                throw new ExportException(
                    "internal error: ObjID already in use");
            } else if (implTable.containsKey(weakImpl)) {
                throw new ExportException("object already exported");
            }

            objTable.put(oe, target);
            implTable.put(weakImpl, target);

            if (!target.isPermanent()) {
                incrementKeepAliveCount();
            }
        }
    }
}
项目:openjdk-jdk10    文件:Server.java   
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
项目:openjdk9    文件:ObjectTable.java   
/**
 * Add target to object table.  If it is not a permanent entry, then
 * make sure that reaper thread is running to remove collected entries
 * and keep VM alive.
 */
static void putTarget(Target target) throws ExportException {
    ObjectEndpoint oe = target.getObjectEndpoint();
    WeakRef weakImpl = target.getWeakImpl();

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "add object " + oe);
    }

    synchronized (tableLock) {
        /**
         * Do nothing if impl has already been collected (see 6597112). Check while
         * holding tableLock to ensure that Reaper cannot process weakImpl in between
         * null check and put/increment effects.
         */
        if (target.getImpl() != null) {
            if (objTable.containsKey(oe)) {
                throw new ExportException(
                    "internal error: ObjID already in use");
            } else if (implTable.containsKey(weakImpl)) {
                throw new ExportException("object already exported");
            }

            objTable.put(oe, target);
            implTable.put(weakImpl, target);

            if (!target.isPermanent()) {
                incrementKeepAliveCount();
            }
        }
    }
}
项目:openjdk9    文件:Server.java   
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
项目:jdk8u_jdk    文件:ObjectTable.java   
/**
 * Add target to object table.  If it is not a permanent entry, then
 * make sure that reaper thread is running to remove collected entries
 * and keep VM alive.
 */
static void putTarget(Target target) throws ExportException {
    ObjectEndpoint oe = target.getObjectEndpoint();
    WeakRef weakImpl = target.getWeakImpl();

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "add object " + oe);
    }

    synchronized (tableLock) {
        /**
         * Do nothing if impl has already been collected (see 6597112). Check while
         * holding tableLock to ensure that Reaper cannot process weakImpl in between
         * null check and put/increment effects.
         */
        if (target.getImpl() != null) {
            if (objTable.containsKey(oe)) {
                throw new ExportException(
                    "internal error: ObjID already in use");
            } else if (implTable.containsKey(weakImpl)) {
                throw new ExportException("object already exported");
            }

            objTable.put(oe, target);
            implTable.put(weakImpl, target);

            if (!target.isPermanent()) {
                incrementKeepAliveCount();
            }
        }
    }
}
项目:jdk8u_jdk    文件:Server.java   
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
项目:lookaside_java-1.8.0-openjdk    文件:ObjectTable.java   
/**
 * Add target to object table.  If it is not a permanent entry, then
 * make sure that reaper thread is running to remove collected entries
 * and keep VM alive.
 */
static void putTarget(Target target) throws ExportException {
    ObjectEndpoint oe = target.getObjectEndpoint();
    WeakRef weakImpl = target.getWeakImpl();

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "add object " + oe);
    }

    synchronized (tableLock) {
        /**
         * Do nothing if impl has already been collected (see 6597112). Check while
         * holding tableLock to ensure that Reaper cannot process weakImpl in between
         * null check and put/increment effects.
         */
        if (target.getImpl() != null) {
            if (objTable.containsKey(oe)) {
                throw new ExportException(
                    "internal error: ObjID already in use");
            } else if (implTable.containsKey(weakImpl)) {
                throw new ExportException("object already exported");
            }

            objTable.put(oe, target);
            implTable.put(weakImpl, target);

            if (!target.isPermanent()) {
                incrementKeepAliveCount();
            }
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Server.java   
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
项目:infobip-open-jdk-8    文件:ObjectTable.java   
/**
 * Add target to object table.  If it is not a permanent entry, then
 * make sure that reaper thread is running to remove collected entries
 * and keep VM alive.
 */
static void putTarget(Target target) throws ExportException {
    ObjectEndpoint oe = target.getObjectEndpoint();
    WeakRef weakImpl = target.getWeakImpl();

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "add object " + oe);
    }

    synchronized (tableLock) {
        /**
         * Do nothing if impl has already been collected (see 6597112). Check while
         * holding tableLock to ensure that Reaper cannot process weakImpl in between
         * null check and put/increment effects.
         */
        if (target.getImpl() != null) {
            if (objTable.containsKey(oe)) {
                throw new ExportException(
                    "internal error: ObjID already in use");
            } else if (implTable.containsKey(weakImpl)) {
                throw new ExportException("object already exported");
            }

            objTable.put(oe, target);
            implTable.put(weakImpl, target);

            if (!target.isPermanent()) {
                incrementKeepAliveCount();
            }
        }
    }
}
项目:infobip-open-jdk-8    文件:Server.java   
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
项目:jdk8u-dev-jdk    文件:ObjectTable.java   
/**
 * Add target to object table.  If it is not a permanent entry, then
 * make sure that reaper thread is running to remove collected entries
 * and keep VM alive.
 */
static void putTarget(Target target) throws ExportException {
    ObjectEndpoint oe = target.getObjectEndpoint();
    WeakRef weakImpl = target.getWeakImpl();

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "add object " + oe);
    }

    synchronized (tableLock) {
        /**
         * Do nothing if impl has already been collected (see 6597112). Check while
         * holding tableLock to ensure that Reaper cannot process weakImpl in between
         * null check and put/increment effects.
         */
        if (target.getImpl() != null) {
            if (objTable.containsKey(oe)) {
                throw new ExportException(
                    "internal error: ObjID already in use");
            } else if (implTable.containsKey(weakImpl)) {
                throw new ExportException("object already exported");
            }

            objTable.put(oe, target);
            implTable.put(weakImpl, target);

            if (!target.isPermanent()) {
                incrementKeepAliveCount();
            }
        }
    }
}
项目:jdk8u-dev-jdk    文件:Server.java   
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
项目:JRemoting    文件:RmiServer.java   
protected Registry createOrMakeRegistry(int port) throws RemoteException {
    try {
        return LocateRegistry.createRegistry(port);
    } catch (ExportException e) {
        return LocateRegistry.getRegistry(addr.getPort());
    }
}
项目:rmiio    文件:IIOPRemoteStreamExporter.java   
public Object export(Remote server, Class<?> remoteClass)
  throws RemoteException
{
  try {
    PortableRemoteObject.exportObject(server);
    POA poa = getPOA();
    Object servant = Util.getTie(server);
    Object ref = poa.servant_to_reference((Servant)servant);
    return PortableRemoteObject.narrow(ref, remoteClass);
  } catch(UserException e) {
    throw new ExportException("could not export corba stream servant", e);
  }
}
项目:jdk7-jdk    文件:ObjectTable.java   
/**
 * Add target to object table.  If it is not a permanent entry, then
 * make sure that reaper thread is running to remove collected entries
 * and keep VM alive.
 */
static void putTarget(Target target) throws ExportException {
    ObjectEndpoint oe = target.getObjectEndpoint();
    WeakRef weakImpl = target.getWeakImpl();

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "add object " + oe);
    }

    synchronized (tableLock) {
        /**
         * Do nothing if impl has already been collected (see 6597112). Check while
         * holding tableLock to ensure that Reaper cannot process weakImpl in between
         * null check and put/increment effects.
         */
        if (target.getImpl() != null) {
            if (objTable.containsKey(oe)) {
                throw new ExportException(
                    "internal error: ObjID already in use");
            } else if (implTable.containsKey(weakImpl)) {
                throw new ExportException("object already exported");
            }

            objTable.put(oe, target);
            implTable.put(weakImpl, target);

            if (!target.isPermanent()) {
                incrementKeepAliveCount();
            }
        }
    }
}
项目:openjdk-source-code-learn    文件:ObjectTable.java   
/**
 * Add target to object table.  If it is not a permanent entry, then
 * make sure that reaper thread is running to remove collected entries
 * and keep VM alive.
 */
static void putTarget(Target target) throws ExportException {
    ObjectEndpoint oe = target.getObjectEndpoint();
    WeakRef weakImpl = target.getWeakImpl();

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "add object " + oe);
    }

    synchronized (tableLock) {
        /**
         * Do nothing if impl has already been collected (see 6597112). Check while
         * holding tableLock to ensure that Reaper cannot process weakImpl in between
         * null check and put/increment effects.
         */
        if (target.getImpl() != null) {
            if (objTable.containsKey(oe)) {
                throw new ExportException(
                    "internal error: ObjID already in use");
            } else if (implTable.containsKey(weakImpl)) {
                throw new ExportException("object already exported");
            }

            objTable.put(oe, target);
            implTable.put(weakImpl, target);

            if (!target.isPermanent()) {
                incrementKeepAliveCount();
            }
        }
    }
}
项目:OLD-OpenJDK8    文件:ObjectTable.java   
/**
 * Add target to object table.  If it is not a permanent entry, then
 * make sure that reaper thread is running to remove collected entries
 * and keep VM alive.
 */
static void putTarget(Target target) throws ExportException {
    ObjectEndpoint oe = target.getObjectEndpoint();
    WeakRef weakImpl = target.getWeakImpl();

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "add object " + oe);
    }

    synchronized (tableLock) {
        /**
         * Do nothing if impl has already been collected (see 6597112). Check while
         * holding tableLock to ensure that Reaper cannot process weakImpl in between
         * null check and put/increment effects.
         */
        if (target.getImpl() != null) {
            if (objTable.containsKey(oe)) {
                throw new ExportException(
                    "internal error: ObjID already in use");
            } else if (implTable.containsKey(weakImpl)) {
                throw new ExportException("object already exported");
            }

            objTable.put(oe, target);
            implTable.put(weakImpl, target);

            if (!target.isPermanent()) {
                incrementKeepAliveCount();
            }
        }
    }
}
项目:OLD-OpenJDK8    文件:Server.java   
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
项目:cn1    文件:ExportManager.java   
/**
 * Exports specified remote object through pre-initialized UnicastServerRef.
 * Returns info for exported object. If object has already been exported,
 * ExportException will be thrown.
 *
 * @param obj remote object to be exported
 * @param sref initialized UnicastServerRef to export object through
 * @param useProxyStubs If true then Proxy stubs will be generated if stub
 *        class could not be found in classpath and codebase; if false Proxy
 *        stubs will not be tried (this is needed for
 *        UnicastRemoteObject.exportObject(Remote) method because it
 *        returns RemoteStub class (but Proxy class could not be casted
 *        to it)
 * @param startListen if false, ServerSocket listening thread will not be
 *        started (this is used for DGC, for example); otherwise listening
 *        thread will be started and object becomes available for
 *        connections from clients
 * @param isSystem if true then existence of this object will not prevent
 *        VM from exiting (for example, for rmiregistry)
 *
 * @return stub for exported object
 *
 * @throws RemoteException if any exception occurred while exporting
 *         specified remote object
 */
public static Remote exportObject(Remote obj,
                                  UnicastServerRef sref,
                                  boolean useProxyStubs,
                                  boolean startListen,
                                  boolean isSystem)
        throws RemoteException {
    if (isExported(obj)) {
        // rmi.7B=Object {0} has already been exported.
        throw new ExportException(Messages.getString("rmi.7B", obj)); //$NON-NLS-1$
    }
    Remote stub = sref.exportObject(obj, null, useProxyStubs, startListen,
            isSystem);
    RMIReference rref = new RMIReference(obj, dgcQueue);
    RMIObjectInfo info = new RMIObjectInfo(
            rref, sref.getObjId(), sref, stub);
    exportedObjs.add(info);

    if (scav == null) {
        (scav = (Thread) AccessController.doPrivileged(
                new CreateThreadAction(new Scavenger(),
                        "Scavenger", false))).start(); //$NON-NLS-1$
    }

    if (isSystem) {
        rref.makeStrong(true);
    } else {
        ++nonSystemObjsNum;
    }
    return stub;
}
项目:cn1    文件:ExportExceptionTest.java   
/**
 * Sets up the fixture, for example, open a network connection. This method
 * is called before a test is executed.
 */
@Override
protected void setUp() {
    errorMessage = "Connectin Error";
    causeMessage = "Caused Exception";
    cause = new ExportException(causeMessage);
}
项目:cn1    文件:ExportExceptionTest.java   
public void assertDeserialized(Serializable initial,
        Serializable deserialized) {

    SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(initial, deserialized);

    ExportException initEx = (ExportException) initial;
    ExportException desrEx = (ExportException) deserialized;

    assertEquals(initEx.getMessage(), desrEx.getMessage());
    assertEquals(initEx.getCause().getMessage(), desrEx.getCause().getMessage());
}