
commons.box.app.DataInit Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-box-app Show documentation
Show all versions of commons-box-app Show documentation
Common utils for BOX projects.
The newest version!
package commons.box.app;
/**
* 允许初始化的实例,可以根据运行状态重新初始化
*/
public abstract class DataInit {
private volatile boolean initialized = false;
/**
* 初始化实例,可以重复调用,仅在需要初始化时才会真正执行初始化过程
*/
public void init() {
if (!this.initialized) {
synchronized (this) {
if (!this.initialized) {
internalInit();
this.initialized = true;
}
}
}
}
/**
* 重新初始化
*/
public void reset() {
if (this.initialized) {
synchronized (this) {
this.initialized = false;
}
}
}
/**
* 内部初始化
*/
protected abstract void internalInit();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy