Hello
I have a customer who sent me a pair of applications with the following
behaviour (see also the attached flow diagram):
- A request is sent to a REST
resource in Application A
- The endpoint makes a RMI call
to ServiceB in Application B
- ServiceB makes an RMI to ServiceA
in Application A
- ServiceA makes an RMI to ServiceB
in Application B
- ServiceB calls back to the rest
resource.
A @RequestScoped bean is
injected into the REST Resource and Service A.
The customer has noticed the same instance of that bean is injected into
both injection points. They believe the two should be separate request
scoped contexts.
The CDI spec says the request context
is alive :
- during the service() method of any servlet
in the web application, during the doFilter() method of any servlet filter
and when the container calls any ServletRequestListener or AsyncListener,
- during any remote method invocation
of any EJB, during any asynchronous method invocation of any EJB, during
any call to an EJB timeout method and during message delivery to any EJB
message-driven bean, and
But it is not clear what
happens if a remote method invocation is nested inside a service() method.
Is that a separate request context or the same as the parent?
If they are seperate contexts, I notice that WeldInitialListener.requestInitialized
requires a ServletRequestEvent, which would be tricky to acquire as part
of processing an EJB remote method invocation. Would I need to find a way
to access a ServletRequestEvent when creating the request context for a
RMI?
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number
741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU