@@ -51,6 +51,7 @@ public void reset(){
51
51
socketFactory = SocketFactory .getDefault ();
52
52
description = null ;
53
53
cursorFinalizerEnabled = true ;
54
+ alwaysUseMBeans = false ;
54
55
}
55
56
56
57
public MongoOptions copy () {
@@ -75,6 +76,7 @@ public MongoOptions copy() {
75
76
m .socketFactory = socketFactory ;
76
77
m .description = description ;
77
78
m .cursorFinalizerEnabled = cursorFinalizerEnabled ;
79
+ m .alwaysUseMBeans = alwaysUseMBeans ;
78
80
return m ;
79
81
}
80
82
@@ -236,7 +238,15 @@ else if (safe)
236
238
*/
237
239
public boolean cursorFinalizerEnabled ;
238
240
239
-
241
+ /**
242
+ * Sets whether JMX beans registered by the driver should always be MBeans, regardless of whether the VM is
243
+ * Java 6 or greater. If false, the driver will use MXBeans if the VM is Java 6 or greater, and use MBeans if
244
+ * the VM is Java 5.
245
+ * <p>
246
+ * Default is false.
247
+ * </p>
248
+ */
249
+ public boolean alwaysUseMBeans ;
240
250
241
251
public String toString (){
242
252
StringBuilder buf = new StringBuilder ();
@@ -258,7 +268,8 @@ public String toString(){
258
268
buf .append ( "wtimeout=" ).append ( wtimeout ).append ( ", " );
259
269
buf .append ( "fsync=" ).append ( fsync ).append ( ", " );
260
270
buf .append ( "j=" ).append (j ).append ( ", " );
261
- buf .append ( "cursorFinalizerEnabled=" ).append ( cursorFinalizerEnabled );
271
+ buf .append ( "cursorFinalizerEnabled=" ).append (cursorFinalizerEnabled ).append ( ", " );
272
+ buf .append ( "alwaysUseMBeans=" ).append (alwaysUseMBeans );
262
273
263
274
return buf .toString ();
264
275
}
@@ -568,4 +579,20 @@ public boolean isCursorFinalizerEnabled() {
568
579
public void setCursorFinalizerEnabled (final boolean cursorFinalizerEnabled ) {
569
580
this .cursorFinalizerEnabled = cursorFinalizerEnabled ;
570
581
}
582
+
583
+ /**
584
+ *
585
+ * @return true if the driver should always use MBeans, regardless of VM
586
+ */
587
+ public boolean isAlwaysUseMBeans () {
588
+ return alwaysUseMBeans ;
589
+ }
590
+
591
+ /**
592
+ *
593
+ * @param alwaysUseMBeans sets whether the driver should always use MBeans, regardless of VM
594
+ */
595
+ public void setAlwaysUseMBeans (final boolean alwaysUseMBeans ) {
596
+ this .alwaysUseMBeans = alwaysUseMBeans ;
597
+ }
571
598
}
0 commit comments