You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by ld...@apache.org on 2010/12/13 21:02:13 UTC

svn commit: r1045349 - in /karaf/trunk: ./ diagnostic/common/ diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/ diagnostic/common/src/main/resources/OSGI-INF/blueprint/ diagnostic/core/ diagnostic/core/src/main/java/org/apache/karaf/d...

Author: ldywicki
Date: Mon Dec 13 20:02:12 2010
New Revision: 1045349

URL: http://svn.apache.org/viewvc?rev=1045349&view=rev
Log:
Diagnostic tool update.

Added:
    karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/BundleDumpProvider.java
    karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/ScreenshotDumpProvider.java
    karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/ThreadDumpProvider.java
    karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/blueprint/diagnostic-services.xml
      - copied, changed from r1045344, karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/blueprint/features-command.xml
    karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpService.java
    karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/ClosingEntryOutputStreamWrapper.java
    karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/TextDumpProvider.java
      - copied, changed from r1045344, karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/Dump.java
Removed:
    karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/FeaturesDump.java
    karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/blueprint/features-command.xml
    karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/Dump.java
    karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/FileDump.java
Modified:
    karaf/trunk/.gitignore
    karaf/trunk/diagnostic/common/pom.xml
    karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/FeaturesDumpProvider.java
    karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/LogDumpProvider.java
    karaf/trunk/diagnostic/core/pom.xml
    karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpDestination.java
    karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/ZipDumpDestination.java

Modified: karaf/trunk/.gitignore
URL: http://svn.apache.org/viewvc/karaf/trunk/.gitignore?rev=1045349&r1=1045348&r2=1045349&view=diff
==============================================================================
--- karaf/trunk/.gitignore (original)
+++ karaf/trunk/.gitignore Mon Dec 13 20:02:12 2010
@@ -2,4 +2,6 @@
 .project
 .classpath
 .settings
-target
\ No newline at end of file
+target
+eclipse-classes
+bin
\ No newline at end of file

Modified: karaf/trunk/diagnostic/common/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/common/pom.xml?rev=1045349&r1=1045348&r2=1045349&view=diff
==============================================================================
--- karaf/trunk/diagnostic/common/pom.xml (original)
+++ karaf/trunk/diagnostic/common/pom.xml Mon Dec 13 20:02:12 2010
@@ -68,6 +68,12 @@
             <artifactId>org.apache.karaf.management</artifactId>
         </dependency>
 
+		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+			<version>2.0</version>
+		</dependency>        
+
         <dependency>
             <groupId>org.springframework.osgi</groupId>
             <artifactId>spring-osgi-core</artifactId>
@@ -103,14 +109,8 @@
                         </Export-Package>
                         <Import-Package>
                             !${project.artifactId}*,
-                            javax.management,
-                            javax.management.loading,
-                            org.apache.felix.service.command,
-                            org.apache.felix.gogo.commands,
-                            org.apache.karaf.shell.console,
                             *
                         </Import-Package>
-                        <Private-Package>org.apache.karaf.diagnostic.management.internal</Private-Package>
                         <_versionpolicy>${bnd.version.policy}</_versionpolicy>
                     </instructions>
                 </configuration>

Added: karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/BundleDumpProvider.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/BundleDumpProvider.java?rev=1045349&view=auto
==============================================================================
--- karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/BundleDumpProvider.java (added)
+++ karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/BundleDumpProvider.java Mon Dec 13 20:02:12 2010
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.karaf.diagnostic.common;
+
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.karaf.diagnostic.core.common.TextDumpProvider;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Dump provider which produces file named bundles.txt with list of
+ * installed bundles and it's state.
+ * 
+ * @author ldywicki
+ */
+public class BundleDumpProvider extends TextDumpProvider {
+
+	/**
+	 * Static map with state mask to string representation.
+	 */
+	private static Map<Integer, String> stateMap = new HashMap<Integer, String>();
+	static {
+		stateMap.put(0x00000001, "UNINSTALLED");;
+		stateMap.put(0x00000002, "INSTALLED");;
+		stateMap.put(0x00000004, "RESOLVED");;
+		stateMap.put(0x00000008, "STARTING");;
+		stateMap.put(0x00000010, "STOPPING");;
+		stateMap.put(0x00000020, "ACTIVE");;
+	}
+
+	private BundleContext bundleContext;
+
+	public BundleDumpProvider(BundleContext context) {
+		super("bundles.txt");
+		this.bundleContext = context;
+	}
+
+	protected void writeDump(OutputStreamWriter writer) throws IOException {
+		Bundle[] bundles = bundleContext.getBundles();
+
+		writer.write("Number of installed bundles " + bundles.length + "\n");
+
+		writer.write("Id\tSymbolic name\tState\n");
+		for (Bundle bundle : bundles) {
+			writer.write(bundle.getBundleId() + "\t" + bundle.getSymbolicName()
+				+ "\t" + stateMap.get(bundle.getState()) + "\n");
+		}
+	}
+
+}

