001: /*
002: * Copyright (C) The MX4J Contributors.
003: * All rights reserved.
004: *
005: * This software is distributed under the terms of the MX4J License version 1.0.
006: * See the terms of the MX4J License in the documentation provided with this software.
007: */
008:
009: package javax.management.timer;
010:
011: import java.util.Date;
012: import java.util.Vector;
013: import javax.management.InstanceNotFoundException;
014:
015: /**
016: * Management interface for the {@link Timer} class.
017: *
018: * @version $Revision: 1.6 $
019: */
020: public interface TimerMBean {
021: /**
022: * Shortcut for {@link #addNotification(String,String,Object,Date,long,long,boolean) addNotification(type, message, userData, date, 0L, 0L, false)}
023: */
024: public Integer addNotification(String type, String message,
025: Object userData, Date date) throws IllegalArgumentException;
026:
027: /**
028: * Shortcut for {@link #addNotification(String,String,Object,Date,long,long,boolean) addNotification(type, message, userData, date, period, 0L, false)}
029: */
030: public Integer addNotification(String type, String message,
031: Object userData, Date date, long period)
032: throws IllegalArgumentException;
033:
034: /**
035: * Shortcut for {@link #addNotification(String,String,Object,Date,long,long,boolean) addNotification(type, message, userData, date, period, occurences, false)}
036: */
037: public Integer addNotification(String type, String message,
038: Object userData, Date date, long period, long occurences)
039: throws IllegalArgumentException;
040:
041: /**
042: * Adds a notification to this Timer. <br>
043: * If the date is before the current date, and the notification is one-shot, it will be delivered immediately.
044: *
045: * @param type The type of the notification
046: * @param message The message of the notification
047: * @param userData The custom user data of the notification
048: * @param date The date at which the notification should be delivered the first time
049: * @param period The period of time between notifications delivers
050: * @param occurences The number of occurrences the notification should be delivered
051: * @param fixedRate True if the periodic notification should be sent at fixed rate, false if should be sent at fixed delay
052: * @return The identifier for the notification
053: * @throws IllegalArgumentException If some of the parameters has illegal value
054: */
055: public Integer addNotification(String type, String message,
056: Object userData, Date date, long period, long occurences,
057: boolean fixedRate) throws IllegalArgumentException;
058:
059: /**
060: * Returns all identifiers for notifications added to this Timer
061: */
062: public Vector getAllNotificationIDs();
063:
064: /**
065: * Returns the date for the notification with the given identifier
066: *
067: * @param id The notification identifier
068: */
069: public Date getDate(Integer id);
070:
071: /**
072: * Returns whether the periodic notification with the given identifier is delivered at fixed rate or not
073: *
074: * @param id The notification identifier
075: */
076: public Boolean getFixedRate(Integer id);
077:
078: /**
079: * Returns the number of notifications added to this Timer
080: */
081: public int getNbNotifications();
082:
083: /**
084: * Returns the number of times the notification with the given identifier is delivered.
085: *
086: * @param id The notification identifier
087: */
088: public Long getNbOccurences(Integer id);
089:
090: /**
091: * Returns the identifiers of the notifications with the given type
092: *
093: * @param type The notification type
094: */
095: public Vector getNotificationIDs(String type);
096:
097: /**
098: * Returns the message of the notification with the given identifier
099: *
100: * @param id The notification identifier
101: */
102: public String getNotificationMessage(Integer id);
103:
104: /**
105: * Returns the type of the notification with the given identifier
106: *
107: * @param id The notification identifier
108: */
109: public String getNotificationType(Integer id);
110:
111: /**
112: * Returns the user data of the notification with the given identifier
113: *
114: * @param id The notification identifier
115: */
116: public Object getNotificationUserData(Integer id);
117:
118: /**
119: * Returns the period between the deliver of two notifications for the notification with the given identifier
120: *
121: * @param id The notification identifier
122: */
123: public Long getPeriod(Integer id);
124:
125: /**
126: * Returns whether this Timer delivers notifications that occurred while it has been stopped
127: *
128: * @see #setSendPastNotifications
129: */
130: public boolean getSendPastNotifications();
131:
132: /**
133: * Returns whether this Timer delivers notifications or not.
134: *
135: * @see #start
136: * @see #stop
137: */
138: public boolean isActive();
139:
140: /**
141: * Returns whether this Timer has notifications to deliver.
142: */
143: public boolean isEmpty();
144:
145: /**
146: * Removes all notifications from this Timer
147: */
148: public void removeAllNotifications();
149:
150: /**
151: * Removes all notifications with the given type
152: *
153: * @param type The type of the notifications to be removed
154: * @throws InstanceNotFoundException If no notifications with the given type are present
155: */
156: public void removeNotifications(String type)
157: throws InstanceNotFoundException;
158:
159: /**
160: * Removes the notification with the given identifier
161: *
162: * @param id The identifier of the notification to be removed
163: * @throws InstanceNotFoundException If no notification with the given identifier is present
164: */
165: public void removeNotification(Integer id)
166: throws InstanceNotFoundException;
167:
168: /**
169: * Sets whether this Timer delivers notifications that occurred while it has been stopped
170: *
171: * @see #getSendPastNotifications
172: */
173: public void setSendPastNotifications(boolean value);
174:
175: /**
176: * Starts this Timer. <br>
177: * Only when a Timer is started it delivers notifications.
178: * If {@link #getSendPastNotifications} returns true, this Timer sends notifications that were waiting
179: * to be delivered, otherwise it updates the notification times to the next deliver.
180: *
181: * @see #stop
182: */
183: public void start();
184:
185: /**
186: * Stops this Timer. <br>
187: *
188: * @see #start
189: */
190: public void stop();
191: }
|