001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }