servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r679691 - in /servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features: ./ internal/ internal/commands/
Date Fri, 25 Jul 2008 07:49:18 GMT
Author: gnodet
Date: Fri Jul 25 00:49:17 2008
New Revision: 679691

URL: http://svn.apache.org/viewvc?rev=679691&view=rev
Log:
SMX4KNL-64: The list of repositories for the features shell is not persisted across restart

Modified:
    servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java
    servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java
    servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java
    servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java
    servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/AddUrlCommand.java
    servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/ListUrlCommand.java
    servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RefreshUrlCommand.java
    servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RemoveUrlCommand.java

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java?rev=679691&r1=679690&r2=679691&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java
Fri Jul 25 00:49:17 2008
@@ -17,15 +17,16 @@
 package org.apache.servicemix.gshell.features;
 
 import java.net.URL;
+import java.net.URI;
 
 /**
  * The service managing features repositories.
  */
 public interface FeaturesService {
 
-    void addRepository(URL url) throws Exception;
+    void addRepository(URI url) throws Exception;
 
-    void removeRepository(URL url);
+    void removeRepository(URI url);
 
     Repository[] listRepositories();
 

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java?rev=679691&r1=679690&r2=679691&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java
Fri Jul 25 00:49:17 2008
@@ -18,13 +18,14 @@
 
 import java.io.IOException;
 import java.net.URL;
+import java.net.URI;
 
 /**
  * A repository of features.
  */
 public interface Repository {
 
-    URL getURL();
+    URI getURI();
 
     Feature[] getFeatures() throws Exception;
 

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java?rev=679691&r1=679690&r2=679691&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java
Fri Jul 25 00:49:17 2008
@@ -19,7 +19,8 @@
 import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -67,8 +68,8 @@
     private BundleContext bundleContext;
     private ConfigurationAdmin configAdmin;
     private PreferencesService preferences;
-    private Set<URL> urls;
-    private Map<URL, RepositoryImpl> repositories = new HashMap<URL, RepositoryImpl>();
+    private Set<URI> uris;
+    private Map<URI, RepositoryImpl> repositories = new HashMap<URI, RepositoryImpl>();
     private Map<String, Feature> features;
     private Map<String, Set<Long>> installed = new HashMap<String, Set<Long>>();
 
@@ -96,32 +97,32 @@
         this.preferences = preferences;
     }
 
-    public void setUrls(String urls) throws MalformedURLException {
-        String[] s = urls.split(",");
-        this.urls = new HashSet<URL>();
+    public void setUrls(String uris) throws URISyntaxException {
+        String[] s = uris.split(",");
+        this.uris = new HashSet<URI>();
         for (int i = 0; i < s.length; i++) {
-            this.urls.add(new URL(s[i]));
+            this.uris.add(new URI(s[i]));
         }
     }
 
-    public void addRepository(URL url) throws Exception {
-        internalAddRepository(url);
+    public void addRepository(URI uri) throws Exception {
+        internalAddRepository(uri);
         saveState();
     }
 
-    protected void internalAddRepository(URL url) throws Exception {
-        RepositoryImpl repo = new RepositoryImpl(url);
-        repositories.put(url, repo);
+    protected void internalAddRepository(URI uri) throws Exception {
+        RepositoryImpl repo = new RepositoryImpl(uri);
+        repositories.put(uri, repo);
         features = null;
     }
 
-    public void removeRepository(URL url) {
-        internalRemoveRepository(url);
+    public void removeRepository(URI uri) {
+        internalRemoveRepository(uri);
         saveState();
     }
 
-    public void internalRemoveRepository(URL url) {
-        repositories.remove(url);
+    public void internalRemoveRepository(URI uri) {
+        repositories.remove(uri);
         features = null;
     }
 
@@ -244,9 +245,9 @@
 
     public void start() throws Exception {
         if (!loadState()) {
-            if (urls != null) {
-                for (URL url : urls) {
-                    internalAddRepository(url);
+            if (uris != null) {
+                for (URI uri : uris) {
+                    internalAddRepository(uri);
                 }
             }
             saveState();
@@ -254,7 +255,7 @@
     }
 
     public void stop() throws Exception {
-        urls = new HashSet<URL>(repositories.keySet());
+        uris = new HashSet<URI>(repositories.keySet());
         while (!repositories.isEmpty()) {
             internalRemoveRepository(repositories.keySet().iterator().next());
         }
@@ -300,8 +301,8 @@
         try {
             Preferences prefs = preferences.getUserPreferences("FeaturesServiceState");
             if (prefs.nodeExists("repositories")) {
-                Set<URL> repositories = loadSet(prefs.node("repositories"));
-                for (URL repo : repositories) {
+                Set<URI> repositories = loadSet(prefs.node("repositories"));
+                for (URI repo : repositories) {
                     internalAddRepository(repo);
                 }
                 installed = loadMap(prefs.node("features"));
@@ -313,8 +314,8 @@
         return false;
     }
 
-    protected void saveSet(Preferences node, Set<URL> set) throws BackingStoreException
{
-        List<URL> l = new ArrayList<URL>(set);
+    protected void saveSet(Preferences node, Set<URI> set) throws BackingStoreException
{
+        List<URI> l = new ArrayList<URI>(set);
         node.clear();
         node.putInt("count", l.size());
         for (int i = 0; i < l.size(); i++) {
@@ -322,23 +323,15 @@
         }
     }
 
-    protected Set<URL> loadSet(Preferences node) {
-        Set<URL> l = new HashSet<URL>();
+    protected Set<URI> loadSet(Preferences node) {
+        Set<URI> l = new HashSet<URI>();
         int count = node.getInt("count", 0);
         for (int i = 0; i < count; i++) {
-            l.add(createURL(node.get("item." + i, null)));
+            l.add(URI.create(node.get("item." + i, null)));
         }
         return l;
     }
 
-    protected URL createURL(String url) {
-        try {
-            return new URL(url);
-        } catch (MalformedURLException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
     protected void saveMap(Preferences node, Map<String, Set<Long>> map) throws
BackingStoreException {
         node.clear();
         for (Map.Entry<String, Set<Long>> entry : map.entrySet()) {

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java?rev=679691&r1=679690&r2=679691&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java
Fri Jul 25 00:49:17 2008
@@ -19,6 +19,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.net.URL;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.List;
@@ -42,15 +43,15 @@
  */
 public class RepositoryImpl implements Repository {
 
-    private URL url;
+    private URI uri;
     private List<Feature> features;
 
-    public RepositoryImpl(URL url) {
-        this.url = url;
+    public RepositoryImpl(URI uri) {
+        this.uri = uri;
     }
 
-    public URL getURL() {
-        return url;
+    public URI getURI() {
+        return uri;
     }
 
     public Feature[] getFeatures() throws Exception {
@@ -64,7 +65,7 @@
         try {
             features = new ArrayList<Feature>();
             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-            Document doc = factory.newDocumentBuilder().parse(url.openStream());
+            Document doc = factory.newDocumentBuilder().parse(uri.toURL().openStream());
             NodeList nodes = doc.getDocumentElement().getChildNodes();
             for (int i = 0; i < nodes.getLength(); i++) {
                 Node node = nodes.item(i);

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/AddUrlCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/AddUrlCommand.java?rev=679691&r1=679690&r2=679691&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/AddUrlCommand.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/AddUrlCommand.java
Fri Jul 25 00:49:17 2008
@@ -17,7 +17,7 @@
 package org.apache.servicemix.gshell.features.internal.commands;
 
 import java.util.List;
-import java.net.URL;
+import java.net.URI;
 
 import org.apache.geronimo.gshell.clp.Argument;
 import org.apache.geronimo.gshell.command.annotation.CommandComponent;
@@ -31,7 +31,7 @@
 
     protected void doExecute(FeaturesService admin) throws Exception {
         for (String url : urls) {
-            admin.addRepository(new URL(url));
+            admin.addRepository(new URI(url));
         }
     }
 }

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/ListUrlCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/ListUrlCommand.java?rev=679691&r1=679690&r2=679691&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/ListUrlCommand.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/ListUrlCommand.java
Fri Jul 25 00:49:17 2008
@@ -27,7 +27,7 @@
         Repository[] repos = admin.listRepositories();
         if ((repos != null) && (repos.length > 0)) {
             for (int i = 0; i < repos.length; i++) {
-                io.out.println(repos[i].getURL());
+                io.out.println(repos[i].getURI());
             }
         } else {
             io.out.println("No repository URLs are set.");

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RefreshUrlCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RefreshUrlCommand.java?rev=679691&r1=679690&r2=679691&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RefreshUrlCommand.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RefreshUrlCommand.java
Fri Jul 25 00:49:17 2008
@@ -16,7 +16,7 @@
  */
 package org.apache.servicemix.gshell.features.internal.commands;
 
-import java.net.URL;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -35,13 +35,13 @@
         if (urls == null || urls.isEmpty()) {
             urls = new ArrayList<String>();
             for (Repository repo : admin.listRepositories()) {
-                urls.add(repo.getURL().toString());
+                urls.add(repo.getURI().toString());
             }
         }
-        for (String strUrl : urls) {
-            URL url = new URL(strUrl);
-            admin.removeRepository(url);
-            admin.addRepository(url);
+        for (String strUri : urls) {
+            URI uri = new URI(strUri);
+            admin.removeRepository(uri);
+            admin.addRepository(uri);
         }
     }
 }
\ No newline at end of file

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RemoveUrlCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RemoveUrlCommand.java?rev=679691&r1=679690&r2=679691&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RemoveUrlCommand.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/commands/RemoveUrlCommand.java
Fri Jul 25 00:49:17 2008
@@ -17,7 +17,7 @@
 package org.apache.servicemix.gshell.features.internal.commands;
 
 import java.util.List;
-import java.net.URL;
+import java.net.URI;
 
 import org.apache.geronimo.gshell.command.annotation.CommandComponent;
 import org.apache.geronimo.gshell.clp.Argument;
@@ -31,7 +31,7 @@
 
     protected void doExecute(FeaturesService admin) throws Exception {
         for (String url : urls) {
-            admin.removeRepository(new URL(url));
+            admin.removeRepository(new URI(url));
         }
     }
 }



Mime
View raw message