package com.shkpr.service.alambizplugin.globalmgr; import com.global.base.log.LogLevelFlag; import com.global.base.log.LogPrintMgr; import com.global.base.taskqueue.TaskQueueData; import com.shkpr.service.alambizplugin.constants.LogFlagBusiType; import com.shkpr.service.alambizplugin.constants.TaskQueueDataTypeEx; import com.shkpr.service.alambizplugin.queues.NotifyMsgQueueHandlerPool; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; public class NotifyMsgQueueMgr { private String mStrClassName; private static volatile NotifyMsgQueueMgr msInstance = null; private NotifyMsgQueueHandlerPool mNotifyMsgQueuePool = null; private NotifyMsgQueueMgr() {mStrClassName = this.getClass().getSimpleName(); } public static NotifyMsgQueueMgr getInstance() { if (msInstance == null){ synchronized (NotifyMsgQueueMgr.class){ if (msInstance == null){ msInstance = new NotifyMsgQueueMgr(); } } } return msInstance; } private void init(){ mNotifyMsgQueuePool = new NotifyMsgQueueHandlerPool(1); mNotifyMsgQueuePool.init(); LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, LogFlagBusiType.BUSI_INIT.toStrValue(), mStrClassName ,String.format("init()...")); } @PostConstruct public void afterPropertiesSet() throws Exception{ init(); } @PreDestroy public void destroy() throws Exception{ if (mNotifyMsgQueuePool != null) mNotifyMsgQueuePool.stopAllQueueHandler(true); } public boolean postTaskData(int type, T data){ if (data != null && type > TaskQueueDataTypeEx.NOTIFY_MSG_BEGIN && type < TaskQueueDataTypeEx.NOTIFY_MSG_END && mNotifyMsgQueuePool != null) return mNotifyMsgQueuePool.postTaskData(type, data); return false; } public boolean postTaskData(TaskQueueData taskData){ if (taskData != null && taskData.getType() > TaskQueueDataTypeEx.NOTIFY_MSG_BEGIN && taskData.getType() < TaskQueueDataTypeEx.NOTIFY_MSG_END && mNotifyMsgQueuePool != null) return mNotifyMsgQueuePool.postTaskData(taskData); return false; } public void stopAllTaskQueue(){ if (mNotifyMsgQueuePool != null) mNotifyMsgQueuePool.stopAllQueueHandler(true); } public void timePerSecondNow(){ if (mNotifyMsgQueuePool != null){ mNotifyMsgQueuePool.timePerSecondNow(); } } }