You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Johan Compagner <jc...@gmail.com> on 2007/04/11 09:46:42 UTC

why are we suddenly creating 2 request cycles?

in the constructor:

    protected Session(Application application, Request request, Response
response)
    {
        // Construct request cycle (which sets thread local)
        getRequestCycleFactory().newRequestCycle(this, request, response);


and ofcourse normally in the WicketFilter.doGet()

please don't tell me this change of the Session constructor (suddenly a
response object as a param)
and the construction of that request cycle is because of UNIT TESTS????
because that would be horrible that we change such a basic code just for
unit testing.

johan

Re: why are we suddenly creating 2 request cycles?

Posted by Jonathan Locke <jo...@gmail.com>.

i simply forgot to remove the creation in the filter.

there's an actual use case in testing.  there's no reasonable use case
in request cycle construction of a session that couldn't be done better 
in the session factory or constructor.

i did actually think about this.


Johan Compagner wrote:
> 
> in the constructor:
> 
>     protected Session(Application application, Request request, Response
> response)
>     {
>         // Construct request cycle (which sets thread local)
>         getRequestCycleFactory().newRequestCycle(this, request, response);
> 
> 
> and ofcourse normally in the WicketFilter.doGet()
> 
> please don't tell me this change of the Session constructor (suddenly a
> response object as a param)
> and the construction of that request cycle is because of UNIT TESTS????
> because that would be horrible that we change such a basic code just for
> unit testing.
> 
> johan
> 
> 

-- 
View this message in context: http://www.nabble.com/why-are-we-suddenly-creating-2-request-cycles--tf3557832.html#a9958099
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: why are we suddenly creating 2 request cycles?

Posted by Jonathan Locke <jo...@gmail.com>.

name one good reason to use session in request cycle construction.


Johan Compagner wrote:
> 
> Looked at it some more
> this needs to be rollbacked. This is really really bad code.
> 
> there are public methods called on the session object that is not fully
> constructed yet
> And the this is given to the newRequestCycle() method.. What if people
> want
> to use there
> own Session object in the RequestCycle create?? That is impossible because
> the Session
> object is not completely valid yet!
> 
> We need to find another solution for this because this can't be done.
> 
> On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
>>
>> in the constructor:
>>
>>     protected Session(Application application, Request request, Response
>> response)
>>     {
>>         // Construct request cycle (which sets thread local)
>>         getRequestCycleFactory().newRequestCycle(this, request,
>> response);
>>
>>
>>
>> and ofcourse normally in the WicketFilter.doGet()
>>
>> please don't tell me this change of the Session constructor (suddenly a
>> response object as a param)
>> and the construction of that request cycle is because of UNIT TESTS????
>> because that would be horrible that we change such a basic code just for
>> unit testing.
>>
>> johan
>>
>>
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/why-are-we-suddenly-creating-2-request-cycles--tf3557832.html#a9958107
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: why are we suddenly creating 2 request cycles?

Posted by Jonathan Locke <jo...@gmail.com>.

correct.


Johan Compagner wrote:
> 
> on curious thing: why do you already sign/set a cookie at the moment the
> session is constructed
> it is the first page that is getting hit then you already have a user?
> 
> johan
> 
> 
> On 4/14/07, Jonathan Locke <jo...@gmail.com> wrote:
>>
>>
>>
>> Yeah, that's it.  Sorry if I failed to convey the why's very well.
>> I was really exhausted (12 hour day, little sleep) when I tried
>> to write that WIKI explanation.  So here's more:
>>
>> The problem we have, that I think others will eventually run into,
>> is that you may want to sign a user in during session construction,
>> most likely under testing, but there could be other reasons.  Until
>> this change was made, it was actually impossible to do this because
>> you could not set a cookie in your session constructor at all (testing
>> or not) because the request cycle (which holds the response for
>> the current thread to set a cookie on) was being constructed after
>> session construction using a factory contained in the session (which
>> is a very bad location for this, in hindsight).
>>
>> We've disliked this organization of things for a long time, but it
>> was this use case that finally pushed us to make this change.
>> It was certainly possible to hack around this by creating a custom
>> request cycle factory (which would mean several times as many
>> lines and a very non-intuitive solution for others who run into this)
>> and sweeping this all under the rug with business-as-usual, but
>> the benefits of doing this right were finally too hard to ignore.
>> We actually shrank the amount of code considerably with this
>> change.  The result is better, faster, smaller and less confusing
>> for both users and developers of Wicket.
>>
>>
>> Eelco Hillenius wrote:
>> >
>> >
>> http://cwiki.apache.org/WICKET/migrate-13.html#Migrate-1.3-RequestCycle%252CIRequestCycleFactory%252CSession%252CIPageMapandPageMapchanges
>> >> > helps.
>> >>
>> >> this says what, but not the why.
>> >
>> > Ok, I thought it was obvious from just looking at the changes, but here
>> we
>> > go.
>> >
>> > * We got rid of getDefaultRequestCycleFactory and replaced it by
>> > getRequestCycleFactory in Application, and we don't create the request
>> > cycle through the session anymore. That's what but if you pull out
>> > your API elegance tentacles, it's the why as well.
>> > * We only create a session instance when we really need to (it's
>> > created lazily). Possibly a slight optimization. The creation and
>> > registering of the session is all in the right place now. Not
>> > scattered througout wicket filter and application, but just in the
>> > session itself.
>> > * The request cycle is now available in the Session's constructor. I
>> > believe this was what Jonathan needed for better testing support, but
>> > I'm not sure.
>> > * PageMaps were updated for the session on every request, and held a
>> > reference to the session object. This wasn't needed at all, so this is
>> > a cleanup and efficiency improvement.
>> >
>> > Eelco
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/why-are-we-suddenly-creating-2-request-cycles--tf3557832.html#a9995066
>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/why-are-we-suddenly-creating-2-request-cycles--tf3557832.html#a9996630
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: why are we suddenly creating 2 request cycles?

