You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by tm...@gmx.de on 2011/04/12 13:48:59 UTC

@Broadcast annotation

Hello again!

Is there any way to get the @Broadcast annotation from Atmosphere:

http://atmosphere.java.net/nonav/apidocs/org/atmosphere/annotation/Broadcast.html

working inside of a Tapestry5 page or component?

Or are there any general, architectural restrictions why this can not work in Tapestry right now?

If not, what changes would be necessary in order to be able to be able to use it?

Thanks!

Tobias

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: @Broadcast annotation

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 12 Apr 2011 08:48:59 -0300, <tm...@gmx.de> wrote:

> Hello again!

Hi!

> Is there any way to get the @Broadcast annotation from Atmosphere:
> http://atmosphere.java.net/nonav/apidocs/org/atmosphere/annotation/Broadcast.html
> working inside of a Tapestry5 page or component?

I never tried Atmosphere, but this integration would need to be  
implemented as a ComponentClassTransformer, as any other annotation  
handling is done in Tapestry pages and components.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: @Broadcast annotation

Posted by Josh Canfield <jo...@gmail.com>.
> I don't think this is correct with regard to services that don't use
> HttpServletRequest or HttpServletResponse directly or indirectly. If I'm
> right, you can use most of your Tapestry services on them, speciallyl the
> singleton ones.

Ah yes, of course you are right. The proxy will get/create the service
for the thread if it doesn't exist. I should have just done the
test... The funny thing is, I was using an @Inject'd logger so clearly
everything isn't null...

Josh

On Wed, Apr 13, 2011 at 5:31 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> On Wed, 13 Apr 2011 19:27:06 -0300, Josh Canfield <jo...@gmail.com>
> wrote:
>
>> When you receive a broadcast you are not in the Tapestry stack. You
>> might think it would be cool to use your @Inject'd services when you
>> get a broadcast, but you'll get an NPE because the thread that
>> executes the broadcast is not a thread that has been setup by
>> tapestry.
>
> I don't think this is correct with regard to services that don't use
> HttpServletRequest or HttpServletResponse directly or indirectly. If I'm
> right, you can use most of your Tapestry services on them, speciallyl the
> singleton ones.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: @Broadcast annotation

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 13 Apr 2011 19:27:06 -0300, Josh Canfield <jo...@gmail.com>  
wrote:

> When you receive a broadcast you are not in the Tapestry stack. You
> might think it would be cool to use your @Inject'd services when you
> get a broadcast, but you'll get an NPE because the thread that
> executes the broadcast is not a thread that has been setup by
> tapestry.

I don't think this is correct with regard to services that don't use  
HttpServletRequest or HttpServletResponse directly or indirectly. If I'm  
right, you can use most of your Tapestry services on them, speciallyl the  
singleton ones.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: @Broadcast annotation

Posted by Taha Hafeez <ta...@gmail.com>.
That is exactly what i had concluded except for the injection part of it.
Thanks for your insight

regards
Taha

On Thu, Apr 14, 2011 at 3:57 AM, Josh Canfield <jo...@gmail.com>wrote:

> > Did you check the meteor module. In that case the Tapestry Filter will
> run
> > inside the Atmosphere Servlet.
>
> I've spent too much of today reading the white paper and experimenting
> because I'm intrigued by anything async these days.
>
> Atmosphere can work with Tapestry, as long as you don't want to do
> anything Tapestry-like when you get a broadcast. I mistakenly assumed
> that this was a more general Continuations library (as is provided in
> jetty-continuations), really it appears to be more about doing more
> pubsub/broadcast type apps. My use case is more about freeing up
> server threads while I continue to process the request.
>
> When you receive a broadcast you are not in the Tapestry stack. You
> might think it would be cool to use your @Inject'd services when you
> get a broadcast, but you'll get an NPE because the thread that
> executes the broadcast is not a thread that has been setup by
> tapestry. Your page attributes are stored as thread locals and so you
> will have none. You can however format and write your own response.
>
> To answer the OPs question, you could write a
> ComponentClassTransformerWorker which checked for the @Broadcast on
> page/component events and trigger a broadcast. If you implement a
> ResultProcessor for some object that doesn't write to the response and
> turn off GZIP compression (always seams to want to write something).
>
> If you use the MeteorServlet then you also need to rename your
> AppModule to TapestryFilterModule because of how MeteorServlet names
> your filter.
>
> Josh
>
> On Wed, Apr 13, 2011 at 10:26 AM, Taha Hafeez <ta...@gmail.com>
> wrote:
> > Hi Josh
> >
> > Did you check the meteor module. In that case the Tapestry Filter will
> run
> > inside the Atmosphere Servlet.
> >
> > regards
> > Taha
> >
> >
> >
> > On Wed, Apr 13, 2011 at 10:38 PM, Josh Canfield <joshcanfield@gmail.com
> >wrote:
> >
> >> I haven't played with Atmosphere specifically, but I've played a bit
> >> Jetty continuations, or Servlet 3's startAsync in Tapestry.
> >>
> >> It's not a trivial integration, but I've gotten something barely
> >> working using Jetty's Continuations. For my solution I created an
> >> @AsyncEvent which essentially hijacks the event method and wraps it in
> >> a Runnable that gets dumped into a threadpool. When the method
> >> completes it resumes the continuation.
> >>
> >> The challenge is that both the Servlet3 and Jetty Continuation (and
> >> atmosphere from the look of it) expect you to return from your event
> >> method when you suspend. This means that you go all they way back up
> >> the stack to the container where it notes that you've suspended the
> >> request and then re-issues the request when you resume. For tapestry,
> >> this means that it thinks you're done with the request and starts
> >> cleaning up all the injectable services that you probably still need
> >> to finish your suspended request.
> >>
> >> I did this all about 6 months ago and haven't had a chance to get into
> >> the tapestry source to work out a way to teach it about suspended
> >> requests.
> >>
> >> Josh
> >>
> >> On Tue, Apr 12, 2011 at 4:48 AM,  <tm...@gmx.de> wrote:
> >> > Hello again!
> >> >
> >> > Is there any way to get the @Broadcast annotation from Atmosphere:
> >> >
> >> >
> >>
> http://atmosphere.java.net/nonav/apidocs/org/atmosphere/annotation/Broadcast.html
> >> >
> >> > working inside of a Tapestry5 page or component?
> >> >
> >> > Or are there any general, architectural restrictions why this can not
> >> work in Tapestry right now?
> >> >
> >> > If not, what changes would be necessary in order to be able to be able
> to
> >> use it?
> >> >
> >> > Thanks!
> >> >
> >> > Tobias
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> > For additional commands, e-mail: users-help@tapestry.apache.org
> >> >
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: @Broadcast annotation

Posted by Josh Canfield <jo...@gmail.com>.
> Did you check the meteor module. In that case the Tapestry Filter will run
> inside the Atmosphere Servlet.

I've spent too much of today reading the white paper and experimenting
because I'm intrigued by anything async these days.

Atmosphere can work with Tapestry, as long as you don't want to do
anything Tapestry-like when you get a broadcast. I mistakenly assumed
that this was a more general Continuations library (as is provided in
jetty-continuations), really it appears to be more about doing more
pubsub/broadcast type apps. My use case is more about freeing up
server threads while I continue to process the request.

When you receive a broadcast you are not in the Tapestry stack. You
might think it would be cool to use your @Inject'd services when you
get a broadcast, but you'll get an NPE because the thread that
executes the broadcast is not a thread that has been setup by
tapestry. Your page attributes are stored as thread locals and so you
will have none. You can however format and write your own response.

To answer the OPs question, you could write a
ComponentClassTransformerWorker which checked for the @Broadcast on
page/component events and trigger a broadcast. If you implement a
ResultProcessor for some object that doesn't write to the response and
turn off GZIP compression (always seams to want to write something).

If you use the MeteorServlet then you also need to rename your
AppModule to TapestryFilterModule because of how MeteorServlet names
your filter.

Josh

