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 20:56:14 UTC
svn commit: r1045344 - in /karaf/trunk/diagnostic: ./ command/ command/src/
command/src/main/ command/src/main/java/ command/src/main/java/org/
command/src/main/java/org/apache/ command/src/main/java/org/apache/karaf/
command/src/main/java/org/apache/k...
Author: ldywicki
Date: Mon Dec 13 19:56:12 2010
New Revision: 1045344
URL: http://svn.apache.org/viewvc?rev=1045344&view=rev
Log:
Diagnostic tool draft
Added:
karaf/trunk/diagnostic/
karaf/trunk/diagnostic/command/
karaf/trunk/diagnostic/command/pom.xml
karaf/trunk/diagnostic/command/src/
karaf/trunk/diagnostic/command/src/main/
karaf/trunk/diagnostic/command/src/main/java/
karaf/trunk/diagnostic/command/src/main/java/org/
karaf/trunk/diagnostic/command/src/main/java/org/apache/
karaf/trunk/diagnostic/command/src/main/java/org/apache/karaf/
karaf/trunk/diagnostic/command/src/main/java/org/apache/karaf/diagnostic/
karaf/trunk/diagnostic/command/src/main/java/org/apache/karaf/diagnostic/command/
karaf/trunk/diagnostic/command/src/main/java/org/apache/karaf/diagnostic/command/DumpCommand.java
karaf/trunk/diagnostic/command/src/main/resources/
karaf/trunk/diagnostic/command/src/main/resources/OSGI-INF/
karaf/trunk/diagnostic/command/src/main/resources/OSGI-INF/blueprint/
karaf/trunk/diagnostic/command/src/main/resources/OSGI-INF/blueprint/shell-diagnostic.xml
karaf/trunk/diagnostic/common/
karaf/trunk/diagnostic/common/pom.xml
karaf/trunk/diagnostic/common/src/
karaf/trunk/diagnostic/common/src/main/
karaf/trunk/diagnostic/common/src/main/java/
karaf/trunk/diagnostic/common/src/main/java/org/
karaf/trunk/diagnostic/common/src/main/java/org/apache/
karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/
karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/
karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/
karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/FeaturesDump.java
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/common/src/main/resources/
karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/
karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/blueprint/
karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/blueprint/features-command.xml
karaf/trunk/diagnostic/core/
karaf/trunk/diagnostic/core/pom.xml
karaf/trunk/diagnostic/core/src/
karaf/trunk/diagnostic/core/src/main/
karaf/trunk/diagnostic/core/src/main/java/
karaf/trunk/diagnostic/core/src/main/java/org/
karaf/trunk/diagnostic/core/src/main/java/org/apache/
karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/
karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/
karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/
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/DumpDestination.java
karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpProvider.java
karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/
karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/FileDump.java
karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/ZipDumpDestination.java
karaf/trunk/diagnostic/management/
karaf/trunk/diagnostic/management/pom.xml
karaf/trunk/diagnostic/pom.xml
Added: karaf/trunk/diagnostic/command/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/command/pom.xml?rev=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/command/pom.xml (added)
+++ karaf/trunk/diagnostic/command/pom.xml Mon Dec 13 19:56:12 2010
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.diagnostic</groupId>
+ <artifactId>diagnostic</artifactId>
+ <version>2.1.99-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.apache.karaf.diagnostic.command</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Karaf :: Diagnostic :: Command</name>
+
+ <properties>
+ <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.diagnostic</groupId>
+ <artifactId>org.apache.karaf.diagnostic.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
+ <Import-Package>
+ !${project.artifactId}*,
+ *
+ </Import-Package>
+ <Private-Package>!*</Private-Package>
+ <_versionpolicy>${bnd.version.policy}</_versionpolicy>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: karaf/trunk/diagnostic/command/src/main/java/org/apache/karaf/diagnostic/command/DumpCommand.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/command/src/main/java/org/apache/karaf/diagnostic/command/DumpCommand.java?rev=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/command/src/main/java/org/apache/karaf/diagnostic/command/DumpCommand.java (added)
+++ karaf/trunk/diagnostic/command/src/main/java/org/apache/karaf/diagnostic/command/DumpCommand.java Mon Dec 13 19:56:12 2010
@@ -0,0 +1,31 @@
+package org.apache.karaf.diagnostic.command;
+
+import java.io.File;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.diagnostic.core.DumpProvider;
+import org.apache.karaf.diagnostic.core.common.ZipDumpDestination;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+@Command(scope = "dev", name = "dump", description = "Dump data")
+public class DumpCommand extends OsgiCommandSupport {
+
+ private List<DumpProvider> providers = new LinkedList<DumpProvider>();
+
+ @Override
+ protected Object doExecute() throws Exception {
+ ZipDumpDestination destination = new ZipDumpDestination(new File("dump.zip"));
+ for (DumpProvider provider : providers) {
+ provider.createDump(destination);
+ }
+ destination.save();
+
+ return null;
+ }
+
+ public void setProviders(List<DumpProvider> providers) {
+ this.providers = providers;
+ }
+}
Added: karaf/trunk/diagnostic/command/src/main/resources/OSGI-INF/blueprint/shell-diagnostic.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/command/src/main/resources/OSGI-INF/blueprint/shell-diagnostic.xml?rev=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/command/src/main/resources/OSGI-INF/blueprint/shell-diagnostic.xml (added)
+++ karaf/trunk/diagnostic/command/src/main/resources/OSGI-INF/blueprint/shell-diagnostic.xml Mon Dec 13 19:56:12 2010
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
+ <command name="dev/create-dump">
+ <action class="org.apache.karaf.diagnostic.command.DumpCommand">
+ <property name="providers" ref="providers"/>
+ </action>
+ </command>
+ </command-bundle>
+
+
+ <reference-list id="providers" interface="org.apache.karaf.diagnostic.core.DumpProvider"
+ availability="optional">
+ </reference-list>
+
+</blueprint>
Added: karaf/trunk/diagnostic/common/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/common/pom.xml?rev=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/common/pom.xml (added)
+++ karaf/trunk/diagnostic/common/pom.xml Mon Dec 13 19:56:12 2010
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.diagnostic</groupId>
+ <artifactId>diagnostic</artifactId>
+ <version>2.1.99-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.apache.karaf.diagnostic.common</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Karaf :: Diagnostic :: Common</name>
+
+ <properties>
+ <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.karaf.diagnostic</groupId>
+ <artifactId>org.apache.karaf.diagnostic.core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.bundlerepository</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.karaf.features</groupId>
+ <artifactId>org.apache.karaf.features.core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>org.apache.karaf.management</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-osgi-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Export-Package>
+ ${project.artifactId}*;version=${project.version}
+ </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>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/FeaturesDump.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/FeaturesDump.java?rev=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/FeaturesDump.java (added)
+++ karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/FeaturesDump.java Mon Dec 13 19:56:12 2010
@@ -0,0 +1,54 @@
+package org.apache.karaf.diagnostic.common;
+
+import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+
+import org.apache.karaf.diagnostic.core.Dump;
+import org.apache.karaf.features.BundleInfo;
+import org.apache.karaf.features.Feature;
+import org.apache.karaf.features.FeaturesService;
+import org.apache.karaf.features.Repository;
+
+public class FeaturesDump implements Dump {
+
+ private final FeaturesService service;
+
+ public FeaturesDump(FeaturesService service) {
+ this.service = service;
+ }
+
+ public InputStream createResource() throws Exception {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream));
+ writer.write("Repositories:\n");
+
+ for (Repository repo : service.listRepositories()) {
+ writer.write(repo.getURI() + "(" + repo.getName() + ")\n");
+ }
+
+ writer.write("\nInstalled features:\n");
+ for (Feature feature : service.listInstalledFeatures()) {
+ writer.write(feature.getName() + " " + feature.getVersion());
+ writer.write("\tBundles:\n");
+ for (BundleInfo bundle : feature.getBundles()) {
+ writer.write("\t" + bundle.getLocation());
+ if (bundle.getStartLevel() != 0) {
+ writer.write(" start level " + bundle.getStartLevel());
+ }
+ writer.write("\n");
+ }
+ }
+ writer.flush();
+
+ return new ByteArrayInputStream(outputStream.toByteArray());
+ }
+
+ public String getName() {
+ return "features.txt";
+ }
+
+}
Added: 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=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/FeaturesDumpProvider.java (added)
+++ karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/FeaturesDumpProvider.java Mon Dec 13 19:56:12 2010
@@ -0,0 +1,19 @@
+package org.apache.karaf.diagnostic.common;
+
+import org.apache.karaf.diagnostic.core.DumpDestination;
+import org.apache.karaf.diagnostic.core.DumpProvider;
+import org.apache.karaf.features.FeaturesService;
+
+public class FeaturesDumpProvider implements DumpProvider {
+
+ private final FeaturesService features;
+
+ public FeaturesDumpProvider(FeaturesService features) {
+ this.features = features;
+ }
+
+ public void createDump(DumpDestination destination) throws Exception {
+ destination.add(new FeaturesDump(features));
+ }
+
+}
Added: 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=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/LogDumpProvider.java (added)
+++ karaf/trunk/diagnostic/common/src/main/java/org/apache/karaf/diagnostic/common/LogDumpProvider.java Mon Dec 13 19:56:12 2010
@@ -0,0 +1,20 @@
+package org.apache.karaf.diagnostic.common;
+
+import java.io.File;
+
+import org.apache.karaf.diagnostic.core.DumpDestination;
+import org.apache.karaf.diagnostic.core.DumpProvider;
+import org.apache.karaf.diagnostic.core.common.FileDump;
+
+public class LogDumpProvider implements DumpProvider {
+
+ 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));
+ }
+ }
+
+}
Added: 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/features-command.xml?rev=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/blueprint/features-command.xml (added)
+++ karaf/trunk/diagnostic/common/src/main/resources/OSGI-INF/blueprint/features-command.xml Mon Dec 13 19:56:12 2010
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <bean id="features" class="org.apache.karaf.diagnostic.common.FeaturesDumpProvider">
+ <argument>
+ <reference interface="org.apache.karaf.features.FeaturesService"
+ availability="optional" />
+ </argument>
+ </bean>
+ <service ref="features" auto-export="interfaces" />
+
+ <bean id="logs" class="org.apache.karaf.diagnostic.common.LogDumpProvider" />
+ <service ref="logs" auto-export="interfaces" />
+
+</blueprint>
Added: karaf/trunk/diagnostic/core/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/core/pom.xml?rev=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/core/pom.xml (added)
+++ karaf/trunk/diagnostic/core/pom.xml Mon Dec 13 19:56:12 2010
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.diagnostic</groupId>
+ <artifactId>diagnostic</artifactId>
+ <version>2.1.99-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.apache.karaf.diagnostic.core</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Karaf :: Diagnostic :: Core</name>
+
+ <properties>
+ <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Export-Package>
+ ${project.artifactId};version=${project.version},
+ ${project.artifactId}.common;version=${project.version},
+ </Export-Package>
+ <Import-Package>
+ !${project.artifactId}*,
+ *
+ </Import-Package>
+ <Private-Package>
+ org.apache.karaf.diagnostic.internal
+ </Private-Package>
+ <_versionpolicy>${bnd.version.policy}</_versionpolicy>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: 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/Dump.java?rev=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/Dump.java (added)
+++ karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/Dump.java Mon Dec 13 19:56:12 2010
@@ -0,0 +1,31 @@
+/*
+ * 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.io.InputStream;
+
+/**
+ * Base class which represents dumped data.
+ *
+ * @author ldywicki
+ */
+public interface Dump {
+
+ InputStream createResource() throws Exception;
+
+ String getName();
+
+}
Added: 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=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpDestination.java (added)
+++ karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpDestination.java Mon Dec 13 19:56:12 2010
@@ -0,0 +1,14 @@
+package org.apache.karaf.diagnostic.core;
+
+/**
+ * Destination for created dumps.
+ *
+ * @author ldywicki
+ */
+public interface DumpDestination {
+
+ void add(Dump ... dump) throws Exception;
+
+ void save() throws Exception;
+
+}
Added: karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpProvider.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpProvider.java?rev=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpProvider.java (added)
+++ karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/DumpProvider.java Mon Dec 13 19:56:12 2010
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+/**
+ * Interface which represents instance of tool which can provide dump
+ * information.
+ *
+ * @author ldywicki
+ */
+public interface DumpProvider {
+
+ /**
+ * Creates dump.
+ */
+ void createDump(DumpDestination destination) throws Exception;
+
+}
Added: karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/FileDump.java
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/FileDump.java?rev=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/FileDump.java (added)
+++ karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/FileDump.java Mon Dec 13 19:56:12 2010
@@ -0,0 +1,25 @@
+package org.apache.karaf.diagnostic.core.common;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.karaf.diagnostic.core.Dump;
+
+public class FileDump implements Dump {
+
+ private final File file;
+
+ public FileDump(File file) {
+ this.file = file;
+ }
+
+ public InputStream createResource() throws Exception {
+ return new FileInputStream(file);
+ }
+
+ public String getName() {
+ return file.getName();
+ }
+
+}
Added: 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=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/ZipDumpDestination.java (added)
+++ karaf/trunk/diagnostic/core/src/main/java/org/apache/karaf/diagnostic/core/common/ZipDumpDestination.java Mon Dec 13 19:56:12 2010
@@ -0,0 +1,70 @@
+/*
+ * 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.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.karaf.diagnostic.core.Dump;
+import org.apache.karaf.diagnostic.core.DumpDestination;
+
+/**
+ * Class which packages dumps to ZIP archive.
+ *
+ * @author ldywicki
+ */
+public class ZipDumpDestination implements DumpDestination {
+
+ private ZipOutputStream outputStream;
+
+ public ZipDumpDestination(File directory, String name) {
+ this(new File(directory, name));
+ }
+
+ public ZipDumpDestination(File file) {
+ try {
+ outputStream = new ZipOutputStream(new FileOutputStream(
+ file));
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException("Unable to create dump destination", e);
+ }
+ }
+
+ 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 void save() throws Exception {
+ outputStream.close();
+ }
+
+}
Added: karaf/trunk/diagnostic/management/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/management/pom.xml?rev=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/management/pom.xml (added)
+++ karaf/trunk/diagnostic/management/pom.xml Mon Dec 13 19:56:12 2010
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.diagnostic</groupId>
+ <artifactId>diagnostic</artifactId>
+ <version>2.1.99-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.apache.karaf.diagnostic.management</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Karaf :: Diagnostic :: Management</name>
+
+ <properties>
+ <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.karaf.diagnostic</groupId>
+ <artifactId>org.apache.karaf.diagnostic.core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.bundlerepository</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>org.apache.karaf.management</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-osgi-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Export-Package>
+ ${project.artifactId}*;version=${project.version}
+ </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>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: karaf/trunk/diagnostic/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/diagnostic/pom.xml?rev=1045344&view=auto
==============================================================================
--- karaf/trunk/diagnostic/pom.xml (added)
+++ karaf/trunk/diagnostic/pom.xml Mon Dec 13 19:56:12 2010
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>karaf</artifactId>
+ <version>2.1.99-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.karaf.diagnostic</groupId>
+ <artifactId>diagnostic</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Karaf :: Diagnostic</name>
+
+ <modules>
+ <module>core</module>
+ <module>command</module>
+ <module>management</module>
+ <module>common</module>
+ </modules>
+
+</project>