ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
609
609
EMPFEHLEN
-
Hi Guys,
ich versuche eine Spring-Bean zu einer Mbean zu exportieren (Ich bin recht neu in Spring JMX)
Im Folgenden sind ein paar einfache Codeschnipsel zu sehen
ApplicationContext.xml:
<context:mbean-export/>
Die Spring-Bean welche ich zu einer Mbean exportieren möchte:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
@Component @Scope(value = "prototype") @ManagedResource(objectName = "mymbean:name=AnyMBean", description = "anyMBean", log = true, logFile = "jmx.log", currencyTimeLimit = 15, persistPolicy = "OnUpdate", persistPeriod = 200, persistLocation = "foo", persistName = "status") public class ExampleClass implements IJmxExampleClassMbean { private int age=28; @ManagedOperation(description = "Add two numbers") @ManagedOperationParameters( { @ManagedOperationParameter(name = "x", description = "The first number"), @ManagedOperationParameter(name = "y", description = "The second number") }) public int add(final int x, final int y) { return x + y; } @ManagedAttribute(description = "The Age Attribute", currencyTimeLimit = 15) // @ManagedMetric(category = "age-category", displayName = "age", description = "How old are you", metricType = MetricType.GAUGE, unit = // "years", currencyTimeLimit = 1000, persistPolicy = "OnUpdate", persistPeriod = 200) public int getAge() { LOG.info("REQUEST: HOW OLD ARE YOU?"); ArrayList<MBeanServer> findMBeanServer = MBeanServerFactory.findMBeanServer(null); Integer mBeanCount = findMBeanServer.get(0).getMBeanCount(); ObjectInstance objectInstance; Object attribute; try { objectInstance = findMBeanServer.get(0).getObjectInstance(ObjectName.getInstance("mymbean:name=GribFileJobMBean")); attribute = findMBeanServer.get(0).getAttribute(objectInstance.getObjectName(), "age"); } catch (InstanceNotFoundException e) { e.printStackTrace(); } catch (MalformedObjectNameException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } catch (AttributeNotFoundException e) { e.printStackTrace(); } catch (MBeanException e) { e.printStackTrace(); } catch (ReflectionException e) { e.printStackTrace(); } return age; } }
In der JConsole kann ich das Mbean sehen, allerdings schmeisst er bei dem Code:
findMBeanServer.get(0).getAttribute(objectInstance.getObjectName(), "age");
Das schmeisst:
javax.management.AttributeNotFoundException: getAttribute failed: ModelMBeanAttributeInfo not found for age.
Hyperic sagt das gleiche, wenn ich versuche das age Attribut als Metric darzustellen:
javax.management.AttributeNotFoundException: getAttribute failed: ModelMBeanAttributeInfo not found for age
Hat jemand Erfahrung damit ?
MfG
Ähnliche Themen
-
Spring Security NTLM & Spring Framework 3.0
Von Thomas Darimont im Forum Enterprise Java (JEE, J2EE, Spring & Co.)Antworten: 2Letzter Beitrag: 26.01.10, 12:50 -
Unterschiede Spring und Spring RCP
Von Looky im Forum JavaAntworten: 8Letzter Beitrag: 26.01.09, 08:45 -
Planung Serversoftware mit Spring als Framework, wie Spring einsetzen?
Von DarthShader im Forum Enterprise Java (JEE, J2EE, Spring & Co.)Antworten: 8Letzter Beitrag: 26.09.08, 19:05 -
DynamicProxy mit Spring.Aop aus Spring.NET
Von Thomas Darimont im Forum .NET Application und Service DesignAntworten: 0Letzter Beitrag: 27.02.08, 14:00 -
Spring One Praesentation: Introduction to Data Access with Spring.NET
Von Thomas Darimont im Forum .NET DatenverwaltungAntworten: 2Letzter Beitrag: 21.06.06, 13:42





Zitieren
Login





