Stateless Session Bean (3) --- remote service interface (unpublished)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.