- 1
- 0
- 约 6页
- 2017-07-09 发布于河南
- 举报
线程上下文ThreadContext
import java.util.ArrayList;?import java.util.HashMap;?import java.util.List;?import java.util.Map;??import org.osgi.framework.Bundle;?import org.osgi.framework.BundleEvent;?import org.osgi.framework.BundleListener;??import com.quickwebframework.entity.Log;?import com.quickwebframework.entity.LogFactory;??public abstract class ThreadContext {?? ? ? ? private static Log log = LogFactory.getLog(ThreadContext.class);??? ? ? ? public static void init() {?? ? ? ? ? ? ? ? final Bundle coreBundle = FrameworkContext.coreBundle;?? ? ? ? ? ? ? ? coreBundle.getBundleContext().addBundleListener(new BundleListener() {?? ? ? ? ? ? ? ? ? ? ? ? @Override?? ? ? ? ? ? ? ? ? ? ? ? public void bundleChanged(BundleEvent arg0) {?? ?inteventType = arg0.getType();?? ?Bundle bundle = arg0.getBundle();??? // 如果插件的状态是正在停止或已经停止?? ?if (eventType == BundleEvent.STOPPED?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? || eventType == BundleEvent.STOPPING) {??if (bundle.equals(coreBundle)) {?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? removeAllFilter();?? ? ? ? ? ? ? } else {?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? removeBundleAllThread(bundle);?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }?? ? ? ? ? ? ? ? ? ? ? ? }?? ? ? ? ? ? ? ? });?? ? ? ? }??? ? ? ? private static ListThread threadList = new ArrayListThread();?? ? ? ? private static MapBundle, ListThread bundleThreadListMap = new HashMapBundle, ListThread();??? ? ? ? /**?? ? ? ? ?* 得到线程列表?? ? ? ? ?* ?? ? ? ? ?* @return?? ? ? ? ?*/?? ? ? ? public static ListThread getThreadList() {?? ? ? ? ? ? ? ? return threadList;?? ? ? ? }??? ? ? ? /**?? ? ? ? ?* 移除所有的线程?? ? ? ? ?*/?? ? ? ? public static void removeAllFilter() {?? ? ? ? ? ? ? ? for (Bundle bundle : bundleThreadListMap.keySet()?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? .toArray(new Bundle[0])) {?? ? ? ? ? ? ? ? ? ? ? ? removeBundleAllThread(bundle);?? ? ? ? ? ? ? ? }?? ? ? ? }??? ? ? ? /**?? ? ? ? ?* 移除某Bundle所有的线程?? ? ? ? ?* ?? ? ? ? ?* @param bundle?? ? ? ? ?
您可能关注的文档
最近下载
- 露营经济带动下2025年户外露营睡袋行业市场调研报告.docx VIP
- 数字图像处理及MATLAB实现(第4版).pptx VIP
- 四川省2025年高职单招文化素质考试(普高类)信息技术和通用技术试卷(含答案).pdf
- 党员在改作风树新风方面存在的问题及整改措施.pdf VIP
- 2025年哈尔滨铁道职业技术学院单招综合素质考试模拟试题及答案解析.docx VIP
- 民用建筑设计统一标准 GB50352(最新).docx VIP
- 2025人教版七年级英语下册全册默写本.pdf
- 《长征胜利万岁》.pptx VIP
- 交往与合作--敲开人际关系的大门.pptx VIP
- 2025年户外运动服饰行业在露营经济下的创新趋势研究报告.docx VIP
原创力文档

文档评论(0)