Project JXTA

net.jxta.impl.pipe
Class WirePipe

java.lang.Object
  extended bynet.jxta.impl.pipe.WirePipe
All Implemented Interfaces:
EndpointListener, InputPipe, PipeRegistrar

public class WirePipe
extends Object
implements EndpointListener, InputPipe, PipeRegistrar

This class implements the JXTA-WIRE pipe.


Constructor Summary
WirePipe(PeerGroup g, PipeResolver pipeResolver, WirePipeImpl pipeService, PipeAdvertisement adv)
          Constructor
 
Method Summary
 void close()
          
(package private)  String createMsgId()
          Create a unique (mostly) identifier for this message
protected  void finalize()
          

Closes the pipe.

 boolean forget(InputPipe wireinputpipe)
          This peer is no longer listening on the specified pipe.
 PipeAdvertisement getAdvertisement()
          
 String getName()
          
 ID getPipeID()
          
 String getType()
          
 Message poll(int timeout)
          
 void processIncomingMessage(Message message, EndpointAddress srcAddr, EndpointAddress dstAddr)
          
(package private)  void processIncomingMessage(Message message, WireHeader header, EndpointAddress srcAddr, EndpointAddress dstAddr)
          local version with the wire header already parsed.
 boolean register(InputPipe wireinputpipe)
          Register that this peer is an InputPipe for the specified Pipe ID.
(package private)  void repropagate(Message message, WireHeader header)
          Repropagate a message.
(package private)  void sendMessage(Message msg, Set peers)
          Send the message
 Message waitForMessage()
          
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WirePipe

public WirePipe(PeerGroup g,
                PipeResolver pipeResolver,
                WirePipeImpl pipeService,
                PipeAdvertisement adv)
Constructor

Parameters:
g - The Group associated with this service
pipeResolver - the associated pipe resolver
pipeService - The pipe service associated with this pipe
adv - pipe advertisement
Method Detail

finalize

protected void finalize()

Closes the pipe.


register

public boolean register(InputPipe wireinputpipe)
Register that this peer is an InputPipe for the specified Pipe ID.

Specified by:
register in interface PipeRegistrar
Parameters:
wireinputpipe - the pipe object

forget

public boolean forget(InputPipe wireinputpipe)
This peer is no longer listening on the specified pipe.

Specified by:
forget in interface PipeRegistrar
Returns:
true if the pipe was removed otherwise false.

waitForMessage

public Message waitForMessage()
                       throws InterruptedException

Specified by:
waitForMessage in interface InputPipe
Throws:
InterruptedException

poll

public Message poll(int timeout)
             throws InterruptedException

Specified by:
poll in interface InputPipe
Throws:
InterruptedException

close

public void close()

Specified by:
close in interface InputPipe

getType

public String getType()

Specified by:
getType in interface InputPipe

getPipeID

public ID getPipeID()

Specified by:
getPipeID in interface InputPipe

getName

public String getName()

Specified by:
getName in interface InputPipe

getAdvertisement

public PipeAdvertisement getAdvertisement()

Specified by:
getAdvertisement in interface InputPipe

processIncomingMessage

public void processIncomingMessage(Message message,
                                   EndpointAddress srcAddr,
                                   EndpointAddress dstAddr)

Specified by:
processIncomingMessage in interface EndpointListener

processIncomingMessage

void processIncomingMessage(Message message,
                            WireHeader header,
                            EndpointAddress srcAddr,
                            EndpointAddress dstAddr)
local version with the wire header already parsed. There are two paths to this point; via the local endpoint listener or via the general propagation listener in WirePipeImpl.


repropagate

void repropagate(Message message,
                 WireHeader header)
Repropagate a message.


sendMessage

void sendMessage(Message msg,
                 Set peers)
           throws IOException
Send the message

Parameters:
msg - The message to send.
peers - The peers to which the message will be sent. If the set is empty then the message is sent to all connected peers or via propagation to the rendezvous.
Throws:
IOException

createMsgId

String createMsgId()
Create a unique (mostly) identifier for this message


JXTA J2SE