当前位置: 首页>>代码示例>>Java>>正文


Java Notification类代码示例

本文整理汇总了Java中javax.management.Notification的典型用法代码示例。如果您正苦于以下问题:Java Notification类的具体用法?Java Notification怎么用?Java Notification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Notification类属于javax.management包,在下文中一共展示了Notification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkNotifs

import javax.management.Notification; //导入依赖的package包/类
/**
 * Check received notifications
 */
public int checkNotifs(int size,
                       List<Notification> received,
                       List<ObjectName> expected) {
    if (received.size() != size) {
        echo("Error: expecting " + size + " notifications, got " +
                received.size());
        return 1;
    } else {
        for (Notification n : received) {
            echo("Received notification: " + n);
            if (!n.getType().equals("nb")) {
                echo("Notification type must be \"nb\"");
                return 1;
            }
            ObjectName o = (ObjectName) n.getSource();
            int index = (int) n.getSequenceNumber();
            ObjectName nb = expected.get(index);
            if (!o.equals(nb)) {
                echo("Notification source must be " + nb);
                return 1;
            }
        }
    }
    return 0;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:NotificationAccessControllerTest.java

示例2: handleNotification

import javax.management.Notification; //导入依赖的package包/类
@Override
public void handleNotification(Notification notification,
                               Object handback) {
    notificationCount.incrementAndGet();
    System.out.println("\nReceived notification:");
    System.out.println("\tClassName: " + notification.getClass().getName());
    System.out.println("\tSource: " + notification.getSource());
    System.out.println("\tType: " + notification.getType());
    System.out.println("\tMessage: " + notification.getMessage());
    if (notification instanceof AttributeChangeNotification) {
        AttributeChangeNotification acn =
            (AttributeChangeNotification) notification;
        System.out.println("\tAttributeName: " + acn.getAttributeName());
        System.out.println("\tAttributeType: " + acn.getAttributeType());
        System.out.println("\tNewValue: " + acn.getNewValue());
        System.out.println("\tOldValue: " + acn.getOldValue());
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:19,代码来源:TestSlowQueryReport.java

示例3: handleGatewaySenderCreation

import javax.management.Notification; //导入依赖的package包/类
/**
 * Handles GatewaySender creation
 * 
 * @param sender the specific gateway sender
 * @throws ManagementException
 */
public void handleGatewaySenderCreation(GatewaySender sender) throws ManagementException {
  if (!isServiceInitialised("handleGatewaySenderCreation")) {
    return;
  }
  GatewaySenderMBeanBridge bridge = new GatewaySenderMBeanBridge(sender);

  GatewaySenderMXBean senderMBean = new GatewaySenderMBean(bridge);
  ObjectName senderObjectName = MBeanJMXAdapter.getGatewaySenderMBeanName(
      cacheImpl.getDistributedSystem().getDistributedMember(), sender.getId());

  ObjectName changedMBeanName = service.registerInternalMBean(senderMBean, senderObjectName);

  service.federate(changedMBeanName, GatewaySenderMXBean.class, true);

  Notification notification = new Notification(JMXNotificationType.GATEWAY_SENDER_CREATED,
      memberSource, SequenceNumber.next(), System.currentTimeMillis(),
      ManagementConstants.GATEWAY_SENDER_CREATED_PREFIX);
  memberLevelNotifEmitter.sendNotification(notification);

}
 
开发者ID:ampool,项目名称:monarch,代码行数:27,代码来源:ManagementAdapter.java

示例4: createGatewayReceiverMBean

import javax.management.Notification; //导入依赖的package包/类
private void createGatewayReceiverMBean(GatewayReceiver recv) {
  GatewayReceiverMBeanBridge bridge = new GatewayReceiverMBeanBridge(recv);

  GatewayReceiverMXBean receiverMBean = new GatewayReceiverMBean(bridge);
  ObjectName recvObjectName = MBeanJMXAdapter
      .getGatewayReceiverMBeanName(cacheImpl.getDistributedSystem().getDistributedMember());

  ObjectName changedMBeanName = service.registerInternalMBean(receiverMBean, recvObjectName);

  service.federate(changedMBeanName, GatewayReceiverMXBean.class, true);

  Notification notification = new Notification(JMXNotificationType.GATEWAY_RECEIVER_CREATED,
      memberSource, SequenceNumber.next(), System.currentTimeMillis(),
      ManagementConstants.GATEWAY_RECEIVER_CREATED_PREFIX);
  memberLevelNotifEmitter.sendNotification(notification);

}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:ManagementAdapter.java

示例5: destroyInternal

import javax.management.Notification; //导入依赖的package包/类
/** Destroy needs to clean up the context completely.
 * 
 * The problem is that undoing all the config in start() and restoring 
 * a 'fresh' state is impossible. After stop()/destroy()/init()/start()
 * we should have the same state as if a fresh start was done - i.e
 * read modified web.xml, etc. This can only be done by completely 
 * removing the context object and remapping a new one, or by cleaning
 * up everything.
 * 
 * XXX Should this be done in stop() ?
 * 
 */ 
@Override
protected void destroyInternal() throws LifecycleException {
    
    // If in state NEW when destroy is called, the object name will never
    // have been set so the notification can't be created
    if (getObjectName() != null) { 
        // Send j2ee.object.deleted notification 
        Notification notification = 
            new Notification("j2ee.object.deleted", this.getObjectName(), 
                             sequenceNumber.getAndIncrement());
        broadcaster.sendNotification(notification);
    }

    if (namingResources != null) {
        namingResources.destroy();
    }

    synchronized (instanceListenersLock) {
        instanceListeners = new String[0];
    }

    super.destroyInternal();
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:36,代码来源:StandardContext.java

示例6: handleSystemNotification

import javax.management.Notification; //导入依赖的package包/类
/**
 * Sends the alert with the Object source as member. This notification will get filtered out for
 * particular alert level
 * 
 * @param details
 */
public void handleSystemNotification(AlertDetails details) {
  if (!isServiceInitialised("handleSystemNotification")) {
    return;
  }
  if (service.isManager()) {
    String systemSource = "DistributedSystem("
        + service.getDistributedSystemMXBean().getDistributedSystemId() + ")";
    Map<String, String> userData = prepareUserData(details);


    Notification notification = new Notification(JMXNotificationType.SYSTEM_ALERT, systemSource,
        SequenceNumber.next(), details.getMsgTime().getTime(), details.getMsg());

    notification.setUserData(userData);
    service.handleNotification(notification);
  }

}
 
开发者ID:ampool,项目名称:monarch,代码行数:25,代码来源:ManagementAdapter.java

示例7: handleNotification

import javax.management.Notification; //导入依赖的package包/类
public void handleNotification(Notification n, Object hb) {
    System.out.println("\tReceived notification: " + n.getType());
    if (n instanceof MonitorNotification) {
        MonitorNotification mn = (MonitorNotification) n;
        System.out.println("\tSource: " +
            mn.getSource());
        System.out.println("\tType: " +
            mn.getType());
        System.out.println("\tTimeStamp: " +
            mn.getTimeStamp());
        System.out.println("\tObservedObject: " +
            mn.getObservedObject());
        System.out.println("\tObservedAttribute: " +
            mn.getObservedAttribute());
        System.out.println("\tDerivedGauge: " +
            mn.getDerivedGauge());
        System.out.println("\tTrigger: " +
            mn.getTrigger());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:CounterMonitorInitThresholdTest.java

示例8: handleGatewayReceiverStop

import javax.management.Notification; //导入依赖的package包/类
/**
 * Handles Gateway receiver creation
 * 
 * @param recv specific gateway receiver
 * @throws ManagementException
 */
public void handleGatewayReceiverStop(GatewayReceiver recv) throws ManagementException {
  if (!isServiceInitialised("handleGatewayReceiverStop")) {
    return;
  }
  GatewayReceiverMBean mbean = (GatewayReceiverMBean) service.getLocalGatewayReceiverMXBean();
  GatewayReceiverMBeanBridge bridge = mbean.getBridge();

  bridge.stopServer();

  Notification notification = new Notification(JMXNotificationType.GATEWAY_RECEIVER_STOPPED,
      memberSource, SequenceNumber.next(), System.currentTimeMillis(),
      ManagementConstants.GATEWAY_RECEIVER_STOPPED_PREFIX);
  memberLevelNotifEmitter.sendNotification(notification);

}
 
开发者ID:ampool,项目名称:monarch,代码行数:22,代码来源:ManagementAdapter.java

示例9: initInternal

import javax.management.Notification; //导入依赖的package包/类
@Override
protected void initInternal() throws LifecycleException {
	super.initInternal();

	if (processTlds) {
		this.addLifecycleListener(new TldConfig());
	}

	// Register the naming resources
	if (namingResources != null) {
		namingResources.init();
	}

	// Send j2ee.object.created notification
	if (this.getObjectName() != null) {
		Notification notification = new Notification("j2ee.object.created", this.getObjectName(),
				sequenceNumber.getAndIncrement());
		broadcaster.sendNotification(notification);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:21,代码来源:StandardContext.java

示例10: handleNotification

import javax.management.Notification; //导入依赖的package包/类
@Override
public void handleNotification(Notification notification, Object handback) {
    String nType = notification.getType();
    String poolName
            = CodeCacheUtils.getPoolNameFromNotification(notification);
    // consider code cache events only
    if (CodeCacheUtils.isAvailableCodeHeapPoolName(poolName)) {
        Asserts.assertEQ(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED,
                nType, "Unexpected event received: " + nType);
        // receiving events from available CodeCache-related beans only
        if (counters.get(poolName) != null) {
            counters.get(poolName).incrementAndGet();
            lastEventTimestamp = System.currentTimeMillis();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:PoolsIndependenceTest.java

示例11: handleNotification

import javax.management.Notification; //导入依赖的package包/类
public void handleNotification(Notification notification, Object handback) {
    echo(">>> Received notification: " + notification);
    if (notification instanceof MonitorNotification) {
        String type = notification.getType();
        if (type.equals(MonitorNotification.RUNTIME_ERROR)) {
            MonitorNotification mn = (MonitorNotification) notification;
            echo("\tType: " + mn.getType());
            echo("\tTimeStamp: " + mn.getTimeStamp());
            echo("\tObservedObject: " + mn.getObservedObject());
            echo("\tObservedAttribute: " + mn.getObservedAttribute());
            echo("\tDerivedGauge: " + mn.getDerivedGauge());
            echo("\tTrigger: " + mn.getTrigger());

            synchronized (this) {
                messageReceived = true;
                notifyAll();
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ReflectionExceptionTest.java

示例12: sendNotification

import javax.management.Notification; //导入依赖的package包/类
/**
 * Send the supplied {@link Notification} using the wrapped
 * {@link ModelMBean} instance.
 * @param notification the {@link Notification} to be sent
 * @throws IllegalArgumentException if the supplied {@code notification} is {@code null}
 * @throws UnableToSendNotificationException if the supplied {@code notification} could not be sent
 */
@Override
public void sendNotification(Notification notification) {
	Assert.notNull(notification, "Notification must not be null");
	replaceNotificationSourceIfNecessary(notification);
	try {
		if (notification instanceof AttributeChangeNotification) {
			this.modelMBean.sendAttributeChangeNotification((AttributeChangeNotification) notification);
		}
		else {
			this.modelMBean.sendNotification(notification);
		}
	}
	catch (MBeanException ex) {
		throw new UnableToSendNotificationException("Unable to send notification [" + notification + "]", ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:ModelMBeanNotificationPublisher.java

示例13: checkNotifs

import javax.management.Notification; //导入依赖的package包/类
public int checkNotifs(int size,
                       List<Notification> received,
                       List<ObjectName> expected) {
    if (received.size() != size) {
        echo("Error: expecting " + size + " notifications, got " +
                received.size());
        return 1;
    } else {
        for (Notification n : received) {
            echo("Received notification: " + n);
            if (!n.getType().equals("nb")) {
                echo("Notification type must be \"nb\"");
                return 1;
            }
            ObjectName o = (ObjectName) n.getSource();
            int index = (int) n.getSequenceNumber();
            ObjectName nb = expected.get(index);
            if (!o.equals(nb)) {
                echo("Notification source must be " + nb);
                return 1;
            }
        }
    }
    return 0;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:NotificationEmissionTest.java

示例14: destroy

import javax.management.Notification; //导入依赖的package包/类
/** Destroy needs to clean up the context completely.
 * 
 * The problem is that undoing all the config in start() and restoring 
 * a 'fresh' state is impossible. After stop()/destroy()/init()/start()
 * we should have the same state as if a fresh start was done - i.e
 * read modified web.xml, etc. This can only be done by completely 
 * removing the context object and remapping a new one, or by cleaning
 * up everything.
 * 
 * XXX Should this be done in stop() ?
 * 
 */ 
public void destroy() throws Exception {
    if( oname != null ) { 
        // Send j2ee.object.deleted notification 
        Notification notification = 
            new Notification("j2ee.object.deleted", this.getObjectName(), 
                            sequenceNumber++);
        broadcaster.sendNotification(notification);
    } 
    super.destroy();

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(DESTROY_EVENT, null);

    instanceListeners = new String[0];

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:StandardContext.java

示例15: handleNotification

import javax.management.Notification; //导入依赖的package包/类
@Override
public void handleNotification(Notification notification, Object handback) {
    if (notification.getType().equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) {
        System.out.println("0XDEADBEAF");
        GarbageCollectionNotificationInfo notifInfo = GarbageCollectionNotificationInfo.from((CompositeData) notification.getUserData());

        GcInfo gcInfo = notifInfo.getGcInfo();
        System.out.printf("Action: %s, %s, %s\n", notifInfo.getGcAction(), notifInfo.getGcCause(), notifInfo.getGcName());
        System.out.printf("Time: %d, %d, %d\n", gcInfo.getStartTime(), gcInfo.getEndTime(), gcInfo.getDuration());
        System.out.printf("Memory: %s, %s\n", gcInfo.getMemoryUsageBeforeGc().toString(), gcInfo.getMemoryUsageAfterGc().toString());



        Map<String, MemoryUsage> memBefore = notifInfo.getGcInfo().getMemoryUsageBeforeGc();
        Map<String, MemoryUsage> memAfter = notifInfo.getGcInfo().getMemoryUsageAfterGc();
        StringBuilder sb = new StringBuilder();
        sb.append("[").append(notifInfo.getGcAction()).append(" / ").append(notifInfo.getGcCause())
                .append(" / ").append(notifInfo.getGcName()).append(" / (");
        appendMemUsage(sb, memBefore);
        sb.append(") -> (");
        appendMemUsage(sb, memAfter);
        sb.append("), ").append(notifInfo.getGcInfo().getDuration()).append(" ms]");
        System.out.println(sb.toString());
    }
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_10,代码行数:26,代码来源:MemoryUtil.java


注:本文中的javax.management.Notification类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。