Modified: karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/FeaturesDumpProvider.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/FeaturesDumpProvider.java?rev=1045349&r1=1045348&r2=1045349&view=diff
==============================================================================
--- karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/FeaturesDumpProvider.java (original)
+++ karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/FeaturesDumpProvider.java Mon Dec 13 20:02:12 2010
@@ -1,11 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.apache.karaf.diagnostic.common;
 
+import java.io.BufferedWriter;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+
 import org.apache.karaf.diagnostic.core.DumpDestination;
 import org.apache.karaf.diagnostic.core.DumpProvider;
+import org.apache.karaf.features.BundleInfo;
+import org.apache.karaf.features.Feature;
 import org.apache.karaf.features.FeaturesService;
+import org.apache.karaf.features.Repository;
 
+/**
+ * Dump provider which add file named features.txt with informations
+ * about installed features and repositories. 
+ * 
+ * @author ldywicki
+ */
 public class FeaturesDumpProvider implements DumpProvider {
 
+	/**
+	 * Feature service.
+	 */
 	private final FeaturesService features;
 
 	public FeaturesDumpProvider(FeaturesService features) {
@@ -13,7 +44,33 @@ public class FeaturesDumpProvider implem
 	}
 
 	public void createDump(DumpDestination destination) throws Exception {
-		destination.add(new FeaturesDump(features));
+		writeDump(destination.add("features.txt"));
+	}
+
+	private void writeDump(OutputStream outputStream) throws Exception {
+		BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream));
+		writer.write("Repositories:\n");
+
+		for (Repository repo : features.listRepositories()) {
+			writer.write(repo.getURI() + " (" + repo.getName() + ")\n");
+		}
+
+		writer.write("\nfeatures:\n");
+		for (Feature feature : features.listFeatures()) {
+			writer.write(feature.getName() + " " + feature.getVersion());
+			writer.write(" installed: " + features.isInstalled(feature));
+			writer.write("\nBundles:\n");
+			for (BundleInfo bundle : feature.getBundles()) {
+				writer.write("\t" + bundle.getLocation());
+				if (bundle.getStartLevel() != 0) {
+					writer.write(" start level " + bundle.getStartLevel());
+				}
+				writer.write("\n");
+			}
+		}
+
+		// flush & close stream
+		writer.close();
 	}
 
 }

Modified: karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/LogDumpProvider.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/LogDumpProvider.java?rev=1045349&r1=1045348&r2=1045349&view=diff
==============================================================================
--- karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/LogDumpProvider.java (original)
+++ karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/LogDumpProvider.java Mon Dec 13 20:02:12 2010
@@ -1,19 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.apache.karaf.diagnostic.common;
 
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.OutputStream;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.karaf.diagnostic.core.DumpDestination;
 import org.apache.karaf.diagnostic.core.DumpProvider;
-import org.apache.karaf.diagnostic.core.common.FileDump;
 
+/**
+ * Dump provider which copies log files from data/log directory to
+ * destination.
+ * 
+ * @author ldywicki
+ */
 public class LogDumpProvider implements DumpProvider {
 
+	/**
+	 * Creates log entries in attached zip.
+	 */
 	public void createDump(DumpDestination destination) throws Exception {
 		File logDir = new File("data/log");
 		File[] listFiles = logDir.listFiles();
 
 		for (File file : listFiles) {
-			destination.add(new FileDump(file));
+			FileInputStream inputStream = new FileInputStream(file);
+
+			OutputStream outputStream = destination.add("log/" + file.getName());
+
+			IOUtils.copy(inputStream, outputStream);
 		}
 	}
 

Added: karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/ScreenshotDumpProvider.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/ScreenshotDumpProvider.java?rev=1045349&view=auto
==============================================================================
--- karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/ScreenshotDumpProvider.java (added)
+++ karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/ScreenshotDumpProvider.java Mon Dec 13 20:02:12 2010
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.karaf.diagnostic.common;
+
+import java.awt.DisplayMode;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.image.BufferedImage;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+
+import org.apache.karaf.diagnostic.core.DumpDestination;
+import org.apache.karaf.diagnostic.core.DumpProvider;
+
+/**
+ * Create screenshot from all devices.
+ * 
+ * @author ldywicki
+ */
+public class ScreenshotDumpProvider implements DumpProvider {
+
+	public void createDump(DumpDestination destination) throws Exception {
+		GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+		GraphicsDevice[] gs = ge.getScreenDevices();
+		 
+		for (int i=0; i < gs.length; i++) {
+			DisplayMode mode = gs[i].getDisplayMode();
+			Rectangle bounds = new Rectangle(0, 0, mode.getWidth(), mode.getHeight());
+		    BufferedImage screenshot = new Robot(gs[i]).createScreenCapture(bounds);
+		    OutputStream outputStream = destination.add("screenshot/display_" + i + ".jpg");
+		    ImageIO.write(screenshot, "PNG", outputStream);
+		}
+
+	}
+
+}

Added: karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/ThreadDumpProvider.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/ThreadDumpProvider.java?rev=1045349&view=auto
==============================================================================
--- karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/ThreadDumpProvider.java (added)
+++ karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/ThreadDumpProvider.java Mon Dec 13 20:02:12 2010
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.karaf.diagnostic.common;
+
+import java.io.OutputStreamWriter;
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadInfo;
+import java.lang.management.ThreadMXBean;
+
+import org.apache.karaf.diagnostic.core.common.TextDumpProvider;
+
+/**
+ * Provider which dumps thread info to file named threads.txt.
+ * 
+ * @author ldywicki
+ */
+public class ThreadDumpProvider extends TextDumpProvider {
+
+	public ThreadDumpProvider() {
+		super("threads.txt");
+	}
+
+	@Override
+	protected void writeDump(OutputStreamWriter outputStream) throws Exception {
+		ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
+		
+		outputStream.write("Number of threads: " + threadMXBean.getDaemonThreadCount() + "\n");
+		ThreadInfo[] threadDump = threadMXBean.dumpAllThreads(true, true);
+		for (ThreadInfo threadInfo : threadDump) {
+			outputStream.write(threadInfo.toString() + "\n\n");
+		}
+	}
+
+}

Copied: karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/blueprint/diagnostic-services.xml (from r1045344, karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/blueprint/features-command.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/blueprint/diagnostic-services.xml?p2=karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/blueprint/diagnostic-services.xml&p1=karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/blueprint/features-command.xml&r1=1045344&r2=1045349&rev=1045349&view=diff
==============================================================================
--- karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/blueprint/features-command.xml (original)
+++ karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/blueprint/diagnostic-services.xml Mon Dec 13 20:02:12 2010
@@ -30,4 +30,15 @@
 	<bean id="logs" class="org.apache.karaf.diagnostic.common.LogDumpProvider" />
 	<service ref="logs" auto-export="interfaces" />	
 
+	<bean id="bundles" class="org.apache.karaf.diagnostic.common.BundleDumpProvider">
+		<argument ref="blueprintBundleContext" />
+	</bean>
+	<service ref="bundles" auto-export="interfaces" />	
+
+	<bean id="threads" class="org.apache.karaf.diagnostic.common.ThreadDumpProvider" />
+	<service ref="threads" auto-export="interfaces" />	
+
+	<bean id="screens" class="org.apache.karaf.diagnostic.common.ScreenshotDumpProvider" />
+	<service ref="screens" auto-export="interfaces" />	
+
 </blueprint>

Modified: karaf/trunk/diagnostic/core/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/core/pom.xml?rev=1045349&r1=1045348&r2=1045349&view=diff
==============================================================================
--- karaf/trunk/diagnostic/core/pom.xml (original)
+++ karaf/trunk/diagnostic/core/pom.xml Mon Dec 13 20:02:12 2010
@@ -59,7 +59,7 @@
                         <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                         <Export-Package>
                         	${project.artifactId};version=${project.version},
-                        	${project.artifactId}.common;version=${project.version},
+                        	${project.artifactId}.common;version=${project.version};-noimport:=true,
                        	</Export-Package>
                         <Import-Package>
                             !${project.artifactId}*,

Modified: karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpDestination.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpDestination.java?rev=1045349&r1=1045348&r2=1045349&view=diff
==============================================================================
--- karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpDestination.java (original)
+++ karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpDestination.java Mon Dec 13 20:02:12 2010
@@ -1,5 +1,7 @@
 package org.apache.karaf.diagnostic.core;
 
+import java.io.OutputStream;
+
 /**
  * Destination for created dumps.
  * 
@@ -7,7 +9,7 @@ package org.apache.karaf.diagnostic.core
  */
 public interface DumpDestination {
 
-	void add(Dump ... dump) throws Exception;
+	OutputStream add(String name) throws Exception;
 
 	void save() throws Exception;
 

Added: karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpService.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpService.java?rev=1045349&view=auto
==============================================================================
--- karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpService.java (added)
+++ karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpService.java Mon Dec 13 20:02:12 2010
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.karaf.diagnostic.core;
+
+import java.util.List;
+
+/**
+ * Dump service which allows to customize dump creation process.
+ * 
+ * @author ldywicki
+ */
+public interface DumpService {
+
+	/**
+	 * Return registered providers.
+	 * 
+	 * @return Providers registered in OSGi service registry.
+	 */
+	List<DumpProvider> listProviders();
+
+	/**
+	 * List destinations where dumps can be stored.
+	 * 
+	 * @return Destinations registered in OSGi service registry.
+	 */
+	List<DumpDestination> listDestinations();
+
+	/**
+	 * Make dump using given providers.
+	 * 
+	 * @param destination Store destination.
+	 * @param providers Dump providers to use.
+	 * @return True if dump was created.
+	 */
+	boolean dump(DumpDestination destination, DumpProvider ... providers);
+
+	/**
+	 * Creates data witch all dump providers.
+	 * 
+	 * @param destination Store destination.
+	 * @return True if dump was created.
+	 */
+	boolean dumpAll(DumpDestination destination);
+}

Added: karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/ClosingEntryOutputStreamWrapper.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/ClosingEntryOutputStreamWrapper.java?rev=1045349&view=auto
==============================================================================
--- karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/ClosingEntryOutputStreamWrapper.java (added)
+++ karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/ClosingEntryOutputStreamWrapper.java Mon Dec 13 20:02:12 2010
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.karaf.diagnostic.core.common;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * Output stream which closes entry instead closing whole stream.
+ * 
+ * @author ldywicki
+ */
+public class ClosingEntryOutputStreamWrapper extends OutputStream {
+
+	/**
+	 * Wrapped ZIP output stream. 
+	 */
+	private ZipOutputStream outputStream;
+
+	/**
+	 * Creates new OutputStream.
+	 * 
+	 * @param outputStream Wrapped output stream.
+	 */
+	public ClosingEntryOutputStreamWrapper(ZipOutputStream outputStream) {
+		this.outputStream = outputStream;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void write(int b) throws IOException {
+		outputStream.write(b);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void write(byte[] b) throws IOException {
+		outputStream.write(b);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void write(byte[] b, int off, int len)
+		throws IOException {
+		outputStream.write(b, off, len);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void close() throws IOException {
+		// close entry instead of closing stream.
+		outputStream.closeEntry();
+	}
+}

Copied: karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/TextDumpProvider.java (from r1045344, karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/Dump.java)
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/TextDumpProvider.java?p2=karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/TextDumpProvider.java&p1=karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/Dump.java&r1=1045344&r2=1045349&rev=1045349&view=diff
==============================================================================
--- karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/Dump.java (original)
+++ karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/TextDumpProvider.java Mon Dec 13 20:02:12 2010
@@ -13,19 +13,28 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.karaf.diagnostic.core;
+package org.apache.karaf.diagnostic.core.common;
 
-import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
 
-/**
- * Base class which represents dumped data.
- * 
- * @author ldywicki
- */
-public interface Dump {
+import org.apache.karaf.diagnostic.core.DumpDestination;
+import org.apache.karaf.diagnostic.core.DumpProvider;
+
+public abstract class TextDumpProvider implements DumpProvider {
+
+	private final String name;
+
+	protected TextDumpProvider(String name) {
+		this.name = name;
+	}
 
-	InputStream createResource() throws Exception;
+	public void createDump(DumpDestination destination) throws Exception {
+		OutputStream outputStream = destination.add(name);
+		writeDump(new OutputStreamWriter(outputStream));
+		outputStream.close();
+	}
 
-	String getName();
+	protected abstract void writeDump(OutputStreamWriter outputStream) throws Exception;
 
 }

Modified: karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/ZipDumpDestination.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/ZipDumpDestination.java?rev=1045349&r1=1045348&r2=1045349&view=diff
==============================================================================
--- karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/ZipDumpDestination.java (original)
+++ karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/ZipDumpDestination.java Mon Dec 13 20:02:12 2010
@@ -18,11 +18,10 @@ package org.apache.karaf.diagnostic.core
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
-import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
-import org.apache.karaf.diagnostic.core.Dump;
 import org.apache.karaf.diagnostic.core.DumpDestination;
 
 /**
@@ -47,20 +46,10 @@ public class ZipDumpDestination implemen
 		}
 	}
 
-	public void add(Dump... dump) throws Exception {
-		for (Dump entry : dump) {
-			ZipEntry zipEntry = new ZipEntry(entry.getName());
-			outputStream.putNextEntry(zipEntry);
-
-			InputStream in = entry.createResource();
-            int len;
-            byte[] buf = new byte[1024];
-
-            while ((len = in.read(buf)) > 0) {
-                outputStream.write(buf, 0, len);
-            }
-            outputStream.closeEntry();
-		}
+	public OutputStream add(String name) throws Exception {
+		ZipEntry zipEntry = new ZipEntry(name);
+		outputStream.putNextEntry(zipEntry);
+		return new ClosingEntryOutputStreamWrapper(outputStream);
 	}
 
 	public void save() throws Exception {