All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.ginere.base.util.dao.cache.KeyCacheManager Maven / Gradle / Ivy

There is a newer version: 1.2.3
Show newest version
package eu.ginere.base.util.dao.cache;

import eu.ginere.base.util.dao.cache.impl.AbstractKeyCacheManager;
import eu.ginere.base.util.properties.GlobalFileProperties;
import eu.ginere.base.util.thread.AbstractPeriodicThread;

import java.util.Vector;

import org.apache.log4j.Logger;

public class KeyCacheManager extends AbstractPeriodicThread {

	protected static final Logger log = Logger.getLogger(KeyCacheManager.class);


	private final long objectMaxUnactiveTime;

	public static final KeyCacheManager MANAGER=new KeyCacheManager();
	
	public final Vector list = new Vector();
	

	public static final long DEFAULT_TIME_TO_SLEEP = 30*1000;
	public static final long DEFAULT_UNACTIVE_TIME = 15*60*1000;
	
	private KeyCacheManager(){
		super(DEFAULT_TIME_TO_SLEEP,KeyCacheManager.class.getName());
		setDaemon(true);
		setTimeToSleep(GlobalFileProperties.getLongValue(KeyCacheManager.class, "ThreadTimeToSleep", DEFAULT_TIME_TO_SLEEP));
		
		objectMaxUnactiveTime=GlobalFileProperties.getLongValue(KeyCacheManager.class, "DefaultUnactiveTime", DEFAULT_UNACTIVE_TIME);
		
	}

	public void subscrive(AbstractKeyCacheManager abstractKeyManager) {
		list.add(abstractKeyManager);
		
		if (!super.isProcessing()){
			super.start();
		}
	}

	@Override
	protected void executeTask() {
//		long time=System.currentTimeMillis()-objectMaxUnactiveTime;

		for (AbstractKeyCacheManager manager:list){
			manager.purge(objectMaxUnactiveTime);
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy