You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by cs...@apache.org on 2012/04/05 17:21:57 UTC

svn commit: r1309898 [1/2] - in /karaf/trunk: ./ assemblies/features/framework/src/main/resources/resources/etc/ assemblies/features/standard/src/main/feature/ dev/ dev/command/ dev/command/src/main/java/org/apache/karaf/dev/ dev/command/src/main/java/...

Author: cschneider
Date: Thu Apr  5 15:21:55 2012
New Revision: 1309898

URL: http://svn.apache.org/viewvc?rev=1309898&view=rev
Log:
KARAF-963 Dev modules refactored

Added:
    karaf/trunk/assemblies/features/framework/src/main/resources/resources/etc/equinox-debug.properties
    karaf/trunk/dev/   (with props)
    karaf/trunk/dev/command/
      - copied from r1309676, karaf/trunk/shell/dev/
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/
      - copied from r1309676, karaf/trunk/shell/dev/src/main/java/org/apache/karaf/shell/dev/
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/bundletree/
      - copied from r1309676, karaf/trunk/shell/dev/src/main/java/org/apache/karaf/shell/dev/util/
    karaf/trunk/dev/command/src/main/resources/OSGI-INF/blueprint/blueprint.xml
      - copied, changed from r1309676, karaf/trunk/shell/dev/src/main/resources/OSGI-INF/blueprint/shell-dev.xml
    karaf/trunk/dev/command/src/test/java/org/apache/karaf/dev/
    karaf/trunk/dev/command/src/test/java/org/apache/karaf/dev/command/
    karaf/trunk/dev/command/src/test/java/org/apache/karaf/dev/command/bundletree/
      - copied from r1309676, karaf/trunk/shell/dev/src/test/java/org/apache/karaf/shell/dev/util/
    karaf/trunk/dev/core/
      - copied from r1309676, karaf/trunk/management/mbeans/dev/
    karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/
    karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/
      - copied from r1309676, karaf/trunk/management/mbeans/dev/src/main/java/org/apache/karaf/management/mbeans/dev/
    karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/BundleWatcher.java
    karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/DevService.java
    karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/FrameworkType.java
    karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/internal/BundleWatcherImpl.java
      - copied, changed from r1309676, karaf/trunk/shell/dev/src/main/java/org/apache/karaf/shell/dev/watch/BundleWatcher.java
    karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/internal/Dev.java
      - copied, changed from r1309676, karaf/trunk/management/mbeans/dev/src/main/java/org/apache/karaf/management/mbeans/dev/internal/DevMBeanImpl.java
    karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/internal/DevServiceImpl.java
    karaf/trunk/dev/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
      - copied, changed from r1309676, karaf/trunk/management/mbeans/dev/src/main/resources/OSGI-INF/blueprint/dev-management.xml
    karaf/trunk/dev/pom.xml
Removed:
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/bundletree/Bundles.java
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/bundletree/IO.java
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/framework/
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/util/
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/watch/
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/shell/
    karaf/trunk/dev/command/src/main/resources/OSGI-INF/blueprint/shell-dev.xml
    karaf/trunk/dev/command/src/main/resources/org/
    karaf/trunk/dev/command/src/test/java/org/apache/karaf/dev/command/bundletree/BundlesTest.java
    karaf/trunk/dev/command/src/test/java/org/apache/karaf/shell/
    karaf/trunk/dev/command/src/test/resources/org/
    karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/internal/DevMBeanImpl.java
    karaf/trunk/dev/core/src/main/java/org/apache/karaf/management/
    karaf/trunk/dev/core/src/main/resources/OSGI-INF/blueprint/dev-management.xml
    karaf/trunk/management/mbeans/dev/
    karaf/trunk/shell/dev/
Modified:
    karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml
    karaf/trunk/dev/command/pom.xml
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/AbstractBundleCommand.java
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/DynamicImport.java
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/FrameworkOptions.java
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/PrintStackTraces.java
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/ShowBundleTree.java
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/SystemProperty.java
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/Watch.java
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/bundletree/Node.java
    karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/bundletree/Tree.java
    karaf/trunk/dev/command/src/test/java/org/apache/karaf/dev/command/bundletree/TreeTest.java
    karaf/trunk/dev/core/pom.xml
    karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/DevMBean.java
    karaf/trunk/dev/core/src/main/resources/OSGI-INF/bundle.info
    karaf/trunk/management/mbeans/pom.xml
    karaf/trunk/pom.xml
    karaf/trunk/shell/pom.xml

Added: karaf/trunk/assemblies/features/framework/src/main/resources/resources/etc/equinox-debug.properties
URL: http://svn.apache.org/viewvc/karaf/trunk/assemblies/features/framework/src/main/resources/resources/etc/equinox-debug.properties?rev=1309898&view=auto
==============================================================================
--- karaf/trunk/assemblies/features/framework/src/main/resources/resources/etc/equinox-debug.properties (added)
+++ karaf/trunk/assemblies/features/framework/src/main/resources/resources/etc/equinox-debug.properties Thu Apr  5 15:21:55 2012
@@ -0,0 +1,111 @@
+# 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.
+
+
+#### Debugging options for org.eclipse.bundles
+
+# Turn on general debugging for org.eclipse.bundles
+org.eclipse.osgi/debug=false
+# Prints out class loading debug information
+org.eclipse.osgi/debug/loader=false
+# Prints out event (FrameworkEvent/BundleEvent/ServiceEvent) and listener debug information
+org.eclipse.osgi/debug/events=false
+# Prints out OSGi service debug information (registration/getting/ungetting etc.)
+org.eclipse.osgi/debug/services=false
+# Prints out bundle manifest parsing debug information
+org.eclipse.osgi/debug/manifest=false
+# Prints out LDAP filter debug information
+org.eclipse.osgi/debug/filter=false
+# Prints out security (PermissionAdmin service) debug information
+org.eclipse.osgi/debug/security=false
+# Prints out start level service debug information
+org.eclipse.osgi/debug/startlevel=false
+# Prints out package instance service debug information
+org.eclipse.osgi/debug/packageadmin=false
+# Prints out timing information for bundle activation
+org.eclipse.osgi/debug/bundleTime=false
+# Debug the loading of message bundles
+org.eclipse.osgi/debug/messageBundles=false
+
+# Eclipse adaptor options
+org.eclipse.osgi/eclipseadaptor/debug = false
+org.eclipse.osgi/eclipseadaptor/debug/location = false
+org.eclipse.osgi/eclipseadaptor/debug/platformadmin=false
+org.eclipse.osgi/eclipseadaptor/debug/platformadmin/resolver=false
+org.eclipse.osgi/eclipseadaptor/converter/debug = false
+
+### OSGi resolver options
+# Turns on debugging for the resolver
+org.eclipse.osgi/resolver/debug = false
+# Prints out wiring information after the resolver has completed the resolve process
+org.eclipse.osgi/resolver/wiring = false
+# Prints out Import-Package information
+org.eclipse.osgi/resolver/imports = false
+# Prints out Require-Bundle information
+org.eclipse.osgi/resolver/requires = false
+# Prints out package grouping information form the "uses" clause
+org.eclipse.osgi/resolver/grouping = false
+# Prints out cycle information
+org.eclipse.osgi/resolver/cycles = false
+# Prints out Eclipse-GenericRequire information
+org.eclipse.osgi/resolver/generics = false
+
+#### Profile settings
+org.eclipse.osgi/profile/startup = false
+org.eclipse.osgi/profile/benchmark = false
+org.eclipse.osgi/profile/debug = false
+
+# Override the default implemenation 
+org.eclipse.osgi/profile/impl = org.eclipse.osgi.internal.profile.DefaultProfileLogger
+
+# Append all profile messages to the filename specified
+org.eclipse.osgi/defaultprofile/logfilename =  
+
+# Output all profile log messages synchronously to the jvm console.
+# By default, all log messages are cached until the log buffer is
+# requested.
+org.eclipse.osgi/defaultprofile/logsynchronously = false
+
+# Specify the size of the default profile implementation log buffer.
+org.eclipse.osgi/defaultprofile/buffersize = 256
+
+#### Monitoring settings
+# monitor class loading
+org.eclipse.osgi/monitor/classes=false
+
+# monitor bundle activation
+org.eclipse.osgi/monitor/activation=false
+
+# monitor resource bundle (*.properties) loading
+org.eclipse.osgi/monitor/resources=false
+
+
+#### Trace settings
+# trace class loading - snapshot the execution stack when a class is loaded
+org.eclipse.osgi/trace/classLoading=false
+
+# trace location - file in which execution traces are written
+org.eclipse.osgi/trace/filename=runtime.traces
+
+# trace filters - Java properties file defining which classes should 
+# be traced (if trace/classLoading is true)
+# File format:
+# plugins=<comma separated list of plugins whose classes to trace>
+# packages=<comma separated list of package prefixes of classes to trace>
+# Note that there may be many 'plugins' and 'packages' lines in one file.
+org.eclipse.osgi/trace/filters=trace.properties
+
+# trace bundle activation - snapshot the execution stack when a bundle is activated
+org.eclipse.osgi/trace/activation=false

Modified: karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml?rev=1309898&r1=1309897&r2=1309898&view=diff
==============================================================================
--- karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml (original)
+++ karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml Thu Apr  5 15:21:55 2012
@@ -19,26 +19,26 @@
 <features name="standard-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.0.0">
 
     <feature name="standard" description="Karaf standard feature" version="${project.version}">
+        <bundle start-level="30">mvn:org.apache.karaf.shell/org.apache.karaf.shell.console/${project.version}</bundle>
+        <bundle start-level="30">mvn:org.apache.karaf.features/org.apache.karaf.features.core/${project.version}</bundle>
         <bundle start-level="30">mvn:org.apache.karaf.features/org.apache.karaf.features.command/${project.version}</bundle>
         <bundle start-level="30">mvn:org.apache.karaf.features/org.apache.karaf.features.management/${project.version}</bundle>
         <bundle start-level="30">mvn:org.apache.karaf.instance/org.apache.karaf.instance.core/${project.version}</bundle>
-        <bundle start-level="30">mvn:org.apache.karaf.shell/org.apache.karaf.shell.console/${project.version}</bundle>
-        <bundle start-level="30">mvn:org.apache.karaf.jaas/org.apache.karaf.jaas.modules/${project.version}</bundle>
-        <bundle start-level="30">mvn:org.apache.karaf.jaas/org.apache.karaf.jaas.config/${project.version}</bundle>
         <bundle start-level="30">mvn:org.apache.karaf.instance/org.apache.karaf.instance.command/${project.version}</bundle>
-        <bundle start-level="30">mvn:org.apache.karaf.features/org.apache.karaf.features.core/${project.version}</bundle>
         <bundle start-level="30">mvn:org.apache.karaf.instance/org.apache.karaf.instance.management/${project.version}</bundle>
+        <bundle start-level="30">mvn:org.apache.karaf.jaas/org.apache.karaf.jaas.modules/${project.version}</bundle>
+        <bundle start-level="30">mvn:org.apache.karaf.jaas/org.apache.karaf.jaas.config/${project.version}</bundle>
+        <bundle start-level="30">mvn:org.apache.karaf.jaas/org.apache.karaf.jaas.command/${project.version}</bundle>
         <bundle start-level="30">mvn:org.apache.karaf.diagnostic/org.apache.karaf.diagnostic.core/${project.version}</bundle>
         <bundle start-level="30">mvn:org.apache.karaf.diagnostic/org.apache.karaf.diagnostic.common/${project.version}</bundle>
         <bundle start-level="30">mvn:org.apache.karaf.diagnostic/org.apache.karaf.diagnostic.command/${project.version}</bundle>
         <bundle start-level="30">mvn:org.apache.karaf.diagnostic/org.apache.karaf.diagnostic.management/${project.version}</bundle>
         <bundle start-level="30">mvn:org.apache.karaf.log/org.apache.karaf.log.core/${project.version}</bundle>
         <bundle start-level="30">mvn:org.apache.karaf.log/org.apache.karaf.log.command/${project.version}</bundle>
-        <bundle start-level="30">mvn:org.apache.karaf.shell/org.apache.karaf.shell.dev/${project.version}</bundle>
-        <bundle start-level="30">mvn:org.apache.karaf.management.mbeans/org.apache.karaf.management.mbeans.dev/${project.version}</bundle>
-        <bundle start-level="30">mvn:org.apache.karaf.jaas/org.apache.karaf.jaas.command/${project.version}</bundle>
         <bundle start-level="30">mvn:org.apache.karaf.service/org.apache.karaf.service.core/${project.version}</bundle>
         <bundle start-level="30">mvn:org.apache.karaf.service/org.apache.karaf.service.command/${project.version}</bundle>
+        <bundle start-level="30">mvn:org.apache.karaf.dev/org.apache.karaf.dev.core/${project.version}</bundle>
+        <bundle start-level="30">mvn:org.apache.karaf.dev/org.apache.karaf.dev.command/${project.version}</bundle>
     </feature>
 
     <feature name="aries-annotation" description="Aries Annotations" version="${project.version}">

Propchange: karaf/trunk/dev/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Apr  5 15:21:55 2012
@@ -0,0 +1,3 @@
+.project
+.settings
+target

Modified: karaf/trunk/dev/command/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/command/pom.xml?rev=1309898&r1=1309676&r2=1309898&view=diff
==============================================================================
--- karaf/trunk/dev/command/pom.xml (original)
+++ karaf/trunk/dev/command/pom.xml Thu Apr  5 15:21:55 2012
@@ -22,33 +22,26 @@
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
-        <artifactId>shell</artifactId>
-        <groupId>org.apache.karaf.shell</groupId>
+        <groupId>org.apache.karaf.dev</groupId>
+        <artifactId>dev</artifactId>
         <version>3.0.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
-    <artifactId>org.apache.karaf.shell.dev</artifactId>
+    <artifactId>org.apache.karaf.dev.command</artifactId>
     <packaging>bundle</packaging>
-    <name>Apache Karaf :: Shell :: Development Commands</name>
-    <description>This bundle provides Karaf shell commands aim to help the developer.</description>
+    <name>Apache Karaf :: Dev :: Command</name>
+    <description>Shell commands for developers</description>
 
     <dependencies>
         <dependency>
-            <groupId>org.apache.karaf.shell</groupId>
-            <artifactId>org.apache.karaf.shell.console</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.ops4j.pax.url</groupId>
-            <artifactId>pax-url-wrap</artifactId>
-            <scope>provided</scope>
+            <groupId>org.apache.karaf.dev</groupId>
+            <artifactId>org.apache.karaf.dev.core</artifactId>
         </dependency>
-
+    
         <dependency>
-            <groupId>org.ops4j.pax.url</groupId>
-            <artifactId>pax-url-aether</artifactId>
-            <scope>provided</scope>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.console</artifactId>
         </dependency>
 
         <dependency>
@@ -98,36 +91,12 @@
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
                     <instructions>
-                        <Import-Package>
-                            !${project.artifactId}.*,
-                            !junit.framework,
-                            !org.cyberneko.html,
-                            !org.cyberneko.html.filters,
-                            !com.sun.jdmk.comm,
-                            !javax.management,
-                            !javax.crypto,
-                            !javax.crypto.spec,
-                            !org.apache.avalon.framework.logger,
-                            !org.apache.log,
-                            !org.apache.xerces.xni,
-                            !org.apache.xerces.xni.parser,
-                            !org.objectweb.asm*,
-                            org.apache.aries.blueprint,
-                            org.osgi.service.blueprint.container,
-                            org.osgi.service.blueprint.reflect,
-                            org.apache.felix.service.command,
-                            org.apache.karaf.shell.commands,
-                            org.apache.karaf.shell.console,
-                            org.ops4j.pax.url.mvn,
-                            org.ops4j.pax.url.maven.commons,
-                            org.ops4j.util.property,
-                            *
-                        </Import-Package>
+                        <Export-Package>!*</Export-Package>
                         <Private-Package>
+                            org.apache.karaf.dev.command,
+                            org.apache.karaf.dev.command.bundletree,
                             org.apache.felix.utils.manifest,
-                            org.apache.felix.utils.version,
-                            org.apache.felix.utils.properties,
-                            !*
+                            org.apache.felix.utils.version
                         </Private-Package>
                     </instructions>
                 </configuration>

Modified: karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/AbstractBundleCommand.java
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/AbstractBundleCommand.java?rev=1309898&r1=1309676&r2=1309898&view=diff
==============================================================================
--- karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/AbstractBundleCommand.java (original)
+++ karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/AbstractBundleCommand.java Thu Apr  5 15:21:55 2012
@@ -14,19 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.karaf.shell.dev;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+package org.apache.karaf.dev.command;
 
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.wiring.BundleRevision;
-import org.osgi.framework.wiring.BundleRevisions;
-import org.osgi.framework.wiring.BundleWire;
-import org.osgi.framework.wiring.BundleWiring;
 
 /**
  * Base class for a dev: command that takes a bundle id as an argument
@@ -53,28 +45,4 @@ public abstract class AbstractBundleComm
 
     protected abstract void doExecute(Bundle bundle) throws Exception;
 
-    /*
-     * Get the list of bundles from which the given bundle imports packages
-     */
-    protected Map<String, Bundle> getWiredBundles(Bundle bundle) {
-        // the set of bundles from which the bundle imports packages
-        Map<String, Bundle> exporters = new HashMap<String, Bundle>();
-
-        for (BundleRevision revision : bundle.adapt(BundleRevisions.class).getRevisions()) {
-            BundleWiring wiring = revision.getWiring();
-            if (wiring != null) {
-                List<BundleWire> wires = wiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
-                if (wires != null) {
-                    for (BundleWire wire : wires) {
-                        if (wire.getProviderWiring().getBundle().getBundleId() != 0) {
-                            exporters.put(wire.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE).toString(),
-                                          wire.getProviderWiring().getBundle());
-                        }
-                    }
-                }
-            }
-        }
-        return exporters;
-    }
-
 }

Modified: karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/DynamicImport.java
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/DynamicImport.java?rev=1309898&r1=1309676&r2=1309898&view=diff
==============================================================================
--- karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/DynamicImport.java (original)
+++ karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/DynamicImport.java Thu Apr  5 15:21:55 2012
@@ -14,22 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.karaf.shell.dev;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Set;
+package org.apache.karaf.dev.command;
 
+import org.apache.karaf.dev.core.DevService;
 import org.apache.karaf.shell.commands.Command;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.wiring.FrameworkWiring;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static java.lang.String.format;
 
 /**
  * Command for enabling/disabling debug logging on a bundle and calculating the difference in
@@ -37,87 +26,21 @@ import static java.lang.String.format;
  */
 @Command(scope = "dev", name = "dynamic-import", description = "Enables/disables dynamic-import for a given bundle.")
 public class DynamicImport extends AbstractBundleCommand {
-
-    private final Logger LOG = LoggerFactory.getLogger(DynamicImport.class);
-
-    /**
-     * The header key where we store the active wires when we enable DynamicImport=*
-     */
-    protected static final String ORIGINAL_WIRES = "Original-Wires";
+    private final DevService devService;
+    
+    public DynamicImport(DevService devService) {
+        this.devService = devService;
+    }
 
     @Override
     protected void doExecute(Bundle bundle) throws Exception {
-        if (bundle.getHeaders().get(ORIGINAL_WIRES) == null) {
-            enableDynamicImports(bundle);
-        } else {
-            disableDynamicImports(bundle);
-        }
-    }
-
-    /*
-     * Enable DynamicImport=* on the bundle
-     */
-    private void enableDynamicImports(Bundle bundle) throws IOException, BundleException {
-        System.out.printf("Enabling dynamic imports on bundle %s%n", bundle);
-
-        String location =
-                String.format("wrap:%s$" +
-                        "Bundle-UpdateLocation=%s&" +
-                        "DynamicImport-Package=*&" +
-                        "%s=%s&" +
-                        "overwrite=merge",
-                        bundle.getLocation(),
-                        bundle.getLocation(),
-                        ORIGINAL_WIRES,
-                        explode(getWiredBundles(bundle).keySet()));
-        LOG.debug(format("Updating %s with URL %s", bundle, location));
-
-        URL url = new URL(location);
-        bundle.update(url.openStream());
-        bundleContext.getBundle(0).adapt(FrameworkWiring.class).refreshBundles(Collections.singleton(bundle));
-    }
-
-    /*
-     * Disable DynamicImport=* on the bundle
-     *
-     * At this time, we will also calculate the difference in package wiring for the bundle compared to
-     * when we enabled the DynamicImport
-     */
-    private void disableDynamicImports(Bundle bundle) throws BundleException {
-        System.out.printf("Disabling dynamic imports on bundle %s%n", bundle);
-
-        Set<String> current = getWiredBundles(bundle).keySet();
-        for (String original : bundle.getHeaders().get(ORIGINAL_WIRES).toString().split(",")) {
-            current.remove(original);
-        }
-
-        if (current.isEmpty()) {
-            System.out.println("(no additional packages have been wired since dynamic import was enabled)");
+        if (devService.isDynamicImport(bundle)) {
+            System.out.printf("Disabling dynamic imports on bundle %s%n", bundle);
+            devService.disableDynamicImports(bundle);
         } else {
-            System.out.printf("%nAdditional packages wired since dynamic import was enabled:%n");
-            for (String pkg : current) {
-                System.out.printf("- %s%n", pkg);
-            }
+            System.out.printf("Enabling dynamic imports on bundle %s%n", bundle);
+            devService.enableDynamicImports(bundle);
         }
-
-        bundle.update();
     }
 
-    /*
-     * Explode a set of string values in to a ,-delimited string
-     */
-    private String explode(Set<String> set) {
-        StringBuffer result = new StringBuffer();
-        Iterator<String> it = set.iterator();
-        while (it.hasNext()) {
-            result.append(it.next());
-            if (it.hasNext()) {
-                result.append(",");
-            }
-        }
-        if (result.length() == 0) {
-            return "--none--";
-        }
-        return result.toString();
-    }
 }

Modified: karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/FrameworkOptions.java
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/FrameworkOptions.java?rev=1309898&r1=1309676&r2=1309898&view=diff
==============================================================================
--- karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/FrameworkOptions.java (original)
+++ karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/FrameworkOptions.java Thu Apr  5 15:21:55 2012
@@ -14,18 +14,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.karaf.shell.dev;
-
-import java.io.File;
+package org.apache.karaf.dev.command;
 
+import org.apache.karaf.dev.core.DevService;
+import org.apache.karaf.dev.core.FrameworkType;
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.commands.Option;
-import org.apache.felix.utils.properties.Properties;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.dev.framework.Equinox;
-import org.apache.karaf.shell.dev.framework.Felix;
-import org.apache.karaf.shell.dev.framework.Framework;
 
 /**
  * Command for enabling/disabling debug logging on the OSGi framework
@@ -33,8 +29,6 @@ import org.apache.karaf.shell.dev.framew
 @Command(scope = "dev", name = "framework", description = "OSGi Framework options.")
 public class FrameworkOptions extends OsgiCommandSupport {
 
-    private static final String KARAF_BASE = System.getProperty("karaf.base");
-
     @Option(name = "-debug", aliases={"--enable-debug"}, description="Enable debug for the OSGi framework", required = false, multiValued = false)
     boolean debug;
 
@@ -43,52 +37,37 @@ public class FrameworkOptions extends Os
 
     @Argument(name = "framework", required = false, description = "Name of the OSGi framework to use")
     String framework;
+    
+    private DevService devService;
+    
+    public FrameworkOptions(DevService devService) {
+        this.devService = devService;
+    }
 
     @Override
     protected Object doExecute() throws Exception {
 
         if (!debug^nodebug && framework == null) {
-            System.out.printf("Current OSGi framework is %s%n", getFramework().getName());
+            System.out.printf("Current OSGi framework is %s%n", devService.getFramework().name());
             return null;
         }
-        Framework frwk = null;
         if (framework != null) {
-            if (!Felix.NAME.equalsIgnoreCase(framework) && !Equinox.NAME.equalsIgnoreCase(framework)) {
-                System.err.printf("Unsupported framework: %s%n", framework);
-                return null;
-            }
-            if (Felix.NAME.equalsIgnoreCase(framework))
-                frwk = new Felix(new File(KARAF_BASE));
-            else
-                frwk = new Equinox(new File(KARAF_BASE));
-            Properties props = new Properties(new File(System.getProperty("karaf.base"), "etc/config.properties"));
-            props.put("karaf.framework", framework.toLowerCase());
-            props.save();
-            System.out.println("Changed OSGi framework to " + framework.toLowerCase() + ". Karaf needs to be restarted to make the change effective");
+            FrameworkType frameworkType = FrameworkType.valueOf(framework);
+            devService.setFramework(frameworkType);
+            System.out.println("Changed OSGi framework to " + frameworkType.toString().toLowerCase() + ". Karaf needs to be restarted to make the change effective");
         }
         if (debug) {
-            if (frwk == null)
-                frwk = getFramework();
-            System.out.printf("Enabling debug for OSGi framework (%s)%n", frwk.getName());
-            frwk.enableDebug(new File(KARAF_BASE));
+            FrameworkType frameworkType = devService.getFramework();
+            System.out.printf("Enabling debug for OSGi framework (%s)%n", frameworkType.name());
+            devService.setFrameworkDebug(true);
         }
         if (nodebug) {
-            if (frwk == null)
-                frwk = getFramework();
-            System.out.printf("Disabling debug for OSGi framework (%s)%n", frwk.getName());
-            frwk.disableDebug(new File(KARAF_BASE));
+            FrameworkType frameworkType = devService.getFramework();
+            System.out.printf("Disabling debug for OSGi framework (%s)%n", frameworkType.name());
+            devService.setFrameworkDebug(false);
         }
 
         return null;
     }
 
-
-    public Framework getFramework() {
-        if (bundleContext.getBundle(0).getSymbolicName().contains("felix")) {
-            return new Felix(new File(KARAF_BASE));
-        } else {
-            return new Equinox(new File(KARAF_BASE));
-        }
-    }
-
 }

Modified: karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/PrintStackTraces.java
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/PrintStackTraces.java?rev=1309898&r1=1309676&r2=1309898&view=diff
==============================================================================
--- karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/PrintStackTraces.java (original)
+++ karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/PrintStackTraces.java Thu Apr  5 15:21:55 2012
@@ -14,16 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.karaf.shell.dev;
+package org.apache.karaf.dev.command;
 
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
 import org.apache.karaf.shell.console.jline.Console;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static java.lang.String.format;
 
 /**
  * Command for showing the full tree of bundles that have been used to resolve
@@ -32,8 +28,6 @@ import static java.lang.String.format;
 @Command(scope = "dev", name = "stack-traces-print", description = "Prints the full stack trace in the console when the execution of a command throws an exception.")
 public class PrintStackTraces extends OsgiCommandSupport {
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(PrintStackTraces.class);
-
     @Argument(name = "print", description="Print stack traces or not", required = false, multiValued = false)
     boolean print = true;
 

Modified: karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/ShowBundleTree.java
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/ShowBundleTree.java?rev=1309898&r1=1309676&r2=1309898&view=diff
==============================================================================
--- karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/ShowBundleTree.java (original)
+++ karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/ShowBundleTree.java Thu Apr  5 15:21:55 2012
@@ -14,7 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.karaf.shell.dev;
+package org.apache.karaf.dev.command;
+
+import static java.lang.String.format;
 
 import java.util.Collection;
 import java.util.HashMap;
@@ -27,10 +29,10 @@ import org.apache.felix.utils.manifest.C
 import org.apache.felix.utils.manifest.Parser;
 import org.apache.felix.utils.version.VersionRange;
 import org.apache.felix.utils.version.VersionTable;
+import org.apache.karaf.dev.command.bundletree.Node;
+import org.apache.karaf.dev.command.bundletree.Tree;
+import org.apache.karaf.dev.core.DevService;
 import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.dev.util.Bundles;
-import org.apache.karaf.shell.dev.util.Node;
-import org.apache.karaf.shell.dev.util.Tree;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.wiring.BundleCapability;
@@ -41,8 +43,6 @@ import org.osgi.framework.wiring.BundleW
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static java.lang.String.format;
-
 /**
  * Command for showing the full tree of bundles that have been used to resolve
  * a given bundle.
@@ -54,6 +54,12 @@ public class ShowBundleTree extends Abst
 
     private Tree<Bundle> tree;
 
+    private final DevService devService;
+    
+    public ShowBundleTree(DevService devService) {
+        this.devService = devService;
+    }
+
     @Override
     protected void doExecute(Bundle bundle) throws Exception {
         long start = System.currentTimeMillis();
@@ -66,6 +72,21 @@ public class ShowBundleTree extends Abst
         LOGGER.debug(format("Dependency tree calculated in %d ms",
                             System.currentTimeMillis() - start));
     }
+    
+    /**
+     * Return a String representation of a bundle state
+     */
+    private String getState(Bundle bundle) {
+        switch (bundle.getState()) {
+            case Bundle.UNINSTALLED : return "UNINSTALLED";
+            case Bundle.INSTALLED : return "INSTALLED";
+            case Bundle.RESOLVED: return "RESOLVED";
+            case Bundle.STARTING : return "STARTING";
+            case Bundle.STOPPING : return "STOPPING";
+            case Bundle.ACTIVE : return "ACTIVE";
+            default : return "UNKNOWN";
+        }
+    }
 
     /*
      * Print the header
@@ -74,7 +95,7 @@ public class ShowBundleTree extends Abst
         System.out.printf("Bundle %s [%s] is currently %s%n",
                 bundle.getSymbolicName(),
                 bundle.getBundleId(),
-                Bundles.toString(bundle.getState()));
+                getState(bundle));
     }
 
     /*
@@ -144,7 +165,7 @@ public class ShowBundleTree extends Abst
     /*
      * Creates nodes for the imports of the bundle (instead of reporting wiring information
      */
-    private void createNodesForImports(Node node, Bundle bundle) {
+    private void createNodesForImports(Node<Bundle> node, Bundle bundle) {
         Clause[] imports = Parser.parseHeader(bundle.getHeaders().get("Import-Package"));
         Clause[] exports = Parser.parseHeader(bundle.getHeaders().get("Export-Package"));
         for (Clause i : imports) {
@@ -164,7 +185,7 @@ public class ShowBundleTree extends Abst
     /*
      * Create a child node for a given import (by finding a matching export in the currently installed bundles)
      */
-    private void createNodeForImport(Node node, Bundle bundle, Clause i) {
+    private void createNodeForImport(Node<Bundle> node, Bundle bundle, Clause i) {
         VersionRange range = VersionRange.parseVersionRange(i.getAttribute(Constants.VERSION_ATTRIBUTE));
         boolean foundMatch = false;
         for (Bundle b : bundleContext.getBundles()) {
@@ -180,7 +201,7 @@ public class ShowBundleTree extends Abst
                             System.out.printf("- import %s: resolved using %s%n", i, b);
                             foundMatch = true;
                             if (!node.hasChild(b)) {
-                                Node child = node.addChild(b);
+                                Node<Bundle> child = node.addChild(b);
                                 if (!existing) {
                                     createNode(child);
                                 }
@@ -191,7 +212,7 @@ public class ShowBundleTree extends Abst
             }
         }
         if (!foundMatch) {
-            System.out.printf("- import %s: WARNING - unable to find matching export%n", i);            
+            System.out.printf("- import %s: WARNING - unable to find matching export%n", i);
         }
     }
 
@@ -206,7 +227,7 @@ public class ShowBundleTree extends Abst
     private void createNode(Node<Bundle> node) {
         Bundle bundle = node.getValue();
         Collection<Bundle> exporters = new HashSet<Bundle>();
-        exporters.addAll(getWiredBundles(bundle).values());
+        exporters.addAll(devService.getWiredBundles(bundle).values());
 
         for (Bundle exporter : exporters) {
             if (node.hasAncestor(exporter)) {                
@@ -214,7 +235,7 @@ public class ShowBundleTree extends Abst
             } else {
                 boolean existing = tree.flatten().contains(exporter);
                 LOGGER.debug(format("Adding %s as a dependency for %s", exporter, bundle));
-                Node child = node.addChild(exporter);
+                Node<Bundle> child = node.addChild(exporter);
                 if (existing) {
                     LOGGER.debug(format("Skipping children of %s (already exists in another branch)", exporter));
                 } else {

Modified: karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/SystemProperty.java
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/SystemProperty.java?rev=1309898&r1=1309676&r2=1309898&view=diff
==============================================================================
--- karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/SystemProperty.java (original)
+++ karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/SystemProperty.java Thu Apr  5 15:21:55 2012
@@ -14,14 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.karaf.shell.dev;
-
-import java.io.File;
+package org.apache.karaf.dev.command;
 
+import org.apache.karaf.dev.core.DevService;
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.commands.Option;
-import org.apache.felix.utils.properties.Properties;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
 
 /**
@@ -39,16 +37,16 @@ public class SystemProperty extends Osgi
     @Argument(index = 1, name = "value", required = false, description = "New value for the system property")
     String value;
 
+    private DevService devService;
+    
+    public SystemProperty(DevService devService) {
+        this.devService = devService;
+    }
+
     @Override
     protected Object doExecute() throws Exception {
         if (value != null) {
-            if (persistent) {
-                String base = System.getProperty("karaf.base");
-                Properties props = new Properties(new File(base, "etc/system.properties"));
-                props.put(key, value);
-                props.save();
-            }
-            return System.setProperty(key, value);
+            return devService.setSystemProperty(key, value, persistent);
         } else {
             return System.getProperty(key);
         }

Modified: karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/Watch.java
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/Watch.java?rev=1309898&r1=1309676&r2=1309898&view=diff
==============================================================================
--- karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/Watch.java (original)
+++ karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/Watch.java Thu Apr  5 15:21:55 2012
@@ -14,19 +14,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.karaf.shell.dev;
+package org.apache.karaf.dev.command;
 
 import java.util.List;
 
+import org.apache.karaf.dev.core.BundleWatcher;
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.commands.Option;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.dev.watch.BundleWatcher;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 
-@Command(scope = "dev", name = "watch", description = "Watches and updates bundles.", detailedDescription="classpath:watch.txt")
+@Command(scope = "dev", name = "watch", description = "Watches and updates bundles", detailedDescription = "Watches the local maven repo for changes in snapshot jars and redploys changed jars")
 public class Watch extends OsgiCommandSupport {
 
     @Argument(index = 0, name = "urls", description = "The bundle IDs or URLs", required = false, multiValued = true)
@@ -48,6 +48,10 @@ public class Watch extends OsgiCommandSu
     protected boolean list;
 
     private BundleWatcher watcher;
+    
+    public Watch(BundleWatcher watcher) {
+        this.watcher = watcher;
+    }
 
     @Override
     protected Object doExecute() throws Exception {
@@ -109,13 +113,6 @@ public class Watch extends OsgiCommandSu
         return null;
     }
 
-    public BundleWatcher getWatcher() {
-        return watcher;
-    }
-
-    public void setWatcher(BundleWatcher watcher) {
-        this.watcher = watcher;
-    }
 }
 
 

Modified: karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/bundletree/Node.java
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/bundletree/Node.java?rev=1309898&r1=1309676&r2=1309898&view=diff
==============================================================================
--- karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/bundletree/Node.java (original)
+++ karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/bundletree/Node.java Thu Apr  5 15:21:55 2012
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.karaf.shell.dev.util;
+package org.apache.karaf.dev.command.bundletree;
 
 import java.io.PrintWriter;
 import java.util.HashSet;
@@ -23,7 +23,7 @@ import java.util.List;
 import java.util.Set;
 
 /**
- * Represents a node in a {@link org.apache.karaf.shell.dev.util.Tree}
+ * Represents a node in a {@link Tree}
  */
 public class Node<T> {
     
@@ -73,8 +73,8 @@ public class Node<T> {
      * @param value the child's value
      * @return the child node
      */
-    public Node addChild(T value) {
-        Node node = new Node(value, this);
+    public Node<T> addChild(T value) {
+        Node<T> node = new Node<T>(value, this);
         children.add(node);
         return node;
     }

Modified: karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/bundletree/Tree.java
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/bundletree/Tree.java?rev=1309898&r1=1309676&r2=1309898&view=diff
==============================================================================
--- karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/bundletree/Tree.java (original)
+++ karaf/trunk/dev/command/src/main/java/org/apache/karaf/dev/command/bundletree/Tree.java Thu Apr  5 15:21:55 2012
@@ -14,13 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.karaf.shell.dev.util;
+package org.apache.karaf.dev.command.bundletree;
 
-import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
 import java.io.PrintWriter;
-import java.util.HashSet;
-import java.util.Set;
 
 /**
  * Represents a tree that can be written to the console.

Copied: karaf/trunk/dev/command/src/main/resources/OSGI-INF/blueprint/blueprint.xml (from r1309676, karaf/trunk/shell/dev/src/main/resources/OSGI-INF/blueprint/shell-dev.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/command/src/main/resources/OSGI-INF/blueprint/blueprint.xml?p2=karaf/trunk/dev/command/src/main/resources/OSGI-INF/blueprint/blueprint.xml&p1=karaf/trunk/shell/dev/src/main/resources/OSGI-INF/blueprint/shell-dev.xml&r1=1309676&r2=1309898&rev=1309898&view=diff
==============================================================================
--- karaf/trunk/shell/dev/src/main/resources/OSGI-INF/blueprint/shell-dev.xml (original)
+++ karaf/trunk/dev/command/src/main/resources/OSGI-INF/blueprint/blueprint.xml Thu Apr  5 15:21:55 2012
@@ -21,33 +21,36 @@
 
     <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
         <command>
-            <action class="org.apache.karaf.shell.dev.ShowBundleTree"/>
+            <action class="org.apache.karaf.dev.command.ShowBundleTree">
+                <argument ref="devService"/>
+            </action>
         </command>
         <command>
-            <action class="org.apache.karaf.shell.dev.FrameworkOptions" />
+            <action class="org.apache.karaf.dev.command.FrameworkOptions" >
+                <argument ref="devService" />
+            </action>
         </command>
         <command>
-            <action class="org.apache.karaf.shell.dev.DynamicImport" />
+            <action class="org.apache.karaf.dev.command.DynamicImport">
+                <argument ref="devService" />
+            </action> 
         </command>
         <command>
-            <action class="org.apache.karaf.shell.dev.PrintStackTraces" />
+            <action class="org.apache.karaf.dev.command.PrintStackTraces" />
         </command>
         <command>
-            <action class="org.apache.karaf.shell.dev.SystemProperty" />
+            <action class="org.apache.karaf.dev.command.SystemProperty" >
+                <argument ref="devService" />
+            </action>
         </command>
         <command>
-            <action class="org.apache.karaf.shell.dev.Watch" >
-                <property name="watcher" ref="watcher"/>
+            <action class="org.apache.karaf.dev.command.Watch" >
+                <argument ref="watcher"/>
             </action>
         </command>
     </command-bundle>
-
-    <!-- Referenace to the Configuration Admin Service -->
-    <reference id="configurationAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/>
-
-    <bean id="watcher" class="org.apache.karaf.shell.dev.watch.BundleWatcher" init-method="start" destroy-method="stop">
-        <property name="bundleContext" ref="blueprintBundleContext"/>
-        <property name="configurationAdmin" ref="configurationAdmin"/>
-    </bean>
+    
+    <reference id="devService" interface="org.apache.karaf.dev.core.DevService"/>
+    <reference id="watcher" interface="org.apache.karaf.dev.core.BundleWatcher"/>
 
 </blueprint>

Modified: karaf/trunk/dev/command/src/test/java/org/apache/karaf/dev/command/bundletree/TreeTest.java
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/command/src/test/java/org/apache/karaf/dev/command/bundletree/TreeTest.java?rev=1309898&r1=1309676&r2=1309898&view=diff
==============================================================================
--- karaf/trunk/dev/command/src/test/java/org/apache/karaf/dev/command/bundletree/TreeTest.java (original)
+++ karaf/trunk/dev/command/src/test/java/org/apache/karaf/dev/command/bundletree/TreeTest.java Thu Apr  5 15:21:55 2012
@@ -14,7 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.karaf.shell.dev.util;
+package org.apache.karaf.dev.command.bundletree;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -23,10 +28,8 @@ import java.io.StringReader;
 import java.io.StringWriter;
 import java.util.Set;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import org.apache.karaf.dev.command.bundletree.Node;
+import org.apache.karaf.dev.command.bundletree.Tree;
 import org.junit.Test;
 
 /**

Modified: karaf/trunk/dev/core/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/core/pom.xml?rev=1309898&r1=1309676&r2=1309898&view=diff
==============================================================================
--- karaf/trunk/dev/core/pom.xml (original)
+++ karaf/trunk/dev/core/pom.xml Thu Apr  5 15:21:55 2012
@@ -1,37 +1,28 @@
 <?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">
+<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.
-    -->
+    <!-- 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.management.mbeans</groupId>
-        <artifactId>mbeans</artifactId>
+        <groupId>org.apache.karaf.dev</groupId>
+        <artifactId>dev</artifactId>
         <version>3.0.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
-    <artifactId>org.apache.karaf.management.mbeans.dev</artifactId>
+    <artifactId>org.apache.karaf.dev.core</artifactId>
     <packaging>bundle</packaging>
-    <name>Apache Karaf :: Management :: MBeans :: Dev</name>
-    <description>This bundle provides a JMX MBean for dev utils actions.</description>
+    <name>Apache Karaf :: Dev :: Core</name>
+    <description>Core Services and MBeans for developer support</description>
 
     <properties>
         <appendedResourcesDirectory>${basedir}../../../etc/appended-resources/</appendedResourcesDirectory>
@@ -39,11 +30,32 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-wrap</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-aether</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.karaf</groupId>
             <artifactId>org.apache.karaf.main</artifactId>
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.utils</artifactId>
         </dependency>
@@ -72,22 +84,28 @@
                 <configuration>
                     <instructions>
                         <Export-Package>
-                            org.apache.karaf.management.mbeans.dev;version=${project.version}
+                            org.apache.karaf.dev.core
                         </Export-Package>
-                        <Import-Package>
-                            !org.apache.karaf.management.mbeans.dev,
-                            javax.management,
-                            javax.management.loading,
-                            org.apache.aries.blueprint,
-                            org.osgi.service.blueprint.container,
-                            org.osgi.service.blueprint.reflect,
-                            org.apache.karaf.management;version=${project.version},
-                            *
-                        </Import-Package>
+<!--                         <Import-Package> -->
+<!--                             !junit.framework, -->
+<!--                             !org.cyberneko.html, -->
+<!--                             !org.cyberneko.html.filters, -->
+<!--                             !com.sun.jdmk.comm, -->
+<!--                             !javax.management, -->
+<!--                             !javax.crypto, -->
+<!--                             !javax.crypto.spec, -->
+<!--                             !org.apache.avalon.framework.logger, -->
+<!--                             !org.apache.log, -->
+<!--                             !org.apache.xerces.xni, -->
+<!--                             !org.apache.xerces.xni.parser, -->
+<!--                             !org.objectweb.asm* -->
+<!--                         </Import-Package> -->
                         <Private-Package>
-                            org.apache.karaf.management.mbeans.dev.internal,
+                            org.apache.karaf.dev.core.internal,
+                            org.apache.felix.utils.properties
+                            org.apache.felix.utils.manifest,
+                            org.apache.felix.utils.version,
                             org.apache.felix.utils.properties,
-                            !*
                         </Private-Package>
                     </instructions>
                 </configuration>

Added: karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/BundleWatcher.java
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/BundleWatcher.java?rev=1309898&view=auto
==============================================================================
--- karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/BundleWatcher.java (added)
+++ karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/BundleWatcher.java Thu Apr  5 15:21:55 2012
@@ -0,0 +1,57 @@
+/*
+ * Licensed 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.dev.core;
+
+import java.util.List;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleEvent;
+
+public interface BundleWatcher {
+
+    void bundleChanged(BundleEvent event);
+
+    /**
+     * Adds a Bundle URLs to the watch list.
+     * 
+     * @param url
+     */
+    void add(String url);
+
+    /**
+     * Removes a bundle URLs from the watch list.
+     * 
+     * @param url
+     */
+    void remove(String url);
+
+    /**
+     * Returns the bundles that match
+     * 
+     * @param url
+     * @return
+     */
+    List<Bundle> getBundlesByURL(String url);
+
+    List<String> getWatchURLs();
+
+    void setWatchURLs(List<String> watchURLs);
+
+    void start();
+
+    void stop();
+
+    void setInterval(long interval);
+
+}

Modified: karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/DevMBean.java
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/DevMBean.java?rev=1309898&r1=1309676&r2=1309898&view=diff
==============================================================================
--- karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/DevMBean.java (original)
+++ karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/DevMBean.java Thu Apr  5 15:21:55 2012
@@ -11,9 +11,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.karaf.management.mbeans.dev;
+package org.apache.karaf.dev.core;
 
-import java.util.List;
 
 /**
  * MBean providing dev actions.
@@ -26,23 +25,26 @@ public interface DevMBean {
      * @return the name of the OSGi framework in use.
      * @throws Exception
      */
-    String framework() throws Exception;
+    String getFramework();
 
     /**
-     * OSGi framework options.
+     * change OSGi framework
      *
-     * @param debug enable debug of the OSGi framework to use.
-     * @param framework name of the OSGI framework to use.
-     * @throws Exception
+     * @param framework to use.
+     */
+    void setFramework(String framework);
+    
+    /**
+     * Enable or diable debgging
+     * @param debug enable if true
      */
-    void frameworkOptions(boolean debug, String framework) throws Exception;
+    void setFrameworkDebug(boolean debug);
 
     /**
-     * Restart Karaf, with eventually a cleanup.
-     *
-     * @param clean if true, Karaf is cleanup, false else.
-     * @throws Exception
+     * Restart Karaf and optionally clean the bundles
+     * 
+     * @param clean all bundle states if true
      */
-    void restart(boolean clean) throws Exception;
+    void restart(boolean clean);
 
 }

Added: karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/DevService.java
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/DevService.java?rev=1309898&view=auto
==============================================================================
--- karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/DevService.java (added)
+++ karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/DevService.java Thu Apr  5 15:21:55 2012
@@ -0,0 +1,63 @@
+/*
+ * Licensed 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.dev.core;
+
+import java.util.Map;
+
+import org.osgi.framework.Bundle;
+
+
+public interface DevService {
+    /**
+     * Get the current OSGi framework in use.
+     *
+     * @return the name of the OSGi framework in use.
+     * @throws Exception
+     */
+    FrameworkType getFramework();
+    
+    /**
+     * change OSGi framework
+     *
+     * @param framework to use.
+     */
+    void setFramework(FrameworkType framework);
+    
+    /**
+     * Enable or diable debgging
+     * @param debug enable if true
+     */
+    void setFrameworkDebug(boolean debug);
+
+    /**
+     * Restart Karaf and optionally clean the bundles
+     * 
+     * @param clean all bundle states if true
+     */
+    void restart(boolean clean);
+
+    /**
+     * Set a system property and persist to etc/system.properties
+     * @param key
+     */
+    String setSystemProperty(String key, String value, boolean persist);
+    
+    boolean isDynamicImport(Bundle bundle);
+
+    void enableDynamicImports(Bundle bundle);
+
+    void disableDynamicImports(Bundle bundle);
+    
+    Map<String, Bundle> getWiredBundles(Bundle bundle);
+}

Added: karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/FrameworkType.java
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/FrameworkType.java?rev=1309898&view=auto
==============================================================================
--- karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/FrameworkType.java (added)
+++ karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/FrameworkType.java Thu Apr  5 15:21:55 2012
@@ -0,0 +1,19 @@
+/*
+ * Licensed 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.dev.core;
+
+public enum FrameworkType {
+    felix,
+    equinox
+}

Copied: karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/internal/BundleWatcherImpl.java (from r1309676, karaf/trunk/shell/dev/src/main/java/org/apache/karaf/shell/dev/watch/BundleWatcher.java)
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/internal/BundleWatcherImpl.java?p2=karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/internal/BundleWatcherImpl.java&p1=karaf/trunk/shell/dev/src/main/java/org/apache/karaf/shell/dev/watch/BundleWatcher.java&r1=1309676&r2=1309898&rev=1309898&view=diff
==============================================================================
--- karaf/trunk/shell/dev/src/main/java/org/apache/karaf/shell/dev/watch/BundleWatcher.java (original)
+++ karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/internal/BundleWatcherImpl.java Thu Apr  5 15:21:55 2012
@@ -14,10 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.karaf.shell.dev.watch;
+package org.apache.karaf.dev.core.internal;
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
@@ -30,18 +31,18 @@ import java.util.concurrent.CopyOnWriteA
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.karaf.dev.core.BundleWatcher;
 import org.ops4j.pax.url.maven.commons.MavenConfiguration;
 import org.ops4j.pax.url.maven.commons.MavenConfigurationImpl;
 import org.ops4j.pax.url.maven.commons.MavenRepositoryURL;
-import org.ops4j.pax.url.mvn.ServiceConstants;
 import org.ops4j.pax.url.mvn.Parser;
+import org.ops4j.pax.url.mvn.ServiceConstants;
 import org.ops4j.util.property.DictionaryPropertyResolver;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.BundleListener;
-import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.packageadmin.PackageAdmin;
@@ -49,30 +50,38 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * A Runnable singleton which watches at the defined location for bundle updates.
+ * A Runnable singleton which watches at the defined location for bundle
+ * updates.
  */
-public class BundleWatcher implements Runnable, BundleListener {
+public class BundleWatcherImpl implements Runnable, BundleListener, BundleWatcher {
 
-    private final Logger logger = LoggerFactory.getLogger(BundleWatcher.class);
+    private final Logger logger = LoggerFactory.getLogger(BundleWatcherImpl.class);
 
     private BundleContext bundleContext;
     private ConfigurationAdmin configurationAdmin;
+    private final PackageAdmin packageAdmin;
 
     private AtomicBoolean running = new AtomicBoolean(false);
     private long interval = 1000L;
     private List<String> watchURLs = new CopyOnWriteArrayList<String>();
     private AtomicInteger counter = new AtomicInteger(0);
 
-
     /**
      * Constructor
      */
-    public BundleWatcher() {
+    @SuppressWarnings("deprecation")
+    public BundleWatcherImpl(BundleContext bundleContext, ConfigurationAdmin configurationAdmin, PackageAdmin packageAdmin) {
+        this.bundleContext = bundleContext;
+        this.configurationAdmin = configurationAdmin;
+        this.packageAdmin = packageAdmin;
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.karaf.dev.core.internal.BundleWatcher#bundleChanged(org.osgi.framework.BundleEvent)
+     */
+    @Override
     public void bundleChanged(BundleEvent event) {
-        if (event.getType() == BundleEvent.INSTALLED
-                || event.getType() == BundleEvent.UNINSTALLED) {
+        if (event.getType() == BundleEvent.INSTALLED || event.getType() == BundleEvent.UNINSTALLED) {
             counter.incrementAndGet();
         }
     }
@@ -81,7 +90,7 @@ public class BundleWatcher implements Ru
         logger.debug("Bundle watcher thread started");
         int oldCounter = -1;
         Set<Bundle> watchedBundles = new HashSet<Bundle>();
-        while (running.get() && watchURLs.size()>0) {
+        while (running.get() && watchURLs.size() > 0) {
             if (oldCounter != counter.get()) {
                 oldCounter = counter.get();
                 watchedBundles.clear();
@@ -91,42 +100,19 @@ public class BundleWatcher implements Ru
                     }
                 }
             }
-            if (watchedBundles.size()>0) {
+            if (watchedBundles.size() > 0) {
                 File localRepository = getLocalRepository();
                 List<Bundle> updated = new ArrayList<Bundle>();
                 for (Bundle bundle : watchedBundles) {
                     try {
-                        File location = getBundleExternalLocation(localRepository, bundle);
-                        if (location != null
-                                && location.exists()
-                                && location.lastModified() > bundle.getLastModified())
-                        {
-                            InputStream is = new FileInputStream(location);
-                            try {
-                                logger.info("[Watch] Updating watched bundle: " + bundle.getSymbolicName() + " (" + bundle.getVersion() + ")");
-                                System.out.println("[Watch] Updating watched bundle: " + bundle.getSymbolicName() + " (" + bundle.getVersion() + ")");
-                                bundle.update(is);
-                                updated.add(bundle);
-                            } finally {
-                                is.close();
-                            }
-                        }
+                        updateBundleIfNecessary(localRepository, updated, bundle);
                     } catch (IOException ex) {
                         logger.error("Error watching bundle.", ex);
                     } catch (BundleException ex) {
                         logger.error("Error updating bundle.", ex);
                     }
                 }
-                ServiceReference ref = null;
-                try {
-                    ref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
-                    PackageAdmin pa = (PackageAdmin) getBundleContext().getService(ref);
-                    pa.refreshPackages(updated.toArray(new Bundle[updated.size()]));
-                } finally {
-                    if (ref != null) {
-                        getBundleContext().ungetService(ref);
-                    }
-                }
+                packageAdmin.refreshPackages(updated.toArray(new Bundle[updated.size()]));
             }
             try {
                 Thread.sleep(interval);
@@ -140,12 +126,28 @@ public class BundleWatcher implements Ru
         }
     }
 
-    /**
-     * Adds a Bundle URLs to the watch list.
-     * @param url
+    private void updateBundleIfNecessary(File localRepository, List<Bundle> updated, Bundle bundle)
+        throws FileNotFoundException, BundleException, IOException {
+        File location = getBundleExternalLocation(localRepository, bundle);
+        if (location != null && location.exists() && location.lastModified() > bundle.getLastModified()) {
+            InputStream is = new FileInputStream(location);
+            try {
+                logger.info("[Watch] Updating watched bundle: " + bundle.getSymbolicName() + " ("
+                            + bundle.getVersion() + ")");
+                bundle.update(is);
+                updated.add(bundle);
+            } finally {
+                is.close();
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.karaf.dev.core.internal.BundleWatcher#add(java.lang.String)
      */
+    @Override
     public void add(String url) {
-        boolean shouldStart = running.get() && (watchURLs.size()==0);
+        boolean shouldStart = running.get() && (watchURLs.size() == 0);
         if (!watchURLs.contains(url)) {
             watchURLs.add(url);
             counter.incrementAndGet();
@@ -156,10 +158,10 @@ public class BundleWatcher implements Ru
         }
     }
 
-    /**
-     * Removes a bundle URLs from the watch list.
-     * @param url
+    /* (non-Javadoc)
+     * @see org.apache.karaf.dev.core.internal.BundleWatcher#remove(java.lang.String)
      */
+    @Override
     public void remove(String url) {
         watchURLs.remove(url);
         counter.incrementAndGet();
@@ -167,10 +169,11 @@ public class BundleWatcher implements Ru
 
     /**
      * Returns the location of the Bundle inside the local maven repository.
+     * 
      * @param bundle
      * @return
      */
-    public File getBundleExternalLocation(File localRepository, Bundle bundle) {
+    private File getBundleExternalLocation(File localRepository, Bundle bundle) {
         try {
             Parser p = new Parser(bundle.getLocation().substring(4));
             return new File(localRepository.getPath() + File.separator + p.getArtifactPath());
@@ -180,7 +183,7 @@ public class BundleWatcher implements Ru
         return null;
     }
 
-    public File getLocalRepository() {
+    private File getLocalRepository() {
         // Attempt to retrieve local repository location from MavenConfiguration
         MavenConfiguration configuration = retrieveMavenConfiguration();
         if (configuration != null) {
@@ -194,7 +197,7 @@ public class BundleWatcher implements Ru
         return new File(localRepo).getAbsoluteFile();
     }
 
-    protected MavenConfiguration retrieveMavenConfiguration() {
+    private MavenConfiguration retrieveMavenConfiguration() {
         MavenConfiguration mavenConfiguration = null;
         try {
             Configuration configuration = configurationAdmin.getConfiguration(ServiceConstants.PID);
@@ -206,16 +209,15 @@ public class BundleWatcher implements Ru
                 }
             }
         } catch (IOException e) {
-            logger.error("Error retrieving maven configuration",e);
+            logger.error("Error retrieving maven configuration", e);
         }
         return mavenConfiguration;
     }
 
-    /**
-     * Returns the bundles that match
-     * @param url
-     * @return
+    /* (non-Javadoc)
+     * @see org.apache.karaf.dev.core.internal.BundleWatcher#getBundlesByURL(java.lang.String)
      */
+    @Override
     public List<Bundle> getBundlesByURL(String url) {
         List<Bundle> bundleList = new ArrayList<Bundle>();
         try {
@@ -235,18 +237,18 @@ public class BundleWatcher implements Ru
         return bundleList;
     }
 
-    protected boolean isMavenSnapshotUrl(String url) {
+    private boolean isMavenSnapshotUrl(String url) {
         return url.startsWith("mvn:") && url.contains("SNAPSHOT");
     }
 
     /**
      * Matches text using a pattern containing wildcards.
-     *
+     * 
      * @param text
      * @param pattern
      * @return
      */
-    protected boolean wildCardMatch(String text, String pattern) {
+    private boolean wildCardMatch(String text, String pattern) {
         String[] cards = pattern.split("\\*");
         // Iterate over the cards.
         for (String card : cards) {
@@ -262,13 +264,11 @@ public class BundleWatcher implements Ru
         return true;
     }
 
-
     public void start() {
-        // register the bundle listener
         bundleContext.addBundleListener(this);
         // start the watch thread
         if (running.compareAndSet(false, true)) {
-            if (watchURLs.size()>0) {
+            if (watchURLs.size() > 0) {
                 Thread thread = new Thread(this);
                 thread.start();
             }
@@ -280,30 +280,21 @@ public class BundleWatcher implements Ru
      */
     public void stop() {
         running.set(false);
-        // unregister the bundle listener
         bundleContext.removeBundleListener(this);
     }
 
-    public ConfigurationAdmin getConfigurationAdmin() {
-        return configurationAdmin;
-    }
-
-    public void setConfigurationAdmin(ConfigurationAdmin configurationAdmin) {
-        this.configurationAdmin = configurationAdmin;
-    }
-
-    public BundleContext getBundleContext() {
-        return bundleContext;
-    }
-
-    public void setBundleContext(BundleContext bundleContext) {
-        this.bundleContext = bundleContext;
-    }
-
+    /* (non-Javadoc)
+     * @see org.apache.karaf.dev.core.internal.BundleWatcher#getWatchURLs()
+     */
+    @Override
     public List<String> getWatchURLs() {
         return watchURLs;
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.karaf.dev.core.internal.BundleWatcher#setWatchURLs(java.util.List)
+     */
+    @Override
     public void setWatchURLs(List<String> watchURLs) {
         this.watchURLs = watchURLs;
     }

Copied: karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/internal/Dev.java (from r1309676, karaf/trunk/management/mbeans/dev/src/main/java/org/apache/karaf/management/mbeans/dev/internal/DevMBeanImpl.java)
URL: http://svn.apache.org/viewvc/karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/internal/Dev.java?p2=karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/internal/Dev.java&p1=karaf/trunk/management/mbeans/dev/src/main/java/org/apache/karaf/management/mbeans/dev/internal/DevMBeanImpl.java&r1=1309676&r2=1309898&rev=1309898&view=diff
==============================================================================
--- karaf/trunk/management/mbeans/dev/src/main/java/org/apache/karaf/management/mbeans/dev/internal/DevMBeanImpl.java (original)
+++ karaf/trunk/dev/core/src/main/java/org/apache/karaf/dev/core/internal/Dev.java Thu Apr  5 15:21:55 2012
@@ -11,76 +11,47 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.karaf.management.mbeans.dev.internal;
-
-import org.apache.felix.utils.properties.Properties;
-import org.apache.karaf.management.mbeans.dev.DevMBean;
-import org.osgi.framework.BundleContext;
+package org.apache.karaf.dev.core.internal;
 
 import javax.management.NotCompliantMBeanException;
 import javax.management.StandardMBean;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.util.Scanner;
+
+import org.apache.karaf.dev.core.DevMBean;
+import org.apache.karaf.dev.core.DevService;
+import org.apache.karaf.dev.core.FrameworkType;
 
 /**
  * Implementation of the DevMBean.
  */
-public class DevMBeanImpl extends StandardMBean implements DevMBean {
+public class Dev extends StandardMBean implements DevMBean {
 
-    private BundleContext bundleContext;
+    private final DevService devService;
 
-    public DevMBeanImpl() throws NotCompliantMBeanException {
+    public Dev(DevService devService) throws NotCompliantMBeanException {
         super(DevMBean.class);
+        this.devService = devService;
     }
 
-    public BundleContext getBundleContext() {
-        return this.bundleContext;
+    @Override
+    public String getFramework() {
+        return this.devService.getFramework().toString();
     }
-
-    public void setBundleContext(BundleContext bundleContext) {
-        this.bundleContext = bundleContext;
+    
+    @Override
+    public void setFramework(String framework) {
+        this.devService.setFramework(FrameworkType.valueOf(framework.toLowerCase()));
     }
 
-    public String framework() throws Exception {
-        if (bundleContext.getBundle(0).getSymbolicName().contains("felix")) {
-            return "Felix";
-        } else {
-            return "Equinox";
-        }
+    @Override
+    public void setFrameworkDebug(boolean debug) {
+        this.devService.setFrameworkDebug(debug);
     }
 
-    public void frameworkOptions(boolean debug, String framework) throws Exception {
-        Properties properties = new Properties(new File(System.getProperty("karaf.base"), "etc/config.properties"));
-        if (framework != null) {
-            // swtich the framework is use
-            if (!framework.equalsIgnoreCase("felix") && !framework.equalsIgnoreCase("equinox")) {
-                throw new IllegalArgumentException("Unsupported framework " + framework);
-            }
-            properties.put("karaf.framework", framework.toLowerCase());
-        }
-        if (framework == null) {
-            if (bundleContext.getBundle(0).getSymbolicName().contains("felix")) {
-                framework = "felix";
-            } else {
-                framework = "equinox";
-            }
-        }
-        if (framework.equals("felix")) {
-            properties.put("felix.log.level", "4");
-        } else {
-            properties.put("osgi.debug", "etc/equinox-debug.properties");
-            // TODO populate the equinox-debug.properties file with the one provided in shell/dev module
-        }
-        properties.save();
+    @Override
+    public void restart(boolean clean) {
+        this.devService.restart(clean);
     }
 
-    public void restart(boolean clean) throws Exception {
-        System.setProperty("karaf.restart", "true");
-        System.setProperty("karaf.restart.clean", Boolean.toString(clean));
-        bundleContext.getBundle(0).stop();
-    }
+ 
 
 }