Posted by Johan Compagner <jc...@gmail.com>.
on curious thing: why do you already sign/set a cookie at the moment the
session is constructed
it is the first page that is getting hit then you already have a user?

johan


On 4/14/07, Jonathan Locke <jo...@gmail.com> wrote:
>
>
>
> Yeah, that's it.  Sorry if I failed to convey the why's very well.
> I was really exhausted (12 hour day, little sleep) when I tried
> to write that WIKI explanation.  So here's more:
>
> The problem we have, that I think others will eventually run into,
> is that you may want to sign a user in during session construction,
> most likely under testing, but there could be other reasons.  Until
> this change was made, it was actually impossible to do this because
> you could not set a cookie in your session constructor at all (testing
> or not) because the request cycle (which holds the response for
> the current thread to set a cookie on) was being constructed after
> session construction using a factory contained in the session (which
> is a very bad location for this, in hindsight).
>
> We've disliked this organization of things for a long time, but it
> was this use case that finally pushed us to make this change.
> It was certainly possible to hack around this by creating a custom
> request cycle factory (which would mean several times as many
> lines and a very non-intuitive solution for others who run into this)
> and sweeping this all under the rug with business-as-usual, but
> the benefits of doing this right were finally too hard to ignore.
> We actually shrank the amount of code considerably with this
> change.  The result is better, faster, smaller and less confusing
> for both users and developers of Wicket.
>
>
> Eelco Hillenius wrote:
> >
> >
> http://cwiki.apache.org/WICKET/migrate-13.html#Migrate-1.3-RequestCycle%252CIRequestCycleFactory%252CSession%252CIPageMapandPageMapchanges
> >> > helps.
> >>
> >> this says what, but not the why.
> >
> > Ok, I thought it was obvious from just looking at the changes, but here
> we
> > go.
> >
> > * We got rid of getDefaultRequestCycleFactory and replaced it by
> > getRequestCycleFactory in Application, and we don't create the request
> > cycle through the session anymore. That's what but if you pull out
> > your API elegance tentacles, it's the why as well.
> > * We only create a session instance when we really need to (it's
> > created lazily). Possibly a slight optimization. The creation and
> > registering of the session is all in the right place now. Not
> > scattered througout wicket filter and application, but just in the
> > session itself.
> > * The request cycle is now available in the Session's constructor. I
> > believe this was what Jonathan needed for better testing support, but
> > I'm not sure.
> > * PageMaps were updated for the session on every request, and held a
> > reference to the session object. This wasn't needed at all, so this is
> > a cleanup and efficiency improvement.
> >
> > Eelco
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/why-are-we-suddenly-creating-2-request-cycles--tf3557832.html#a9995066
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>

Re: why are we suddenly creating 2 request cycles?

Posted by Jonathan Locke <jo...@gmail.com>.

Yeah, that's it.  Sorry if I failed to convey the why's very well.
I was really exhausted (12 hour day, little sleep) when I tried
to write that WIKI explanation.  So here's more:

The problem we have, that I think others will eventually run into,
is that you may want to sign a user in during session construction, 
most likely under testing, but there could be other reasons.  Until
this change was made, it was actually impossible to do this because 
you could not set a cookie in your session constructor at all (testing 
or not) because the request cycle (which holds the response for
the current thread to set a cookie on) was being constructed after 
session construction using a factory contained in the session (which
is a very bad location for this, in hindsight).

We've disliked this organization of things for a long time, but it 
was this use case that finally pushed us to make this change.  
It was certainly possible to hack around this by creating a custom
request cycle factory (which would mean several times as many
lines and a very non-intuitive solution for others who run into this) 
and sweeping this all under the rug with business-as-usual, but 
the benefits of doing this right were finally too hard to ignore.
We actually shrank the amount of code considerably with this 
change.  The result is better, faster, smaller and less confusing 
for both users and developers of Wicket.


Eelco Hillenius wrote:
> 
> http://cwiki.apache.org/WICKET/migrate-13.html#Migrate-1.3-RequestCycle%252CIRequestCycleFactory%252CSession%252CIPageMapandPageMapchanges
>> > helps.
>>
>> this says what, but not the why.
> 
> Ok, I thought it was obvious from just looking at the changes, but here we
> go.
> 
> * We got rid of getDefaultRequestCycleFactory and replaced it by
> getRequestCycleFactory in Application, and we don't create the request
> cycle through the session anymore. That's what but if you pull out
> your API elegance tentacles, it's the why as well.
> * We only create a session instance when we really need to (it's
> created lazily). Possibly a slight optimization. The creation and
> registering of the session is all in the right place now. Not
> scattered througout wicket filter and application, but just in the
> session itself.
> * The request cycle is now available in the Session's constructor. I
> believe this was what Jonathan needed for better testing support, but
> I'm not sure.
> * PageMaps were updated for the session on every request, and held a
> reference to the session object. This wasn't needed at all, so this is
> a cleanup and efficiency improvement.
> 
> Eelco
> 
> 

