package com.v512.example.service.impl;
import org.compass.gps.CompassGps;
import org.springframework.beans.factory.InitializingBean;
/**
* 通过quartz定时调度定时重建索引或自动随Spring ApplicationContext启动而重建索引的Builder.
* 会启动后延时数秒新开线程调用compassGps.index()函数.
* 默认会在Web应用每次启动时重建索引,可以设置buildIndex属性为false来禁止此功能.
* 也可以不用本Builder, 编写手动调用compassGps.index()的代码.
*
*/
public class CompassIndexBuilder implements InitializingBean {
// 是否需要建立索引,可被设置为false使本Builder失效.
private boolean buildIndex = false;
// 索引操作线程延时启动的时间,单位为秒
private int lazyTime = 10;
// Compass封装
private CompassGps compassGps;
// 索引线程
private Thread indexThread = new Thread() {
@Override
public void run() {
try {
Thread.sleep(lazyTime * 1000);
System.out.println("begin compass index...");
long beginTime = System.currentTimeMillis();
// 重建索引.
// 如果compass实体中定义的索引文件已存在,索引过程中会建立临时索引,
// 索引完成后再进行覆盖.
compassGps.index();
long costTime = System.currentTimeMillis() - beginTime;
System.out.println("compss index finished.");
System.out.println("costed " + costTime + " milliseconds");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
/**
* 实现<code>InitializingBean</code>接口,在完成注入后调用启动索引线程.
*
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
public void afterPropertiesSet() throws Exception {
if (buildIndex) {
indexThread.setDaemon(true);
indexThread.setName("Compass Indexer");
indexThread.start();
}
}
public void setBuildIndex(boolean buildIndex) {
this.buildIndex = buildIndex;
}
public void setLazyTime(int lazyTime) {
this.lazyTime = lazyTime;
}
public void setCompassGps(CompassGps compassGps) {
this.compassGps = compassGps;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
compass_src.rar (42个子文件)
compass
lucene-highlighter.jar 89KB
compass-index-patch.jar 1KB
paoding-analysis.jar 123KB
lucene-core.jar 800KB
compass-2.1.0.jar 2.09MB
compass1
.project 2KB
.settings
org.eclipse.jdt.core.prefs 330B
.mymetadata 297B
WebRoot
WEB-INF
web.xml 2KB
applicationContext.xml 4KB
applicationContext-compass.xml 3KB
lib
ojdbc14-10.2.0.3.jar 1.47MB
classes
com
v512
example
dao
ProductDao.class 354B
hibernate
ProductDaoHibernate.class 2KB
action
ProductAction.class 2KB
model
Product.hbm.xml 1KB
Product.class 2KB
service
ProductManager.class 337B
impl
CompassIndexBuilder.class 2KB
CompassIndexBuilder$1.class 2KB
ProductManagerImpl.class 3KB
paoding-dic-home.properties 65B
struts.xml 786B
index.jsp 829B
META-INF
MANIFEST.MF 39B
product
searchResults.jsp 808B
input.jsp 2KB
search.jsp 544B
insertOk.jsp 374B
.myeclipse
src
com
v512
example
dao
hibernate
ProductDaoHibernate.java 800B
ProductDao.java 311B
action
ProductAction.java 1KB
model
Product.hbm.xml 1KB
Product.java 1KB
service
impl
ProductManagerImpl.java 2KB
CompassIndexBuilder.java 2KB
ProductManager.java 276B
paoding-dic-home.properties 65B
struts.xml 786B
.springBeans 479B
.classpath 1KB
.myhibernatedata 445B
共 42 条
- 1
资源评论
- yy70158042013-07-05给了不少帮助,谢谢楼主
- 阿亮说技术2013-09-03还可以,可以运行,谢谢了
- dahaizwl2014-05-27学习学习这三个框架!
xusiyuan
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- mmqrcode1714153659780.png
- Screenshot_2024-04-27-06-08-58-486_com.baidu.xin.aiqicha.jpg
- 基于Javaweb+Tomcat+MySQL的大学生公寓管理系统+sql文件.zip
- 实训作业基于javaweb的订单管理系统源码+数据库+实训报告.zip
- 多机调度问题贪心算法基于最小堆和贪心算法求解多机调度问题.zip
- 基于同态加密技术的匿名电子投票系统源码.zip
- Pyqt5项目框架-PyQt项目开发实践
- 基于C通过MQTT的智能农业大棚管理系统(本科毕业设计)
- python+CNN的网络入侵检测算法源码.zip
- js 实现记住密码功能 js.cookie.min.js
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功