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


Java NotificationFilterSupport类代码示例

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


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

示例1: addLoggerMBean

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
ObjectName addLoggerMBean(Logger logger) {
  String name = logger.getName();
  ObjectName objectName = null;
  try {
    LoggerDynamicMBean loggerMBean = new LoggerDynamicMBean(logger);
    objectName = new ObjectName("log4j", "logger", name);
    
    if (!server.isRegistered(objectName)) {
      server.registerMBean(loggerMBean, objectName);
      NotificationFilterSupport nfs = new NotificationFilterSupport();
      nfs.enableType(ADD_APPENDER + logger.getName());
      log.debug("---Adding logger [" + name + "] as listener.");
      nbs.addNotificationListener(loggerMBean, nfs, null);
      vAttributes.add(new MBeanAttributeInfo("logger=" + name, "javax.management.ObjectName",
              "The " + name + " logger.", true, true, // this makes the object
              // clickable
              false));
      
    }

  } catch(Exception e) {
    log.error("Could not add loggerMBean for ["+name+"].", e);
  }
  return objectName;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:26,代码来源:HierarchyDynamicMBean.java

示例2: addEventListeners

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
/**
 * Sets up event listeners for this MBean as described in the descriptor.
 * The descriptor contains a map with layout {item -> Map[event:"...", from:ObjectName, callback:&Closure],...,}
 *
 * @param server     the MBeanServer is to be registered.
 * @param descriptor a map containing info about the event
 */
public void addEventListeners(MBeanServer server, Map<String, Map<String, Object>> descriptor) {
    for (Map.Entry<String, Map<String, Object>> item : descriptor.entrySet()) {
        Map<String, Object> listener = item.getValue();

        // register with server
        ObjectName broadcaster = (ObjectName) listener.get("from");
        try {
            String eventType = (String) listener.get("event");

            if (eventType != null) {
                NotificationFilterSupport filter = new NotificationFilterSupport();
                filter.enableType(eventType);
                server.addNotificationListener(broadcaster, JmxEventListener.getListener(), filter, listener);
            } else {
                server.addNotificationListener(broadcaster, JmxEventListener.getListener(), null, listener);
            }
        } catch (InstanceNotFoundException e) {
            throw new JmxBuilderException(e);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:29,代码来源:JmxBuilderModelMBean.java

示例3: addMBeanServerDelegateListener

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
private void addMBeanServerDelegateListener() {
  
    _MBeanServerDelegateNotificationListener = new MBeanServerDelegateNotificationListener();
    NotificationFilterSupport filter = new NotificationFilterSupport();
    filter.enableType(MBeanServerNotification.REGISTRATION_NOTIFICATION);
    filter.enableType(MBeanServerNotification.UNREGISTRATION_NOTIFICATION);

    try {
        _MBeanServerConnection.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME,
                _MBeanServerDelegateNotificationListener, filter, null);
    }
    catch (Exception e) {
    }

}
 
开发者ID:baloise,项目名称:eZooKeeper,代码行数:16,代码来源:JmxConnection.java

示例4: addListenerForMBeanRemovedNotif

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
protected Integer addListenerForMBeanRemovedNotif()
throws IOException, InstanceNotFoundException {
    NotificationFilterSupport clientFilter =
            new NotificationFilterSupport();
    clientFilter.enableType(
            MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
    MarshalledObject<NotificationFilter> sFilter =
        new MarshalledObject<NotificationFilter>(clientFilter);

    Integer[] listenerIDs;
    final ObjectName[] names =
        new ObjectName[] {MBeanServerDelegate.DELEGATE_NAME};
    final MarshalledObject<NotificationFilter>[] filters =
        Util.cast(new MarshalledObject<?>[] {sFilter});
    final Subject[] subjects = new Subject[] {null};
    try {
        listenerIDs =
                connection.addNotificationListeners(names,
                filters,
                subjects);

    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        listenerIDs =
                connection.addNotificationListeners(names,
                filters,
                subjects);
    }
    return listenerIDs[0];
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:RMIConnector.java

示例5: connectToDS

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
/**
 * the INITTASKS calling connectToDS across ThreadGroups 
 * should be executed with the keyword SEQUENTIAL
 * <p>
 * Must be invoked after the JMX agents have been created, started, and
 * connected using {@link hydra.AgentHelper}.
 */
public static void connectToDS() throws Exception
{
  // Connect To DS
  connectToDSButDoNotAttachListeners();

  //Register the stat alert notification listener as well.
  listener = new StatAlertNotificationListener(40);
  NotificationFilterSupport support = new NotificationFilterSupport();
  support.enableType(AdminDistributedSystemJmxImpl.NOTIF_STAT_ALERT);
  mbsc.addNotificationListener(distributedSys, listener, support, new Object());
  
  logger.info("Connected to JMX ADS " + distributedSys);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:21,代码来源:JMXHelper.java

示例6: addOperationCallListeners

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
/**
 * Registers listeners for operation calls (i.e. method, getter, and setter calls) when
 * invoked on this bean from the MBeanServer.  Descriptor should contain a map with layout
 * item -> [Map[methodListener:[target:"", tpe:"", callback:&amp;Closure], ... ,]]
 *
 * @param descriptor MetaMap descriptor containing description of operation call listeners
 */
public void addOperationCallListeners(Map<String, Map<String, Map<String, Object>>> descriptor) {
    if (descriptor == null) return;
    for (Map.Entry<String, Map<String, Map<String, Object>>> item : descriptor.entrySet()) {
        // set up method listeners (such as attributeListener and Operation Listeners)
        // item -> [Map[methodListener:[target:"", tpe:"", callback:&Closure], ... ,]]
        if (item.getValue().containsKey("methodListener")) {
            Map<String, Object> listener = item.getValue().get("methodListener");
            String target = (String) listener.get("target");
            methodListeners.add(target);
            String listenerType = (String) listener.get("type");
            listener.put("managedObject", this.managedObject);
            // register an attribute change notification listener with model mbean
            if (listenerType.equals("attributeChangeListener")) {
                try {
                    this.addAttributeChangeNotificationListener(
                            AttributeChangedListener.getListener(), (String) listener.get("attribute"), listener
                    );
                } catch (MBeanException e) {
                    throw new JmxBuilderException(e);
                }
            }
            if (listenerType.equals("operationCallListener")) {
                String eventType = "jmx.operation.call." + target;
                NotificationFilterSupport filter = new NotificationFilterSupport();
                filter.enableType(eventType);
                this.addNotificationListener(JmxEventListener.getListener(), filter, listener);
            }
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:38,代码来源:JmxBuilderModelMBean.java

示例7: start

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
public void start(ApplicationServer server, EventContext defaultEventContext, EventPublisher eventPublisher, String state) {
    NotificationFilterSupport filter = new NotificationFilterSupport();
    // TODO: use constants from NotificationConstants here
    filter.enableType("websphere.ras.audit");
    filter.enableType("websphere.ras.warning");
    filter.enableType("websphere.ras.error");
    filter.enableType("websphere.ras.fatal");
    registration = server.addNotificationListener(Utils.createObjectName("WebSphere:type=RasLoggingService,*"), new RasLoggingNotificationListener(defaultEventContext, eventPublisher), filter, null, true);
}
 
开发者ID:kszbcss,项目名称:rhq-websphere-plugin,代码行数:10,代码来源:RasLoggingProvider.java

示例8: addLoggerMBean

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
ObjectName addLoggerMBean(Logger logger) {
  String name = logger.getName();
  ObjectName objectName = null;
  try {
    LoggerDynamicMBean loggerMBean = new LoggerDynamicMBean(logger);
    objectName = new ObjectName("log4j", "logger", name);
    server.registerMBean(loggerMBean, objectName);

    NotificationFilterSupport nfs = new NotificationFilterSupport();
    nfs.enableType(ADD_APPENDER+logger.getName());

    log.debug("---Adding logger ["+name+"] as listener.");

    nbs.addNotificationListener(loggerMBean, nfs, null);


    vAttributes.add(new MBeanAttributeInfo("logger="+name,
			     "javax.management.ObjectName",
			     "The "+name+" logger.",
			     true,
			     true, // this makes the object
			     // clickable
			     false));

  } catch(Exception e) {
    log.error("Could not add loggerMBean for ["+name+"].", e);
  }
  return objectName;
}
 
开发者ID:nologic,项目名称:nabs,代码行数:30,代码来源:HierarchyDynamicMBean.java

示例9: doTestMBeanServerNotification_REGISTRATION_NOTIFICATION

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
public void doTestMBeanServerNotification_REGISTRATION_NOTIFICATION(MBeanServerConnection connection, boolean mustReceiveNotification) throws Exception {
    final ObjectName testObjectName = createObjectName(LEGACY_DOMAIN + ":subsystem=test");
    final ObjectName childObjectName = createObjectName(LEGACY_DOMAIN + ":subsystem=test,single=only");

    final CountDownLatch notificationEmitted = new CountDownLatch(1);
    final AtomicReference<Notification> notification = new AtomicReference<>();
    NotificationListener listener = new MbeanServerNotificationListener(notification, notificationEmitted, LEGACY_DOMAIN);
    NotificationFilterSupport filter = new NotificationFilterSupport();
    filter.enableType(MBeanServerNotification.REGISTRATION_NOTIFICATION);

    connection.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME, listener, filter, null);

    // add a management resource
    connection.invoke(testObjectName, "addSingleOnly", new Object[]{123}, new String[]{String.class.getName()});

    if (mustReceiveNotification) {
        Assert.assertTrue("Did not receive expected notification", notificationEmitted.await(1, TimeUnit.SECONDS));
        Notification notif = notification.get();
        Assert.assertNotNull(notif);
        Assert.assertTrue(notif instanceof MBeanServerNotification);
        MBeanServerNotification mBeanServerNotification = (MBeanServerNotification) notif;
        Assert.assertEquals(MBeanServerNotification.REGISTRATION_NOTIFICATION, notif.getType());
        Assert.assertEquals(childObjectName, mBeanServerNotification.getMBeanName());
    } else {
        Assert.assertFalse("Did receive unexpected notification", notificationEmitted.await(500, TimeUnit.MILLISECONDS));
    }

    connection.removeNotificationListener(MBeanServerDelegate.DELEGATE_NAME, listener, filter, null);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:30,代码来源:ModelControllerMBeanTestCase.java

示例10: doTestMBeanServerNotification_UNREGISTRATION_NOTIFICATION

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
private void doTestMBeanServerNotification_UNREGISTRATION_NOTIFICATION(MBeanServerConnection connection, boolean mustReceiveNotification) throws Exception {
    final ObjectName testObjectName = createObjectName(LEGACY_DOMAIN + ":subsystem=test");
    final ObjectName childObjectName = createObjectName(LEGACY_DOMAIN + ":subsystem=test,single=only");

    final CountDownLatch notificationEmitted = new CountDownLatch(1);
    final AtomicReference<Notification> notification = new AtomicReference<>();

    NotificationListener listener = new MbeanServerNotificationListener(notification, notificationEmitted, LEGACY_DOMAIN);
    NotificationFilterSupport filter = new NotificationFilterSupport();
    filter.enableType(MBeanServerNotification.UNREGISTRATION_NOTIFICATION);

    connection.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME, listener, filter, null);

    // add a management resource
    connection.invoke(testObjectName, "addSingleOnly", new Object[]{123}, new String[]{String.class.getName()});
    // and remove it
    connection.invoke(childObjectName, "remove", new Object[0], new String[0]);

    if (mustReceiveNotification) {
        Assert.assertTrue("Did not receive expected notification", notificationEmitted.await(1, TimeUnit.SECONDS));
        Notification notif = notification.get();
        Assert.assertNotNull(notif);
        Assert.assertTrue(notif instanceof MBeanServerNotification);
        MBeanServerNotification mBeanServerNotification = (MBeanServerNotification) notif;
        Assert.assertEquals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION, mBeanServerNotification.getType());
        Assert.assertEquals(childObjectName, mBeanServerNotification.getMBeanName());
    } else {
        Assert.assertFalse("Did receive unexpected notification", notificationEmitted.await(500, TimeUnit.MILLISECONDS));
    }

    connection.removeNotificationListener(MBeanServerDelegate.DELEGATE_NAME, listener, filter, null);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:33,代码来源:ModelControllerMBeanTestCase.java

示例11: testNotificationFilterSupport

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
/**
 * Test for the constructor NotificationFilterSupport()
 * 
 * @see javax.management.NotificationFilterSupport#NotificationFilterSupport()
 */
public final void testNotificationFilterSupport() {
    NotificationFilterSupport f = new NotificationFilterSupport();
    assertEquals("No one notification type should be enabled!", 0, f
        .getEnabledTypes().size());
    assertTrue("The instance should be serializable!",
        (Serializable.class
        .isAssignableFrom(f.getClass())));
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:14,代码来源:NotificationFilterSupportTest.java

示例12: setUpDisableAllTypes

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
/**
 * Disable all types, change attribute1, invoke sayHello.
 */
public final void setUpDisableAllTypes()
    throws InstanceNotFoundException, AttributeNotFoundException,
    InvalidAttributeValueException, MBeanException, ReflectionException {
    NotificationFilterSupport f = new NotificationFilterSupport();
    f.enableType(AttributeChangeNotification.ATTRIBUTE_CHANGE);
    f.enableType(Hello.SAY_HELLO_INVOKED);
    f.disableAllTypes();
    mbs.addNotificationListener(name, this, f, null);
    freeze(300);
    mbs.setAttribute(name, new Attribute("Attribute1", "New value"));
    mbs.invoke(name, "sayHello", new Object[0], new String[0]);
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:16,代码来源:NotificationFilterSupportTest.java

示例13: setUpDisableType

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
/**
 * Disable ATTRIBUTE_CHANGE type, change attribute1.
 */
public final void setUpDisableType() throws InstanceNotFoundException,
    AttributeNotFoundException, InvalidAttributeValueException,
    MBeanException, ReflectionException {
    NotificationFilterSupport f = new NotificationFilterSupport();
    f.enableType(AttributeChangeNotification.ATTRIBUTE_CHANGE);
    f.disableType(AttributeChangeNotification.ATTRIBUTE_CHANGE);
    mbs.addNotificationListener(name, this, f, null);
    freeze(300);
    mbs.setAttribute(name, new Attribute("Attribute1", "New value"));
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:14,代码来源:NotificationFilterSupportTest.java

示例14: testEnableType

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
/**
 * Test for the method enableType(java.lang.String)
 * 
 * @see javax.management.NotificationFilterSupport#enableType(java.lang.String)
 */
public final void testEnableType() {
    assertNotNull("Notification has not been received!", n);

    // Test exception.
    NotificationFilterSupport f = new NotificationFilterSupport();
    try {
        f.enableType(null);
        fail("IllegalArgumentException not thrown!");
    } catch (Throwable ex) {
        assertTrue("Wrong exception thrown: " + ex,
            (ex instanceof IllegalArgumentException));
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:19,代码来源:NotificationFilterSupportTest.java

示例15: testGetEnabledTypes

import javax.management.NotificationFilterSupport; //导入依赖的package包/类
/**
 * Test for the method getEnabledTypes()
 * 
 * @see javax.management.NotificationFilterSupport#getEnabledTypes()
 */
public final void testGetEnabledTypes() {
    NotificationFilterSupport f = new NotificationFilterSupport();
    f.enableType(AttributeChangeNotification.ATTRIBUTE_CHANGE);
    f.enableType(Hello.SAY_HELLO_INVOKED);
    Vector v = f.getEnabledTypes();

    assertTrue("The ATTRIBUTE_CHANGE notification should be enabled!", v
        .contains(AttributeChangeNotification.ATTRIBUTE_CHANGE));
    assertTrue("The SAY_HELLO_INVOKED notification should be enabled!", v
        .contains(Hello.SAY_HELLO_INVOKED));
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:17,代码来源:NotificationFilterSupportTest.java


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