Java
  Home arrow Java arrow Using RMI with Apache Jserv
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
OLM
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Using RMI with Apache Jserv
By: Richard Yumul
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 5
    2000-01-21

    Table of Contents:
  • Using RMI with Apache Jserv
  • Design the Remote Interface
  • Create the client program (the servlet)
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    The Web Buyer's Guide is your best source for white papers on a wide range of IT products and services. This Week's Featured White Papers: Building a Virtual Infrastructure from Servers to Storage by Network Appliance

    Using RMI with Apache Jserv
    (Page 1 of 4 )

    One of the greatest advantages which Jserv brings to Apache is ability to leverage the large number of API's available to Java. Remote Method Invocation (RMI) delivers several significant benefits to the servlet solution. The primary benefit of using RMI with servlets is that it significantly expands the variety of datasources which Apache can serve to the browser. Furthermore, RMI's simplifies code on the client side of the RMI connection (the servlet), and also allows for load distribution.

    For example, if you wanted a servlet to access a database through JDBC, you would start off with importing the java.sql package into your servlet. Then your servlet would have to manage handling the database connection, preparing and executing SQL statements, as well as managing the result sets. This adds a lot of complexity to your servlet, as not only does it have to handle logic & return appropriate responses to the browser, it is also bogged down managing communications with the database.


    Servlet <== JDBC ==> Database
    With RMI, an abstraction layer is added between the data source and the servlet. This layer, the RMI Service (or server tier), provides an simplified interface to the client, handling all of the internals of communicating with the database.

    Servlet <== Remote Interface ==> RMI Service <== JDBC ==> Database
    So, instead of having to manage the database communications in your servlet, RMI hides all the that from your servlet behind its remote interface.

    With RMI, the server tier can be anything, as long as it implements the defined remote interface. The service could even be hosted on a different machine with a different operating system. The client will not care if the server tier stores its data in a database, LDAP server, or even text files. Your Linux Apache-Jserv box could be pulling data from an application server on a Solaris box.

    Example

    Using RMI with Apache Jserv is fairly straight-forward, and the procedure in this example pretty much follows the RMI examples which can be found in the JDK documentation or Sun's tutorial. The steps include:

    1. Design the remote interface
    2. Implement the remote interface
    3. Compile the classes, create the stub and skeleton classes
    4. Create the client program (in this case, the servlet)
    5. Deploy

    In the following example, we will create a simple email address book. The server will store it's data in a Hashtable. Of course, the data in the server will disappear when the server is stopped, but that's okay for this example's purposes. For a more robust server, the address book data could be stored in a database, LDAP server, or any other type of data storage. The servlet (client) will use the address book service through RMI.

    There are three packages in our example. The first one, is the directory.* package. It holds the remote interface class, as well as the Entry class, a data structure representing an directory record. The server package will contain the implementation of the remote interface. The client package contains the servlet which talks to the server implementation via RMI.

    More Java Articles
    More By Richard Yumul


     

       

    JAVA ARTICLES

    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup
    - Using RPC-Style Web Services with J2EE
    - Integrating XML with J2EE
    - Taming Tiger: Concurrent Collections
    - Combating the ‘Object Crisis’

    Iron Speed



    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway