java类javax.management.Notification的实例源码

NotificationAccessControllerTest.java 文件源码 项目:openjdk-jdk10 阅读 21 收藏 0 点赞 0 评论 0
@Override
public void handleNotification(Notification n, Object h) {
    echo("handleNotification:");
    echo("\tNotification = " + n);
    echo("\tNotification.SeqNum = " + n.getSequenceNumber());
    echo("\tHandback = " + h);
    notifs.add(n);
    s.release();
}
ManagementAdapter.java 文件源码 项目:monarch 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Invoked when a client has gracefully disconnected from this process or when this process has
 * gracefully disconnected from a CacheServer.
 */
public void memberLeft(ClientMembershipEvent event) {
  Notification notification = new Notification(JMXNotificationType.CLIENT_LEFT, serverSource,
      SequenceNumber.next(), System.currentTimeMillis(),
      ManagementConstants.CLIENT_LEFT_PREFIX + event.getMemberId());
  serverLevelNotifEmitter.sendNotification(notification);
  memberLevelNotifEmitter.sendNotification(notification);
}
ServerNotifForwarder.java 文件源码 项目:openjdk-jdk10 阅读 27 收藏 0 点赞 0 评论 0
public void apply(List<TargetedNotification> targetedNotifs,
                  ObjectName source, Notification notif) {
    // We proceed in two stages here, to avoid holding the listenerMap
    // lock while invoking the filters (which are user code).
    final IdAndFilter[] candidates;
    synchronized (listenerMap) {
        final Set<IdAndFilter> set = listenerMap.get(source);
        if (set == null) {
            logger.debug("bufferFilter", "no listeners for this name");
            return;
        }
        candidates = new IdAndFilter[set.size()];
        set.toArray(candidates);
    }
    // We don't synchronize on targetedNotifs, because it is a local
    // variable of our caller and no other thread can see it.
    for (IdAndFilter idaf : candidates) {
        final NotificationFilter nf = idaf.getFilter();
        if (nf == null || nf.isNotificationEnabled(notif)) {
            logger.debug("bufferFilter", "filter matches");
            final TargetedNotification tn =
                    new TargetedNotification(notif, idaf.getId());
            if (allowNotificationEmission(source, tn))
                targetedNotifs.add(tn);
        }
    }
}
ServerNotifForwarder.java 文件源码 项目:jdk8u-jdk 阅读 23 收藏 0 点赞 0 评论 0
public void apply(List<TargetedNotification> targetedNotifs,
                  ObjectName source, Notification notif) {
    // We proceed in two stages here, to avoid holding the listenerMap
    // lock while invoking the filters (which are user code).
    final IdAndFilter[] candidates;
    synchronized (listenerMap) {
        final Set<IdAndFilter> set = listenerMap.get(source);
        if (set == null) {
            logger.debug("bufferFilter", "no listeners for this name");
            return;
        }
        candidates = new IdAndFilter[set.size()];
        set.toArray(candidates);
    }
    // We don't synchronize on targetedNotifs, because it is a local
    // variable of our caller and no other thread can see it.
    for (IdAndFilter idaf : candidates) {
        final NotificationFilter nf = idaf.getFilter();
        if (nf == null || nf.isNotificationEnabled(notif)) {
            logger.debug("bufferFilter", "filter matches");
            final TargetedNotification tn =
                    new TargetedNotification(notif, idaf.getId());
            if (allowNotificationEmission(source, tn))
                targetedNotifs.add(tn);
        }
    }
}
BaseModelMBean.java 文件源码 项目:tomcat7 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Send a <code>Notification</code> to all registered listeners as a
 * <code>jmx.modelmbean.general</code> notification.
 *
 * @param notification The <code>Notification</code> that will be passed
 *
 * @exception MBeanException if an object initializer throws an
 *  exception
 * @exception RuntimeOperationsException wraps IllegalArgumentException
 *  when the specified notification is <code>null</code> or invalid
 */
@Override
public void sendNotification(Notification notification)
    throws MBeanException, RuntimeOperationsException {

    if (notification == null)
        throw new RuntimeOperationsException
            (new IllegalArgumentException("Notification is null"),
             "Notification is null");
    if (generalBroadcaster == null)
        return; // This means there are no registered listeners
    generalBroadcaster.sendNotification(notification);

}
ManagementAdapter.java 文件源码 项目:monarch 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Invoked when a client has connected to this process or when this process has connected to a
 * CacheServer.
 */
public void memberJoined(ClientMembershipEvent event) {
  Notification notification = new Notification(JMXNotificationType.CLIENT_JOINED, serverSource,
      SequenceNumber.next(), System.currentTimeMillis(),
      ManagementConstants.CLIENT_JOINED_PREFIX + event.getMemberId());
  serverLevelNotifEmitter.sendNotification(notification);
  memberLevelNotifEmitter.sendNotification(notification);

}
MBeanListener.java 文件源码 项目:openjdk-jdk10 阅读 17 收藏 0 点赞 0 评论 0
public void handleNotification(
        final Notification notifIn,
        final Object handback)
{
    if (notifIn instanceof MBeanServerNotification)
    {
        final MBeanServerNotification notif = (MBeanServerNotification) notifIn;
        final ObjectName objectName = notif.getMBeanName();

        boolean match = false;
        if ( mObjectName != null && mObjectName.equals(objectName) )
        {
            match = true;
        }
        else if ( objectName.getDomain().equals( mJMXDomain ) )
        {
            if ( mType != null && mType.equals(objectName.getKeyProperty(TYPE_KEY)) )
            {
                final String mbeanName = objectName.getKeyProperty(NAME_KEY);
                if (mName != null && mName.equals(mbeanName))
                {
                    match = true;
                }
            }
        }

        if ( match )
        {
            final String notifType = notif.getType();
            if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(notifType))
            {
                mCallback.mbeanRegistered(objectName, this);
            }
            else if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(notifType))
            {
                mCallback.mbeanUnregistered(objectName, this);
            }
        }
    }
}
ManagementAdapter.java 文件源码 项目:monarch 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Handles LockService Creation
 * 
 * @param lockService
 */
public void handleLockServiceCreation(DLockService lockService) throws ManagementException {
  if (!isServiceInitialised("handleLockServiceCreation")) {
    return;
  }
  /** Internal Locks Should not be exposed to client for monitoring **/
  if (internalLocks.contains(lockService.getName())) {
    return;
  }
  LockServiceMBeanBridge bridge = new LockServiceMBeanBridge(lockService);
  LockServiceMXBean lockServiceMBean = new LockServiceMBean(bridge);

  ObjectName lockServiceMBeanName = MBeanJMXAdapter.getLockServiceMBeanName(
      cacheImpl.getDistributedSystem().getDistributedMember(), lockService.getName());

  ObjectName changedMBeanName =
      service.registerInternalMBean(lockServiceMBean, lockServiceMBeanName);

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

  Notification notification = new Notification(JMXNotificationType.LOCK_SERVICE_CREATED,
      memberSource, SequenceNumber.next(), System.currentTimeMillis(),
      ManagementConstants.LOCK_SERVICE_CREATED_PREFIX + lockService.getName());
  memberLevelNotifEmitter.sendNotification(notification);

  memberMBeanBridge.addLockServiceStats(lockService);
}
StandardContext.java 文件源码 项目:lams 阅读 27 收藏 0 点赞 0 评论 0
private void registerJMX() {
    try {
        if (log.isDebugEnabled()) {
            log.debug("Checking for " + oname );
        }
        if(! Registry.getRegistry(null, null)
            .getMBeanServer().isRegistered(oname)) {
            controller = oname;
            Registry.getRegistry(null, null)
                .registerComponent(this, oname, null);

            // Send j2ee.object.created notification 
            if (this.getObjectName() != null) {
                Notification notification = new Notification(
                                                    "j2ee.object.created", 
                                                    this.getObjectName(), 
                                                    sequenceNumber++);
                broadcaster.sendNotification(notification);
            }
        }
        Container children[] = findChildren();
        for (int i=0; children!=null && i<children.length; i++) {
            ((StandardWrapper)children[i]).registerJMX( this );
        }
    } catch (Exception ex) {
        if(log.isInfoEnabled())
            log.info("Error registering wrapper with jmx " + this + " " +
                oname + " " + ex.toString(), ex );
    }
}
DirectoryScanner.java 文件源码 项目:jdk8u-jdk 阅读 29 收藏 0 点赞 0 评论 0
/**
 * The {@link DirectoryScannerMXBean} may send two types of
 * notifications: filematch, and state attribute changed.
 **/
public MBeanNotificationInfo[] getNotificationInfo() {
    return new MBeanNotificationInfo[] {
        new MBeanNotificationInfo(
                new String[] {FILE_MATCHES_NOTIFICATION},
                Notification.class.getName(),
                "Emitted when a file that matches the scan criteria is found"
                ),
        new MBeanNotificationInfo(
                new String[] {AttributeChangeNotification.ATTRIBUTE_CHANGE},
                AttributeChangeNotification.class.getName(),
                "Emitted when the State attribute changes"
                )
    };
}


问题


面经


文章

微信
公众号

扫码关注公众号