Example usage for org.springframework.jmx.export.annotation AnnotationJmxAttributeSource AnnotationJmxAttributeSource

List of usage examples for org.springframework.jmx.export.annotation AnnotationJmxAttributeSource AnnotationJmxAttributeSource

Introduction

In this page you can find the example usage for org.springframework.jmx.export.annotation AnnotationJmxAttributeSource AnnotationJmxAttributeSource.

Prototype

AnnotationJmxAttributeSource

Source Link

Usage

From source file:com.mtgi.jmx.export.naming.AppendNamingStrategyTest.java

@Test
public void testNamingStrategy() throws MalformedObjectNameException {

    MetadataNamingStrategy delegate = new MetadataNamingStrategy();
    delegate.setAttributeSource(new AnnotationJmxAttributeSource());

    AppendNamingStrategy ans = new AppendNamingStrategy();
    ans.setDelegate(delegate);/*w  ww.  j a  va2 s  . c om*/
    ans.setDomain("testApplication");

    ObjectName name = ans.getObjectName(new XmlBehaviorEventPersisterImpl(), "testPersister");
    assertNotNull("name is constructed", name);
    assertEquals("name has been transformed correctly",
            "testApplication:package=com.mtgi.analytics,name=BeetLog", name.toString());
    assertEquals("package name quoted properly", "com.mtgi.analytics", name.getKeyProperty("package"));
}

From source file:com.brienwheeler.lib.jmx.MBeanRegistrationSupport.java

public static void registerMBean(Object mbean) {
    try {//from  w  w  w  .j  a  v  a 2 s .  c o  m
        ObjectNamingStrategy namingStrategy = new IdentityNamingStrategy();
        ObjectName objectName = namingStrategy.getObjectName(mbean, null);

        MBeanRegistrationSupport registrar = new MBeanRegistrationSupport();
        registrar.setServer(JmxUtils.locateMBeanServer());

        // if item qualifies as MBean, export it directly
        if (JmxUtils.isMBean(mbean.getClass())) {
            registrar.doRegister(mbean, objectName);
            return;
        }

        // assemble MBean info (from annotations by default)
        ModelMBean modelMBean = new RequiredModelMBean();
        modelMBean.setManagedResource(mbean, MR_TYPE_OBJECT_REFERENCE);
        MBeanInfoAssembler mBeanInfoAssembler = new MetadataMBeanInfoAssembler(
                new AnnotationJmxAttributeSource());
        modelMBean.setModelMBeanInfo(mBeanInfoAssembler.getMBeanInfo(mbean, objectName.getCanonicalName()));
        registrar.doRegister(modelMBean, objectName);
    } catch (Exception e) {
        throw new JmxRegisterException("error registering MBean", e);
    }
}

From source file:ru.trett.cis.config.Beans.java

@Bean
public AnnotationJmxAttributeSource attributeSource() {
    return new AnnotationJmxAttributeSource();
}

From source file:com.mtgi.jmx.export.naming.AppendNamingStrategyTest.java

@Test
public void testNewKey() throws MalformedObjectNameException {
    MetadataNamingStrategy delegate = new MetadataNamingStrategy();
    delegate.setAttributeSource(new AnnotationJmxAttributeSource());

    AppendNamingStrategy ans = new AppendNamingStrategy();
    ans.setDelegate(delegate);//from ww w.  j  ava2  s.c om
    ans.setValue("testPersister");
    ans.setDomain("testApplication");

    ObjectName name = ans.getObjectName(new XmlBehaviorEventPersisterImpl(), "testPersister");
    assertNotNull("name is constructed", name);
    assertEquals("name has been transformed correctly",
            "testApplication:package=com.mtgi.analytics,group=BeetLog,name=testPersister", name.toString());
    assertEquals("package name quoted properly", "com.mtgi.analytics", name.getKeyProperty("package"));
}

From source file:com.predic8.membrane.core.jmx.JmxExporter.java

@Override
public void start() {
    exporter = new MBeanExporter();
    exporter.setRegistrationPolicy(RegistrationPolicy.IGNORE_EXISTING);
    MetadataMBeanInfoAssembler assembler = new MetadataMBeanInfoAssembler();
    assembler.setAttributeSource(new AnnotationJmxAttributeSource());
    assembler.afterPropertiesSet();//from  w  w  w. jav  a  2s . c  om
    exporter.setAssembler(assembler);
}

From source file:org.apache.servicemix.nmr.management.ManagementAgent.java

public ManagementAgent() {
    assembler = new MetadataMBeanInfoAssembler();
    assembler.setAttributeSource(new AnnotationJmxAttributeSource());
}

From source file:co.paralleluniverse.common.spring.SpringContainerHelper.java

private static BeanDefinition getMBeanExporterBeanDefinition(String defaultDomain) {
    final AnnotationJmxAttributeSource annotationSource = new AnnotationJmxAttributeSource();

    final GenericBeanDefinition bean = new GenericBeanDefinition();
    bean.setBeanClass(MBeanExporter.class);
    MutablePropertyValues properties = new MutablePropertyValues();
    properties.add("server", ManagementFactory.getPlatformMBeanServer());
    properties.add("autodetectMode", MBeanExporter.AUTODETECT_ASSEMBLER);
    properties.add("assembler", new MetadataMBeanInfoAssembler(annotationSource));
    properties.add("namingStrategy", new MBeanNamingStrategy(annotationSource).setDefaultDomain(defaultDomain));
    bean.setPropertyValues(properties);/*from   www.j a  v a2 s  .com*/
    return bean;
}

From source file:org.apache.camel.management.JmxMBeanAssembler.java

public JmxMBeanAssembler(MBeanServer server) {
    this.server = server;
    this.assembler = new MetadataMBeanInfoAssembler();
    this.assembler.setAttributeSource(new AnnotationJmxAttributeSource());
}