geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r557828 - in /geronimo/server/trunk: assemblies/geronimo-jetty6-jee5/src/main/resources/var/config/ configs/rmi-naming/src/plan/ modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/
Date Fri, 20 Jul 2007 00:51:26 GMT
Author: djencks
Date: Thu Jul 19 17:51:24 2007
New Revision: 557828

URL: http://svn.apache.org/viewvc?view=rev&rev=557828
Log:
GERONIMO-3335 make it easy for the local maven repo to be a plugin repo

Modified:
    geronimo/server/trunk/assemblies/geronimo-jetty6-jee5/src/main/resources/var/config/config.xml
    geronimo/server/trunk/configs/rmi-naming/src/plan/plan.xml
    geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryDownloader.java

Modified: geronimo/server/trunk/assemblies/geronimo-jetty6-jee5/src/main/resources/var/config/config.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-jetty6-jee5/src/main/resources/var/config/config.xml?view=diff&rev=557828&r1=557827&r2=557828
==============================================================================
--- geronimo/server/trunk/assemblies/geronimo-jetty6-jee5/src/main/resources/var/config/config.xml
(original)
+++ geronimo/server/trunk/assemblies/geronimo-jetty6-jee5/src/main/resources/var/config/config.xml
Thu Jul 19 17:51:24 2007
@@ -36,7 +36,7 @@
         </gbean>
         <gbean name="DownloadedPluginRepos">
           <attribute name="repositoryList">http://geronimo.apache.org/plugins/plugin-repository-list-2.0.txt</attribute>
-          <attribute name="userRepositories">[]</attribute>
+          <attribute name="userRepositories">~/.m2/repository</attribute>
         </gbean>
     </module>
 

Modified: geronimo/server/trunk/configs/rmi-naming/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/rmi-naming/src/plan/plan.xml?view=diff&rev=557828&r1=557827&r2=557828
==============================================================================
--- geronimo/server/trunk/configs/rmi-naming/src/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/rmi-naming/src/plan/plan.xml Thu Jul 19 17:51:24 2007
@@ -81,6 +81,7 @@
 
     <gbean name="DownloadedPluginRepos" class="org.apache.geronimo.system.plugin.PluginRepositoryDownloader">
         <attribute name="repositoryList">http://geronimo.apache.org/plugins/plugin-repository-list-2.0.txt</attribute>
+        <attribute name="userRepositories">~/.m2/repository</attribute>
     </gbean>
     
 </module>

Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryDownloader.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryDownloader.java?view=diff&rev=557828&r1=557827&r2=557828
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryDownloader.java
(original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryDownloader.java
Thu Jul 19 17:51:24 2007
@@ -16,19 +16,23 @@
  */
 package org.apache.geronimo.system.plugin;
 
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.util.List;
-import java.util.ArrayList;
 import java.io.BufferedReader;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.Kernel;
 
 /**
  * An implementation of PluginRepositoryList that downloads plugins from
@@ -38,15 +42,15 @@
  */
 public class PluginRepositoryDownloader implements PluginRepositoryList {
     private final static Log log = LogFactory.getLog(PluginRepositoryDownloader.class);
-    private List downloadRepositories = new ArrayList();
-    private List userRepositories = new ArrayList();
+    private List<String> downloadRepositories = new ArrayList<String>();
+    private List<String> userRepositories = new ArrayList<String>();
     private Kernel kernel;
     private AbstractName name;
     private URL repositoryList;
 
-    public PluginRepositoryDownloader(List downloadRepositories, List userRepositories, URL
repositoryList, Kernel kernel, AbstractName name) {
-        if(downloadRepositories != null) this.downloadRepositories = downloadRepositories;
-        if(userRepositories != null) this.userRepositories = userRepositories;
+    public PluginRepositoryDownloader(List<String> downloadRepositories, List<String>
userRepositories, URL repositoryList, Kernel kernel, AbstractName name) {
+        if (downloadRepositories != null) this.downloadRepositories = downloadRepositories;
+        if (userRepositories != null) this.userRepositories = userRepositories;
         this.repositoryList = repositoryList;
         this.kernel = kernel;
         this.name = name;
@@ -55,41 +59,56 @@
     /**
      * The list of repositories that were downloaded from central.
      */
-    public void setDownloadRepositories(List downloadRepositories) {
+    public void setDownloadRepositories(List<String> downloadRepositories) {
         this.downloadRepositories = downloadRepositories;
-        if(this.downloadRepositories == null) this.downloadRepositories = new ArrayList();
+        if (this.downloadRepositories == null) this.downloadRepositories = new ArrayList<String>();
     }
 
     /**
      * Any repositories that the user added manually
      */
-    public void setUserRepositories(List userRepositories) {
+    public void setUserRepositories(List<String> userRepositories) {
         this.userRepositories = userRepositories;
-        if(this.userRepositories == null) this.userRepositories = new ArrayList();
+        if (this.userRepositories == null) this.userRepositories = new ArrayList<String>();
     }
 
     /**
      * Gets the union of centrally-listed repositories and user-added repositories.
      */
     public URL[] getRepositories() {
-        List list = new ArrayList();
-        for (int i = 0; i < downloadRepositories.size(); i++) {
-            String url = (String) downloadRepositories.get(i);
+        List<URL> list = new ArrayList<URL>();
+        for (String url : downloadRepositories) {
             try {
                 list.add(new URL(url.trim()));
             } catch (MalformedURLException e) {
-                log.error("Unable to format plugin repository URL "+url, e);
+                log.error("Unable to format plugin repository URL " + url, e);
             }
         }
-        for (int i = 0; i < userRepositories.size(); i++) {
-            String url = (String) userRepositories.get(i);
+        for (String userRepository : userRepositories) {
+            userRepository = userRepository.trim();
             try {
-                list.add(new URL(url.trim()));
+                URI uri = new URI(userRepository);
+                if (uri.getScheme() == null) {
+                    if (uri.isAbsolute()) {
+                        URL url = new URI("file", userRepository, null).toURL();
+                        list.add(url);
+                    } else if (userRepository.startsWith("~")) {
+                        userRepository = userRepository.substring(2);
+                        URI fullUri = new URI("file", System.getProperty("user.home") + "/",
null).resolve(userRepository);
+                        list.add(fullUri.toURL());
+                    } else {
+                        log.error("Can't interpret path: " + userRepository);
+                    }
+                } else {
+                    list.add(uri.toURL());
+                }
             } catch (MalformedURLException e) {
-                log.error("Unable to format plugin repository URL "+url, e);
+                log.error("Unable to format plugin repository URL " + userRepository, e);
+            } catch (URISyntaxException e) {
+                log.error("Unable to format plugin repository URL " + userRepository, e);
             }
         }
-        return (URL[]) list.toArray(new URL[list.size()]);
+        return list.toArray(new URL[list.size()]);
     }
 
     /**
@@ -100,15 +119,16 @@
         try {
             in = new BufferedReader(new InputStreamReader(repositoryList.openStream()));
             String line;
-            List list = new ArrayList();
-            while((line = in.readLine()) != null) {
+            List<String> list = new ArrayList<String>();
+            while ((line = in.readLine()) != null) {
                 line = line.trim();
-                if(!line.equals("") && !line.startsWith("#")) {
+                if (!line.equals("") && !line.startsWith("#")) {
                     list.add(line);
                 }
             }
             in.close();
             in = null;
+            //this saves the new value in config.xml
             kernel.setAttribute(name, "downloadRepositories", list);
         } catch (Exception e) {
             log.error("Unable to save download repositories", e);
@@ -116,7 +136,8 @@
             if (in != null) {
                 try {
                     in.close();
-                } catch (IOException ignored) {}
+                } catch (IOException ignored) {
+                }
             }
         }
     }
@@ -144,7 +165,7 @@
         infoFactory.addAttribute("kernel", Kernel.class, false);
         infoFactory.addAttribute("abstractName", AbstractName.class, false);
         infoFactory.addInterface(PluginRepositoryList.class);
-        infoFactory.setConstructor(new String[]{"downloadRepositories","userRepositories","repositoryList","kernel","abstractName"});
+        infoFactory.setConstructor(new String[]{"downloadRepositories", "userRepositories",
"repositoryList", "kernel", "abstractName"});
 
         GBEAN_INFO = infoFactory.getBeanInfo();
     }



Mime
View raw message