/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The default activation group implementation.
*
* @author Ann Wollrath
* @since 1.2
* @see java.rmi.activation.ActivationGroup
*/
// use serialVersionUID from JDK 1.2.2 for interoperability
/** maps persistent IDs to activated remote objects */
new Hashtable<>();
private boolean groupInactive = false;
/**
* Creates a default activation group implementation.
*
* @param id the group's identifier
* @param data ignored
*/
throws RemoteException
{
super(id);
/*
* Unexport activation group impl and attempt to export it on
* an unshared anonymous port. See 4692286.
*/
unexportObject(this, true);
try {
// Provide a default security manager.
} catch (Exception e) {
throw new RemoteException("unable to set security manager", e);
}
}
}
/**
* Trivial server socket factory used to export the activation group
* impl on an unshared port.
*/
private static class ServerSocketFactoryImpl
implements RMIServerSocketFactory
{
{
}
}
}
/*
* Obtains a lock on the ActivationID id before returning. Allows only one
* thread at a time to hold a lock on a particular id. If the lock for id
* is in use, all requests for an equivalent (in the Object.equals sense)
* id will wait for the id to be notified and use the supplied id as the
* next lock. The caller of "acquireLock" must execute the "releaseLock"
* method" to release the lock and "notifyAll" waiters for the id lock
* obtained from this method. The typical usage pattern is as follows:
*
* try {
* acquireLock(id);
* // do stuff pertaining to id...
* } finally {
* releaseLock(id);
* checkInactiveGroup();
* }
*/
for (;;) {
synchronized (lockedIDs) {
if (index < 0) {
return;
} else {
}
}
synchronized (waitForID) {
synchronized (lockedIDs) {
if (index < 0) continue;
/*
* don't wait on an id that won't be notified.
*/
continue;
}
try {
} catch (InterruptedException ignore) {
}
}
}
}
/*
* Releases the id lock obtained via the "acquireLock" method and then
* notifies all threads waiting on the lock.
*/
synchronized (lockedIDs) {
}
synchronized (id) {
}
}
/**
* Creates a new instance of an activatable remote object. The
* <code>Activator</code> calls this method to create an activatable
* object in this group. This method should be idempotent; a call to
* activate an already active object should return the previously
* activated object.
*
* Note: this method assumes that the Activator will only invoke
* newInstance for the same object in a serial fashion (i.e.,
* the activator will not allow the group to see concurrent requests
* to activate the same object.
*
* @param id the object's activation identifier
* @param desc the object's activation descriptor
* @return a marshalled object containing the activated object's stub
*/
public MarshalledObject<? extends Remote>
final ActivationDesc desc)
throws ActivationException, RemoteException
{
throw new ActivationException("newInstance in wrong group");
try {
synchronized (this) {
if (groupInactive == true)
throw new InactiveGroupException("group is inactive");
}
.asSubclass(Remote.class);
/*
* Fix for 4164971: allow non-public activatable class
* privileged block
*/
try {
/*
* The code below is in a doPrivileged block to
* protect against user code which code might have set
* a global socket factory (in which case application
* code would be on the stack).
*/
new PrivilegedExceptionAction<Remote>() {
{
ActivationID.class, MarshalledObject.class);
constructor.setAccessible(true);
try {
/*
* Fix for 4289544: make sure to set the
* context class loader to be the class
* loader of the impl class before
* constructing that class.
*/
} finally {
}
}
});
} catch (PrivilegedActionException pae) {
// narrow the exception's type and rethrow it
if (e instanceof InstantiationException) {
throw (InstantiationException) e;
} else if (e instanceof NoSuchMethodException) {
throw (NoSuchMethodException) e;
} else if (e instanceof IllegalAccessException) {
throw (IllegalAccessException) e;
} else if (e instanceof InvocationTargetException) {
throw (InvocationTargetException) e;
} else if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else if (e instanceof Error) {
throw (Error) e;
}
}
} catch (NoSuchMethodException | NoSuchMethodError e) {
/* user forgot to provide activatable constructor?
* or code recompiled and user forgot to provide
* activatable constructor?
*/
throw new ActivationException
("Activatable object must provide an activation"+
" constructor", e );
} catch (InvocationTargetException e) {
throw new ActivationException("exception in object constructor",
e.getTargetException());
} catch (Exception e) {
throw new ActivationException("unable to activate object", e);
} finally {
}
}
/**
* 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
* will be returned.
*
* 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
* @exception UnknownObjectException if object is unknown (may already
* be inactive)
* @exception RemoteException if call informing monitor fails
*/
{
try {
synchronized (this) {
if (groupInactive == true)
throw new ActivationException("group is inactive");
}
// REMIND: should this be silent?
throw new UnknownObjectException("object not active");
}
try {
return false;
} catch (NoSuchObjectException allowUnexportedObjects) {
}
try {
super.inactiveObject(id);
} catch (UnknownObjectException allowUnregisteredObjects) {
}
} finally {
}
return true;
}
/*
* Determines if the group has become inactive and
* marks it as such.
*/
private void checkInactiveGroup() {
boolean groupMarkedInactive = false;
synchronized (this) {
groupInactive == false)
{
groupInactive = true;
groupMarkedInactive = true;
}
}
if (groupMarkedInactive) {
try {
super.inactiveGroup();
} catch (Exception ignoreDeactivateFailure) {
}
try {
UnicastRemoteObject.unexportObject(this, true);
} catch (NoSuchObjectException allowUnexportedGroup) {
}
}
}
/**
* The group's <code>activeObject</code> method is called when an
* object is exported (either by <code>Activatable</code> object
* construction or an explicit call to
* <code>Activatable.exportObject</code>. The group must inform its
* <code>ActivationMonitor</code> that the object is active (via
* the monitor's <code>activeObject</code> method) if the group
* hasn't already done so.
*
* @param id the object's identifier
* @param obj the remote object implementation
* @exception UnknownObjectException if object is not registered
* @exception RemoteException if call informing monitor fails
*/
{
try {
synchronized (this) {
if (groupInactive == true)
throw new ActivationException("group is inactive");
}
// created new entry, so inform monitor of active object
try {
} catch (RemoteException e) {
// daemon can still find it by calling newInstance
}
}
} finally {
}
}
/**
* Entry in table for active object.
*/
private static class ActiveEntry {
try {
} catch (IOException e) {
throw new
ActivationException("failed to marshal remote object", e);
}
}
}
/**
* Returns true if the first argument is either equal to, or is a
* descendant of, the second argument. Null is treated as the root of
* the tree.
*/
return true;
return false;
}
do {
return true;
}
return false;
}
}