servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r641902 - in /servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main: java/org/apache/geronimo/gshell/obr/RefreshUrlCommand.java resources/META-INF/spring/gshell-obr.xml
Date Thu, 27 Mar 2008 17:09:56 GMT
Author: gnodet
Date: Thu Mar 27 10:09:49 2008
New Revision: 641902

URL: http://svn.apache.org/viewvc?rev=641902&view=rev
Log:
SMX4KNL-20: Command to refresh OBR repositories

Added:
    servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/RefreshUrlCommand.java
      - copied, changed from r641731, servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/ListUrlCommand.java
Modified:
    servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main/resources/META-INF/spring/gshell-obr.xml

Copied: servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/RefreshUrlCommand.java
(from r641731, servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/ListUrlCommand.java)
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/RefreshUrlCommand.java?p2=servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/RefreshUrlCommand.java&p1=servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/ListUrlCommand.java&r1=641731&r2=641902&rev=641902&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/ListUrlCommand.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main/java/org/apache/geronimo/gshell/obr/RefreshUrlCommand.java
Thu Mar 27 10:09:49 2008
@@ -16,22 +16,36 @@
  */
 package org.apache.geronimo.gshell.obr;
 
+import java.net.URL;
+import java.util.List;
+
+import org.apache.geronimo.gshell.clp.Argument;
 import org.apache.geronimo.gshell.command.annotation.CommandComponent;
 import org.osgi.service.obr.Repository;
 import org.osgi.service.obr.RepositoryAdmin;
 
-@CommandComponent(id="obr:listUrl", description="Display the repository URLs currently associated
with the repository service.")
-public class ListUrlCommand extends ObrCommandSupport {
+@CommandComponent(id="obr:refreshUrl", description="Refresh a list of repository URLs to
the repository service")
+public class RefreshUrlCommand extends ObrCommandSupport {
+
+    @Argument(required = false, multiValued = true, description = "Repository URLs (leave
empty for all)")
+    List<String> urls;
+
 
-    protected void doExecute(RepositoryAdmin admin) {
-        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.");
-        }
+    protected void doExecute(RepositoryAdmin admin) throws Exception {
+		if (urls != null || urls.isEmpty()) {
+			for (String url : urls) {
+				admin.removeRepository(new URL(url));
+				admin.addRepository(new URL(url));
+			}
+		} else {
+			Repository[] repos = admin.listRepositories();
+			if ((repos != null) && (repos.length > 0)) {
+				for (int i = 0; i < repos.length; i++) {
+					admin.removeRepository(repos[i].getURL());
+					admin.addRepository(repos[i].getURL());
+				}
+			}
+		}
     }
 
 }

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main/resources/META-INF/spring/gshell-obr.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main/resources/META-INF/spring/gshell-obr.xml?rev=641902&r1=641901&r2=641902&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main/resources/META-INF/spring/gshell-obr.xml
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-obr/src/main/resources/META-INF/spring/gshell-obr.xml
Thu Mar 27 10:09:49 2008
@@ -41,6 +41,8 @@
 
     <bean id="removeUrl" class="org.apache.geronimo.gshell.obr.RemoveUrlCommand" />
 
+    <bean id="refreshUrl" class="org.apache.geronimo.gshell.obr.RefreshUrlCommand" />
+
     <bean id="source" class="org.apache.geronimo.gshell.obr.SourceCommand" />
 
     <bean id="start" class="org.apache.geronimo.gshell.obr.StartCommand" />
@@ -84,6 +86,13 @@
       <osgi:service-properties>
         <entry key="shell" value="obr"/>
         <entry key="alias" value="removeUrl"/>
+      </osgi:service-properties>
+    </osgi:service>
+
+    <osgi:service ref="refreshUrl" interface="org.apache.geronimo.gshell.command.Command">
+      <osgi:service-properties>
+        <entry key="shell" value="obr"/>
+        <entry key="alias" value="refreshUrl"/>
       </osgi:service-properties>
     </osgi:service>
 



Mime
View raw message