You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2012/01/21 08:28:36 UTC
svn commit: r1234278 [22/29] - in /river/tck: ./ configs/ doc/ doc/api/
doc/api/com/ doc/api/com/sun/ doc/api/com/sun/jini/
doc/api/com/sun/jini/compat/ doc/api/com/sun/jini/compat/admin1/
doc/api/com/sun/jini/compat/admin2/ doc/api/com/sun/jini/compat...
Propchange: river/tck/src/com/sun/jini/compat/start/ServiceStarter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: river/tck/src/com/sun/jini/compat/start/SharedActivation.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/start/SharedActivation.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/start/SharedActivation.java (added)
+++ river/tck/src/com/sun/jini/compat/start/SharedActivation.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,52 @@
+/*
+ *
+ * Copyright 2005 Sun Microsystems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package com.sun.jini.compat.start;
+
+import java.rmi.activation.ActivationID;
+import java.rmi.activation.ActivationException;
+import java.rmi.MarshalledObject;
+import java.rmi.RemoteException;
+
+/**
+ * An interface that shared activation clients use in order to interact
+ * with the activation system. Since the clients are wrapped in the
+ * activation system, they shouldn't directly access the activation data
+ * associated with there <code>ActivationID</code>. Instead they should
+ * use this interface to interact with the activation system.
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ */
+public interface SharedActivation {
+
+ /**
+ * Change the <code>MarshalledObject</code> initialization data for
+ * the activatable object with the specified activation identifier,
+ * assuming the object was registered using this wrapper mechanism.
+ */
+ public void setInitializationData(ActivationID aid,
+ MarshalledObject data)
+ throws ActivationException, RemoteException;
+ /**
+ * Obtain the <code>ActivateDesc</code> for the specified
+ * activation identifier. Returns null if no
+ * <code>ActivateDesc</code> is found.
+ */
+ public ActivateWrapper.ActivateDesc getActivateDesc(ActivationID aid)
+ throws ActivationException, RemoteException;
+}
Propchange: river/tck/src/com/sun/jini/compat/start/SharedActivation.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: river/tck/src/com/sun/jini/compat/start/SharedActivationPolicyPermission.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/start/SharedActivationPolicyPermission.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/start/SharedActivationPolicyPermission.java (added)
+++ river/tck/src/com/sun/jini/compat/start/SharedActivationPolicyPermission.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,202 @@
+/*
+ *
+ * Copyright 2005 Sun Microsystems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package com.sun.jini.compat.start;
+
+import java.io.File;
+import java.io.FilePermission;
+import java.io.Serializable;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+
+/**
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ */
+public final class SharedActivationPolicyPermission extends Permission
+ implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ /*
+ * Debug flag.
+ */
+ private static final boolean DEBUG = false;
+
+ /**
+ * <code>FilePermission</code> object that is the delegation
+ * target of the <code>implies()</code> checks.
+ */
+ private /*final*/ FilePermission policyPermission;
+
+ /**
+ * Constructor that creates a
+ * <code>SharedActivationPolicyPermission</code> with the specified name.
+ * Delegates <code>policy</code> to supertype.
+ */
+ public SharedActivationPolicyPermission(String policy) {
+ //TBD - check for null args
+ super(policy);
+ init(policy);
+ }
+
+ /**
+ * Constructor that creates a
+ * <code>SharedActivationPolicyPermission</code> with the specified name.
+ * This constructor exists for use by the <code>Policy</code> object
+ * to instantiate new Permission objects. The <code>action</code>
+ * argument is currently ignored.
+ */
+ public SharedActivationPolicyPermission(String policy, String action) {
+ //TBD - check for null args
+ super(policy);
+ init(policy);
+ }
+
+ /**
+ * Contains common code to all constructors.
+ */
+ private void init(final String policy) {
+ /*
+ * In order to leverage the <code>FilePermission</code> logic
+ * we need to make sure that forward slashes ("/"), in
+ * <code>URLs</code>, are converted to
+ * the appropriate system dependent <code>File.separatorChar</code>.
+ * For example,
+ * http://host:port/* matches http://host:port/bogus.jar under
+ * UNIX, but not under Windows since "\*" is the wildcard there.
+ */
+ String uncanonicalPath = null;
+ try {
+ URL url = new URL(policy);
+ uncanonicalPath = url.toExternalForm();
+ uncanonicalPath = uncanonicalPath.replace('/', File.separatorChar);
+ if (DEBUG) {
+ System.out.println("SharedActivationPolicyPermission::init() - "
+ + policy + " => " + uncanonicalPath);
+ }
+ } catch (MalformedURLException me) {
+ uncanonicalPath = policy;
+ }
+
+ policyPermission = new FilePermission(uncanonicalPath, "read");
+ }
+
+ // javadoc inherited from superclass
+ public boolean implies(Permission p) {
+
+ // Quick reject tests
+ if (p == null)
+ return false;
+ if (!(p instanceof SharedActivationPolicyPermission))
+ return false;
+
+ SharedActivationPolicyPermission other =
+ (SharedActivationPolicyPermission)p;
+
+ // Delegate to FilePermission logic
+ boolean answer = policyPermission.implies(other.policyPermission);
+
+ if (DEBUG) {
+ System.out.println("SharedActivationPolicyPermission::implies() - "
+ + "checking " + policyPermission + " vs. "
+ + other.policyPermission + ": " + answer);
+ }
+
+ return answer;
+ }
+
+ /** Two instances are equal if they have the same name. */
+ public boolean equals(Object obj) {
+ // Quick reject tests
+ if (obj == null)
+ return false;
+ if (this == obj)
+ return true;
+ if (!(obj instanceof SharedActivationPolicyPermission))
+ return false;
+
+ SharedActivationPolicyPermission other =
+ (SharedActivationPolicyPermission)obj;
+
+ boolean answer = policyPermission.equals(other.policyPermission);
+ if (DEBUG) {
+ System.out.println("SharedActivationPolicyPermission::equals() - "
+ + "checking " + policyPermission + " vs. "
+ + other.policyPermission + ": " + answer);
+ }
+
+ return answer;
+ }
+
+ // javadoc inherited from superclass
+ public int hashCode() {
+ return getName().hashCode();
+ }
+
+ // javadoc inherited from superclass
+ public String getActions() {
+ return "";
+ }
+
+ // javadoc inherited from superclass
+ public PermissionCollection newPermissionCollection() {
+ /* bug 4158302 fix */
+ return new Collection();
+ }
+
+ /** Simple permission collection. See Bug 4158302 */
+ private static class Collection extends PermissionCollection {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Permissions
+ *
+ * @serial
+ **/
+ private final ArrayList perms = new ArrayList(3);
+
+ // javadoc inherited from superclass
+ public synchronized void add(Permission p) {
+ if (isReadOnly())
+ throw new SecurityException("Collection cannot be modified.");
+
+ if (perms.indexOf(p) < 0)
+ perms.add(p);
+ }
+
+ // javadoc inherited from superclass
+ public synchronized boolean implies(Permission p) {
+ for (int i = perms.size(); --i >= 0; ) {
+ if (((Permission)perms.get(i)).implies(p))
+ return true;
+ }
+ return false;
+ }
+
+ // javadoc inherited from superclass
+ public Enumeration elements() {
+ return Collections.enumeration(perms);
+ }
+ }
+}
Propchange: river/tck/src/com/sun/jini/compat/start/SharedActivationPolicyPermission.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: river/tck/src/com/sun/jini/compat/start/SharedGroup.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/start/SharedGroup.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/start/SharedGroup.java (added)
+++ river/tck/src/com/sun/jini/compat/start/SharedGroup.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,33 @@
+/*
+ *
+ * Copyright 2005 Sun Microsystems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.sun.jini.compat.start;
+
+import java.rmi.activation.ActivationException;
+import java.rmi.RemoteException;
+
+/**
+ * The <code>SharedGroup</code> marker interface
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ */
+
+public interface SharedGroup {
+ // no methods or fields
+}
Propchange: river/tck/src/com/sun/jini/compat/start/SharedGroup.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: river/tck/src/com/sun/jini/compat/start/SharedGroupAdminProxy.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/start/SharedGroupAdminProxy.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/start/SharedGroupAdminProxy.java (added)
+++ river/tck/src/com/sun/jini/compat/start/SharedGroupAdminProxy.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,88 @@
+/*
+ *
+ * Copyright 2005 Sun Microsystems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package com.sun.jini.compat.start;
+
+import java.io.Serializable;
+import java.rmi.RemoteException;
+
+import com.sun.jini.admin.DestroyAdmin;
+import com.sun.jini.mahout.KillVMAdmin;
+
+
+/**
+ * <code>SharedGroupAdminProxy</code> is a client-side admin proxy for a
+ * shared group service.
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ * @since 1.2
+ */
+class SharedGroupAdminProxy
+ implements DestroyAdmin, KillVMAdmin, Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The backend service
+ *
+ * @serial
+ */
+ private final SharedGroupBackEnd server;
+
+ /** Simple constructor. */
+ public SharedGroupAdminProxy(SharedGroupBackEnd sgbe) {
+ if (sgbe == null)
+ throw new IllegalArgumentException("SharedGroupBackEnd "
+ + "reference cannot be null");
+
+ server = sgbe;
+ }
+
+ // documentation inherited from supertype
+ public void destroy() throws RemoteException {
+ server.destroy();
+ }
+
+ // documentation inherited from supertype
+ public long killVM() throws RemoteException {
+ return server.killVM();
+ }
+
+ // documentation inherited from supertype
+ public int hashCode() {
+ return server.hashCode();
+ }
+
+ /**
+ * Proxies for the same remote server are considered equal
+ */
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null)
+ return false;
+
+ if (o.getClass() != getClass())
+ return false;
+
+ SharedGroupAdminProxy op = (SharedGroupAdminProxy)o;
+ return server.equals(op.server);
+ }
+}
+
Propchange: river/tck/src/com/sun/jini/compat/start/SharedGroupAdminProxy.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: river/tck/src/com/sun/jini/compat/start/SharedGroupBackEnd.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/start/SharedGroupBackEnd.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/start/SharedGroupBackEnd.java (added)
+++ river/tck/src/com/sun/jini/compat/start/SharedGroupBackEnd.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,44 @@
+/*
+ *
+ * Copyright 2005 Sun Microsystems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.sun.jini.compat.start;
+
+import java.rmi.Remote;
+
+import com.sun.jini.admin.DestroyAdmin;
+import com.sun.jini.mahout.KillVMAdmin;
+
+import net.jini.admin.Administrable;
+
+/**
+ * The <code>SharedGroupBackEnd</code> interface
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ * @see net.jini.admin.Administrable
+ * @see com.sun.jini.compat.start.SharedGroupAdmin
+ * @see com.sun.jini.mahout.KillVMAdmin
+ *
+ * @since 1.2
+ */
+
+interface SharedGroupBackEnd
+ extends Administrable, DestroyAdmin, KillVMAdmin, Remote
+{
+ // No additional methods
+}
Propchange: river/tck/src/com/sun/jini/compat/start/SharedGroupBackEnd.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: river/tck/src/com/sun/jini/compat/start/SharedGroupImpl.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/start/SharedGroupImpl.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/start/SharedGroupImpl.java (added)
+++ river/tck/src/com/sun/jini/compat/start/SharedGroupImpl.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,426 @@
+/*
+ *
+ * Copyright 2005 Sun Microsystems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package com.sun.jini.compat.start;
+
+import com.sun.jini.constants.TimeConstants;
+import com.sun.jini.debug.Debug;
+import com.sun.jini.system.FileSystem;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.rmi.MarshalledObject;
+import java.rmi.NoSuchObjectException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.activation.Activatable;
+import java.rmi.activation.ActivationGroup;
+import java.rmi.activation.ActivationGroupID;
+import java.rmi.activation.ActivationID;
+import java.rmi.activation.ActivationSystem;
+import java.rmi.activation.ActivationException;
+import java.rmi.server.UnicastRemoteObject;
+import java.security.AccessController;
+import java.util.Iterator;
+
+// TBD - Implement Registry.checkAccess() to insure local access to this
+// object's methods.
+//
+
+/**
+ * The <code>SharedGroupImpl</code> class is the back-end implementation
+ * of the <code>SharedGroup</code> service.
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ */
+public class SharedGroupImpl implements SharedGroupBackEnd {
+ /**
+ * Utility for outputting debug messages.
+ */
+ private static final Debug debug =
+ (Debug)AccessController.doPrivileged(
+ Debug.getDebugAction(GroupConstants.DEBUG_PROP));
+
+
+ /**
+ * Print writer for group administration related messages.
+ */
+ private static final PrintWriter dbgAdmin = debug.getWriter("admin");
+
+ /**
+ * Print writer for group initialization related messages.
+ */
+ private static final PrintWriter dbgInit = debug.getWriter("init");
+
+ /** Our activation ID */
+ private ActivationID activationID = null;
+
+ /** Name of persistence directory */
+ private String logDirname = null;
+
+ /** Object for coordinating the destroy process */
+ private final Object destroyLock = new Object();
+
+ /**
+ * Flag that denotes whether or not destroy has already been called.
+ * The variable is guarded by <code>destroyLock</code>.
+ */
+ private boolean destroySucceeded = false;
+
+ /**
+ * Shared activation constructor required by the
+ * <code>ActivateWrapper</code> class.
+ */
+ public SharedGroupImpl(ActivationID activationID, MarshalledObject data,
+ SharedActivation sa)
+ throws IOException, ClassNotFoundException
+ {
+ // TBD - write lock out file to log
+ if (dbgInit != null) {
+ dbgInit.println("SharedGroupImpl::SharedGroupImpl()");
+ System.getProperties().list(dbgInit);
+ }
+ this.activationID = activationID;
+
+ boolean runtimeThrown = false;
+ Remote ourStub = null;
+ try {
+ try {
+ if (dbgInit != null) {
+ dbgInit.println("SharedGroupImpl is being exported");
+ }
+ ourStub = Activatable.exportObject(this, activationID, 0);
+ } catch (RemoteException e) {
+ alertAndUnregister("Failure exporting object", e);
+ throw e;
+ }
+
+ // Get Log Dir Name
+ try {
+ logDirname = (String)data.get();
+ if (dbgInit != null) {
+ dbgInit.println("Obtained persistence path: " + logDirname);
+ }
+ } catch (IOException e) {
+ alertAndUnregister("Failure recovering activation data", e);
+ throw e;
+ } catch (ClassNotFoundException e) {
+ alertAndUnregister("Failure recovering activation data", e);
+ throw e;
+ } catch (ClassCastException e) {
+ alertAndUnregister("Failure recovering activation data", e);
+ runtimeThrown = true;
+ throw e;
+ }
+ } catch (RuntimeException e) {
+ if (runtimeThrown == false) {
+ alertAndUnregister("Unexpected exception during activation",
+ e);
+ }
+ throw e;
+ } catch (Error e) {
+ alertAndUnregister("Unexpected error during activation", e);
+ throw e;
+ }
+
+
+ }
+
+ ////////////////////////
+ // DestroyAdmin Methods
+ ////////////////////////
+
+ // javadoc inherited from supertype
+ public void destroy() {
+ if (dbgAdmin != null) {
+ dbgAdmin.println("SharedGroupImpl::destroy()");
+ }
+ (new DestroyThread()).start();
+ }
+
+ ////////////////////////
+ // Administrable Methods
+ ////////////////////////
+
+ // javadoc inherited from supertype
+ public Object getAdmin() throws RemoteException {
+ if (dbgAdmin != null) {
+ dbgAdmin.println("getAdmin called");
+ }
+ return (new SharedGroupAdminProxy(this));
+ }
+
+ //////////////////////////////////
+ // KillVMAdmin methods
+ //////////////////////////////////
+ /**
+ * Sleep time for <code>killVM</code>.
+ *
+ * @see killVM
+ */
+ private final static long KILL_DELAY = 500; // milliseconds
+
+ // javadoc inherited from supertype
+ public long killVM() {
+ if (dbgAdmin != null) {
+ dbgAdmin.println("killVM called");
+ }
+ System.exit(0); // exit immediately
+
+ // Not used, but makes the compiler happy
+ return KILL_DELAY * 6;
+ }
+
+ /**
+ * If for some reason we can't activate, we dump a message to the log
+ * and unregister with activation.
+ * @param m message to dump to <code>System.err</code>
+ * @param e If non-<code>null</code> this exception is dumped to
+ * <code>System.err</code> as well
+ */
+ private void alertAndUnregister(String m, Throwable e) {
+ System.err.println("Fatal error during activation:" + m);
+ if (e != null) {
+ e.printStackTrace();
+ }
+ Exception failed = null;
+
+ try {
+ System.err.println("Attempting to unregister with activation system"
+);
+ ActivationSystem sys = ActivationGroup.getSystem();
+ System.err.println("Contacted activation system");
+ // Unregistering the group will also unregister all assoc. objects
+ ActivationGroupID grp = ActivationGroup.currentGroupID();
+ if (grp != null) {
+ sys.unregisterGroup(grp);
+ } else {
+ throw new ActivationException("ActivationGroup does not exist");
+ }
+ System.err.println("Unregistered group with activation system");
+ } catch (Exception ee) {
+ failed = ee;
+ }
+
+ if (failed != null) {
+ System.err.println("Failed to unregister with activation system");
+ failed.printStackTrace();
+ } else {
+ System.err.println("Succeeded in unregistering");
+ }
+ }
+
+ /**
+ * Termination thread code. We do this in a separate thread to
+ * avoid deadlock, because Activatable.inactive will block until
+ * in-progress RMI calls are finished.
+ */
+ private class DestroyThread extends Thread implements TimeConstants {
+
+ /** Maximum delay for unexport attempts */
+ private static final long MAX_UNEXPORT_DELAY = 2 * MINUTES;
+
+ /** Create a non-daemon thread */
+ public DestroyThread() {
+ super("DestroyThread");
+ /* override inheritance from RMI daemon thread */
+ setDaemon(false);
+ }
+
+ public void run() {
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread started ...");
+ }
+ synchronized (destroyLock) {
+
+ if (destroySucceeded == true) { // someone got here first
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread skipped ...");
+ }
+ return;
+ }
+
+ /* must unregister before unexport */
+ if (activationID != null) {
+ try {
+ Activatable.unregister(activationID);
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread: unregistered "
+ + "successfully.");
+ }
+ } catch (RemoteException e) {
+ /* give up until we can at least unregister */
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread: trouble "
+ + "unregistering: " + e);
+ dbgAdmin.println("DestroyThread: skipping "
+ + "destroy processing.");
+ }
+ return;
+ } catch (ActivationException e) {
+ /*
+ * Activation system is shutting down or this
+ * object has already been unregistered --
+ * ignore in either case.
+ */
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread: trouble "
+ + "unregistering: " + e);
+ }
+ }
+ }
+
+ final long end_time =
+ System.currentTimeMillis() + MAX_UNEXPORT_DELAY;
+ boolean unexported = false;
+ boolean force = false;
+ try {
+ while ((!unexported) &&
+ (System.currentTimeMillis() < end_time))
+ {
+ /* wait for any pending operations to complete */
+ unexported =
+ UnicastRemoteObject.unexportObject(
+ SharedGroupImpl.this, force);
+ if (unexported) {
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread: successfully "
+ + "unexported without forcing.");
+ }
+ } else {
+ Thread.yield();
+ }
+ }
+ } catch (NoSuchObjectException e) {
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread: trouble "
+ + "unexporting without forcing: " + e);
+ }
+ unexported = true; // no sense trying again
+ }
+
+ if (!unexported) {
+ /* Attempt to forcefully export the service */
+ force = true;
+ try {
+ unexported =
+ UnicastRemoteObject.unexportObject(
+ SharedGroupImpl.this, force);
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread: unexporting "
+ + this.getClass().getName()
+ + ((unexported)?" succeeded":" failed"));
+ }
+ } catch (NoSuchObjectException e) {
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread: trouble "
+ + "unexporting forced: " + e);
+ }
+ unexported = true; // no sense trying again
+ }
+ }
+
+
+ // Attempt to delete the persistence directory
+ boolean proceed = true;
+ try {
+ File log = new File(logDirname);
+ FileSystem.destroy(log, proceed);
+ } catch (IOException ioe) {
+ if (dbgAdmin != null) {
+ dbgAdmin.println("Trouble destroying persistence"
+ + " directory[" + logDirname + "]: "
+ + ioe);
+ ioe.printStackTrace(dbgAdmin);
+ }
+
+ } catch (SecurityException se) {
+ if (dbgAdmin != null) {
+ dbgAdmin.println("Trouble destroying persistence"
+ + " directory[" + logDirname + "]: "
+ + se);
+ se.printStackTrace(dbgAdmin);
+ }
+ }
+
+ if (activationID != null) {
+ /* inactive will set current group ID to null */
+ ActivationGroupID gid = ActivationGroup.currentGroupID();
+ boolean inactive = false;
+ try {
+ inactive = Activatable.inactive(activationID);
+ if (dbgAdmin != null) {
+ if (inactive) {
+ dbgAdmin.println("DestroyThread: Object "
+ + "inactivated.");
+ } else {
+ dbgAdmin.println("DestroyThread: Call to "
+ + "inactive failed -- should not happen.");
+ }
+ }
+ } catch (RemoteException e) {
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread: trouble "
+ + "calling inactive: " + e);
+ }
+ // ignore
+ } catch (ActivationException e) {
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread: trouble "
+ + "calling inactive: " + e);
+ }
+ // ignore
+ }
+
+ try {
+ ActivationGroup.getSystem().unregisterGroup(gid);
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread: ActivationGroup "
+ + "unregistered.");
+ }
+ } catch (RemoteException e) {
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread: trouble "
+ + "unregistering group: " + e);
+ }
+ // ignore
+ } catch (ActivationException e) {
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread: trouble "
+ + "unregistering group: " + e);
+ }
+ // ignore
+ }
+ } // if (activationID != null)
+
+ destroySucceeded = true;
+ } // end sync block
+
+ if (dbgAdmin != null) {
+ dbgAdmin.println("DestroyThread finished ... killing VM");
+ }
+
+ /*
+ * Forcefully destroy the VM, in case there are any lingering
+ * threads.
+ */
+ System.exit(0);
+ }
+ }
+}
Propchange: river/tck/src/com/sun/jini/compat/start/SharedGroupImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: river/tck/src/com/sun/jini/compat/start/SharedGroupProxy.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/start/SharedGroupProxy.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/start/SharedGroupProxy.java (added)
+++ river/tck/src/com/sun/jini/compat/start/SharedGroupProxy.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,82 @@
+/*
+ *
+ * Copyright 2005 Sun Microsystems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package com.sun.jini.compat.start;
+
+import java.io.Serializable;
+import java.rmi.RemoteException;
+
+import net.jini.admin.Administrable;
+
+
+/**
+ * The <code>SharedGroupProxy</code> class represents the client-side
+ * reference to a shared group object.
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ */
+
+class SharedGroupProxy implements SharedGroup, Administrable, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The reference to the service implementation
+ *
+ * @serial
+ */
+ private final SharedGroupBackEnd server;
+
+ /**
+ * Simple Constructor.
+ */
+ public SharedGroupProxy(SharedGroupBackEnd sgbe) {
+ if (sgbe == null)
+ throw new IllegalArgumentException("SharedGroupBackEnd "
+ + "reference cannot be null");
+ server = sgbe;
+ }
+
+ // Documentation inherited from supertype
+ public Object getAdmin() throws RemoteException
+ {
+ return server.getAdmin();
+ }
+
+ // documentation inherited from supertype
+ public int hashCode() {
+ return server.hashCode();
+ }
+
+ /**
+ * Proxies for the same remote server are considered equal
+ */
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null)
+ return false;
+
+ if (o.getClass() != getClass())
+ return false;
+
+ SharedGroupProxy op = (SharedGroupProxy)o;
+ return server.equals(op.server);
+ }
+}
Propchange: river/tck/src/com/sun/jini/compat/start/SharedGroupProxy.java
------------------------------------------------------------------------------
svn:eol-style = native