设为首页 收藏本站
查看: 996|回复: 0

[经验分享] constellio——基于solr的开源搜索引擎系统源码研究(一)

[复制链接]

尚未签到

发表于 2015-7-16 14:04:21 | 显示全部楼层 |阅读模式
  以下为spring的配置文件 constellio.xml,对基础服务类进行配置










en
fr











http://127.0.0.1:8089/huilan-constellio


/WEB-INF/dictionaries



http://localhost:8089/huilan-constellio
        














































































































































































































        















relais.videotron.ca



25


baril.francis@gmail.com
                        











  接着是ConstellioSpringUtils.java工具类,获取spring容器里面的bean



/**
* Constellio, Open Source Enterprise Search
* Copyright (C) 2010 DocuLibre inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA  02110-1301  USA
*/
package com.doculibre.constellio.utils;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.Resource;
import com.doculibre.constellio.lucene.impl.FeaturedLinkIndexHelper;
import com.doculibre.constellio.lucene.impl.FreeTextTagIndexHelper;
import com.doculibre.constellio.lucene.impl.SkosIndexHelper;
import com.doculibre.constellio.plugins.PluginFactory;
import com.doculibre.constellio.plugins.api.beans.BeanFactoryPlugin;
import com.doculibre.constellio.services.ACLServices;
import com.doculibre.constellio.services.AnalyzerClassServices;
import com.doculibre.constellio.services.AnalyzerServices;
import com.doculibre.constellio.services.AuthenticationServices;
import com.doculibre.constellio.services.AuthorizationServices;
import com.doculibre.constellio.services.AutocompleteServices;
import com.doculibre.constellio.services.BackupServices;
import com.doculibre.constellio.services.CategorizationServices;
import com.doculibre.constellio.services.ClickLogEntryServices;
import com.doculibre.constellio.services.ClusteringServices;
import com.doculibre.constellio.services.CollectionPermissionServices;
import com.doculibre.constellio.services.ConnectorInstanceServices;
import com.doculibre.constellio.services.ConnectorManagerServices;
import com.doculibre.constellio.services.ConnectorTypeMetaMappingServices;
import com.doculibre.constellio.services.ConnectorTypeServices;
import com.doculibre.constellio.services.ConstellioInitServices;
import com.doculibre.constellio.services.CopyFieldServices;
import com.doculibre.constellio.services.CredentialGroupServices;
import com.doculibre.constellio.services.DistributedSolrServerServices;
import com.doculibre.constellio.services.ElevateServices;
import com.doculibre.constellio.services.EmailServices;
import com.doculibre.constellio.services.FacetServices;
import com.doculibre.constellio.services.FavoriteDocumentServices;
import com.doculibre.constellio.services.FavoriteSearchServices;
import com.doculibre.constellio.services.FeaturedLinkServices;
import com.doculibre.constellio.services.FederationServices;
import com.doculibre.constellio.services.FieldTypeClassServices;
import com.doculibre.constellio.services.FieldTypeServices;
import com.doculibre.constellio.services.FilterClassServices;
import com.doculibre.constellio.services.FreeTextTagServices;
import com.doculibre.constellio.services.GroupServices;
import com.doculibre.constellio.services.ImportExportServices;
import com.doculibre.constellio.services.IndexFieldServices;
import com.doculibre.constellio.services.LoggingServices;
import com.doculibre.constellio.services.MetaNameServices;
import com.doculibre.constellio.services.RawContentServices;
import com.doculibre.constellio.services.RealisedSearchServices;
import com.doculibre.constellio.services.RecordCollectionServices;
import com.doculibre.constellio.services.RecordServices;
import com.doculibre.constellio.services.SearchAlertServices;
import com.doculibre.constellio.services.SearchInterfaceConfigServices;
import com.doculibre.constellio.services.SearchResultFieldServices;
import com.doculibre.constellio.services.SearchServices;
import com.doculibre.constellio.services.SkosServices;
import com.doculibre.constellio.services.SolrConfigServices;
import com.doculibre.constellio.services.SolrServices;
import com.doculibre.constellio.services.StatusServices;
import com.doculibre.constellio.services.SynonymServices;
import com.doculibre.constellio.services.TokenizerClassServices;
import com.doculibre.constellio.services.UserServices;
public class ConstellioSpringUtils {
private static ApplicationContext applicationContext;
private static void loadApplicationContext() {
if (applicationContext == null) {
applicationContext = new ClassPathXmlApplicationContext("constellio.xml");
}
}
public static void setApplicationContext(ApplicationContext applicationContext) {
ConstellioSpringUtils.applicationContext = applicationContext;
}
@SuppressWarnings("unchecked")
public static final  T getBean(String name) {
loadApplicationContext();
return (T) applicationContext.getBean(name);
}
@SuppressWarnings("unchecked")
public static final  T getPluggableBean(String name) {
T bean;
BeanFactoryPlugin beanFactoryPlugin = PluginFactory.getPlugin(BeanFactoryPlugin.class);
if (beanFactoryPlugin != null) {
bean = (T) beanFactoryPlugin.getBean(name);
} else {
bean = (T) getBean(name);
}
return bean;
}
public static Resource[] getResources(String locationPattern) {
loadApplicationContext();
try {
return applicationContext.getResources(locationPattern);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static Map getConfig() {
return getBean("config");
}
public static String getDictionaries() {
return (String) getConfig().get("dictionaries");
}
public static String getExternalServerURL() {
return (String) getConfig().get("externalServerUrl");
}
@SuppressWarnings("unchecked")
public static List getFileDownloadDirs() {
return (List) getConfig().get("fileDownloadDirs");
}
public static URL getDefaultConnectorManagerURL() {
String defaultConnectorManager = (String) getConfig().get("defaultConnectorManager");
try {
return new URL(defaultConnectorManager);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
@SuppressWarnings("unchecked")
public static List getSupportedLocales() {
List supportedLocales = new ArrayList();
List supportedLanguages = (List) getConfig().get("supportedLanguages");
for (String supportedLanguage : supportedLanguages) {
supportedLocales.add(new Locale(supportedLanguage));
}
return supportedLocales;
}
@SuppressWarnings("unchecked")
public static List getSearchableLocales() {
List searchableLocales = new ArrayList();
List searchableLanguages = (List) getConfig().get("searchableLanguages");
if (searchableLanguages != null) {
for (String searchableLanguage : searchableLanguages) {
searchableLocales.add(new Locale(searchableLanguage));
}
}
return searchableLocales;
}
public static Locale getDefaultLocale() {
return getSupportedLocales().get(0);
}
public static ACLServices getACLServices() {
return getPluggableBean("aclServices");
}
public static List getAvailablePluginNames() {
return getBean("availablePluginNames");
}
public static AnalyzerClassServices getAnalyzerClassServices() {
return getPluggableBean("analyzerClassServices");
}
public static AnalyzerServices getAnalyzerServices() {
return getPluggableBean("analyzerServices");
}
public static AuthenticationServices getAuthenticationServices() {
return getPluggableBean("authenticationServices");
}
public static AuthorizationServices getAuthorizationServices() {
return getPluggableBean("authorizationServices");
}
public static BackupServices getBackupServices() {
return getPluggableBean("backupServices");
}
public static ClickLogEntryServices getClickLogEntryServices() {
return getPluggableBean("clickLogEntryServices");
}
public static ClusteringServices getClusteringServices() {
return getPluggableBean("clusteringServices");
}
public static ConnectorInstanceServices getConnectorInstanceServices() {
return getPluggableBean("connectorInstanceServices");
}
public static ConnectorManagerServices getConnectorManagerServices() {
return getPluggableBean("connectorManagerServices");
}
public static ConnectorTypeMetaMappingServices getConnectorTypeMetaMappingServices() {
return getPluggableBean("connectorTypeMetaMappingServices");
}
public static ConnectorTypeServices getConnectorTypeServices() {
return getPluggableBean("connectorTypeServices");
}
public static ConstellioInitServices getConstellioInitServices() {
return getPluggableBean("constellioInitServices");
}
public static CredentialGroupServices getCredentialGroupServices() {
return getPluggableBean("credentialGroupServices");
}
public static ElevateServices getElevateServices() {
return getPluggableBean("elevateServices");
}
public static FacetServices getFacetServices() {
return getPluggableBean("facetServices");
}
public static FeaturedLinkIndexHelper getFeaturedLinkIndexHelper() {
return getPluggableBean("featuredLinkIndexHelper");
}
public static FeaturedLinkServices getFeaturedLinkServices() {
return getPluggableBean("featuredLinkServices");
}
public static FederationServices getFederationServices() {
return getPluggableBean("federationServices");
}
public static FieldTypeClassServices getFieldTypeClassServices() {
return getPluggableBean("fieldTypeClassServices");
}
public static FieldTypeServices getFieldTypeServices() {
return getPluggableBean("fieldTypeServices");
}
public static FilterClassServices getFilterClassServices() {
return getPluggableBean("filterClassServices");
}
public static FreeTextTagServices getFreeTextTagServices() {
return getPluggableBean("freeTextTagServices");
}
public static FreeTextTagIndexHelper getFreeTextTagIndexHelper() {
return getPluggableBean("freeTextTagIndexHelper");
}
public static GroupServices getGroupServices() {
return getPluggableBean("groupServices");
}
public static CollectionPermissionServices getCollectionPermissionServices() {
return getPluggableBean("collectionPermissionServices");
}
public static ImportExportServices getImportExportServices() {
return getPluggableBean("importExportServices");
}
public static IndexFieldServices getIndexFieldServices() {
return getPluggableBean("indexFieldServices");
}
public static MetaNameServices getMetaNameServices() {
return getPluggableBean("metaNameServices");
}
public static RawContentServices getRawContentServices() {
return getPluggableBean("rawContentServices");
}
public static RecordCollectionServices getRecordCollectionServices() {
return getPluggableBean("recordCollectionServices");
}
public static RecordServices getRecordServices() {
return getPluggableBean("recordServices");
}
public static SearchInterfaceConfigServices getSearchInterfaceConfigServices() {
return getPluggableBean("searchInterfaceConfigServices");
}
public static LoggingServices getLoggingServices() {
return getPluggableBean("loggingServices");
}
public static SearchResultFieldServices getSearchResultFieldServices() {
return getPluggableBean("searchResultFieldServices");
}
public static SearchServices getSearchServices() {
return getPluggableBean("searchServices");
}
public static SkosIndexHelper getSkosIndexHelper() {
return getPluggableBean("skosIndexHelper");
}
public static SkosServices getSkosServices() {
return getPluggableBean("skosServices");
}
public static SolrServices getSolrServices() {
return getPluggableBean("solrServices");
}
public static SolrConfigServices getSolrConfigServices() {
return getPluggableBean("solrConfigServices");
}
public static StatusServices getStatusServices() {
return getPluggableBean("statusServices");
}
public static CategorizationServices getCategorizationServices() {
return getPluggableBean("categorizationServices");
}
public static SynonymServices getSynonymServices() {
return getPluggableBean("synonymServices");
}
public static TokenizerClassServices getTokenizerClassServices() {
return getPluggableBean("tokenizerClassServices");
}
public static UserServices getUserServices() {
return getPluggableBean("userServices");
}
public static AutocompleteServices getAutocompleteServices() {
return getPluggableBean("autocompleteServices");
}
public static CopyFieldServices getCopyFieldServices() {
return getPluggableBean("copyFieldServices");
}
public static FavoriteDocumentServices getFavoriteDocumentServices() {
return getPluggableBean("favoriteDocumentServices");
}
public static SearchAlertServices getSearchAlertServices() {
return getPluggableBean("searchAlertServices");
}
public static RealisedSearchServices getRealisedSearchServices() {
return getPluggableBean("realisedSearchServices");
}
public static FavoriteSearchServices getFavoriteSearchServices() {
return getPluggableBean("favoriteSearchServices");
}
public static EmailServices getEmailServices() {
return getPluggableBean("emailServices");
}
public static DistributedSolrServerServices getDistributedSolrServerServices() {
return getPluggableBean("distributedSolrServerServices");
}
}

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-87364-1-1.html 上篇帖子: Apache Solr的索引和查询顺序 下篇帖子: [ solr扩展 ] MoreLikeThis的原理分析
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表