java.rmi: The Remote Method Invocation Guide

Book description

"This book collects an astonishing range of Java RMI material, suitable for any Java programmer regardless of experience with RMI. The RMI novice will be able to run RMI programs without excessive hair-pulling; the accomplished RMI programmer will find enough techniques and explanations to improve the performance, capability, or aesthetic quality of his or her code; and the RMI expert will be able to perform great RMI-based hacks without the JDK source code. If you're looking at this book because I directed you to it on the RMI-USERS mailing list, then, yes, you've found the right one!"
--from the foreword by Adrian Colley, RMI team, Sun Microsystems, Ireland

"Esmond is one of the long-time RMI 'gurus', accumulating a vast and deep arsenal of practical knowledge in RMI uses, internals, tricks and techniques. I am amazed he has packed so much in just under 300 pages. An effective RMI or Jini developer should absolutely have this reference in his collection."
--Brian Maso; consultant, DevelopMentor instructor, and Java Pro at DevX.com"

The definitive guide to remote method invocation in Java.

This book provides an in-depth resource to all features of RMI, building a firm, logical foundation for understanding and applying the RMI technology. It contains detailed information about how to apply RMI to get professional developers and students alike "up and running", while clarifying and extending the official information found in the specification. The authors address many of the real-world issues and unexpected features that you will encounter whilst working with the technology.

