EJB 2.0 VS EJB 3.0

Nag*_*ran 3 java ejb java-ee ejb-3.0 ejb-2.x

在EJB 2.0中,我们有Home接口和Component接口.但是在EJB 3.0中我们没有这些接口(而是我们有注释).我怀疑的是,如果我们没有那些接口,那么谁在EJB 3.0中工作,以及实现和工作(调用和被调用者)程序如何改变?

Hei*_*upp 5

在EJB 3中,您不再需要home接口,因为容器在使用@EJB注释时直接注入bean

@EJB
MyLocalInterface bean1;

@EJB
OtherRemoteInterface bean2;

String foo = bean1.doSomething();
String bar = bean2.soSomethingElse();
Run Code Online (Sandbox Code Playgroud)