【问题标题】:Liferay hook CDILiferay 挂钩 CDI
【发布时间】:2014-04-10 21:08:53
【问题描述】:

我正在为 Liferay 开发一个服务挂钩,并且我想使用一个外部 EJB 来为我执行业务逻辑。有没有办法将 bean 注入服务类?

这是我的代码:

public class MyUserService extends UserServiceWrapper {

    //I want a bean injected
    @Inject
    MyBean myBean;

    public MyUserService(UserService userService) {
        super(userService);
    }

    @Override
    public User addUserWithWorkflow(/* all kind of parameters */)
            throws PortalException, SystemException {
        User user = super.addUserWithWorkflow(/* all parameters passes here //);

        //do my business logic here
        myBean.userRegistered(user);

        return user;
    }
}

有没有办法做到这一点?

【问题讨论】:

    标签: liferay hook cdi


    【解决方案1】:

    如果 bean 已经加载到 AppContext 中(使用 hook-spring.xml 文件),您可以使用

    Object bean = com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate(
           "bean id", "class")
    

    这就是你要找的吗?

    【讨论】:

      猜你喜欢
      • 2014-01-26
      • 2016-10-01
      • 2015-10-20
      • 1970-01-01
      • 1970-01-01
      • 2012-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多