org.xwiki.observation.ObservationManager.removeListener()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(86)

本文整理了Java中org.xwiki.observation.ObservationManager.removeListener()方法的一些代码示例,展示了ObservationManager.removeListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObservationManager.removeListener()方法的具体详情如下:
包路径:org.xwiki.observation.ObservationManager
类名称:ObservationManager
方法名:removeListener

ObservationManager.removeListener介绍

[英]Remove a listener from the list of registered listeners. The removed listener will no longer receive events.
[中]从已注册的侦听器列表中删除侦听器。删除的侦听器将不再接收事件。

代码示例

代码示例来源:origin: org.xwiki.platform/xwiki-platform-configuration-default

@Override
public void dispose() throws ComponentLifecycleException
{
  this.observation.removeListener(getCacheId());
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-localization-source-wiki

@Override
  public void dispose() throws ComponentLifecycleException
  {
    this.observation.removeListener(this.listener.getName());
    this.observation.removeListener(this.wikilistener.getName());
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-localization-source-wiki

@Override
public void dispose()
{
  this.disposed = true;
  this.bundleCache.clear();
  this.observation.removeListener(getName());
}

代码示例来源:origin: org.xwiki.commons/xwiki-commons-logging-logback

@Override
public void pushLogListener(EventListener listener)
{
  Stack<EventListener> listenerStack = this.listeners.get();
  if (listenerStack == null) {
    listenerStack = new Stack<EventListener>();
    this.listeners.set(listenerStack);
  }
  if (!listenerStack.isEmpty()) {
    this.observation.removeListener(listenerStack.peek().getName());
  }
  if (listener != null) {
    this.observation.addListener(new WrappedThreadEventListener(listener));
  }
  if (listenerStack.isEmpty()) {
    grabLog(Thread.currentThread());
  }
  listenerStack.push(listener);
}

代码示例来源:origin: org.xwiki.commons/xwiki-commons-logging-logback

@Override
public EventListener popLogListener()
{
  Stack<EventListener> listenerStack = this.listeners.get();
  EventListener listener;
  if (listenerStack != null && !listenerStack.isEmpty()) {
    listener = listenerStack.pop();
    if (listener != null) {
      this.observation.removeListener(listener.getName());
    }
    if (listenerStack.isEmpty()) {
      ungrabLog(Thread.currentThread());
    } else {
      EventListener topListener = listenerStack.peek();
      if (topListener != null) {
        this.observation.addListener(new WrappedThreadEventListener(topListener));
      }
    }
  } else {
    listener = null;
  }
  return listener;
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-search-lucene-api

@Override
public void flushCache(XWikiContext context)
{
  // take care of crappy code calling #flushCache with no context...
  if (context == null) {
    context =
      (XWikiContext) Utils.getComponent(Execution.class).getContext()
        .getProperty(XWikiContext.EXECUTIONCONTEXT_KEY);
  }
  if (this.indexUpdater != null) {
    Utils.getComponent(ObservationManager.class).removeListener(this.indexUpdater.getName());
    // set the thread to exit
    this.indexUpdater.doExit();
    try {
      // wait for the thread to finish
      this.indexUpdaterThread.join();
    } catch (InterruptedException ex) {
      LOGGER.warn("Error while waiting for indexUpdaterThread to die.", ex);
    }
    this.indexUpdater = null;
    this.indexUpdaterThread = null;
  }
  this.indexRebuilder = null;
  this.analyzer = null;
  init(context);
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-observation-remote

@Override
  public void onEvent(Event event, Object source, Object data)
  {
    if (this.remoteObservationManager == null) {
      try {
        // Make sure to not receive events until RemoteObservationManager is ready
        ObservationManager om = this.componentManager.getInstance(ObservationManager.class);
        om.removeListener(getName());
        this.remoteObservationManager = this.componentManager.getInstance(RemoteObservationManager.class);
        om.addListener(this);

        this.remoteObservationManager.notify(new LocalEventData(event, source, data));
      } catch (ComponentLookupException e) {
        this.logger.error("Failed to initialize the Remote Observation Manager", e);
      }
    } else {
      this.remoteObservationManager.notify(new LocalEventData(event, source, data));
    }
  }
}

相关文章