So far, we have only discussed session beans that use a local service interface. In this case, local means that the dependency of the session bean can only be declared by the javaee component running on the same application server instance. For example, remote clients cannot use session beans through local interfaces.
To accommodate remote clients, session beans can use the @ remote annotation to mark their business interfaces to declare that they are remotely available. The following code demonstrates the remote version syntax of the preceding helloservice interface. Marking an interface as remote is equivalent to extending the java. RMI. remote interface. The bean referenced by the client is no longer a local reference on the server, but a remote method call (RMI) Stub (stub), so that the session bean operation can be called across networks. Using remote interfaces on bean classes does not require special support.
(CODE)
Changing an interface to a remote one will affect the performance and process the parameters passed to the business method. Remote service interfaces can be used in servers running locally. However, if the method call is routed through the RMI layer, this may still cause network overhead. The parameters of the method above the remote interface are also passed by value, rather than by reference. This means that the real-time client is local to the Session Bean and also needs to serialize parameters. It is usually better to provide local interfaces for local clients. The Local interface saves the semantics of conventional Java method calls, avoiding network and RMI-related overhead.
Note:
Many application servers provide options to improve the performance of remote interfaces when using them locally. This may include the ability to disable serialization of method parameters to protect farmers from RMI completely. Be cautious when using these features in application code, so that they are not portable to different application servers.
Stateless Session Bean (3) --- remote service interface (unpublished)