私の設定XML:appconfig.xml
<beans xmlns="...">
<context:mbean-server/>
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
<property name="beans">
<map>
<entry key="bean:name=notificationSender" value-ref="notificationSenderImpl"></entry>
<entry key="bean:name=notificationListener" value-ref="notificationListenerImpl"></entry>
</map>
</property>
<property name="notificationListenerMappings">
<map>
<entry key="notificationListenerImpl" value-ref="notificationListenerImpl"></entry>
</map>
</property>
<property name="server" ref="mbeanServer"/>
</bean>
<bean id="notificationSender" class="com....NotificationSenderImpl"/>
<bean id="notificationListener" class="com....NotificationListenerImpl"/>
私のコード:Test.java
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:appconfig.xml")
public class Test {
@Autowired
private ConfigurableApplicationContext context;
@Test
public void testFlow() {
NotificationSender sender = (NotificationSender) context.getBean("notificationSender");
sender.send();
}
@After
public void tearDown(){
context.close();
}
}
クラスNotificationSenderImpl.java
public class NotificationSenderImpl implements NotificationPublisherAware{
private NotificationPublisher notificationPublisher;
public void setNotificationPublisher(NotificationPublisher notificationPublisher) {
// TODO Auto-generated method stub
this.notificationPublisher = notificationPublisher;
}
public void send(){
notificationPublisher.sendNotification(new Notification("simple", this, 0L));
}
}
とリスナー...クラスNotificationListenerImpl
public class NotificationListenerImpl implements NotificationListener{
public void handleNotification(Notification notification, Object handback) {
// TODO Auto-generated method stub
System.out.println("Notification received");
}
}
通知は送信されていますが、受信されていません。ポインタはありますか?