You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Thiago H. de Paula Figueiredo" <th...@arsmachina.com.br> on 2010/01/05 01:46:00 UTC

Tapestry-IoC proxies

Hi!

I just had an urge to fix https://issues.apache.org/jira/browse/TAP5-335.  
My intention is to make the proxy methods have the same annotations as the  
original methods. Any advice? I'm trying to find some way to add  
annotations to a method in Javassist, but I'm still struggling. Any  
pointers?

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

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


Re: Tapestry-IoC proxies

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 06 Jan 2010 01:47:14 -0200, Howard Lewis Ship <hl...@gmail.com>  
escreveu:

> Possibly extending ServiceDef2 as ServiceDef3 which would add methods
> to give access to annotations would be a step in the right direction,

I was thinking the same.
That would solve a large number of scenarios. Nice! :)

By the way, some days ago I was reading the Weld (JSR 299 reference  
implementation) and I thought it wouldn't be hard to provide Tapestry-IoC  
as an extension. To do that, we need some way to find all the services  
(both ServiceDef and the actual object).

> though it may only be implementable in terms of standard services
> (those defined via the ServiceBinder).

Regarding services defined by build methods, maybe we could use some kind  
of delayed ServiceDef. It would have all the information when it was  
created, expect the service implementation type. It would be set when the  
object is created.

By the way, Java 6 has a proper, standard way (interface JavaCompiler) to  
compile classes programatically. I hope I have some time to play with it  
this weekend. That could be used to generate proxies without using  
Javassist. I have a good source code generation experience and I think  
that wouldn't be hard. Of course, this has a downside of requiring Java 6.

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

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


Re: Tapestry-IoC proxies

Posted by Howard Lewis Ship <hl...@gmail.com>.
Possibly extending ServiceDef2 as ServiceDef3 which would add methods
to give access to annotations would be a step in the right direction,
though it may only be implementable in terms of standard services
(those defined via the ServiceBinder).

On Tue, Jan 5, 2010 at 5:17 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> Em Tue, 05 Jan 2010 14:42:48 -0200, Howard Lewis Ship <hl...@gmail.com>
> escreveu:
>
>> I'm cautious about extending the ClassFactory/ClassFab APIs to support
>> this when my long term plan is to get away from Javassist entirely.
>
> Maybe we should create a service that centralizes all the proxy creation
> logic.
>
>> Further, I'm not sure how this will go together, because at the time
>> the IoC service proxy is created, the code does not necessarily know
>> the class that will be instantiated (especially if the service is
>> constructed using a build method, rather than via bind).
>
> I was thinking about a best effort approach. Regarding building methods, use
> whatever object it returns.
>
>> To be honest, I'd rather see an API to expose class and method
>> annotations on the core service implementation to advisors &
>> decorators.
>
> It's not my ideal solution, but it's a good solution that solves almost all
> the really important scenarios.
> Any thoughts about it? I'm really eager to have this solved. :)
>
>> And even that will have issues for the perthread
>> lifecycle (where the core service implementation is itself a proxy).
>
> If all proxies are created with the annotations of the proxied object, I
> guess this isn't an issue.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, software architect and developer, Ars Machina Tecnologia da
> Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: dev-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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


Re: Tapestry-IoC proxies

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 05 Jan 2010 14:42:48 -0200, Howard Lewis Ship <hl...@gmail.com>  
escreveu:

> I'm cautious about extending the ClassFactory/ClassFab APIs to support
> this when my long term plan is to get away from Javassist entirely.

Maybe we should create a service that centralizes all the proxy creation  
logic.

> Further, I'm not sure how this will go together, because at the time
> the IoC service proxy is created, the code does not necessarily know
> the class that will be instantiated (especially if the service is
> constructed using a build method, rather than via bind).

I was thinking about a best effort approach. Regarding building methods,  
use whatever object it returns.

> To be honest, I'd rather see an API to expose class and method
> annotations on the core service implementation to advisors &
> decorators.

It's not my ideal solution, but it's a good solution that solves almost  
all the really important scenarios.
Any thoughts about it? I'm really eager to have this solved. :)

> And even that will have issues for the perthread
> lifecycle (where the core service implementation is itself a proxy).

If all proxies are created with the annotations of the proxied object, I  
guess this isn't an issue.

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

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


Re: Tapestry-IoC proxies

Posted by Howard Lewis Ship <hl...@gmail.com>.
I'm cautious about extending the ClassFactory/ClassFab APIs to support
this when my long term plan is to get away from Javassist entirely.

Further, I'm not sure how this will go together, because at the time
the IoC service proxy is created, the code does not necessarily know
the class that will be instantiated (especially if the service is
constructed using a build method, rather than via bind).

To be honest, I'd rather see an API to expose class and method
annotations on the core service implementation to advisors &
decorators.  And even that will have issues for the perthread
lifecycle (where the core service implementation is itself a proxy).

On Mon, Jan 4, 2010 at 10:40 PM, Igor Drobiazko
<ig...@gmail.com> wrote:
> Check this out.
>
> http://www.csg.is.titech.ac.jp/~chiba/javassist/html/javassist/bytecode/AnnotationsAttribute.html
>
> On Tue, Jan 5, 2010 at 1:46 AM, Thiago H. de Paula Figueiredo <
> thiago@arsmachina.com.br> wrote:
>
>> Hi!
>>
>> I just had an urge to fix https://issues.apache.org/jira/browse/TAP5-335.
>> My intention is to make the proxy methods have the same annotations as the
>> original methods. Any advice? I'm trying to find some way to add annotations
>> to a method in Javassist, but I'm still struggling. Any pointers?
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>> and instructor
>> Owner, software architect and developer, Ars Machina Tecnologia da
>> Informação Ltda.
>> http://www.arsmachina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: dev-help@tapestry.apache.org
>>
>>
>
>
> --
> Best regards,
>
> Igor Drobiazko
> http://tapestry5.de/blog
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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


Re: Tapestry-IoC proxies

Posted by Igor Drobiazko <ig...@gmail.com>.
Check this out.

http://www.csg.is.titech.ac.jp/~chiba/javassist/html/javassist/bytecode/AnnotationsAttribute.html

On Tue, Jan 5, 2010 at 1:46 AM, Thiago H. de Paula Figueiredo <
thiago@arsmachina.com.br> wrote:

> Hi!
>
> I just had an urge to fix https://issues.apache.org/jira/browse/TAP5-335.
> My intention is to make the proxy methods have the same annotations as the
> original methods. Any advice? I'm trying to find some way to add annotations
> to a method in Javassist, but I'm still struggling. Any pointers?
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, software architect and developer, Ars Machina Tecnologia da
> Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: dev-help@tapestry.apache.org
>
>


-- 
Best regards,

Igor Drobiazko
http://tapestry5.de/blog