Java EE6: Does annotating an interface or bean with @local, @remote matter?

I see that in EJB 3 it is desirable to have both a local and a remote interface. Then you create a bean that implements these interfaces. Does it matter where the @remote annotation is either on the interface itself (first example) or on a bean of the interface implementation (second example)? This is not just a style issue, is it? Can someone explain the deeper consequences?

@Remote public interface CarSalesRemote { void getSales(); } @Stateless public class CarSales implements CarSalesRemote { @Override public void getsales() {} } 

Vs

 public interface CarSalesRemote { void getSales(); } @Stateless @Remote public class CarSales implements CarSalesRemote { @Override public void getsales(); } 
+4
source share
1 answer
However, it is important to note that when annotating the bean class, you must specify the interface in the @Remote (CarSalesRemote) annotation, as indicated in the Java EE tutorial:

The bean class can implement more than one interface. If the bean class implements several interfaces, either the business interfaces must be explicitly annotated with either @Local or @Remote, or the business interfaces must be defined by decorating the bean class with @Local or @Remote.

 @Remote(InterfaceName.class) public class BeanName implements InterfaceName { ... } 

vs.

 @Remote public interface InterfaceName { ... } 
+1
source

Source: https://habr.com/ru/post/1483215/


All Articles