You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Taylor Mathewson <ta...@gmail.com> on 2009/07/30 01:01:38 UTC

Injecting overridden Service into a page

Hi,

I have a Core Module which binds a service impl to an interface, and
decorates it (hibernate transaction decorator, and a couple of custom
things)

I have page beans which reference the service, e.g.:

@Inject
private SomeService someService;

Everything works fine up to this point.

I add in an Extension Module, which refers to the Core Module as a
submodule, and overrides the service impl, e.g.:

    public static void contributeServiceOverride(MappedConfiguration<Class,
Object> configuration, ObjectLocator locator) {
        configuration.add(OrganizationService.class,
locator.proxy(SomeService.class, ExtendedSomeServiceImpl.class));
    }

My services all get the right stuff, but the pages get the extended service
impl without any decoration.

This can be worked around by the following:
@InjectService("SomeService")
private SomeService someService;

But this an onerous change and cumbersome implementation going forward.  Is
this a bug?  The javadocs on @Inject are a little unclear.
-- 
View this message in context: http://www.nabble.com/Injecting-overridden-Service-into-a-page-tp24729662p24729662.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Injecting overridden Service into a page

Posted by Taylor Mathewson <ta...@gmail.com>.
It's a long story, but the short version is that service override is very
appropriate here, and decoration would not accomplish what is needed.

You help is much appreciated.

Cheers,
Taylor


Thiago H. de Paula Figueiredo wrote:
> 
> Em Wed, 29 Jul 2009 20:45:36 -0300, Taylor Mathewson  
> <ta...@gmail.com> escreveu:
> 
>> Hi Thiago,
>> Thanks for the lightning quick reply!
> 
> Hi!
> 
>> The services are wired together using implicit injection via constructors
>> and the pages are using the @Inject annotation, which gives an  
>> undecorated impl with a single proxy (i.e. it circumvents all the  
>> decoration).
> 
> In the meantime, why don't you use proper Tapestry-IoC service decoration  
> instead of service overriding?
> 
>> I'll log it in JIRA then.
> 
> Thanks!
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Injecting-overridden-Service-into-a-page-tp24729662p24730801.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Injecting overridden Service into a page

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 29 Jul 2009 20:45:36 -0300, Taylor Mathewson  
<ta...@gmail.com> escreveu:

> Hi Thiago,
> Thanks for the lightning quick reply!

Hi!

> The services are wired together using implicit injection via constructors
> and the pages are using the @Inject annotation, which gives an  
> undecorated impl with a single proxy (i.e. it circumvents all the  
> decoration).

In the meantime, why don't you use proper Tapestry-IoC service decoration  
instead of service overriding?

> I'll log it in JIRA then.

Thanks!

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: Injecting overridden Service into a page

Posted by Taylor Mathewson <ta...@gmail.com>.
Hi Thiago, 

Thanks for the lightning quick reply!

D'oh, that should read:

        configuration.add(SomeService.class,
locator.proxy(SomeService.class, ExtendedSomeServiceImpl.class));


The services are wired together using implicit injection via constructors
and the pages are using the @Inject annotation, which gives an undecorated
impl with a single proxy (i.e. it circumvents all the decoration).

I'll log it in JIRA then.


Thiago H. de Paula Figueiredo wrote:
> 
> Em Wed, 29 Jul 2009 20:01:38 -0300, Taylor Mathewson  
> <ta...@gmail.com> escreveu:
> 
>> Hi,
> 
> Hi!
> 
>>     public static void  
>> contributeServiceOverride(MappedConfiguration<Class,
>> Object> configuration, ObjectLocator locator) {
>>         configuration.add(OrganizationService.class,
>> locator.proxy(SomeService.class, ExtendedSomeServiceImpl.class));
>>     }
> 
> You're overriding the OrganizationService then injecting SomeService.  
> Shouldn't you override SomeService? Or inject OrganizationService?
> 
>> My services all get the right stuff, but the pages get the extended  
>> service impl without any decoration.
> 
> Are you sure? It shouldn't make any difference if a service is injected in  
> a service or in a page. Both should receive the same service, otherwise I  
> think it is a bug.
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Injecting-overridden-Service-into-a-page-tp24729662p24729996.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Injecting overridden Service into a page

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 29 Jul 2009 20:01:38 -0300, Taylor Mathewson  
<ta...@gmail.com> escreveu:

> Hi,

Hi!

>     public static void  
> contributeServiceOverride(MappedConfiguration<Class,
> Object> configuration, ObjectLocator locator) {
>         configuration.add(OrganizationService.class,
> locator.proxy(SomeService.class, ExtendedSomeServiceImpl.class));
>     }

You're overriding the OrganizationService then injecting SomeService.  
Shouldn't you override SomeService? Or inject OrganizationService?

> My services all get the right stuff, but the pages get the extended  
> service impl without any decoration.

Are you sure? It shouldn't make any difference if a service is injected in  
a service or in a page. Both should receive the same service, otherwise I  
think it is a bug.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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