You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by rektide <re...@voodoowarez.com> on 2011/03/04 18:40:54 UTC

Advising a Scope PerThread Services with Context

Hello everyone.  I'm new here, so let me just say hello.  I'm rektide, I've been using
Tapestry 5.1 since July 2010.  Been mostly great, with the main caveat being trying to
figure out how to coax my app into having enough context when I run Ajax requests.  The
component model is awesome, the IOC engine works great, the JS integration is like nothing
I've seen & has proved time & time again quite flexible.  Good stuff, thanks all.

At present, I'm trying to build a MethodAdvice implementation that modifies the behavior 
of a PerThread Scope'd service.  The MethodAdvice needs access to the public members of the
Service to perform this advising.

I cant find any way to get the Service instance from inside the MethodAdvice.

The module that fires the MethodAdviceReceiver can be injected in to, but this is a one time
initialization action: it rebuild the MethodAdvice per-request.  I've tried various
injection annotations in the MethodAdvice itself, but havent had any luck.  Is there some
programatic means of requesting a Service that I can run inside the MethodAdvice to pull out
the current instance of my Service?

As a note, it would be awfully handy if Invocation had a getThis() method!  Or if the
advise method had a second parameter to provide that context!

Any suggestions for now, on how to get the Service being advised from within the
MethodAdvisor?

Regards & thanks,
-rektide

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


Re: Advising a Scope PerThread Services with Context

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 04 Mar 2011 14:40:54 -0300, rektide <re...@voodoowarez.com>  
wrote:

> At present, I'm trying to build a MethodAdvice implementation that  
> modifies the behavior of a PerThread Scope'd service.

The fact that your service has perthread scope shouldn't change anything.

> The MethodAdvice needs access to the public members of the Service to  
> perform this advising.

What do you mean by public members? Fields? Methods in the service  
interface? Methods not in the service interface?
You shouldn't rely in anything outside methods defined in the service  
interface.

> The module that fires the MethodAdviceReceiver can be injected in to,  
> but this is a one time initialization action: it rebuild the  
> MethodAdvice per-request.  I've tried various
> injection annotations in the MethodAdvice itself, but havent had any  
> luck.  Is there some
> programatic means of requesting a Service that I can run inside the  
> MethodAdvice to pull out
> the current instance of my Service?

Any service, including per-threads one, is accessed through a proxy. The  
the service is per-thread, the proxy will delegate method calls to the  
appropriate instance.

Have you tried decoration instead of advising?

-- 
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