All you need to know about:

  • understanding RMI in the context of Java and object-oriented programming

  • using RMI to create applications in networked environments ranging from LANs to the Internet

  • mastering serialization, remote interfaces, clients, the RMI registry, servers, security, and mobile code

  • applying advanced concepts e.g. activation, socket factories, Internet firewalls, distributed garbage collection, and design patterns

  • working with alternatives or extensions to the standard RMI implementation e.g., JNDI naming services and CORBA IIOP.

  • Features:

  • Complete RMI Alamanac lift-out

  • Extensive code samples and exercises



  • 0201700433B07022001

    Table of contents

    1. Copyright
      1. Dedication
    2. List of Tables
    3. List of Figures
    4. List of Examples
    5. Foreword
    6. Preface
      1. About this book
        1. How it is organized
        2. Prerequisite knowledge
        3. Terminology and conventions
        4. Examples
        5. Exercises
      2. Colophon
      3. Acknowledgements
        1. From Kathy
        2. From Esmond
    7. 1. Introduction to RMI
      1. 1.1. In this chapter
      2. 1.2. Java and RMI
      3. 1.3. Architecture of RMI systems
      4. 1.4. Syntax of RMI
      5. 1.5. First principles—remote method invocation
        1. 1.5.1. Remote stubs
        2. 1.5.2. Remote exceptions
      6. 1.6. Baby's first words
      7. 1.7. Exercises
    8. 2. Characteristics of RMI
      1. 2.1. In this chapter
      2. 2.2. Syntax
      3. 2.3. Semantics
        1. 2.3.1. Remote objects
        2. 2.3.2. Arguments and results
        3. 2.3.3. “At most once” semantics
      4. 2.4. Semantics of local method invocation
      5. 2.5. Semantics of remote method invocation
        1. 2.5.1. Partial failure
        2. 2.5.2. Memory access
        3. 2.5.3. Networks
      6. 2.6. Summary
      7. 2.7. Exercises
    9. 3. Serialization
      1. 3.1. In this chapter
      2. 3.2. Introduction
      3. 3.3. Essentials
      4. 3.4. Serialization in depth
        1. 3.4.1. Motivation
        2. 3.4.2. Object graphs
      5. 3.5. The serialization process
        1. 3.5.1. Serializing an object
        2. 3.5.2. De-serializing an object
        3. 3.5.3. Object graphs and RMI
      6. 3.6. The Serializable interface
        1. 3.6.1. Default constructors in Serializable classes
        2. 3.6.2. Custom serialization: readObject and writeObject
      7. 3.7. The Externalizable interface
        1. 3.7.1. The readExternal and writeExternal methods
        2. 3.7.2. Default constructors in Externalizable classes
        3. 3.7.3. When to use Externalizable
      8. 3.8. MarshalledObject
      9. 3.9. Class versioning
        1. 3.9.1. Limitations of automatic class versioning
        2. 3.9.2. Adding and rearranging fields
        3. 3.9.3. Limitations—RMI/IIOP
      10. 3.10. Serial Version UID
        1. 3.10.1. Defining your own SUID
        2. 3.10.2. Examples—class versioning
      11. 3.11. Alternative approaches to versioning
        1. 3.11.1. Code mobility
        2. 3.11.2. Versioning by derivation
      12. 3.12. Advanced facilities in Serialization
        1. 3.12.1. The readResolve and writeReplace methods
        2. 3.12.2. The serialPersistentFields member
      13. 3.13. javadoc and serialization
      14. 3.14. Improving the performance of Serialization
      15. 3.15. Exercises
    10. 4. Remote interfaces
      1. 4.1. In this chapter
      2. 4.2. Introduction
      3. 4.3. Proxies
      4. 4.4. Dispatchers
      5. 4.5. Exercises
    11. 5. RMI clients
      1. 5.1. In this chapter
      2. 5.2. Introduction
      3. 5.3. Remote failure
      4. 5.4. Partial failure
      5. 5.5. Latency
      6. 5.6. Applets
      7. 5.7. Exercises
    12. 6. Naming I—RMI registry
      1. 6.1. In this chapter
      2. 6.2. Purpose
      3. 6.3. How it works
        1. 6.3.1. Bind, unbind, and lookup
        2. 6.3.2. Rebind and list
      4. 6.4. Names in the registry
        1. 6.4.1. Unique naming
      5. 6.5. The Naming class
      6. 6.6. The Registry interface
      7. 6.7. Registry exceptions
      8. 6.8. Names and URLs
        1. 6.8.1. Recommendation
      9. 6.9. Registry setup
        1. 6.9.1. Starting a registry process
        2. 6.9.2. Creating a local registry
        3. 6.9.3. Deployment
      10. 6.10. Registry configurations
        1. 6.10.1. Standard configuration
        2. 6.10.2. Development configuration
      11. 6.11. Utilities
        1. 6.11.1. Listing the registry
        2. 6.11.2. Sun registry utility
      12. 6.12. Alternative naming services
      13. 6.13. Exercises
    13. 7. Servers I—unicast servers
      1. 7.1. In this chapter
      2. 7.2. Introduction
      3. 7.3. Writing the server
        1. 7.3.1. Extend UnicastRemoteObject
        2. 7.3.2. Extend RemoteServer or RemoteObject
        3. 7.3.3. Extend another class
        4. 7.3.4. Exporting
        5. 7.3.5. Unexporting
        6. 7.3.6. Summary
      4. 7.4. Implementing remote interface methods
      5. 7.5. Threads, sockets, and ports
        1. 7.5.1. Threads
        2. 7.5.2. Server sockets
        3. 7.5.3. Client sockets
      6. 7.6. The Unreferenced interface
        1. 7.6.1. Idle-time activity
        2. 7.6.2. Exiting when idle
      7. 7.7. Building the server
        1. 7.7.1. Stub protocols
        2. 7.7.2. Installation and distribution
      8. 7.8. Foundation classes
        1. 7.8.1. RemoteObject
        2. 7.8.2. RemoteServer
        3. 7.8.3. Semantics of remote objects
      9. 7.9. Serialization
      10. 7.10. Alternative server classes
      11. 7.11. Exercises
    14. 8. Security I—execution
      1. 8.1. In this chapter
      2. 8.2. Introduction
      3. 8.3. RMI and security managers
      4. 8.4. Applets
      5. 8.5. Clients
      6. 8.6. Servers
        1. 8.6.1. Non-activatable servers
        2. 8.6.2. Activatable servers
      7. 8.7. System properties—security
      8. 8.8. Policy files
        1. 8.8.1. Protection domain
        2. 8.8.2. Code source
        3. 8.8.3. Permission entry
      9. 8.9. Granting AllPermission
    15. 9. Mobile code
      1. 9.1. In this chapter
      2. 9.2. Outline
      3. 9.3. How code mobility works
        1. 9.3.1. Format of a codebase
      4. 9.4. Uses of code mobility
        1. 9.4.1. True polymorphism
        2. 9.4.2. Thinner clients
        3. 9.4.3. Application rollout
        4. 9.4.4. Application integrity
      5. 9.5. Security considerations
      6. 9.6. Setup
        1. 9.6.1. Codebase property
        2. 9.6.2. RMI registry
        3. 9.6.3. Codebase server
        4. 9.6.4. Client installations
        5. 9.6.5. The useCodebaseOnly property
      7. 9.7. HTTP servers
        1. 9.7.1. The lightweight HTTP class server
        2. 9.7.2. Other http servers
      8. 9.8. Other protocols
        1. 9.8.1. The file: protocol
        2. 9.8.2. FTP—file transfer protocol
        3. 9.8.3. HTTPS—secure hypertext transfer protocol
        4. 9.8.4. Authentication
      9. 9.9. Deployment
      10. 9.10. Downloading the client
        1. 9.10.1. RMIClassLoader bootstrap
        2. 9.10.2. Bootstrapping via RMI
        3. 9.10.3. MarshalledObject bootstrap
    16. 10. Servers II—activation
      1. 10.1. In this chapter
      2. 10.2. Introduction
        1. 10.2.1. Uses of activation
      3. 10.3. First principles—activation
        1. 10.3.1. Activatable servers
        2. 10.3.2. Activation groups
      4. 10.4. How it works
      5. 10.5. Writing an activatable server
        1. 10.5.1. Define the required constructor
        2. 10.5.2. Extend the Activatable class
        3. 10.5.3. Extend another class
      6. 10.6. Registration
        1. 10.6.1. Registering an activation group
        2. 10.6.2. Registering an activatable server
        3. 10.6.3. A registration is a singleton
        4. 10.6.4. Registrations are persistent
      7. 10.7. Building an activatable server
      8. 10.8. Run-time setup
        1. 10.8.1. Codebase and activation
        2. 10.8.2. rmid security policy—JDK 1.3
      9. 10.9. Activation and the Unreferenced interface
      10. 10.10. Which servers should be activatable
      11. 10.11. The activation system as an RMI registry
      12. 10.12. Debugging
        1. 10.12.1. Debugging utility
      13. 10.13. Activation groups in Win32
      14. 10.14. Activation clients
        1. 10.14.1. Activation delays
        2. 10.14.2. Activation exceptions
      15. 10.15. Remarks on the Activation Package
        1. 10.15.1. How it really works
        2. 10.15.2. Creating the activation group
        3. 10.15.3. Simultaneous registration and export
        4. 10.15.4. The ActivationGroup class
        5. 10.15.5. The ActivationGroupId and ActivationID classes
        6. 10.15.6. Remote interfaces
      16. 10.16. Exercises
    17. 11. Socket factories
      1. 11.1. In this chapter
      2. 11.2. Purpose
        1. 11.2.1. Java 1
        2. 11.2.2. Java 2
      3. 11.3. Server socket factories
      4. 11.4. Client socket factories
      5. 11.5. Factory equality—the equals method
        1. 11.5.1. Implementing equals for socket factories
      6. 11.6. Uses of socket factories
        1. 11.6.1. Secure sockets
        2. 11.6.2. HTTP tunnelling
        3. 11.6.3. Multi-homing
        4. 11.6.4. Note—the java.rmi.server.hostname property
      7. 11.7. Remarks
    18. 12. Agents and patterns
      1. 12.1. In this chapter
      2. 12.2. Introduction
      3. 12.3. Mobile agents
      4. 12.4. Callbacks
        1. 12.4.1. Limitations—deadlocks
        2. 12.4.2. Limitations—firewalls
      5. 12.5. Mobile servers
        1. 12.5.1. Limitations—firewalls
      6. 12.6. Agents and design patterns
      7. 12.7. Adapter
        1. 12.7.1. Example adapter: remote input stream
      8. 12.8. Proxy
        1. 12.8.1. Smart proxy
        2. 12.8.2. Example proxy: remote output stream
        3. 12.8.3. Remote proxy
        4. 12.8.4. Smart remote proxy
        5. 12.8.5. Virtual proxy
        6. 12.8.6. Activatable proxy
        7. 12.8.7. Other uses of proxies
      9. 12.9. Client-server patterns
        1. 12.9.1. Client-server
        2. 12.9.2. Client-dispatcher-server
        3. 12.9.3. Peer-to-peer
      10. 12.10. Singleton
        1. 12.10.1. Stateless servers
        2. 12.10.2. Servers in the registry
        3. 12.10.3. Activatables
      11. 12.11. Remote factory
      12. 12.12. Abstract remote
      13. 12.13. Session
      14. 12.14. Exercises
      15. 12.15. Remarks on the examples and exercises
    19. 13. Naming II—JNDI and Jini
      1. 13.1. In this chapter
      2. 13.2. JNDI
      3. 13.3. JNDI operations
        1. 13.3.1. Basic operations
        2. 13.3.2. Sub-contexts
        3. 13.3.3. Federation
        4. 13.3.4. Directory contexts
        5. 13.3.5. Event notification
      4. 13.4. JNDI providers
        1. 13.4.1. Provider properties
        2. 13.4.2. RMI registry provider
        3. 13.4.3. COS Naming provider
        4. 13.4.4. LDAP provider
      5. 13.5. Examples
      6. 13.6. Other features and setup
      7. 13.7. Other JNDI service providers
      8. 13.8. Jini naming
      9. 13.9. Exercises
    20. 14. Servers III—RMI/IIOP
      1. 14.1. In this chapter
      2. 14.2. Introduction
      3. 14.3. RMI/IIOP and CORBA
      4. 14.4. RMI/IIOP and Enterprise Java Beans
      5. 14.5. PortableRemoteObject
      6. 14.6. Writing the server
        1. 14.6.1. Extend PortableRemoteObject
        2. 14.6.2. Extend RemoteObject
        3. 14.6.3. Extend another class
      7. 14.7. Building the server
      8. 14.8. Java/IDL tool
      9. 14.9. Supporting both JRMP and IIOP
      10. 14.10. Restrictions
      11. 14.11. Implementing the service in another language
      12. 14.12. IIOP clients
        1. 14.12.1. Naming services
        2. 14.12.2. Using the remote interface
      13. 14.13. Implementing the client in another language
      14. 14.14. Exercises
    21. 15. RMI through firewalls
      1. 15.1. In this chapter
      2. 15.2. Firewalls
        1. 15.2.1. Transport firewalls
        2. 15.2.2. Application firewalls
        3. 15.2.3. HTTP proxies
        4. 15.2.4. Firewall configuration and control
      3. 15.3. SOCKS
        1. 15.3.1. Limitations of SOCKS
      4. 15.4. HTTP tunnelling
        1. 15.4.1. Limitations of HTTP tunnelling
      5. 15.5. Firewalls and RMI
        1. 15.5.1. Direct forwarding over HTTP
        2. 15.5.2. Indirect forwarding over HTTP and CGI
        3. 15.5.3. The java-rmi CGI script
        4. 15.5.4. The RMI servlet handler
        5. 15.5.5. Authenticated HTTP tunnelling
        6. 15.5.6. Disabling RMI/HTTP
        7. 15.5.7. Limitations of RMI/HTTP
        8. 15.5.8. Summary
      6. 15.6. GIOP Proxies
        1. 15.6.1. Benefits
        2. 15.6.2. Limitations
      7. 15.7. The RMI Proxy
        1. 15.7.1. Benefits
        2. 15.7.2. Limitations
      8. 15.8. A note on callbacks
      9. 15.9. A note on firewall implementations and RMI
    22. 16. Security II—the conversation
      1. 16.1. In this chapter
      2. 16.2. Identity
        1. 16.2.1. Authentication
        2. 16.2.2. Authorization
      3. 16.3. Integrity
        1. 16.3.1. Message Digest
      4. 16.4. Privacy
        1. 16.4.1. Encryption
      5. 16.5. Secure Sockets Layer
      6. 16.6. LDAP authentication
      7. 16.7. JAAS
      8. 16.8. RMI Security Extension
        1. 16.8.1. Security constraints
        2. 16.8.2. Secure servers
        3. 16.8.3. Secure stub
        4. 16.8.4. Client subject
        5. 16.8.5. Remote call control
        6. 16.8.6. Activatable secure servers
        7. 16.8.7. Secure clients
        8. 16.8.8. Secure clients of activatable secure servers
        9. 16.8.9. Secure sections
      9. 16.9. Exercises
    23. 17. Servers IV—beyond unicast
      1. 17.1. In this chapter
      2. 17.2. Datagrams
        1. 17.2.1. Purpose
        2. 17.2.2. Semantics
        3. 17.2.3. Example
        4. 17.2.4. Implementation
      3. 17.3. Multicast
        1. 17.3.1. Purpose
        2. 17.3.2. Semantics
        3. 17.3.3. Implementation
      4. 17.4. Broadcast
        1. 17.4.1. Purpose
        2. 17.4.2. Semantics
        3. 17.4.3. Implementation
      5. 17.5. Clients
      6. 17.6. Exercises
    24. 18. Selected further topics
      1. 18.1. In this chapter
      2. 18.2. Distributed garbage collection
        1. 18.2.1. Overview
        2. 18.2.2. Description
        3. 18.2.3. Limitations of DGC
        4. 18.2.4. For further information
      3. 18.3. Logging
        1. 18.3.1. Application logging
        2. 18.3.2. Debug logging
      4. 18.4. Debugging
        1. 18.4.1. RMIstat utility
      5. 18.5. Testing RMI in a single machine
        1. 18.5.1. Loopback
        2. 18.5 2. Unix domain sockets
      6. 18.6. Performance
        1. 18.6.1. Resource conservation in RMI
        2. 18.6.2. Efficiency
        3. 18.6.3. Scalability
        4. 18.6.4. Tuning techniques
          1. 18.6.4.1. Tuning timeouts
          2. 18.6.4.2. Performance recommendations
          3. 18.6.4.3. Improving the performance of Serialization
      7. 18.7. RMI and JDK versions
        1. 18.7.1. Overview of versions
        2. 18.7.2. Clients
        3. 18.7.3. Servers
        4. 18.7.4. Interoperability
      8. 18.8. Exercises
    25. A. Exceptions in RMI
      1. A.1. Class hierarchy
      2. A.2. Exceptions in RMI servers
      3. A.3. Exceptions in RMI clients
      4. A.4. Alphabetic list of exceptions
        1. A.4.1. java.rmi.AccessException
        2. A.4.2. java.rmi.activation.ActivationException
        3. A.4.3. java.rmi.activation.ActivateFailedException
        4. A.4.4. java.rmi.AlreadyBoundException
        5. A.4.5. java.lang.ClassCastException
        6. A.4.6. java.lang.ClassNotFoundException
        7. A.4.7. java.rmi.ConnectException
        8. A.4.8. java.rmi.ConnectIOException
        9. A.4.9. java.rmi.server.ExportException
        10. A.4.10. java.rmi.MarshalException
        11. A.4.11. java.rmi.NoClassDefFoundError
        12. A.4.12. java.rmi.NoSuchObjectException
        13. A.4.13. java.rmi.NotBoundException
        14. A.4.14. java.rmi.RemoteException
        15. A.4.15. java.rmi.RMISecurityException
        16. A.4.16. java.lang.SecurityException
        17. A.4.17. java.rmi.server.ServerCloneException
        18. A.4.18. java.rmi.ServerError
        19. A.4.19. java.rmi.ServerException
        20. A.4.20. java.rmi.server.ServerNotActiveException
        21. A.4.21. java.rmi.ServerRuntimeException
        22. A.4.22. java.rmi.server.SkeletonMismatchException
        23. A.4.23. java.rmi.server.SkeletonNotFoundException
        24. A.4.24. java.rmi.server.SocketSecurityException
        25. A.4.25. java.rmi.StubNotFoundException
        26. A.4.26. java.rmi.UnexpectedException
        27. A.4.27. java.rmi.activation.UnknownGroupException
        28. A.4.28. java.rmi.UnknownHostException
        29. A.4.29. java.rmi.activation.UnknownObjectException
        30. A.4.30. java.rmi.UnmarshalException
      5. A.5. Remarks on exceptions in RMI
        1. A.5.1. Catching deprecated exceptions
        2. A.5.2. Name collisions
        3. A.5.3. Remote call stack
    26. B. System properties
      1. B.1. RMI system properties
      2. B.2. Implementation-dependent system properties
    27. C. References
      1. C.1. Books
        1. C.1.1. Books on Java
        2. C.1.2. Books on related topics
      2. C.2. Papers
        1. C.2.1. IETF RFCs
        2. C.2.2. Specifications
        3. C.2.3. Research papers
      3. C.3. Web resources
        1. C.3.1. Java Software
        2. C.3.2. Home page and source code for this book
    28. D. Glossary

    Product information

    • Title: java.rmi: The Remote Method Invocation Guide
    • Author(s): Esmond Pitt, Kathleen McNiff
    • Release date: July 2001
    • Publisher(s): Pearson Business
    • ISBN: 9780201700435