You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/12/12 15:09:30 UTC

svn commit: r603618 - in /servicemix/smx4/runtime/trunk: assembly/ assembly/src/main/descriptors/ assembly/src/main/distribution/text/etc/ gshell/ gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/ gshell/gshell-features/ gshell/gshell...

Author: gnodet
Date: Wed Dec 12 06:09:20 2007
New Revision: 603618

URL: http://svn.apache.org/viewvc?rev=603618&view=rev
Log:
Add commands hooks

Added:
    servicemix/smx4/runtime/trunk/assembly/src/main/distribution/text/etc/org.apache.servicemix.features.cfg
    servicemix/smx4/runtime/trunk/gshell/gshell-features/   (with props)
    servicemix/smx4/runtime/trunk/gshell/gshell-features/pom.xml
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Feature.java
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/CommandProxy.java
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeatureImpl.java
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/AddUrlCommand.java
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/FeaturesCommandSupport.java
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/ListUrlCommand.java
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RemoveUrlCommand.java
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/resources/
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/resources/META-INF/
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/resources/META-INF/spring/
    servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/resources/META-INF/spring/gshell-features.xml
Modified:
    servicemix/smx4/runtime/trunk/assembly/pom.xml
    servicemix/smx4/runtime/trunk/assembly/src/main/descriptors/unix-bin.xml
    servicemix/smx4/runtime/trunk/assembly/src/main/descriptors/windows-bin.xml
    servicemix/smx4/runtime/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java
    servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/DeployCommand.java
    servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/ObrCommandSupport.java
    servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/StartCommand.java
    servicemix/smx4/runtime/trunk/gshell/pom.xml

Modified: servicemix/smx4/runtime/trunk/assembly/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/assembly/pom.xml?rev=603618&r1=603617&r2=603618&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/assembly/pom.xml (original)
+++ servicemix/smx4/runtime/trunk/assembly/pom.xml Wed Dec 12 06:09:20 2007
@@ -104,6 +104,11 @@
           <artifactId>org.apache.servicemix.runtime.gshell.osgi</artifactId>
           <version>0.1-SNAPSHOT</version>
       </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.runtime.gshell</groupId>
+            <artifactId>org.apache.servicemix.runtime.gshell.features</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
       <dependency>
           <groupId>org.apache.servicemix.bundles</groupId>
           <artifactId>org.apache.servicemix.bundles.mina-${mina.version}</artifactId>

Modified: servicemix/smx4/runtime/trunk/assembly/src/main/descriptors/unix-bin.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/assembly/src/main/descriptors/unix-bin.xml?rev=603618&r1=603617&r2=603618&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/assembly/src/main/descriptors/unix-bin.xml (original)
+++ servicemix/smx4/runtime/trunk/assembly/src/main/descriptors/unix-bin.xml Wed Dec 12 06:09:20 2007
@@ -120,6 +120,7 @@
 		        <!-- OBR + GShell command -->
                 <include>org.apache.felix:org.apache.felix.bundlerepository</include>
                 <include>org.apache.servicemix.runtime.gshell:org.apache.servicemix.runtime.gshell.obr</include>
+                <include>org.apache.servicemix.runtime.gshell:org.apache.servicemix.runtime.gshell.features</include>
 
             </includes>
         </dependencySet>

Modified: servicemix/smx4/runtime/trunk/assembly/src/main/descriptors/windows-bin.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/assembly/src/main/descriptors/windows-bin.xml?rev=603618&r1=603617&r2=603618&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/assembly/src/main/descriptors/windows-bin.xml (original)
+++ servicemix/smx4/runtime/trunk/assembly/src/main/descriptors/windows-bin.xml Wed Dec 12 06:09:20 2007
@@ -112,6 +112,7 @@
 		        <!-- OBR + GShell command -->
                 <include>org.apache.felix:org.apache.felix.bundlerepository</include>
                 <include>org.apache.servicemix.runtime.gshell:org.apache.servicemix.runtime.gshell.obr</include>
+                <include>org.apache.servicemix.runtime.gshell:org.apache.servicemix.runtime.gshell.features</include>
 
             </includes>
         </dependencySet>

