Java RMI - Helion
ISBN: 978-14-493-1535-1
stron: 576, Format: ebook
Data wydania: 2001-10-22
Księgarnia: Helion
Cena książki: 160,65 zł (poprzednio: 186,80 zł)
Oszczędzasz: 14% (-26,15 zł)
Java RMI contains a wealth of experience in designing and implementing Java's Remote Method Invocation. If you're a novice reader, you will quickly be brought up to speed on why RMI is such a powerful yet easy to use tool for distributed programming, while experts can gain valuable experience for constructing their own enterprise and distributed systems.With Java RMI, you'll learn tips and tricks for making your RMI code excel. The book also provides strategies for working with serialization, threading, the RMI registry, sockets and socket factories, activation, dynamic class downloading, HTTP tunneling, distributed garbage collection, JNDI, and CORBA. In short, a treasure trove of valuable RMI knowledge packed into one book.
Osoby które kupowały "Java RMI", wybierały także:
- Wprowadzenie do Javy. Programowanie i struktury danych. Wydanie XII 193,23 zł, (59,90 zł -69%)
- Spring i Spring Boot. Kurs video. Testowanie aplikacji i bezpiecze 129,00 zł, (51,60 zł -60%)
- Metoda dziel i zwyci 89,00 zł, (35,60 zł -60%)
- JavaFX. Kurs video. Wzorce oraz typy generyczne 79,00 zł, (31,60 zł -60%)
- Platforma Xamarin. Kurs video. Poziom drugi. Zaawansowane techniki tworzenia aplikacji cross-platform 99,00 zł, (39,60 zł -60%)
Spis treści
Java RMI eBook -- spis treści
- Java RMI
- SPECIAL OFFER: Upgrade this ebook with OReilly
- A Note Regarding Supplemental Files
- Preface
- About This Book
- Part I
- Part II
- Part III
- About the Example Code
- Conventions Used in This Book
- Coding Conventions
- Applications
- Compiling and Building
- Downloading the Source Examples
- For Further Information
- How to Contact Us
- Acknowledgments
- About This Book
- I. Designing and Building: The Basics of RMI Applications
- 1. Streams
- The Core Classes
- InputStream
- Reading data
- Stream navigation
- Resource management
- IOException
- OutputStream
- Writing data
- Resource management
- InputStream
- Viewing a File
- Layering Streams
- Compressing a File
- How this works
- Some Useful Intermediate Streams
- Compressing a File
- Readers and Writers
- Revisiting the ViewFile Application
- The Core Classes
- 2. Sockets
- Internet Definitions
- Sockets
- Creating a Socket
- A simple client application
- Protocols and Metadata
- Protocols
- Metadata
- Creating a Socket
- ServerSockets
- The accept( ) method
- A Simple Web Server
- Customizing Socket Behavior
- Special-Purpose Sockets
- Direct Stream Manipulation
- Subclassing Socket Is a Better Solution
- A Special-Purpose Socket
- Factories
- Socket Factories
- Security
- Using SSL
- The SSL Handshake
- Using SSL with JSSE
- Registering providers
- Configuring SSLServerSocket
- Configuring SSLSocket
- Sending data
- Revisiting Our Web Server
- 3. A Socket-Based Printer Server
- A Network-Based Printer
- The Basic Objects
- The Protocol
- Encapsulation and Sending Objects
- DocumentDescription
- Network-Aware Wrapper Objects
- ClientNetworkWrapper
- ServerNetworkWrapper
- Encapsulation and Sending Objects
- The Application Itself
- Writing the Client
- Redrawing the Architecture Diagram
- Evolving the Application
- What These Changes Entail
- 4. The Same Server, Written Using RMI
- The Basic Structure of RMI
- Methods Across the Wire
- Passing by Value Versus Passing by Reference
- The Architecture Diagram Revisited
- Implementing the Basic Objects
- The Printer Interface
- Implementing a Printer
- Examining the skeleton
- The Data Objects
- DocumentDescription
- The Rest of the Server
- The Client Application
- Summary
- The Basic Structure of RMI
- 5. Introducing the Bank Example
- The Bank Example
- Sketching a Rough Architecture
- Five Steps to a Sketch
- The Basic Use Case
- Additional Design Decisions
- Design Postponements
- Security
- Scalability
- Implications of the Environment
- Design Postponements
- A Distributed Architecturefor the Bank Example
- Problems That Arise in Distributed Applications
- Partial Failures
- Network Latency
- 6. Deciding on the Remote Server
- A Little Bit of Bias
- Important Questions WhenThinking About Servers
- Does Each Instance of the Server Requirea Shared/Scarce Resource?
- Memory, in general, is not an issue here
- Sockets in RMI arent a limitation either
- An example of a resource limitation
- Moving things to a singleton resource object handles this problem
- Applying this to Bank versus Accounts
- How Well Does the Given Server Replicate/Scaleto Multiple Machines?
- Applying this to Bank versus Accounts
- Can a Single Server Handle a Typical Client Interaction?
- How many of the servers does the client need to know about during the courseof a typical conceptual operation?
- Applying this to Bank versus Accounts
- How Easy Is It to Make a Server Handle Multiple Simultaneous Clients?
- Applying this to Bank versus Accounts
- How Easy Is It to Tell Whether the Code Is Correct?
- Applying this to Bank versus Accounts
- How Fatal Is a Server Failure?
- Applying this to Bank versus Accounts
- How Easy Is It to Gracefully Extend the Software and Add New Functionality?
- Applying this to Bank versus Accounts
- Does Each Instance of the Server Requirea Shared/Scarce Resource?
- Should We Implement Bank or Account?
- 7. Designing the Remote Interface
- Important Questions When Designing Remote Interfaces
- Should We Pass Method Objects?
- Applying this to the Account interface
- Should We Pass Objects as Argumentsor Use Primitive Values?
- Applying this to the Account interface
- Should We Receive Objects as Return Valuesor Receive Primitive Values?
- Applying this to the Account interface
- Do Individual Method Calls Waste Bandwidth?
- Applying this to the Account interface
- Is Each Conceptual Operation a Single Method Call?
- Iterators, again
- Applying this to the Account interface
- Does the Interface Expose the Right Amount of Metadata?
- Applying this to the Account interface
- Have We Identified a Reasonable Set of Distributed Exceptions?
- Applying this to the Account interface
- Should We Pass Method Objects?
- Building the Data Objects
- Data Objects Dont Usually Have Functional Methods
- Interfaces Give You the Data Objects
- Accounting for Partial Failure
- Important Questions When Designing Remote Interfaces
- 8. Implementing the Bank Server
- The Structure of a Server
- Implementing the Server
- A Server That Extends UnicastRemoteObject
- A Server That Does Not Extend UnicastRemoteObject
- Extending UnicastRemoteObject
- The benefits of UnicastRemoteObject
- The costs of UnicastRemoteObject
- Generating Stubs and Skeletons
- Getting Rid of the Skeletons
- 9. The Rest of the Application
- The Need for Launch Code
- The Idea of a Server Lifecycle
- Our Actual Launch Code
- Build Test Applications
- Build the Client Application
- Dont Hold Connections to a Server Youre Not Using
- Validate Arguments on the Client Side Whenever Reasonable
- The Actual Client Application
- Deploying the Application
- The Need for Launch Code
- 1. Streams
- II. Drilling Down: Scalability
- 10. Serialization
- The Need for Serialization
- Drilling Down on Object Creation
- Using Serialization
- ObjectOutputStream
- The write methods
- The stream manipulation methods
- Methods that customize the serialization mechanism
- ObjectInputStream
- The read methods
- The stream manipulation methods
- Methods that customize the serialization mechanism
- ObjectOutputStream
- How to Make a Class Serializable
- Implement the Serializable Interface
- Make Sure That Instance-Level, Locally Defined StateIs Serialized Properly
- Declaring transient fields
- Implementing writeObject() and readObject( )
- Declaring serialPersistentFields
- Make Sure That Superclass State Is Handled Correctly
- Override equals( ) and hashCode( ) if Necessary
- Making DocumentDescription Serializable
- Implement the Serializable interface
- Make sure that instance-level, locally defined state is serialized properly
- Make sure that superclass state is handled correctly
- Override equals() and hashCode( ) if necessary
- The Serialization Algorithm
- The Data Format
- A Simplified Version of the Serialization Algorithm
- Writing
- Reading
- RMI Customizes the Serialization Algorithm
- annotateClass( )
- replaceObject( )
- Maintaining Direct Connections
- Versioning Classes
- The Two Types of Versioning Problems
- How Serialization Detects When a Class Has Changed
- Implementing Your Own Versioning Scheme
- Performance Issues
- Serialization Depends on Reflection
- Serialization Has a Verbose Data Format
- It Is Easy to Send More Data Than Is Required
- The Externalizable Interface
- Comparing Externalizable to Serializable
- One Final Point
- The Need for Serialization
- 11. Threads
- More Than One Client
- Basic Terminology
- The Calling Stack
- The Heap
- Threads
- Mutexes
- Applying This to the Printer Server
- Threading Concepts
- Controlling Individual Threads
- Coordinating Thread Activities
- Cache Management
- Assigning Priorities to Threads
- Support for Threads in Java
- Objects Have Associated Mutex Variables
- The effects of synchronization on the threads local cache
- Acquiring the same lock more than once
- Thread Manipulation Methods Defined on Object
- The wait methods
- The notify methods
- Classes
- Starting a thread is easy
- Stopping a thread is harder
- Using Runnable instead of subclassing Thread
- Useful methods defined on the Thread class
- Objects Have Associated Mutex Variables
- Deadlock
- Threading and RMI
- 12. Implementing Threading
- The Basic Task
- Guidelines for Threading
- Start with Code That Works
- Above All Else, Ensure Data Integrity
- Applying this to the bank example
- Minimize Time Spent in Synchronized Blocks
- Synchronize around the smallest possible block of code
- Dont synchronize across device accesses
- Dont synchronize across secondary remote method invocations
- Be Careful When Using Container Classes
- Concurrent modification exceptions
- The other containers
- Use Containers to Mediate Interthread Communication
- Immutable Objects Are Automatically Threadsafe
- Always Have a Safe Way to Stop Your Threads
- Background Threads Should Have Low Priority
- Applying this to the bank example
- Pay Careful Attention to What You Serialize
- Use Threading to Reduce Response-Time Variance
- Limit the Number of Objects a Thread Touches
- Acquire Locks in a Fixed Order
- Use Worker Threads to Prevent Deadlocks
- Pools: An Extended Example
- The Idea of a Pool
- Two Interfaces That Define a Pool
- A First Implementation of Pooling
- Problems with SimplePool
- The Creation Thread
- Adding a Return Thread
- Gradually Shrinking the Pool
- Two Additional Considerations When Implementing a Pool
- The initial-resource creation strategy
- The difference between the steady-state size and the maximum-pool size
- Some Final Words on Threading
- 13. Testing a Distributed Application
- Testing the Bank Application
- What Were Testing
- How to Test a Server
- Testing the Bank Application
- Build simple test objects
- Build aggregate tests that test entire use cases
- Build a threaded tester that repeatedly performs these tests
- Build a thread container that launches many threads and stores the resultsof the test in an indexed structure
- Build a reporting mechanism
- Testing the Bank Application
- 14. The RMI Registry
- Why Use a Naming Service?
- Bootstrapping
- Installing a new printer
- When Are Naming Services Appropriate?
- Bootstrapping
- The RMI Registry
- bind( ), rebind( ), and unbind( )
- lookup( ) and list( )
- The RMI Registry Is an RMI Server
- Bootstrapping the Registry
- Examining the Registry
- Querying the Registry
- Launching an Application-Specific Registry
- Limitations of the RMI Registry
- Directories and Entries
- Filesystems
- Yellow pages
- The general idea of directories and entries
- Directories and Entries
- Security Issues
- Why Use a Naming Service?
- 15. Naming Services
- Basic Design, Terminology,and Requirements
- Hierarchies
- Operations on contexts
- Query by Attribute
- Attributes are string-valued, name-value pairs
- Hierarchies
- Requirements for Our Naming Service
- Our Use Case
- Federation and Threading
- Federation
- The Context Interface
- Value Objects Represent Sets and Lists
- Paths, Names, and Attributes Are All Distinct
- Null Arguments Are Okay
- Attributes Are Single Valued
- Contexts Are Handled by a Separate Set of Methods
- Contexts, When Bound as Contexts, Have No Attributes
- Contexts Can Create Subcontexts Directly
- There Are No Remote Iterators
- The Value Objects
- AttributeSet
- Path and ContextList
- ContextImpl
- NameAttributeSetPair
- RemoteHolder
- ContextHolder
- ContextImpl
- Bootstrapping
- Version 2.0
- Switching Between Naming Services
- Adapting the Bank Example
- Modifying the launch code
- Modifying the client code
- Adapting the Bank Example
- The Java Naming and Directory Interface (JNDI)
- The Context Interface
- Using JNDI with the Bank Example
- Basic Design, Terminology,and Requirements
- 16. The RMI Runtime
- Reviewing the Mechanics of a Remote Method Call
- How RMI Solves the Bootstrapping Problem
- Distributed Garbage Collection
- Ordinary Garbage Collection
- Defining Network Garbage
- Leasing
- The Actual Distributed Garbage Collector
- The Unreferenced Interface
- RMIs Logging Facilities
- The Standard Log
- The Specialized Logs
- The Debugging Log
- Other JVM Parameters
- Basic Java Parameters
- Xms
- Xmx
- Basic RMI Parameters
- java.rmi.server.randomIDs
- sun.rmi.server.exceptionTrace
- Transport Layer Parameters
- sun.rmi.transport.connectionTimeout
- sun.rmi.transport.tcp.readTimeout
- sun.rmi.transport.proxy.connectTimeout
- Parameters That Affect the Distributed Garbage Collector
- java.rmi.dgc.leaseValue
- sun.rmi.dgc.client.gcInterval
- sun.rmi.dgc.server.gcInterval
- sun.rmi.dgc.checkInterval
- sun.rmi.dgc.cleanInterval
- Basic Java Parameters
- Reviewing the Mechanics of a Remote Method Call
- 17. Factories and the Activation Framework
- Resource Management
- Factories
- Revisiting Our Basic Design
- Implementing a Generic Factory
- A Basic Factory
- Modifying the Existing Application
- The consequences for the client
- The consequences for the naming service
- The consequences for the account servers
- A Better Factory
- Some Prior Art
- Building on the Account-Locking Mechanism
- The new factory
- The new account
- The launch code and the client
- Persistence and the Server Lifecycle
- Activation
- Code Changes Necessary for Activation
- Making a server into an activatable object
- Modifying our launch code
- Deploying an Activatable System
- ActivationDesc, ActivationGroupDesc, and ActivationGroup in More Detail
- Shutting Down an Activatable Server
- rmid Command-Line Arguments
- -port
- -log
- -stop
- -C
- Activation Parameters
- java.rmi.activation.activator.class
- java.rmi.activation.port
- sun.rmi.activation.execTimeout
- sun.rmi.activation.snapshotInterval
- sun.rmi.rmid.maxstartgroup
- sun.rmi.server.activation.debugExec
- Code Changes Necessary for Activation
- A Final Word About Factories
- 10. Serialization
- III. Advanced Topics
- 18. Using Custom Sockets
- Custom Socket Factories
- Creating Custom Socket Factories
- Implementing Serializable
- Implementing equals( ) and hashCode( )
- Creating Custom Socket Factories
- Incorporating a Custom Socket into an Application
- Modifying Ordinary Servers
- Modifying Activatable Servers
- Modifying the Default Servers
- Failure handlers
- Interaction with Parameters
- Custom Socket Factories
- 19. Dynamic Classloading
- Deploying Can Be Difficult
- Classloaders
- How Classes Are Loaded
- How Dynamic Classloading Works
- A Redeployment Scenario
- A Multiple-Deployment Scenario
- The Class Server
- Requesting a Class
- Receiving a Class
- Handling JAR files
- Suns Class Server
- Using Dynamic Classloadingin an Application
- Server-Side Changes
- Naming-Service Changes
- Client-Side Changes
- Disabling Dynamic Classloading Entirely
- 20. Security Policies
- A Different Kind of Security Problem
- Permissions
- The Types of Permissions
- AWT permissions
- File permissions
- Socket permissions
- Property permissions
- The Types of Permissions
- Security Managers
- Installing an Instance of SecurityManager
- How a Security Manager Works
- java.security.debug
- Setting Up a Security Policy
- The Three Policy Files
- Setting the application-specific policy file
- Inside a Policy File
- Using Security Policies with RMI
- Policy Tool
- Some Final Words
- The Three Policy Files
- 21. Multithreaded Clients
- Different Types of Remote Methods
- Printer-Type Methods
- Report-Type Methods
- Handling Printer-Type Methods
- A First Pass at a Solution
- Better Solutions
- Client-side polling
- Polling code in the printer application
- Server-side callbacks
- Define a client-side callback interface
- Implement the client-side interface
- Handling Report-Type Methods
- Chapter 7 Revisited
- Server-evaluation models
- Iterators on the client side
- Implementing Background Downloading on the Client Side
- Chapter 7 Revisited
- Generalizing from These Examples
- Different Types of Remote Methods
- 22. HTTP Tunneling
- Firewalls
- CGI and Dynamic Content
- The Common Gateway Interface
- Servlets
- HTTP Tunneling
- How RMI Tunnels Messages
- Naming services and the server machine
- How RMI Tunnels Messages
- A Servlet Implementationof HTTP Tunneling
- The Servlet Code
- Modifying the Tunneling Mechanism
- The Bank via HTTP Tunneling
- Drawbacks of HTTP Tunneling
- Disabling HTTP Tunneling
- 23. RMI, CORBA, and RMI/IIOP
- How CORBA Works
- CORBA Contains Other Things Too
- The Bank Example in CORBA
- Defining the Interface
- Generating Stubs and Skeletons
- The Server
- The Launch and Client Code
- A Quick Comparison of CORBA and RMI
- RMI on Top of CORBA
- The Fine Print
- Converting the Bank Example to RMI/IIOP
- Communicating via CORBA
- How CORBA Works
- 18. Using Custom Sockets
- Index
- About the Author
- Colophon
- SPECIAL OFFER: Upgrade this ebook with OReilly