MessageDrivenBeans 抽象父类中的 @Resource-annotation?
这是可以的
@MessageDriven(...)
public class EventMDB implements MessageListener
{
@Resource
private MessageDrivenContext context;
//onMessage(Message)
...
,但是如果我将资源注释放在抽象父类中,它也可以工作吗?
@MessageDriven(...)
public class EventMDB extend ParentMDB
{
//onEvent(Event)
...
和
public abstract class ParentMDB implements MessageListener
{
@Resource
protected MessageDrivenContext context;
//onMessage(Message) retrieves object of ObjectMessage and invokes onEvent(Event)
//abstract void onEvent(Event)
...
this is ok
@MessageDriven(...)
public class EventMDB implements MessageListener
{
@Resource
private MessageDrivenContext context;
//onMessage(Message)
...
but does it also work, if i put the resource annotation in an abstract parent class?
@MessageDriven(...)
public class EventMDB extend ParentMDB
{
//onEvent(Event)
...
with
public abstract class ParentMDB implements MessageListener
{
@Resource
protected MessageDrivenContext context;
//onMessage(Message) retrieves object of ObjectMessage and invokes onEvent(Event)
//abstract void onEvent(Event)
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不明白为什么它不起作用(Java EE API ):
您是否有一个不起作用的用例,或者您只是在考虑“假设”?
I can't see why it wouldn't work (Java EE API):
Do you have a use case when it doesn't work, or are you just contemplating the "what-ifs"?