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 019/** 020 * Bean post processor. 021 */ 022public interface CamelBeanPostProcessor { 023 024 /** 025 * Apply this post processor to the given new bean instance <i>before</i> any bean 026 * initialization callbacks (like <code>afterPropertiesSet</code> 027 * or a custom init-method). The bean will already be populated with property values. 028 * The returned bean instance may be a wrapper around the original. 029 * 030 * @param bean the new bean instance 031 * @param beanName the name of the bean 032 * @return the bean instance to use, either the original or a wrapped one; if 033 * <code>null</code>, no subsequent BeanPostProcessors will be invoked 034 * @throws Exception is thrown if error post processing bean 035 */ 036 default Object postProcessBeforeInitialization(Object bean, String beanName) throws Exception { 037 return bean; 038 } 039 040 /** 041 * Apply this post processor to the given new bean instance <i>after</i> any bean 042 * initialization callbacks (like <code>afterPropertiesSet</code> 043 * or a custom init-method). The bean will already be populated with property values. 044 * The returned bean instance may be a wrapper around the original. 045 * 046 * @param bean the new bean instance 047 * @param beanName the name of the bean 048 * @return the bean instance to use, either the original or a wrapped one; if 049 * <code>null</code>, no subsequent BeanPostProcessors will be invoked 050 * @throws Exception is thrown if error post processing bean 051 */ 052 default Object postProcessAfterInitialization(Object bean, String beanName) throws Exception { 053 return bean; 054 } 055 056}