001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel.spi; 018 019import java.util.EventObject; 020 021import org.apache.camel.Exchange; 022import org.apache.camel.NamedNode; 023import org.apache.camel.Processor; 024import org.apache.camel.spi.CamelEvent.ExchangeEvent; 025 026/** 027 * {@link org.apache.camel.spi.Breakpoint} are used by the {@link org.apache.camel.spi.Debugger} API. 028 * <p/> 029 * This allows you to register {@link org.apache.camel.spi.Breakpoint}s to the {@link org.apache.camel.spi.Debugger} 030 * and have those breakpoints activated when their {@link org.apache.camel.spi.Condition}s match. 031 * <p/> 032 * If any exceptions is thrown from the callback methods then the {@link org.apache.camel.spi.Debugger} 033 * will catch and log those at <tt>WARN</tt> level and continue. This ensures Camel can continue to route 034 * the message without having breakpoints causing issues. 035 * @see org.apache.camel.spi.Debugger 036 * @see org.apache.camel.spi.Condition 037 */ 038public interface Breakpoint { 039 040 /** 041 * State of the breakpoint as either active or suspended. 042 */ 043 enum State { 044 Active, Suspended 045 } 046 047 /** 048 * Gets the state of this break 049 * 050 * @return the state 051 */ 052 State getState(); 053 054 /** 055 * Suspend this breakpoint 056 */ 057 void suspend(); 058 059 /** 060 * Activates this breakpoint 061 */ 062 void activate(); 063 064 /** 065 * Callback invoked when the breakpoint was hit and the {@link Exchange} is about to be processed (before). 066 * @param exchange the {@link Exchange} 067 * @param processor the {@link Processor} about to be processed 068 * @param definition the {@link NamedNode} definition of the processor 069 */ 070 void beforeProcess(Exchange exchange, Processor processor, NamedNode definition); 071 072 /** 073 * Callback invoked when the breakpoint was hit and the {@link Exchange} has been processed (after). 074 * @param exchange the {@link Exchange} 075 * @param processor the {@link Processor} which was processed 076 * @param definition the {@link NamedNode} definition of the processor 077 * @param timeTaken time in millis it took to process the {@link Exchange} - time spend in breakpoint callbacks may affect this time 078 */ 079 void afterProcess(Exchange exchange, Processor processor, NamedNode definition, long timeTaken); 080 081 /** 082 * Callback invoked when the breakpoint was hit and any of the {@link Exchange} {@link EventObject event}s occurred. 083 * 084 * @param exchange the {@link Exchange} 085 * @param event the event (instance of {@link ExchangeEvent} 086 * @param definition the {@link NamedNode} definition of the last processor executed, 087 * may be <tt>null</tt> if not possible to resolve from tracing 088 * @see ExchangeEvent 089 */ 090 void onEvent(Exchange exchange, ExchangeEvent event, NamedNode definition); 091 092}