简体   繁体   中英

What is the purpose of home/remote interfaces EJB 3.1

I have recently started reading about Java EE6 and in the examples I follow I need to make remote interface. What is the purpose of this? I also read about home interfaces, but I don't understand. I have never done enterprise programming before so I can't relate it to something else either. Could someone explain me these interfaces?

Basically by declaring the @Local @Remote interfaces you specify which methods should be available for the remote clients and which for the local beans in the same JVM. Home interface is used to allow a remote client to create, find, and remove EJB objects.

You can easily find that information on the official documentation pages, for example for EJBHome , or nice overview for local and remote here

I highly recommend reading EJB book by Bill Burke, Richard Monson-Haefel for starters.

Every Session bean has to implement Interface and Bean Class. When User requests then JNDI helps to lookup which Interface is required for that Request. When your EJBs are deployed in same EAR then you should prefer Local Interface.

If EJBs are in same EAR then Remote Interface should be used.

This Interface will call business logic which resides in Bean Class. Home Interface creates and finds EJB objects for Remote Interface. So first you should create Home Interface with create method and then Remote Interface.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM