}
public String initPipes(int numPipes) {
int i=0;
JxtaBiDiPipe firstPipe = null;
boolean connected = false;
if (_pipelogger.isLoggable(Level.FINE)) {
_pipelogger.fine("Waiting for JxtaBidiPipe connections on JxtaServerPipe");
}
ArrayList pipeWrappers = new ArrayList();
String sourceInstanceName = null;
while (i < numPipes) {
try {
if (_pipelogger.isLoggable(Level.FINER)) {
_pipelogger.finer("JxtaServerPipeWrapper:JxtaBidiPipe# " + i + " waiting to accept");
}
JxtaBiDiPipe bipipe = serverPipe.accept();
sourceInstanceName = bipipe.getRemotePeerAdvertisement().getName();
if (_pipelogger.isLoggable(Level.FINEST)) {
_pipelogger.finest("sourceInstanceName=" + sourceInstanceName);
}
//for each pipe, create and register handler with manager
//later this can be a collection or pool in manager
if (bipipe != null) {
//ConnectionHandler handler = new ConnectionHandler(bipipe);
PipeWrapper pipeWrapper = new PipeWrapper("pipe#" + i, PipeWrapper.RECEIVER_PIPE, sourceInstanceName, bipipe);
bipipe.setMessageListener(pipeWrapper);
bipipe.setPipeEventListener(pipeWrapper);
if(i == 0) {
//first one is health pipe
//JxtaSenderPipeManager.createInstance().setHealthPipeWrapper(pipeWrapper);
//JxtaReceiverPipeManager.createInstance().setHealthPipeWrapper(pipeWrapper);
JxtaReceiverPipeManager.createInstance().setHealthPipeWrapper(pipeWrapper, sourceInstanceName);