On Fri, Feb 6, 2009 at 5:29 PM, Simon Laws <[email protected]>wrote:
> > > On Wed, Feb 4, 2009 at 8:51 PM, Vamsavardhana Reddy > <[email protected]>wrote: > >> >> >> On Thu, Feb 5, 2009 at 12:33 AM, Raymond Feng <[email protected]>wrote: >> >>> Some comments inline. >>> >>> Thanks, >>> Raymond >>> >>> *From:* Vamsavardhana Reddy <[email protected]> >>> *Sent:* Wednesday, February 04, 2009 9:41 AM >>> *To:* [email protected] >>> *Subject:* Does callback support for EJB3 session beans make sense? >>> >>> As part of the Tuscany plugin for Geronimo, I was looking at providing >>> SCA services from session beans, and then started wondering if callback >>> support for session beans makes sense. Here are some questions and comments >>> I have: >>> >>> 1. If an EJB 3 business interface has an @Callback annotation on it, what >>> does it mean when this EJB is invoked as a regular EJB, say from a Servlet. >>> Does it mean that the Servlet will have to implement the callback interface? >>> What happens when the Servlet invokes the EJB as an SCA service? >>> <rfeng>I think the callback is an interaction pattern between the client >>> and the component. The client has to be an SCA component that implements the >>> callback interface. Since implementation.web doesn't support SCA services, I >>> think it cannot support callback (which is actually a service too). <rfeng> >>> >>> 2. If there is no callback is injected when the EJB is invoked as an EJB, >>> does the EJB implementation need to distinguish it is an EJB call and >>> service the request or throw an error since no callback is available? >>> >>> <rfeng>If the implementaiton.ejb component is not invoked from another >>> SCA component, there won't be context for the request which guides how the >>> callback can be made. I think it would be an error if an operation is >>> invoked from non-SCA client that requires to make an SCA callback.</rfeng> >>> >>> >>> 3. Even though the SCA JEE spec restricts that each EJB can be used as a >>> component implementation at most once, when there are more than one >>> component that has this EJB component as SCA reference target, the callbacks >>> will have to be injected differently based on the component that is invoking >>> the service. >>> >>> <rfeng>The idea is that there is context from the caller SCA component >>> which helps the runtime to decide how to callback. The same case can happen >>> for POJOs, for example PO1 and PO2 call PO3 and PO3 can call back to PO1 or >>> PO2 depending on which caller is making the call.</rfeng> >>> >> This is the situation I referred to in the other post about callback >> problem with COMPOSITE scoped implementations >> >>> >>> -- >>> Vamsi >>> >> >> >> >> -- >> Vamsi >> > > Vamsi > > I agree that it is not clear what is intended to happen when a Session Bean > that is marked as requiring @Callback is called by an SCA component that > doesn't support callbacks or a non SCA component. Neither of these problems > are specific to EJBs. Two options > > - Raise an error in the runtime > - Rely on the component implementor handling the case where a null callback > is injected > > The former sounds a more reliable approach. > > One thing I'm a little hazy on w.r.t the JEE code you have built. What > happens when a normal EJB request comes in, i.e it doesn't come in via the > SCA binding for the component for which the EJB provides and implementation. > I assume in this case the Tuscany runtime is not involved so it is very > likely that a callback annotated EJB will be called by a non-SCA client and > that the EJB will find the callback set to null. This depends on when > injection occurs. See my next point. > > On your last point about injection and the unique identification of > callback targets. What level of injection support have you implemented? Are > the beans you focus on stateless where injection happens for each request? > If this is the case then we can expect the callback to be correct for each > request. Simon, The code is injecting ComponentContext.getRequestContext().getCallback() at bean initialization. The callback injection is happening once per session bean. In case of EJB invocation through non-SCA means, this callback is null. When the service is invoked as SCA service, the first callback to be injected is used in all subsequent requests. But if ComponentContext.getRequestContext().getCallback() is used in the service method on each invocation, the correct callback target is returned. > > Simon > -- Vamsi
