harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r468833 - in /incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java: java/rmi/activation/ActivationGroup.java org/apache/harmony/rmi/common/GetStringPropAction.java
Date Sun, 29 Oct 2006 05:05:18 GMT
Author: ndbeyer
Date: Sat Oct 28 22:05:17 2006
New Revision: 468833

URL: http://svn.apache.org/viewvc?view=rev&rev=468833
Log:
Cleanup ActivationGroup; remove weird Thread.sleep() call, format the code, etc 

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/java/rmi/activation/ActivationGroup.java
    incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/common/GetStringPropAction.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/java/rmi/activation/ActivationGroup.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/java/rmi/activation/ActivationGroup.java?view=diff&rev=468833&r1=468832&r2=468833
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/java/rmi/activation/ActivationGroup.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/java/rmi/activation/ActivationGroup.java
Sat Oct 28 22:05:17 2006
@@ -16,10 +16,6 @@
  * limitations under the License.
  */
 
-/**
- * @author  Victor A. Martynov
- * @version $Revision: 1.17.2.3 $
- */
 package java.rmi.activation;
 
 import java.lang.reflect.Constructor;
@@ -36,15 +32,11 @@
 import org.apache.harmony.rmi.common.RMILog;
 import org.apache.harmony.rmi.internal.nls.Messages;
 
-
-/**
- * @com.intel.drl.spec_ref
- *
- * @author  Victor A. Martynov
- * @version $Revision: 1.17.2.3 $
- */
 public abstract class ActivationGroup extends UnicastRemoteObject
         implements ActivationInstantiator {
+    private static final long serialVersionUID = -7696947875314805420L;
+
+    private static final RMILog rlog = RMILog.getActivationLog();
 
     /**
      * The ActivationSystem for this VM.
@@ -61,88 +53,25 @@
      */
     private static ActivationGroup current_AG;
 
-    /**
-     * Boolean value that is used to prohibit the recurring creation of
-     * ActivationGroup for this VM.
-     */
-    private static boolean isGroupCreated = false;
-
-    /**
-     * Information got from ActivationGroup Serialized form.
-     */
-    private static final long serialVersionUID = -7696947875314805420L;
-
-    private ActivationGroupID groupID;
-
-    private ActivationMonitor monitor;
-
-    private long incarnation;
-
-    private static RMILog rlog = RMILog.getActivationLog();
-
-    /**
-     * @com.intel.drl.spec_ref
-     */
-    protected ActivationGroup(ActivationGroupID groupID) throws RemoteException {
-        /**
-         * We need to export this group, so we call the constructor of the
-         * superclass.
-         */
-        super(0);
-        this.groupID = groupID;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     */
-    protected void activeObject(ActivationID id, MarshalledObject mobj)
-            throws ActivationException, UnknownObjectException, RemoteException {
-        try {
-            Thread.sleep(500);
-        } catch (Throwable t) {
-        }
-        // rmi.log.14=ActivationGroup.activeObject: {0}; {1}
-        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.14", id, mobj)); //$NON-NLS-1$
-        // rmi.log.15=monitor: {0}
-        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.15", monitor)); //$NON-NLS-1$
-        monitor.activeObject(id, mobj);
-        // rmi.log.16=ActivationGroup.activeObject finished.
-        rlog.log(RMILog.VERBOSE,Messages.getString("rmi.log.16")); //$NON-NLS-1$
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     */
-    public abstract void activeObject(ActivationID id, Remote obj)
-            throws ActivationException, UnknownObjectException, RemoteException;
-
-    /**
-     * @com.intel.drl.spec_ref
-     */
-    public static synchronized ActivationGroup createGroup(
-            ActivationGroupID id, ActivationGroupDesc desc, long incarnation)
-            throws ActivationException {
-        // rmi.log.17=ActivationGroup.createGroup [id={0}, desc={1}, incarnation={2}
+    public static synchronized ActivationGroup createGroup(ActivationGroupID id,
+            ActivationGroupDesc desc, long incarnation) throws ActivationException {
+        // rmi.log.17=ActivationGroup.createGroup [id={0}, desc={1},
+        // incarnation={2}
         rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.17", //$NON-NLS-1$ 
-                new Object[]{id, desc, incarnation})); 
-
+                new Object[] { id, desc, incarnation }));
         SecurityManager sm = System.getSecurityManager();
-
-        if(sm != null) {
+        if (sm != null) {
             sm.checkSetFactory();
         }
-
         /*
-         * Classname of the ActivationGroup implemenation. If the group class
+         * Classname of the ActivationGroup implementation. If the group class
          * name was given in 'desc' assign it to group_CN, use default
          * otherwise.
          */
-        String group_CN = (desc.getClassName() == null) ?
-                "org.apache.harmony.rmi.activation.ActivationGroupImpl" //$NON-NLS-1$
+        String group_CN = (desc.getClassName() == null) ? "org.apache.harmony.rmi.activation.ActivationGroupImpl"
//$NON-NLS-1$
                 : desc.getClassName();
         // rmi.log.18=group_CN = {0}
         rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.18", group_CN)); //$NON-NLS-1$
-
         if (current_AG != null) {
             // rmi.11=The ActivationGroup for this VM already exists.
             throw new ActivationException(Messages.getString("rmi.11")); //$NON-NLS-1$
@@ -150,15 +79,12 @@
         try {
             // rmi.log.19=Ready to load ActivationGroupImpl class
             rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.19")); //$NON-NLS-1$
-            Class cl = RMIClassLoader.loadClass(desc.getLocation(), group_CN);
+            Class<?> cl = RMIClassLoader.loadClass(desc.getLocation(), group_CN);
             // rmi.log.1A=ag class = {0}
             rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.1A", cl)); //$NON-NLS-1$
-
-            Class[] special_constructor_parameter_classes = {
-                    ActivationGroupID.class, MarshalledObject.class };
-
-            Constructor constructor = cl
-                    .getConstructor(special_constructor_parameter_classes);
+            Class[] special_constructor_parameter_classes = { ActivationGroupID.class,
+                    MarshalledObject.class };
+            Constructor<?> constructor = cl.getConstructor(special_constructor_parameter_classes);
             Object[] constructor_parameters = { id, desc.getData() };
             ActivationGroup ag = (ActivationGroup) constructor
                     .newInstance(constructor_parameters);
@@ -167,58 +93,41 @@
             current_AS = id.getSystem();
             // rmi.log.1C=current_AS = {0}
             rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.1C", current_AS)); //$NON-NLS-1$
-
             ag.incarnation = incarnation;
             // rmi.log.1D=ag.incarnation = {0}
             rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.1D", ag.incarnation)); //$NON-NLS-1$
-
             ag.monitor = current_AS.activeGroup(id, ag, incarnation);
             // rmi.log.1E=ag.monitor = {0}
             rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.1E", ag.monitor)); //$NON-NLS-1$
-
             current_AG = ag;
             current_AGID = id;
-            isGroupCreated = true;
-
         } catch (Throwable t) {
             // rmi.log.1F=Exception in createGroup: {0}
             rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.1F", t)); //$NON-NLS-1$
-            t.printStackTrace();
             // rmi.12=Unable to create group.
             throw new ActivationException(Messages.getString("rmi.12"), t); //$NON-NLS-1$
         }
         // rmi.log.20=Group created: {0}
         rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.20", current_AG)); //$NON-NLS-1$
-
         return current_AG;
     }
 
-    /**
-     * @com.intel.drl.spec_ref
-     */
     public static synchronized ActivationGroupID currentGroupID() {
         return current_AGID;
     }
 
-    /**
-     * @com.intel.drl.spec_ref
-     */
-    public static synchronized ActivationSystem getSystem()
-            throws ActivationException {
+    public static synchronized ActivationSystem getSystem() throws ActivationException {
         // rmi.log.21=---------- ActivationGroup.getSystem() ----------
         rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.21")); //$NON-NLS-1$
-        System.out.flush();
-
         try {
             if (current_AS == null) {
-
-                String port = (String)AccessController.doPrivileged(
-                        new GetStringPropAction("java.rmi.activation.port", //$NON-NLS-1$
-                                                ActivationSystem.SYSTEM_PORT+"")); //$NON-NLS-1$
-
+                String port = AccessController.doPrivileged(new GetStringPropAction(
+                        "java.rmi.activation.port", //$NON-NLS-1$
+                        ActivationSystem.SYSTEM_PORT + "")); //$NON-NLS-1$
                 current_AS = (ActivationSystem) Naming.lookup("//:" + port //$NON-NLS-1$
                         + "/java.rmi.activation.ActivationSystem"); //$NON-NLS-1$
-                // rmi.log.22=Activation System was got using Naming.lookup() at port {0}
+                // rmi.log.22=Activation System was got using Naming.lookup() at
+                // port {0}
                 rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.22", port)); //$NON-NLS-1$
             }
         } catch (Throwable t) {
@@ -230,47 +139,62 @@
         // rmi.log.23=current_AS.ref = {0}
         rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.23", //$NON-NLS-1$
                 ((RemoteObject) current_AS).getRef()));
-
         // rmi.log.24=---------- END -> ActivationGroup.getSystem() ----------
         rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.24")); //$NON-NLS-1$
-
         return current_AS;
     }
 
-    /**
-     * @com.intel.drl.spec_ref
-     */
-    protected void inactiveGroup() throws UnknownGroupException,
-            RemoteException {
-        monitor.inactiveGroup(groupID, incarnation);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     */
-    public boolean inactiveObject(ActivationID id) throws ActivationException,
-            UnknownObjectException, RemoteException {
-        monitor.inactiveObject(id);
-        return true;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     */
     public static synchronized void setSystem(ActivationSystem system)
             throws ActivationException {
         if (current_AS != null) {
-            // rmi.14=The ActivationSystem for this ActivationGroup was already defined.
+            // rmi.14=The ActivationSystem for this ActivationGroup was already
+            // defined.
             throw new ActivationException(Messages.getString("rmi.14")); //$NON-NLS-1$
         }
         current_AS = system;
     }
 
-    /* ********************************************************************* */
-    /* ************** Package protected methods **************************** */
-    /* ********************************************************************* */
-
     static synchronized ActivationGroup getCurrentAG() {
         return current_AG;
+    }
+
+    private ActivationGroupID groupID;
+
+    private ActivationMonitor monitor;
+
+    private long incarnation;
+
+    protected ActivationGroup(ActivationGroupID groupID) throws RemoteException {
+        /**
+         * We need to export this group, so we call the constructor of the
+         * superclass.
+         */
+        super(0);
+        this.groupID = groupID;
+    }
+
+    protected void activeObject(ActivationID id, MarshalledObject mobj)
+            throws ActivationException, UnknownObjectException, RemoteException {       

+        // rmi.log.14=ActivationGroup.activeObject: {0}; {1}
+        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.14", id, mobj)); //$NON-NLS-1$
+        // rmi.log.15=monitor: {0}
+        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.15", monitor)); //$NON-NLS-1$
+        monitor.activeObject(id, mobj);
+        // rmi.log.16=ActivationGroup.activeObject finished.
+        rlog.log(RMILog.VERBOSE,Messages.getString("rmi.log.16")); //$NON-NLS-1$
+    }
+
+    public abstract void activeObject(ActivationID id, Remote obj)
+            throws ActivationException, UnknownObjectException, RemoteException;
+
+    protected void inactiveGroup() throws UnknownGroupException,
+            RemoteException {
+        monitor.inactiveGroup(groupID, incarnation);
+    }
+
+    public boolean inactiveObject(ActivationID id) throws ActivationException,
+            UnknownObjectException, RemoteException {
+        monitor.inactiveObject(id);
+        return true;
     }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/common/GetStringPropAction.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/common/GetStringPropAction.java?view=diff&rev=468833&r1=468832&r2=468833
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/common/GetStringPropAction.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/common/GetStringPropAction.java
Sat Oct 28 22:05:17 2006
@@ -16,28 +16,19 @@
  * limitations under the License.
  */
 
-/**
- * @author  Mikhail A. Markov
- * @version $Revision: 1.1.2.3 $
- */
 package org.apache.harmony.rmi.common;
 
 import java.security.PrivilegedAction;
 
-
 /**
  * Action for obtaining properties holding string values.
- *
- * @author  Mikhail A. Markov
- * @version $Revision: 1.1.2.3 $
  */
-public class GetStringPropAction implements PrivilegedAction {
-
+public class GetStringPropAction implements PrivilegedAction<String> {
     // the name of the property to be obtained
-    private String propName;
+    private final String propName;
 
     // default value for the property
-    private String defaultVal;
+    private final String defaultVal;
 
     /**
      * Constructs GetStringPropAction to read property with the given name.
@@ -67,7 +58,7 @@
      *
      * @return property read or defaultValue if property read is null
      */
-    public Object run() {
+    public String run() {
         return System.getProperty(propName, defaultVal);
     }
 }



Mime
View raw message