Rules (from memory):
- Bean has annotation
@LocalBean bean has a view without an interface - Bean has annotation
@Local bean has a local view - Bean has annotation
@Remote bean has a remote view - A Bean does not have view annotations, but directly implements an interface that has an @Local annotation -> a bean has a local representation
- Bean does not have view annotations, but directly implements an interface that has @Remote β bean annotation, has remote viewing
- Bean does not have view annotations, but directly implements an interface that does not have view annotations -> bean has a local view
- Bean does not have view annotations and does not implement interfaces -> bean has a view without interface
So using @LocalBean and not using annotation at all are both ways to get a view without an interface. If you just need a view without an interface, then the easiest way is not to comment. If you do not implement any interfaces.
Part of the reason @LocalBean exists to add a view without an interface to the bean, which also takes the form of an interface. I believe that the script topmost in the minds of the spec authors was one that has a bean like:
@Stateless public class UserPreferences { public String getPreference(String preferenceName); public Map<String, String> getPreferences(); }
If you want to expose both methods locally, but only the getPreferences() remotely. This can be done by declaring the remote interface with this particular method, and then simply pressing @LocalBean in the bean class. Without this, you would have to write a meaningless local interface to expose both methods locally.
Or, to look at it differently, @LocalBean exists, because there is such a thing as a view without an interface, and the no-annotation option exists as a convenient shortcut.
Tom Anderson Jun 05 '12 at 11:22 2012-06-05 11:22
source share