PersistentMBean.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* PersistentMBean.java -- Interface for beans that should persist.
  2. Copyright (C) 2007 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package javax.management;
  32. /**
  33. * Beans may implement this interface in order to become
  34. * persistent. The {@link #load()} method should be
  35. * called on construction in order to reload the stored
  36. * state. The {@link #store()} method should be called
  37. * sometime during the bean's lifetime in order to create
  38. * a persistent copy of the bean's instance data. This
  39. * method may also be called by the {@link MBeanServer}
  40. * as a result of the {@link Descriptor} of an
  41. * {@link javax.management.modelmbean.ModelMBean}.
  42. *
  43. * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
  44. * @since 1.5
  45. */
  46. public interface PersistentMBean
  47. {
  48. /**
  49. * Instantiates the bean with the data previously stored
  50. * using a call to {@link #store()}. The data stored can
  51. * include values held by attributes as well as those returned
  52. * by operations. This method should be called during
  53. * construction or initialisation of the bean, before
  54. * it becomes registered with an {@link MBeanServer}.
  55. *
  56. * @throws MBeanException if persistence is not supported,
  57. * or another exception is thrown
  58. * (which this then wraps).
  59. * @throws RuntimeOperationsException if the persistence
  60. * mechanism throws an
  61. * exception.
  62. * @throws InstanceNotFoundException if the bean can not
  63. * be found in the
  64. * persistent store.
  65. */
  66. void load()
  67. throws MBeanException, RuntimeOperationsException,
  68. InstanceNotFoundException;
  69. /**
  70. * <p>
  71. * Captures the current state of the bean and stores it
  72. * for future retrieval by the {@link #load()} method.
  73. * The data stored can include values held by attributes
  74. * as well as those returned by operations.
  75. * </p>
  76. * <p>
  77. * Whether the state is stored or not depends on the
  78. * <code>persistPolicy</code> field of the MBean/attribute
  79. * descriptor. The state should be stored if the policy
  80. * is set to any of the following:
  81. * </p>
  82. * <ul>
  83. * <li><code>always</code></li>
  84. * <li><code>onTimer</code> and <code>now</code> is
  85. * greater than or equal to <code>lastPersistTime +
  86. * persistPeriod</code>.</li>
  87. * <li><code>noMoreOftenThan</code> and <code>now</code> is
  88. * greater than or equal to <code>lastPersistTime +
  89. * persistPeriod</code>.</li>
  90. * <li>onUnregister</li>
  91. * </ul>
  92. * <p>If the policy is set to any of the following, the state
  93. * should not be stored:</p>
  94. * <ul>
  95. * <li><code>never</code></li>
  96. * <li><code>onUpdate</code></li>
  97. * <li><code>onTimer</code> and <code>now</code> is
  98. * less than <code>lastPersistTime + persistPeriod</code>.
  99. * </li>
  100. * </ul>
  101. *
  102. * @throws MBeanException if persistence is not supported,
  103. * or another exception is thrown
  104. * (which this then wraps).
  105. * @throws RuntimeOperationsException if the persistence
  106. * mechanism throws an
  107. * exception.
  108. * @throws InstanceNotFoundException if the persistent
  109. * store can not be found
  110. * or accessed.
  111. */
  112. void store()
  113. throws MBeanException, RuntimeOperationsException,
  114. InstanceNotFoundException;
  115. }