Package org.switchyard

Examples of org.switchyard.HandlerException


            CommonCommonLogger.ROOT_LOGGER.replyArrivedAfterTimeout(exchange.getConsumer().getName().toString());
        } else {
            try {
                _responseQueue.put(exchange);
            } catch (InterruptedException e) {
                throw new HandlerException(e);
            }
        }
    }
View Full Code Here


            Object propagateException = _domain.getProperty(Exchange.PROPAGATE_EXCEPTION_ON_IN_ONLY);
            if (propagateException != null && Boolean.parseBoolean(propagateException.toString())
                    && camelExchange.isFailed()) {
                Exception camelException = camelExchange.getException();
                if (camelException != null) {
                    throw new HandlerException(camelException);
                } else {
                    throw CommonCamelMessages.MESSAGES.camelExchangeFailedWithoutAnException("");
                }
            }
        } catch (final CamelExecutionException e) {
            throw new HandlerException(e);
        }
    }
View Full Code Here

            if (camelFault != null && declaredFault != null && declaredFault.isAssignableFrom(camelFault.getClass())) {
                Message msg = null;
                try {
                    msg = _messageComposer.compose(bindingData, switchyardExchange);
                } catch (Exception e) {
                    throw new HandlerException(e);
                }
                switchyardExchange.sendFault(msg);
            } else if (camelFault instanceof Throwable) {
                throw new HandlerException(Throwable.class.cast(camelFault));
            } else {
                if (camelFault == null) {
                    throw CommonCamelMessages.MESSAGES.camelExchangeFailedWithoutAnException("");                   
                } else {
                    throw CommonCamelMessages.MESSAGES.camelExchangeFailedWithoutAnException(camelFault.toString());
View Full Code Here

    private void sendResponseToSwitchyard(final Exchange switchyardExchange, CamelBindingData bindingData) throws HandlerException {
        Message msg = null;
        try {
            msg = _messageComposer.compose(bindingData, switchyardExchange);
        } catch (Exception e) {
            throw new HandlerException(e);
        }
        switchyardExchange.send(msg);
    }
View Full Code Here

    public static Throwable getCauseFromHandlerException(final Throwable thrown) {
        Throwable cause = thrown;
        if (thrown instanceof InvocationFaultException) {
            final InvocationFaultException faultException = (InvocationFaultException) thrown;
            if (faultException.getCause() instanceof HandlerException) {
                HandlerException handlerEx = (HandlerException)faultException.getCause();
                cause = handlerEx.isWrapper() ? handlerEx.getCause() : handlerEx;
            } else if (faultException.getFaultMessage().getContent() instanceof Exception) {
                cause = faultException.getFaultMessage().getContent(Throwable.class);
            }
        }
        return cause;
View Full Code Here

                invokeRemote(exchange);
            } else {
                invokeLocal(exchange);
            }
        } catch (SwitchYardException syEx) {
            throw new HandlerException(syEx.getMessage());
        }
    }
View Full Code Here

    private HandlerException createHandlerException(Message message) {
        return createHandlerException(message == null ? null : message.getContent());
    }
   
    private HandlerException createHandlerException(Object content) {
        HandlerException ex;
        if (content == null) {
            ex = SCAMessages.MESSAGES.runtimeFaultOccurredWithoutExceptionDetails();
        } else if (content instanceof HandlerException) {
            ex = (HandlerException)content;
        } else if (content instanceof Throwable) {
            ex = new HandlerException((Throwable)content);
        } else {
            ex = new HandlerException(content.toString());
        }
        return ex;
    }
View Full Code Here

        try {
            restRequest = _messageComposer.decompose(exchange, new RESTEasyBindingData());
        } catch (Exception e) {
            final String m = RestEasyMessages.MESSAGES.unexpectedExceptionComposingRESTRequest();
            LOGGER.error(m, e);
            throw new HandlerException(m, e);
        }

        Object response = null;
        MethodInvoker methodInvoker = _methodMap.get(opName);
        if (methodInvoker == null) {
            final String m = RestEasyMessages.MESSAGES.unableToMapAmongResources(opName, _methodMap.keySet().toString());
            throw new HandlerException(m);
        }

        try {
            RESTEasyBindingData restResponse = methodInvoker.invoke(restRequest.getParameters(), restRequest.getHeaders());
            restResponse.setOperationName(opName);
            Message out = _messageComposer.compose(restResponse, exchange);
            // Our transformer magic transforms the entity appropriately here :)
            exchange.send(out);
        } catch (Exception e) {
            final String m = "Unexpected exception composing inbound Message from Outbound";
            LOGGER.error(m, e);
            throw new HandlerException(m, e);
        }
    }
View Full Code Here

            if (declaredFault != null && QNameUtil.isJavaMessageType(declaredFault)
                    && QNameUtil.toJavaMessageType(declaredFault).isAssignableFrom(e.getClass())) {
                Message msg = exchange.createMessage().setContent(e);
                exchange.sendFault(msg);
            } else {
                throw new HandlerException(e);
            }
        }
    }
View Full Code Here

    private void runFaultResultProcess(final boolean bomb) throws Exception {
        serviceDomain.registerService(new QName("TestService"), new InOnlyService(), new BaseHandler(){
            public void handleMessage(Exchange exchange) throws HandlerException {
                if (bomb) {
                    throw new HandlerException("BOOM!");
                }
            }
        });
        serviceDomain.registerServiceReference(new QName("TestService"), new InOutService());
        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
        kbuilder.add(ResourceFactory.newClassPathResource(FAULT_RESULT_PROCESS_BPMN), ResourceType.BPMN2);
        KieBase kbase = kbuilder.newKnowledgeBase();
        KieSession ksession = kbase.newKieSession();
        SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
        ssth.setProcessRuntime(ksession);
        ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
        ksession.getWorkItemManager().registerWorkItemHandler(ssth.getName(), ssth);
        WorkflowProcessInstance wpi = (WorkflowProcessInstance)ksession.startProcess("FaultResultProcess");
        HandlerException he = (HandlerException)wpi.getVariable("faultResult");
        if (bomb) {
            Assert.assertNotNull(he);
            Assert.assertEquals("BOOM!", he.getMessage());
        } else {
            Assert.assertNull(he);
        }
        ksession.halt();
        ksession.dispose();
View Full Code Here

TOP

Related Classes of org.switchyard.HandlerException

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.