Author: ivaynberg
Date: Fri Oct 22 03:27:25 2010
New Revision: 1026203

URL: http://svn.apache.org/viewvc?rev=1026203&view=rev
Log:
further listener collection cleanup

Added:
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentInitializationListenerCollection.java
   (with props)
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentInstantiationListenerCollection.java
   (with props)
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentOnAfterRenderListenerCollection.java
   (with props)
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentOnBeforeRenderListenerCollection.java
   (with props)
Modified:
    
wicket/trunk/wicket-devutils/src/test/java/org/apache/wicket/devutils/stateless/StatelessCheckerTest.java
    
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/guice/GuiceApplication.java
    
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/spring/common/web/ExampleApplication.java
    
wicket/trunk/wicket-guice/src/main/java/org/apache/wicket/guice/GuiceWebApplicationFactory.java
    
wicket/trunk/wicket-guice/src/test/java/org/apache/wicket/guice/GuiceInjectorTest.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/ComponentInitializationTest.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/request/cycle/RequestCycleListenerTest.java

Modified: 
wicket/trunk/wicket-devutils/src/test/java/org/apache/wicket/devutils/stateless/StatelessCheckerTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-devutils/src/test/java/org/apache/wicket/devutils/stateless/StatelessCheckerTest.java?rev=1026203&r1=1026202&r2=1026203&view=diff
==============================================================================
--- 
wicket/trunk/wicket-devutils/src/test/java/org/apache/wicket/devutils/stateless/StatelessCheckerTest.java
 (original)
+++ 
wicket/trunk/wicket-devutils/src/test/java/org/apache/wicket/devutils/stateless/StatelessCheckerTest.java
 Fri Oct 22 03:27:25 2010
@@ -78,7 +78,7 @@ public class StatelessCheckerTest extend
                boolean hit = false;
                try
                {
-                       
tester.getApplication().addPostComponentOnBeforeRenderListener(checker);
+                       
tester.getApplication().getComponentPostOnBeforeRenderListeners().add(checker);
                        tester.startPage(StatelessPage.class);
                }
                catch (IllegalArgumentException ex)
@@ -93,7 +93,7 @@ public class StatelessCheckerTest extend
         */
        public void testPositive()
        {
-               
tester.getApplication().addPostComponentOnBeforeRenderListener(checker);
+               
tester.getApplication().getComponentPostOnBeforeRenderListeners().add(checker);
                tester.startComponent(new StatelessLabel("foo"));
        }
 }

Modified: 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/guice/GuiceApplication.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/guice/GuiceApplication.java?rev=1026203&r1=1026202&r2=1026203&view=diff
==============================================================================
--- 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/guice/GuiceApplication.java
 (original)
+++ 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/guice/GuiceApplication.java
 Fri Oct 22 03:27:25 2010
