Example #1
0
  public void registerAvailableMBeans(@Observes final AfterDeploymentValidation event) {
    MBeanManager manager = Beans.getReference(MBeanManager.class);
    JMXConfig configuration = Beans.getReference(JMXConfig.class);

    for (AnnotatedType<?> type : types) {
      final Class<?> clazz = type.getJavaClass();
      DynamicMBeanProxy beanProxy = new DynamicMBeanProxy(clazz, this.mbeanContext);

      StringBuffer name =
          new StringBuffer()
              .append(
                  configuration.getMbeanDomain() != null
                      ? configuration.getMbeanDomain()
                      : clazz.getPackage().getName())
              .append(":name=")
              .append(
                  configuration.getMbeanDomain() != null
                      ? configuration.getMbeanDomain()
                      : clazz.getSimpleName());

      if (manager.findMBeanInstance(name.toString()) == null) {
        ObjectInstance instance = MBeanHelper.register(beanProxy, name.toString());
        manager.storeRegisteredMBean(instance);
      }
    }
  }
Example #2
0
  public void registerNotificationMBean(@Observes final AfterDeploymentValidation event) {
    MBeanManager mbeanManager = Beans.getReference(MBeanManager.class);
    JMXConfig configuration = Beans.getReference(JMXConfig.class);

    NotificationBroadcaster notificationBroadcaster =
        Beans.getReference(NotificationBroadcaster.class);

    StringBuffer notificationMBeanName =
        new StringBuffer()
            .append(
                configuration.getNotificationDomain() != null
                    ? configuration.getNotificationDomain()
                    : "br.gov.frameworkdemoiselle.jmx")
            .append(":name=")
            .append(configuration.getNotificationMBeanName());

    if (mbeanManager.findMBeanInstance(notificationMBeanName.toString()) == null) {
      ObjectInstance instance =
          MBeanHelper.register(notificationBroadcaster, notificationMBeanName.toString());
      mbeanManager.storeRegisteredMBean(instance);
    }
  }