001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.spring.context;
016    
017    import com.liferay.portal.kernel.portlet.PortletClassLoaderUtil;
018    import com.liferay.portal.kernel.util.AggregateClassLoader;
019    import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
020    import com.liferay.portal.spring.util.FilterClassLoader;
021    
022    import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
023    import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class PortletBeanFactoryPostProcessor
029            implements BeanFactoryPostProcessor {
030    
031            public void postProcessBeanFactory(
032                    ConfigurableListableBeanFactory beanFactory) {
033    
034                    ClassLoader beanClassLoader =
035                            AggregateClassLoader.getAggregateClassLoader(
036                                    new ClassLoader[] {
037                                            PortletClassLoaderUtil.getClassLoader(),
038                                            PortalClassLoaderUtil.getClassLoader()
039                                    });
040    
041                    beanClassLoader = new FilterClassLoader(beanClassLoader);
042    
043                    beanFactory.setBeanClassLoader(beanClassLoader);
044            }
045    
046    }