private void handleNewBroker(NewBroker nb, ServletOutputStream ostream) {
synchronized(notificationTypeLock) {
if (notificationTypeLock.isLocked) {
try { notificationTypeLock.wait(); } catch(InterruptedException e) {}
}
NewBrokerResponse nbr = new NewBrokerResponse();
if (consumerList != null || producerList != null || brokerList == null) {
nbr.setFirstBroker(true);
EndConsumers endConsumers = new EndConsumers();
if (consumerList != null) {
endConsumers.setSequenceType(Constants.EndConsumers);
for (URL consumerUrl : consumerList) {
endConsumers.addReferenceToSequence(EncodingUtils.createEndpointReference(consumerUrl, null));
}
} else {
endConsumers.setSequenceType(Constants.NoConsumers);
}
nbr.setEndConsumers(endConsumers);
EndProducers endProducers = new EndProducers();
if (producerList != null) {
endProducers.setSequenceType(Constants.EndProducers);
for (URL producerUrl : producerList) {
endProducers.addReferenceToSequence(EncodingUtils.createEndpointReference(producerUrl, null));
}
} else {
endProducers.setSequenceType(Constants.NoProducers);
}
nbr.setEndProducers(endProducers);
} else {
nbr.setFirstBroker(false);
Brokers brokers = new Brokers();
for (BrokerStruct brokerStruct : brokerList) {
Broker brokerElt = new Broker();
BrokerConsumerReference bcr = new BrokerConsumerReference();
bcr.setReference(EncodingUtils.createEndpointReference(brokerStruct.consumerUrl, brokerStruct.brokerID));
brokerElt.setBrokerConsumerReference(bcr);
BrokerProducerReference bpr = new BrokerProducerReference();
bpr.setReference(EncodingUtils.createEndpointReference(brokerStruct.producerUrl, brokerStruct.brokerID));
brokerElt.setBrokerProducerReference(bpr);
brokers.addBrokerToSequence(brokerElt);
}
nbr.setBrokers(brokers);
}
EndpointReference consumerEPR = nb.getBrokerConsumerReference().getReference();
URL consumerUrl = consumerEPR.getEndpointAddress().getAddress();
BrokerID consumerBrokerID = consumerEPR.getReferenceProperties().getProperty(BrokerID.class);
EndpointReference producerEPR = nb.getBrokerProducerReference().getReference();