Table of Contents
Foreword by Bill Joy
Foreword by Brian Murphy
Introduction
A Roadmap
Conventions Used in This Book
Getting Sample Code from the Internet
Feedback
Further Information
A Note on Versions
Acknowledgments
Part 1: Foundations
Chapter 1: A New Computing Paradigm
Jini History
The Jini Vision
Not Just for Consumer Electronics
Jini Becomes Public
Licensees
Community Source Licensing
Getting and Installing Jini
Installing Java 2
Downloading the JDK from Sun
Unpacking the Distribution
Examining the Distribution
Installing Jini
Downloading Jini from Sun
Unpacking the Distribution
Examining the Distribution
Set Up Your Environment
Setting Your PATH
Start the Jini Run-time Services
Starting Required Services via the GUI
Running the GUI
Starting Required Services via the Command Line
Start the Web Server
Start the RMI Activation Daemon
Start the Lookup Service
Running the Sample Program
Further Reading and Resources
Chapter 2: Distributed Systems
What's So Hard about the Network?
Classical Networked Systems
The Network Is Not Transparent
Performance and Latency
New Failure Modes
Concurrency and Consistency
New Paradigms in Distributed Computing
The Need for Strong Typing
Practical Remote Polymorphism
Remoteness Is Part of the Interface, Not the Implementation
Further Reading
Chapter 3: The Jini Model
Jini Design Center
Simplicity
Reliability
Scalability
Device Agnosticism
What Jini Is Not
Jini Is Not a Name Server
Jini Is Not JavaBeans
Jini Is Not Enterprise JavaBeans
Jini Is Not RMI
Jini Is Not a Distributed Operating System
What Jini Is
Services Carry the Code Needed to Use Them
A "Meta Service" Provides Access to All Other Services
A Bootstrapping Process is Used to Find Proxies for the Lookup Service
Fleshing Out the Key Ideas
Downloadable Proxies
Using Lookup Services
Publishing a Service
Finding a Service
Common Interfaces, Divergent Implementations
Discovery
The Discovery Protocols
Supporting Multiple Communities
Supporting Technology
Leasing
Time-Based Resource Reservation
Remote Events
How Jini Uses Events
Remote vs. Local Events
Distributed Transactions
Ensuring Data Integrity
Transactions In Jini
What's Next?
Chapter 4: Deployment Scenarios
What Does It Mean to Be a Jini Service?
How to Use Jini for Your Devices and Services
Jini on General-Purpose Computers
Jini on Java-Enabled Devices
Limited Java Environments
Versioning
Jini Using Device Proxies
Requirements for Jini Infrastructure Services
When Does Jini Make Sense?
When Is Jini Not Appropriate?
Further Reading
What's Next?
Part 2: Building with Jini
Chapter 5: Getting Started with Jini
Running the Jini Services
Developing with Deployment in Mind
Run Multiple HTTP Servers
Watch Out for Codebase Problems
Always Set a Security Manager
Pay Attention to Security Policies
Take Care with CLASSPATH
Consider Bundling Downloadable Code into a JAR File
Summary
A First Jini Program: Hello, World
Writing the Service Proxy
The "Wrapper" Application
Using Discovery and Lookup
Last Details
Using Service Templates to Search for a Service
Looking Up a Service
Compiling and Running the Examples
Compiling
Start an HTTP Server for the Service
Set Up a Security Policy File
Running
Extending Hello World with Events
Writing a Remote Event Listener
Soliciting Events via Notify()
Compiling and Running the Code
Compiling
Generating the RMI Stubs
Start an HTTP Server to Export the Client's Downloadable Code
Running
Hello World with Leasing
A Simple Approach
Compiling and Running the Code
Compiling
Running
Using an Activatable Back-End Process
Defining the Remote Protocol
Defining a New Network-Aware Proxy
Defining the New Service Wrapper
Compiling and Running the Example
Compiling
Generating the RMI Stubs
Running
One Final Iteration
What's Next?
Chapter 6: In Depth: Discovery
What's Discovery?
Groups Partition the Community Namespace
Types of Discovery
An Overview of Discovery
An IP Multicast Primer
Service-Initiated Discovery
Lookup Service-Initiated Discovery
"Direct" Discovery
Using Discovery in Applications
DiscoveryListeners Are Informed of Discoveries
DiscoveryChange Listeners Are Informed of Changes in Group Membership of Lookup Services
DiscoveryEvents Encapsulate Discovery Information
Using LookupDiscovery to Control Multicast Discovery
An Example
Security and LookupDiscovery
Compiling and Running the Program
Common Interfaces for Controlling Discovery
Other Discovery Classes
Using LookupLocator to Control UnicastDiscovery
An Example
Compiling and Running the Program
Under the Hood: The Discovery Protocols
The Multicast Request Protocol
Communication Flow
Packet Format
ing the Multicst Request Protocol
The Multicast Announcement Protocol
Communication Flow
Packet Format
Using the Multicast Announcement Protocol
The Unicast Discovery Protocol
Communication Flow
Packet Format
Using Unicast Discovery
An Example
Compiling and Running the Program
Other Internal Discovery Issues
Multicast Restrictions and Guidelines
Multicast Routing Infrastructure
Security
Host and Network Requirements
Interfaces for Discovery Implementors
Summary
What's Next?
Chapter 7: Attributes, Templates, and Service Matching
Attributes Basics
What Are Attributes?
Search Using Attributes
The Special Semantics of Attributes?
Who Changes Attributes?
The Standard Attributes
Writing New Attributes
An Example: A Capacity Attribute
Attributes and Beans
Using Entry Beans to Map Entries to Beans
How Are Entry Beans Found?
The Entry Bean Class
The Standard Entry Beans
An Example: A Capacity Bean
A Second Bean Example: Using GUI Beans
Matching using Service Templates
An Example of Matching Multiple Attributes
Further Reading
Chapter 8: IThe Service Join Protocol
Overview of Lookup
Publishing a Service Proxy:
The Join Protocol
The JoinManager Class
Managing Service IDs
Using the JoinManager in Applications
Compiling and Running the Example
Using Attributes through the JoinManager
Restricting Changes to ServiceControlled Attributes
Further Reading
Summary
What's Next?
Chapter 9: Using Low-Level Service Interfaces
How Clients Use Lookup
Using the ServiceRegistrar Interface
Searching for Services
The Search APIs
An Example: Searching for Service Information
Compiling and Running the Example
Soliciting Events from a Lookup Service
Specifying When Events Should Be Sent
Using Notify() to Ask for Events
Receiving Events
An Example: Using Events to Find Services
Compiling and Running
Other Client Issues
You Cannot Change a Service's Attributes Without Going
through the Service
Downloaded Service Proxies Are Not Leased
Service IDs Are Unique Across Lookup Services
"Browser-Oriented" Lookup APIs
Federating and Administering Lookup Services
A Quick Overview of Service Administration
Lookup Administrative Interfaces
Administering the Reggie Lookup Service Implementation
Federating Lookup Services
Compiling and Running
Example: A Lookup Service Tunnel
Compiling and Running
Summary
What's Next?
Chapter 10: Using the ServiceDiscovery Manager
Higher Level APIs for Client Lookup
The ServiceDiscoveryManager
A Word on Usage Patterns
Creating Lookup Caches
New Versions of Lookup()
Miscellaneous Methods
Receiving Remote Events
Supporting Classes
LookupCache
ServiceItemFilter
ServiceDiscoveryListener
ServiceDiscoveryEvent
A Basic Example
Compiling and Running the Example
Using Filters
Compiling and Running the Example
Using Events
Compiling and Running the Example
Summary
What's Next?
Chapter 11: A Jini Lookup Service Brower
What Does a Browser Do?
Using the Browser
Building Administration Components
DestroyAdminPanel
StorageLocationAdminPanel
A ListBox for Managing Sets
DiscoveryAdminPanel
JoinAdminPanel
AdminPanel
JList Cell Renderers for Common Jini Types
LookupCellRenderer
ServiceCellRenderer
AttrCellRenderer
The Core Browser Framework
Storing Data in Lists
Using Discovery
Receiving Service Events
Handling List Events
The Browser Class
Building and Running the Browser
What's Next?
Chapter 12: Leasing
Reliability in Distributed Systems
The Need for Self-Healing
The Need for Evolvability
Leasing as a Solution
The Leasing Approach
Issues in Leasing
Relative vs. Absolute Time
Lease Negotiation
Leasing Done by Third Parties
The Cost of Leasing
Building Lease Consumers
The Lease Interface
Determining When a Lease Expires
Canceling a Lease
Renewing a Lease
Ensuring That Leases are Serialized Correctly
Batching Leases for Performance
The LeaseMap Interface
Higher Level APIs for Lease Consumers
A Leasing Service
An Overview of a Leasing Service
Remote Leasing APIs
Events and Listeners for Remote Leasing
Leasing Service Implementation
Compiling and Running the Example
Leasing in Practice
Who Handles Lease Renewals?
The Perils of Leasing
Delegation to an External JVM vs. Delegation to an Internal Class
Leasing vs. Garbage Collection
Summary
What's Next?
Chapter 13: Exporting Leased Resources
Leasing Interfaces and Implementations
The Landlord Paradigm
Identifying Leased Resources
Implementing the Landlord Interface
An Example
Compiling and Running the Examples
Summary
What's Next?
Chapter 14: The Well-Behaved Service
The Responsibilities of a Service
Service Administration
Administration through Delegation
Administrative Interfaces
Implementation of Administrative Delegates
An Example: Administering the LeaseService
Providing User Interfaces for Services
Several Approaches to Providing UIs
A Simple Example: User Interfaces as Attributes
The ServiceUI Approach
The Jini Community at Work
ServiceUI Essentials
UI Factories
UI Roles
Where to Go Next
Summary
Related Reading
What's Next
Chapter 15: The Complete Example: The Print Service
Requirements for a Printing Service
A Service Writer's Toolkit
A Superclass for Services
A Tool for Administration
Defining the Print Service API
Communicating with Clients: Events and Listeners
The Remote Printing Interface
The Print Service Proxy
Printer Administration APIs and UIs
Internals of the Print Service
Printing
Persistent Data Formats
Implementing Print Service Administration
A Print Client
Compiling and Running the Examples
Ideas for Future Work
Summary
Related Reading
What's Next?
Chapter 16: In Depth: Remote Events
The Need for Notifications
Jini Event Design Center
How Remote Events Differ from Local Events
Out of Order Delivery
Partial Failures
Latency Versus Computation
Addressing Application Semantics
The Jini Event Programming Model
The RemoteEvent Class
Event Types
Sequence Numbers, Idempotency, and Ordering
Application-Specified Return Data
The RemoteEventListener Interface
Dealing with Errors
Other Event Interfaces
An Example: Heartbeat Events
A Toolkit for Event Registrations
A Simple Event Generator
Event Types and Sequence Numbers
Defining a Cookie Type
Persistent Data
Registering for and Sending Events
A Client to Test the HeartbeatGenerator
Compiling and Running the Heartbeat Examples
Third-Party Event Delegates
Designing for Composition
Composition in Practice
How Events Are Delivered through the Pipeline
Setting up the Pipeline
Pipelines from the Generator Perspective
Pipelines from the Listener Perspective
Leasing across Delegates
An Example: An Event Mailbox
The EventMailbox Service
A Mailbox Client
Compiling and Running the Examples
Summary
What's Next?
Chapter 17: JavaSpaces
What Is JavaSpaces?
A Filesystem for Objects
Attribute-Based Search
Predecessors to JavaSpaces
Configuring and Running JavaSpaces
Start the Run-Time Services
Starting Required Services via the GUI
Starting the Required Services via the Command Line
Transient and Persistent JavaSpaces
The JavaSpaces Programming Model
Transactions, in Brief
JavaSpaces APIs
Write()
Read() and ReadIfExists()
Take() and TakeIfExists()
Notify()
Snapshot()
An Example: Persistent Event Logging with JavaSpaces
Design for Searchability
A Community Watcher
A Consumer of Logged Event Data
Compiling and Running the Programs
Applying JavaSpaces to Distributed Computing Problems
Further Reading
What's Next?
Chapter 18: Distributed Applications
Consistency and the Evils of Partial Failure
A Classical Transaction Model
Two-Phase Commit
Transactions in Jini
The Players in Jini Transactions
Programming with Jini Transactions
The Transaction Manager
Creating Transactions
The Transaction Interface
Transaction Participants
Using Transactions with JavaSpaces
Compiling and Running the EntryMover
Other Transaction Issues and Idioms
Transactions and Visibility
Nesting Transactions
Events and Sequence Numbers
Using Transactions to Hide Data
Summary
Chapter 19: The Jini Utility Services
Why the Utility Services?
Configuring and Running the Utility Services
A Refresher: The Lifecycle of Activatable Services
Starting the LookupDiscoveryService
Starting the LeaseRenewalService
Starting the EventMailbox
The LookupDiscoveryService
Other Situations
The LookupDiscoveryService Programming Model
RemoteDiscoveryEvents
LookupDiscoveryRegistrations
The LeaseRenewalService
The LeaseRenewalService Programming Model
The LeaseRenewalSet Interface
Exception Classes
Event Classes
The EventMailbox
An Example
Compiling and Running the Example
Summary
Part 3: Appendices
Appendix A: An RMI Primer
Overview of RMI
Remote Interfaces
Stubs and Skeletons
Serialization
Parameters and Return Values
Dynamic Code Loading
Security Implications
Marshalled Objects
Building with RMI
Compiling the Example
Running the Programs
The Activation Framework
Players in Activation
Using the Activation Framework
An Example
Compiling and Running the Example
Compiling
Running
Fully Utilizing Activation in a Jini Service
Other Activation Topics
"Lazy" References
Deactivation
Getting the Most from the Activation Daemon
Further Reading
Appendix B: Common Java and Jini System Properties
Index