Added: servicemix/smx4/runtime/trunk/assembly/src/main/distribution/text/etc/org.apache.servicemix.features.cfg
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/assembly/src/main/distribution/text/etc/org.apache.servicemix.features.cfg?rev=603618&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/assembly/src/main/distribution/text/etc/org.apache.servicemix.features.cfg (added)
+++ servicemix/smx4/runtime/trunk/assembly/src/main/distribution/text/etc/org.apache.servicemix.features.cfg Wed Dec 12 06:09:20 2007
@@ -0,0 +1,21 @@
+################################################################################
+#
+#    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.
+#
+################################################################################
+
+#
+featuresRepositories=file:///Users/gnodet/work/servicemix/smx4/obr-repo/features.xml

Modified: servicemix/smx4/runtime/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java?rev=603618&r1=603617&r2=603618&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java (original)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java Wed Dec 12 06:09:20 2007
@@ -48,7 +48,7 @@
 
     private Environment env;
 
-    private Layout layout = new Layout();
+    private MutableLayout layout = new MutableLayout();
 
     public SpringCommandRegistry(Environment env) {
         this.env = env;
@@ -64,38 +64,77 @@
             name = (String) properties.get("name");
         }
 
+        // Find rank
+        int rank = 0;
+        if (properties.containsKey("rank")) {
+            rank = Integer.parseInt((String) properties.get("rank"));
+        }
+
         // Find or create the subshell group
         GroupNode gn = layout;
         String shell = (String) properties.get("shell");
         String[] aliases = properties.get("alias") != null ? properties.get("alias").toString().split(",") : new String[0];
-        if (shell != null && shell.length() > 0) {
+
+        if (name.equals(shell))
+        {
             Node n = gn.find(shell);
-            if (n == null) {
-                GroupNode g = new GroupNode(shell);
-                gn.add(g);
-                register(new GroupCommand(shell, g));
-                gn = g;
-            } else if (n instanceof GroupNode) {
-                gn = (GroupNode) n;
-            } else {
-                throw new IllegalStateException("A command conflicts has been detected when registering " + command.getId());
+            MutableGroupNode g = new MutableGroupNode(shell);
+            gn.add(g);
+            register(command);
+        }
+        else
+        {
+            if (shell != null && shell.length() > 0) {
+                Node n = gn.find(shell);
+                if (n == null) {
+                    MutableGroupNode g = new MutableGroupNode(shell);
+                    gn.add(g);
+                    register(new GroupCommand(shell, g));
+                    gn = g;
+                } else if (n instanceof GroupNode) {
+                    gn = (GroupNode) n;
+                } else {
+                    throw new IllegalStateException("A command conflicts has been detected when registering " + command.getId());
+                }
             }
-        }
 
-        CommandNode cn = new CommandNode(name, command.getId());
-        gn.add(cn);
+            CommandNode cn = new CommandNode(name, command.getId());
+            gn.add(cn);
 
-        for (int i = 0; i < aliases.length; i++) {
-            if (!name.equals(aliases[i])) {
-                AliasNode an = new AliasNode(aliases[i], ALIAS_PREFIX + command.getId());
-                gn.add(an);
+            for (int i = 0; i < aliases.length; i++) {
+                if (!name.equals(aliases[i])) {
+                    AliasNode an = new AliasNode(aliases[i], ALIAS_PREFIX + command.getId());
+                    gn.add(an);
+                }
             }
-        }
 
-        register(command);
+            register(command);
+        }
     }
 
     public void unregister(final Command command, Map<String, ?> properties) throws NotRegisteredException {
+        // Find command name
+        String name = command.getId();
+        if (name.lastIndexOf(':') >= 0) {
+            name = name.substring(name.lastIndexOf(':') + 1);
+        }
+        if (properties.containsKey("name")) {
+            name = (String) properties.get("name");
+        }
+        String shell = (String) properties.get("shell");
+
+        if (name.equals(shell) || shell == null || shell.length() == 0) {
+            Node n = layout.find(name);
+            layout.removeNode(n);
+        } else {
+            MutableGroupNode gn = (MutableGroupNode) layout.find(shell);
+            Node n = gn.find(name);
+            gn.removeNode(n);
+            if (gn.size() == 0) {
+                layout.removeNode(gn);
+            }
+        }
+
         unregister(command);
     }
 
@@ -182,5 +221,25 @@
             }
             return SUCCESS;
         }
