You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2013/11/22 14:46:17 UTC

svn commit: r1544536 - in /karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core: DiagnosticDumpMBean.java internal/DiagnosticDump.java

Author: jbonofre
Date: Fri Nov 22 13:46:17 2013
New Revision: 1544536

URL: http://svn.apache.org/r1544536
Log:
[KARAF-2264] Wrap exceptions in MBeanException in DiagnosticMBean

Modified:
    karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DiagnosticDumpMBean.java
    karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/internal/DiagnosticDump.java

Modified: karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DiagnosticDumpMBean.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DiagnosticDumpMBean.java?rev=1544536&r1=1544535&r2=1544536&view=diff
==============================================================================
--- karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DiagnosticDumpMBean.java (original)
+++ karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DiagnosticDumpMBean.java Fri Nov 22 13:46:17 2013
@@ -15,6 +15,8 @@
  */
 package org.apache.karaf.diagnostic.core;
 
+import javax.management.MBeanException;
+
 /**
  * Diagnostic MBean which allows to create dumps over JMX.
  */
@@ -26,7 +28,7 @@ public interface DiagnosticDumpMBean {
      * @param name Name of the dump.
      * @throws Exception In case of any problems.
      */
-    void createDump(String name) throws Exception;
+    void createDump(String name) throws MBeanException;
 
     /**
      * Create dump with directory switch and name.
@@ -35,6 +37,6 @@ public interface DiagnosticDumpMBean {
      * @param name Name of the dump.
      * @throws Exception In case of any problems.
      */
-    void createDump(boolean directory, String name) throws Exception;
+    void createDump(boolean directory, String name) throws MBeanException;
 
 }

Modified: karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/internal/DiagnosticDump.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/internal/DiagnosticDump.java?rev=1544536&r1=1544535&r2=1544536&view=diff
==============================================================================
--- karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/internal/DiagnosticDump.java (original)
+++ karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/internal/DiagnosticDump.java Fri Nov 22 13:46:17 2013
@@ -16,6 +16,7 @@ package org.apache.karaf.diagnostic.core
 import java.io.File;
 import java.util.List;
 
+import javax.management.MBeanException;
 import javax.management.NotCompliantMBeanException;
 import javax.management.StandardMBean;
 
@@ -28,8 +29,7 @@ import org.apache.karaf.diagnostic.core.
 /**
  * Implementation of diagnostic MBean.
  */
-public class DiagnosticDump extends StandardMBean implements 
-    DiagnosticDumpMBean {
+public class DiagnosticDump extends StandardMBean implements DiagnosticDumpMBean {
 
     /**
      * Dump providers.
@@ -38,7 +38,7 @@ public class DiagnosticDump extends Stan
 
     /**
      * Creates new diagnostic mbean.
-     * 
+     *
      * @throws NotCompliantMBeanException
      */
     public DiagnosticDump() throws NotCompliantMBeanException {
@@ -47,37 +47,41 @@ public class DiagnosticDump extends Stan
 
     /**
      * Creates dump witch given name
-     * 
+     *
      * @param name Name of the dump.
      */
-    public void createDump(String name) throws Exception {
+    public void createDump(String name) throws MBeanException {
         createDump(false, name);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void createDump(boolean directory, String name) throws Exception {
-        File target = new File(name);
-
-        DumpDestination destination;
-        if (directory) {
-            destination = new DirectoryDumpDestination(target);
-        } else {
-            destination = new ZipDumpDestination(target);
-        }
-
-        for (DumpProvider provider : providers) {
-            provider.createDump(destination);
+    public void createDump(boolean directory, String name) throws MBeanException {
+        try {
+            File target = new File(name);
+
+            DumpDestination destination;
+            if (directory) {
+                destination = new DirectoryDumpDestination(target);
+            } else {
+                destination = new ZipDumpDestination(target);
+            }
+
+            for (DumpProvider provider : providers) {
+                provider.createDump(destination);
+            }
+
+            destination.save();
+        } catch (Exception e) {
+            throw new MBeanException(null, e.getMessage());
         }
-
-        destination.save();
     }
 
     /**
      * Sets dump providers.
-     * 
-     * @param providers Dump providers. 
+     *
+     * @param providers Dump providers.
      */
     public void setProviders(List<DumpProvider> providers) {
         this.providers = providers;