當前位置: 首頁>>代碼示例>>Java>>正文


Java ApplicationListener.onApplicationEvent方法代碼示例

本文整理匯總了Java中org.springframework.context.ApplicationListener.onApplicationEvent方法的典型用法代碼示例。如果您正苦於以下問題:Java ApplicationListener.onApplicationEvent方法的具體用法?Java ApplicationListener.onApplicationEvent怎麽用?Java ApplicationListener.onApplicationEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.context.ApplicationListener的用法示例。


在下文中一共展示了ApplicationListener.onApplicationEvent方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: invokeListener

import org.springframework.context.ApplicationListener; //導入方法依賴的package包/類
/**
 * Invoke the given listener with the given event.
 * @param listener the ApplicationListener to invoke
 * @param event the current event to propagate
 * @since 4.1
 */
@SuppressWarnings({"unchecked", "rawtypes"})
protected void invokeListener(ApplicationListener listener, ApplicationEvent event) {
	ErrorHandler errorHandler = getErrorHandler();
	if (errorHandler != null) {
		try {
			listener.onApplicationEvent(event);
		}
		catch (Throwable err) {
			errorHandler.handleError(err);
		}
	}
	else {
		listener.onApplicationEvent(event);
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:22,代碼來源:SimpleApplicationEventMulticaster.java

示例2: multicastEventInternal

import org.springframework.context.ApplicationListener; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
protected void multicastEventInternal(final ApplicationEvent event) {
    for (final ApplicationListener listener : getApplicationListeners(event)) {
        Executor executor = getTaskExecutor();
        if (executor != null) {
            executor.execute(new Runnable() {
                public void run() {
                    listener.onApplicationEvent(event);
                }
            });
        }
        else {
            listener.onApplicationEvent(event);
        }
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:17,代碼來源:SafeApplicationEventMulticaster.java

示例3: multicastEvent

import org.springframework.context.ApplicationListener; //導入方法依賴的package包/類
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void multicastEvent(final ApplicationEvent event) {
	for (final ApplicationListener listener : getApplicationListeners(event)) {
		Executor executor = getTaskExecutor();
		if (executor != null) {
			executor.execute(new Runnable() {
				@Override
				public void run() {
					listener.onApplicationEvent(event);
				}
			});
		}
		else {
			listener.onApplicationEvent(event);
		}
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:19,代碼來源:SimpleApplicationEventMulticaster.java

示例4: invokeListener

import org.springframework.context.ApplicationListener; //導入方法依賴的package包/類
/**
 * Invoke the given listener with the given event.
 * @param listener the ApplicationListener to invoke
 * @param event the current event to propagate
 * @since 4.1
 */
@SuppressWarnings({"unchecked", "rawtypes"})
protected void invokeListener(ApplicationListener listener, ApplicationEvent event) {
	ErrorHandler errorHandler = getErrorHandler();
	if (errorHandler != null) {
		try {
			listener.onApplicationEvent(event);
		}
		catch (Throwable err) {
			errorHandler.handleError(err);
		}
	}
	else {
		try {
			listener.onApplicationEvent(event);
		}
		catch (ClassCastException ex) {
			// Possibly a lambda-defined listener which we could not resolve the generic event type for
			LogFactory.getLog(getClass()).debug("Non-matching event type for listener: " + listener, ex);
		}
	}
}
 
開發者ID:txazo,項目名稱:spring,代碼行數:28,代碼來源:SimpleApplicationEventMulticaster.java

示例5: multicastEvent

import org.springframework.context.ApplicationListener; //導入方法依賴的package包/類
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void multicastEvent(ApplicationEvent event, ResolvableType eventType) {

	ResolvableType type = eventType == null ? ResolvableType.forInstance(event) : eventType;
	Collection<ApplicationListener<?>> listeners = getApplicationListeners(event, type);

	if (listeners.isEmpty()) {
		return;
	}

	List<ApplicationListener<?>> transactionalListeners = listeners.stream()//
			.filter(PersistentApplicationEventMulticaster::isTransactionalApplicationEventListener)//
			.collect(Collectors.toList());

	if (!transactionalListeners.isEmpty()) {

		Object eventToPersist = getEventToPersist(event);

		registry.getObject().store(eventToPersist, transactionalListeners);
		// EventStore.persist(eventThis)
		// SpringMVC Controller Atom Feed
	}

	for (ApplicationListener listener : listeners) {
		listener.onApplicationEvent(event);
	}
}
 
開發者ID:olivergierke,項目名稱:spring-domain-events,代碼行數:29,代碼來源:PersistentApplicationEventMulticaster.java

示例6: notifyListeners

import org.springframework.context.ApplicationListener; //導入方法依賴的package包/類
private void notifyListeners(String description, int count)
{
    if (!this.applicationListeners.isEmpty())
    {
        IndexEvent event = new IndexEvent(this, description, count);
        for (ApplicationListener listener : this.applicationListeners)
        {
            listener.onApplicationEvent(event);
        }
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:12,代碼來源:IndexInfo.java

示例7: broadcastEvent

import org.springframework.context.ApplicationListener; //導入方法依賴的package包/類
/**
 * Broadcast event.
 * 
 * @param event
 *            the event
 */
private void broadcastEvent(PropertyBackedBeanEvent event)
{
    // If the system is up and running, broadcast the event immediately
    if (this.isSchemaAvailable && this.wasDictionaryBootstrapped)
    {
        // If we have a transaction, the changed properties in it should be updated earlier,
        // then the bean restart message will be sent to other node
        // see ALF-20066
        if (AlfrescoTransactionSupport.getTransactionId() != null &&
                (event instanceof PropertyBackedBeanStartedEvent ||
                event instanceof PropertyBackedBeanStoppedEvent))
        {
            this.afterTransactionEvents.add(event);
            AlfrescoTransactionSupport.bindListener(this);
        }
        else
        {
            for (ApplicationListener listener : this.listeners)
            {
                listener.onApplicationEvent(event);
            }
        }
    }
    // Otherwise, defer broadcasting until the schema available event is handled
    else
    {
        this.deferredEvents.add(event);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:36,代碼來源:DefaultPropertyBackedBeanRegistry.java

示例8: afterCommit

import org.springframework.context.ApplicationListener; //導入方法依賴的package包/類
@Override
public void afterCommit()
{
    for (ApplicationEvent event : this.afterTransactionEvents)
    {
        for (ApplicationListener listener : this.listeners)
        {
            listener.onApplicationEvent(event);
        }
    }
    this.afterTransactionEvents.clear();
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:13,代碼來源:DefaultPropertyBackedBeanRegistry.java

示例9: invokeListener

import org.springframework.context.ApplicationListener; //導入方法依賴的package包/類
@SuppressWarnings({"unchecked", "rawtypes"})
protected void invokeListener(ApplicationListener listener, ApplicationEvent event) {
    try {
        listener.onApplicationEvent(event);
    } catch (ClassCastException ex) {
        String msg = ex.getMessage();
        if (msg == null || msg.startsWith(event.getClass().getName())) {
            // Possibly a lambda-defined listener which we could not resolve the generic event type for
            LoggerFactory.getLogger(UiEventsMulticaster.class)
                    .debug("Non-matching event type for listener: {}", listener, ex);
        } else {
            throw ex;
        }
    }
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:16,代碼來源:UiEventsMulticasterImpl.java


注:本文中的org.springframework.context.ApplicationListener.onApplicationEvent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。