Hi,

this is unfortunate and I have a fix for it, but a hackish one. The injected
Request is a proxy, so you can do this:

create empty container service, and inject it to the baseurlresource (just
like the request earlier.) Add setter to your container service for the
request, and contribute startupservice with a code piece that injects the
request and your container service, and then just putthe request to your
container service's setter, and then it will be there when the first request
comes in. This works because the injected request is actually a proxy, and
not an actual request. Haven't tried that though, so no guarantees. Note
that the container service must NOT declare the request in the constructor.

Docs to add startup code: http://tapestry.apache.org/registry-startup.html 

Ville
Ps. If anyone has better fix for this, please share as I'm interested too.

-----Alkuperäinen viesti-----
Lähettäjä: Andy Pahne [mailto:li...@bodenkurier.de] 
Lähetetty: 22. syyskuuta 2013 21:43
Vastaanottaja: Tapestry users
Aihe: Re: BaseURLSource with access to current request


No, that does not work. When I try to inject the Request object as a method
parameter, the application won't start. An Exception is thrown on startup:
2013-09-22 20:40:30,689 ERROR ServiceOverride:64 - Construction of service
ServiceOverride failed: Error invoking service contribution method
de.bodenkurier.web.site.services.AppModule.contributeServiceOverride(MappedC
onfiguration, Request): Exception constructing service 'ServiceOverride':
Construction of service 'ServiceOverride' has failed due to recursion: the
service depends on itself in some way. Please check
org.apache.tapestry5.ioc.internal.services.ServiceOverrideImpl(Map) (at
ServiceOverrideImpl.java:31) via
org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at
TapestryIOCModule.java:49) for references to another service that is itself
dependent on service 'ServiceOverride'.
…
...


Am 22.09.2013 um 20:05 schrieb "Ville Virtanen"
<ville.virta...@orientimport.fi>:

> 
>    public static void contributeServiceOverride(final 
> MappedConfiguration<Class,Object> configuration, final Request request) {
>        BaseURLSource source = new  BaseURLSource()
>    {
>         ...
>    
>        configuration.add(BaseURLSource.class, source);
>    }
> 
> Ville


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



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

Reply via email to