Advertisement
Guest User

Untitled

a guest
Jul 11th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. wsadmin>print Help.attributes(object)
  2. Attribute Type Access
  3. name java.lang.String RO
  4. maximumSize int RW
  5. minimumSize int RW
  6. inactivityTimeout long RW
  7. growable boolean RW
  8. stats javax.management.j2ee.statistics.Stats RO
  9.  
  10. wsadmin>print Help.operations(object)
  11. Operation
  12. java.lang.String getName()
  13. int getMaximumPoolSize()
  14. void setMaximumPoolSize(int)
  15. int getMinimumPoolSize()
  16. void setMinimumPoolSize(int)
  17. long getKeepAliveTime()
  18. void setKeepAliveTime(long)
  19. boolean isGrowAsNeeded()
  20. void setGrowAsNeeded(boolean)
  21. javax.management.j2ee.statistics.Stats getStats()
  22.  
  23. JmxClient client = new JmxClient(hostName, port);
  24. Set<ObjectName> objectNames = getBeanNames()
  25. for (ObjectName name : objectNames) {
  26. MBeanAttributeInfo[] attributes = getAttributesInfo(name);
  27. MBeanOperationInfo[] operations = getOperationsInfo(name);
  28. }
  29.  
  30. MBeanServer server = ManagementFactory.getPlatformMBeanServer();
  31. Set<ObjectName> objectNames = server.queryNames(null, null);
  32. for (ObjectName name : objectNames) {
  33. MBeanInfo info = server.getMBeanInfo(name);
  34. }
  35.  
  36. String brokerName = "AMQBroker";
  37. String username = "";
  38. String password = "";
  39. String hostname = "localhost";
  40. int port = 1099;
  41.  
  42. Map<String, Object> env = new HashMap<String, Object>();
  43. if (username != null || password != null) {
  44. String[] credentials = new String[] { username, password };
  45. env.put("jmx.remote.credentials", credentials);
  46. }
  47.  
  48. JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + hostname + ":" + port + "/jmxrmi");
  49. JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
  50. MBeanServerConnection conn = jmxc.getMBeanServerConnection();
  51.  
  52. // here is example for Type=Broker, can be different like
  53. // "org.apache.activemq:BrokerName=" + brokerName + ",Type=Connection,ConnectorName=openwire,Connection=*"
  54. // "org.apache.activemq:BrokerName=" + brokerName + ",*,Type=NetworkBridge" or same for Queue, Topic, Subscription
  55. ObjectName name = new ObjectName("org.apache.activemq:BrokerName=" + brokerName + ",Type=Broker");
  56. Set<ObjectName> queryNames = conn.queryNames(name, null);
  57. // here is set with one element, but can be more depending on ObjectName query
  58. for (ObjectName objectName : queryNames) {
  59. System.out.println(objectName.getCanonicalName());
  60. // use attribute you can be interested in
  61. System.out.println(conn.getAttribute(objectName, "Slave"));
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement