
JXTA v2.3.x: Java™ Programmer’s Guide Apr 7, 2005 1 JXTA v2.3.x: Java Programmer’s Guide © 2005 Sun Microsystems, Inc. All rights reserved. Sun, Sun Microsystems, the Sun Logo, and Java are trademarks, registered trademarks, or service marks of Sun Microsystems, Inc. in the United States and other countries. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc., in the United States and other countries. Products bearing SPARC trademarks are based upon an architecture developed by Sun Microsystems, Inc. UNIX is a registered trademark in the United States and other countries, exclusively licensed through X/Open Company, Ltd. ♺ Please Recycle 2 JXTA v2.3.x: Java Programmer’s Guide Table of Contents Chapter 1: Introduction........................................................................................................6 Why JXTATM ?..............................................................................................................6 What can be done with JXTATM Technology? ..............................................................7 Where to get the JXTATM technology............................................................................8 Getting Involved..............................................................................................................8 Chapter 2: JXTATM Architecture........................................................................................9 Overview.........................................................................................................................9 JXTAComponents........................................................................................................10 Key aspects of the JXTAarchitecture...........................................................................10 Chapter 3: JXTAConcepts.................................................................................................11 Peers..............................................................................................................................11 Peer Groups...................................................................................................................11 Network Services .........................................................................................................13 Modules.........................................................................................................................13 Pipes..............................................................................................................................14 Bidirectional reliable communication channels (JxtaSocket, and JxtaBiDiPipe)........16 Messages.......................................................................................................................17 Advertisements..............................................................................................................18 Security..............................................................................................................................19 Security.........................................................................................................................19 IDs.................................................................................................................................20 Chapter 4: Network Architecture.......................................................................................21 Network Organization...................................................................................................21 Shared Resource Distributed Index (SRDI)..................................................................22 Queries......................................................................................................................23 Firewalls and NAT........................................................................................................24 Chapter 5: JXTAProtocols................................................................................................26 Peer Discovery Protocol................................................................................................27 Peer Information Protocol.............................................................................................27 Peer Resolver Protocol..................................................................................................27 Pipe Binding Protocol...................................................................................................28 Endpoint Routing Protocol............................................................................................28 Rendezvous Protocol.....................................................................................................29 Chapter 6: Hello World Example.......................................................................................30 Getting Started..............................................................................................................30 Accessing On-line Documentation ...............................................................................30 Downloading Binaries...................................................................................................30 Compiling JXTACode..................................................................................................31 Configuration................................................................................................................32 HelloWorld Example................................................................................................34 Running the Hello World Example...........................................................................35 Source Code: SimpleJxtaApp...................................................................................37 Chapter 7: Programming with JXTA.................................................................................38 Peer Discovery..............................................................................................................38 3 JXTA v2.3.x: Java Programmer’s Guide Discovery Service.....................................................................................................38 DiscoveryDemo........................................................................................................39 Source Code: DiscoveryDemo.................................................................................42 Peer Group Discovery...................................................................................................44 Source Code: GroupDiscoveryDemo.......................................................................46 Creating Peer Groups and Publishing Advertisements.................................................49 groupsInLocalCache()..............................................................................................49 createGroup()............................................................................................................50 Source Code: PublishDemo......................................................................................51 Joining a Peer Group.....................................................................................................54 Membership Service.................................................................................................54 createGroup()............................................................................................................55 joinGroup()...............................................................................................................55 Source Code: JoinDemo...........................................................................................57 Sending Messages Between Two Peers.........................................................................60 JXTAPipe Service....................................................................................................60 PipeListener..............................................................................................................61 pipeMsgEvent()........................................................................................................62 Source Code: PipeListener.......................................................................................63 PipeExample.............................................................................................................67 outputPipeEvent() ....................................................................................................67 rendezvousEvent()....................................................................................................68 Source Code: PipeExample......................................................................................69 examplepipe.adv.......................................................................................................73 Using a JxtaBiDiPipe (A bidirectional reliable pipe)....................................................74 JxtaBiDiPipe.............................................................................................................74 JxtaServerPipeExample............................................................................................75 Source Code: JxtaServerPipeExample.....................................................................76 Example pipe advertisement: pipe.adv.....................................................................81 JxtaBidiPipeExample...............................................................................................82
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages147 Page
-
File Size-