コード例 #1
0
  public JMXRegistrationInfo provide(
      PicoContainer picoContainer, ComponentAdapter componentAdapter) {
    final Object _componentInstance = componentAdapter.getComponentInstance(picoContainer);

    try {
      final JMXManageable _manageable = (JMXManageable) _componentInstance;

      Exception _exception = null;

      try {
        // try to load XML XMBean Descriptor.
        String _clazzName = _manageable.getClass().getName().replace('.', '/');

        URL _url = _manageable.getClass().getResource("/" + _clazzName + ".xml");

        if (_url == null) {
          return fallback_.provide(picoContainer, componentAdapter);
        }

        final ObjectName _objectName =
            ObjectName.getInstance(domain_ + ":" + _manageable.getJMXObjectName());
        final JMXManageableXMBean _xmbean = new JMXManageableXMBean(_manageable, _url);

        return new JMXRegistrationInfo(_objectName, _xmbean);
      } catch (MalformedObjectNameException e) {
        _exception = e;
      } catch (NotCompliantMBeanException e) {
        _exception = e;
      } catch (NullPointerException e) {
        _exception = e;
      } catch (MBeanException e) {
        _exception = e;
      }

      throw new JMXRegistrationException(
          "Cannot create MBean for component '" + componentAdapter.getComponentKey() + "'",
          _exception);

    } catch (ClassCastException e) {
      return null;
    }
  }
コード例 #2
0
    public JMXManageableXMBean(final JMXManageable manageable, URL url)
        throws NotCompliantMBeanException, MBeanException {
      super(manageable, url);

      types_ = manageable.getJMXNotificationTypes();

      manageable.setJMXCallback(
          new JMXManageable.JMXCallback() {

            public void sendJMXNotification(String type, String message) {
              broadCaster_.sendNotification(
                  new Notification(
                      type, // type
                      manageable, // source
                      ++notificationSequence_, // seq. number
                      message // message
                      ));
            }

            public void sendJMXAttributeChanged(String name, Object oldValue, Object newValue) {
              broadCaster_.sendNotification(
                  new AttributeChangeNotification(
                      manageable,
                      ++notificationSequence_,
                      System.currentTimeMillis(),
                      "Attribute value changed",
                      name,
                      oldValue == null ? null : oldValue.getClass().getName(),
                      oldValue,
                      newValue));
            }

            public void sendJMXNotification(String type, String message, Object payload) {
              sendJMXNotification(type, message);
            }
          });
    }