/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Defines a monitor MBean designed to observe the values of a string
* attribute.
* <P>
* A string monitor sends notifications as follows:
* <UL>
* <LI> if the attribute value matches the string to compare value,
* a {@link MonitorNotification#STRING_TO_COMPARE_VALUE_MATCHED
* match notification} is sent.
* The notify match flag must be set to <CODE>true</CODE>.
* <BR>Subsequent matchings of the string to compare values do not
* cause further notifications unless
* the attribute value differs from the string to compare value.
* <LI> if the attribute value differs from the string to compare value,
* a {@link MonitorNotification#STRING_TO_COMPARE_VALUE_DIFFERED
* differ notification} is sent.
* The notify differ flag must be set to <CODE>true</CODE>.
* <BR>Subsequent differences from the string to compare value do
* not cause further notifications unless
* the attribute value matches the string to compare value.
* </UL>
*
*
* @since 1.5
*/
/*
* ------------------------------------------
* PACKAGE CLASSES
* ------------------------------------------
*/
super(observedObject);
}
public final synchronized int getStatus() {
return status;
}
}
private int status;
}
/*
* ------------------------------------------
* PRIVATE VARIABLES
* ------------------------------------------
*/
/**
* String to compare with the observed attribute.
* <BR>The default value is an empty character sequence.
*/
/**
* Flag indicating if the string monitor notifies when matching
* the string to compare.
* <BR>The default value is set to <CODE>false</CODE>.
*/
private boolean notifyMatch = false;
/**
* Flag indicating if the string monitor notifies when differing
* from the string to compare.
* <BR>The default value is set to <CODE>false</CODE>.
*/
private boolean notifyDiffer = false;
};
"javax.management.monitor.MonitorNotification",
"Notifications sent by the StringMonitor MBean")
};
//
/*
* ------------------------------------------
* CONSTRUCTORS
* ------------------------------------------
*/
/**
* Default constructor.
*/
public StringMonitor() {
}
/*
* ------------------------------------------
* PUBLIC METHODS
* ------------------------------------------
*/
/**
* Starts the string monitor.
*/
public synchronized void start() {
if (isActive()) {
"start", "the monitor is already active");
return;
}
// Reset values.
//
for (ObservedObject o : observedObjects) {
final StringMonitorObservedObject smo =
}
doStart();
}
/**
* Stops the string monitor.
*/
public synchronized void stop() {
doStop();
}
// GETTERS AND SETTERS
//--------------------
/**
* Gets the derived gauge of the specified object, if this object is
* contained in the set of observed MBeans, or <code>null</code> otherwise.
*
* @param object the name of the MBean whose derived gauge is required.
*
* @return The derived gauge of the specified object.
*
*/
}
/**
* Gets the derived gauge timestamp of the specified object, if
* this object is contained in the set of observed MBeans, or
* <code>0</code> otherwise.
*
* @param object the name of the object whose derived gauge
* timestamp is to be returned.
*
* @return The derived gauge timestamp of the specified object.
*
*/
return super.getDerivedGaugeTimeStamp(object);
}
/**
* Returns the derived gauge of the first object in the set of
* observed MBeans.
*
* @return The derived gauge.
*
* @deprecated As of JMX 1.2, replaced by
* {@link #getDerivedGauge(ObjectName)}
*/
if (observedObjects.isEmpty()) {
return null;
} else {
}
}
/**
* Gets the derived gauge timestamp of the first object in the set
* of observed MBeans.
*
* @return The derived gauge timestamp.
*
* @deprecated As of JMX 1.2, replaced by
* {@link #getDerivedGaugeTimeStamp(ObjectName)}
*/
public synchronized long getDerivedGaugeTimeStamp() {
if (observedObjects.isEmpty()) {
return 0;
} else {
}
}
/**
* Gets the string to compare with the observed attribute common
* to all observed MBeans.
*
* @return The string value.
*
* @see #setStringToCompare
*/
return stringToCompare;
}
/**
* Sets the string to compare with the observed attribute common
* to all observed MBeans.
*
* @param value The string value.
*
* @exception IllegalArgumentException The specified
* string to compare is null.
*
* @see #getStringToCompare
*/
throws IllegalArgumentException {
throw new IllegalArgumentException("Null string to compare");
}
return;
// Reset values.
//
for (ObservedObject o : observedObjects) {
final StringMonitorObservedObject smo =
}
}
/**
* all observed MBeans.
*
* @return <CODE>true</CODE> if the string monitor notifies when
* matching the string to compare, <CODE>false</CODE> otherwise.
*
* @see #setNotifyMatch
*/
public synchronized boolean getNotifyMatch() {
return notifyMatch;
}
/**
* all observed MBeans.
*
*
* @see #getNotifyMatch
*/
if (notifyMatch == value)
return;
notifyMatch = value;
}
/**
* all observed MBeans.
*
* @return <CODE>true</CODE> if the string monitor notifies when
* differing from the string to compare, <CODE>false</CODE> otherwise.
*
* @see #setNotifyDiffer
*/
public synchronized boolean getNotifyDiffer() {
return notifyDiffer;
}
/**
* all observed MBeans.
*
*
* @see #getNotifyDiffer
*/
if (notifyDiffer == value)
return;
}
/**
* Returns a <CODE>NotificationInfo</CODE> object containing the name of
* the Java class of the notification and the notification types sent by
* the string monitor.
*/
return notifsInfo.clone();
}
/*
* ------------------------------------------
* PACKAGE METHODS
* ------------------------------------------
*/
/**
* Factory method for ObservedObject creation.
*
* @since 1.6
*/
final StringMonitorObservedObject smo =
return smo;
}
/**
* Check that the type of the supplied observed attribute
* value is one of the value types supported by this monitor.
*/
Comparable<?> value) {
// Check that the observed attribute is of type "String".
//
return true;
}
return false;
}
if (o == null)
return;
// Reset values.
//
}
Comparable<?> value) {
final StringMonitorObservedObject o =
if (o == null)
return null;
// Send matching notification if notifyMatch is true.
// Send differing notification if notifyDiffer is true.
//
if (o.getStatus() == MATCHING_OR_DIFFERING) {
if (notifyMatch) {
msg = "";
}
} else {
if (notifyDiffer) {
msg = "";
}
}
} else {
if (notifyMatch) {
msg = "";
}
}
if (notifyDiffer) {
msg = "";
}
}
}
}
return new MonitorNotification(type,
this,
0,
0,
msg,
null,
null,
null,
trigger);
}
}