在POJO的使用依赖注入注入EJB的 [英] Using Dependency Injection in POJO's to inject EJB's

查看:252
本文介绍了在POJO的使用依赖注入注入EJB的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能注入EJB的POJO到的使用@EJB注解?
如果是,我是否设立任何特殊一个JBoss服务器上,使其工作?

Is it possible to inject ejb's into pojo's using the @EJB annotation? If it is, do I have to set up anything special on a JBoss server to make it work?

请让我们不讨论这样做背后的理由 - 我只是想破解一些老code,使其工作: - )

Please let us not discuss the rationale behind doing this - I am just trying to hack some old code to make it work :-)

推荐答案

是的,如果你可以让JBoss的创建POJO你。

Yes, if you can make JBoss create the Pojo for you.

您的问题是,你可能称之为来创建POJO和框架无法截获此这就是为什么@EJB被忽略。

Your problem is that you probably call new to create the Pojo and the framework can't intercept this which is why @EJB is ignored.

该解决方案是使用一个工厂来创建你的POJO和告诉工厂对EJB的,所以它可以返回新POJO的面前。

The solution is to use a factory to create your Pojos and tell the factory about the EJBs, so it can set them before returning the new Pojo.

这篇关于在POJO的使用依赖注入注入EJB的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