2
2
3
3
import java .io .File ;
4
4
import java .io .IOException ;
5
- import java .io .InputStream ;
6
- import java .lang .management .ManagementFactory ;
7
5
import java .lang .reflect .Array ;
8
6
import java .rmi .UnmarshalException ;
9
7
import java .util .ArrayList ;
10
8
import java .util .HashMap ;
11
- import java .util .HashSet ;
12
9
import java .util .List ;
13
10
import java .util .Map ;
14
11
import java .util .Map .Entry ;
22
19
import javax .management .AttributeList ;
23
20
import javax .management .MBeanAttributeInfo ;
24
21
import javax .management .MBeanInfo ;
25
- import javax .management .MBeanServer ;
26
22
import javax .management .MBeanServerConnection ;
27
23
import javax .management .ObjectInstance ;
28
24
import javax .management .ObjectName ;
@@ -61,7 +57,7 @@ public class JmxUtils {
61
57
62
58
private static final Logger log = LoggerFactory .getLogger (JmxUtils .class );
63
59
64
- /**
60
+ /**
65
61
* Merges two lists of servers (and their queries). Based on the equality of both sets of objects.
66
62
* Public for testing purposes.
67
63
*/
@@ -335,10 +331,6 @@ private static void runOutputWritersForQuery(Query query) throws Exception {
335
331
* Helper method for connecting to a Server. You need to close the resulting connection.
336
332
*/
337
333
public static JMXConnector getServerConnection (Server server ) throws Exception {
338
- if (server .isLocal ()) {
339
- MBeanServer mbeanServer = server .getLocalMBeanServer ();
340
- return new LocalJMXConnector (mbeanServer );
341
- }
342
334
JMXServiceURL url = new JMXServiceURL (server .getUrl ());
343
335
344
336
if (server .getProtocolProviderPackages () != null && server .getProtocolProviderPackages ().contains ("weblogic" ))
@@ -348,7 +340,7 @@ public static JMXConnector getServerConnection(Server server) throws Exception {
348
340
349
341
}
350
342
351
- /**
343
+ /**
352
344
* Generates the proper username/password environment for JMX connections.
353
345
*/
354
346
public static Map <String , String > getWebLogicEnvironment (Server server ) {
@@ -491,17 +483,6 @@ public static JmxProcess getJmxProcess(File file) throws JsonParseException, Jso
491
483
return jmx ;
492
484
}
493
485
494
- /**
495
- * Uses jackson to load json configuration from a File into a full object
496
- * tree representation of that json.
497
- */
498
- public static JmxProcess getJmxProcess (String name , InputStream in ) throws JsonParseException , JsonMappingException , IOException {
499
- ObjectMapper mapper = new ObjectMapper ();
500
- JmxProcess jmx = mapper .readValue (in , JmxProcess .class );
501
- jmx .setName (name );
502
- return jmx ;
503
- }
504
-
505
486
/**
506
487
* Useful for figuring out if an Object is a number.
507
488
*/
@@ -659,7 +640,7 @@ public static String getKeyString2(Query query, Result result, Entry<String, Obj
659
640
}
660
641
661
642
662
- /**
643
+ /**
663
644
* Replaces all . with _ and removes all spaces and double/single quotes.
664
645
*/
665
646
public static String cleanupStr (String name ) {
@@ -698,28 +679,30 @@ public static String getConcatedTypeNameValues(List<String> typeNames, String ty
698
679
}
699
680
700
681
701
- /**
702
- * Given a typeName string, get the first match from the typeNames setting.
703
- * In other words, suppose you have:
704
- *
705
- * typeName=name=PS Eden Space,type=MemoryPool
706
- *
707
- * If you addTypeName("name"), then it'll retrieve 'PS Eden Space' from the string
708
- */
709
- public static String getConcatedTypeNameValues (Query query , List <String > typeNames , String typeName ) {
710
- Set <String > queryTypeNames = query .getTypeNames ();
711
- if (queryTypeNames != null && queryTypeNames .size () > 0 ) {
712
- List <String > allNames = new ArrayList <String >(queryTypeNames );
713
- for (String name : typeNames ) {
714
- if (!allNames .contains (name )) {
715
- allNames .add (name );
716
- }
717
- }
718
- return getConcatedTypeNameValues (allNames , typeName );
719
- } else {
720
- return getConcatedTypeNameValues (typeNames , typeName );
721
- }
722
- }
682
+ /**
683
+ * Given a typeName string, get the first match from the typeNames setting.
684
+ * In other words, suppose you have:
685
+ *
686
+ * typeName=name=PS Eden Space,type=MemoryPool
687
+ *
688
+ * If you addTypeName("name"), then it'll retrieve 'PS Eden Space' from the
689
+ * string
690
+ */
691
+ public static String getConcatedTypeNameValues (Query query , List <String > typeNames , String typeName ) {
692
+ Set <String > queryTypeNames = query .getTypeNames ();
693
+ if (queryTypeNames != null && queryTypeNames .size () > 0 ) {
694
+ List <String > allNames = new ArrayList <String >(queryTypeNames );
695
+ for (String name : typeNames ) {
696
+ if (!allNames .contains (name )) {
697
+ allNames .add (name );
698
+ }
699
+ }
700
+ return getConcatedTypeNameValues (allNames , typeName );
701
+ } else {
702
+ return getConcatedTypeNameValues (typeNames , typeName );
703
+ }
704
+ }
705
+
723
706
/** */
724
707
private static String getTypeNameValue (String typeName , String [] tokens ) {
725
708
boolean foundIt = false ;
0 commit comments