geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r377617 [2/2] - in /geronimo/branches/configid: applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/ applications/consol...
Date Tue, 14 Feb 2006 04:51:03 GMT
Modified: geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java?rev=377617&r1=377616&r2=377617&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java
(original)
+++ geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java
Mon Feb 13 20:50:59 2006
@@ -17,20 +17,18 @@
 package org.apache.geronimo.plugin.assembly;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URI;
-import java.net.URL;
-import java.net.MalformedURLException;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.FileWriteMonitor;
 import org.apache.geronimo.kernel.repository.Repository;
-import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.system.repository.FileSystemRepository;
-import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.repository.WriteableRepository;
 
 /**
  * @version $Rev$ $Date$
@@ -57,7 +55,6 @@
      * location of the source repository for the dependencies
      */
     private File sourceRepository;
-    protected URI sourceRepositoryURI;
 
     public File getTargetRoot() {
         return targetRoot;
@@ -97,23 +94,14 @@
 
     public void setSourceRepository(File sourceRepository) {
         this.sourceRepository = sourceRepository;
-        sourceRepositoryURI = sourceRepository.toURI();
     }
 
-    public URI getSourceRepositoryURI() {
-        return sourceRepositoryURI;
-    }
-
-    public void setSourceRepositoryURI(URI sourceRepositoryURI) {
-        this.sourceRepositoryURI = sourceRepositoryURI;
-    }
-
-    protected void execute(InstallAdapter installAdapter, Repository sourceRepo, FileSystemRepository
targetRepo) throws IOException, InvalidConfigException {
+    protected void execute(InstallAdapter installAdapter, Repository sourceRepo, WriteableRepository
targetRepo) throws IOException, InvalidConfigException {
         Artifact configId = Artifact.create(artifact);
         execute(configId, installAdapter, sourceRepo,  targetRepo);
     }
 
-    protected void execute(Artifact configId, InstallAdapter installAdapter, Repository sourceRepo,
FileSystemRepository targetRepo) throws IOException, InvalidConfigException {
+    protected void execute(Artifact configId, InstallAdapter installAdapter, Repository sourceRepo,
WriteableRepository targetRepo) throws IOException, InvalidConfigException {
         if (installAdapter.containsConfiguration(configId)) {
             System.out.println("Configuration " + configId + " already present in configuration
store");
             return;
@@ -125,13 +113,13 @@
         FileWriteMonitor monitor = new StartFileWriteMonitor();
 
         for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
-            URI dependency = (URI) iterator.next();
-            if (!sourceRepo.hasURI(dependency)) {
+            Artifact dependency = (Artifact) iterator.next();
+            if (!sourceRepo.contains(dependency)) {
                 throw new RuntimeException("Dependency: " + dependency + " not found in local
maven repo: for configuration: " + artifact);
             }
-            if (!targetRepo.hasURI(dependency)) {
-                URL sourceURL = sourceRepo.getURL(dependency);
-                InputStream in = sourceURL.openStream();
+            if (!targetRepo.contains(dependency)) {
+                File sourceFile = sourceRepo.getLocation(dependency);
+                InputStream in = new FileInputStream(sourceFile);
                 targetRepo.copyToRepository(in, dependency, monitor);
             }
         }
@@ -162,42 +150,6 @@
 
         public void writeComplete(int bytes) {
 
-        }
-    }
-
-    protected class InnerRepository implements Repository {
-
-        public boolean hasURI(URI uri) {
-            uri = resolve(uri);
-            if ("file".equals(uri.getScheme())) {
-                return new File(uri).canRead();
-            } else {
-                try {
-                    uri.toURL().openStream().close();
-                    return true;
-                } catch (IOException e) {
-                    return false;
-                }
-            }
-        }
-
-        public URL getURL(URI uri) throws MalformedURLException {
-            uri = resolve(uri);
-            return uri.toURL();
-        }
-
-        /**
-         * todo if the uri has a scheme, don't dissect it.
-         *
-         * @param uri
-         * @return uri 
-         */
-        private URI resolve(final URI uri) {
-            String[] bits = uri.toString().split("/");
-            StringBuffer buf = new StringBuffer(bits[0]).append('/');
-            String type = bits.length >= 4 ? bits[3] : "jar";
-            buf.append(type).append('s').append('/').append(bits[1]).append('-').append(bits[2]).append('.').append(type);
-            return sourceRepositoryURI.resolve(buf.toString());
         }
     }
 }

Modified: geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java?rev=377617&r1=377616&r2=377617&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java
(original)
+++ geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java
Mon Feb 13 20:50:59 2006
@@ -17,18 +17,16 @@
 
 package org.apache.geronimo.plugin.assembly;
 
+import java.io.File;
+import java.io.IOException;
+
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.system.configuration.LocalConfigStore;
-import org.apache.geronimo.system.repository.FileSystemRepository;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
+import org.apache.geronimo.system.repository.Maven1Repository;
+import org.apache.geronimo.system.repository.Maven2Repository;
 
 /**
  * JellyBean that installs configuration artifacts into a LocalConfigurationStore,  It also
copies all
@@ -44,13 +42,8 @@
         InstallAdapter installAdapter = new InstallAdapter() {
 
             public GBeanData install(Repository sourceRepo, Artifact configId) throws IOException,
InvalidConfigException {
-                URL artifact = null;
-                try {
-                    artifact = sourceRepo.getURL(configId.toURI());
-                } catch (URISyntaxException e) {
-                    throw new InvalidConfigException(e);
-                }
-                GBeanData config = store.install2(artifact);
+                File artifact = sourceRepo.getLocation(configId);
+                GBeanData config = store.install2(artifact.toURL());
                 return config;
             }
 
@@ -58,21 +51,13 @@
                 return store.containsConfiguration(configID);
             }
         };
-        Repository sourceRepo = new InnerRepository();
-        URI rootURI = targetRoot.toURI().resolve(targetRepository);
-        FileSystemRepository targetRepo = new FileSystemRepository(rootURI, null);
-        targetRepo.doStart();
+        Repository sourceRepo = new Maven1Repository(getSourceRepository());
+        Maven2Repository targetRepo = new Maven2Repository(new File(targetRoot, targetRepository));
 
         try {
-            try {
-                execute(installAdapter, sourceRepo, targetRepo);
-            } finally {
-                store.doStop();
-            }
+            execute(installAdapter, sourceRepo, targetRepo);
         } finally {
-            targetRepo.doStop();
+            store.doStop();
         }
-
     }
-
 }

Modified: geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java?rev=377617&r1=377616&r2=377617&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java
(original)
+++ geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java
Mon Feb 13 20:50:59 2006
@@ -17,18 +17,20 @@
 
 package org.apache.geronimo.plugin.assembly;
 
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.ObjectInputStream;
-import java.net.URI;
 import java.net.URL;
-import java.net.URISyntaxException;
 
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.system.repository.FileSystemRepository;
+import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.kernel.repository.WriteableRepository;
+import org.apache.geronimo.system.repository.Maven1Repository;
+import org.apache.geronimo.system.repository.Maven2Repository;
 
 /**
  * JellyBean that installs configuration artifacts into a repository based ConfigurationStore,
 It also copies all
@@ -39,47 +41,34 @@
 public class RepoConfigInstaller extends BaseConfigInstaller {
 
     public void execute() throws Exception {
-        Repository sourceRepo = new InnerRepository();
-        URI rootURI = targetRoot.toURI().resolve(targetRepository);
-        FileSystemRepository targetRepo = new FileSystemRepository(rootURI, null);
+        Repository sourceRepo = new Maven1Repository(getSourceRepository());
+        Maven2Repository targetRepo = new Maven2Repository(new File(targetRoot, targetRepository));
         InstallAdapter installAdapter = new CopyConfigStore(targetRepo);
-        targetRepo.doStart();
-
-        try {
-            execute(installAdapter, sourceRepo, targetRepo);
-        } finally {
-            targetRepo.doStop();
-        }
 
-    }
+        execute(installAdapter, sourceRepo, targetRepo);
+   }
 
     private static class CopyConfigStore implements InstallAdapter {
+        private final WriteableRepository targetRepo;
 
-        private final FileSystemRepository targetRepo;
-
-        public CopyConfigStore(FileSystemRepository targetRepo) {
+        public CopyConfigStore(WriteableRepository targetRepo) {
             this.targetRepo = targetRepo;
         }
 
         public GBeanData install(Repository sourceRepo, Artifact configId) throws IOException,
InvalidConfigException {
-            URI sourceURI;
-            try {
-                sourceURI = configId.toURI();
-            } catch (URISyntaxException e) {
-                throw new InvalidConfigException(e);
-            }
-            URL sourceURL = sourceRepo.getURL(sourceURI);
-            InputStream in = sourceURL.openStream();
-            try {
-                if (!targetRepo.hasURI(sourceURI)) {
-                    targetRepo.copyToRepository(in, sourceURI, new StartFileWriteMonitor());
+            if (!targetRepo.contains(configId)) {
+                File sourceFile = sourceRepo.getLocation(configId);
+                InputStream in = new FileInputStream(sourceFile);
+                try {
+                    targetRepo.copyToRepository(in, configId, new StartFileWriteMonitor());
+                } finally {
+                    in.close();
                 }
-            } finally {
-                in.close();
             }
-            URL targetURL = targetRepo.getURL(sourceURI);
+
+            File targetFile = targetRepo.getLocation(configId);
             GBeanData config = new GBeanData();
-            URL baseURL = new URL("jar:" + targetURL.toString() + "!/");
+            URL baseURL = new URL("jar:" + targetFile.toString() + "!/");
             InputStream jis = null;
             try {
                 URL stateURL = new URL(baseURL, "META-INF/config.ser");
@@ -97,11 +86,7 @@
         }
 
         public boolean containsConfiguration(Artifact configID) {
-            try {
-                return targetRepo.hasURI(configID.toURI());
-            } catch (URISyntaxException e) {
-                throw (IllegalArgumentException)new IllegalArgumentException("bad artifact").initCause(e);
-            }
+            return targetRepo.contains(configID);
         }
     }
 

Modified: geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java?rev=377617&r1=377616&r2=377617&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
(original)
+++ geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
Mon Feb 13 20:50:59 2006
@@ -20,10 +20,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.ObjectInputStream;
-import java.net.URI;
 import java.net.URL;
-import java.net.URLDecoder;
-import java.net.URISyntaxException;
 import java.util.List;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
@@ -31,15 +28,15 @@
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationData;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.config.NoSuchConfigException;
-import org.apache.geronimo.kernel.config.ConfigurationData;
 import org.apache.geronimo.kernel.config.ManageableAttributeStore;
-import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
 import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.system.configuration.ExecutableConfigurationUtil;
 
 /**
@@ -67,18 +64,12 @@
     }
 
     public synchronized ObjectName loadConfiguration(Artifact configId) throws NoSuchConfigException,
IOException, InvalidConfigException {
-        URI uri;
-        try {
-             uri = configId.toURI();
-        } catch (URISyntaxException e) {
-            throw new NoSuchConfigException("Configuration not found: " + configId, e);
+        if (!repository.contains(configId)) {
+            throw new NoSuchConfigException("Configuration not found: " + configId);
         }
-            if (!repository.hasURI(uri)) {
-                throw new NoSuchConfigException("Configuration not found: " + configId);
-            }
 
         GBeanData config = new GBeanData();
-        URL baseURL = new URL("jar:" + repository.getURL(uri).toString() + "!/");
+        URL baseURL = new URL("jar:" + repository.getLocation(configId).toString() + "!/");
         InputStream jis = null;
         try {
             URL stateURL = new URL(baseURL, "META-INF/config.ser");
@@ -108,11 +99,7 @@
 
 
     public boolean containsConfiguration(Artifact configID) {
-        try {
-            return repository.hasURI(configID.toURI());
-        } catch (URISyntaxException e) {
-            return false;
-        }
+        return repository.contains(configID);
     }
 
     public File createNewConfigurationDir() {
@@ -139,23 +126,7 @@
             throw new InvalidConfigException("Source must be a directory: source=" + source);
         }
         Artifact configId = configurationData.getId();
-        URL targetURL = null;
-        try {
-            targetURL = repository.getURL(configId.toURI());
-        } catch (URISyntaxException e) {
-            throw new InvalidConfigException(e);
-        }
-        File targetFile;
-        if (targetURL.getProtocol().equalsIgnoreCase("file")) {
-            try {
-                targetFile = new File(URLDecoder.decode(targetURL.getFile(), "UTF-8"));
-            } catch (IOException e) {
-                throw new InvalidConfigException("Could not construct File for car location",
e);
-            }
-        } else {
-            URI targetURI = URI.create(targetURL.toString());
-            targetFile = new File(targetURI);
-        }
+        File targetFile =repository.getLocation(configId);
         ExecutableConfigurationUtil.createExecutableConfiguration(configurationData, null,
source, targetFile);
     }
 

Modified: geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java?rev=377617&r1=377616&r2=377617&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java
(original)
+++ geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java
Mon Feb 13 20:50:59 2006
@@ -34,6 +34,7 @@
 import org.apache.maven.jelly.MavenJellyContext;
 import org.apache.maven.project.Dependency;
 import org.apache.maven.repository.Artifact;
+import org.apache.geronimo.system.repository.Maven1Repository;
 
 /**
  * JellyBean that builds a Geronimo Configuration using the local Mavem
@@ -215,7 +216,7 @@
             set("setPackageFile", packageFile, File.class, packageBuilder);
             set("setPlanFile", planFile, File.class, packageBuilder);
             set("setRepository", repository, File.class, packageBuilder);
-            set("setRepositoryClass", MavenRepository.class.getName(), String.class, packageBuilder);
+            set("setRepositoryClass", Maven1Repository.class.getName(), String.class, packageBuilder);
             set("setConfigurationStoreClass", MavenConfigStore.class.getName(), String.class,
packageBuilder);
 
             Method m = packageBuilder.getClass().getMethod("execute", new Class[]{});



Mime
View raw message