📄 cachepublisher.java
字号:
package org.artemis.right.jms;
import java.util.Properties;
import org.apache.log4j.Logger;
import com.gsta.eshore.framework.jcf.IState;
import com.gsta.eshore.framework.jcf.StateImpl;
import com.gsta.eshore.framework.jms.AbstractCacheService;
import com.gsta.eshore.framework.servicerepository.ServiceLocator;
/**
*
* @author hewenqiang
*
*/
public class CachePublisher {
private static Logger logger=Logger.getLogger(CachePublisher.class);
public static final String SPLIT_CHAR = ",";
public static final String CONFIG_FILE = "etc/jcf/framework/config/ServiceConfig.xml";
public static final String ACTION_UPDATE = "Update";
public static final String ACTION_ADD = "Add";
public static final String ACTION_DELETE = "Delete";
public static final String ACTION_TYPE = "__ActionType__";
public static final String CLASS_NAME = "__ClassName__";
public static final String ROLE_RELATIONSHIP = "__ROLE_RELATIONSHIP__";
public static final String JMS_JNDI_NAME = "JMSTopic";
protected ServiceLocator locator = null;
protected AbstractCacheService service = null;
//private static CachePublisher instance_ = null;
public CachePublisher() throws Exception{
}
/**
* 构造函数
* @param confFileName
* @throws Exception
*/
public CachePublisher(String confFileName) throws Exception{
locator = ServiceLocator.getInstance();
locator.init(confFileName);
IState state = new StateImpl();
service = AbstractCacheService.createCachService(CachePublisher.JMS_JNDI_NAME,state);
if (!state.isOK()){
logger.fatal("createCachService fail," , state.getThrowable());
}
}
// public static CachePublisher getInstance(){
// if (CachePublisher.instance_ == null){
// try{
// instance_ = new CachePublisher(CachePublisher.CONFIG_FILE);
// }catch(Exception ex){
// logger.fatal("initial jms fail:" , ex);
// }
// }
// return instance_;
// }
protected boolean pushCache(Properties map){
IState state = new StateImpl();
service.updateCacheContent(map,state);
if (!state.isOK()){
logger.error("publish jms message fail:" + state.getErrCode(),state.getThrowable());
}else
logger.debug("publish jms message ok:" + map.toString());
return state.isOK();
}
public boolean notifyUpdateConstantTableReader(String ConstantTableReaderClassName){
Properties props = new Properties();
try {
props.setProperty(CachePublisher.CLASS_NAME,ConstantTableReaderClassName);
props.setProperty(CachePublisher.ACTION_TYPE,CachePublisher.ACTION_UPDATE);
} catch (Exception e) {
logger.error("CachePublisher set properties failed:",e);
}
if (props != null){
return this.pushCache(props);
}else
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -