You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2006/04/06 22:49:21 UTC

svn commit: r392066 - in /beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime: bean/ControlBean.java bean/ControlBeanContext.java servlet/ServletBeanContext.java

Author: ekoneil
Date: Thu Apr  6 13:49:19 2006
New Revision: 392066

URL: http://svn.apache.org/viewcvs?rev=392066&view=rev
Log:
Consistency / readability in Controls code.

BB: self
Test: Controls pass


Modified:
    beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/bean/ControlBean.java
    beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/bean/ControlBeanContext.java
    beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/servlet/ServletBeanContext.java

Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/bean/ControlBean.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/bean/ControlBean.java?rev=392066&r1=392065&r2=392066&view=diff
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/bean/ControlBean.java (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/bean/ControlBean.java Thu Apr  6 13:49:19 2006
@@ -768,7 +768,7 @@
     /**
      * This protected version is only available to concrete subclasses that expose bound
      * property support.   This method is synchronized to enable lazy instantiation, in
-     * the belief that is a bigger win to avoid allocating when there are no listeners
+     * the belief that it is a bigger win to avoid allocating when there are no listeners
      * than it is to introduce synchronization overhead on access.
      */
     synchronized protected PropertyChangeSupport getPropertyChangeSupport()

Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/bean/ControlBeanContext.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/bean/ControlBeanContext.java?rev=392066&r1=392065&r2=392066&view=diff
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/bean/ControlBeanContext.java (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/bean/ControlBeanContext.java Thu Apr  6 13:49:19 2006
@@ -64,8 +64,7 @@
  */
 public class ControlBeanContext 
     extends BeanContextServicesSupport
-    implements BeanContextServiceRevokedListener,
-    org.apache.beehive.controls.api.context.ControlBeanContext,
+    implements org.apache.beehive.controls.api.context.ControlBeanContext,
     java.beans.PropertyChangeListener,
     java.beans.VetoableChangeListener
 {
@@ -82,54 +81,6 @@
     }
 
     /**
-     * The ControlBeanContextProvider inner class acts as a single BeanContext service
-     * provider for the ControlBeanContext service class.  The implementation is simple,
-     * because the runtime ControlBeanContext implementation class directly implements
-     * this interface.
-     */
-    private static class ControlBeanContextProvider implements BeanContextServiceProvider
-    {
-        //
-        // BeanContextServiceProvider.getService()
-        //
-        public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass,
-                                 Object serviceSelector)
-        {
-            //
-            // Contextual services for a ControlBean is provided by the peer context
-            // instance.
-            //
-            if (requestor instanceof ControlBean)
-                return ((ControlBean)requestor).getControlBeanContext();
-
-            return null;
-        }
-
-        //
-        // BeanContextServiceProvider.releaseService()
-        //
-        public void releaseService(BeanContextServices bcs, Object requestor, Object service)
-        {
-            // noop, because context exists whether referenced or not
-        }
-
-        //
-        // BeanContextServiceProvider.getContextServiceSelectors()
-        //
-        public Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass)
-        {
-            return null;    // no selectors
-        }
-    }
-
-    /**
-     * A singleton instance of the ControlBeanContextProvider class is that will be registered
-     * on all ControlBeanContext instances.  The provider can be a singleton because it is
-     * completely stateless and thread-safe.
-     */
-    static private ControlBeanContextProvider theProvider = new ControlBeanContextProvider();
-
-    /**
      * Called by BeanContextSupport superclass during construction and deserialization to 
      * initialize subclass transient state
      */
@@ -144,8 +95,9 @@
     }
 
     /**
-     * Implements the BeanContextServicesRevokedListener.servicesRevoked method.  This is
-     * called if the associated ControlBean has requested a service that is being subsequently
+     * Implements the
+     * {@link java.beans.beancontext.BeanContextServiceRevokedListener#serviceRevoked(java.beans.beancontext.BeanContextServiceRevokedEvent)}
+     * method.  This is called if the associated {@link ControlBean} has requested a service that is being subsequently
      * revoked.
      */
     public void serviceRevoked(BeanContextServiceRevokedEvent bcsre)
@@ -157,9 +109,9 @@
     }
 
     /**
-     * Overrides the BeanContextChild.setBeanContext() method.  This hook is used to perform
-     * additional processing that needs to occur when the control is associated with a new
-     * nesting context.
+     * Overrides the {@link java.beans.beancontext.BeanContextChild#setBeanContext(java.beans.beancontext.BeanContext)}
+     * method.  This hook is used to perform additional processing that needs to occur when the control is associated
+     * with a new nesting context.
      */
     public synchronized void setBeanContext(BeanContext beanContext) throws PropertyVetoException
     {
@@ -173,8 +125,7 @@
             //
             if (!(beanContext instanceof ControlBeanContext))
             {
-                PropertyChangeEvent pce = new PropertyChangeEvent(_bean, "beanContext",
-                                                                  getBeanContext(), beanContext);
+                PropertyChangeEvent pce = new PropertyChangeEvent(_bean, "beanContext", getBeanContext(), beanContext);
                 throw new PropertyVetoException("Context does not support nesting controls: " +
                                                 beanContext.getClass(), pce);
             }
@@ -375,11 +326,8 @@
         //
         if (_lifeCycleListeners != null)
         {
-            Iterator iter = _lifeCycleListeners.iterator();      
-            while (iter.hasNext())
-            {
-                LifeCycle listener = (LifeCycle)iter.next();
-                listener.onCreate();
+            for (LifeCycle lifeCycleListener : _lifeCycleListeners) {
+                lifeCycleListener.onCreate();
             }
         }
     }
@@ -716,15 +664,15 @@
             }
             catch (IOException e)
             {
+                // ignore
             }
             finally
             {
-                try
-                {
+                try {
                     if (in != null)
                         in.close();
                 }
-                catch ( IOException ie ) { }
+                catch ( IOException ie ) { /* ignore */ }
             }
         }
 
@@ -804,11 +752,8 @@
     {
         if (_lifeCycleListeners != null)
         {
-            Iterator iter = _lifeCycleListeners.iterator();      
-            while (iter.hasNext())
-            {
-                LifeCycle listener = (LifeCycle)iter.next();
-                listener.onVetoableChange(pce);
+            for (LifeCycle lifeCycleListener : _lifeCycleListeners) {
+                lifeCycleListener.onVetoableChange(pce);
             }
         }
     }
@@ -848,12 +793,9 @@
     private void resetControlID()
     {
         _controlID = null;
-        Iterator childIter = this.iterator();
-        while (childIter.hasNext())
-        {
-            Object child = childIter.next();
+        for (Object child : this) {
             if (child instanceof ControlBeanContext)
-                ((ControlBeanContext)child).resetControlID();
+                ((ControlBeanContext) child).resetControlID();
         }
     }
 
@@ -913,6 +855,59 @@
     }
 
     /**
+     * The ControlBeanContextProvider inner class acts as a single BeanContext service
+     * provider for the ControlBeanContext service class.  The implementation is simple,
+     * because the runtime ControlBeanContext implementation class directly implements
+     * this interface.
+     */
+    private static class ControlBeanContextProvider implements BeanContextServiceProvider
+    {
+        //
+        // BeanContextServiceProvider.getService()
+        //
+        public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass,
+                                 Object serviceSelector)
+        {
+            //
+            // Contextual services for a ControlBean is provided by the peer context
+            // instance.
+            //
+            if (requestor instanceof ControlBean)
+                return ((ControlBean)requestor).getControlBeanContext();
+
+            return null;
+        }
+
+        //
+        // BeanContextServiceProvider.releaseService()
+        //
+        public void releaseService(BeanContextServices bcs, Object requestor, Object service)
+        {
+            // noop, because context exists whether referenced or not
+        }
+
+        //
+        // BeanContextServiceProvider.getContextServiceSelectors()
+        //
+        public Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass)
+        {
+            return null;    // no selectors
+        }
+    }
+
+    /**
+     * A singleton instance of the ControlBeanContextProvider class is that will be registered
+     * on all ControlBeanContext instances.  The provider can be a singleton because it is
+     * completely stateless and thread-safe.
+     */
+    private static ControlBeanContextProvider theProvider = new ControlBeanContextProvider();
+
+    /**
+     * List that keeps track of the interceptors in their priority order.
+     */
+    private static ArrayList<String> _interceptorPriorities;
+
+    /**
      * The ControlBean instance that this context is providing services for.  This value can
      * be null, if the context instance is associated with top-level (non-control) context.
      */
@@ -930,8 +925,7 @@
      * to synchronize add/remove, since setBeanContext on the child is inside this lock scope,
      * but gets on the map are another story.
      */
-    private Map<String,Object> _childMap = 
-                Collections.synchronizedMap(new HashMap<String,Object>());
+    private Map<String,Object> _childMap = Collections.synchronizedMap(new HashMap<String,Object>());
 
     /**
      * Maintains a set of NameGenerators (for control ID generation) keyed by a
@@ -943,14 +937,12 @@
     /**
      * Maintains the list of lifecycle event listeners (if any) for this context.
      */
-    transient private Vector<LifeCycle> _lifeCycleListeners;
+    private transient Vector<LifeCycle> _lifeCycleListeners;
 
     /**
      * Caches the full composite control ID, that includes the entire path from the root
      * ContainerContext to the associated bean.  This value can be transient, since it
      * can be easily recomputed when needed.
      */
-    transient private String _controlID;
-
-    private static ArrayList<String> _interceptorPriorities;
+    private transient String _controlID;
 }

Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/servlet/ServletBeanContext.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/servlet/ServletBeanContext.java?rev=392066&r1=392065&r2=392066&view=diff
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/servlet/ServletBeanContext.java (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/servlet/ServletBeanContext.java Thu Apr  6 13:49:19 2006
@@ -227,8 +227,10 @@
         return null;
     }
 
-    protected boolean useWrappers() { return _useWrappers; }
+    protected boolean useWrappers() {
+        return _useWrappers;
+    }
 
     private boolean _useWrappers = true;
-    transient private Stack<RequestContext> _reqStack;
+    private transient Stack<RequestContext> _reqStack;
 }