ejb-3.1java-ee-7ejb-3.2

The client must not make any assumptions regarding the internal implementation


the full sentence taken from the EJB3.2 specifications:

When interacting with a reference to the no-interface view, the client must not make any assumptions regarding the internal implementation of the reference, such as any instance-specific state that may be present in the reference

I'm actually trying to understand what that actually mean and I was wondering if someone could kindly provide some examples.

EDIT:
The Above sentence is take from Section 3.4.4 Session Bean’s No-Interface View, maybe this info is helpful


Solution

  • When generating a no-interface view proxy, the EJB container must create a subclass of the EJB class and override all public methods to provide proxying behavior (like security, transactions).

    You can get a reference to the bean with (eg. for passing 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 class itself (normally if the EJB has a business interface it would return the interface class), but it is not a reference to an instance of NoInterfaceBean (but to that proxy class with the same name). Think of it as a reference to a pimped version of your bean, about which you

    must not make any assumptions regarding the internal implementation

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

    So the specification emphasizes this difference at that point. Even if it looks like a reference to your concrete class it is none (as they say in the next paragraph of the specification JSR-000345 Enterprise JavaBeansTM 3.2 Final Release:

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