diff --git a/org.springframework.context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java b/org.springframework.context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java
index 3bba5a6360..8a1bd763f0 100644
--- a/org.springframework.context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java
+++ b/org.springframework.context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -146,7 +146,7 @@ public abstract class AbstractApplicationEventMulticaster implements Application
BeanFactory beanFactory = getBeanFactory();
for (String listenerBeanName : this.defaultRetriever.applicationListenerBeans) {
ApplicationListener listener = beanFactory.getBean(listenerBeanName, ApplicationListener.class);
- if (supportsEvent(listener, eventType, sourceType)) {
+ if (!allListeners.contains(listener) && supportsEvent(listener, eventType, sourceType)) {
retriever.applicationListenerBeans.add(listenerBeanName);
allListeners.add(listener);
}
diff --git a/org.springframework.context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java b/org.springframework.context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java
index 090ef9fde4..d3ecec1760 100644
--- a/org.springframework.context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java
+++ b/org.springframework.context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 the original author or authors.
+ * Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import org.springframework.aop.support.AopUtils;
import org.springframework.aop.target.dynamic.Refreshable;
import org.springframework.beans.TestBean;
import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationEvent;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.NestedRuntimeException;
import org.springframework.scripting.Calculator;
@@ -303,4 +304,19 @@ public class BshScriptFactoryTests extends TestCase {
assertTrue("Messenger should be Refreshable", messenger instanceof Refreshable);
}
+ public void testApplicationEventListener() throws Exception {
+ ApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
+ Messenger eventListener = (Messenger) ctx.getBean("eventListener");
+ ctx.publishEvent(new MyEvent(ctx));
+ assertEquals("count=2", eventListener.getMessage());
+ }
+
+
+ private static class MyEvent extends ApplicationEvent {
+
+ public MyEvent(Object source) {
+ super(source);
+ }
+ }
+
}
diff --git a/org.springframework.context/src/test/java/org/springframework/scripting/bsh/bsh-with-xsd.xml b/org.springframework.context/src/test/java/org/springframework/scripting/bsh/bsh-with-xsd.xml
index 09453b3c0d..5908749d75 100644
--- a/org.springframework.context/src/test/java/org/springframework/scripting/bsh/bsh-with-xsd.xml
+++ b/org.springframework.context/src/test/java/org/springframework/scripting/bsh/bsh-with-xsd.xml
@@ -52,4 +52,12 @@
+
+
+
+