Notice that our bean implements the remote interface, which at this point is an
empty interface with the @Remote annotation added. This annotation was added
because we chose to create a remote interface.
The reason we need to have a remote and/or an optional local interface is because
session bean clients never invoke the bean's methods directly; instead, they obtain a
reference of a class implementing their remote and/or local interface and invoke the
methods on this class. Beginning with Java EE 6, it is no longer necessary to create
a local interface; the application server can generate one automatically when the
application is deployed.
The remote and/or local interface implementation is created automatically by the
EJB container when we deploy our bean. This implementation does some processing
before invoking our session bean's method. Since the methods need to be defined
both on the interface and our bean, typically we would need to add the method
signature to both the bean and its remote and/or local interface. However, when
working with session beans in NetBeans, we can simply right-click on the bean's
source code and go to Insert Code | Add Business Method . This will result in the
method being added to both the bean and the remote/local interface.