Example usage for javax.xml.ws WebServiceException getCause

List of usage examples for javax.xml.ws WebServiceException getCause

Introduction

In this page you can find the example usage for javax.xml.ws WebServiceException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:org.yes.cart.cluster.node.impl.ManagerWsNodeServiceImpl.java

/**
 * {@inheritDoc}/* w ww . j a v a 2s .  co  m*/
 */
public void broadcast(final Message message) {

    if (reloadClusterTopics.contains(message.getSubject())) {
        LOG.info("Reloading cluster information before {}", message.getSubject());
        reloadClusterConfiguration();
    }

    final ContextRspMessage wsMessage = (ContextRspMessage) message;
    final AsyncContext context = wsMessage.getAsyncContext();

    final List<String> targets = message.getTargets();

    final List<Node> cluster = new ArrayList<Node>(getYesNodes());
    if (CollectionUtils.isNotEmpty(targets)) {
        final Iterator<Node> clusterIt = cluster.iterator();
        while (clusterIt.hasNext()) {
            if (!targets.contains(clusterIt.next().getNodeId())) {
                clusterIt.remove();
            }
        }
    }

    for (final Node yesNode : cluster) {
        try {
            final WsClientFactory<WebServiceInboundChannel> factory = getWebServiceInboundChannel(context,
                    yesNode.getChannel(), (String) context.getAttribute(AsyncContext.TIMEOUT_KEY));

            WebServiceInboundChannel service = factory.getService();
            try {
                final WsMessage rsp = service.accept(new WsMessage(wsMessage));
                if (rsp instanceof WsMessage) {
                    wsMessage.addResponse(new BasicMessageImpl(rsp.getSource(), rsp.getTargets(),
                            rsp.getSubject(), rsp.getPayloadObject()));
                }
            } finally {
                factory.release(service);
                service = null;
            }

        } catch (javax.xml.ws.WebServiceException wse) {

            if (wse.getCause() instanceof ConnectException) {

                blacklist(yesNode.getNodeId());

                if (LOG.isErrorEnabled()) {
                    LOG.error("Cannot send message [" + message + "] to  url [" + yesNode.getNodeId() + ":"
                            + yesNode.getChannel() + "] . Blacklisting this node", wse);
                }

            } else {

                if (LOG.isErrorEnabled()) {
                    LOG.error("Cannot send message [" + message + "] to  url [" + yesNode.getNodeId() + ":"
                            + yesNode.getChannel() + "] . Exception occurred during ws call", wse);
                }

            }

        } catch (Exception e) {

            if (LOG.isErrorEnabled()) {
                LOG.error("Cannot send message [" + message + "] to  url [" + yesNode.getNodeId() + ":"
                        + yesNode.getChannel() + "] . Exception occurred during ws call", e);
            }

        }
    }

}