- A business interface cannot be annotated with more than one access type.
- For example, an interface HelloWorld cannot have both @Local and @Remote annotations.
- If we want the bean to provide multiple client views (for eg. both Local and Remote) we need to create two interfaces HelloWorldLocal and HelloWorldRemote annotated with @Local and @Remote respectively and let the bean HelloWorldBean implement both the interfaces as shown below.
Local Client View:
import javax.ejb.Local; @Local public interface HelloWorldLocal { String sayHello(); }
Remote Client View
import javax.ejb.Remote; @Remote public interface HelloWorldRemote { String sayHello(); }
Session Bean class
import javax.ejb.Stateless; @Stateless public class HelloWorldBean implements HelloWorldLocal, HelloWorldRemote { public HelloWorldBean() { } public String sayHello() { return "Hello World !!!"; } }