Package org.switchyard

Examples of org.switchyard.HandlerException


    private void runFaultEventProcess(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_EVENT_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("FaultEventProcess");
        HandlerException he = (HandlerException)wpi.getVariable("faultEvent");
        if (bomb) {
            Assert.assertNotNull(he);
            Assert.assertEquals("BOOM!", he.getMessage());
        } else {
            Assert.assertNull(he);
        }
        ksession.halt();
        ksession.dispose();
View Full Code Here


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

   
    @Test
    public void undeclaredException() {
        testKit.registerInOutService(REFERENCE_A, new BaseHandler() {
            public void handleMessage(Exchange exchange) throws HandlerException {
                throw new HandlerException(new DummyException(
                        exchange.getMessage().getContent(String.class)));
            }
        });
        invokerService.operation("undeclaredException").sendInOut("undeclaredException");
    }
View Full Code Here

    @Override
    public void handleMessage(final Exchange switchYardExchange) throws HandlerException {
        try {
            compose(switchYardExchange);
        } catch (Exception e) {
            throw new HandlerException(e);
        }
    }
View Full Code Here

                            exchange.sendFault(exchange.createMessage().setContent(faultContent));
                            return;
                        }
                    }
                }
                throw new HandlerException(faultContent);
            }
        } else {
            throw BeanMessages.MESSAGES.unexpectedErrorBeanServiceMetadataShouldReturnAnInvocationInstanceOrThrowABeanComponentException();
        }
    }
View Full Code Here

            if (camelFault != null && declaredFault != null && declaredFault.isAssignableFrom(camelFault.getClass())) {
                Message msg = switchyardExchange.createMessage().setContent(camelFault);
                switchyardExchange.sendFault(msg);
            } else if (camelFault instanceof Throwable) {
                throw new HandlerException(Throwable.class.cast(camelFault));
            } else if (camelFault instanceof Node) {
                Message msg = switchyardExchange.createMessage().setContent((Node)camelFault);
                switchyardExchange.sendFault(msg);
            } else {
                String faultMessage = (camelFault == null) ? null : camelFault.toString();
View Full Code Here

    private void invokeCamelProcessor(final org.apache.camel.Exchange camelExchange) throws HandlerException {
        try {
            getProcessor().process(camelExchange);
        } catch (final Exception e) {
            throw new HandlerException(e);
        }
    }
View Full Code Here

                throw createException(_replyHandler.getExchange());
            }
           
            // Unwrap HandlerException instances if appropriate
            if (error instanceof HandlerException) {
                HandlerException haEx = (HandlerException)error;
                error = haEx.isWrapper() ? haEx.getCause() : haEx;
            }
           
            // Time to throw up!
            if (error instanceof Exception) {
                throw (Exception)error;
View Full Code Here

                Detail detail=fault.addDetail();
                Node cloned=detail.getOwnerDocument().importNode(WSDLHelper.unwrapMessagePart(f.getFaultMessage()), true);
                detail.appendChild(cloned);
       
            } catch (Exception e) {
                throw new HandlerException(e);
            }
           
            Message msg = exchange.createMessage().setContent(fault);
            exchange.sendFault(msg);
           
        } catch (Exception e) {
            throw new HandlerException(e);
        }
    }
View Full Code Here

                                BusLogger.ROOT_LOGGER.alreadyInFaultState(error);
                            } else {
                                if (error instanceof HandlerException) {
                                    throw (HandlerException)error;
                                } else {
                                    throw new HandlerException(error);
                                }
                            }
                        }
                    }
                }
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.