PageRenderTime 271ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/core/src/main/java/org/javasimon/jmx/SimonInfo.java

http://javasimon.googlecode.com/
Java | 75 lines | 20 code | 8 blank | 47 comment | 0 complexity | 06659cd96da02ecaa6010566c487448d MD5 | raw file
Possible License(s): LGPL-2.1
  1. package org.javasimon.jmx;
  2. import java.beans.ConstructorProperties;
  3. /**
  4. * Value object for retrieving Simon name and type info via Simon MXBean ({@link SimonMXBean}).
  5. * This value object make possible to retrieve list of all instantiated Simons together with
  6. * their types, so no multiple roundtrips are needed.
  7. * <p>
  8. * Example: Following example shows usage of SimonInfo object to find out Simon type through jmx.
  9. * <pre>
  10. * System.out.println("List of stopwatch Simons:");
  11. * for (SimonInfo si : simon.getSimonInfos()) {
  12. * if (si.getType().equals(SimonInfo.STOPWATCH)) {
  13. * System.out.println(" " + si.getName());
  14. * }
  15. * }</pre>
  16. *
  17. * @author Radovan Sninsky
  18. * @author <a href="mailto:virgo47@gmail.com">Richard "Virgo" Richter</a>
  19. * @see SimonMXBean#getSimonInfos
  20. * @since 2.0
  21. */
  22. public final class SimonInfo {
  23. /**
  24. * Type identifier for unknown Simon.
  25. */
  26. public static final String UNKNOWN = "Unknown";
  27. /**
  28. * Type identifier for Stopwatch.
  29. */
  30. public static final String STOPWATCH = "Stopwatch";
  31. /**
  32. * Type identifier for Counter.
  33. */
  34. public static final String COUNTER = "Counter";
  35. private String name;
  36. private String type;
  37. /**
  38. * Class constructor due to JMX requirements.
  39. *
  40. * @param name Simon name
  41. * @param type Simon type ({@code 'stopwatch'} or {@code 'counter'})
  42. */
  43. @ConstructorProperties({"name", "type"})
  44. public SimonInfo(String name, String type) {
  45. this.name = name;
  46. this.type = type;
  47. }
  48. /**
  49. * Returns fully hierarchical name of Simon.
  50. *
  51. * @return Simon name
  52. */
  53. public String getName() {
  54. return name;
  55. }
  56. /**
  57. * Returns Simon type, either {@code 'stopwatch'} or {@code 'counter'} strings.
  58. *
  59. * @return Simon type
  60. * @see org.javasimon.jmx.SimonInfo#UNKNOWN
  61. * @see org.javasimon.jmx.SimonInfo#STOPWATCH
  62. * @see org.javasimon.jmx.SimonInfo#COUNTER
  63. */
  64. public String getType() {
  65. return type;
  66. }
  67. }