EJB bean可以实现多个接口吗? [英] Can an EJB bean implement multiple interfaces?
问题描述
EJB bean是否可以实现多个用户定义的接口,业务接口(@ Local,@ Remote)或No-Interface视图(@LocalBean)除外?
Can an EJB bean implement multiple user defined interfaces, except business interfaces (@Local, @Remote) or No-Interface view (@LocalBean)?
例如定义两个接口 UserInterface1
, UserInterface2
,没有注释。
For example define two interfaces UserInterface1
, UserInterface2
, with no annotation.
这是合法的实现:
@Stateless
public class MyBean implements UserInterface1, UserInterface2 { ...
然后我又有另一种困惑:
Then I have another confusion:
@Stateless
public class MyBean implements Runnable { ...
//inside I won't try to manage thread
}
这是合法的还是非法的,我发现glassfish支持这种情况。
Is this legal or illegal, I found that glassfish support this situation.
推荐答案
给出的示例是非法的,但仍被相当一些实现(应用程序服务器)接受。
The given example is illegal, but nevertheless accepted by quite some implementations (application servers).
David Blevins开始一个关于的线程,不久前在EJB邮件列表上。
David Blevins started a thread about this on the EJB mailing list a while ago.
EJB 3.2将使该主题的规则更加清晰。请参阅 EJB 3.2中有哪些新功能? - Java EE 7继续!(查找简化规则以定义bean的所有本地/远程视图)
EJB 3.2 will make the rules more clear for this topic. See What's new in EJB 3.2 ? - Java EE 7 chugging along! (look for section Simplified the rules to define all local/remote views of the bean)
这篇关于EJB bean可以实现多个接口吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!