You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Aleksandar Nikolov <ma...@anikolov.com> on 2014/12/18 00:40:34 UTC

ServiceOverride help wanted

Hi,

I need to override the original HibernateSessionSourceImpl service with 
a modification of mine - MyHibernateSessionSourceImpl. It is 5.3.8 version.

I followed the instructions in 
http://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.html
and replace the example code:

@Contribute(ServiceOverride.class)
public static void 
setupApplicationServiceOverrides(MappedConfiguration<Class,Object> 
configuration)
{
   configuration.addInstance(SomeServiceType.class, 
SomeServiceTypeOverrideImpl.class);
}

with mine:

     @Contribute(ServiceOverride.class)
     public static void 
setupApplicationServiceOverrides(MappedConfiguration<Class<?>, Object> 
configuration) {
         configuration.addInstance(HibernateSessionSource.class, 
MyHibernateSessionSourceImpl.class);
     }

But it throws:

java.lang.RuntimeException: Error invoking service contribution method 
com.mypack.services.AppModule.setupApplicationServiceOverrides(MappedConfiguration): 
Error invoking service contribution method 
org.apache.tapestry5.services.TapestryModule.productionModeOverrides(MappedConfiguration, 
boolean): Service 'ServiceOverride' is configured using 
org.apache.tapestry5.ioc.OrderedConfiguration, not 
org.apache.tapestry5.ioc.MappedConfiguration.


So I changed MappedConfiguration to OrderedConfiguration:

     @Contribute(ServiceOverride.class)
     public static void 
setupApplicationServiceOverrides(OrderedConfiguration<HibernateSessionSource> 
configuration) {
         configuration.addInstance("Default", 
MyHibernateSessionSourceImpl.class);
     }

But it throws:

java.lang.RuntimeException: Error invoking service contribution method 
com.mypack.services.AppModule.setupApplicationServiceOverrides(OrderedConfiguration): 
Service 'ServiceOverride' is configured using 
org.apache.tapestry5.ioc.MappedConfiguration, not 
org.apache.tapestry5.ioc.OrderedConfiguration.

It looks like Catch-22.

So, what is the proper way to override a service implementation?

-- 
Best regards,
Aleksandar

Re: ServiceOverride help wanted

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
There's documentation for that:  
http://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.html

On Sat, 03 Jan 2015 13:38:18 -0200, Dimitris Zenios  
<di...@gmail.com> wrote:

> This is the way i do it and it works
>
> @Contribute(ServiceOverride.class)
> public static void
> setupApplicationServiceOverrides(MappedConfiguration<Class,Object>
> configuration,@Local WebSecurityManager customAuthenticator)
> {
> configuration.add(WebSecurityManager.class, customAuthenticator);
> }
>
> On Sat, Jan 3, 2015 at 1:02 PM, Aleksandar Nikolov <ma...@anikolov.com>
> wrote:
>
>> Hi,
>>
>> Does anybody know how to override a service in Tapestry 5.3.8?
>>
>> I don't want to use the back door - copy&paste&change the original  
>> source
>> in the original location and thus force the webserver to use the  
>> modified
>> class rather than the original one.
>>
>> --
>> Best regards,
>> Aleksandar
>>


-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: ServiceOverride help wanted

Posted by Dimitris Zenios <di...@gmail.com>.
This is the way i do it and it works

@Contribute(ServiceOverride.class)
public static void
setupApplicationServiceOverrides(MappedConfiguration<Class,Object>
configuration,@Local WebSecurityManager customAuthenticator)
{
configuration.add(WebSecurityManager.class, customAuthenticator);
}

On Sat, Jan 3, 2015 at 1:02 PM, Aleksandar Nikolov <ma...@anikolov.com>
wrote:

> Hi,
>
> Does anybody know how to override a service in Tapestry 5.3.8?
>
> I don't want to use the back door - copy&paste&change the original source
> in the original location and thus force the webserver to use the modified
> class rather than the original one.
>
> --
> Best regards,
> Aleksandar
>

Re: ServiceOverride help wanted

Posted by Aleksandar Nikolov <ma...@anikolov.com>.
Hi,

Does anybody know how to override a service in Tapestry 5.3.8?

I don't want to use the back door - copy&paste&change the original 
source in the original location and thus force the webserver to use the 
modified class rather than the original one.

-- 
Best regards,
Aleksandar