Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
347 views
in Technique[技术] by (71.8m points)

java - Can an EJB bean implement multiple interfaces?

Can an EJB bean implement multiple user defined interfaces, except business interfaces (@Local, @Remote) or No-Interface view (@LocalBean)?

For example define two interfaces UserInterface1, UserInterface2, with no annotation.

Is this legal to implement:

@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
}

Is this legal or illegal, I found that glassfish support this situation.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The given example is illegal, but nevertheless accepted by quite some implementations (application servers).

David Blevins started a thread about this on the EJB mailing list a while ago.

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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...