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.

Reply via email to