/* * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * 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.
*/
/* Creates a new instance of Basic */
@SqeDescriptorKey("CONSTRUCTOR Basic") public Basic() {
}
/* Creates a new instance of Basic */
@SqeDescriptorKey("CONSTRUCTOR Basic") public Basic(
@SqeDescriptorKey("CONSTRUCTOR PARAMETER SqeParameter") SqeParameter param) {
}
/** * Get int attribute
*/ publicint getIntAtt() { return intAtt;
}
/** * Set int attribute
*/ publicvoid setIntAtt(int value) {
intAtt = value;
}
/** * Get Integer attribute
*/ public Integer getIntegerAtt() { return integerAtt;
}
/** * Get the Descriptor used to build the NotificationInfo * of emitted notifications.
*/ public Map<String, String> getNotifDescriptorAsMapAtt() { if (notifDescriptorAsMapAtt == null) {
initNotifDescriptorAtt();
}
return notifDescriptorAsMapAtt;
}
/** * Set the Descriptor used to build the NotificationInfo * of emitted notifications. * <br>A Map<String, Object> would better fit Descriptor needs but then * it is not convertible according the MXBean specification so the MBean * registration fails. * As we plan to test our custom Descriptor finds its way into * the metadata of emitted notifications, String is good enough.
*/ publicvoid setNotifDescriptorAsMapAtt(Map<String, String> value) {
notifDescriptorAsMapAtt = new HashMap<String, String>(value);
notifDescriptorAtt = new ImmutableDescriptor(value);
}
/** * Do nothing
*/ publicvoid doNothing() { // I said NOTHING !
}
/** * Do take SqeParameter as a parameter
*/ publicvoid doWeird(SqeParameter param) {
}
/** * Returns the weather for the coming days * @param verbose <code>boolean</code> verbosity * @throws java.lang.Exception <code>storm</code> * @return <code>ObjectName</code>
*/ public Weather getWeather(boolean verbose) throws java.lang.Exception { return Weather.SUNNY;
}
// Starting here are the 4 methods of MBeanRegistration interface. // We use that to grab the ObjectName the MBean is registered with. // public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { // Grab a reference on the MBeanServer we're registered in.
mbs = server; // Compute the name we're registered with. if (name != null) {
mbeanName = name; return name;
} else {
mbeanName = new ObjectName("sqe:type=" + Basic.class.getName()); return mbeanName;
}
}
publicvoid postRegister(Boolean registrationDone) { // Do nothing
}
publicvoid preDeregister() throws Exception { // Do nothing
}
publicvoid postDeregister() { // Do nothing
}
/** * Send one Notification of the provided notifType type.
*/ publicvoid sendNotification(String notifType) {
Notification notification = null;
if (notifType.equals(NOTIF_TYPE_0)) {
notification = new Notification(NOTIF_TYPE_0,
mbeanName,
seqNumber,
NOTIFICATION_MESSAGE);
} elseif (notifType.equals(NOTIF_TYPE_1)) {
notification = new SqeNotification(NOTIF_TYPE_1,
mbeanName,
seqNumber,
NOTIFICATION_MESSAGE);
}
/** * That method starts a set of threads, each thread sends a given number of * notifications. * The number of threads can be set via the attribute numOfNotificationSenders. * The number of notification sent by each thread can be set via * the attribute numOfNotificationSenderLoops. * Depending on the parameter customNotification we send either custom * notification(s) or MBeanServer registration and unregistration notification(s). * When customNotification=true the total number of notification(s) sent is * (numOfNotificationSenders * numOfNotificationSenderLoops). They are * sequentially of type NOTIF_TYPE_0 then NOTIF_TYPE_1 and so on. * * When customNotification=false the total number of notification(s) sent is * (numOfNotificationSenders * numOfNotificationSenderLoops) registration * notification(s) * + * (numOfNotificationSenders * numOfNotificationSenderLoops) unregistration * notification(s) * * @throws java.lang.Exception
*/ publicvoid sendNotificationWave(boolean customNotification) throws
Exception { // Build the set of notification sender.
Collection<Callable<Integer>> tasks = new HashSet<Callable<Integer>>(numOfNotificationSenders);
for (int i = 1; i <= numOfNotificationSenders; i++) {
tasks.add(new NotifSender(numOfNotificationSenderLoops,
customNotification, i));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.