You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2009/05/02 14:07:48 UTC

svn commit: r770942 - /incubator/click/trunk/click/framework/src/org/apache/click/ControlRegistry.java

Author: sabob
Date: Sat May  2 12:07:48 2009
New Revision: 770942

URL: http://svn.apache.org/viewvc?rev=770942&view=rev
Log:
promote ControlRegistry methods to protected for easier extending

Modified:
    incubator/click/trunk/click/framework/src/org/apache/click/ControlRegistry.java

Modified: incubator/click/trunk/click/framework/src/org/apache/click/ControlRegistry.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/ControlRegistry.java?rev=770942&r1=770941&r2=770942&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/ControlRegistry.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/ControlRegistry.java Sat May  2 12:07:48 2009
@@ -182,7 +182,26 @@
         eventHolder.registerActionEvent(source, listener);
     }
 
-    // ------------------------------------------------ Package Private Methods
+    // ------------------------------------------------------ Protected Methods
+
+    /**
+     * Clear the registry.
+     */
+    protected void clearRegistry() {
+        getPostProcessEventHolder().clear();
+        getPostRenderEventHolder().clear();
+    }
+
+    /**
+     * Return the thread local registry instance.
+     *
+     * @return the thread local registry instance.
+     * @throws RuntimeException if a ControlRegistry is not available on the
+     * thread.
+     */
+    protected static ControlRegistry getThreadLocalRegistry() {
+        return getRegistryStack().peek();
+    }
 
     /**
      * Fire the actions for the given listener list and event source list which
@@ -202,7 +221,7 @@
      *
      * @return true if the page should continue processing or false otherwise
      */
-    boolean fireActionEvents(Context context, List eventSourceList,
+    protected boolean fireActionEvents(Context context, List eventSourceList,
         List eventListenerList) {
 
         boolean continueProcessing = true;
@@ -229,7 +248,7 @@
      *
      * @return true if the page should continue processing or false otherwise
      */
-    boolean fireActionEvents(Context context) {
+    protected boolean fireActionEvents(Context context) {
         return fireActionEvents(context, ControlRegistry.POST_ON_PROCESS_EVENT);
     }
 
@@ -242,7 +261,7 @@
      *
      * @return true if the page should continue processing or false otherwise
      */
-    boolean fireActionEvents(Context context, int event) {
+    protected boolean fireActionEvents(Context context, int event) {
         EventHolder eventHolder = getEventHolder(event);
         return eventHolder.fireActionEvents(context);
     }
@@ -254,7 +273,7 @@
      *
      * @return the EventHolder for the specified event
      */
-    EventHolder getEventHolder(int event) {
+    protected EventHolder getEventHolder(int event) {
         if (event == POST_ON_RENDER_EVENT) {
             return getPostRenderEventHolder();
         } else if (event == POST_ON_PROCESS_EVENT) {
@@ -264,6 +283,8 @@
         }
     }
 
+    // ------------------------------------------------ Package Private Methods
+
     /**
      * Return the {@link #POST_ON_PROCESS_EVENT} {@link EventHolder}.
      *
@@ -289,25 +310,6 @@
     }
 
     /**
-     * Clear the registry.
-     */
-    void clearRegistry() {
-        getPostProcessEventHolder().clear();
-        getPostRenderEventHolder().clear();
-    }
-
-    /**
-     * Return the thread local registry instance.
-     *
-     * @return the thread local registry instance.
-     * @throws RuntimeException if a ControlRegistry is not available on the
-     * thread.
-     */
-    static ControlRegistry getThreadLocalRegistry() {
-        return getRegistryStack().peek();
-    }
-
-    /**
      * Adds the specified ControlRegistry on top of the Registry stack.
      *
      * @param controlRegistry the ControlRegistry to add
@@ -352,69 +354,9 @@
     // ---------------------------------------------------------- Inner Classes
 
     /**
-     * Provides an unsynchronized Stack.
-     */
-    static class RegistryStack extends ArrayList {
-
-        /** Serialization version indicator. */
-        private static final long serialVersionUID = 1L;
-
-        /**
-         * Create a new RegistryStack with the given initial capacity.
-         *
-         * @param initialCapacity specify initial capacity of this stack
-         */
-        private RegistryStack(int initialCapacity) {
-            super(initialCapacity);
-        }
-
-        /**
-         * Pushes the ControlRegistry onto the top of this stack.
-         *
-         * @param controlRegistry the ControlRegistry to push onto this stack
-         * @return the ControlRegistry pushed on this stack
-         */
-        private ControlRegistry push(ControlRegistry controlRegistry) {
-            add(controlRegistry);
-
-            return controlRegistry;
-        }
-
-        /**
-         * Removes and return the ControlRegistry at the top of this stack.
-         *
-         * @return the ControlRegistry at the top of this stack
-         */
-        private ControlRegistry pop() {
-            ControlRegistry controlRegistry = peek();
-
-            remove(size() - 1);
-
-            return controlRegistry;
-        }
-
-        /**
-         * Looks at the ControlRegistry at the top of this stack without
-         * removing it.
-         *
-         * @return the ControlRegistry at the top of this stack
-         */
-        private ControlRegistry peek() {
-            int length = size();
-
-            if (length == 0) {
-                String msg = "No ControlRegistry available on ThreadLocal Registry Stack";
-                throw new RuntimeException(msg);
-            }
-
-            return (ControlRegistry) get(length - 1);
-        }
-    }
-
-    /**
      * Holds the list of listeners and event sources.
      */
-    class EventHolder {
+    public class EventHolder {
 
         /** The list of registered event sources. */
         private List eventSourceList;
@@ -430,7 +372,7 @@
          * @param listener the event action listener
          * @param event the specific event to trigger the action event
          */
-        void registerActionEvent(Control source, ActionListener listener) {
+        public void registerActionEvent(Control source, ActionListener listener) {
             Validate.notNull(source, "Null source parameter");
             Validate.notNull(listener, "Null listener parameter");
 
@@ -441,7 +383,7 @@
         /**
          * Checks if any Action Events have been registered.
          */
-        boolean hasActionEvents() {
+        public boolean hasActionEvents() {
             if (eventListenerList == null || eventListenerList.isEmpty()) {
                 return false;
             }
@@ -453,7 +395,7 @@
          *
          * @return list of event listeners
          */
-        List getEventListenerList() {
+        public List getEventListenerList() {
             if (eventListenerList == null) {
                 eventListenerList = new ArrayList();
             }
@@ -465,7 +407,7 @@
          *
          * @return list of event sources
          */
-        List getEventSourceList() {
+        public List getEventSourceList() {
             if (eventSourceList == null) {
                 eventSourceList = new ArrayList();
             }
@@ -475,7 +417,7 @@
         /**
          * Clear the events.
          */
-        void clear() {
+        public void clear() {
             if (hasActionEvents()) {
                 getEventSourceList().clear();
                 getEventListenerList().clear();
@@ -488,7 +430,7 @@
          *
          * @return true if the page should continue processing or false otherwise
          */
-        boolean fireActionEvents(Context context) {
+        public boolean fireActionEvents(Context context) {
 
             if (!hasActionEvents()) {
                 return true;
@@ -498,4 +440,64 @@
                 getEventSourceList(), getEventListenerList());
         }
     }
+
+    /**
+     * Provides an unsynchronized Stack.
+     */
+    static class RegistryStack extends ArrayList {
+
+        /** Serialization version indicator. */
+        private static final long serialVersionUID = 1L;
+
+        /**
+         * Create a new RegistryStack with the given initial capacity.
+         *
+         * @param initialCapacity specify initial capacity of this stack
+         */
+        private RegistryStack(int initialCapacity) {
+            super(initialCapacity);
+        }
+
+        /**
+         * Pushes the ControlRegistry onto the top of this stack.
+         *
+         * @param controlRegistry the ControlRegistry to push onto this stack
+         * @return the ControlRegistry pushed on this stack
+         */
+        private ControlRegistry push(ControlRegistry controlRegistry) {
+            add(controlRegistry);
+
+            return controlRegistry;
+        }
+
+        /**
+         * Removes and return the ControlRegistry at the top of this stack.
+         *
+         * @return the ControlRegistry at the top of this stack
+         */
+        private ControlRegistry pop() {
+            ControlRegistry controlRegistry = peek();
+
+            remove(size() - 1);
+
+            return controlRegistry;
+        }
+
+        /**
+         * Looks at the ControlRegistry at the top of this stack without
+         * removing it.
+         *
+         * @return the ControlRegistry at the top of this stack
+         */
+        private ControlRegistry peek() {
+            int length = size();
+
+            if (length == 0) {
+                String msg = "No ControlRegistry available on ThreadLocal Registry Stack";
+                throw new RuntimeException(msg);
+            }
+
+            return (ControlRegistry) get(length - 1);
+        }
+    }
 }