The client should not make any assumptions about the internal implementation

a complete sentence taken from the EJB3.2 specs:

When interacting with a link to a view without an interface, the client should not make any assumptions about the internal implementation of the link, such as any particular concrete state that might be present in the link

I'm actually trying to figure out what this means, and I was wondering if anyone could suggest some examples.

EDIT :
The above suggestion is taken from 3.4.4 Session Bean s No-Interface View, maybe this info is helpful

+3


source to share


1 answer


When creating a proxy server without an interface, the EJB container must subclass the EJB class and override all public methods to provide proxy behavior (eg security, transactions).

You can get a reference to the bean from (for example, to pass it to another ejb):

NoInterfaceBean bean = ejbContext.getBusinessObject(NoInterfaceBean.class);

      

This returns a reference with a class type that is the same as the bean (usually if the EJB has a business interface, it returns an interface class), but it is not a reference to the NoInterfaceBean instance (but for that proxy class with the same name). Think of it as a link to the pimp version of your bean that you



no assumptions should be made about the internal implementation

This is basically the same with "normal" EJBs. You know there is some magic around your bean instance, but since you get the interface as a class type, it is already clear that every class that implements the interface can have a different internal implementation.

Thus, the specification highlights this difference at this point. Even if it looks like a reference to your specific class, it is not (as the next paragraph of the JSR-000345 Enterprise JavaBeansTM 3.2 Final Release spec says :

Although the referenced object is type compatible with the corresponding bean class type, there is no prescribed dependency between the internal implementation of the reference and the implementation of the bean instance.

+1


source







All Articles