You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Jan Vermeulen <ja...@isencia.com> on 2007/05/04 17:30:28 UTC

Backporting from 2.0: Session.attach() only called when session is created

In the former Wicket 2.0, the Session attach() was defined in WebSession, and
called in WebSession:initForRequest():
	/**
	 * Initializes this session for a request.
	 */
	public final void initForRequest()
	{
		// Set the current session
		set(this);

		attach();
	}

In the new trunk, Session attach() is defined in Session, and called in
Session:findOrCreate():
	public static final Session findOrCreate()
	{
                ......
		if (session == null)
		{
			// Create session using session factory
			session =
application.getSessionFactory().newSession(requestCycle.getRequest(),
					requestCycle.getResponse());
			// Set the current session
			// execute any attach logic now
			session.attach();
		}

		set(session);

		return session;
	}

As can be seen in the code, attach() will only be called if no session has
been found, while it was called whenever the session was bound to the
current thread in the former 2.0.

It does not match the comment on the attach() itself:
	/**
	 * Any attach logic for session subclasses. Called when a session is set
for
	 * the thread. Note that this is done on demand (lazily): as long as the
	 * session isn't being used, it is not located or created and this method
is
	 * not called.
	 */
	protected void attach()
	{
	}

So this is a bug ?

Jan.
-- 
View this message in context: http://www.nabble.com/Backporting-from-2.0%3A-Session.attach%28%29-only-called-when-session-is-created-tf3692290.html#a10323451
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: Backporting from 2.0: Session.attach() only called when session is created

Posted by Jan Vermeulen <ja...@isencia.com>.
Thanks.

Jan.
-- 
View this message in context: http://www.nabble.com/Backporting-from-2.0%3A-Session.attach%28%29-only-called-when-session-is-created-tf3692290.html#a10358183
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: Backporting from 2.0: Session.attach() only called when session is created

Posted by Johan Compagner <jc...@gmail.com>.
shoulw be fixed now.

johan


On 5/7/07, Jan Vermeulen <ja...@isencia.com> wrote:
>
>
> Maybe this one got lost between the feathers of the bird...
> But I think it might be a bug in the current trunk, so if someone of the
> core could look at it ?
>
> Jan.
> --
> View this message in context:
> http://www.nabble.com/Backporting-from-2.0%3A-Session.attach%28%29-only-called-when-session-is-created-tf3692290.html#a10356377
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>

Re: Backporting from 2.0: Session.attach() only called when session is created

Posted by Johan Compagner <jc...@gmail.com>.
i was 4 minutes quicker!!

On 5/7/07, Eelco Hillenius <ee...@gmail.com> wrote:
>
> Good catch, thanks. I've fixed it, and now call attach in the
> threadlocal set method so that we're sure it will always be called
> whenever the session is exposed for the current thread.
>
> Eeco
>
>
> On 5/7/07, Jan Vermeulen <ja...@isencia.com> wrote:
> >
> > Maybe this one got lost between the feathers of the bird...
> > But I think it might be a bug in the current trunk, so if someone of the
> > core could look at it ?
> >
> > Jan.
> > --
> > View this message in context:
> http://www.nabble.com/Backporting-from-2.0%3A-Session.attach%28%29-only-called-when-session-is-created-tf3692290.html#a10356377
> > Sent from the Wicket - Dev mailing list archive at Nabble.com.
> >
> >
>

Re: Backporting from 2.0: Session.attach() only called when session is created

Posted by Eelco Hillenius <ee...@gmail.com>.
Good catch, thanks. I've fixed it, and now call attach in the
threadlocal set method so that we're sure it will always be called
whenever the session is exposed for the current thread.

Eeco


On 5/7/07, Jan Vermeulen <ja...@isencia.com> wrote:
>
> Maybe this one got lost between the feathers of the bird...
> But I think it might be a bug in the current trunk, so if someone of the
> core could look at it ?
>
> Jan.
> --
> View this message in context: http://www.nabble.com/Backporting-from-2.0%3A-Session.attach%28%29-only-called-when-session-is-created-tf3692290.html#a10356377
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>

Re: Backporting from 2.0: Session.attach() only called when session is created

Posted by Jan Vermeulen <ja...@isencia.com>.
Maybe this one got lost between the feathers of the bird...
But I think it might be a bug in the current trunk, so if someone of the
core could look at it ?

Jan.
-- 
View this message in context: http://www.nabble.com/Backporting-from-2.0%3A-Session.attach%28%29-only-called-when-session-is-created-tf3692290.html#a10356377
Sent from the Wicket - Dev mailing list archive at Nabble.com.