Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Liferay hook CDI_Liferay_Hook_Cdi - Fatal编程技术网

Liferay hook CDI

Liferay hook CDI,liferay,hook,cdi,Liferay,Hook,Cdi,我正在为Liferay开发一个服务钩子,我想使用一个外部EJB为我完成业务逻辑。有没有办法将bean注入服务类 这是我的密码: public class MyUserService extends UserServiceWrapper { //I want a bean injected @Inject MyBean myBean; public MyUserService(UserService userService) { super(us

我正在为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;
    }
}

有没有办法做到这一点

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

Object bean = com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate(
       "bean id", "class")
这就是你要找的吗