You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by pa...@apache.org on 2012/01/04 19:55:20 UTC
[1/2] git commit: WICKET-4212: Add ISessionStore BindListener
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 <pa...@apache.org>
Authored: Wed Nov 9 15:31:56 2011 +0100
Committer: Emond Papegaaij <pa...@apache.org>
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();
+
}
Re: [1/2] git commit: WICKET-4212: Add ISessionStore BindListener
Posted by Martin Grigorov <mg...@apache.org>.
Hi Emond,
The names of the methods in that code is a bit misleading already... :-/
HttpSessionStore#bind() actually does nothing but calling HSS#onBind()
which has no specialized implementations in Wicket core code.
I.e. the new BindListener is similar to #onBind(). Both of them notify
when a new Wicket Session is created.
The actual binding of the HttpSession is in
org.apache.wicket.session.HttpSessionStore#getSessionId(Request, true)
UnboudListener listens for unbinding of HttpSession ...
On Thu, Jan 5, 2012 at 10:47 AM, Emond Papegaaij
<em...@gmail.com> wrote:
> About the name: the BindListener is called before the session is actually
> bound, it is called from the bind method, just after onBind. The
> UnboundListener is called after is session is unbound, from the valueUnbound
> method. I think the name is correct as it is.
>
> About the commented methods: I actually forgot about them :) They do serve a
> purpose though, as people can see these methods will be added (are already
> added) to wicket 6. Shall I remove them?
>
> Emond
>
>
> On Thu, Jan 5, 2012 at 8:42 AM, Martin Grigorov <mg...@apache.org>
> wrote:
>>
>> On Wed, Jan 4, 2012 at 8:55 PM, <pa...@apache.org> wrote:
>> > 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 <pa...@apache.org>
>> > Authored: Wed Nov 9 15:31:56 2011 +0100
>> > Committer: Emond Papegaaij <pa...@apache.org>
>> > 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
>>
>> What's the purpose of these commented methods ?
>> I understand you didn't add them because of API change but why added
>> them as commented ?
>>
>> > + /**
>> > + * 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();
>> > +
>> > }
>> >
>>
>>
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
Re: [1/2] git commit: WICKET-4212: Add ISessionStore BindListener
Posted by Martin Grigorov <mg...@apache.org>.
On Wed, Jan 4, 2012 at 8:55 PM, <pa...@apache.org> wrote:
> 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 <pa...@apache.org>
> Authored: Wed Nov 9 15:31:56 2011 +0100
> Committer: Emond Papegaaij <pa...@apache.org>
> 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
What's the purpose of these commented methods ?
I understand you didn't add them because of API change but why added
them as commented ?
> + /**
> + * 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();
> +
> }
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com