diff --git a/Test11-Event/.idea/compiler.xml b/Test11-Event/.idea/compiler.xml new file mode 100644 index 00000000..39d6471c --- /dev/null +++ b/Test11-Event/.idea/compiler.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test11-Event/.idea/copyright/profiles_settings.xml b/Test11-Event/.idea/copyright/profiles_settings.xml new file mode 100644 index 00000000..e7bedf33 --- /dev/null +++ b/Test11-Event/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Test11-Event/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml b/Test11-Event/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml new file mode 100644 index 00000000..eab40b32 --- /dev/null +++ b/Test11-Event/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test11-Event/.idea/libraries/Maven__org_springframework_spring_aop_4_3_3_RELEASE.xml b/Test11-Event/.idea/libraries/Maven__org_springframework_spring_aop_4_3_3_RELEASE.xml new file mode 100644 index 00000000..9e08177c --- /dev/null +++ b/Test11-Event/.idea/libraries/Maven__org_springframework_spring_aop_4_3_3_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test11-Event/.idea/libraries/Maven__org_springframework_spring_beans_4_3_3_RELEASE.xml b/Test11-Event/.idea/libraries/Maven__org_springframework_spring_beans_4_3_3_RELEASE.xml new file mode 100644 index 00000000..1ddd8b9b --- /dev/null +++ b/Test11-Event/.idea/libraries/Maven__org_springframework_spring_beans_4_3_3_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test11-Event/.idea/libraries/Maven__org_springframework_spring_context_4_3_3_RELEASE.xml b/Test11-Event/.idea/libraries/Maven__org_springframework_spring_context_4_3_3_RELEASE.xml new file mode 100644 index 00000000..fbc79eb4 --- /dev/null +++ b/Test11-Event/.idea/libraries/Maven__org_springframework_spring_context_4_3_3_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test11-Event/.idea/libraries/Maven__org_springframework_spring_core_4_3_3_RELEASE.xml b/Test11-Event/.idea/libraries/Maven__org_springframework_spring_core_4_3_3_RELEASE.xml new file mode 100644 index 00000000..cabb772e --- /dev/null +++ b/Test11-Event/.idea/libraries/Maven__org_springframework_spring_core_4_3_3_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test11-Event/.idea/libraries/Maven__org_springframework_spring_expression_4_3_3_RELEASE.xml b/Test11-Event/.idea/libraries/Maven__org_springframework_spring_expression_4_3_3_RELEASE.xml new file mode 100644 index 00000000..200454c0 --- /dev/null +++ b/Test11-Event/.idea/libraries/Maven__org_springframework_spring_expression_4_3_3_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test11-Event/.idea/misc.xml b/Test11-Event/.idea/misc.xml new file mode 100644 index 00000000..233a7f02 --- /dev/null +++ b/Test11-Event/.idea/misc.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test11-Event/.idea/modules.xml b/Test11-Event/.idea/modules.xml new file mode 100644 index 00000000..30a43204 --- /dev/null +++ b/Test11-Event/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Test11-Event/.idea/workspace.xml b/Test11-Event/.idea/workspace.xml new file mode 100644 index 00000000..8c6d676a --- /dev/null +++ b/Test11-Event/.idea/workspace.xml @@ -0,0 +1,902 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + project + + + + + + + + + + + + + + + + project + + + true + + + + DIRECTORY + + false + + + + + + + + + + + + + + + + + + + + + + + 1481629792135 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test11-Event/Test11-Event.iml b/Test11-Event/Test11-Event.iml new file mode 100644 index 00000000..468a222f --- /dev/null +++ b/Test11-Event/Test11-Event.iml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test11-Event/pom.xml b/Test11-Event/pom.xml new file mode 100644 index 00000000..36b9699d --- /dev/null +++ b/Test11-Event/pom.xml @@ -0,0 +1,18 @@ + + + 4.0.0 + + Test11-Event + Test11-Event + 1.0-SNAPSHOT + + + org.springframework + spring-context + 4.3.3.RELEASE + + + + \ No newline at end of file diff --git a/Test11-Event/src/main/java/org/sang/DemoEvent.java b/Test11-Event/src/main/java/org/sang/DemoEvent.java new file mode 100644 index 00000000..1ebfb772 --- /dev/null +++ b/Test11-Event/src/main/java/org/sang/DemoEvent.java @@ -0,0 +1,23 @@ +package org.sang; + +import org.springframework.context.ApplicationEvent; + +/** + * Created by sang on 16-12-13. + */ +public class DemoEvent extends ApplicationEvent{ + private String msg; + + public DemoEvent(Object source, String msg) { + super(source); + this.msg = msg; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } +} diff --git a/Test11-Event/src/main/java/org/sang/DemoListener.java b/Test11-Event/src/main/java/org/sang/DemoListener.java new file mode 100644 index 00000000..055388da --- /dev/null +++ b/Test11-Event/src/main/java/org/sang/DemoListener.java @@ -0,0 +1,14 @@ +package org.sang; + +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +/** + * Created by sang on 16-12-13. + */ +@Component +public class DemoListener implements ApplicationListener { + public void onApplicationEvent(DemoEvent demoEvent) { + System.out.println("我收到DemoEvent的事件了:"+demoEvent.getMsg()); + } +} diff --git a/Test11-Event/src/main/java/org/sang/DemoPublish.java b/Test11-Event/src/main/java/org/sang/DemoPublish.java new file mode 100644 index 00000000..568a6358 --- /dev/null +++ b/Test11-Event/src/main/java/org/sang/DemoPublish.java @@ -0,0 +1,18 @@ +package org.sang; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + +/** + * Created by sang on 16-12-13. + */ +@Component +public class DemoPublish{ + @Autowired + ApplicationContext applicationContext; + + public void publish(String msg) { + applicationContext.publishEvent(new DemoEvent(this,msg)); + } +} diff --git a/Test11-Event/src/main/java/org/sang/Main.java b/Test11-Event/src/main/java/org/sang/Main.java new file mode 100644 index 00000000..157038c9 --- /dev/null +++ b/Test11-Event/src/main/java/org/sang/Main.java @@ -0,0 +1,15 @@ +package org.sang; + +import org.springframework.context.annotation.AnnotationConfigApplicationContext; + +/** + * Created by sang on 16-12-13. + */ +public class Main { + public static void main(String[] args) { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyConfig.class); + DemoPublish demoPublish = context.getBean(DemoPublish.class); + demoPublish.publish("Hello sang !"); + context.close(); + } +} diff --git a/Test11-Event/src/main/java/org/sang/MyConfig.java b/Test11-Event/src/main/java/org/sang/MyConfig.java new file mode 100644 index 00000000..390236c5 --- /dev/null +++ b/Test11-Event/src/main/java/org/sang/MyConfig.java @@ -0,0 +1,12 @@ +package org.sang; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +/** + * Created by sang on 16-12-13. + */ +@Configuration +@ComponentScan("org.sang") +public class MyConfig { +} diff --git a/Test11-Event/target/classes/org/sang/DemoEvent.class b/Test11-Event/target/classes/org/sang/DemoEvent.class new file mode 100644 index 00000000..19d623e6 Binary files /dev/null and b/Test11-Event/target/classes/org/sang/DemoEvent.class differ diff --git a/Test11-Event/target/classes/org/sang/DemoListener.class b/Test11-Event/target/classes/org/sang/DemoListener.class new file mode 100644 index 00000000..6fed1350 Binary files /dev/null and b/Test11-Event/target/classes/org/sang/DemoListener.class differ diff --git a/Test11-Event/target/classes/org/sang/DemoPublish.class b/Test11-Event/target/classes/org/sang/DemoPublish.class new file mode 100644 index 00000000..3f25a4e2 Binary files /dev/null and b/Test11-Event/target/classes/org/sang/DemoPublish.class differ diff --git a/Test11-Event/target/classes/org/sang/Main.class b/Test11-Event/target/classes/org/sang/Main.class new file mode 100644 index 00000000..d94baa03 Binary files /dev/null and b/Test11-Event/target/classes/org/sang/Main.class differ diff --git a/Test11-Event/target/classes/org/sang/MyConfig.class b/Test11-Event/target/classes/org/sang/MyConfig.class new file mode 100644 index 00000000..d975dec5 Binary files /dev/null and b/Test11-Event/target/classes/org/sang/MyConfig.class differ