On Wed, Apr 13, 2011 at 10:26 AM, Taha Hafeez <ta...@gmail.com> wrote:
> Hi Josh
>
> Did you check the meteor module. In that case the Tapestry Filter will run
> inside the Atmosphere Servlet.
>
> regards
> Taha
>
>
>
> On Wed, Apr 13, 2011 at 10:38 PM, Josh Canfield <jo...@gmail.com>wrote:
>
>> I haven't played with Atmosphere specifically, but I've played a bit
>> Jetty continuations, or Servlet 3's startAsync in Tapestry.
>>
>> It's not a trivial integration, but I've gotten something barely
>> working using Jetty's Continuations. For my solution I created an
>> @AsyncEvent which essentially hijacks the event method and wraps it in
>> a Runnable that gets dumped into a threadpool. When the method
>> completes it resumes the continuation.
>>
>> The challenge is that both the Servlet3 and Jetty Continuation (and
>> atmosphere from the look of it) expect you to return from your event
>> method when you suspend. This means that you go all they way back up
>> the stack to the container where it notes that you've suspended the
>> request and then re-issues the request when you resume. For tapestry,
>> this means that it thinks you're done with the request and starts
>> cleaning up all the injectable services that you probably still need
>> to finish your suspended request.
>>
>> I did this all about 6 months ago and haven't had a chance to get into
>> the tapestry source to work out a way to teach it about suspended
>> requests.
>>
>> Josh
>>
>> On Tue, Apr 12, 2011 at 4:48 AM,  <tm...@gmx.de> wrote:
>> > Hello again!
>> >
>> > Is there any way to get the @Broadcast annotation from Atmosphere:
>> >
>> >
>> http://atmosphere.java.net/nonav/apidocs/org/atmosphere/annotation/Broadcast.html
>> >
>> > working inside of a Tapestry5 page or component?
>> >
>> > Or are there any general, architectural restrictions why this can not
>> work in Tapestry right now?
>> >
>> > If not, what changes would be necessary in order to be able to be able to
>> use it?
>> >
>> > Thanks!
>> >
>> > Tobias
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: @Broadcast annotation

Posted by Taha Hafeez <ta...@gmail.com>.
Hi Josh

Did you check the meteor module. In that case the Tapestry Filter will run
inside the Atmosphere Servlet.

regards
Taha



On Wed, Apr 13, 2011 at 10:38 PM, Josh Canfield <jo...@gmail.com>wrote:

> I haven't played with Atmosphere specifically, but I've played a bit
> Jetty continuations, or Servlet 3's startAsync in Tapestry.
>
> It's not a trivial integration, but I've gotten something barely
> working using Jetty's Continuations. For my solution I created an
> @AsyncEvent which essentially hijacks the event method and wraps it in
> a Runnable that gets dumped into a threadpool. When the method
> completes it resumes the continuation.
>
> The challenge is that both the Servlet3 and Jetty Continuation (and
> atmosphere from the look of it) expect you to return from your event
> method when you suspend. This means that you go all they way back up
> the stack to the container where it notes that you've suspended the
> request and then re-issues the request when you resume. For tapestry,
> this means that it thinks you're done with the request and starts
> cleaning up all the injectable services that you probably still need
> to finish your suspended request.
>
> I did this all about 6 months ago and haven't had a chance to get into
> the tapestry source to work out a way to teach it about suspended
> requests.
>
> Josh
>
> On Tue, Apr 12, 2011 at 4:48 AM,  <tm...@gmx.de> wrote:
> > Hello again!
> >
> > Is there any way to get the @Broadcast annotation from Atmosphere:
> >
> >
> http://atmosphere.java.net/nonav/apidocs/org/atmosphere/annotation/Broadcast.html
> >
> > working inside of a Tapestry5 page or component?
> >
> > Or are there any general, architectural restrictions why this can not
> work in Tapestry right now?
> >
> > If not, what changes would be necessary in order to be able to be able to
> use it?
> >
> > Thanks!
> >
> > Tobias
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: @Broadcast annotation

Posted by Josh Canfield <jo...@gmail.com>.
I haven't played with Atmosphere specifically, but I've played a bit
Jetty continuations, or Servlet 3's startAsync in Tapestry.

It's not a trivial integration, but I've gotten something barely
working using Jetty's Continuations. For my solution I created an
@AsyncEvent which essentially hijacks the event method and wraps it in
a Runnable that gets dumped into a threadpool. When the method
completes it resumes the continuation.

The challenge is that both the Servlet3 and Jetty Continuation (and
atmosphere from the look of it) expect you to return from your event
method when you suspend. This means that you go all they way back up
the stack to the container where it notes that you've suspended the
request and then re-issues the request when you resume. For tapestry,
this means that it thinks you're done with the request and starts
cleaning up all the injectable services that you probably still need
to finish your suspended request.

I did this all about 6 months ago and haven't had a chance to get into
the tapestry source to work out a way to teach it about suspended
requests.

Josh

On Tue, Apr 12, 2011 at 4:48 AM,  <tm...@gmx.de> wrote:
> Hello again!
>
> Is there any way to get the @Broadcast annotation from Atmosphere:
>
> http://atmosphere.java.net/nonav/apidocs/org/atmosphere/annotation/Broadcast.html
>
> working inside of a Tapestry5 page or component?
>
> Or are there any general, architectural restrictions why this can not work in Tapestry right now?
>
> If not, what changes would be necessary in order to be able to be able to use it?
>
> Thanks!
>
> Tobias
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org