You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org> on 2010/10/27 23:21:48 UTC
[jira] Closed: (TAP5-799) Overriden Service Injected Into Page via
@Inject Loses Decoration
[ https://issues.apache.org/jira/browse/TAP5-799?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Howard M. Lewis Ship closed TAP5-799.
-------------------------------------
Resolution: Invalid
This is normal behavior; the object you provide to ServiceOverride is the actual replacement (not a replacement of the service implementation, but a complete replacement for the entire service, as is). More specifically, it is the object used when an injection of the indicated type occurs. The object provided is not necessarily a service. Further, the original service still exists.
What you want to do is define a replacement service, decorate it as well, inject that into your ServiceOverride contribute method and add it to the configuration.
The newly added @Contribute and @Decorate annotations will make this easier.
There is a full write-up of Tapestry's approach to injection in the new documentation.
> Overriden Service Injected Into Page via @Inject Loses Decoration
> -----------------------------------------------------------------
>
> Key: TAP5-799
> URL: https://issues.apache.org/jira/browse/TAP5-799
> Project: Tapestry 5
> Issue Type: Bug
> Components: tapestry-ioc
> Affects Versions: 5.1.0.5
> Reporter: Taylor Mathewson
>
> 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(SomeService.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;
> Workaround is cumbersome and loses the elegance of injection by type.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.