So I've ended up with the following implementation:
@Contribute(HttpServletRequestHandler.class)
public void contributeHttpServletRequestHandler (
OrderedConfiguration<HttpServletRequestFilter> configuration,
@Inject @Symbol(ResteasySymbols.MAPPING_PREFIX) final String
restFilterPath,
@Inject @Symbol(SymbolConstants.CHARSET) final String
applicationCharset,
@Primary final SessionPersistedObjectAnalyzer<?> analyzer,
final RequestGlobals requestGlobals ) {
HttpServletRequestFilter storeRestSession =
newHttpServletRequestFilter () {
public boolean service ( HttpServletRequest servletRequest,
HttpServletResponse servletResponse,
HttpServletRequestHandler handler ) throws IOException {
if ( servletRequest.getServletPath ().startsWith (
restFilterPath + "/" ) ) {
Request request = new RequestImpl ( servletRequest,
applicationCharset, new TapestrySessionFactoryImpl ( false, analyzer,
servletRequest ) );
Response response = new ResponseImpl ( servletRequest,
servletResponse );
requestGlobals.storeRequestResponse ( request, response
);
}
return handler.service ( servletRequest, servletResponse );
}
};
configuration.add("StoreRestSession", storeRestSession,
"before:ResteasyRequestFilter");
}
Probably it's possible to achieve the same goal by overriding RestEasy
request filter.
On Fri, Jan 24, 2014 at 11:07 PM, Ilya Obshadko <[email protected]>wrote:
> Just run into this thread with a similar problem. I'm implementing REST
> service (using tapestry-resteasy) for mobile clients.
>
> I've already found a solution:
>
> public void contributeHttpServletRequestHandler (
> OrderedConfiguration<HttpServletRequestFilter> configuration,
>
> @Inject @Symbol(SymbolConstants.CHARSET) final String
> applicationCharset,
>
> @Primary final SessionPersistedObjectAnalyzer<?> analyzer,
>
> final RequestGlobals requestGlobals ) {
>
>
> HttpServletRequestFilter storeRequestResponse =
> newHttpServletRequestFilter () {
>
> public boolean service ( HttpServletRequest servletRequest,
> HttpServletResponse servletResponse,
>
> HttpServletRequestHandler handler ) throwsIOException {
>
>
>
> Request request = new RequestImpl ( servletRequest,
> applicationCharset, new TapestrySessionFactoryImpl ( false, analyzer,
> servletRequest ) );
>
> Response response = new ResponseImpl ( servletRequest,
> servletResponse );
>
> requestGlobals.storeRequestResponse ( request, response );
>
> return handler.service ( servletRequest, servletResponse
> );
>
> }
>
> };
>
>
> configuration.add("StoreRequestResponse", storeRequestResponse,
> "before:*");
>
> }
>
> But it doesn't look very elegant. Is there any better way to expose
> ApplicationStateManager to RestEasy service?
>
>
>
> On Fri, Jun 28, 2013 at 12:04 PM, Thiago H de Paula Figueiredo <
> [email protected]> wrote:
>
>> On Thu, 27 Jun 2013 19:46:20 -0300, Jon Williams <
>> [email protected]> wrote:
>>
>> Hi,
>>>
>>
>> Hi!
>>
>> My problem has gone away.
>>> A short FYI on how I got past this problem...
>>>
>>> First I tried adding a new request Builder method in QaModule using the
>>> shadowbuilder service that would build my TestRequest. But that didn't
>>> work because of a Request service implementation collision with predeclared
>>> (in TapModule) service Request.class interface implementation. Only 1
>>> Request
>>> interface implementation is allowed, and TapModule beats me to the punch.
>>>
>>
>> You've already found a very good solution, but I'd like to mention you
>> could also use service overriding, so your Request implementation is used
>> and not Tapestry's.
>>
>>
>> --
>> Thiago H. de Paula Figueiredo
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>>
>> For additional commands, e-mail: [email protected]
>>
>>
>
>
> --
> Ilya Obshadko
>
>
--
Ilya Obshadko