|
Project JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.util.JxtaBiDiPipe
public class JxtaBiDiPipe
JxtaBiDiPipe is a bi-directional Pipe, it creates an InputPipe for incoming Messages, and EndpointMessenger for outgoing messages JxtaBiDiPipe defines its own protocol for negotiating connections. Connection requests arrive as a JXTA Message with the following elements :
<Credential> to determine whether requestor has the proper access to be granted a connection
<reqPipe> Requestor's pipe advertisement </reqPipe>
<remPipe> remote pipe advertisement </remPipe>
<remPeer> remote peer advertisement </remPeer>
<reliable> Reliability setting ("true", or "false") </reliable>
<data> data <data>
Field Summary | |
---|---|
protected String |
acceptLock
|
protected boolean |
bound
|
protected boolean |
closed
|
protected String |
closeLock
|
protected OutputPipe |
connectOutpipe
|
protected Credential |
credential
|
protected StructuredDocument |
credentialDoc
|
protected PipeEventListener |
eventListener
|
protected String |
finalLock
|
protected PeerGroup |
group
|
protected InputPipe |
in
|
protected boolean |
isReliable
|
protected PipeMsgListener |
listener
|
protected Messenger |
msgr
|
protected StructuredDocument |
myCredentialDoc
|
protected PipeAdvertisement |
myPipeAdv
|
protected net.jxta.impl.util.pipe.reliable.OutgoingMsgrAdaptor |
outgoing
|
static int |
PIPE_CLOSED_EVENT
Pipe close Event |
protected PipeAdvertisement |
pipeAdv
|
protected PipeService |
pipeSvc
|
protected net.jxta.impl.util.pipe.reliable.ReliableInputStream |
ris
|
protected net.jxta.impl.util.pipe.reliable.ReliableOutputStream |
ros
|
protected InputStream |
stream
|
protected boolean |
waiting
|
Constructor Summary | |
---|---|
|
JxtaBiDiPipe()
JxtaBiDiPipe A bidirectional pipe Creates a new object with a default timeout of 60,000ms, and a reliability setting of false |
protected |
JxtaBiDiPipe(PeerGroup group,
Messenger msgr,
PipeAdvertisement pipe,
StructuredDocument credDoc,
boolean isReliable)
JxtaBiDiPipe A bidirectional pipe |
|
JxtaBiDiPipe(PeerGroup group,
PipeAdvertisement pipeAd,
int timeout,
PipeMsgListener listener)
attempts to create a bidirectional connection to remote peer within default timeout of 1 minutes, and initiates a connection |
|
JxtaBiDiPipe(PeerGroup group,
PipeAdvertisement pipeAd,
int timeout,
PipeMsgListener listener,
boolean reliable)
attempts to create a bidirectional connection to remote peer within default timeout of 60,000ms, and initiates a connection |
|
JxtaBiDiPipe(PeerGroup group,
PipeAdvertisement pipeAd,
PipeMsgListener listener)
attempts to create a bidirectional connection to remote peer within default timeout of 60,000ms, and initiates a connection |
Method Summary | |
---|---|
protected void |
accept(JxtaBiDiPipe s)
Accepts a connection |
protected boolean |
checkCred(StructuredDocument cred)
Not implemented yet |
void |
close()
Closes this pipe. |
protected void |
closePipe()
|
void |
connect(PeerGroup group,
PeerID peerid,
PipeAdvertisement pipeAd,
int timeout,
PipeMsgListener listener)
Connects to a remote JxtaBiDiPipe |
void |
connect(PeerGroup group,
PeerID peerid,
PipeAdvertisement pipeAd,
int timeout,
PipeMsgListener listener,
boolean reliable)
Connects to a remote JxtaBiDiPipe |
void |
connect(PeerGroup group,
PipeAdvertisement pipeAd)
Connect to JxtaBiDiPipe with default timeout |
void |
connect(PeerGroup group,
PipeAdvertisement pipeAd,
int timeout)
Connects to a remote JxtaBiDiPipe |
protected Message |
createOpenMessage(PeerGroup group,
PipeAdvertisement pipeAd)
Create a connection request message |
protected static StructuredDocument |
getCredDoc(PeerGroup group)
obtain the cred doc from the group object |
StructuredDocument |
getCredentialDoc()
get the remote credential doc |
InputPipe |
getInputPipe()
Returns an input stream for this socket. |
PipeMsgListener |
getListener()
Returns the message listener for this pipe |
Message |
getMessage(int timeout)
Gets a message from the queue. |
Messenger |
getMessenger()
Deprecated. use sendMessage instead |
PipeAdvertisement |
getPipeAdvertisement()
Returns the Assigned PipeAdvertisement |
PeerAdvertisement |
getRemotePeerAdvertisement()
Returns remote PeerAdvertisement |
PipeAdvertisement |
getRemotePipeAdvertisement()
Returns remote PipeAdvertisement |
boolean |
isBound()
Returns the binding state of the JxtaServerPipe. |
protected static Messenger |
lightweightOutputPipe(PeerGroup group,
PipeAdvertisement pipeAdv,
PeerAdvertisement peer)
A lightweight output pipe constructor, note the return type Since all the info needed is available, there's no need for to use the pipe service to resolve the pipe we have all we need to construct a messenger. |
void |
outputPipeEvent(OutputPipeEvent event)
Called when a input pipe has been located for a previously registered pipe. |
void |
pipeMsgEvent(PipeMsgEvent event)
Called for each pipe message event that occurs. |
void |
processIncomingMessage(Message message)
/** This method is invoked by the Reliablity library for each incoming data message |
boolean |
sendMessage(Message msg)
Send a message |
void |
setCredentialDoc(StructuredDocument doc)
Sets the connection credential doc If no credentials are set, the default group credential will be used |
protected void |
setInputPipe(InputPipe in)
Sets the inputPipe attribute of the JxtaBiDiPipe object |
void |
setListener(PipeEventListener listener)
Sets a Pipe event listener, set listener to null to unset the listener |
void |
setListener(PipeMsgListener listener)
Sets message listener for a pipe spawned by the JxtaServerPipe. |
void |
setReliable(boolean reliable)
Toggles reliability |
protected void |
setRemotePeerAdvertisement(PeerAdvertisement peer)
Sets the remote PeerAdvertisement |
protected void |
setRemotePipeAdvertisement(PipeAdvertisement pipe)
Sets the remote PipeAdvertisement |
protected void |
waiter(int timeMilisecs)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected PeerGroup group
protected PipeAdvertisement pipeAdv
protected PipeAdvertisement myPipeAdv
protected PipeService pipeSvc
protected InputPipe in
protected OutputPipe connectOutpipe
protected Messenger msgr
protected InputStream stream
protected final String closeLock
protected final String acceptLock
protected final String finalLock
protected boolean closed
protected boolean bound
protected PipeMsgListener listener
protected PipeEventListener eventListener
protected Credential credential
protected boolean waiting
protected boolean isReliable
protected net.jxta.impl.util.pipe.reliable.OutgoingMsgrAdaptor outgoing
protected net.jxta.impl.util.pipe.reliable.ReliableInputStream ris
protected net.jxta.impl.util.pipe.reliable.ReliableOutputStream ros
protected StructuredDocument credentialDoc
protected StructuredDocument myCredentialDoc
public static final int PIPE_CLOSED_EVENT
Constructor Detail |
---|
protected JxtaBiDiPipe(PeerGroup group, Messenger msgr, PipeAdvertisement pipe, StructuredDocument credDoc, boolean isReliable) throws IOException
group
- group contextmsgr
- lightweight output pipepipe
- PipeAdvertisementisReliable
- Whether the connection is reliable or not
IOException
- if an io error occurspublic JxtaBiDiPipe()
public JxtaBiDiPipe(PeerGroup group, PipeAdvertisement pipeAd, PipeMsgListener listener) throws IOException
group
- group contextpipeAd
- PipeAdvertisementlistener
- application PipeMsgListener
IOException
- if an io error occurspublic JxtaBiDiPipe(PeerGroup group, PipeAdvertisement pipeAd, int timeout, PipeMsgListener listener) throws IOException
group
- group contextpipeAd
- PipeAdvertisementlistener
- application PipeMsgListener
IOException
- if an io error occurspublic JxtaBiDiPipe(PeerGroup group, PipeAdvertisement pipeAd, int timeout, PipeMsgListener listener, boolean reliable) throws IOException
group
- group contextpipeAd
- PipeAdvertisementlistener
- application PipeMsgListener
IOException
- if an io error occursMethod Detail |
---|
public void connect(PeerGroup group, PipeAdvertisement pipeAd) throws IOException
group
- group contextpipeAd
- PipeAdvertisement
IOException
- if an io error occurspublic void connect(PeerGroup group, PipeAdvertisement pipeAd, int timeout) throws IOException
group
- group contextpipeAd
- PipeAdvertisementtimeout
- timeout in ms, also reset object default timeout
to that of timeout
IOException
- if an io error occurspublic void connect(PeerGroup group, PeerID peerid, PipeAdvertisement pipeAd, int timeout, PipeMsgListener listener) throws IOException
group
- group contextpeerid
- peer to connect topipeAd
- PipeAdvertisementtimeout
- timeout in ms, also reset object default timeout to that of timeout
IOException
- if an io error occurspublic void connect(PeerGroup group, PeerID peerid, PipeAdvertisement pipeAd, int timeout, PipeMsgListener listener, boolean reliable) throws IOException
group
- group contextpeerid
- peer to connect topipeAd
- PipeAdvertisementtimeout
- timeout in ms, also reset object default timeout to that of timeoutreliable
- Reliable connection
IOException
- if an io error occurspublic void setReliable(boolean reliable) throws IOException
reliable
- Toggles reliability to reliable
IOEXecption
- if pipe is bound
IOException
protected static StructuredDocument getCredDoc(PeerGroup group)
group
- group context
public StructuredDocument getCredentialDoc()
public void setCredentialDoc(StructuredDocument doc)
doc
- Credential StructuredDocumentprotected Message createOpenMessage(PeerGroup group, PipeAdvertisement pipeAd) throws IOException
group
- group contextpipeAd
- pipe advertisement
IOException
protected void accept(JxtaBiDiPipe s) throws IOException
s
- the accepted connection.
IOException
- if an I/O error occurs when accepting the
connection.public boolean isBound()
public InputPipe getInputPipe() throws IOException
IOException
- if an I/O error occurs when creating the
input stream.public Messenger getMessenger() throws IOException
IOException
- if an I/O error occurs whenprotected void waiter(int timeMilisecs)
public PeerAdvertisement getRemotePeerAdvertisement()
public PipeAdvertisement getRemotePipeAdvertisement()
protected void setRemotePeerAdvertisement(PeerAdvertisement peer)
peer
- Remote PeerAdvertisementprotected void setRemotePipeAdvertisement(PipeAdvertisement pipe)
pipe
- PipeAdvertisementpublic void close() throws IOException
IOException
- if an I/O error occurs when closing this
socket.protected void closePipe() throws IOException
IOException
protected void setInputPipe(InputPipe in)
in
- The new inputPipe valuepublic void pipeMsgEvent(PipeMsgEvent event)
pipeMsgEvent
in interface PipeMsgListener
event
- The event being received.public void processIncomingMessage(Message message)
processIncomingMessage
in interface net.jxta.impl.util.pipe.reliable.ReliableInputStream.MsgListener
message
- Incoming messagepublic boolean sendMessage(Message msg) throws IOException
msg
- Message to send to the remote side
IOException
public void outputPipeEvent(OutputPipeEvent event)
OutputPipe
which can
be used to communicate with the remote peer.
outputPipeEvent
in interface OutputPipeListener
event
- the eventprotected static Messenger lightweightOutputPipe(PeerGroup group, PipeAdvertisement pipeAdv, PeerAdvertisement peer)
group
- group contextpipeAdv
- Remote Pipe Advertisementpeer
- Remote Peer advertisement
protected boolean checkCred(StructuredDocument cred)
public PipeMsgListener getListener()
public void setListener(PipeMsgListener listener)
listener
- New value of property listener.public void setListener(PipeEventListener listener)
listener
- New value of property listener.public Message getMessage(int timeout) throws InterruptedException
timeout
- Amount of time to wait in milliseconds for an object to
be available. Per Java convention, a timeout of zero (0) means wait an
infinite amount of time. Negative values mean do not wait at all.
InterruptedException
- if the operation is interrupted before
the timeout interval is completed.public PipeAdvertisement getPipeAdvertisement()
|
JXTA J2SE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |