View Javadoc

1   /*
2    * Copyright 2006-2008 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.osgi.extender;
18  
19  import org.osgi.framework.BundleContext;
20  import org.osgi.framework.BundleException;
21  import org.osgi.framework.InvalidSyntaxException;
22  import org.springframework.beans.BeansException;
23  import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
24  
25  /**
26   * Extender hook that allows custom modification of an application context's
27   * bean definitions. New beans can be created, removed or existing definitions
28   * modified.
29   * 
30   * <p/> Similar in functionality with Spring's BeanFactoryPostProcessor, this
31   * interface also considers the BundleContext in which the beanFactory runs.
32   * 
33   * <p/>Just like the BeanFactoryPostProcessor, the post processing happens
34   * during the creation of the bean factory but before any beans (including
35   * declared BeanFactoryPostProcessors) are initialized.
36   * 
37   * @see org.springframework.beans.factory.config.BeanFactoryPostProcessor
38   * @see BundleContext
39   * 
40   * @author Costin Leau
41   */
42  public interface OsgiBeanFactoryPostProcessor {
43  
44  	/**
45  	 * 
46  	 * Modifies the application context's internal bean factory after its
47  	 * standard initialization. All bean definitions will have been loaded, but
48  	 * no beans will have been instantiated yet. This allows for overriding or
49  	 * adding properties even to eager-initializing beans.
50  	 * 
51  	 * @param bundleContext bundle
52  	 * @param beanFactory the bean factory used by the application context
53  	 * @throws BeansException in case of factory errors
54  	 * @throws InvalidSyntaxException in case of OSGi filters errors
55  	 * @throws BundleException in case of OSGi bundle errors
56  	 */
57  	void postProcessBeanFactory(BundleContext bundleContext, ConfigurableListableBeanFactory beanFactory)
58  			throws BeansException, InvalidSyntaxException, BundleException;
59  }