1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.spring.context;
16  
17  import com.liferay.portal.kernel.portlet.PortletClassLoaderUtil;
18  import com.liferay.portal.kernel.util.AggregateClassLoader;
19  import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
20  import com.liferay.portal.spring.util.FilterClassLoader;
21  
22  import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
23  import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
24  
25  /**
26   * <a href="PortletBeanFactoryPostProcessor.java.html"><b><i>View Source</i></b>
27   * </a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class PortletBeanFactoryPostProcessor
32      implements BeanFactoryPostProcessor {
33  
34      public void postProcessBeanFactory(
35          ConfigurableListableBeanFactory beanFactory) {
36  
37          ClassLoader beanClassLoader =
38              AggregateClassLoader.getAggregateClassLoader(
39                  new ClassLoader[] {
40                      PortletClassLoaderUtil.getClassLoader(),
41                      PortalClassLoaderUtil.getClassLoader()
42                  });
43  
44          beanClassLoader = new FilterClassLoader(beanClassLoader);
45  
46          beanFactory.setBeanClassLoader(beanClassLoader);
47      }
48  
49  }