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