线程上下文ThreadContext.docxVIP

  • 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?? ? ? ? ?

文档评论(0)

1亿VIP精品文档

相关文档