@@ -35,7 +35,7 @@ public class GuiceApplication extends Wi
        {
                super.init();
 
-               addComponentInstantiationListener(new 
GuiceComponentInjector(this));
+               getComponentInstantiationListeners().add(new 
GuiceComponentInjector(this));
        }
 
        /**

Modified: 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/spring/common/web/ExampleApplication.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/spring/common/web/ExampleApplication.java?rev=1026203&r1=1026202&r2=1026203&view=diff
==============================================================================
--- 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/spring/common/web/ExampleApplication.java
 (original)
+++ 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/spring/common/web/ExampleApplication.java
 Fri Oct 22 03:27:25 2010
@@ -48,7 +48,7 @@ public class ExampleApplication extends 
 
                // THIS LINE IS IMPORTANT - IT INSTALLS THE COMPONENT INJECTOR 
THAT WILL
                // INJECT NEWLY CREATED COMPONENTS WITH THEIR SPRING 
DEPENDENCIES
-               addComponentInstantiationListener(new 
SpringComponentInjector(this));
+               getComponentInstantiationListeners().add(new 
SpringComponentInjector(this));
        }
 
        @Override

Modified: 
wicket/trunk/wicket-guice/src/main/java/org/apache/wicket/guice/GuiceWebApplicationFactory.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-guice/src/main/java/org/apache/wicket/guice/GuiceWebApplicationFactory.java?rev=1026203&r1=1026202&r2=1026203&view=diff
==============================================================================
--- 
wicket/trunk/wicket-guice/src/main/java/org/apache/wicket/guice/GuiceWebApplicationFactory.java
 (original)
+++ 
wicket/trunk/wicket-guice/src/main/java/org/apache/wicket/guice/GuiceWebApplicationFactory.java
 Fri Oct 22 03:27:25 2010
@@ -98,15 +98,16 @@ public class GuiceWebApplicationFactory 
                Injector injector;
 
                String injectorContextAttribute = 
filter.getFilterConfig().getInitParameter(
-                               "injectorContextAttribute");
+                       "injectorContextAttribute");
 
                Stage stage = null;
 
                String stageContextAttribute = 
filter.getFilterConfig().getInitParameter(STAGE_PARAMETER);
                if (stageContextAttribute == null)
                {
-                       stageContextAttribute = 
filter.getFilterConfig().getServletContext().getInitParameter(
-                                       STAGE_PARAMETER);
+                       stageContextAttribute = filter.getFilterConfig()
+                               .getServletContext()
+                               .getInitParameter(STAGE_PARAMETER);
                }
                if (stageContextAttribute != null)
                {
@@ -123,8 +124,8 @@ public class GuiceWebApplicationFactory 
                        if (injector == null)
                        {
                                throw new RuntimeException(
-                                               "Could not find Guice Injector 
in the ServletContext under attribute: " +
-                                                               
injectorContextAttribute);
+                                       "Could not find Guice Injector in the 
ServletContext under attribute: " +
+                                               injectorContextAttribute);
                        }
                }
                else if (filter.getFilterConfig().getInitParameter("module") != 
null)
@@ -137,24 +138,24 @@ public class GuiceWebApplicationFactory 
                                String moduleName = moduleNames[i].trim();
                                try
                                {
-                                       Class< ? > moduleClazz = 
Class.forName(moduleName);
+                                       Class<?> moduleClazz = 
Class.forName(moduleName);
                                        Object moduleObject = 
moduleClazz.newInstance();
                                        modules[i] = (Module)moduleObject;
                                }
                                catch (InstantiationException e)
                                {
                                        throw new RuntimeException(
-                                                       "Could not create new 
instance of Guice Module class " + moduleName, e);
+                                               "Could not create new instance 
of Guice Module class " + moduleName, e);
                                }
                                catch (ClassNotFoundException e)
                                {
                                        throw new RuntimeException(
-                                                       "Could not create new 
instance of Guice Module class " + moduleName, e);
+                                               "Could not create new instance 
of Guice Module class " + moduleName, e);
                                }
                                catch (IllegalAccessException e)
                                {
                                        throw new RuntimeException(
-                                                       "Could not create new 
instance of Guice Module class " + moduleName, e);
+                                               "Could not create new instance 
of Guice Module class " + moduleName, e);
                                }
                        }
                        if (stage != null)
@@ -169,10 +170,10 @@ public class GuiceWebApplicationFactory 
                else
                {
                        throw new RuntimeException(
-                                       "To use GuiceWebApplicationFactory, you 
must specify either an 'injectorContextAttribute' or a 'module' init-param.");
+                               "To use GuiceWebApplicationFactory, you must 
specify either an 'injectorContextAttribute' or a 'module' init-param.");
                }
                WebApplication app = injector.getInstance(WebApplication.class);
-               app.addComponentInstantiationListener(new 
GuiceComponentInjector(app, injector));
+               app.getComponentInstantiationListeners().add(new 
GuiceComponentInjector(app, injector));
                return app;
        }
 

Modified: 
wicket/trunk/wicket-guice/src/test/java/org/apache/wicket/guice/GuiceInjectorTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-guice/src/test/java/org/apache/wicket/guice/GuiceInjectorTest.java?rev=1026203&r1=1026202&r2=1026203&view=diff
==============================================================================
--- 
wicket/trunk/wicket-guice/src/test/java/org/apache/wicket/guice/GuiceInjectorTest.java
 (original)
+++ 
wicket/trunk/wicket-guice/src/test/java/org/apache/wicket/guice/GuiceInjectorTest.java
 Fri Oct 22 03:27:25 2010
@@ -58,10 +58,12 @@ public class GuiceInjectorTest extends T
                                public void configure(Binder binder)
                                {
                                        
binder.bind(ITestService.class).to(TestService.class);
-                                       
binder.bind(ITestService.class).annotatedWith(Red.class).to(
-                                                       TestServiceRed.class);
-                                       
binder.bind(ITestService.class).annotatedWith(Blue.class).to(
-                                                       TestServiceBlue.class);
+                                       binder.bind(ITestService.class)
+                                               .annotatedWith(Red.class)
+                                               .to(TestServiceRed.class);
+                                       binder.bind(ITestService.class)
+                                               .annotatedWith(Blue.class)
+                                               .to(TestServiceBlue.class);
                                        binder.bind(new TypeLiteral<Map<String, 
String>>()
                                        {
                                        }).toProvider(new Provider<Map<String, 
String>>()
@@ -78,7 +80,7 @@ public class GuiceInjectorTest extends T
                                }
 
                        });
-                       app.addComponentInstantiationListener(injector);
+                       app.getComponentInstantiationListeners().add(injector);
 
                        // Create a new component, which should be 
automatically injected,
                        // and test to make sure the injection has worked.
@@ -115,7 +117,7 @@ public class GuiceInjectorTest extends T
 
                assertEquals(ITestService.RESULT, 
component.getInjectedFieldProvider().get().getString());
 
-               assertEquals(ITestService.RESULT, 
component.getInjectedTypeLiteralField().get(
-                               ITestService.RESULT));
+               assertEquals(ITestService.RESULT,
+                       
component.getInjectedTypeLiteralField().get(ITestService.RESULT));
        }
 }

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java?rev=1026203&r1=1026202&r2=1026203&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java 
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java Fri 
Oct 22 03:27:25 2010
@@ -28,12 +28,13 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
 
+import org.apache.wicket.application.ComponentInitializationListenerCollection;
+import org.apache.wicket.application.ComponentInstantiationListenerCollection;
+import org.apache.wicket.application.ComponentOnAfterRenderListenerCollection;
+import org.apache.wicket.application.ComponentOnBeforeRenderListenerCollection;
 import org.apache.wicket.application.IComponentInitializationListener;
 import org.apache.wicket.application.IComponentInstantiationListener;
-import org.apache.wicket.application.IComponentOnAfterRenderListener;
-import org.apache.wicket.application.IComponentOnBeforeRenderListener;
 import org.apache.wicket.event.IEvent;
 import org.apache.wicket.event.IEventSink;
 import org.apache.wicket.javascript.DefaultJavascriptCompressor;
@@ -164,13 +165,13 @@ public abstract class Application implem
        private static final Logger log = 
LoggerFactory.getLogger(Application.class);
 
        /** */
-       private List<IComponentOnBeforeRenderListener> 
componentPreOnBeforeRenderListeners;
+       private final ComponentOnBeforeRenderListenerCollection 
componentPreOnBeforeRenderListeners = new 
ComponentOnBeforeRenderListenerCollection();
 
        /** */
-       private List<IComponentOnBeforeRenderListener> 
componentPostOnBeforeRenderListeners;
+       private final ComponentOnBeforeRenderListenerCollection 
componentPostOnBeforeRenderListeners = new 
ComponentOnBeforeRenderListenerCollection();
 
        /** */
-       private List<IComponentOnAfterRenderListener> 
componentOnAfterRenderListeners;
+       private ComponentOnAfterRenderListenerCollection 
componentOnAfterRenderListeners = new 
ComponentOnAfterRenderListenerCollection();
 
        private final RequestCycleListenerCollection requestCycleListeners = 
new RequestCycleListenerCollection();
 
@@ -178,10 +179,10 @@ public abstract class Application implem
        private IRequestMapper rootRequestMapper;
 
        /** list of {...@link IComponentInstantiationListener}s. */
-       private IComponentInstantiationListener[] 
componentInstantiationListeners = new IComponentInstantiationListener[0];
+       private final ComponentInstantiationListenerCollection 
componentInstantiationListeners = new 
ComponentInstantiationListenerCollection();
 
        /** list of {...@link IComponentInitializationListener}s. */
