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 org.apache.camel.Exchange; 020import org.apache.camel.Route; 021 022/** 023 * An extended {@link org.apache.camel.spi.Synchronization} which is route aware. 024 */ 025public interface SynchronizationRouteAware extends Synchronization { 026 027 /** 028 * Invoked before the {@link org.apache.camel.Exchange} is being routed by the given route. 029 * <p/> 030 * Notice if the exchange is being routed through multiple routes, there will be callbacks for each route. 031 * <p/> 032 * <b>Important:</b> this callback may not invoked if the {@link org.apache.camel.spi.SynchronizationRouteAware} implementation 033 * is being added to the {@link org.apache.camel.spi.UnitOfWork} after the routing has started. 034 * 035 * @param route the route 036 * @param exchange the exchange 037 */ 038 void onBeforeRoute(Route route, Exchange exchange); 039 040 /** 041 * Invoked after the {@link org.apache.camel.Exchange} has been routed by the given route. 042 * <p/> 043 * Notice if the exchange is being routed through multiple routes, there will be callbacks for each route. 044 * <p/> 045 * This invocation happens before these callbacks: 046 * <ul> 047 * <li>The consumer of the route writes any response back to the caller (if in InOut mode)</li> 048 * <li>The UoW is done calling either {@link #onComplete(org.apache.camel.Exchange)} or {@link #onFailure(org.apache.camel.Exchange)}</li> 049 * </ul> 050 * This allows custom logic to be executed after all routing is done, but before the {@link org.apache.camel.Consumer} prepares and writes 051 * any data back to the caller (if in InOut mode). 052 * 053 * @param route the route 054 * @param exchange the exchange 055 */ 056 void onAfterRoute(Route route, Exchange exchange); 057 058}