Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The rules are (from memory):</p> <ol> <li>Bean has a <code>@LocalBean</code> annotation -> bean has a no-interface view</li> <li>Bean has a <code>@Local</code> annotation -> bean has a local view</li> <li>Bean has a <code>@Remote</code> annotation -> bean has a remote view</li> <li>Bean has no view annotations, but directly implements an interface which has a @Local annotation -> bean has a local view</li> <li>Bean has no view annotations, but directly implements an interface which has a @Remote annotation -> bean has a remote view</li> <li>Bean has no view annotations, but directly implements an interface which has no view annotations -> bean has a local view</li> <li>Bean has no view annotations, and implements no interfaces -> bean has a no-interface view</li> </ol> <p>So, using <code>@LocalBean</code> and using no annotation at all are both ways of getting a no-interface view. If you just want a no-interface view, then the simplest thing is not to annotate. Provided you're not also implementing any interfaces.</p> <p>Part of the reason <code>@LocalBean</code> exists to add a no-interface view to a bean which also has an interface view. I imagine the scenario uppermost in the spec authors' minds was one where you have a bean like:</p> <pre><code>@Stateless public class UserPreferences { public String getPreference(String preferenceName); public Map&lt;String, String&gt; getPreferences(); } </code></pre> <p>Where you would want to expose both methods locally, but only the coarser-grained <code>getPreferences()</code> remotely. You can do that by declaring a remote interface with just that method, then just slapping <code>@LocalBean</code> on the bean class. Without it, you'd have to write a pointless local interface just to expose both methods locally.</p> <p>Or, to look at it another way, the <code>@LocalBean</code> exists because there is such a thing as a no-interface view, and the no-annotation option exists as a handy shortcut.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload