001    /**
002     * Copyright (c) 2000-2011 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.kernel.search;
016    
017    import com.liferay.portal.kernel.bean.BeanLocator;
018    import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
019    import com.liferay.portal.kernel.messaging.MessageBus;
020    import com.liferay.portal.kernel.messaging.MessageBusUtil;
021    import com.liferay.portal.kernel.portlet.PortletClassLoaderUtil;
022    
023    /**
024     * @author Michael C. Han
025     */
026    public class PluginSearchEngineConfigurator
027            extends AbstractSearchEngineConfigurator {
028    
029            @Override
030            protected IndexSearcher getIndexSearcher() {
031                    BeanLocator beanLocator = PortalBeanLocatorUtil.getBeanLocator();
032    
033                    return (IndexSearcher)beanLocator.locate(
034                            IndexSearcherProxyBean.class.getName());
035            }
036    
037            @Override
038            protected IndexWriter getIndexWriter() {
039                    BeanLocator beanLocator = PortalBeanLocatorUtil.getBeanLocator();
040    
041                    return (IndexWriter)beanLocator.locate(
042                            IndexWriterProxyBean.class.getName());
043            }
044    
045            @Override
046            protected MessageBus getMessageBus() {
047                    return MessageBusUtil.getMessageBus();
048            }
049    
050            @Override
051            protected ClassLoader getOperatingClassloader() {
052                    ClassLoader classLoader = PortletClassLoaderUtil.getClassLoader();
053    
054                    if (classLoader == null) {
055                            Thread currentThread = Thread.currentThread();
056    
057                            classLoader = currentThread.getContextClassLoader();
058                    }
059    
060                    return classLoader;
061            }
062    
063    }