-- 
View this message in context: http://www.nabble.com/why-are-we-suddenly-creating-2-request-cycles--tf3557832.html#a9995066
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: why are we suddenly creating 2 request cycles?

Posted by Igor Vaynberg <ig...@gmail.com>.
this shouldve been the commit message and then everyone wouldve been happy.

thank you

-igor


On 4/13/07, Eelco Hillenius <ee...@gmail.com> wrote:
>
>
> http://cwiki.apache.org/WICKET/migrate-13.html#Migrate-1.3-RequestCycle%252CIRequestCycleFactory%252CSession%252CIPageMapandPageMapchanges
> > > helps.
> >
> > this says what, but not the why.
>
> Ok, I thought it was obvious from just looking at the changes, but here we
> go.
>
> * We got rid of getDefaultRequestCycleFactory and replaced it by
> getRequestCycleFactory in Application, and we don't create the request
> cycle through the session anymore. That's what but if you pull out
> your API elegance tentacles, it's the why as well.
> * We only create a session instance when we really need to (it's
> created lazily). Possibly a slight optimization. The creation and
> registering of the session is all in the right place now. Not
> scattered througout wicket filter and application, but just in the
> session itself.
> * The request cycle is now available in the Session's constructor. I
> believe this was what Jonathan needed for better testing support, but
> I'm not sure.
> * PageMaps were updated for the session on every request, and held a
> reference to the session object. This wasn't needed at all, so this is
> a cleanup and efficiency improvement.
>
> Eelco
>

Re: why are we suddenly creating 2 request cycles?

Posted by Eelco Hillenius <ee...@gmail.com>.
http://cwiki.apache.org/WICKET/migrate-13.html#Migrate-1.3-RequestCycle%252CIRequestCycleFactory%252CSession%252CIPageMapandPageMapchanges
> > helps.
>
> this says what, but not the why.

Ok, I thought it was obvious from just looking at the changes, but here we go.

* We got rid of getDefaultRequestCycleFactory and replaced it by
getRequestCycleFactory in Application, and we don't create the request
cycle through the session anymore. That's what but if you pull out
your API elegance tentacles, it's the why as well.
* We only create a session instance when we really need to (it's
created lazily). Possibly a slight optimization. The creation and
registering of the session is all in the right place now. Not
scattered througout wicket filter and application, but just in the
session itself.
* The request cycle is now available in the Session's constructor. I
believe this was what Jonathan needed for better testing support, but
I'm not sure.
* PageMaps were updated for the session on every request, and held a
reference to the session object. This wasn't needed at all, so this is
a cleanup and efficiency improvement.

Eelco

Re: why are we suddenly creating 2 request cycles?

Posted by Igor Vaynberg <ig...@gmail.com>.
On 4/13/07, Eelco Hillenius <ee...@gmail.com> wrote:
>
>
> I hope
> http://cwiki.apache.org/WICKET/migrate-13.html#Migrate-1.3-RequestCycle%252CIRequestCycleFactory%252CSession%252CIPageMapandPageMapchanges
> helps.


this says what, but not the why.

-igor


Eelco
>

Re: why are we suddenly creating 2 request cycles?

Posted by Eelco Hillenius <ee...@gmail.com>.
> Can you please  explain your changes,

The way request cycles were created was something that annoyed at
least some of us for a while. But one of these things that didn't get
fixed earlier because the annoyance level wasn't high enough I guess.
But this time Jonathan had a good use case. Don't exactly, something
with testing. Maybe he'll explain a bit more. Regardless of the
immediate practical reasons, the changes were for the better.

> one checks  in some changes, the  other  one  reverts  part  of  it?

I wouldn't say it's always the ideal way of developing, but this is
what has been our development style for long. At least you can state
we truly share code ownership. :) Seriously, we've been patching your
code, and you ours as well. That's all fine. Sometimes I find
communicating via commits even more efficient than explaining what you
mean first. I know, that does sound extreme.

>   Consider  that  I  don't
> understand  what you  are  changing now,  especially  in the  late
> stages  of  the  1.3  release.   It's  worth  an  explanation  for
> unexperienced Wicket-deep-internals like me.

I hope http://cwiki.apache.org/WICKET/migrate-13.html#Migrate-1.3-RequestCycle%252CIRequestCycleFactory%252CSession%252CIPageMapandPageMapchanges
helps.

Eelco

Re: why are we suddenly creating 2 request cycles?

Posted by Jean-Baptiste Quenot <jb...@apache.org>.
Jonathan, Eelco, Johan,

Can you please  explain your changes, one checks  in some changes,
the  other  one  reverts  part  of  it?   Consider  that  I  don't
understand  what you  are  changing now,  especially  in the  late
stages  of  the  1.3  release.   It's  worth  an  explanation  for
unexperienced Wicket-deep-internals like me.

What is the problem with RequestCycle?

Thanks in advance,
-- 
     Jean-Baptiste Quenot
aka  John Banana   Qwerty
http://caraldi.com/jbq/

Re: why are we suddenly creating 2 request cycles?

Posted by Eelco Hillenius <ee...@gmail.com>.
newRequestCycle in Session always annoyed, so yes, please get rid of it :)

About changing the order of construction... let's give it a try and
double check there aren't any side effects we didn't think about.

Eelco


