⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 constants.java

📁 这是一款最新的野蔷薇论坛源码,有需要的朋友可以尽情下载
💻 JAVA
字号:
/* 
 * Created on 2007-5-27
 * Last modified on 2007-5-27
 * Powered by GamVan.com
 */
package com.yeqiangwei.club.service.search;

import java.io.File;
import java.io.IOException;

import org.apache.log4j.Logger;

import org.apache.lucene.index.IndexReader;
import org.apache.lucene.store.Directory;

import com.yeqiangwei.util.Validator;

public class Constants {
	
	private static Logger logger = Logger.getLogger(Constants.class);
	
	public static String REAL_PATH = null;
	
	public static String INDEX_PATH = null;
	
	public static int TOPICID = 0; //正在创建索引的文章ID
	
	public static int STOP = 0;
	
	static
	{
		logger.debug("=============初始化开始===============");
		logger.debug(Constants.class.getResource("/"));
		logger.debug(Constants.class.getResource("/").getFile());
		logger.debug((new File(Constants.class.getResource("/").getFile())));
		logger.debug((new File(Constants.class.getResource("/").getFile())).getParentFile());
		logger.debug((new File(Constants.class.getResource("/").getFile())).getParentFile().getParent());
		if(REAL_PATH==null) REAL_PATH = (new File(Constants.class.getResource("/").getFile())).getParentFile().getParent()+File.separator;
		logger.debug("REAL_PATH:"+REAL_PATH);
		if(INDEX_PATH==null) INDEX_PATH = REAL_PATH+"WEB-INF"+File.separator+"index"+File.separator;
		checkDirectory();
		logger.debug("=============初始化结束================");
	}
	
	private static void checkDirectory()
	{
		logger.debug(INDEX_PATH);
		File indexFolder = new File(INDEX_PATH);
		File[] indexDirs = indexFolder.listFiles();
		if(!Validator.isEmpty(indexDirs)){
			for(File file:indexDirs)
			{
				if(file.isDirectory()){
					try {
						Directory directory = SearchUtils.getDirectory(file);
						if(IndexReader.isLocked(directory))
						{
							logger.debug(file.getAbsoluteFile()+" is locked .try to unlock");
							//IndexReader reader = IndexReader.open(directory);
							IndexReader.unlock(directory);
						}
					} catch (IOException e) {
						logger.error(e.toString());
					}
				}
			}
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -