Search in sources :

Example 6 with Breakpoint

use of org.apache.camel.spi.Breakpoint in project camel by apache.

the class DefaultDebugger method addSingleStepBreakpoint.

@Override
public void addSingleStepBreakpoint(final Breakpoint breakpoint, Condition... conditions) {
    // wrap the breakpoint into single step breakpoint so we can automatic enable/disable the single step mode
    Breakpoint singlestep = new Breakpoint() {

        @Override
        public State getState() {
            return breakpoint.getState();
        }

        @Override
        public void suspend() {
            breakpoint.suspend();
        }

        @Override
        public void activate() {
            breakpoint.activate();
        }

        @Override
        public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
            breakpoint.beforeProcess(exchange, processor, definition);
        }

        @Override
        public void afterProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, long timeTaken) {
            breakpoint.afterProcess(exchange, processor, definition, timeTaken);
        }

        @Override
        public void onEvent(Exchange exchange, EventObject event, ProcessorDefinition<?> definition) {
            if (event instanceof ExchangeCreatedEvent) {
                exchange.getContext().getDebugger().startSingleStepExchange(exchange.getExchangeId(), this);
            } else if (event instanceof ExchangeCompletedEvent) {
                exchange.getContext().getDebugger().stopSingleStepExchange(exchange.getExchangeId());
            }
            breakpoint.onEvent(exchange, event, definition);
        }

        @Override
        public String toString() {
            return breakpoint.toString();
        }
    };
    addBreakpoint(singlestep, conditions);
}
Also used : Exchange(org.apache.camel.Exchange) Breakpoint(org.apache.camel.spi.Breakpoint) ExchangeCreatedEvent(org.apache.camel.management.event.ExchangeCreatedEvent) Processor(org.apache.camel.Processor) ProcessorDefinition(org.apache.camel.model.ProcessorDefinition) ExchangeCompletedEvent(org.apache.camel.management.event.ExchangeCompletedEvent) EventObject(java.util.EventObject)

Aggregations

Breakpoint (org.apache.camel.spi.Breakpoint)6 Method (java.lang.reflect.Method)2 LinkedList (java.util.LinkedList)2 DefaultDebugger (org.apache.camel.impl.DefaultDebugger)2 Debugger (org.apache.camel.spi.Debugger)2 SpringCamelContext (org.apache.camel.spring.SpringCamelContext)2 EventObject (java.util.EventObject)1 Exchange (org.apache.camel.Exchange)1 Processor (org.apache.camel.Processor)1 ExchangeCompletedEvent (org.apache.camel.management.event.ExchangeCompletedEvent)1 ExchangeCreatedEvent (org.apache.camel.management.event.ExchangeCreatedEvent)1 ProcessorDefinition (org.apache.camel.model.ProcessorDefinition)1 DoToSpringCamelContextsStrategy (org.apache.camel.test.spring.CamelSpringTestHelper.DoToSpringCamelContextsStrategy)1