Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2011-10-25 10:57:42 -0400
committerChristopher Frost2011-10-25 10:57:42 -0400
commit149985f8d9971016cbf4f47b9011b616877ca1d1 (patch)
tree906a0b7f687abd569d95b24ed27031d2a0eb34a7
parent875f850f78799efad6bc7a8c11b5b38346a48900 (diff)
downloadorg.eclipse.virgo.medic-149985f8d9971016cbf4f47b9011b616877ca1d1.tar.gz
org.eclipse.virgo.medic-149985f8d9971016cbf4f47b9011b616877ca1d1.tar.xz
org.eclipse.virgo.medic-149985f8d9971016cbf4f47b9011b616877ca1d1.zip
360646 Adding a slight change to the MBean api
-rw-r--r--org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/DumpInspector.java8
-rw-r--r--org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/FileSystemDumpInspector.java23
-rw-r--r--org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/management/FileSystemDumpInspectorTests.java7
3 files changed, 28 insertions, 10 deletions
diff --git a/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/DumpInspector.java b/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/DumpInspector.java
index e16b610..d21947a 100644
--- a/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/DumpInspector.java
+++ b/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/DumpInspector.java
@@ -24,7 +24,7 @@ import javax.management.MXBean;
public interface DumpInspector {
/**
- * A list of the available dump names
+ * An array of the available dump ids
*
* @return array of dump ids
* @throws IOException
@@ -33,13 +33,15 @@ public interface DumpInspector {
String[] getDumps() throws IOException, ParseException;
/**
- * A list of the available dump items for the given dump
+ * An array of the available dump items for the given dump with each array
+ * containing an array in the order of display name, bean to use for displaying
+ * the item (optional). When not given, this bean should be used.
*
* @param dumpId
* @return array of dump entries
* @throws IOException
*/
- String[] getDumpEntries(String dumpId) throws IOException;
+ String[][] getDumpEntries(String dumpId) throws IOException;
/**
* Return the requested dump item as an array of Strings, one per line
diff --git a/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/FileSystemDumpInspector.java b/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/FileSystemDumpInspector.java
index eadcda4..4ae85c5 100644
--- a/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/FileSystemDumpInspector.java
+++ b/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/FileSystemDumpInspector.java
@@ -15,6 +15,7 @@ import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.slf4j.Logger;
@@ -58,15 +59,29 @@ public class FileSystemDumpInspector implements DumpInspector {
}
@Override
- public String[] getDumpEntries(String dumpId) throws IOException {
+ public String[][] getDumpEntries(String dumpId) throws IOException {
if(dumpId == null){
- return new String[0];
+ return new String[0][];
}
File dumpDir = new File(getDumpDirectory(), dumpId);
if(dumpDir != null && dumpDir.exists() && dumpDir.isDirectory()){
- return FileSystemUtils.list(dumpDir, this.logger);
+ List<String> dumpItems = Arrays.asList(FileSystemUtils.list(dumpDir, this.logger));
+ if(dumpItems.contains("osgi.zip") && dumpItems.contains("region.digraph")){
+ dumpItems.add("OSGi state");
+ }
+ dumpItems.remove("osgi.zip");
+ dumpItems.remove("region.digraph");
+ String[][] result = new String[dumpItems.size()][];
+ for(int i = 0; i < dumpItems.size(); i++) {
+ if("OSGi state".equals(dumpItems.get(i))){
+ result[i] = new String[]{dumpItems.get(i), "StateDumpInspector"};
+ }else{
+ result[i] = new String[]{dumpItems.get(i), "DumpInspector"};
+ }
+ }
+ return result;
} else {
- return new String[0];
+ return new String[0][];
}
}
diff --git a/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/management/FileSystemDumpInspectorTests.java b/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/management/FileSystemDumpInspectorTests.java
index 8a6a5db..a928780 100644
--- a/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/management/FileSystemDumpInspectorTests.java
+++ b/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/management/FileSystemDumpInspectorTests.java
@@ -7,6 +7,7 @@ import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertArrayEquals;
import java.io.File;
import java.io.IOException;
@@ -57,14 +58,14 @@ public class FileSystemDumpInspectorTests {
@Test
public void testGetDumpEntries() throws IOException {
- String[] dumpEntries = fileSystemDumpInspector.getDumpEntries("testDump");
+ String[][] dumpEntries = fileSystemDumpInspector.getDumpEntries("testDump");
assertTrue(dumpEntries.length == 1);
- assertEquals("Unexpected dump found" + dumpEntries[0], "testDumpItem.txt", dumpEntries[0]);
+ assertArrayEquals("Unexpected dump found" + dumpEntries[0], new String[]{"testDumpItem.txt", "DumpInspector"}, dumpEntries[0]);
}
@Test
public void testGetDumpEntriesNotThere() throws IOException {
- String[] dumpEntries = fileSystemDumpInspector.getDumpEntries("notHere");
+ String[][] dumpEntries = fileSystemDumpInspector.getDumpEntries("notHere");
assertTrue(dumpEntries.length == 0);
}

Back to the top