当前位置: 首页>>代码示例>>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;未经允许,请勿转载。