5 Replies Latest reply on Aug 1, 2006 5:36 PM by lhoriman

    @Local and @Remote version of the same interface?

      The calculator example in the tutorial looks like this:

      public interface Calculator
      {
       ...
      }
      
      @Local public interface CalculatorLocal extends Calculator {}
      
      @Remote public interface CalculatorRemote extends Calculator {}
      
      @Stateless public class CalculatorBean implements CalculatorLocal, CalculatorRemote
      {
       ...
      }
      


      The idea being, as a client, you choose whether or not to use the Local or Remote version of the interface.

      Why would you ever want a bean with identical Local and Remote interfaces?

      I understand why you might want a bean with a Local interface only to prevent access from outside the JVM. But since JBoss optimizes a Remote call when in-process, what advantage does the above example have over:

      @Remote public interface Calculator
      {
       ...
      }
      
      @Stateless public class CalculatorBean implements Calculator
      {
       ...
      }
      


      ?

      If there is no advantage, it seems like the general rule of thumb for development should be using a single interface, with either @Local if it should be local-only, or @Remote if it should be local-or-remote.

      Thanks,
      Jeff Schnitzer
      http://subetha.tigris.org/