优化注释与输出信息,现会打印被调用inform();方法的hashcode;

This commit is contained in:
magese 2018-09-03 13:53:28 +08:00
parent 0140ab4623
commit bb006641b0

View File

@ -19,7 +19,7 @@ import java.util.*;
/** /**
* @author <a href="magese@live.cn">Magese</a> * @author <a href="magese@live.cn">Magese</a>
*/ */
public class IKTokenizerFactory extends TokenizerFactory implements ResourceLoaderAware, UpdateKeeper.UpdateJob { public class IKTokenizerFactory extends TokenizerFactory implements ResourceLoaderAware, UpdateThread.UpdateJob {
private boolean useSmart; private boolean useSmart;
private ResourceLoader loader; private ResourceLoader loader;
private long lastUpdateTime = -1L; private long lastUpdateTime = -1L;
@ -37,19 +37,19 @@ public class IKTokenizerFactory extends TokenizerFactory implements ResourceLoad
} }
/** /**
* 通知方法 * 通知方法用于获取工厂使用的资源文件路径等信息实现与{@link ResourceLoaderAware#inform(ResourceLoader)}
* 方法被调用时将当前实例注册到更新任务中 * 方法被调用时将当前实例注册到更新任务中
* *
* @param resourceLoader 类路径资源加载实例 * @param resourceLoader 类路径资源加载实例
* @throws IOException IO读写异常 * @throws IOException IO读写异常
*/ */
@Override @Override
public void inform(ResourceLoader resourceLoader) throws IOException { public void inform(ResourceLoader resourceLoader) throws IOException {
System.out.println(String.format(":::ik:::inform:::::::::::::::::::::::: %s", this.conf)); System.out.println(String.format("IKTokenizerFactory "+ this.hashCode() +" inform conf: %s", this.conf));
this.loader = resourceLoader; this.loader = resourceLoader;
update(); update();
if ((this.conf != null) && (!this.conf.trim().isEmpty())) { if ((this.conf != null) && (!this.conf.trim().isEmpty())) {
UpdateKeeper.getInstance().register(this); UpdateThread.getInstance().register(this);
} }
} }
@ -100,13 +100,13 @@ public class IKTokenizerFactory extends TokenizerFactory implements ResourceLoad
String paths = p.getProperty("files"); // 获取词典文件名 String paths = p.getProperty("files"); // 获取词典文件名
if ((paths == null) || (paths.trim().isEmpty())) if ((paths == null) || (paths.trim().isEmpty()))
return null; return null;
System.out.println("loading conf files success."); System.out.println("loading ik.conf files success.");
return p; return p;
} }
this.lastUpdateTime = t; this.lastUpdateTime = t;
return null; return null;
} catch (Exception e) { } catch (Exception e) {
System.err.println("IK parsing conf NullPointerException~~~~~" + Arrays.toString(e.getStackTrace())); System.err.println("parsing ik.conf NullPointerException!!!" + Arrays.toString(e.getStackTrace()));
} }
return null; return null;
} }