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

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

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

ObservationManager.addListener介绍

[英]Manually add a listener.
[中]手动添加一个侦听器。

代码示例

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

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

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

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

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

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

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

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

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

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

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

/**
 * {@inheritDoc}
 * 
 * @see com.xpn.xwiki.user.api.XWikiGroupService#init(com.xpn.xwiki.XWiki, com.xpn.xwiki.XWikiContext)
 */
public synchronized void init(XWiki xwiki, XWikiContext context) throws XWikiException
{
  initCache(context);
  Utils.getComponent(ObservationManager.class).addListener(this);
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

public XWikiMacrosMappingRenderer(XWiki xwiki, XWikiContext context)
{
  loadPreferences(xwiki, context);
  // Add a notification rule if the preference property plugin is modified
  Utils.getComponent(ObservationManager.class).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: org.xwiki.platform/xwiki-platform-scheduler-api

@Override
public void init(XWikiContext context)
{
  Thread thread = new Thread(new ExecutionContextRunnable(new Runnable()
  {
    @Override
    public void run()
    {
      initAsync();
    }
  }, Utils.getComponentManager()));
  thread.setName("XWiki Scheduler initialization");
  thread.setDaemon(true);
  thread.start();
  // Start listening to documents modifications
  Utils.getComponent(ObservationManager.class).addListener(this);
}

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

@Override
public void initialize() throws InitializationException
{
  // Cache
  CacheConfiguration cacheConfiguration = new CacheConfiguration("localization.bundle.document");
  try {
    this.onDemandBundleCache = this.cacheManager.createNewCache(cacheConfiguration);
  } catch (CacheException e) {
    this.logger.error("Failed to create cache [{}]", cacheConfiguration.getConfigurationId(), e);
  }
  // Load existing translations from main wiki, wait for WikiReaderEvent for other wikis
  loadTranslations(this.wikiManager.getMainWikiId());
  // Listeners
  this.observation.addListener(this.listener);
  this.observation.addListener(this.wikilistener);
}

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

/**
 * {@inheritDoc}
 * <p>
 * Create/update the XClass corresponding to this kind of extension, and register the listeners that update the list
 * of always used extensions.
 * </p>
 * 
 * @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#init(com.xpn.xwiki.XWikiContext)
 */
@Override
public void init(XWikiContext context)
{
  super.init(context);
  this.alwaysUsedExtensions = new HashMap<String, Set<DocumentReference>>();
  getExtensionClass(context);
  Utils.getComponent(ObservationManager.class).addListener(this);
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

/**
 * {@inheritDoc}
 * 
 * @see com.xpn.xwiki.stats.api.XWikiStatsService#init(com.xpn.xwiki.XWikiContext)
 */
public void init(XWikiContext context)
{
  if (LOG.isInfoEnabled()) {
    LOG.info("Start statistics service initialization");
  }
  if (StatsUtil.isStatsEnabled(context)) {
    // Start statistics store thread
    this.statsRegister = new XWikiStatsStoreService(context);
    this.statsRegister.start();
    // Adding the rule which will allow this module to be called on each page view
    Utils.getComponent(ObservationManager.class).addListener(this);
  }
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

public XWikiCacheStore(XWikiStoreInterface store, XWikiContext context) throws XWikiException
{
  setStore(store);
  initCache(context);
  // register XWikiCacheStore as listener to remote document events
  this.remoteObservationManagerContext = Utils.getComponent(RemoteObservationManagerContext.class);
  this.observationManager = Utils.getComponent(ObservationManager.class);
  this.observationManager.addListener(this);
}

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

private void initialize()
{
  this.events =
    Arrays.<Event>asList(new DocumentUpdatedEvent(this.documentReference), new DocumentCreatedEvent(
      this.documentReference), new DocumentDeletedEvent(this.documentReference), new WikiDeletedEvent(
      this.documentReference.getWikiReference().getName()));
  this.observation.addListener(this);
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

/**
 * The mandatory plugin constructor, this is the method called (through reflection) by the plugin manager.
 * 
 * @param name the plugin name
 * @param className the name of this class, ignored
 * @param context the current request context
 */
public PatternPlugin(String name, String className, XWikiContext context)
{
  super(name, className, context);
  init(context);
  // Watch for any modifications of the Plugins.PatternPlugin document.
  Utils.getComponent(ObservationManager.class).addListener(this);
  this.patternListSubstitution = new WikiSubstitution(context.getUtil(), "%PATTERNS%");
}

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

/**
 * {@inheritDoc}
 * 
 * @see com.xpn.xwiki.internal.cache.DocumentCache#create(org.xwiki.cache.config.CacheConfiguration)
 */
public void create(CacheConfiguration cacheConfiguration) throws CacheException
{
  this.name = cacheConfiguration.getConfigurationId();
  this.cache = this.cacheManager.createNewCache(cacheConfiguration);
  CacheConfiguration mappingCacheConfiguration = (CacheConfiguration) cacheConfiguration.clone();
  mappingCacheConfiguration.setConfigurationId(cacheConfiguration.getConfigurationId() + ".mapping");
  this.mappingCache = this.cacheManager.createNewCache(cacheConfiguration);
  this.observationManager.addListener(this.listener);
}

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

相关文章