質問

I'm new in EJB & persistence at all, so excuse me please if I'll ask a stupid question. I read a book about EJB and JPA, and faces phrase that I don't understand at all:

Intended to fully insulate developers from dealing directly with persistence, it (EJB) introduced an interface-based approach, where the concrete bean class was never directly used by client code. Instead, a specialized bean compiler generated an implementation of the bean interface to facilitate such things as persistence, security, and transaction management, delegating the business logic to the entity bean implementation.

and

The notion of container-managed entity beans was introduced, where bean classes became abstract and the server was responsible for generating a subclass to manage the persistent data.

What does it mean:

  1. Specialized bean compiler generated an implementation of the bean interface

  2. server was responsible for generating a subclass to manage the persistent data Actually I can't grasp what mean generate implementation/subclass, does it mean in runtime?

Thank you in advance.

EDITED:

Finally, entity beans were modeled as remote objects that used RMI and CORBA, introducing network overhead and restrictions that should never have been added to a persistent object to begin with.

Does it also sink into nothingness?

役に立ちましたか?

解決

1) Interfaces: To define a bean, you had to declare a Local interface and a Remote interface (if you were writting bean MyEJB, they had to be MyEJBLocal and MyEJBRemote; MyEJB would implement both). With that, the compiler generated some derived class implementing the methods, such methods would just connect to the EJB server to retrieve a bean and execute its methods.

I am not so sure about 2, since we had so many performance issues that we ended implementing JDBC logic in the Session beans (I know, I know)...

他のヒント

  1. Specialized Bean: Since Java EE 5, EJB turn into annotation @EJB. All annotaion works like interface. This simple annotaion provide security, and transaction management, delegating the business logic at compile time.

  2. JPA: No more entity bean remain since Java EE 5. Now if you put @Entity to on pojo than server will generate container-managed entity beans and communicate with database through persistance context.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top