Example usage for org.springframework.jmx.export.naming MetadataNamingStrategy setAttributeSource

List of usage examples for org.springframework.jmx.export.naming MetadataNamingStrategy setAttributeSource

Introduction

In this page you can find the example usage for org.springframework.jmx.export.naming MetadataNamingStrategy setAttributeSource.

Prototype

public void setAttributeSource(JmxAttributeSource attributeSource) 

Source Link

Document

Set the implementation of the JmxAttributeSource interface to use when reading the source-level metadata.

Usage

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

@Bean
public MetadataNamingStrategy strategy() {
    MetadataNamingStrategy strategy = new MetadataNamingStrategy();
    strategy.setAttributeSource(attributeSource());
    return strategy;
}

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);//from www.jav a  2s. co  m
    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.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 a  v  a  2 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"));
}