# HG changeset patch
# User swamyv
# Date 1218044971 25200
# Node ID a9abec8db74d493daa6cebbbf62bcd916dabecd8
# Parent c3c2f8023df15467615940d249735de41cc8cec6# Parent 2cc4873fa29ff133d124787321ff966f2c875e54
Merge
diff -r c3c2f8023df1 -r a9abec8db74d jdk/src/share/classes/javax/management/MXBean.java
--- a/jdk/src/share/classes/javax/management/MXBean.java Wed Aug 06 10:24:33 2008 -0700
+++ b/jdk/src/share/classes/javax/management/MXBean.java Wed Aug 06 10:49:31 2008 -0700
@@ -1081,9 +1081,10 @@
MXBean is determined as follows.
- If an {@link JMX.MBeanOptions} argument is supplied to
+
If a {@link JMX.MBeanOptions} argument is supplied to
the {@link StandardMBean} constructor that makes an MXBean,
- or to the {@link JMX#newMXBeanProxy JMX.newMXBeanProxy}
+ or to the {@link JMX#newMBeanProxy(MBeanServerConnection,
+ ObjectName, Class, JMX.MBeanOptions) JMX.newMBeanProxy}
method, and the {@code MBeanOptions} object defines a non-null
{@code MXBeanMappingFactory}, then that is the value of
f
.
diff -r c3c2f8023df1 -r a9abec8db74d jdk/src/share/classes/javax/management/openmbean/MXBeanMapping.java
--- a/jdk/src/share/classes/javax/management/openmbean/MXBeanMapping.java Wed Aug 06 10:24:33 2008 -0700
+++ b/jdk/src/share/classes/javax/management/openmbean/MXBeanMapping.java Wed Aug 06 10:49:31 2008 -0700
@@ -108,6 +108,9 @@
* If we are unable to modify the {@code MyLinkedList} class,
* we can define an {@link MXBeanMappingFactory}. See the documentation
* of that class for further details.
+ *
+ * @see MXBean specification, section
+ * "Custom MXBean type mappings"
*/
public abstract class MXBeanMapping {
private final Type javaType;
diff -r c3c2f8023df1 -r a9abec8db74d jdk/src/share/classes/javax/management/openmbean/MXBeanMappingFactory.java
--- a/jdk/src/share/classes/javax/management/openmbean/MXBeanMappingFactory.java Wed Aug 06 10:24:33 2008 -0700
+++ b/jdk/src/share/classes/javax/management/openmbean/MXBeanMappingFactory.java Wed Aug 06 10:49:31 2008 -0700
@@ -82,6 +82,9 @@
* appears in, or we can supply the factory to a {@link
* javax.management.StandardMBean StandardMBean} constructor or MXBean
* proxy.
+ *
+ * @see MXBean specification, section
+ * "Custom MXBean type mappings"
*/
public abstract class MXBeanMappingFactory {
/**
diff -r c3c2f8023df1 -r a9abec8db74d jdk/test/javax/management/eventService/SharingThreadTest.java
--- a/jdk/test/javax/management/eventService/SharingThreadTest.java Wed Aug 06 10:24:33 2008 -0700
+++ b/jdk/test/javax/management/eventService/SharingThreadTest.java Wed Aug 06 10:49:31 2008 -0700
@@ -32,8 +32,6 @@
*/
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
@@ -60,23 +58,22 @@
public class SharingThreadTest {
private static MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
- private static List notifList = new ArrayList();
private static ObjectName emitter;
private static NotificationEmitter emitterImpl;
private static JMXServiceURL url;
private static JMXConnectorServer server;
- private static JMXConnector conn;
private static int toSend = 10;
- private static long sequenceNumber = 0;
private static final long bigWaiting = 6000;
private static int counter = 0;
private static int jobs = 10;
private static int endedJobs = 0;
+ private static volatile String failure;
+
private static Executor sharedExecutor = new ThreadPoolExecutor(0, 1, 1000,
- TimeUnit.MILLISECONDS, new ArrayBlockingQueue(jobs));
+ TimeUnit.MILLISECONDS, new ArrayBlockingQueue(jobs));
//Executors.newFixedThreadPool(1);
public static void main(String[] args) throws Exception {
@@ -93,7 +90,7 @@
EventClientDelegateMBean.OBJECT_NAME);
sharedExecutor = new ThreadPoolExecutor(1, 1, 1000,
- TimeUnit.MILLISECONDS, new ArrayBlockingQueue(jobs));
+ TimeUnit.MILLISECONDS, new ArrayBlockingQueue(jobs));
}
emitter = new ObjectName("Default:name=NotificationEmitter");
@@ -133,35 +130,16 @@
noise.setDaemon(true);
noise.start();
- Thread[] threads = new Thread[jobs];
try {
for (String type: types) {
System.out.println("\n\n>>> Testing "+type+" on "+url+" ...");
- newConn();
- for (int i=0; i>> Testing "+type+" on "+url+" ... done");
}
-
- // to wait
- long toWait = bigWaiting*jobs;
- long stopTime = System.currentTimeMillis() + toWait;
-
- synchronized(SharingThreadTest.class) {
- while (endedJobs < jobs && toWait > 0) {
- SharingThreadTest.class.wait(toWait);
- toWait = stopTime - System.currentTimeMillis();
- }
- }
-
- if (endedJobs != jobs) {
- throw new RuntimeException("Need to set bigger waiting timeout?");
- }
-
- endedJobs = 0;
- conn.close();
- System.out.println(">>> Testing "+type+" on "+url+" ... done");
}
} finally {
server.stop();
@@ -169,13 +147,40 @@
}
}
+ private static void testType(String type, JMXConnector conn) throws Exception {
+ Thread[] threads = new Thread[jobs];
+ for (int i=0; i 0 && failure == null) {
+ SharingThreadTest.class.wait(toWait);
+ toWait = stopTime - System.currentTimeMillis();
+ }
+ }
+
+ if (endedJobs != jobs && failure == null) {
+ throw new RuntimeException("Need to set bigger waiting timeout?");
+ }
+
+ endedJobs = 0;
+ }
+
public static class Job implements Runnable {
- public Job(String type) {
+ public Job(String type, JMXConnector conn) {
this.type = type;
+ this.conn = conn;
}
public void run() {
try {
- test(type);
+ test(type, conn);
synchronized(SharingThreadTest.class) {
endedJobs++;
@@ -184,6 +189,7 @@
}
}
} catch (RuntimeException re) {
+ re.printStackTrace(System.out);
throw re;
} catch (Exception e) {
throw new RuntimeException(e);
@@ -191,16 +197,17 @@
}
private final String type;
+ private final JMXConnector conn;
}
- private static void test(String type) throws Exception {
+ private static void test(String type, JMXConnector conn) throws Exception {
String id = getId();
Listener listener = new Listener(id);
Filter filter = new Filter(id);
//newConn();
- EventClient ec = newEventClient(type);
+ EventClient ec = newEventClient(type, conn);
System.out.println(">>> ("+id+") To receive notifications "+toSend);
ec.addNotificationListener(emitter,
@@ -213,8 +220,7 @@
+toSend+", but got: "+listener.received);
}
- // not close the EventClient to keep using thread
- //ec.close();
+ ec.close();
}
//--------------------------
@@ -232,16 +238,16 @@
System.exit(1);
}
System.out.println("("+id+") received "+notif.getSequenceNumber());
- synchronized (notifList) {
+ synchronized (this) {
received++;
if (sequenceNB < 0) {
sequenceNB = notif.getSequenceNumber();
} else if(++sequenceNB != notif.getSequenceNumber()) {
- throw new RuntimeException("Wrong sequence number, expecte: "
+ fail("(" + id + ") Wrong sequence number, expected: "
+sequenceNB+", but got: "+notif.getSequenceNumber());
}
- if (received >= toSend) {
+ if (received >= toSend || failure != null) {
this.notify();
}
}
@@ -251,20 +257,13 @@
long toWait = timeout;
long stopTime = System.currentTimeMillis() + timeout;
synchronized(this) {
- while (received < nb && toWait > 0) {
+ while (received < nb && toWait > 0 && failure == null) {
this.wait(toWait);
toWait = stopTime - System.currentTimeMillis();
}
}
}
- public void clear() {
- synchronized(this) {
- received = 0;
- sequenceNB = -1;
- }
- }
-
private String id;
private int received = 0;
@@ -282,11 +281,6 @@
private String id;
}
- private static NotificationListener dummyListener = new NotificationListener() {
- public void handleNotification(Notification notif, Object handback) {
- }
- };
-
public static class NotificationEmitter extends NotificationBroadcasterSupport
implements NotificationEmitterMBean {
@@ -309,6 +303,7 @@
if (userData != null) {
System.out.println(">>> ("+userData+") sending "+nb);
}
+ long sequenceNumber = 0;
for (int i = 0; i