org.xwiki.observation.ObservationManager类的使用及代码示例

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

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

ObservationManager介绍

[英]The main orchestrator for event notification. To receive events create a component implementing the EventListener interface. Your component will be automatically registered when this Observation Manager component is loaded. To send events to all registered listeners, call one of the #notify methods.
[中]事件通知的主编排器。要接收事件,请创建一个实现EventListener接口的组件。加载此Observation Manager组件时,您的组件将自动注册。要向所有注册的侦听器发送事件,请调用#notify方法之一。

代码示例

代码示例来源:origin: org.xwiki.commons/xwiki-commons-component-default

/**
 * Send the event.
 *
 * @param event the event to send
 * @param descriptor the event related component descriptor.
 * @param componentManager the event related component manager instance.
 */
private void sendEvent(Event event, ComponentDescriptor<?> descriptor, ComponentManager componentManager)
{
  if (this.observationManager != null) {
    this.observationManager.notify(event, componentManager, descriptor);
  }
}

代码示例来源:origin: org.phenotips/patient-tools

@Override
public void initialize() throws InitializationException
{
  this.observationManager.addListener(this);
}

代码示例来源: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: com.xpn.xwiki.platform/xwiki-core

/**
 * {@inheritDoc}
 * 
 * @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#init(com.xpn.xwiki.XWikiContext)
 */
@Override
public void init(XWikiContext context)
{
  // Register a listener so that the RightsManager is called when a document with a XWikiUsers object is
  // removed in order to remove that user from its groups.
  // Make sure we allow this plugin to be initialized several times in a row; i.e. don't re-register the
  // listener if it's already registered.
  RightsManagerListener rightsManagerListener = RightsManagerListener.getInstance();
  ObservationManager observationManager = Utils.getComponent(ObservationManager.class);
  if (observationManager.getListener(rightsManagerListener.getName()) == null) {
    observationManager.addListener(rightsManagerListener);
  }
}

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

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

代码示例来源:origin: com.xpn.xwiki.platform.plugins/xwiki-plugin-activitystream

/**
 * {@inheritDoc}
 */
public void init(XWikiContext context) throws XWikiException
{
  // Listent to Events.
  ObservationManager observationManager = Utils.getComponent(ObservationManager.class);
  if (observationManager.getListener(getName()) == null) {
    observationManager.addListener(this);
  }
  // Init activitystream cleaner.
  ActivityStreamCleaner.getInstance().init(context);
}

代码示例来源: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.phenotips/patient-access-rules-api

public void fireRightsUpdateEvent(String patientId)
  {
    this.observationManager.notify(new PatientRightsUpdatedEvent(patientId), null);
  }
}

代码示例来源:origin: phenotips/phenotips

@Override
public void initialize() throws InitializationException
{
  this.observationManager.addListener(this);
}

代码示例来源: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

if (observationManager.getListener(indexUpdater.getName()) == null) {
  observationManager.addListener(indexUpdater);

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

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

代码示例来源:origin: phenotips/phenotips

@Override
  public void fireRightsUpdateEvent(@Nonnull final String entityId)
  {
    this.observationManager.notify(new EntityRightsUpdatedEvent(entityId), null);
  }
}

代码示例来源:origin: jvelo/mayocat-shop

@Override
public void initialize() throws InitializationException
{
  this.observationManager.addListener(new FileEventListener());
}

代码示例来源: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));
    }
  }
}

代码示例来源: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-wiki-default

@Override
public void delete(String wikiId) throws WikiManagerException
{
  // Delete the wiki
  wikiDeleter.delete(wikiId);
  // Send an event
  observationManager.notify(new WikiDeletedEvent(wikiId), wikiId);
}

代码示例来源:origin: jvelo/mayocat-shop

@Override
public void initialize() throws InitializationException {
  observationManager.addListener(new Listener());
}

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

@Override
  public void handleNext(ResourceReference reference) throws ResourceReferenceHandlerException
  {
    if (!this.handlerStack.isEmpty()) {
      ResourceReferenceHandler<?> handler = this.handlerStack.poll();

      if (this.observation != null) {
        this.observation.notify(new ResourceReferenceHandlingEvent(reference), handler);
      }

      ResourceReferenceHandlerException exception = null;
      try {
        handler.handle(reference, this);
      } catch (ResourceReferenceHandlerException e) {
        exception = e;
      } finally {
        if (this.observation != null) {
          this.observation.notify(new ResourceReferenceHandledEvent(reference), handler, exception);
        }
      }

      // Throw the exception if any
      if (exception != null) {
        throw exception;
      }
    }
  }
}

代码示例来源:origin: jvelo/mayocat-shop

public void initialize() throws InitializationException
{
  this.observationManager.addListener(new SearchEngineEventListener());
}

相关文章