ejb3.1中引用的获得使用了依赖注入
@EJB注解的六个参数都是可选的
name 元素由于绑定到注入的EJB的JNDI名称
beanInterface 用于访问EJB的业务接口
beanName 如果多个EJB实现同一个业务接口,那么beanName元素允许我们表示此业务接口
lookup 全局 JNDI 名称
description
mappedName
1.Interface View(接口视图)
2.No-Interface View(非接口视图)
@EJB注解的六个参数都是可选的
name 元素由于绑定到注入的EJB的JNDI名称
beanInterface 用于访问EJB的业务接口
beanName 如果多个EJB实现同一个业务接口,那么beanName元素允许我们表示此业务接口
lookup 全局 JNDI 名称
description
mappedName
1.Interface View(接口视图)
public interface JpaOperations {};
@Stateless
public class JpaTemplate extends JpaAccessor implements JpaOperations {};
@Stateful
public class GpsTelSessionBean{
/**
* Interface view 必须使用接口进行注入,不能使用实现类进行注入,否则会抛出
* EntityBean未找到异常.
* @EJB
* private JpaOperations jpatemp;
* or
* @EJB(lookup="java:global/kkxt-war/kkxt/JpaTemplate")
* private JpaOperations jpatemp;
*/
@EJB
private JpaOperations jpa;
};
2.No-Interface View(非接口视图)
@Stateless
public class JpaTemplate extends JpaAccessor{};
@Stateful
public class GpsTelSessionBean{
/**
* No-Interface view
* @EJB
* private JpaTemplate jpatemp;
* or
* @EJB(lookup="java:global/kkxt-war/kkxt/JpaTemplate")
* private JpaTemplate jpatemp;
*/
@EJB
private JpaTemplate jpatemp;
};