I see that in EJB 3 it's desirable to have both local and remote interface. Then you make a bean that implements these interfaces. Does it matter where the @remote annotation is--either on the interface itself (the first example) or on the bean implementing the interface (the second example)? It is not an issue of just style, is it? Can someone explain the deeper implications?
@Remote
public interface CarSalesRemote {
void getSales();
}
@Stateless
public class CarSales implements CarSalesRemote {
@Override
public void getsales() {}
}
Versus
public interface CarSalesRemote {
void getSales();
}
@Stateless
@Remote
public class CarSales implements CarSalesRemote {
@Override
public void getsales();
}
It's a matter of preference, however, note that when annotating the bean class you have to specify the interface on the annotation @Remote(CarSalesRemote) as stated by the Java EE Tutorial:
The bean class may implement more than one interface. If the bean class implements more than one interface, either the business interfaces must be explicitly annotated either @Local or @Remote, or the business interfaces must be specified by decorating the bean class with @Local or @Remote.
@Remote(InterfaceName.class)
public class BeanName implements InterfaceName { ... }
vs.
@Remote
public interface InterfaceName { ... }