本文整理汇总了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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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();
}
示例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;
}
}
}