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

com.holmos.cache.config.CacheConfig Maven / Gradle / Ivy

The newest version!
package com.holmos.cache.config;

import java.net.Inet4Address;
import java.util.ArrayList;

import com.holmos.cache.config.listener.CacheConfigListener;

/**
 * 缓存配置信息,指的是一个缓存节点的配置信息,包括若干不同层的缓存组件
 *
 * @author: 吴银龙([email protected])
 * @version: 2013-3-7 下午19:23:28 
 * */
public class CacheConfig implements CacheConfigListener{
	
	/**不同层的缓存节点信息,也就是一台缓存机器上部署的不同层次的缓存*/
	private ArrayListcacheComponents;
	
	/**互为主从节点的机器地址列表*/
	private ArrayList brothers;

	/**缓存配置的监听器列表*/
	private ArrayList configListeners;
	
	public ArrayList getCacheComponents() {
		return cacheComponents;
	}

	/**
	 * 删除类型为cacheComponentType的缓存节点
	 * 
  • 有名字为cacheComponent的节点,则删除
  • *
  • 没有,则不进行任何操作
  • * */ public void removeCacheComponent(String cacheComponentType){ if(null==cacheComponentType||"".equalsIgnoreCase(cacheComponentType)) return; for(CacheConfigComponent component:this.cacheComponents){ if(cacheComponentType.equalsIgnoreCase(component.getCacheType())) cacheComponents.remove(component); } } public void addCacheComponent(CacheConfigComponent component){ this.cacheComponents.add(component); } public ArrayList getBrothers() { return brothers; } public ArrayList getCacheConfigListeners(){ return configListeners; } public void registerCacheConfigListener(CacheConfigListener configListener){ configListeners.add(configListener); } public void removeCacheConfigListener(CacheConfigListener configListener){ configListeners.remove(configListener); } public void clearCacheConfigListeners(){ configListeners.clear(); } @Override public void beforeConfigLoad() { for(CacheConfigListener listener : configListeners){ listener.beforeConfigLoad(); } } @Override public void beforeConfigLoadOfLayer(int layer) { for(CacheConfigListener listener : configListeners){ listener.beforeConfigLoadOfLayer(layer); } } @Override public void afterConfigLoadOfLayer(int layer) { for(CacheConfigListener listener : configListeners){ listener.afterConfigLoadOfLayer(layer); } } @Override public void afterConfigLoad() { for(CacheConfigListener listener : configListeners){ listener.afterConfigLoad(); } } }




    © 2015 - 2024 Weber Informatics LLC | Privacy Policy