Java Code Examples for java.rmi.NoSuchObjectException

The following are top voted examples for showing how to use java.rmi.NoSuchObjectException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: PortableRemoteObject.java   View source code 6 votes vote down vote up
/**
 * 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.");
        }
    }
}
 
Example 2
Project: OpenJSharp   File: Util.java   View source code 6 votes vote down vote up
public void unregisterTargetsForORB(org.omg.CORBA.ORB orb)
{
    for (Enumeration e = exportedServants.keys(); e.hasMoreElements(); )
    {
        java.lang.Object key = e.nextElement();
        Remote target = (Remote)(key instanceof Tie ? ((Tie)key).getTarget() : key);

        // Bug 4476347: BAD_OPERATION is thrown if the ties delegate isn't set.
        // We can ignore this because it means the tie is not connected to an ORB.
        try {
            if (orb == getTie(target).orb()) {
                try {
                    unexportObject(target);
                } catch( java.rmi.NoSuchObjectException ex ) {
                    // We neglect this exception if at all if it is
                    // raised. It is not harmful.
                }
            }
        } catch (BAD_OPERATION bad) {
            /* Ignore */
        }
    }
}
 
Example 3
Project: OpenJSharp   File: ObjectTable.java   View source code 6 votes vote down vote up
/**
 * Remove the remote object, obj, from the RMI runtime. If
 * successful, the object can no longer accept incoming RMI calls.
 * If the force parameter is true, the object is forcibly unexported
 * even if there are pending calls to the remote object or the
 * remote object still has calls in progress.  If the force
 * parameter is false, the object is only unexported if there are
 * no pending or in progress calls to the object.
 *
 * @param obj the remote object to be unexported
 * @param force if true, unexports the object even if there are
 * pending or in-progress calls; if false, only unexports the object
 * if there are no pending or in-progress calls
 * @return true if operation is successful, false otherwise
 * @exception NoSuchObjectException if the remote object is not
 * currently exported
 */
public static boolean unexportObject(Remote obj, boolean force)
     throws java.rmi.NoSuchObjectException
 {
     synchronized (tableLock) {
         Target target = getTarget(obj);
         if (target == null) {
             throw new NoSuchObjectException("object not exported");
         } else {
             if (target.unexport(force)) {
                 removeTarget(target);
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
 
Example 4
Project: OpenJSharp   File: ActivationGroupImpl.java   View source code 6 votes vote down vote up
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) {
        }
    }
}
 
Example 5
Project: OpenJSharp   File: IIOPProxyImpl.java   View source code 6 votes vote down vote up
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
    if (System.getSecurityManager() == null) {
        return PortableRemoteObject.toStub(obj);
    } else {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {

                @Override
                public Remote run() throws Exception {
                    return PortableRemoteObject.toStub(obj);
                }
            }, STUB_ACC);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof NoSuchObjectException) {
                throw (NoSuchObjectException)e.getException();
            }
            throw new RuntimeException("Unexpected exception type", e.getException());
        }
    }
}
 
Example 6
Project: jdk8u-jdk   File: ObjectTable.java   View source code 6 votes vote down vote up
/**
 * Remove the remote object, obj, from the RMI runtime. If
 * successful, the object can no longer accept incoming RMI calls.
 * If the force parameter is true, the object is forcibly unexported
 * even if there are pending calls to the remote object or the
 * remote object still has calls in progress.  If the force
 * parameter is false, the object is only unexported if there are
 * no pending or in progress calls to the object.
 *
 * @param obj the remote object to be unexported
 * @param force if true, unexports the object even if there are
 * pending or in-progress calls; if false, only unexports the object
 * if there are no pending or in-progress calls
 * @return true if operation is successful, false otherwise
 * @exception NoSuchObjectException if the remote object is not
 * currently exported
 */
public static boolean unexportObject(Remote obj, boolean force)
     throws java.rmi.NoSuchObjectException
 {
     synchronized (tableLock) {
         Target target = getTarget(obj);
         if (target == null) {
             throw new NoSuchObjectException("object not exported");
         } else {
             if (target.unexport(force)) {
                 removeTarget(target);
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
 
Example 7
Project: jdk8u-jdk   File: ActivationGroupImpl.java   View source code 6 votes vote down vote up
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) {
        }
    }
}
 
Example 8
Project: jdk8u-jdk   File: IIOPProxyImpl.java   View source code 6 votes vote down vote up
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
    if (System.getSecurityManager() == null) {
        return PortableRemoteObject.toStub(obj);
    } else {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {

                @Override
                public Remote run() throws Exception {
                    return PortableRemoteObject.toStub(obj);
                }
            }, STUB_ACC);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof NoSuchObjectException) {
                throw (NoSuchObjectException)e.getException();
            }
            throw new RuntimeException("Unexpected exception type", e.getException());
        }
    }
}
 
Example 9
Project: jdk8u-jdk   File: JMXStartStopTest.java   View source code 6 votes vote down vote up
private static void testNoConnect(int port, int rmiPort) throws Exception {
    try {
        testConnect(port, rmiPort);
        throw new Exception("Didn't expect the management agent running");
    } catch (Exception e) {
        Throwable t = e;
        while (t != null) {
            if (t instanceof NoSuchObjectException ||
                t instanceof ConnectException ||
                t instanceof SSLHandshakeException) {
                break;
            }
            t = t.getCause();
        }
        if (t == null) {
            throw new Exception("Unexpected exception", e);
        }
    }
}
 
Example 10
Project: openjdk-jdk10   File: PortableRemoteObject.java   View source code 6 votes vote down vote up
/**
 * 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.");
        }
    }
}
 
Example 11
Project: openjdk-jdk10   File: Util.java   View source code 6 votes vote down vote up
public void unregisterTargetsForORB(org.omg.CORBA.ORB orb)
{
    for (Enumeration e = exportedServants.keys(); e.hasMoreElements(); )
    {
        java.lang.Object key = e.nextElement();
        Remote target = (Remote)(key instanceof Tie ? ((Tie)key).getTarget() : key);

        // Bug 4476347: BAD_OPERATION is thrown if the ties delegate isn't set.
        // We can ignore this because it means the tie is not connected to an ORB.
        try {
            if (orb == getTie(target).orb()) {
                try {
                    unexportObject(target);
                } catch( java.rmi.NoSuchObjectException ex ) {
                    // We neglect this exception if at all if it is
                    // raised. It is not harmful.
                }
            }
        } catch (BAD_OPERATION bad) {
            /* Ignore */
        }
    }
}
 
Example 12
Project: openjdk-jdk10   File: ObjectTable.java   View source code 6 votes vote down vote up
/**
 * Remove the remote object, obj, from the RMI runtime. If
 * successful, the object can no longer accept incoming RMI calls.
 * If the force parameter is true, the object is forcibly unexported
 * even if there are pending calls to the remote object or the
 * remote object still has calls in progress.  If the force
 * parameter is false, the object is only unexported if there are
 * no pending or in progress calls to the object.
 *
 * @param obj the remote object to be unexported
 * @param force if true, unexports the object even if there are
 * pending or in-progress calls; if false, only unexports the object
 * if there are no pending or in-progress calls
 * @return true if operation is successful, false otherwise
 * @exception NoSuchObjectException if the remote object is not
 * currently exported
 */
public static boolean unexportObject(Remote obj, boolean force)
     throws java.rmi.NoSuchObjectException
 {
     synchronized (tableLock) {
         Target target = getTarget(obj);
         if (target == null) {
             throw new NoSuchObjectException("object not exported");
         } else {
             if (target.unexport(force)) {
                 removeTarget(target);
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
 
Example 13
Project: openjdk-jdk10   File: ActivationGroupImpl.java   View source code 6 votes vote down vote up
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) {
        }
    }
}
 
Example 14
Project: openjdk9   File: PortableRemoteObject.java   View source code 6 votes vote down vote up
/**
 * 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.");
        }
    }
}
 
Example 15
Project: openjdk9   File: Util.java   View source code 6 votes vote down vote up
public void unregisterTargetsForORB(org.omg.CORBA.ORB orb)
{
    for (Enumeration e = exportedServants.keys(); e.hasMoreElements(); )
    {
        java.lang.Object key = e.nextElement();
        Remote target = (Remote)(key instanceof Tie ? ((Tie)key).getTarget() : key);

        // Bug 4476347: BAD_OPERATION is thrown if the ties delegate isn't set.
        // We can ignore this because it means the tie is not connected to an ORB.
        try {
            if (orb == getTie(target).orb()) {
                try {
                    unexportObject(target);
                } catch( java.rmi.NoSuchObjectException ex ) {
                    // We neglect this exception if at all if it is
                    // raised. It is not harmful.
                }
            }
        } catch (BAD_OPERATION bad) {
            /* Ignore */
        }
    }
}
 
Example 16
Project: jdk8u_corba   File: Util.java   View source code 6 votes vote down vote up
public void unregisterTargetsForORB(org.omg.CORBA.ORB orb)
{
    for (Enumeration e = exportedServants.keys(); e.hasMoreElements(); )
    {
        java.lang.Object key = e.nextElement();
        Remote target = (Remote)(key instanceof Tie ? ((Tie)key).getTarget() : key);

        // Bug 4476347: BAD_OPERATION is thrown if the ties delegate isn't set.
        // We can ignore this because it means the tie is not connected to an ORB.
        try {
            if (orb == getTie(target).orb()) {
                try {
                    unexportObject(target);
                } catch( java.rmi.NoSuchObjectException ex ) {
                    // We neglect this exception if at all if it is
                    // raised. It is not harmful.
                }
            }
        } catch (BAD_OPERATION bad) {
            /* Ignore */
        }
    }
}
 
Example 17
Project: openjdk9   File: ObjectTable.java   View source code 6 votes vote down vote up
/**
 * Remove the remote object, obj, from the RMI runtime. If
 * successful, the object can no longer accept incoming RMI calls.
 * If the force parameter is true, the object is forcibly unexported
 * even if there are pending calls to the remote object or the
 * remote object still has calls in progress.  If the force
 * parameter is false, the object is only unexported if there are
 * no pending or in progress calls to the object.
 *
 * @param obj the remote object to be unexported
 * @param force if true, unexports the object even if there are
 * pending or in-progress calls; if false, only unexports the object
 * if there are no pending or in-progress calls
 * @return true if operation is successful, false otherwise
 * @exception NoSuchObjectException if the remote object is not
 * currently exported
 */
public static boolean unexportObject(Remote obj, boolean force)
     throws java.rmi.NoSuchObjectException
 {
     synchronized (tableLock) {
         Target target = getTarget(obj);
         if (target == null) {
             throw new NoSuchObjectException("object not exported");
         } else {
             if (target.unexport(force)) {
                 removeTarget(target);
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
 
Example 18
Project: openjdk9   File: ActivationGroupImpl.java   View source code 6 votes vote down vote up
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) {
        }
    }
}
 
Example 19
Project: jdk8u_jdk   File: ObjectTable.java   View source code 6 votes vote down vote up
/**
 * Remove the remote object, obj, from the RMI runtime. If
 * successful, the object can no longer accept incoming RMI calls.
 * If the force parameter is true, the object is forcibly unexported
 * even if there are pending calls to the remote object or the
 * remote object still has calls in progress.  If the force
 * parameter is false, the object is only unexported if there are
 * no pending or in progress calls to the object.
 *
 * @param obj the remote object to be unexported
 * @param force if true, unexports the object even if there are
 * pending or in-progress calls; if false, only unexports the object
 * if there are no pending or in-progress calls
 * @return true if operation is successful, false otherwise
 * @exception NoSuchObjectException if the remote object is not
 * currently exported
 */
public static boolean unexportObject(Remote obj, boolean force)
     throws java.rmi.NoSuchObjectException
 {
     synchronized (tableLock) {
         Target target = getTarget(obj);
         if (target == null) {
             throw new NoSuchObjectException("object not exported");
         } else {
             if (target.unexport(force)) {
                 removeTarget(target);
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
 
Example 20
Project: tlaplus   File: TLCWorker.java   View source code 6 votes vote down vote up
/**
 * Terminates all {@link TLCWorker}s currently running concurrently by
 * gracefully unregistering with RMI. Additionally it terminates each
 * keep-alive timer.
 */
public static void shutdown() {
	// Exit the keepAliveTimer
	if (keepAliveTimer != null) {
		keepAliveTimer.cancel();
	}
	
	// Exit and unregister all worker threads
	for (int i = 0; i < runnables.length; i++) {
		TLCWorker worker = runnables[i].getTLCWorker();
		try {
			if (worker != null) {
				worker.exit();
			}
		} catch (NoSuchObjectException e) {
			// may happen, ignore
		}
	}
	
	fts = null;
	runnables = new TLCWorkerRunnable[0];
}
 
Example 21
Project: jdk8u_jdk   File: IIOPProxyImpl.java   View source code 6 votes vote down vote up
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
    if (System.getSecurityManager() == null) {
        return PortableRemoteObject.toStub(obj);
    } else {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {

                @Override
                public Remote run() throws Exception {
                    return PortableRemoteObject.toStub(obj);
                }
            }, STUB_ACC);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof NoSuchObjectException) {
                throw (NoSuchObjectException)e.getException();
            }
            throw new RuntimeException("Unexpected exception type", e.getException());
        }
    }
}
 
Example 22
Project: lookaside_java-1.8.0-openjdk   File: JMXStartStopTest.java   View source code 6 votes vote down vote up
private static void testNoConnect(int port, int rmiPort) throws Exception {
    try {
        testConnect(port, rmiPort);
        throw new Exception("Didn't expect the management agent running");
    } catch (Exception e) {
        Throwable t = e;
        while (t != null) {
            if (t instanceof NoSuchObjectException ||
                t instanceof ConnectException ||
                t instanceof SSLHandshakeException) {
                break;
            }
            t = t.getCause();
        }
        if (t == null) {
            throw new Exception("Unexpected exception", e);
        }
    }
}
 
Example 23
Project: jdk8u_jdk   File: JMXStartStopTest.java   View source code 6 votes vote down vote up
private static void testNoConnect(int port, int rmiPort) throws Exception {
    try {
        testConnect(port, rmiPort);
        throw new Exception("Didn't expect the management agent running");
    } catch (Exception e) {
        Throwable t = e;
        while (t != null) {
            if (t instanceof NoSuchObjectException ||
                t instanceof ConnectException ||
                t instanceof SSLHandshakeException) {
                break;
            }
            t = t.getCause();
        }
        if (t == null) {
            throw new Exception("Unexpected exception", e);
        }
    }
}
 
Example 24
Project: lookaside_java-1.8.0-openjdk   File: Util.java   View source code 6 votes vote down vote up
public void unregisterTargetsForORB(org.omg.CORBA.ORB orb)
{
    for (Enumeration e = exportedServants.keys(); e.hasMoreElements(); )
    {
        java.lang.Object key = e.nextElement();
        Remote target = (Remote)(key instanceof Tie ? ((Tie)key).getTarget() : key);

        // Bug 4476347: BAD_OPERATION is thrown if the ties delegate isn't set.
        // We can ignore this because it means the tie is not connected to an ORB.
        try {
            if (orb == getTie(target).orb()) {
                try {
                    unexportObject(target);
                } catch( java.rmi.NoSuchObjectException ex ) {
                    // We neglect this exception if at all if it is
                    // raised. It is not harmful.
                }
            }
        } catch (BAD_OPERATION bad) {
            /* Ignore */
        }
    }
}
 
Example 25
Project: lookaside_java-1.8.0-openjdk   File: ObjectTable.java   View source code 6 votes vote down vote up
/**
 * Remove the remote object, obj, from the RMI runtime. If
 * successful, the object can no longer accept incoming RMI calls.
 * If the force parameter is true, the object is forcibly unexported
 * even if there are pending calls to the remote object or the
 * remote object still has calls in progress.  If the force
 * parameter is false, the object is only unexported if there are
 * no pending or in progress calls to the object.
 *
 * @param obj the remote object to be unexported
 * @param force if true, unexports the object even if there are
 * pending or in-progress calls; if false, only unexports the object
 * if there are no pending or in-progress calls
 * @return true if operation is successful, false otherwise
 * @exception NoSuchObjectException if the remote object is not
 * currently exported
 */
public static boolean unexportObject(Remote obj, boolean force)
     throws java.rmi.NoSuchObjectException
 {
     synchronized (tableLock) {
         Target target = getTarget(obj);
         if (target == null) {
             throw new NoSuchObjectException("object not exported");
         } else {
             if (target.unexport(force)) {
                 removeTarget(target);
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
 
Example 26
Project: lookaside_java-1.8.0-openjdk   File: ActivationGroupImpl.java   View source code 6 votes vote down vote up
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) {
        }
    }
}
 
Example 27
Project: flink   File: JMXReporter.java   View source code 6 votes vote down vote up
public void stop() throws IOException {
	if (connector != null) {
		try {
			connector.stop();
		} finally {
			connector = null;
		}
	}
	if (rmiRegistry != null) {
		try {
			UnicastRemoteObject.unexportObject(rmiRegistry, true);
		} catch (NoSuchObjectException e) {
			throw new IOException("Could not un-export our RMI registry", e);
		} finally {
			rmiRegistry = null;
		}
	}
}
 
Example 28
Project: lams   File: JndiRmiServiceExporter.java   View source code 5 votes vote down vote up
/**
 * Unbind the RMI service from JNDI on bean factory shutdown.
 */
@Override
public void destroy() throws NamingException, NoSuchObjectException {
	if (logger.isInfoEnabled()) {
		logger.info("Unbinding RMI service from JNDI location [" + this.jndiName + "]");
	}
	this.jndiTemplate.unbind(this.jndiName);
	PortableRemoteObject.unexportObject(this.exportedObject);
}
 
Example 29
Project: lams   File: RmiServiceExporter.java   View source code 5 votes vote down vote up
/**
 * Unexport the registered RMI object, logging any exception that arises.
 */
private void unexportObjectSilently() {
	try {
		UnicastRemoteObject.unexportObject(this.exportedObject, true);
	}
	catch (NoSuchObjectException ex) {
		if (logger.isWarnEnabled()) {
			logger.warn("RMI object for service '" + this.serviceName + "' isn't exported anymore", ex);
		}
	}
}
 
Example 30
Project: OpenJSharp   File: PortableRemoteObject.java   View source code 5 votes vote down vote up
/**
 * Returns a stub for the given server object.
 * @param obj the server object for which a stub is required. Must either be a subclass
 * of PortableRemoteObject or have been previously the target of a call to
 * {@link #exportObject}.
 * @return the most derived stub for the object.
 * @exception NoSuchObjectException if a stub cannot be located for the given server object.
 */
public Remote toStub (Remote obj)
    throws NoSuchObjectException
{
    Remote result = null;
    if (obj == null) {
        throw new NullPointerException("invalid argument");
    }

    // If the class is already an IIOP stub then return it.
    if (StubAdapter.isStub( obj )) {
        return obj;
    }

    // If the class is already a JRMP stub then return it.
    if (obj instanceof java.rmi.server.RemoteStub) {
        return obj;
    }

    // Has it been exported to IIOP?
    Tie theTie = Util.getTie(obj);

    if (theTie != null) {
        result = Utility.loadStub(theTie,null,null,true);
    } else {
        if (Utility.loadTie(obj) == null) {
            result = java.rmi.server.RemoteObject.toStub(obj);
        }
    }

    if (result == null) {
        throw new NoSuchObjectException("object not exported");
    }

    return result;
}
 
Example 31
Project: OpenJSharp   File: PortableRemoteObject.java   View source code 5 votes vote down vote up
/**
 * Returns a stub for the given server object.
 * @param obj the server object for which a stub is required. Must either be a subclass
 * of PortableRemoteObject or have been previously the target of a call to
 * {@link #exportObject}.
 * @return the most derived stub for the object.
 * @exception NoSuchObjectException if a stub cannot be located for the given server object.
 */
public static Remote toStub (Remote obj)
    throws NoSuchObjectException {

    if (proDelegate != null) {
        return proDelegate.toStub(obj);
    }
    return null;
}
 
Example 32
Project: OpenJSharp   File: PortableRemoteObject.java   View source code 5 votes vote down vote up
/**
 * 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 static void unexportObject(Remote obj)
    throws NoSuchObjectException {

    if (proDelegate != null) {
        proDelegate.unexportObject(obj);
    }

}
 
Example 33
Project: OpenJSharp   File: RemoteObject.java   View source code 5 votes vote down vote up
/**
 * Returns the stub for the remote object <code>obj</code> passed
 * as a parameter. This operation is only valid <i>after</i>
 * the object has been exported.
 * @param obj the remote object whose stub is needed
 * @return the stub for the remote object, <code>obj</code>.
 * @exception NoSuchObjectException if the stub for the
 * remote object could not be found.
 * @since 1.2
 */
public static Remote toStub(Remote obj) throws NoSuchObjectException {
    if (obj instanceof RemoteStub ||
        (obj != null &&
         Proxy.isProxyClass(obj.getClass()) &&
         Proxy.getInvocationHandler(obj) instanceof
         RemoteObjectInvocationHandler))
    {
        return obj;
    } else {
        return sun.rmi.transport.ObjectTable.getStub(obj);
    }
}
 
Example 34
Project: OpenJSharp   File: Target.java   View source code 5 votes vote down vote up
/**
 * Increment call count.
 */
synchronized void incrementCallCount() throws NoSuchObjectException {

    if (disp != null) {
        callCount ++;
    } else {
        throw new NoSuchObjectException("object not accepting new calls");
    }
}
 
Example 35
Project: OpenJSharp   File: ObjectTable.java   View source code 5 votes vote down vote up
/**
 * Returns the stub for the remote object <b>obj</b> passed
 * as a parameter. This operation is only valid <i>after</i>
 * the object has been exported.
 *
 * @return the stub for the remote object, <b>obj</b>.
 * @exception NoSuchObjectException if the stub for the
 * remote object could not be found.
 */
public static Remote getStub(Remote impl)
    throws NoSuchObjectException
{
    Target target = getTarget(impl);
    if (target == null) {
        throw new NoSuchObjectException("object not exported");
    } else {
        return target.getStub();
    }
}
 
Example 36
Project: OpenJSharp   File: ActivationGroupImpl.java   View source code 5 votes vote down vote up
/**
* The group's <code>inactiveObject</code> method is called
* indirectly via a call to the <code>Activatable.inactive</code>
* method. A remote object implementation must call
* <code>Activatable</code>'s <code>inactive</code> method when
* that object deactivates (the object deems that it is no longer
* active). If the object does not call
* <code>Activatable.inactive</code> when it deactivates, the
* object will never be garbage collected since the group keeps
* strong references to the objects it creates. <p>
*
* The group's <code>inactiveObject</code> method
* unexports the remote object from the RMI runtime so that the
* object can no longer receive incoming RMI calls. This call will
* only succeed if the object has no pending/executing calls. If
* the object does have pending/executing RMI calls, then false
* will be returned.
*
* If the object has no pending/executing calls, the object is
* removed from the RMI runtime and the group informs its
* <code>ActivationMonitor</code> (via the monitor's
* <code>inactiveObject</code> method) that the remote object is
* not currently active so that the remote object will be
* re-activated by the activator upon a subsequent activation
* request.
*
* @param id the object's activation identifier
* @returns true if the operation succeeds (the operation will
* succeed if the object in currently known to be active and is
* either already unexported or is currently exported and has no
* pending/executing calls); false is returned if the object has
* pending/executing calls in which case it cannot be deactivated
* @exception UnknownObjectException if object is unknown (may already
* be inactive)
* @exception RemoteException if call informing monitor fails
*/
public boolean inactiveObject(ActivationID id)
    throws ActivationException, UnknownObjectException, RemoteException
{

    try {
        acquireLock(id);
        synchronized (this) {
            if (groupInactive == true)
                throw new ActivationException("group is inactive");
        }

        ActiveEntry entry = active.get(id);
        if (entry == null) {
            // REMIND: should this be silent?
            throw new UnknownObjectException("object not active");
        }

        try {
            if (Activatable.unexportObject(entry.impl, false) == false)
                return false;
        } catch (NoSuchObjectException allowUnexportedObjects) {
        }

        try {
            super.inactiveObject(id);
        } catch (UnknownObjectException allowUnregisteredObjects) {
        }

        active.remove(id);

    } finally {
        releaseLock(id);
        checkInactiveGroup();
    }

    return true;
}
 
Example 37
Project: OpenJSharp   File: ConnectorBootstrap.java   View source code 5 votes vote down vote up
public static void unexportRegistry() {
    // Remove the entry from registry
    try {
        if (registry != null) {
            UnicastRemoteObject.unexportObject(registry, true);
            registry = null;
        }
    } catch(NoSuchObjectException ex) {
        // This exception can appears only if we attempt
        // to unexportRegistry second time. So it's safe
        // to ignore it without additional messages.
    }
}
 
Example 38
Project: OpenJSharp   File: RMIJRMPServerImpl.java   View source code 5 votes vote down vote up
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);
}
 
Example 39
Project: jdk8u-jdk   File: RemoteObject.java   View source code 5 votes vote down vote up
/**
 * Returns the stub for the remote object <code>obj</code> passed
 * as a parameter. This operation is only valid <i>after</i>
 * the object has been exported.
 * @param obj the remote object whose stub is needed
 * @return the stub for the remote object, <code>obj</code>.
 * @exception NoSuchObjectException if the stub for the
 * remote object could not be found.
 * @since 1.2
 */
public static Remote toStub(Remote obj) throws NoSuchObjectException {
    if (obj instanceof RemoteStub ||
        (obj != null &&
         Proxy.isProxyClass(obj.getClass()) &&
         Proxy.getInvocationHandler(obj) instanceof
         RemoteObjectInvocationHandler))
    {
        return obj;
    } else {
        return sun.rmi.transport.ObjectTable.getStub(obj);
    }
}
 
Example 40
Project: jdk8u-jdk   File: Target.java   View source code 5 votes vote down vote up
/**
 * Increment call count.
 */
synchronized void incrementCallCount() throws NoSuchObjectException {

    if (disp != null) {
        callCount ++;
    } else {
        throw new NoSuchObjectException("object not accepting new calls");
    }
}