On 4/12/07, Jonathan Locke <jo...@gmail.com> wrote:
>
>
> i think we just change order of construction and move requestcycle factory
> to application, where it makes more sense anyway.
>
>
> Johan Compagner wrote:
> >
> > I didn't revert that
> >
> > ISessionFactory still has:
> >
> > Session newSession(Request request, Response response);
> >
> > But i am proposing to do this:
> >
> > ISessionFactory: Session newSession(RequestCycle requestCycle);
> >
> > then create the request cycle before the session creation
> >
> > and let the session get the RequestCycle
> > the request cycle factory should move to application then instead of
> > session
> >
> > johan
> >
> >
> >
> >
> > On 4/12/07, Jonathan Locke <jo...@gmail.com> wrote:
> >>
> >>
> >>
> >> why did you revert the changes that threaded the response through?
> >>
> >> that's a definite improvement.
> >>
> >>
> >> Johan Compagner wrote:
> >> >
> >> > ok i changed it back for now
> >> > But if we want to fix this then we need to change some flow
> >> >
> >> > Now a RequestCycle is created by a Session object:
> >> >
> >> >
> >> > final WebRequest request =
> >> webApplication.newWebRequest(servletRequest);
> >> >
> >> > // First, set the webapplication for this thread
> >> > Application.set(webApplication);
> >> >
> >> > // Create a response object and set the output encoding according to
> >> > // org.apache.wicket's application setttings.
> >> > final WebResponse response =
> >> > webApplication.newWebResponse(servletResponse);
> >> > response.setAjax(request.isAjax());
> >> > response.setCharacterEncoding(webApplication.getRequestCycleSettings
> >> > ().getResponseRequestEncoding());
> >> >
> >> > // Get session for request
> >> > final WebSession session = webApplication.getSession(request,
> >> response);
> >> >
> >> > RequestCycle cycle = session.newRequestCycle(request, response);
> >> >
> >> > we could do this:
> >> >
> >> >
> >> >
> >> > final WebRequest request =
> >> webApplication.newWebRequest(servletRequest);
> >> >
> >> > // First, set the webapplication for this thread
> >> > Application.set(webApplication);
> >> >
> >> > // Create a response object and set the output encoding according to
> >> > // org.apache.wicket's application setttings.
> >> > final WebResponse response =
> >> > webApplication.newWebResponse(servletResponse);
> >> > response.setAjax(request.isAjax());
> >> > response.setCharacterEncoding(webApplication.getRequestCycleSettings
> >> > ().getResponseRequestEncoding());
> >> >
> >> > RequestCycle cycle =
> >> > webApplication.getRequestCycleFactory().newRequestCycle(request,
> >> > response);
> >> >
> >> > // Get session for request
> >> > final WebSession session = webApplication.getSession(request,
> >> response);
> >> >
> >> >
> >> > Then a request cycle is not a child anymore of the session.
> >> > So a request cycle doesn't get the session in its constructor anymore.
> >> (it
> >> > doesn't have access at all to a session object)
> >> >
> >> > johan
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
> >> >>
> >> >> Looked at it some more
> >> >> this needs to be rollbacked. This is really really bad code.
> >> >>
> >> >> there are public methods called on the session object that is not
> >> fully
> >> >> constructed yet
> >> >> And the this is given to the newRequestCycle() method.. What if people
> >> >> want to use there
> >> >> own Session object in the RequestCycle create?? That is impossible
> >> >> because
> >> >> the Session
> >> >> object is not completely valid yet!
> >> >>
> >> >> We need to find another solution for this because this can't be done.
> >> >>
> >> >> On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
> >> >> >
> >> >> > in the constructor:
> >> >> >
> >> >> >     protected Session(Application application, Request request,
> >> >> Response
> >> >> > response)
> >> >> >     {
> >> >> >         // Construct request cycle (which sets thread local)
> >> >> >         getRequestCycleFactory().newRequestCycle(this, request,
> >> >> > response);
> >> >> >
> >> >> >
> >> >> > and ofcourse normally in the WicketFilter.doGet()
> >> >> >
> >> >> > please don't tell me this change of the Session constructor
> >> (suddenly
> >> a
> >> >> > response object as a param)
> >> >> > and the construction of that request cycle is because of UNIT
> >> TESTS????
> >> >> > because that would be horrible that we change such a basic code just
> >> >> for
> >> >> > unit testing.
> >> >> >
> >> >> > johan
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/why-are-we-suddenly-creating-2-request-cycles--tf3557832.html#a9958131
> >> Sent from the Wicket - Dev mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/why-are-we-suddenly-creating-2-request-cycles--tf3557832.html#a9958553
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>

Re: why are we suddenly creating 2 request cycles?

Posted by Jonathan Locke <jo...@gmail.com>.

i think we just change order of construction and move requestcycle factory
to application, where it makes more sense anyway.


Johan Compagner wrote:
> 
> I didn't revert that
> 
> ISessionFactory still has:
> 
> Session newSession(Request request, Response response);
> 
> But i am proposing to do this:
> 
> ISessionFactory: Session newSession(RequestCycle requestCycle);
> 
> then create the request cycle before the session creation
> 
> and let the session get the RequestCycle
> the request cycle factory should move to application then instead of
> session
> 
> johan
> 
> 
> 
> 
> On 4/12/07, Jonathan Locke <jo...@gmail.com> wrote:
>>
>>
>>
>> why did you revert the changes that threaded the response through?
>>
>> that's a definite improvement.
>>
>>
>> Johan Compagner wrote:
>> >
>> > ok i changed it back for now
>> > But if we want to fix this then we need to change some flow
>> >
>> > Now a RequestCycle is created by a Session object:
>> >
>> >
>> > final WebRequest request =
>> webApplication.newWebRequest(servletRequest);
>> >
>> > // First, set the webapplication for this thread
>> > Application.set(webApplication);
>> >
>> > // Create a response object and set the output encoding according to
>> > // org.apache.wicket's application setttings.
>> > final WebResponse response =
>> > webApplication.newWebResponse(servletResponse);
>> > response.setAjax(request.isAjax());
>> > response.setCharacterEncoding(webApplication.getRequestCycleSettings
>> > ().getResponseRequestEncoding());
>> >
>> > // Get session for request
>> > final WebSession session = webApplication.getSession(request,
>> response);
>> >
>> > RequestCycle cycle = session.newRequestCycle(request, response);
>> >
>> > we could do this:
>> >
>> >
>> >
>> > final WebRequest request =
>> webApplication.newWebRequest(servletRequest);
>> >
>> > // First, set the webapplication for this thread
>> > Application.set(webApplication);
>> >
>> > // Create a response object and set the output encoding according to
>> > // org.apache.wicket's application setttings.
>> > final WebResponse response =
>> > webApplication.newWebResponse(servletResponse);
>> > response.setAjax(request.isAjax());
>> > response.setCharacterEncoding(webApplication.getRequestCycleSettings
>> > ().getResponseRequestEncoding());
>> >
>> > RequestCycle cycle =
>> > webApplication.getRequestCycleFactory().newRequestCycle(request,
>> > response);
>> >
>> > // Get session for request
>> > final WebSession session = webApplication.getSession(request,
>> response);
>> >
>> >
>> > Then a request cycle is not a child anymore of the session.
>> > So a request cycle doesn't get the session in its constructor anymore.
>> (it
>> > doesn't have access at all to a session object)
>> >
>> > johan
>> >
>> >
>> >
>> >
>> >
>> > On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
>> >>
>> >> Looked at it some more
>> >> this needs to be rollbacked. This is really really bad code.
>> >>
>> >> there are public methods called on the session object that is not
>> fully
>> >> constructed yet
>> >> And the this is given to the newRequestCycle() method.. What if people
>> >> want to use there
>> >> own Session object in the RequestCycle create?? That is impossible
>> >> because
>> >> the Session
>> >> object is not completely valid yet!
>> >>
>> >> We need to find another solution for this because this can't be done.
>> >>
>> >> On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
>> >> >
>> >> > in the constructor:
>> >> >
>> >> >     protected Session(Application application, Request request,
>> >> Response
>> >> > response)
>> >> >     {
>> >> >         // Construct request cycle (which sets thread local)
>> >> >         getRequestCycleFactory().newRequestCycle(this, request,
>> >> > response);
>> >> >
>> >> >
>> >> > and ofcourse normally in the WicketFilter.doGet()
>> >> >
>> >> > please don't tell me this change of the Session constructor
>> (suddenly
>> a
>> >> > response object as a param)
>> >> > and the construction of that request cycle is because of UNIT
>> TESTS????
>> >> > because that would be horrible that we change such a basic code just
>> >> for
>> >> > unit testing.
>> >> >
>> >> > johan
>> >> >
>> >> >
>> >> >
>> >> >
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/why-are-we-suddenly-creating-2-request-cycles--tf3557832.html#a9958131
>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/why-are-we-suddenly-creating-2-request-cycles--tf3557832.html#a9958553
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: why are we suddenly creating 2 request cycles?

Posted by Jonathan Locke <jo...@gmail.com>.

ah, okay.

but i don't think we need to break session factories to be explicit 
here.  request cycle is available by threadlocal.


Johan Compagner wrote:
> 
> I didn't revert that
> 
> ISessionFactory still has:
> 
> Session newSession(Request request, Response response);
> 
> But i am proposing to do this:
> 
> ISessionFactory: Session newSession(RequestCycle requestCycle);
> 
> then create the request cycle before the session creation
> 
> and let the session get the RequestCycle
> the request cycle factory should move to application then instead of
> session
> 
> johan
> 
> 
> 
> 
> On 4/12/07, Jonathan Locke <jo...@gmail.com> wrote:
>>
>>
>>
>> why did you revert the changes that threaded the response through?
>>
>> that's a definite improvement.
>>
>>
>> Johan Compagner wrote:
>> >
>> > ok i changed it back for now
>> > But if we want to fix this then we need to change some flow
>> >
>> > Now a RequestCycle is created by a Session object:
>> >
>> >
>> > final WebRequest request =
>> webApplication.newWebRequest(servletRequest);
>> >
>> > // First, set the webapplication for this thread
>> > Application.set(webApplication);
>> >
>> > // Create a response object and set the output encoding according to
>> > // org.apache.wicket's application setttings.
>> > final WebResponse response =
>> > webApplication.newWebResponse(servletResponse);
>> > response.setAjax(request.isAjax());
>> > response.setCharacterEncoding(webApplication.getRequestCycleSettings
>> > ().getResponseRequestEncoding());
>> >
>> > // Get session for request
>> > final WebSession session = webApplication.getSession(request,
>> response);
>> >
>> > RequestCycle cycle = session.newRequestCycle(request, response);
>> >
>> > we could do this:
>> >
>> >
>> >
>> > final WebRequest request =
>> webApplication.newWebRequest(servletRequest);
>> >
>> > // First, set the webapplication for this thread
>> > Application.set(webApplication);
>> >
>> > // Create a response object and set the output encoding according to
>> > // org.apache.wicket's application setttings.
>> > final WebResponse response =
>> > webApplication.newWebResponse(servletResponse);
>> > response.setAjax(request.isAjax());
>> > response.setCharacterEncoding(webApplication.getRequestCycleSettings
>> > ().getResponseRequestEncoding());
>> >
>> > RequestCycle cycle =
>> > webApplication.getRequestCycleFactory().newRequestCycle(request,
>> > response);
>> >
>> > // Get session for request
>> > final WebSession session = webApplication.getSession(request,
>> response);
>> >
>> >
>> > Then a request cycle is not a child anymore of the session.
>> > So a request cycle doesn't get the session in its constructor anymore.
>> (it
>> > doesn't have access at all to a session object)
>> >
>> > johan
>> >
>> >
>> >
>> >
>> >
>> > On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
>> >>
>> >> Looked at it some more
>> >> this needs to be rollbacked. This is really really bad code.
>> >>
>> >> there are public methods called on the session object that is not
>> fully
>> >> constructed yet
>> >> And the this is given to the newRequestCycle() method.. What if people
>> >> want to use there
>> >> own Session object in the RequestCycle create?? That is impossible
>> >> because
>> >> the Session
>> >> object is not completely valid yet!
>> >>
>> >> We need to find another solution for this because this can't be done.
>> >>
>> >> On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
>> >> >
>> >> > in the constructor:
>> >> >
>> >> >     protected Session(Application application, Request request,
>> >> Response
>> >> > response)
>> >> >     {
>> >> >         // Construct request cycle (which sets thread local)
>> >> >         getRequestCycleFactory().newRequestCycle(this, request,
>> >> > response);
>> >> >
>> >> >
>> >> > and ofcourse normally in the WicketFilter.doGet()
>> >> >
>> >> > please don't tell me this change of the Session constructor
>> (suddenly
>> a
>> >> > response object as a param)
>> >> > and the construction of that request cycle is because of UNIT
>> TESTS????
>> >> > because that would be horrible that we change such a basic code just
>> >> for
>> >> > unit testing.
>> >> >
>> >> > johan
>> >> >
>> >> >
>> >> >
>> >> >
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/why-are-we-suddenly-creating-2-request-cycles--tf3557832.html#a9958131
>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/why-are-we-suddenly-creating-2-request-cycles--tf3557832.html#a9958541
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: why are we suddenly creating 2 request cycles?

Posted by Johan Compagner <jc...@gmail.com>.
I didn't revert that

ISessionFactory still has:

Session newSession(Request request, Response response);

But i am proposing to do this:

ISessionFactory: Session newSession(RequestCycle requestCycle);

then create the request cycle before the session creation

and let the session get the RequestCycle
the request cycle factory should move to application then instead of session

johan




On 4/12/07, Jonathan Locke <jo...@gmail.com> wrote:
>
>
>
> why did you revert the changes that threaded the response through?
>
> that's a definite improvement.
>
>
> Johan Compagner wrote:
> >
> > ok i changed it back for now
> > But if we want to fix this then we need to change some flow
> >
> > Now a RequestCycle is created by a Session object:
> >
> >
> > final WebRequest request = webApplication.newWebRequest(servletRequest);
> >
> > // First, set the webapplication for this thread
> > Application.set(webApplication);
> >
> > // Create a response object and set the output encoding according to
> > // org.apache.wicket's application setttings.
> > final WebResponse response =
> > webApplication.newWebResponse(servletResponse);
> > response.setAjax(request.isAjax());
> > response.setCharacterEncoding(webApplication.getRequestCycleSettings
> > ().getResponseRequestEncoding());
> >
> > // Get session for request
> > final WebSession session = webApplication.getSession(request, response);
> >
> > RequestCycle cycle = session.newRequestCycle(request, response);
> >
> > we could do this:
> >
> >
> >
> > final WebRequest request = webApplication.newWebRequest(servletRequest);
> >
> > // First, set the webapplication for this thread
> > Application.set(webApplication);
> >
> > // Create a response object and set the output encoding according to
> > // org.apache.wicket's application setttings.
> > final WebResponse response =
> > webApplication.newWebResponse(servletResponse);
> > response.setAjax(request.isAjax());
> > response.setCharacterEncoding(webApplication.getRequestCycleSettings
> > ().getResponseRequestEncoding());
> >
> > RequestCycle cycle =
> > webApplication.getRequestCycleFactory().newRequestCycle(request,
> > response);
> >
> > // Get session for request
> > final WebSession session = webApplication.getSession(request, response);
> >
> >
> > Then a request cycle is not a child anymore of the session.
> > So a request cycle doesn't get the session in its constructor anymore.
> (it
> > doesn't have access at all to a session object)
> >
> > johan
> >
> >
> >
> >
> >
> > On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
> >>
> >> Looked at it some more
> >> this needs to be rollbacked. This is really really bad code.
> >>
> >> there are public methods called on the session object that is not fully
> >> constructed yet
> >> And the this is given to the newRequestCycle() method.. What if people
> >> want to use there
> >> own Session object in the RequestCycle create?? That is impossible
> >> because
> >> the Session
> >> object is not completely valid yet!
> >>
> >> We need to find another solution for this because this can't be done.
> >>
> >> On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
> >> >
> >> > in the constructor:
> >> >
> >> >     protected Session(Application application, Request request,
> >> Response
> >> > response)
> >> >     {
> >> >         // Construct request cycle (which sets thread local)
> >> >         getRequestCycleFactory().newRequestCycle(this, request,
> >> > response);
> >> >
> >> >
> >> > and ofcourse normally in the WicketFilter.doGet()
> >> >
> >> > please don't tell me this change of the Session constructor (suddenly
> a
> >> > response object as a param)
> >> > and the construction of that request cycle is because of UNIT
> TESTS????
> >> > because that would be horrible that we change such a basic code just
> >> for
> >> > unit testing.
> >> >
> >> > johan
> >> >
> >> >
> >> >
> >> >
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/why-are-we-suddenly-creating-2-request-cycles--tf3557832.html#a9958131
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>

Re: why are we suddenly creating 2 request cycles?

Posted by Jonathan Locke <jo...@gmail.com>.

why did you revert the changes that threaded the response through?

that's a definite improvement.


Johan Compagner wrote:
> 
> ok i changed it back for now
> But if we want to fix this then we need to change some flow
> 
> Now a RequestCycle is created by a Session object:
> 
> 
> final WebRequest request = webApplication.newWebRequest(servletRequest);
> 
> // First, set the webapplication for this thread
> Application.set(webApplication);
> 
> // Create a response object and set the output encoding according to
> // org.apache.wicket's application setttings.
> final WebResponse response =
> webApplication.newWebResponse(servletResponse);
> response.setAjax(request.isAjax());
> response.setCharacterEncoding(webApplication.getRequestCycleSettings
> ().getResponseRequestEncoding());
> 
> // Get session for request
> final WebSession session = webApplication.getSession(request, response);
> 
> RequestCycle cycle = session.newRequestCycle(request, response);
> 
> we could do this:
> 
> 
> 
> final WebRequest request = webApplication.newWebRequest(servletRequest);
> 
> // First, set the webapplication for this thread
> Application.set(webApplication);
> 
> // Create a response object and set the output encoding according to
> // org.apache.wicket's application setttings.
> final WebResponse response =
> webApplication.newWebResponse(servletResponse);
> response.setAjax(request.isAjax());
> response.setCharacterEncoding(webApplication.getRequestCycleSettings
> ().getResponseRequestEncoding());
> 
> RequestCycle cycle =
> webApplication.getRequestCycleFactory().newRequestCycle(request,
> response);
> 
> // Get session for request
> final WebSession session = webApplication.getSession(request, response);
> 
> 
> Then a request cycle is not a child anymore of the session.
> So a request cycle doesn't get the session in its constructor anymore. (it
> doesn't have access at all to a session object)
> 
> johan
> 
> 
> 
> 
> 
> On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
>>
>> Looked at it some more
>> this needs to be rollbacked. This is really really bad code.
>>
>> there are public methods called on the session object that is not fully
>> constructed yet
>> And the this is given to the newRequestCycle() method.. What if people
>> want to use there
>> own Session object in the RequestCycle create?? That is impossible
>> because
>> the Session
>> object is not completely valid yet!
>>
>> We need to find another solution for this because this can't be done.
>>
>> On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
>> >
>> > in the constructor:
>> >
>> >     protected Session(Application application, Request request,
>> Response
>> > response)
>> >     {
>> >         // Construct request cycle (which sets thread local)
>> >         getRequestCycleFactory().newRequestCycle(this, request,
>> > response);
>> >
>> >
>> > and ofcourse normally in the WicketFilter.doGet()
>> >
>> > please don't tell me this change of the Session constructor (suddenly a
>> > response object as a param)
>> > and the construction of that request cycle is because of UNIT TESTS????
>> > because that would be horrible that we change such a basic code just
>> for
>> > unit testing.
>> >
>> > johan
>> >
>> >
>> >
>> >
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/why-are-we-suddenly-creating-2-request-cycles--tf3557832.html#a9958131
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: why are we suddenly creating 2 request cycles?

Posted by Eelco Hillenius <ee...@gmail.com>.
> The second approuch looks like a step in the right direction. It would be
> nice not to need a session to serve a request.

That's quite impossible for many (internal) reasons. However, as long
as you are operating stateless (no reall HttpSession or whatever
backing created yet), only temporary instances of are created (and
discarded at the end of a request). See Session#isTemporary.

Eelco

Re: why are we suddenly creating 2 request cycles?

Posted by Ryan <cr...@gmail.com>.
The second approuch looks like a step in the right direction. It would be
nice not to need a session to serve a request.

Ryan

On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
>
> ok i changed it back for now
> But if we want to fix this then we need to change some flow
>
> Now a RequestCycle is created by a Session object:
>
>
> final WebRequest request = webApplication.newWebRequest(servletRequest);
>
> // First, set the webapplication for this thread
> Application.set(webApplication);
>
> // Create a response object and set the output encoding according to
> // org.apache.wicket's application setttings.
> final WebResponse response = webApplication.newWebResponse
> (servletResponse);
> response.setAjax(request.isAjax());
> response.setCharacterEncoding(webApplication.getRequestCycleSettings
> ().getResponseRequestEncoding());
>
> // Get session for request
> final WebSession session = webApplication.getSession(request, response);
>
> RequestCycle cycle = session.newRequestCycle(request, response);
>
> we could do this:
>
>
>
> final WebRequest request = webApplication.newWebRequest(servletRequest);
>
> // First, set the webapplication for this thread
> Application.set(webApplication);
>
> // Create a response object and set the output encoding according to
> // org.apache.wicket's application setttings.
> final WebResponse response = webApplication.newWebResponse
> (servletResponse);
> response.setAjax(request.isAjax());
> response.setCharacterEncoding(webApplication.getRequestCycleSettings
> ().getResponseRequestEncoding());
>
> RequestCycle cycle =
> webApplication.getRequestCycleFactory().newRequestCycle(request,
> response);
>
> // Get session for request
> final WebSession session = webApplication.getSession(request, response);
>
>
> Then a request cycle is not a child anymore of the session.
> So a request cycle doesn't get the session in its constructor anymore. (it
> doesn't have access at all to a session object)
>
> johan
>
>
>
>
>
> On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
> >
> > Looked at it some more
> > this needs to be rollbacked. This is really really bad code.
> >
> > there are public methods called on the session object that is not fully
> > constructed yet
> > And the this is given to the newRequestCycle() method.. What if people
> > want to use there
> > own Session object in the RequestCycle create?? That is impossible
> because
> > the Session
> > object is not completely valid yet!
> >
> > We need to find another solution for this because this can't be done.
> >
> > On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
> > >
> > > in the constructor:
> > >
> > >     protected Session(Application application, Request request,
> Response
> > > response)
> > >     {
> > >         // Construct request cycle (which sets thread local)
> > >         getRequestCycleFactory().newRequestCycle(this, request,
> > > response);
> > >
> > >
> > > and ofcourse normally in the WicketFilter.doGet()
> > >
> > > please don't tell me this change of the Session constructor (suddenly
> a
> > > response object as a param)
> > > and the construction of that request cycle is because of UNIT
> TESTS????
> > > because that would be horrible that we change such a basic code just
> for
> > > unit testing.
> > >
> > > johan
> > >
> > >
> > >
> > >
> >
>

Re: why are we suddenly creating 2 request cycles?

Posted by Johan Compagner <jc...@gmail.com>.
ok i changed it back for now
But if we want to fix this then we need to change some flow

Now a RequestCycle is created by a Session object:


final WebRequest request = webApplication.newWebRequest(servletRequest);

// First, set the webapplication for this thread
Application.set(webApplication);

// Create a response object and set the output encoding according to
// org.apache.wicket's application setttings.
final WebResponse response = webApplication.newWebResponse(servletResponse);
response.setAjax(request.isAjax());
response.setCharacterEncoding(webApplication.getRequestCycleSettings
().getResponseRequestEncoding());

// Get session for request
final WebSession session = webApplication.getSession(request, response);

RequestCycle cycle = session.newRequestCycle(request, response);

we could do this:



final WebRequest request = webApplication.newWebRequest(servletRequest);

// First, set the webapplication for this thread
Application.set(webApplication);

// Create a response object and set the output encoding according to
// org.apache.wicket's application setttings.
final WebResponse response = webApplication.newWebResponse(servletResponse);
response.setAjax(request.isAjax());
response.setCharacterEncoding(webApplication.getRequestCycleSettings
().getResponseRequestEncoding());

RequestCycle cycle =
webApplication.getRequestCycleFactory().newRequestCycle(request,
response);

// Get session for request
final WebSession session = webApplication.getSession(request, response);


Then a request cycle is not a child anymore of the session.
So a request cycle doesn't get the session in its constructor anymore. (it
doesn't have access at all to a session object)

johan





On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
>
> Looked at it some more
> this needs to be rollbacked. This is really really bad code.
>
> there are public methods called on the session object that is not fully
> constructed yet
> And the this is given to the newRequestCycle() method.. What if people
> want to use there
> own Session object in the RequestCycle create?? That is impossible because
> the Session
> object is not completely valid yet!
>
> We need to find another solution for this because this can't be done.
>
> On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
> >
> > in the constructor:
> >
> >     protected Session(Application application, Request request, Response
> > response)
> >     {
> >         // Construct request cycle (which sets thread local)
> >         getRequestCycleFactory().newRequestCycle(this, request,
> > response);
> >
> >
> > and ofcourse normally in the WicketFilter.doGet()
> >
> > please don't tell me this change of the Session constructor (suddenly a
> > response object as a param)
> > and the construction of that request cycle is because of UNIT TESTS????
> > because that would be horrible that we change such a basic code just for
> > unit testing.
> >
> > johan
> >
> >
> >
> >
>

Re: why are we suddenly creating 2 request cycles?

Posted by Johan Compagner <jc...@gmail.com>.
Looked at it some more
this needs to be rollbacked. This is really really bad code.

there are public methods called on the session object that is not fully
constructed yet
And the this is given to the newRequestCycle() method.. What if people want
to use there
own Session object in the RequestCycle create?? That is impossible because
the Session
object is not completely valid yet!

We need to find another solution for this because this can't be done.

On 4/11/07, Johan Compagner <jc...@gmail.com> wrote:
>
> in the constructor:
>
>     protected Session(Application application, Request request, Response
> response)
>     {
>         // Construct request cycle (which sets thread local)
>         getRequestCycleFactory().newRequestCycle(this, request, response);
>
>
>
> and ofcourse normally in the WicketFilter.doGet()
>
> please don't tell me this change of the Session constructor (suddenly a
> response object as a param)
> and the construction of that request cycle is because of UNIT TESTS????
> because that would be horrible that we change such a basic code just for
> unit testing.
>
> johan
>
>
>
>