| package cn.xy.hw; /** *//** * @author hanwei * */ public class User ...{ private String name; private int age; public int getAge() ...{ return age; } public void setAge(int age) ...{ this.age = age; } public String getName() ...{ return name; } public void setName(String name) ...{ this.name = name; } } |
| userlogin user ...{0} login at ...{1} |
| package cn.xy.hw; import org.springframework.context.ApplicationEvent; /** *//** * @author hanwei * */ public class RainEvent extends ApplicationEvent ...{ public RainEvent(Object arg0) ...{ super(arg0); System.out.println("乌云密布、闪电、打雷,紧接着,下起了瓢泼大雨。"); } } |
| package cn.xy.hw; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; /** *//** * @author hanwei * */ public class RainListener implements ApplicationListener ...{ /**//* (non-Javadoc) * @see org.springframework.context.ApplicationListener#onApplicationEvent( org.springframework.context.ApplicationEvent) */ public void onApplicationEvent(ApplicationEvent arg0) ...{ if(arg0 instanceof RainEvent)...{ System.out.println("唐僧大喊:"+arg0.getSource()+"赶快收衣服喽!"); } } } |