+    }
+
+    public static class MutableLayout extends Layout {
+
+        public void removeNode(Node n) {
+            nodes.remove(n);
+        }
+
+    }
+
+    public static class MutableGroupNode extends GroupNode {
+
+        public MutableGroupNode(String name) {
+            super(name);
+        }
+
+        public void removeNode(Node n) {
+            nodes.remove(n);
+        }
+
     }
 }

Propchange: servicemix/smx4/runtime/trunk/gshell/gshell-features/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Dec 12 06:09:20 2007
@@ -0,0 +1,8 @@
+target
+*.iml
+*.iws
+*.ipr
+.classpath
+.project
+.settings
+eclipse-classes

Added: servicemix/smx4/runtime/trunk/gshell/gshell-features/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-features/pom.xml?rev=603618&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-features/pom.xml (added)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-features/pom.xml Wed Dec 12 06:09:20 2007
@@ -0,0 +1,90 @@
+<?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/maven-v4_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.servicemix.runtime.gshell</groupId>
+        <artifactId>gshell</artifactId>
+        <version>0.1-SNAPSHOT</version>
+    </parent>
+
+    <groupId>org.apache.servicemix.runtime.gshell</groupId>
+    <artifactId>org.apache.servicemix.runtime.gshell.features</artifactId>
+    <packaging>bundle</packaging>
+    <name>ServiceMix Runtime :: GShell Features</name>
+
+    <description>
+        Provides Features in GShell
+    </description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>${felix.osgi.version}</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.bundlerepository</artifactId>
+            <version>${felix.bundlerepository.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.servicemix.runtime.gshell</groupId>
+            <artifactId>org.apache.servicemix.runtime.gshell.core</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.servicemix.runtime.gshell</groupId>
+            <artifactId>org.apache.servicemix.runtime.gshell.obr</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.osgi</groupId>
+            <artifactId>spring-osgi-core</artifactId>
+            <version>${spring.osgi.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
+                        <Export-Package>org.apache.servicemix.gshell.features*;version=${project.version}</Export-Package>
+                        <Import-Package>*</Import-Package>
+                        <Private-Package>!*</Private-Package>
+                        <Spring-Context>*;publish-context:=false</Spring-Context>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file

Added: servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Feature.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Feature.java?rev=603618&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Feature.java (added)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Feature.java Wed Dec 12 06:09:20 2007
@@ -0,0 +1,28 @@
+/*
+ * 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.servicemix.gshell.features;
+
+/**
+ * A feature is a list of bundles associated identified by its name.
+ */
+public interface Feature {
+
+    String getName();
+
+    String[] getBundles();
+
+}

Added: servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java?rev=603618&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java (added)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java Wed Dec 12 06:09:20 2007
@@ -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.servicemix.gshell.features;
+
+import java.net.URL;
+
+/**
+ * The service managing features repositories.
+ */
+public interface FeaturesService {
+
+    void addRepository(URL url) throws Exception;
+
+    void removeRepository(URL url);
+
+    Repository[] listRepositories();
+}

Added: servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java?rev=603618&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java (added)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java Wed Dec 12 06:09:20 2007
@@ -0,0 +1,30 @@
+/*
+ * 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.servicemix.gshell.features;
+
+import java.net.URL;
+
+/**
+ * A repository of features.
+ */
+public interface Repository {
+
+    URL getURL();
+
+    Feature[] getFeatures();
+
+}

Added: servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/CommandProxy.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/CommandProxy.java?rev=603618&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/CommandProxy.java (added)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/CommandProxy.java Wed Dec 12 06:09:20 2007
@@ -0,0 +1,84 @@
+/*
+ * 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.servicemix.gshell.features.internal;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Arrays;
+import java.util.Properties;
+
+import org.apache.geronimo.gshell.command.Command;
+import org.apache.geronimo.gshell.obr.ObrCommandSupport;
+import org.apache.geronimo.gshell.support.OsgiCommandSupport;
+import org.apache.servicemix.gshell.features.Feature;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.obr.RepositoryAdmin;
+
+/**
+ * Simple command which prompts the user and installs the needed bundles.
+ * The bundles need to be available through the OBR repositories.
+ */
+public class CommandProxy extends ObrCommandSupport {
+
+    private Feature feature;
+    private ServiceRegistration registration;
+
+    public CommandProxy(Feature feature, BundleContext bundleContext) {
+        this.feature = feature;
+        setBundleContext(bundleContext);
+        Properties props = new Properties();
+        props.put("shell", feature.getName());
+        props.put("rank", "-1");
+        registration = bundleContext.registerService(Command.class.getName(), this, props);
+    }
+
+    protected OsgiCommandSupport createCommand() {
+        return this;
+    }
+
+    @Deprecated
+    public String getId() {
+        return feature.getName();
+    }
+
+    @Deprecated
+    public String getDescription() {
+        return feature.getName();
+    }
+
+    protected void doExecute(RepositoryAdmin admin) throws Exception {
+        io.out.println("This feature is not yet installed.  Do you want to install it (y/n) ? ");
+        int c = io.in.read();
+        if (c == 'y' || c == 'Y') {
+            io.out.println("Installing feature.  Please wait...");
+            registration.unregister();
+            doDeploy(admin, Arrays.asList(feature.getBundles()), true);
+        }
+    }
+
+    private String readLine(Reader in) throws IOException {
+        StringBuffer buf = new StringBuffer();
+        while (true) {
+            int i = in.read();
+            if ((i == -1) || (i == '\n') || (i == '\r')) {
+                return buf.toString();
+            }
+            buf.append((char) i);
+        }
+    }
+}

Added: servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeatureImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeatureImpl.java?rev=603618&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeatureImpl.java (added)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeatureImpl.java Wed Dec 12 06:09:20 2007
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.gshell.features.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.servicemix.gshell.features.Feature;
+
+/**
+ * A feature
+ */
+public class FeatureImpl implements Feature {
+
+    private String name;
+    private List<String> bundles = new ArrayList<String>();
+
+    public FeatureImpl(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String[] getBundles() {
+        return bundles.toArray(new String[bundles.size()]);
+    }
+
+    public void addBundle(String bundle) {
+        bundles.add(bundle);
+    }
+}

Added: servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java?rev=603618&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java (added)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java Wed Dec 12 06:09:20 2007
@@ -0,0 +1,106 @@
+/*
+ * 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.servicemix.gshell.features.internal;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.geronimo.gshell.command.Command;
+import org.apache.servicemix.gshell.features.Feature;
+import org.apache.servicemix.gshell.features.FeaturesService;
+import org.apache.servicemix.gshell.features.Repository;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.obr.RepositoryAdmin;
+import org.springframework.osgi.context.BundleContextAware;
+
+/**
+ * The Features service implementation.
+ * Adding a repository url will load the features contained in this repository and
+ * create dummy sub shells.  When invoked, these commands will prompt the user for
+ * installing the needed bundles.
+ *
+ */
+public class FeaturesServiceImpl implements FeaturesService, BundleContextAware {
+
+    private BundleContext bundleContext;
+    private RepositoryAdmin admin;
+    private Set<URL> urls;
+    private Map<URL, RepositoryImpl> repositories = new HashMap<URL, RepositoryImpl>();
+
+    public BundleContext getBundleContext() {
+        return bundleContext;
+    }
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+    public RepositoryAdmin getAdmin() {
+        return admin;
+    }
+
+    public void setAdmin(RepositoryAdmin admin) {
+        this.admin = admin;
+    }
+
+    public void setUrls(String urls) throws MalformedURLException {
+        String[] s = urls.split(",");
+        this.urls = new HashSet<URL>();
+        for (int i = 0; i < s.length; i++) {
+            this.urls.add(new URL(s[i]));
+        }
+    }
+
+    public void addRepository(URL url) throws Exception {
+        RepositoryImpl repo = new RepositoryImpl(url);
+        repo.load();
+        Feature[] features = repo.getFeatures();
+        for (int i = 0; i < features.length; i++) {
+            CommandProxy cmd = new CommandProxy(features[i], bundleContext);
+        }
+        repositories.put(url, repo);
+    }
+
+    public void removeRepository(URL url) {
+        Repository repo = repositories.remove(url);
+        // TODO: ...
+    }
+
+    public Repository[] listRepositories() {
+        return new Repository[0];  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public void start() throws Exception {
+        if (urls != null) {
+            for (URL url : urls) {
+                addRepository(url);
+            }
+        }
+    }
+
+    public void stop() throws Exception {
+        urls = new HashSet<URL>(repositories.keySet());
+        while (!repositories.isEmpty()) {
+            removeRepository(repositories.keySet().iterator().next());
+        }
+    }
+}

Added: servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java?rev=603618&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java (added)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java Wed Dec 12 06:09:20 2007
@@ -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.servicemix.gshell.features.internal;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import org.apache.servicemix.gshell.features.Feature;
+import org.apache.servicemix.gshell.features.Repository;
+
+/**
+ * The repository implementation.
+ */
+public class RepositoryImpl implements Repository {
+
+    private URL url;
+    private List<Feature> features = new ArrayList<Feature>();
+
+    public RepositoryImpl(URL url) {
+        this.url = url;
+    }
+
+    public URL getURL() {
+        return url;
+    }
+
+    public Feature[] getFeatures() {
+        return features.toArray(new Feature[features.size()]);
+    }
+
+    public void load() throws Exception {
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        Document doc = factory.newDocumentBuilder().parse(url.openStream());
+        NodeList nodes = doc.getDocumentElement().getElementsByTagName("feature");
+        for (int i = 0; i < nodes.getLength(); i++) {
+            Element e = (Element) nodes.item(i);
+            String name = e.getAttribute("name");
+            FeatureImpl f = new FeatureImpl(name);
+            NodeList bundleNodes = e.getElementsByTagName("bundle");
+            for (int j = 0; j < bundleNodes.getLength(); j++) {
+                Element b = (Element) bundleNodes.item(j);
+                f.addBundle(b.getTextContent());
+            }
+            features.add(f);
+        }
+
+    }
+
+}

Added: servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/AddUrlCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/AddUrlCommand.java?rev=603618&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/AddUrlCommand.java (added)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/AddUrlCommand.java Wed Dec 12 06:09:20 2007
@@ -0,0 +1,37 @@
+/*
+ * 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.servicemix.gshell.features.internal.commands;
+
+import java.util.List;
+import java.net.URL;
+
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.command.annotation.CommandComponent;
+import org.apache.servicemix.gshell.features.FeaturesService;
+
+@CommandComponent(id="features:addUrl", description="Add a list of repository URLs to the features service")
+public class AddUrlCommand extends FeaturesCommandSupport {
+
+    @Argument(required = true, multiValued = true, description = "Repository URLs")
+    List<String> urls;
+
+    protected void doExecute(FeaturesService admin) throws Exception {
+        for (String url : urls) {
+            admin.addRepository(new URL(url));
+        }
+    }
+}

Added: servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/FeaturesCommandSupport.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/FeaturesCommandSupport.java?rev=603618&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/FeaturesCommandSupport.java (added)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/FeaturesCommandSupport.java Wed Dec 12 06:09:20 2007
@@ -0,0 +1,50 @@
+/*
+ * 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.servicemix.gshell.features.internal.commands;
+
+import org.apache.geronimo.gshell.support.OsgiCommandSupport;
+import org.apache.servicemix.gshell.features.FeaturesService;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.obr.RepositoryAdmin;
+
+public abstract class FeaturesCommandSupport extends OsgiCommandSupport {
+
+    protected Object doExecute() throws Exception {
+        // Get repository admin service.
+        ServiceReference ref = getBundleContext().getServiceReference(FeaturesService.class.getName());
+        if (ref == null) {
+            io.out.println("FeaturesService service is unavailable.");
+            return null;
+        }
+        try {
+            FeaturesService admin = (FeaturesService) getBundleContext().getService(ref);
+            if (admin == null) {
+                io.out.println("FeaturesService service is unavailable.");
+                return null;
+            }
+
+            doExecute(admin);
+        }
+        finally {
+            getBundleContext().ungetService(ref);
+        }
+        return null;
+    }
+
+    protected abstract void doExecute(FeaturesService admin) throws Exception;
+
+}

Added: servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/ListUrlCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/ListUrlCommand.java?rev=603618&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/ListUrlCommand.java (added)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/ListUrlCommand.java Wed Dec 12 06:09:20 2007
@@ -0,0 +1,36 @@
+/*
+ * 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.servicemix.gshell.features.internal.commands;
+
+import org.apache.servicemix.gshell.features.FeaturesService;
+import org.apache.servicemix.gshell.features.Repository;
+import org.apache.geronimo.gshell.command.annotation.CommandComponent;
+
+@CommandComponent(id="features:listUrl", description="Display the repository URLs currently associated with the features service.")
+public class ListUrlCommand extends FeaturesCommandSupport {
+
+    protected void doExecute(FeaturesService admin) throws Exception {
+        Repository[] repos = admin.listRepositories();
+        if ((repos != null) && (repos.length > 0)) {
+            for (int i = 0; i < repos.length; i++) {
+                io.out.println(repos[i].getURL());
+            }
+        } else {
+            io.out.println("No repository URLs are set.");
+        }
+    }
+}

Added: servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RemoveUrlCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RemoveUrlCommand.java?rev=603618&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RemoveUrlCommand.java (added)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RemoveUrlCommand.java Wed Dec 12 06:09:20 2007
@@ -0,0 +1,37 @@
+/*
+ * 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.servicemix.gshell.features.internal.commands;
+
+import java.util.List;
+import java.net.URL;
+
+import org.apache.geronimo.gshell.command.annotation.CommandComponent;
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.servicemix.gshell.features.FeaturesService;
+
+@CommandComponent(id="features:removeUrl", description="Remove a list of repository URLs from the features service")
+public class RemoveUrlCommand extends FeaturesCommandSupport {
+
+    @Argument(required = true, multiValued = true, description = "Repository URLs")
+    List<String> urls;
+
+    protected void doExecute(FeaturesService admin) throws Exception {
+        for (String url : urls) {
+            admin.removeRepository(new URL(url));
+        }
+    }
+}

Added: servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/resources/META-INF/spring/gshell-features.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/resources/META-INF/spring/gshell-features.xml?rev=603618&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/resources/META-INF/spring/gshell-features.xml (added)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-features/src/main/resources/META-INF/spring/gshell-features.xml Wed Dec 12 06:09:20 2007
@@ -0,0 +1,74 @@
+<?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.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:osgi="http://www.springframework.org/schema/osgi"
+       xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+  http://www.springframework.org/schema/beans
+  http://www.springframework.org/schema/beans/spring-beans.xsd
+  http://www.springframework.org/schema/util
+  http://www.springframework.org/schema/util/spring-util.xsd
+  http://www.springframework.org/schema/osgi
+  http://www.springframework.org/schema/osgi/spring-osgi.xsd
+  http://www.springframework.org/schema/osgi-compendium
+  http://www.springframework.org/schema/osgi/spring-osgi-compendium.xsd">
+
+    <bean id="addUrl" class="org.apache.servicemix.gshell.features.internal.commands.AddUrlCommand" />
+
+    <bean id="listUrl" class="org.apache.servicemix.gshell.features.internal.commands.ListUrlCommand" />
+
+    <bean id="removeUrl" class="org.apache.servicemix.gshell.features.internal.commands.RemoveUrlCommand" />
+
+    <bean id="featuresService" class="org.apache.servicemix.gshell.features.internal.FeaturesServiceImpl">
+        <property name="urls" value="${featuresRepositories}" />
+    </bean>
+
+    <osgi:service ref="addUrl" interface="org.apache.geronimo.gshell.command.Command">
+      <osgi:service-properties>
+        <entry key="shell" value="features"/>
+        <entry key="alias" value="addUrl"/>
+      </osgi:service-properties>
+    </osgi:service>
+
+    <osgi:service ref="listUrl" interface="org.apache.geronimo.gshell.command.Command">
+      <osgi:service-properties>
+        <entry key="shell" value="features"/>
+        <entry key="alias" value="listUrl"/>
+      </osgi:service-properties>
+    </osgi:service>
+
+    <osgi:service ref="removeUrl" interface="org.apache.geronimo.gshell.command.Command">
+      <osgi:service-properties>
+        <entry key="shell" value="features"/>
+        <entry key="alias" value="removeUrl"/>
+      </osgi:service-properties>
+    </osgi:service>
+
+    <osgi:service ref="featuresService" interface="org.apache.servicemix.gshell.features.FeaturesService" />
+
+    <osgix:property-placeholder persistent-id="org.apache.servicemix.features">
+        <osgix:default-properties>
+            <prop key="featuresRepositories"></prop>
+        </osgix:default-properties>
+    </osgix:property-placeholder>
+
+</beans>
\ No newline at end of file

Modified: servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/DeployCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/DeployCommand.java?rev=603618&r1=603617&r2=603618&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/DeployCommand.java (original)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/DeployCommand.java Wed Dec 12 06:09:20 2007
@@ -29,97 +29,10 @@
 public class DeployCommand extends ObrCommandSupport {
 
     @Argument(required = true, multiValued = true, description = "List of bundles")
-    List<String> bundles;
+    protected List<String> bundles;
 
     protected void doExecute(RepositoryAdmin admin) throws Exception {
-        doDeploy(admin, false);
-    }
-
-    protected void doDeploy(RepositoryAdmin admin, boolean start) throws Exception {
-        Resolver resolver = admin.resolver();
-        for (String bundle : bundles) {
-            String[] target = getTarget(bundle);
-            Resource resource = selectNewestVersion(searchRepository(admin, target[0], target[1]));
-            if (resource != null)
-            {
-                resolver.add(resource);
-            }
-            else
-            {
-                io.err.println("Unknown bundle - " + target[0]);
-            }
-        }
-        if ((resolver.getAddedResources() != null) &&
-            (resolver.getAddedResources().length > 0))
-        {
-            if (resolver.resolve())
-            {
-                io.out.println("Target resource(s):");
-                printUnderline(io.out, 19);
-                Resource[] resources = resolver.getAddedResources();
-                for (int resIdx = 0; (resources != null) && (resIdx < resources.length); resIdx++)
-                {
-                    io.out.println("   " + resources[resIdx].getPresentationName()
-                        + " (" + resources[resIdx].getVersion() + ")");
-                }
-                resources = resolver.getRequiredResources();
-                if ((resources != null) && (resources.length > 0))
-                {
-                    io.out.println("\nRequired resource(s):");
-                    printUnderline(io.out, 21);
-                    for (int resIdx = 0; resIdx < resources.length; resIdx++)
-                    {
-                        io.out.println("   " + resources[resIdx].getPresentationName()
-                            + " (" + resources[resIdx].getVersion() + ")");
-                    }
-                }
-                resources = resolver.getOptionalResources();
-                if ((resources != null) && (resources.length > 0))
-                {
-                    io.out.println("\nOptional resource(s):");
-                    printUnderline(io.out, 21);
-                    for (int resIdx = 0; resIdx < resources.length; resIdx++)
-                    {
-                        io.out.println("   " + resources[resIdx].getPresentationName()
-                            + " (" + resources[resIdx].getVersion() + ")");
-                    }
-                }
-
-                try
-                {
-                    io.out.print("\nDeploying...");
-                    resolver.deploy(start);
-                    io.out.println("done.");
-                }
-                catch (IllegalStateException ex)
-                {
-                    io.err.println(ex);
-                }
-            }
-            else
-            {
-                Requirement[] reqs = resolver.getUnsatisfiedRequirements();
-                if ((reqs != null) && (reqs.length > 0))
-                {
-                    io.out.println("Unsatisfied requirement(s):");
-                    printUnderline(io.out, 27);
-                    for (int reqIdx = 0; reqIdx < reqs.length; reqIdx++)
-                    {
-                        io.out.println("   " + reqs[reqIdx].getFilter());
-                        Resource[] resources = resolver.getResources(reqs[reqIdx]);
-                        for (int resIdx = 0; resIdx < resources.length; resIdx++)
-                        {
-                            io.out.println("      " + resources[resIdx].getPresentationName());
-                        }
-                    }
-                }
-                else
-                {
-                    io.out.println("Could not resolve targets.");
-                }
-            }
-        }
-
+        doDeploy(admin, bundles, false);
     }
 
 }

Modified: servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/ObrCommandSupport.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/ObrCommandSupport.java?rev=603618&r1=603617&r2=603618&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/ObrCommandSupport.java (original)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/ObrCommandSupport.java Wed Dec 12 06:09:20 2007
@@ -17,12 +17,15 @@
 package org.apache.geronimo.gshell.obr;
 
 import java.io.PrintWriter;
+import java.util.List;
 
 import org.apache.geronimo.gshell.support.OsgiCommandSupport;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.Version;
 import org.osgi.service.obr.RepositoryAdmin;
+import org.osgi.service.obr.Requirement;
+import org.osgi.service.obr.Resolver;
 import org.osgi.service.obr.Resource;
 
 /**
@@ -134,5 +137,92 @@
             out.print('-');
         }
         out.println("");
+    }
+
+    protected void doDeploy(RepositoryAdmin admin, List<String> bundles, boolean start) throws Exception {
+        Resolver resolver = admin.resolver();
+        for (String bundle : bundles) {
+            String[] target = getTarget(bundle);
+            Resource resource = selectNewestVersion(searchRepository(admin, target[0], target[1]));
+            if (resource != null)
+            {
+                resolver.add(resource);
+            }
+            else
+            {
+                io.err.println("Unknown bundle - " + target[0]);
+            }
+        }
+        if ((resolver.getAddedResources() != null) &&
+            (resolver.getAddedResources().length > 0))
+        {
+            if (resolver.resolve())
+            {
+                io.out.println("Target resource(s):");
+                printUnderline(io.out, 19);
+                Resource[] resources = resolver.getAddedResources();
+                for (int resIdx = 0; (resources != null) && (resIdx < resources.length); resIdx++)
+                {
+                    io.out.println("   " + resources[resIdx].getPresentationName()
+                        + " (" + resources[resIdx].getVersion() + ")");
+                }
+                resources = resolver.getRequiredResources();
+                if ((resources != null) && (resources.length > 0))
+                {
+                    io.out.println("\nRequired resource(s):");
+                    printUnderline(io.out, 21);
+                    for (int resIdx = 0; resIdx < resources.length; resIdx++)
+                    {
+                        io.out.println("   " + resources[resIdx].getPresentationName()
+                            + " (" + resources[resIdx].getVersion() + ")");
+                    }
+                }
+                resources = resolver.getOptionalResources();
+                if ((resources != null) && (resources.length > 0))
+                {
+                    io.out.println("\nOptional resource(s):");
+                    printUnderline(io.out, 21);
+                    for (int resIdx = 0; resIdx < resources.length; resIdx++)
+                    {
+                        io.out.println("   " + resources[resIdx].getPresentationName()
+                            + " (" + resources[resIdx].getVersion() + ")");
+                    }
+                }
+
+                try
+                {
+                    io.out.print("\nDeploying...");
+                    resolver.deploy(start);
+                    io.out.println("done.");
+                }
+                catch (IllegalStateException ex)
+                {
+                    io.err.println(ex);
+                }
+            }
+            else
+            {
+                Requirement[] reqs = resolver.getUnsatisfiedRequirements();
+                if ((reqs != null) && (reqs.length > 0))
+                {
+                    io.out.println("Unsatisfied requirement(s):");
+                    printUnderline(io.out, 27);
+                    for (int reqIdx = 0; reqIdx < reqs.length; reqIdx++)
+                    {
+                        io.out.println("   " + reqs[reqIdx].getFilter());
+                        Resource[] resources = resolver.getResources(reqs[reqIdx]);
+                        for (int resIdx = 0; resIdx < resources.length; resIdx++)
+                        {
+                            io.out.println("      " + resources[resIdx].getPresentationName());
+                        }
+                    }
+                }
+                else
+                {
+                    io.out.println("Could not resolve targets.");
+                }
+            }
+        }
+
     }
 }

Modified: servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/StartCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/StartCommand.java?rev=603618&r1=603617&r2=603618&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/StartCommand.java (original)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/StartCommand.java Wed Dec 12 06:09:20 2007
@@ -23,7 +23,7 @@
 public class StartCommand extends DeployCommand {
 
     protected void doExecute(RepositoryAdmin admin) throws Exception {
-        doDeploy(admin, true);
+        doDeploy(admin, bundles, true);
     }
 
 }

Modified: servicemix/smx4/runtime/trunk/gshell/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/pom.xml?rev=603618&r1=603617&r2=603618&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/pom.xml (original)
+++ servicemix/smx4/runtime/trunk/gshell/pom.xml Wed Dec 12 06:09:20 2007
@@ -38,6 +38,7 @@
         <module>gshell-osgi</module>
         <module>gshell-obr</module>
         <module>gshell-wrapper</module>
+        <module>gshell-features</module>
     </modules>
 
 </project>