Package org.apache.tuscany.sca.binding.notification.encoding

Examples of org.apache.tuscany.sca.binding.notification.encoding.NewBrokerResponse


        eaed.start();
       
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader reader = xif.createXMLStreamReader(new StringReader(testNewBrokerResponse1));
        reader.next();
        NewBrokerResponse newBrokerResponse = (NewBrokerResponse)der.decode(reader);
        Assert.assertFalse(!newBrokerResponse.isFirstBroker());
        Assert.assertEquals(newBrokerResponse.getEndProducers().getSequenceType(), "NoProducers");
        Assert.assertEquals(newBrokerResponse.getEndConsumers().getSequenceType(), "EndConsumers");
        Assert.assertEquals(newBrokerResponse.getEndConsumers().getReferenceSequence().get(0).getEndpointAddress().getAddress().toString(),
                            testUrl1);
       
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        StringWriter testWriter = new StringWriter();
        XMLStreamWriter writer = xof.createXMLStreamWriter(testWriter);
View Full Code Here


        bied.start();
       
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader reader = xif.createXMLStreamReader(new StringReader(testNewBrokerResponse2));
        reader.next();
        NewBrokerResponse newBrokerResponse = (NewBrokerResponse)der.decode(reader);
        Assert.assertFalse(newBrokerResponse.isFirstBroker());
        Assert.assertEquals(newBrokerResponse.getBrokers().getBrokerSequence().get(0)
                            .getBrokerConsumerReference().getReference().getEndpointAddress().getAddress().toString(),
                            testUrl1);
        Assert.assertEquals(newBrokerResponse.getBrokers().getBrokerSequence().get(0)
                            .getBrokerProducerReference().getReference().getEndpointAddress().getAddress().toString(),
                            testUrl2);
       
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        StringWriter testWriter = new StringWriter();
View Full Code Here

        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();
View Full Code Here

        }
        if (ntmUrlIsRemote(producerUrl, remoteNtmUrl)) {
            try {
                WriteableNewBroker wnb = new WriteableNewBroker(consumerUrl, producerUrl, brokerID);
                InputStreamDecoder isd = new InputStreamDecoder();
                NewBrokerResponse nbr =
                    (NewBrokerResponse)IOUtils.sendHttpRequest(remoteNtmUrl, Constants.NEW_BROKER_OP, wnb, isd);
                if (nbr.isFirstBroker()) {
                    if (nbr.getEndConsumers().getSequenceType().equals(Constants.EndConsumers)) {
                        for (EndpointReference epr : nbr.getEndConsumers().getReferenceSequence()) {
                            consumerListResult.add(epr);
                        }
                    }
                    if (nbr.getEndProducers().getSequenceType().equals(Constants.EndProducers)) {
                        for (EndpointReference epr : nbr.getEndProducers().getReferenceSequence()) {
                            producerListResult.add(epr);
                        }
                    }
                } else {
                    for (Broker broker : nbr.getBrokers().getBrokerSequence()) {
                        consumerListResult.add(broker.getBrokerConsumerReference().getReference());
                        producerListResult.add(broker.getBrokerProducerReference().getReference());
                    }
                }
                return nbr.isFirstBroker();
            } catch(Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        } else {
View Full Code Here

        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();
View Full Code Here

        }
        if (ntmUrlIsRemote(producerUrl, remoteNtmUrl)) {
            try {
                WriteableNewBroker wnb = new WriteableNewBroker(consumerUrl, producerUrl, brokerID);
                InputStreamDecoder isd = new InputStreamDecoder();
                NewBrokerResponse nbr =
                    (NewBrokerResponse)IOUtils.sendHttpRequest(remoteNtmUrl, Constants.NEW_BROKER_OP, wnb, isd);
                if (nbr.isFirstBroker()) {
                    if (nbr.getEndConsumers().getSequenceType().equals(Constants.EndConsumers)) {
                        for (EndpointReference epr : nbr.getEndConsumers().getReferenceSequence()) {
                            consumerListResult.add(epr);
                        }
                    }
                    if (nbr.getEndProducers().getSequenceType().equals(Constants.EndProducers)) {
                        for (EndpointReference epr : nbr.getEndProducers().getReferenceSequence()) {
                            producerListResult.add(epr);
                        }
                    }
                }
                else {
                    for (Broker broker : nbr.getBrokers().getBrokerSequence()) {
                        consumerListResult.add(broker.getBrokerConsumerReference().getReference());
                        producerListResult.add(broker.getBrokerProducerReference().getReference());
                    }
                }
                return nbr.isFirstBroker();
            } catch(Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.binding.notification.encoding.NewBrokerResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.