Override an IoC service

View: New views
6 Messages — Rating Filter:   Alert me  

Override an IoC service

by P.Stavrinides :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have recently introduced a multiple IoC module structure into my web applications, so I have a core web module and then application specific modules separately, and now I am getting the following error:
ERROR - Service interface com.albourne.web.interfaces.ISiteError is matched by 2 services: CoreError, SiteError.

I have introduced these changes mostly for testing purposes... its not a big problem as I can simply remove the offending service from the shared core and provide an implementation of it in each application specific module, but it got me wandering about this issue on a larger scale, is it possible to override a service? if not would such a feature be useful? How do others deal with this, using service decoration potentially?

Kind regards,
Peter




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


Re: Override an IoC service

by Thiago H. de Paula Figueiredo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jun 29, 2009 at 9:17 AM, Peter
Stavrinides<P.Stavrinides@...> wrote:
> Hi,

Hi!

> I have introduced these changes mostly for testing purposes... its not a big problem as I can simply remove the offending service from the shared core and
> provide an implementation of it in each application specific module, but it got me wandering about this issue on a larger scale, is it possible to override a
> service? if not would such a feature be useful? How do others deal with this, using service decoration potentially?

Yes, you can override services:
http://tapestry.apache.org/tapestry5.1/tapestry-ioc/cookbook/override.html.

--
Thiago

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


Re: Override an IoC service

by P.Stavrinides :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Brilliant!

Thanks
Peter


----- Original Message -----
From: "Thiago H. de Paula Figueiredo" <thiagohp@...>
To: "Tapestry users" <users@...>
Sent: Monday, 29 June, 2009 15:20:26 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: Re: Override an IoC service

On Mon, Jun 29, 2009 at 9:17 AM, Peter
Stavrinides<P.Stavrinides@...> wrote:
> Hi,

Hi!

> I have introduced these changes mostly for testing purposes... its not a big problem as I can simply remove the offending service from the shared core and
> provide an implementation of it in each application specific module, but it got me wandering about this issue on a larger scale, is it possible to override a
> service? if not would such a feature be useful? How do others deal with this, using service decoration potentially?

Yes, you can override services:
http://tapestry.apache.org/tapestry5.1/tapestry-ioc/cookbook/override.html.

--
Thiago

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


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


Parent Message unknown Re: Override an IoC service

by nille hammer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Peter,

Isn't this a question of  disambiguation of Services either with ids or with the@Local annotation as described here: http://tapestry.apache.org/tapestry5.1/tapestry-ioc/service.html ? Or did I get lost somewhere?

Regards, nillehammer

==
http://www.winfonet.eu

----- original Nachricht --------

Betreff: Override an IoC service
Gesendet: Mo, 29. Jun 2009
Von: Peter Stavrinides<P.Stavrinides@...>

> Hi,
>
> I have recently introduced a multiple IoC module structure into my web
> applications, so I have a core web module and then application specific
> modules separately, and now I am getting the following error:
> ERROR - Service interface com.albourne.web.interfaces.ISiteError is matched
> by 2 services: CoreError, SiteError.
>
> I have introduced these changes mostly for testing purposes... its not a big
> problem as I can simply remove the offending service from the shared core
> and provide an implementation of it in each application specific module, but
> it got me wandering about this issue on a larger scale, is it possible to
> override a service? if not would such a feature be useful? How do others
> deal with this, using service decoration potentially?
>
> Kind regards,
> Peter
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

--- original Nachricht Ende ----


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


Parent Message unknown Re: Override an IoC service

by P.Stavrinides :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi nillehammer,

> Isn't this a question of  disambiguation of Services either with ids or with the @Local annotation as described here: http://tapestry.apache.org/tapestry5.1/tapestry-
> ioc/service.html ? Or did I get lost somewhere?
I am not sure to be perfectly honest, looking through that link I guess there may have been a case... in my situation Thiagos solution is perfect because I use a generic error handling service that is configured in the shared core module and is reused without change by many applications, but in one particular application I have to extend this service to override some of the handling... so far as I know I could do this either by:
- decorating the service
- not bind it in the shared core module, and then binding it each applications AppModule (my solution before)
- Or implement the override (Thiagos suggestion), which I have now done

But perhaps I could have done it that way as well?

regards,
Peter

----- Original Message -----
From: "nille hammer" <tapestry.nillehammer@...>
To: "Tapestry users" <users@...>
Sent: Monday, 29 June, 2009 15:31:04 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: Re: Override an IoC service

Hi Peter,

Isn't this a question of  disambiguation of Services either with ids or with the@Local annotation as described here: http://tapestry.apache.org/tapestry5.1/tapestry-ioc/service.html ? Or did I get lost somewhere?

Regards, nillehammer

==
http://www.winfonet.eu

----- original Nachricht --------

Betreff: Override an IoC service
Gesendet: Mo, 29. Jun 2009
Von: Peter Stavrinides<P.Stavrinides@...>

> Hi,
>
> I have recently introduced a multiple IoC module structure into my web
> applications, so I have a core web module and then application specific
> modules separately, and now I am getting the following error:
> ERROR - Service interface com.albourne.web.interfaces.ISiteError is matched
> by 2 services: CoreError, SiteError.
>
> I have introduced these changes mostly for testing purposes... its not a big
> problem as I can simply remove the offending service from the shared core
> and provide an implementation of it in each application specific module, but
> it got me wandering about this issue on a larger scale, is it possible to
> override a service? if not would such a feature be useful? How do others
> deal with this, using service decoration potentially?
>
> Kind regards,
> Peter
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

--- original Nachricht Ende ----


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


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


Re: Override an IoC service

by Thiago H. de Paula Figueiredo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think that, in your scenario, service overriding is the best option,
decoration being second (but a little more complicated to implement).

--
Thiago

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