Package javax.resource.spi.work

Examples of javax.resource.spi.work.Work


    }

    @Override
    public void runPhase(final FlowProcessingPhaseTemplate flowProcessingPhaseTemplate, final MessageProcessContext messageProcessContext, final PhaseResultNotifier phaseResultNotifier)
    {
        Work flowExecutionWork = new Work()
        {
            @Override
            public void release()
            {
            }

            @Override
            public void run()
            {
                try
                {
                    try
                    {
                        final AtomicReference exceptionThrownDuringFlowProcessing = new AtomicReference();
                        TransactionalErrorHandlingExecutionTemplate transactionTemplate = TransactionalErrorHandlingExecutionTemplate.
                                createMainExecutionTemplate(messageProcessContext.getFlowConstruct().getMuleContext(),
                                                            (messageProcessContext.getTransactionConfig() == null ? new MuleTransactionConfig() : messageProcessContext.getTransactionConfig()),
                                                            messageProcessContext.getFlowConstruct().getExceptionListener());
                        MuleEvent response = transactionTemplate.execute(new ExecutionCallback<MuleEvent>()
                        {
                            @Override
                            public MuleEvent process() throws Exception
                            {
                                try
                                {
                                    Object message = flowProcessingPhaseTemplate.getOriginalMessage();
                                    if (message == null)
                                    {
                                        return null;
                                    }
                                    MuleEvent muleEvent = flowProcessingPhaseTemplate.getMuleEvent();
                                    muleEvent = flowProcessingPhaseTemplate.beforeRouteEvent(muleEvent);
                                    muleEvent = flowProcessingPhaseTemplate.routeEvent(muleEvent);
                                    muleEvent = flowProcessingPhaseTemplate.afterRouteEvent(muleEvent);
                                    sendResponseIfNeccessary(muleEvent, flowProcessingPhaseTemplate);
                                    return muleEvent;
                                }
                                catch (Exception e)
                                {
                                    exceptionThrownDuringFlowProcessing.set(e);
                                    throw e;
                                }
                            }
                        });
                        if (exceptionThrownDuringFlowProcessing.get() != null && !(exceptionThrownDuringFlowProcessing.get() instanceof ResponseDispatchException))
                        {
                            sendResponseIfNeccessary(response, flowProcessingPhaseTemplate);
                        }
                        flowProcessingPhaseTemplate.afterSuccessfulProcessingFlow(response);
                    }
                    catch (ResponseDispatchException e)
                    {
                        flowProcessingPhaseTemplate.afterFailureProcessingFlow(e);
                    }
                    catch (MessagingException e)
                    {
                        sendFailureResponseIfNeccessary(e, flowProcessingPhaseTemplate);
                        flowProcessingPhaseTemplate.afterFailureProcessingFlow(e);
                    }
                    phaseResultNotifier.phaseSuccessfully();
                }
                catch (Exception e)
                {
                    MuleException me = new DefaultMuleException(e);
                    try
                    {
                        flowProcessingPhaseTemplate.afterFailureProcessingFlow(me);
                    }
                    catch (MuleException e1)
                    {
                        logger.warn("Failure during exception processing in flow template: " + e.getMessage());
                        if (logger.isDebugEnabled())
                        {
                            logger.debug(e);
                        }
                    }
                    phaseResultNotifier.phaseFailure(e);
                }
            }
        };
        if (messageProcessContext.supportsAsynchronousProcessing())
        {
            try
            {
                messageProcessContext.getFlowExecutionWorkManager().scheduleWork(flowExecutionWork);
            }
            catch (WorkException e)
            {
                phaseResultNotifier.phaseFailure(e);
            }
        }
        else
        {
            flowExecutionWork.run();
        }
    }
View Full Code Here


    @Override
    public void runPhase(final AsyncResponseFlowProcessingPhaseTemplate template, final MessageProcessContext messageProcessContext, final PhaseResultNotifier phaseResultNotifier)
    {
        Preconditions.checkArgument(messageProcessContext.supportsAsynchronousProcessing(), String.format("Cannot execute %s if %s does not support asynchronous processing", this.getClass().getName(), messageProcessContext.getClass().getName()));
        Work flowExecutionWork = new Work()
        {
            @Override
            public void release()
            {
            }
View Full Code Here

    {
        try
        {
            workTracker.addWork(work);

            Work wrappedWork = new TrackeableWork(work);

            return delegateHolder.getWorkManager().startWork(wrappedWork);
        }
        catch (WorkException e)
        {
View Full Code Here

    {
        try
        {
            workTracker.addWork(work);

            Work wrappedWork = new TrackeableWork(work);

            delegateHolder.getWorkManager().scheduleWork(wrappedWork);
        }
        catch (WorkException e)
        {
View Full Code Here

        }

        // Reconnect (retry policy will go into effect here if configured)
        try
        {
            connector.getMuleContext().getWorkManager().scheduleWork(new Work()
            {
                @Override
                public void release()
                {
                }
View Full Code Here

        try
        {
            wm.start();

            wm.startWork(new Work()
            {
                public void release()
                {
                    // no-op
                }
View Full Code Here

       
        try
        {
            wm.start();
           
            wm.doWork(new Work()
            {
                public void release()
                {
                    // no-op
                }
View Full Code Here

        try
        {
            wm.start();

            wm.scheduleWork(new Work()
            {
                public void release()
                {
                    // no-op
                }
View Full Code Here

        final Service service = getTestService();

        final AtomicInteger count = new AtomicInteger();
        for (int i = 0; i < 500; i++)
        {
            muleContext.getWorkManager().scheduleWork(new Work()
            {
                public void run()
                {
                    MuleEvent event;
                    try
View Full Code Here

        assertNull(connector.getScheduler());
    }

    protected Work createSomeWork()
    {
        return new Work()
        {
            public void run()
            {
                System.out.println("I'm doing some work");
            }
View Full Code Here

TOP

Related Classes of javax.resource.spi.work.Work

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.