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;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
基于java的开发源码-copass源代码.zip
共42个文件
class:8个
xml:7个
java:7个
2 下载量 53 浏览量
2024-01-07
18:24:39
上传
评论
收藏 4.16MB ZIP 举报
温馨提示
基于java的开发源码-copass源代码.zip 基于java的开发源码-copass源代码.zip 基于java的开发源码-copass源代码.zip 基于java的开发源码-copass源代码.zip 基于java的开发源码-copass源代码.zip 基于java的开发源码-copass源代码.zip 基于java的开发源码-copass源代码.zip 基于java的开发源码-copass源代码.zip 基于java的开发源码-copass源代码.zip 基于java的开发源码-copass源代码.zip
资源推荐
资源详情
资源评论
收起资源包目录
基于java的开发源码-copass源代码.zip (42个子文件)
compass
paoding-analysis.jar 123KB
compass-2.1.0.jar 2.09MB
lucene-core.jar 800KB
compass-index-patch.jar 1KB
lucene-highlighter.jar 89KB
compass1
.classpath 1KB
.settings
org.eclipse.jdt.core.prefs 330B
.mymetadata 297B
src
paoding-dic-home.properties 65B
struts.xml 786B
com
v512
example
dao
ProductDao.java 311B
hibernate
ProductDaoHibernate.java 800B
service
ProductManager.java 276B
impl
CompassIndexBuilder.java 2KB
ProductManagerImpl.java 2KB
model
Product.java 1KB
Product.hbm.xml 1KB
action
ProductAction.java 1KB
.myhibernatedata 445B
WebRoot
WEB-INF
classes
paoding-dic-home.properties 65B
struts.xml 786B
com
v512
example
dao
ProductDao.class 354B
hibernate
ProductDaoHibernate.class 2KB
service
impl
CompassIndexBuilder$1.class 2KB
CompassIndexBuilder.class 2KB
ProductManagerImpl.class 3KB
ProductManager.class 337B
model
Product.hbm.xml 1KB
Product.class 2KB
action
ProductAction.class 2KB
lib
ojdbc14-10.2.0.3.jar 1.47MB
web.xml 2KB
applicationContext.xml 4KB
applicationContext-compass.xml 3KB
index.jsp 829B
product
input.jsp 2KB
search.jsp 544B
searchResults.jsp 808B
insertOk.jsp 374B
META-INF
MANIFEST.MF 39B
.springBeans 479B
.project 2KB
.myeclipse
共 42 条
- 1
资源评论
快乐无限出发
- 粉丝: 1126
- 资源: 7260
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功