-       private CopyOnWriteArrayList<IComponentInitializationListener> 
componentInitializationListeners = new 
CopyOnWriteArrayList<IComponentInitializationListener>();
+       private final ComponentInitializationListenerCollection 
componentInitializationListeners = new 
ComponentInitializationListenerCollection();
 
        /** The converter locator instance. */
        private IConverterLocator converterLocator;
@@ -279,7 +280,7 @@ public abstract class Application implem
        {
                // Install default component instantiation listener that uses
                // authorization strategy to check component instantiations.
-               addComponentInstantiationListener(new 
IComponentInstantiationListener()
+               getComponentInstantiationListeners().add(new 
IComponentInstantiationListener()
                {
                        /**
                         * @see 
org.apache.wicket.application.IComponentInstantiationListener#onInstantiation(org.apache.wicket.Component)
@@ -299,80 +300,15 @@ public abstract class Application implem
                });
        }
 
-       /**
-        * Adds a component instantiation listener. This method should 
typically only be called during
-        * application startup; it is not thread safe.
-        * <p>
-        * Note: wicket does not guarantee the execution order of added 
listeners
-        * 
-        * @param listener
-        *            the listener to add
-        */
-       public final void addComponentInstantiationListener(
-               final IComponentInstantiationListener listener)
-       {
-               if (listener == null)
-               {
-                       throw new IllegalArgumentException("argument listener 
may not be null");
-               }
 
-               // if an instance of this listener is already present ignore 
this call
-               for (IComponentInstantiationListener 
componentInstantiationListener : componentInstantiationListeners)
-               {
-                       if (listener == componentInstantiationListener)
-                       {
-                               return;
-                       }
-               }
-
-               final IComponentInstantiationListener[] newListeners = new 
IComponentInstantiationListener[componentInstantiationListeners.length + 1];
-               System.arraycopy(componentInstantiationListeners, 0, 
newListeners, 0,
-                       componentInstantiationListeners.length);
-               newListeners[componentInstantiationListeners.length] = listener;
-               componentInstantiationListeners = newListeners;
-       }
-
-       /**
-        * Adds a component initialization listener. This method should 
typically only be called during
-        * application startup; it is not thread safe.
-        * <p>
-        * Each added listener will be notified after Component's {...@link 
Component#onInitialize()}
-        * method has been executed.
-        * </p>
-        * <p>
-        * Note: wicket does not guarantee the execution order of added 
listeners
-        * 
-        * @param listener
-        *            the listener to add
-        */
-       public final void addComponentInitializationListener(
-               final IComponentInitializationListener listener)
+       public final ComponentInstantiationListenerCollection 
getComponentInstantiationListeners()
        {
-               if (listener == null)
-               {
-                       throw new IllegalArgumentException("argument listener 
may not be null");
-               }
-
-               if (componentInitializationListeners.contains(listener))
-               {
-                       return;
-               }
-               componentInitializationListeners.add(listener);
+               return componentInstantiationListeners;
        }
 
-       /**
-        * Fires registered {...@link IComponentInitializationListener}s on the 
component
-        * 
-        * @param component
-        * 
-        * @see 
#addComponentInitializationListener(IComponentInitializationListener)
-        */
-       public final void fireComponentInitializationListeners(Component 
component)
+       public final ComponentInitializationListenerCollection 
getComponentInitializationListeners()
        {
-               for (IComponentInitializationListener listener : 
componentInitializationListeners)
-               {
-                       listener.onInitialize(component);
-               }
+               return componentInitializationListeners;
        }
 
        /**
@@ -752,42 +688,6 @@ public abstract class Application implem
        public abstract Session newSession(Request request, Response response);
 
        /**
-        * Removes a component instantiation listener. This method should 
typically only be called
-        * during application startup; it is not thread safe.
-        * 
-        * @param listener
-        *            the listener to remove
-        */
-       public final void removeComponentInstantiationListener(
-               final IComponentInstantiationListener listener)
-       {
-               final IComponentInstantiationListener[] listeners = 
componentInstantiationListeners;
-               final int len = listeners.length;
-
-               if (listener != null && len > 0)
-               {
-                       int pos;
-
-                       for (pos = 0; pos < len; pos++)
-                       {
-                               if (listener == listeners[pos])
-                               {
-                                       break;
-                               }
-                       }
-
-                       if (pos < len)
-                       {
-                               listeners[pos] = listeners[len - 1];
-                               final IComponentInstantiationListener[] 
newListeners = new IComponentInstantiationListener[len - 1];
-                               System.arraycopy(listeners, 0, newListeners, 0, 
newListeners.length);
-
-                               componentInstantiationListeners = newListeners;
-                       }
-               }
-       }
-
-       /**
         * Sets the metadata for this application using the given key. If the 
metadata object is not of
         * the correct type for the metadata key, an IllegalArgumentException 
will be thrown. For
         * information on creating MetaDataKeys, see {...@link MetaDataKey}.
@@ -1010,158 +910,22 @@ public abstract class Application implem
                return new DummyRequestLogger();
        }
 
-       /**
-        * Notifies the registered component instantiation listeners of the 
construction of the provided
-        * component
-        * 
-        * @param component
-        *            the component that is being instantiated
-        */
-       final void notifyComponentInstantiationListeners(final Component 
component)
-       {
-               final int len = componentInstantiationListeners.length;
-               for (int i = 0; i < len; i++)
-               {
-                       
componentInstantiationListeners[i].onInstantiation(component);
-               }
-       }
-
-       /**
-        * Adds an {...@link IComponentOnBeforeRenderListener}. This method 
should typically only be called
-        * during application startup; it is not thread safe.
-        * 
-        * @param listener
-        */
-       final public void addPreComponentOnBeforeRenderListener(
-               final IComponentOnBeforeRenderListener listener)
-       {
-               if (componentPreOnBeforeRenderListeners == null)
-               {
-                       componentPreOnBeforeRenderListeners = new 
ArrayList<IComponentOnBeforeRenderListener>();
-               }
-
-               if (componentPreOnBeforeRenderListeners.contains(listener) == 
false)
-               {
-                       componentPreOnBeforeRenderListeners.add(listener);
-               }
-       }
-
-       /**
-        * Removes an {...@link IComponentOnBeforeRenderListener}.
-        * 
-        * @param listener
-        */
-       final public void removePreComponentOnBeforeRenderListener(
-               final IComponentOnBeforeRenderListener listener)
-       {
-               if (componentPreOnBeforeRenderListeners != null)
-               {
-                       componentPreOnBeforeRenderListeners.remove(listener);
-                       if (componentPreOnBeforeRenderListeners.isEmpty())
-                       {
-                               componentPreOnBeforeRenderListeners = null;
-                       }
-               }
-       }
-
-       /**
-        * Notifies the {...@link IComponentOnBeforeRenderListener}s.
-        * 
-        * @param component
-        */
-       final void notifyPreComponentOnBeforeRenderListeners(final Component 
component)
+       public final ComponentOnBeforeRenderListenerCollection 
getComponentPreOnBeforeRenderListeners()
        {
-               if (componentPreOnBeforeRenderListeners != null)
-               {
-                       for (IComponentOnBeforeRenderListener listener : 
componentPreOnBeforeRenderListeners)
-                       {
-                               listener.onBeforeRender(component);
-                       }
-               }
+               return componentPreOnBeforeRenderListeners;
        }
 
-       /**
-        * Adds an {...@link IComponentOnBeforeRenderListener}. This method 
should typically only be called
-        * during application startup; it is not thread safe.
-        * 
-        * @param listener
-        */
-       final public void addPostComponentOnBeforeRenderListener(
-               final IComponentOnBeforeRenderListener listener)
+       public final ComponentOnBeforeRenderListenerCollection 
getComponentPostOnBeforeRenderListeners()
        {
-               if (componentPostOnBeforeRenderListeners == null)
-               {
-                       componentPostOnBeforeRenderListeners = new 
ArrayList<IComponentOnBeforeRenderListener>();
-               }
-
-               if (componentPostOnBeforeRenderListeners.contains(listener) == 
false)
-               {
-                       componentPostOnBeforeRenderListeners.add(listener);
-               }
-       }
-
-       /**
-        * Removes an {...@link IComponentOnBeforeRenderListener}.
-        * 
-        * @param listener
-        */
-       final public void removePostComponentOnBeforeRenderListener(
-               final IComponentOnBeforeRenderListener listener)
-       {
-               if (componentPostOnBeforeRenderListeners != null)
-               {
-                       componentPostOnBeforeRenderListeners.remove(listener);
-                       if (componentPostOnBeforeRenderListeners.isEmpty())
-                       {
-                               componentPostOnBeforeRenderListeners = null;
-                       }
-               }
+               return componentPostOnBeforeRenderListeners;
        }
 
        /**
-        * Notifies the {...@link IComponentOnBeforeRenderListener}s.
-        * 
-        * @param component
+        * @return on after render listeners collection
         */
-       final void notifyPostComponentOnBeforeRenderListeners(final Component 
component)
+       public final ComponentOnAfterRenderListenerCollection 
getComponentOnAfterRenderListeners()
        {
-               if (componentPostOnBeforeRenderListeners != null)
-               {
-                       for (IComponentOnBeforeRenderListener listener : 
componentPostOnBeforeRenderListeners)
-                       {
-                               listener.onBeforeRender(component);
-                       }
-               }
-       }
-
-       /**
-        * Adds an {...@link IComponentOnAfterRenderListener}. This method 
should typically only be called
-        * during application startup; it is not thread safe.
-        * 
-        * @param listener
-        */
-       final public void addComponentOnAfterRenderListener(
-               final IComponentOnAfterRenderListener listener)
-       {
-               if (componentOnAfterRenderListeners == null)
-               {
-                       componentOnAfterRenderListeners = new 
ArrayList<IComponentOnAfterRenderListener>();
-               }
-
-               if (componentOnAfterRenderListeners.contains(listener) == false)
-               {
-                       componentOnAfterRenderListeners.add(listener);
-               }
-       }
-
-       /**
-        * Registers a listener to extend functionality in the {...@link 
RequestCycle}.
-        * 
-        * @param listener
-        */
-       public void addRequestCycleListener(IRequestCycleListener listener)
-       {
-               requestCycleListeners.add(listener);
+               return componentOnAfterRenderListeners;
        }
 
        /**
@@ -1172,41 +936,6 @@ public abstract class Application implem
                return requestCycleListeners;
        }
 
-
-       /**
-        * Removes an {...@link IComponentOnAfterRenderListener}.
-        * 
-        * @param listener
-        */
-       final public void removeComponentOnAfterRenderListener(
-               final IComponentOnAfterRenderListener listener)
-       {
-               if (componentOnAfterRenderListeners != null)
-               {
-                       componentOnAfterRenderListeners.remove(listener);
-                       if (componentOnAfterRenderListeners.isEmpty())
-                       {
-                               componentOnAfterRenderListeners = null;
-                       }
-               }
-       }
-
-       /**
-        * Notifies the {...@link IComponentOnAfterRenderListener}s.
-        * 
-        * @param component
-        */
-       final void notifyComponentOnAfterRenderListeners(final Component 
component)
-       {
-               if (componentOnAfterRenderListeners != null)
-               {
-                       for (IComponentOnAfterRenderListener listener : 
componentOnAfterRenderListeners)
-                       {
-                               listener.onAfterRender(component);
-                       }
-               }
-       }
-
        /**
         * Converts the root mapper to a {...@link ICompoundRequestMapper} if 
necessary and returns the
         * converted instance.
@@ -1498,6 +1227,7 @@ public abstract class Application implem
                requestCycle.getListeners().add(requestCycleListeners);
                requestCycle.getListeners().add(new 
AbstractRequestCycleListener()
                {
+                       @Override
                        public void onDetach(RequestCycle requestCycle)
                        {
                                getPageManager().commitRequest();

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java?rev=1026203&r1=1026202&r2=1026203&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java 
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java Fri Oct 
22 03:27:25 2010
@@ -693,7 +693,7 @@ public abstract class Component
        public Component(final String id, final IModel<?> model)
        {
                setId(id);
-               getApplication().notifyComponentInstantiationListeners(this);
+               
getApplication().getComponentInstantiationListeners().onInstantiation(this);
 
                final IDebugSettings debugSettings = 
Application.get().getDebugSettings();
                if (debugSettings.isLinePreciseReportingOnNewComponentEnabled())
@@ -1019,7 +1019,7 @@ public abstract class Component
                        }
                        setFlag(FLAG_INITIALIZE_SUPER_CALL_VERIFIED, false);
 
-                       
getApplication().fireComponentInitializationListeners(this);
+                       
getApplication().getComponentInitializationListeners().onInitialize(this);
                }
        }
 
@@ -1117,7 +1117,7 @@ public abstract class Component
                {
                        setFlag(FLAG_AFTER_RENDERING, true);
                        onAfterRender();
-                       
getApplication().notifyComponentOnAfterRenderListeners(this);
+                       
getApplication().getComponentOnAfterRenderListeners().onAfterRender(this);
                        if (getFlag(FLAG_AFTER_RENDERING))
                        {
                                throw new 
IllegalStateException(Component.class.getName() +
@@ -1148,14 +1148,14 @@ public abstract class Component
                {
                        setFlag(FLAG_BEFORE_RENDER_SUPER_CALL_VERIFIED, false);
 
-                       
getApplication().notifyPreComponentOnBeforeRenderListeners(this);
+                       
getApplication().getComponentPreOnBeforeRenderListeners().onBeforeRender(this);
 
                        // clear the enabled in hierarchy cache as it may 
change as a result of form processing
                        // or other logic executed in onbeforerender 
(WICKET-2063)
                        clearEnabledInHierarchyCache();
 
                        onBeforeRender();
-                       
getApplication().notifyPostComponentOnBeforeRenderListeners(this);
+                       
getApplication().getComponentPostOnBeforeRenderListeners().onBeforeRender(this);
 
                        if (!getFlag(FLAG_BEFORE_RENDER_SUPER_CALL_VERIFIED))
                        {

Added: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentInitializationListenerCollection.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentInitializationListenerCollection.java?rev=1026203&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentInitializationListenerCollection.java
 (added)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentInitializationListenerCollection.java
 Fri Oct 22 03:27:25 2010
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.wicket.application;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.util.listener.ListenerCollection;
+
+public class ComponentInitializationListenerCollection extends
+       ListenerCollection<IComponentInitializationListener>
+       implements
+               IComponentInitializationListener
+{
+       public void onInitialize(final Component component)
+       {
+               notify(new INotifier<IComponentInitializationListener>()
+               {
+                       public void notify(IComponentInitializationListener 
listener)
+                       {
+                               listener.onInitialize(component);
+                       }
+               });
+       }
+}

Propchange: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentInitializationListenerCollection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentInstantiationListenerCollection.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentInstantiationListenerCollection.java?rev=1026203&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentInstantiationListenerCollection.java
 (added)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentInstantiationListenerCollection.java
 Fri Oct 22 03:27:25 2010
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.wicket.application;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.util.listener.ListenerCollection;
+
+public class ComponentInstantiationListenerCollection extends
+       ListenerCollection<IComponentInstantiationListener> implements 
IComponentInstantiationListener
+{
+       public void onInstantiation(final Component component)
+       {
+               notify(new INotifier<IComponentInstantiationListener>()
+               {
+                       public void notify(IComponentInstantiationListener 
listener)
+                       {
+                               listener.onInstantiation(component);
+                       }
+               });
+       }
+}

Propchange: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentInstantiationListenerCollection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentOnAfterRenderListenerCollection.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentOnAfterRenderListenerCollection.java?rev=1026203&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentOnAfterRenderListenerCollection.java
 (added)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentOnAfterRenderListenerCollection.java
 Fri Oct 22 03:27:25 2010
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.wicket.application;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.util.listener.ListenerCollection;
+
+public class ComponentOnAfterRenderListenerCollection extends
+       ListenerCollection<IComponentOnAfterRenderListener> implements 
IComponentOnAfterRenderListener
+{
+       public void onAfterRender(final Component component)
+       {
+               notify(new INotifier<IComponentOnAfterRenderListener>()
+               {
+                       public void notify(IComponentOnAfterRenderListener 
listener)
+                       {
+                               listener.onAfterRender(component);
+                       }
+               });
+       }
+
+}

Propchange: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentOnAfterRenderListenerCollection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentOnBeforeRenderListenerCollection.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentOnBeforeRenderListenerCollection.java?rev=1026203&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentOnBeforeRenderListenerCollection.java
 (added)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentOnBeforeRenderListenerCollection.java
 Fri Oct 22 03:27:25 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.wicket.application;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.util.listener.ListenerCollection;
+
+public class ComponentOnBeforeRenderListenerCollection extends
+       ListenerCollection<IComponentOnBeforeRenderListener>
+       implements
+               IComponentOnBeforeRenderListener
+{
+       public void onBeforeRender(final Component component)
+       {
+               notify(new INotifier<IComponentOnBeforeRenderListener>()
+               {
+                       public void notify(IComponentOnBeforeRenderListener 
listener)
+                       {
+                               listener.onBeforeRender(component);
+                       }
+               });
+       }
+
+}

Propchange: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ComponentOnBeforeRenderListenerCollection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java?rev=1026203&r1=1026202&r2=1026203&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
 Fri Oct 22 03:27:25 2010
@@ -30,8 +30,8 @@ import org.apache.wicket.markup.html.for
 import org.apache.wicket.markup.html.form.IFormSubmittingComponent;
 import org.apache.wicket.markup.parser.filter.EnclosureHandler;
 import org.apache.wicket.markup.resolver.ComponentResolvers;
-import org.apache.wicket.markup.resolver.IComponentResolver;
 import org.apache.wicket.markup.resolver.ComponentResolvers.ResolverFilter;
+import org.apache.wicket.markup.resolver.IComponentResolver;
 import org.apache.wicket.request.Response;
 import org.apache.wicket.request.cycle.RequestCycle;
 import org.apache.wicket.response.NullResponse;
@@ -173,7 +173,7 @@ public class Enclosure extends WebMarkup
                try
                {
                        // register the listener
-                       
getApplication().addComponentOnAfterRenderListener(listener);
+                       
getApplication().getComponentOnAfterRenderListeners().add(listener);
 
                        if (visible)
                        {
@@ -198,7 +198,7 @@ public class Enclosure extends WebMarkup
                finally
                {
                        // make sure we remove the listener
-                       
getApplication().removeComponentOnAfterRenderListener(listener);
+                       
getApplication().getComponentOnAfterRenderListeners().remove(listener);
                }
        }
 

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ComponentInitializationTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/ComponentInitializationTest.java?rev=1026203&r1=1026202&r2=1026203&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ComponentInitializationTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/ComponentInitializationTest.java
 Fri Oct 22 03:27:25 2010
@@ -134,8 +134,8 @@ public class ComponentInitializationTest
        {
                TestInitListener listener1 = new TestInitListener();
                TestInitListener listener2 = new TestInitListener();
-               
tester.getApplication().addComponentInitializationListener(listener1);
-               
tester.getApplication().addComponentInitializationListener(listener2);
+               
tester.getApplication().getComponentInitializationListeners().add(listener1);
+               
tester.getApplication().getComponentInitializationListeners().add(listener2);
 
                WebPage page = new WebPage()
                {
@@ -157,7 +157,7 @@ public class ComponentInitializationTest
        public void testInitializationOrder()
        {
                TestInitListener listener1 = new TestInitListener();
-               
tester.getApplication().addComponentInitializationListener(listener1);
+               
tester.getApplication().getComponentInitializationListeners().add(listener1);
 
                WebPage page = new WebPage()
                {

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/request/cycle/RequestCycleListenerTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/request/cycle/RequestCycleListenerTest.java?rev=1026203&r1=1026202&r2=1026203&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/request/cycle/RequestCycleListenerTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/request/cycle/RequestCycleListenerTest.java
 Fri Oct 22 03:27:25 2010
@@ -110,7 +110,7 @@ public class RequestCycleListenerTest ex
         */
        public void testBasicOperations() throws Exception
        {
-               Application.get().addRequestCycleListener(new 
IncrementingListener());
+               Application.get().getRequestCycleListeners().add(new 
IncrementingListener());
 
                RequestCycle cycle = newRequestCycle(false);
 


Reply via email to