本文整理了Java中javax.management.Notification.getSource()
方法的一些代码示例,展示了Notification.getSource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Notification.getSource()
方法的具体详情如下:
包路径:javax.management.Notification
类名称:Notification
方法名:getSource
暂无
代码示例来源:origin: spring-projects/spring-framework
/**
* Replaces the notification source if necessary to do so.
* From the {@link Notification javadoc}:
* <i>"It is strongly recommended that notification senders use the object name
* rather than a reference to the MBean object as the source."</i>
* @param notification the {@link Notification} whose
* {@link javax.management.Notification#getSource()} might need massaging
*/
private void replaceNotificationSourceIfNecessary(Notification notification) {
if (notification.getSource() == null || notification.getSource().equals(this.managedResource)) {
notification.setSource(this.objectName);
}
}
代码示例来源:origin: org.springframework/spring-context
/**
* Replaces the notification source if necessary to do so.
* From the {@link Notification javadoc}:
* <i>"It is strongly recommended that notification senders use the object name
* rather than a reference to the MBean object as the source."</i>
* @param notification the {@link Notification} whose
* {@link javax.management.Notification#getSource()} might need massaging
*/
private void replaceNotificationSourceIfNecessary(Notification notification) {
if (notification.getSource() == null || notification.getSource().equals(this.managedResource)) {
notification.setSource(this.objectName);
}
}
代码示例来源:origin: groovy/groovy-core
private static Map buildOperationNotificationPacket(Notification note) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("event", note.getType());
result.put("source", note.getSource());
result.put("sequenceNumber", note.getSequenceNumber());
result.put("timeStamp", note.getTimeStamp());
result.put("data", note.getUserData());
return result;
}
}
代码示例来源:origin: apache/geode
Object notifSource = notification.getSource();
if (AdminDistributedSystemJmxImpl.NOTIF_MEMBER_JOINED.equals(notification.getType())) {
ObjectName source = (ObjectName) notifSource;
代码示例来源:origin: spring-projects/spring-framework
public void testSendAttributeChangeNotificationWhereSourceIsNotTheManagedResource() throws Exception {
StubSpringModelMBean mbean = new StubSpringModelMBean();
Notification notification = new AttributeChangeNotification(this, 1872, System.currentTimeMillis(), "Shall we break for some tea?", "agree", "java.lang.Boolean", Boolean.FALSE, Boolean.TRUE);
ObjectName objectName = createObjectName();
NotificationPublisher publisher = new ModelMBeanNotificationPublisher(mbean, objectName, mbean);
publisher.sendNotification(notification);
assertNotNull(mbean.getActualNotification());
assertTrue(mbean.getActualNotification() instanceof AttributeChangeNotification);
assertSame("The exact same Notification is not being passed through from the publisher to the mbean.", notification, mbean.getActualNotification());
assertSame("The 'source' property of the Notification is *wrongly* being set to the ObjectName of the associated MBean.", this, mbean.getActualNotification().getSource());
}
代码示例来源:origin: spring-projects/spring-framework
public void testSendAttributeChangeNotification() throws Exception {
StubSpringModelMBean mbean = new StubSpringModelMBean();
Notification notification = new AttributeChangeNotification(mbean, 1872, System.currentTimeMillis(), "Shall we break for some tea?", "agree", "java.lang.Boolean", Boolean.FALSE, Boolean.TRUE);
ObjectName objectName = createObjectName();
NotificationPublisher publisher = new ModelMBeanNotificationPublisher(mbean, objectName, mbean);
publisher.sendNotification(notification);
assertNotNull(mbean.getActualNotification());
assertTrue(mbean.getActualNotification() instanceof AttributeChangeNotification);
assertSame("The exact same Notification is not being passed through from the publisher to the mbean.", notification, mbean.getActualNotification());
assertSame("The 'source' property of the Notification is not being set to the ObjectName of the associated MBean.", objectName, mbean.getActualNotification().getSource());
}
代码示例来源:origin: spring-projects/spring-framework
public void testSendVanillaNotification() throws Exception {
StubSpringModelMBean mbean = new StubSpringModelMBean();
Notification notification = new Notification("network.alarm.router", mbean, 1872);
ObjectName objectName = createObjectName();
NotificationPublisher publisher = new ModelMBeanNotificationPublisher(mbean, objectName, mbean);
publisher.sendNotification(notification);
assertNotNull(mbean.getActualNotification());
assertSame("The exact same Notification is not being passed through from the publisher to the mbean.", notification, mbean.getActualNotification());
assertSame("The 'source' property of the Notification is not being set to the ObjectName of the associated MBean.", objectName, mbean.getActualNotification().getSource());
}
代码示例来源:origin: spring-projects/spring-integration
private void verifyReceipt(PollableChannel channel, String beanName) {
Message<?> message = channel.receive(1000);
assertNotNull(message);
assertEquals(Notification.class, message.getPayload().getClass());
assertEquals("ABC", ((Notification) message.getPayload()).getMessage());
assertTrue(((String) ((Notification) message.getPayload()).getSource()).endsWith(beanName));
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void simplePublish() {
MessageHandler handler = context.getBean("testPublisher", MessageHandler.class);
assertEquals(0, this.listener.notifications.size());
handler.handleMessage(new GenericMessage<String>("foo"));
assertEquals(1, this.listener.notifications.size());
Notification notification = this.listener.notifications.get(0);
assertEquals(this.publisherObjectName, notification.getSource());
assertEquals("foo", notification.getMessage());
assertEquals("test.type", notification.getType());
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void simpleNotification() {
QueueChannel outputChannel = new QueueChannel();
NotificationListeningMessageProducer adapter = new NotificationListeningMessageProducer();
adapter.setServer(this.server);
adapter.setObjectName(this.objectName);
adapter.setOutputChannel(outputChannel);
adapter.setBeanFactory(mock(BeanFactory.class));
adapter.afterPropertiesSet();
adapter.start();
adapter.onApplicationEvent(new ContextRefreshedEvent(Mockito.mock(ApplicationContext.class)));
this.numberHolder.publish("foo");
Message<?> message = outputChannel.receive(0);
assertNotNull(message);
assertTrue(message.getPayload() instanceof Notification);
Notification notification = (Notification) message.getPayload();
assertEquals("foo", notification.getMessage());
assertEquals(objectName, notification.getSource());
assertNull(message.getHeaders().get(JmxHeaders.NOTIFICATION_HANDBACK));
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void notificationWithHandback() {
QueueChannel outputChannel = new QueueChannel();
NotificationListeningMessageProducer adapter = new NotificationListeningMessageProducer();
adapter.setServer(this.server);
adapter.setObjectName(this.objectName);
adapter.setOutputChannel(outputChannel);
Integer handback = 123;
adapter.setHandback(handback);
adapter.setBeanFactory(mock(BeanFactory.class));
adapter.afterPropertiesSet();
adapter.start();
adapter.onApplicationEvent(new ContextRefreshedEvent(Mockito.mock(ApplicationContext.class)));
this.numberHolder.publish("foo");
Message<?> message = outputChannel.receive(0);
assertNotNull(message);
assertTrue(message.getPayload() instanceof Notification);
Notification notification = (Notification) message.getPayload();
assertEquals("foo", notification.getMessage());
assertEquals(objectName, notification.getSource());
assertEquals(handback, message.getHeaders().get(JmxHeaders.NOTIFICATION_HANDBACK));
}
代码示例来源:origin: org.jboss.jbossas/jboss-as-connector
public boolean isNotificationEnabled(Notification n)
{
return RARDeployment.MCF_ATTRIBUTE_CHANGED_NOTIFICATION.equals(n.getType())
&& managedConnectionFactoryName.equals(n.getSource());
}
},
代码示例来源:origin: io.snappydata/gemfire-hydra-tests
public String toString(){
StringBuilder sb = new StringBuilder();
sb.append("Recorded Notif [ Type ").append(jmxNotificaiton.getType())
.append(" source : ").append(jmxNotificaiton.getSource())
.append(" message : ").append(jmxNotificaiton.getMessage())
.append(" userData : ").append(jmxNotificaiton.getUserData())
.append(" timestamp : ").append(jmxNotificaiton.getTimeStamp())
.append(" ]");
return sb.toString();
}
代码示例来源:origin: org.cyclopsgroup/jmxterm
@Override
public void handleNotification(Notification notification, Object handback) {
Session session = getSession();
StringBuilder sb = new StringBuilder("notification received: ");
sb.append("timestamp=").append(notification.getTimeStamp());
sb.append(",class=").append(notification.getClass().getName());
sb.append(",source=").append(notification.getSource());
sb.append(",type=").append(notification.getType());
sb.append(",message=").append(notification.getMessage());
session.output.println(sb.toString());
}
}
代码示例来源:origin: org.kohsuke.droovy/groovy
private static Map buildOperationNotificationPacket(Notification note) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("event", note.getType());
result.put("source", note.getSource());
result.put("sequenceNumber", note.getSequenceNumber());
result.put("timeStamp", note.getTimeStamp());
result.put("data", note.getUserData());
return result;
}
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
private static Map buildOperationNotificationPacket(Notification note) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("event", note.getType());
result.put("source", note.getSource());
result.put("sequenceNumber", note.getSequenceNumber());
result.put("timeStamp", note.getTimeStamp());
result.put("data", note.getUserData());
return result;
}
}
代码示例来源:origin: org.codehaus.groovy/groovy-jmx
private static Map buildOperationNotificationPacket(Notification note) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("event", note.getType());
result.put("source", note.getSource());
result.put("sequenceNumber", note.getSequenceNumber());
result.put("timeStamp", note.getTimeStamp());
result.put("data", note.getUserData());
return result;
}
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
private static Map buildOperationNotificationPacket(Notification note) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("event", note.getType());
result.put("source", note.getSource());
result.put("sequenceNumber", note.getSequenceNumber());
result.put("timeStamp", note.getTimeStamp());
result.put("data", note.getUserData());
return result;
}
}
代码示例来源:origin: io.snappydata/gemfire-hydra-tests
private void printJMXNotification(Notification notification, Object handback) {
StringBuilder sb = new StringBuilder();
sb.append("JMXNotificationListener(" + prefix + ") : Notification [ type=").append(notification.getType()).append(", message=")
.append(notification.getMessage())
.append(", source=").append(notification.getSource())
.append(", seqNo=").append(notification.getSequenceNumber())
.append(", timestamp=").append(notification.getTimeStamp())
.append(", data=").append(ObjectToString(notification.getUserData()))
.append(", handbackObject=").append(ObjectToString(handback)).append(" ]");
logInfo(sb.toString());
}
代码示例来源:origin: net.open-esb.core/jbi-admin-common
/**
* Handle the Event Notification
* @param the notification
* @param the handback object
*
* @see javax.management.NotificationListener#handleNotification(javax.management.Notification, java.lang.Object)
*/
public void handleNotification(Notification notification, Object handback) {
EventNotificationImpl event = new EventNotificationImpl(notification.getSource());
event.setNotification(notification);
executorService.execute(new NotificationSender(this.listeners, event));
}
内容来源于网络,如有侵权,请联系作者删除!