Updated Branches:
  refs/heads/wicket-1.5.x ec53d1b75 -> b01790689

WICKET-4212: Add ISessionStore BindListener


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/b0179068
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/b0179068
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/b0179068

Branch: refs/heads/wicket-1.5.x
Commit: b01790689f54327ba755e5250dfe7d15c8059c06
Parents: eb86ba3
Author: Emond Papegaaij <[email protected]>
Authored: Wed Nov 9 15:31:56 2011 +0100
Committer: Emond Papegaaij <[email protected]>
Committed: Wed Jan 4 17:56:13 2012 +0100

----------------------------------------------------------------------
 .../apache/wicket/session/HttpSessionStore.java    |   34 +++++++++++++
 .../org/apache/wicket/session/ISessionStore.java   |   38 +++++++++++++++
 2 files changed, 72 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/b0179068/wicket-core/src/main/java/org/apache/wicket/session/HttpSessionStore.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/session/HttpSessionStore.java 
b/wicket-core/src/main/java/org/apache/wicket/session/HttpSessionStore.java
index 68e2a1a..07d3e6d 100644
--- a/wicket-core/src/main/java/org/apache/wicket/session/HttpSessionStore.java
+++ b/wicket-core/src/main/java/org/apache/wicket/session/HttpSessionStore.java
@@ -55,6 +55,8 @@ public class HttpSessionStore implements ISessionStore
        /** */
        private final Set<UnboundListener> unboundListeners = new 
CopyOnWriteArraySet<UnboundListener>();
 
+       private final Set<BindListener> bindListeners = new 
CopyOnWriteArraySet<BindListener>();
+
        /**
         * Construct.
         */
@@ -102,6 +104,10 @@ public class HttpSessionStore implements ISessionStore
                {
                        // call template method
                        onBind(request, newSession);
+                       for (BindListener listener : getBindListeners())
+                       {
+                               listener.bindingSession(request, newSession);
+                       }
 
                        HttpSession httpSession = getHttpSession(request, 
false);
 
@@ -354,6 +360,34 @@ public class HttpSessionStore implements ISessionStore
        }
 
        /**
+        * Registers listener invoked when session is bound.
+        * 
+        * @param listener
+        */
+       public void registerBindListener(BindListener listener)
+       {
+               bindListeners.add(listener);
+       }
+
+       /**
+        * Unregisters listener invoked when session is bound.
+        * 
+        * @param listener
+        */
+       public void unregisterBindListener(BindListener listener)
+       {
+               bindListeners.remove(listener);
+       }
+
+       /**
+        * @return The list of registered bind listeners
+        */
+       public Set<BindListener> getBindListeners()
+       {
+               return Collections.unmodifiableSet(bindListeners);
+       }
+
+       /**
         * Reacts on unbinding from the session by cleaning up the session 
related data.
         */
        protected static final class SessionBindingListener

http://git-wip-us.apache.org/repos/asf/wicket/blob/b0179068/wicket-core/src/main/java/org/apache/wicket/session/ISessionStore.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/session/ISessionStore.java 
b/wicket-core/src/main/java/org/apache/wicket/session/ISessionStore.java
index f4894d7..ead4444 100644
--- a/wicket-core/src/main/java/org/apache/wicket/session/ISessionStore.java
+++ b/wicket-core/src/main/java/org/apache/wicket/session/ISessionStore.java
@@ -180,4 +180,42 @@ public interface ISessionStore
         * @return The list of registered unbound listeners
         */
        Set<UnboundListener> getUnboundListener();
+
+       /**
+        * Listener invoked when session is bound.
+        */
+       public interface BindListener
+       {
+               /**
+                * Informs the listener that a session is about to be bound. 
Note that this method is also
+                * called for {@link Session#isTemporary() temporary sessions}.
+                * 
+                * @param request
+                *            The request the session is bound in
+                * @param newSession
+                *            The session that will be bound
+                */
+               void bindingSession(Request request, Session newSession);
+       }
+
+       // TODO Wicket.next add these methods to the interface
+       /**
+        * Registers listener invoked when session is bound.
+        * 
+        * @param listener
+        */
+       // void registerBindListener(BindListener listener);
+
+       /**
+        * Unregisters listener invoked when session is bound.
+        * 
+        * @param listener
+        */
+       // void unregisterBindListener(BindListener listener);
+
+       /**
+        * @return The list of registered bind listeners
+        */
+       // Set<BindListener> getBindListener();
+
 }

Reply via email to