Welding GWT-RPC with CDI @ConversationScoped
Summary
For conversation propagation, request-parameter must have conversation-ID(cid).Although, it is difficult to modify GWT-RPC request-body.
So, I try setting cid in request-header.
As a result, conversation is able to be propageted.
Description
Environment:- Java1.8.0u60
- Wildfly10Beta2(Weld2.3.0.CR1)
- GWT(Google Web Toolkit) 2.7.0
CDI1.2 spec:
6.7.4. Conversation context lifecycleWeld doc:
The long-running conversation associated with a request may be propagated to any Servlet request via use of a request parameter named cid containing the unique identifier of the conversation.
5.3.2. Conversation propagation
We can force the conversation to propagate with a non-faces request by including the unique identifier of the conversation as a request parameter. The CDI specification reserves the request parameter named cid for this use.
Weld gets cid at ConversationContextActivator
And, we able to preprocess in Servlet Filter named "CDI Conversation Filter".
CDI1.2 spec:
6.7.4. Conversation context lifecycleThere are also described:
The container provides a filter with the name "CDI Conversation Filter", which may be mapped in web.xml, allowing the user alter when the conversation is associated with the servlet request.
- 5.3.4. CDI Conversation filter
- A.2.3. CDI Conversation Filter
- FAQ: Why does Weld set character encoding of an HTTP request/response body to ISO-8859-1?
Using custom filter, we able to create a request, not exist in request-body but providable cid.
Source shown at the beginning explain:
On GWT client side, set cid in header with RpcRequestBuilder.
On server side, define use of custom filter before CDI Conversation Fiter adaption with web.xml.
Then, provide cid in header as request parameter with HttpServletRequestWrapper.
« GWT-RPCでCDI @ConversationScoped を成立させる | トップページ | みんな本当にloggerをinjectionしたいなんて考えてるの? »
この記事へのコメントは終了しました。
« GWT-RPCでCDI @ConversationScoped を成立させる | トップページ | みんな本当にloggerをinjectionしたいなんて考えてるの? »
コメント