001    /**
002     * Copyright (c) 2000-present 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.portlet.PortletClassLoaderUtil;
020    
021    /**
022     * @author Michael C. Han
023     */
024    public class PluginSearchEngineConfigurator
025            extends AbstractSearchEngineConfigurator {
026    
027            public void setDefaultSearchEngineId(String defaultSearchEngineId) {
028                    _defaultSearchEngineId = defaultSearchEngineId;
029            }
030    
031            @Override
032            protected String getDefaultSearchEngineId() {
033                    return _defaultSearchEngineId;
034            }
035    
036            @Override
037            protected IndexSearcher getIndexSearcher() {
038                    BeanLocator beanLocator = PortalBeanLocatorUtil.getBeanLocator();
039    
040                    return (IndexSearcher)beanLocator.locate(
041                            IndexSearcherProxyBean.class.getName());
042            }
043    
044            @Override
045            protected IndexWriter getIndexWriter() {
046                    BeanLocator beanLocator = PortalBeanLocatorUtil.getBeanLocator();
047    
048                    return (IndexWriter)beanLocator.locate(
049                            IndexWriterProxyBean.class.getName());
050            }
051    
052            @Override
053            protected ClassLoader getOperatingClassloader() {
054                    ClassLoader classLoader = PortletClassLoaderUtil.getClassLoader();
055    
056                    if (classLoader == null) {
057                            Thread currentThread = Thread.currentThread();
058    
059                            classLoader = currentThread.getContextClassLoader();
060                    }
061    
062                    return classLoader;
063            }
064    
065            private String _defaultSearchEngineId;
066    
067    }