geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r396048 - in /geronimo/branches/1.1: modules/system/src/java/org/apache/geronimo/system/configuration/ plugins/geronimo-packaging-plugin/ plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/
Date Sat, 22 Apr 2006 01:33:29 GMT
Author: djencks
Date: Fri Apr 21 18:33:27 2006
New Revision: 396048

URL: http://svn.apache.org/viewcvs?rev=396048&view=rev
Log:
GERONIMO-1866  Make the packaging plugin put stuff first in the target dir, then copy to maven

Added:
    geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/ConfigCopier.java
Modified:
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
    geronimo/branches/1.1/plugins/geronimo-packaging-plugin/plugin.jelly
    geronimo/branches/1.1/plugins/geronimo-packaging-plugin/plugin.properties
    geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
    geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
    geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java?rev=396048&r1=396047&r2=396048&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
(original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
Fri Apr 21 18:33:27 2006
@@ -31,6 +31,7 @@
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedList;
+import java.util.Arrays;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 import java.util.zip.ZipEntry;
@@ -42,6 +43,15 @@
  * @version $Rev$ $Date$
  */
 public final class ExecutableConfigurationUtil {
+    private static final String META_INF = "META-INF";
+    private static final String CONFIG_SER = "config.ser";
+    private static final String CONFIG_INFO = "config.info";
+    private static final String META_INF_STARTUP_JAR = META_INF + "/startup-jar";
+    private static final String META_INF_CONFIG_SER = META_INF + "/" + CONFIG_SER;
+    private static final String META_INF_CONFIG_SER_SHA1 = META_INF_CONFIG_SER + ".sha1";
+    private static final String META_INF_CONFIG_INFO = META_INF + "/" + CONFIG_INFO;
+
+    private static final Collection EXCLUDED = Arrays.asList(new String[] {META_INF_STARTUP_JAR,
META_INF_CONFIG_SER, META_INF_CONFIG_SER_SHA1, META_INF_CONFIG_INFO});
 
     private ExecutableConfigurationUtil() {
     }
@@ -58,13 +68,13 @@
             byte[] buffer = new byte[4096];
 
             if (manifest != null) {
-                out = new JarOutputStream(new FileOutputStream(destinationFile), manifest);
+                out = new JarOutputStream(new FileOutputStream(destinationFile, false), manifest);
 
                 // add the startup file which allows us to locate the startup directory
-                out.putNextEntry(new ZipEntry("META-INF/startup-jar"));
+                out.putNextEntry(new ZipEntry(META_INF_STARTUP_JAR));
                 out.closeEntry();
             } else {
-                out = new JarOutputStream(new FileOutputStream(destinationFile));
+                out = new JarOutputStream(new FileOutputStream(destinationFile, false));
             }
 
             // write the configurationData
@@ -75,19 +85,21 @@
             for (Iterator iterator = files.iterator(); iterator.hasNext();) {
                 File file = (File) iterator.next();
                 String relativePath = baseURI.relativize(file.toURI()).getPath();
-                InputStream in = new FileInputStream(file);
-                try {
-                    out.putNextEntry(new ZipEntry(relativePath));
+                if (!EXCLUDED.contains(relativePath)) {
+                    InputStream in = new FileInputStream(file);
                     try {
-                        int count;
-                        while ((count = in.read(buffer)) > 0) {
-                            out.write(buffer, 0, count);
+                        out.putNextEntry(new ZipEntry(relativePath));
+                        try {
+                            int count;
+                            while ((count = in.read(buffer)) > 0) {
+                                out.write(buffer, 0, count);
+                            }
+                        } finally {
+                            out.closeEntry();
                         }
                     } finally {
-                        out.closeEntry();
+                        close(in);
                     }
-                } finally {
-                    close(in);
                 }
             }
         } finally {
@@ -97,7 +109,7 @@
 
     public static void writeConfiguration(ConfigurationData configurationData, JarOutputStream
out) throws IOException {
         // save the persisted form in the source directory
-        out.putNextEntry(new ZipEntry("META-INF/config.ser"));
+        out.putNextEntry(new ZipEntry(META_INF_CONFIG_SER));
         ConfigurationStoreUtil.ChecksumOutputStream sumOut = new ConfigurationStoreUtil.ChecksumOutputStream(out);
         try {
             ConfigurationUtil.writeConfigurationData(configurationData, sumOut);
@@ -106,7 +118,7 @@
         }
 
         // write the checksum file
-        out.putNextEntry(new ZipEntry("META-INF/config.ser.sha1"));
+        out.putNextEntry(new ZipEntry(META_INF_CONFIG_SER_SHA1));
         try {
             OutputStreamWriter writer = new OutputStreamWriter(out);
             writer.write(sumOut.getChecksum());
@@ -116,7 +128,7 @@
         }
 
         // write the info file
-        out.putNextEntry(new ZipEntry("META-INF/config.info"));
+        out.putNextEntry(new ZipEntry(META_INF_CONFIG_INFO));
         try {
             PrintWriter writer = new PrintWriter(new OutputStreamWriter(out));
             ConfigurationUtil.writeConfigInfo(writer, configurationData);
@@ -128,9 +140,9 @@
 
     public static void writeConfiguration(ConfigurationData configurationData, File source)
throws IOException {
         // save the persisted form in the source directory
-        File metaInf = new File(source, "META-INF");
+        File metaInf = new File(source, META_INF);
         metaInf.mkdirs();
-        File configSer = new File(metaInf, "config.ser");
+        File configSer = new File(metaInf, CONFIG_SER);
 
         OutputStream out = new FileOutputStream(configSer);
         try {
@@ -146,7 +158,7 @@
         // write the info file
         PrintWriter writer = null;
         try {
-            writer = new PrintWriter(new FileWriter(new File(metaInf, "config.info")));
+            writer = new PrintWriter(new FileWriter(new File(metaInf, CONFIG_INFO)));
             ConfigurationUtil.writeConfigInfo(writer, configurationData);
         } finally {
             flush(writer);

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?rev=396048&r1=396047&r2=396048&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
(original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
Fri Apr 21 18:33:27 2006
@@ -82,7 +82,7 @@
     }
 
     public AbstractName getAbstractName() {
-        return kernel.getAbstractNameFor(this);
+        return kernel == null? null:kernel.getAbstractNameFor(this);
     }
 
     public ConfigurationData loadConfiguration(Artifact configId) throws NoSuchConfigException,
IOException, InvalidConfigException {

Modified: geronimo/branches/1.1/plugins/geronimo-packaging-plugin/plugin.jelly
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/plugins/geronimo-packaging-plugin/plugin.jelly?rev=396048&r1=396047&r2=396048&view=diff
==============================================================================
--- geronimo/branches/1.1/plugins/geronimo-packaging-plugin/plugin.jelly (original)
+++ geronimo/branches/1.1/plugins/geronimo-packaging-plugin/plugin.jelly Fri Apr 21 18:33:27
2006
@@ -29,6 +29,7 @@
     <define:taglib uri="geronimo:packaging">
         <define:jellybean name="package" className="org.apache.geronimo.plugin.packaging.PackageBuilderShell"
method="execute"/>
         <define:jellybean name="dependencies" className="org.apache.geronimo.plugin.packaging.PlanProcessor"
method="execute"/>
+        <define:jellybean name="copyConfigs" className="org.apache.geronimo.plugin.packaging.ConfigCopier"
method="execute"/>
     </define:taglib>
 
     <goal name="car" description="Package a Geronimo Configuration" prereqs="car:package"/>
@@ -47,11 +48,14 @@
     </goal>
 
     <goal name="car:package" prereqs="car:prepare-plan" description="Package a Geronimo
Configuration">
+        <delete dir="${geronimo.packaging.targetRepository}"/>
+        <mkdir dir="${geronimo.packaging.targetRepository}"/>
         <car:package
             context="${context}"
             artifacts="${pom.artifacts}"
             pluginArtifacts="${plugin.artifacts}"
             repository="${geronimo.packaging.repository}"
+            targetRepository="${geronimo.packaging.targetRepository}"
             deployerName="${geronimo.packaging.deployerName}"
             planFile="${geronimo.packaging.buildFile}"
             moduleFile="${geronimo.packaging.moduleFile}"
@@ -67,6 +71,18 @@
     <goal name="car:install" prereqs="car:package" description="Install the package in
the local repository">
         <j:catch>
             <artifact:install artifact="${maven.build.dir}/${maven.final.name}.car" type="car"
project="${pom}"/>
+        </j:catch>
+        <j:catch>
+            <echo>about to copy configs</echo>
+            <car:copyConfigs
+                sourceRepositoryClass="${geronimo.packaging.install.sourceRepositoryClass}"
+                sourceConfigurationStoreClass="${geronimo.packaging.install.sourceConfigurationStoreClass}"
+                sourceRepositoryLocation="${geronimo.packaging.install.sourceRepositoryLocation}"
+                targetRepositoryClass="${geronimo.packaging.install.targetRepositoryClass}"
+                targetConfigurationStoreClass="${geronimo.packaging.install.targetConfigurationStoreClass}"
+                targetRepositoryLocation="${geronimo.packaging.install.targetRepositoryLocation}"
+                    />
+            <echo>done copying configs</echo>
         </j:catch>
     </goal>
 </project>

Modified: geronimo/branches/1.1/plugins/geronimo-packaging-plugin/plugin.properties
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/plugins/geronimo-packaging-plugin/plugin.properties?rev=396048&r1=396047&r2=396048&view=diff
==============================================================================
--- geronimo/branches/1.1/plugins/geronimo-packaging-plugin/plugin.properties (original)
+++ geronimo/branches/1.1/plugins/geronimo-packaging-plugin/plugin.properties Fri Apr 21 18:33:27
2006
@@ -27,6 +27,7 @@
 geronimo.packaging.buildFile=${geronimo.packaging.buildDir}/${geronimo.packaging.planFile}
 
 geronimo.packaging.repository=${maven.repo.local}
+geronimo.packaging.targetRepository=${maven.build.dir}/repository
 geronimo.packaging.deploymentConfig=geronimo/geronimo-gbean-deployer/${geronimo.packaging.geronimo_version}/car,geronimo/j2ee-deployer/${geronimo.packaging.geronimo_version}/car
 geronimo.packaging.deployerName=geronimo/geronimo-gbean-deployer/${geronimo.packaging.geronimo_version}/car?j2eeType=Deployer,name=Deployer
 #  geronimo.maven:name=Deployer,j2eeType=Deployer,J2EEModule=geronimo/geronimo-gbean-deployer/${geronimo.packaging.geronimo_version}/car,*
@@ -40,3 +41,10 @@
 geronimo.packaging.url=service:jmx:${geronimo.packaging.protocol}:${geronimo.packaging.sap}
 
 geronimo.packaging.explicit.versions=${basedir}/../../etc/explicit_versions.properties
+
+geronimo.packaging.install.sourceRepositoryClass=org.apache.geronimo.system.repository.Maven2Repository
+geronimo.packaging.install.sourceConfigurationStoreClass=org.apache.geronimo.system.configuration.RepositoryConfigurationStore
+geronimo.packaging.install.sourceRepositoryLocation=${maven.build.dir}/repository
+geronimo.packaging.install.targetRepositoryClass=org.apache.geronimo.system.repository.Maven1Repository
+geronimo.packaging.install.targetConfigurationStoreClass=org.apache.geronimo.plugin.packaging.MavenConfigStore
+geronimo.packaging.install.targetRepositoryLocation=${maven.repo.local}

Added: geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/ConfigCopier.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/ConfigCopier.java?rev=396048&view=auto
==============================================================================
--- geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/ConfigCopier.java
(added)
+++ geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/ConfigCopier.java
Fri Apr 21 18:33:27 2006
@@ -0,0 +1,126 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.geronimo.plugin.packaging;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.List;
+
+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.ConfigurationInfo;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.WritableListableRepository;
+
+/**
+ * Copies all the configurations out of source config store into target config store.
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class ConfigCopier {
+
+    private static final Class[] REPO_ARGS = new Class[] {File.class};
+    private static final Class[] STORE_ARGS = new Class[] {WritableListableRepository.class};
+
+
+    private String sourceRepositoryClass;
+    private String targetRepositoryClass;
+    private String sourceConfigurationStoreClass;
+    private String targetConfigurationStoreClass;
+    private File sourceRepositoryLocation;
+    private File targetRepositoryLocation;
+
+
+    public String getSourceRepositoryClass() {
+        return sourceRepositoryClass;
+    }
+
+    public void setSourceRepositoryClass(String sourceRepositoryClass) {
+        this.sourceRepositoryClass = sourceRepositoryClass;
+    }
+
+    public String getTargetRepositoryClass() {
+        return targetRepositoryClass;
+    }
+
+    public void setTargetRepositoryClass(String targetRepositoryClass) {
+        this.targetRepositoryClass = targetRepositoryClass;
+    }
+
+    public String getSourceConfigurationStoreClass() {
+        return sourceConfigurationStoreClass;
+    }
+
+    public void setSourceConfigurationStoreClass(String sourceConfigurationStoreClass) {
+        this.sourceConfigurationStoreClass = sourceConfigurationStoreClass;
+    }
+
+    public String getTargetConfigurationStoreClass() {
+        return targetConfigurationStoreClass;
+    }
+
+    public void setTargetConfigurationStoreClass(String targetConfigurationStoreClass) {
+        this.targetConfigurationStoreClass = targetConfigurationStoreClass;
+    }
+
+    public File getSourceRepositoryLocation() {
+        return sourceRepositoryLocation;
+    }
+
+    public void setSourceRepositoryLocation(File sourceRepositoryLocation) {
+        this.sourceRepositoryLocation = sourceRepositoryLocation;
+    }
+
+    public File getTargetRepositoryLocation() {
+        return targetRepositoryLocation;
+    }
+
+    public void setTargetRepositoryLocation(File targetRepositoryLocation) {
+        this.targetRepositoryLocation = targetRepositoryLocation;
+    }
+
+    public void execute() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException, InstantiationException, InvalidConfigException, IOException, NoSuchConfigException
{
+        ClassLoader cl = this.getClass().getClassLoader();
+
+        Class sourceRepoClass = cl.loadClass(sourceRepositoryClass);
+        WritableListableRepository sourceRepository = (WritableListableRepository) sourceRepoClass.getDeclaredConstructor(REPO_ARGS).newInstance(new
Object[] {sourceRepositoryLocation});
+        Class sourceConfigStoreClass = cl.loadClass(sourceConfigurationStoreClass);
+        ConfigurationStore sourceConfigStore = (ConfigurationStore) sourceConfigStoreClass.getDeclaredConstructor(STORE_ARGS).newInstance(new
Object[] {sourceRepository});
+
+        Class targetRepoClass = cl.loadClass(targetRepositoryClass);
+        WritableListableRepository targetRepository = (WritableListableRepository) targetRepoClass.getDeclaredConstructor(REPO_ARGS).newInstance(new
Object[] {targetRepositoryLocation});
+        Class targetConfigStoreClass = cl.loadClass(targetConfigurationStoreClass);
+        ConfigurationStore targetConfigStore = (ConfigurationStore) targetConfigStoreClass.getDeclaredConstructor(STORE_ARGS).newInstance(new
Object[] {targetRepository});
+
+        List configs = sourceConfigStore.listConfigurations();
+        for (Iterator iterator = configs.iterator(); iterator.hasNext();) {
+            ConfigurationInfo configInfo = (ConfigurationInfo) iterator.next();
+            Artifact configId = configInfo.getConfigID();
+            ConfigurationData configData = sourceConfigStore.loadConfiguration(configId);
+            if (targetConfigStore.containsConfiguration(configId)) {
+                targetConfigStore.uninstall(configId);
+            }
+            targetConfigStore.install(configData);
+        }
+
+    }
+}

Modified: geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java?rev=396048&r1=396047&r2=396048&view=diff
==============================================================================
--- geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
(original)
+++ geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
Fri Apr 21 18:33:27 2006
@@ -43,6 +43,10 @@
         super(kernel, objectName, repository);
     }
 
+    public MavenConfigStore(WritableListableRepository repository) {
+        super(repository);
+    }
+
     public File createNewConfigurationDir(Artifact configId) {
         try {
             File tmpFile = File.createTempFile("package", ".tmpdir");
@@ -72,7 +76,8 @@
     }
 
     public void uninstall(Artifact configID) throws NoSuchConfigException, IOException {
-        throw new UnsupportedOperationException();
+        File targetFile = repository.getLocation(configID);
+        targetFile.delete();
     }
 
     public List listConfigurations() {

Modified: geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java?rev=396048&r1=396047&r2=396048&view=diff
==============================================================================
--- geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
(original)
+++ geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
Fri Apr 21 18:33:27 2006
@@ -21,6 +21,8 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Collection;
+import java.util.Set;
+import java.util.HashSet;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -28,6 +30,7 @@
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.ReferencePatterns;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelFactory;
 import org.apache.geronimo.kernel.KernelRegistry;
@@ -74,8 +77,11 @@
 
     private String repositoryClass;
     private String configurationStoreClass;
+    private String targetRepositoryClass;
+    private String targetConfigurationStoreClass;
 
     private File repository;
+    private File targetRepository;
     private Collection deploymentConfigs;
 //    private Artifact[] deploymentConfig;
     private AbstractName deployerName;
@@ -121,6 +127,30 @@
         this.repository = repository;
     }
 
+    public String getTargetRepositoryClass() {
+        return targetRepositoryClass;
+    }
+
+    public void setTargetRepositoryClass(String targetRepositoryClass) {
+        this.targetRepositoryClass = targetRepositoryClass;
+    }
+
+    public String getTargetConfigurationStoreClass() {
+        return targetConfigurationStoreClass;
+    }
+
+    public void setTargetConfigurationStoreClass(String targetConfigurationStoreClass) {
+        this.targetConfigurationStoreClass = targetConfigurationStoreClass;
+    }
+
+    public File getTargetRepository() {
+        return targetRepository;
+    }
+
+    public void setTargetRepository(File targetRepository) {
+        this.targetRepository = targetRepository;
+    }
+
     public Collection getDeploymentConfig() {
         return deploymentConfigs;
     }
@@ -237,7 +267,7 @@
         System.out.println("    Packaging configuration " + planFile);
         System.out.println();
         try {
-            Kernel kernel = createKernel(repository, repositoryClass, configurationStoreClass,
explicitResolutionLocation);
+            Kernel kernel = createKernel();
 
             // start the Configuration we're going to use for this deployment
             ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
@@ -266,7 +296,7 @@
     /**
      * Create a Geronimo Kernel to contain the deployment configurations.
      */
-    private synchronized Kernel createKernel(File repository, String repoClass, String configStoreClass,
String explicitResolutionLocation) throws Exception {
+    private synchronized Kernel createKernel() throws Exception {
         // first return our cached version
         if (kernel != null) {
             return kernel;
@@ -283,7 +313,7 @@
         kernel = KernelFactory.newInstance().createKernel(KERNEL_NAME);
         kernel.boot();
 
-        bootDeployerSystem(kernel, repository, repoClass, configStoreClass, explicitResolutionLocation);
+        bootDeployerSystem();
 
         return kernel;
     }
@@ -293,39 +323,60 @@
      * This contains Repository and ConfigurationStore GBeans that map to
      * the local maven installation.
      */
-    private void bootDeployerSystem(Kernel kernel, File repository, String
-            repoClass, String configStoreClass, String explicitResolutionLocation) throws
Exception {
+    private void bootDeployerSystem() throws Exception {
         Artifact baseId = new Artifact("geronimo", "packaging", "fixed", "car");
         Naming naming = kernel.getNaming();
         ConfigurationData bootstrap = new ConfigurationData(baseId, naming);
         ClassLoader cl = PackageBuilder.class.getClassLoader();
+        Set repoNames = new HashSet();
 
-        GBeanData repoGBean = bootstrap.addGBean("Repository", GBeanInfo.getGBeanInfo(repoClass,
cl));
+        //Source repo
+        GBeanData repoGBean = bootstrap.addGBean("SourceRepository", GBeanInfo.getGBeanInfo(repositoryClass,
cl));
         URI repositoryURI = repository.toURI();
         repoGBean.setAttribute("root", repositoryURI);
+        repoNames.add(repoGBean.getAbstractName());
+
+        //Target repo
+        GBeanData targetRepoGBean = bootstrap.addGBean("TargetRepository", GBeanInfo.getGBeanInfo(targetRepositoryClass,
cl));
+        URI targetRepositoryURI = targetRepository.toURI();
+        targetRepoGBean.setAttribute("root", targetRepositoryURI);
+        repoNames.add(targetRepoGBean.getAbstractName());
 
         GBeanData artifactManagerGBean = bootstrap.addGBean("ArtifactManager", DefaultArtifactManager.GBEAN_INFO);
 
         GBeanData artifactResolverGBean = bootstrap.addGBean("ArtifactResolver", ExplicitDefaultArtifactResolver.GBEAN_INFO);
         artifactResolverGBean.setAttribute("versionMapLocation", explicitResolutionLocation);
-        artifactResolverGBean.setReferencePattern("Repositories", repoGBean.getAbstractName());
+        ReferencePatterns repoPatterns = new ReferencePatterns(repoNames);
+        artifactResolverGBean.setReferencePatterns("Repositories", repoPatterns);
         artifactResolverGBean.setReferencePattern("ArtifactManager", artifactManagerGBean.getAbstractName());
 
-        GBeanInfo configStoreInfo = GBeanInfo.getGBeanInfo(configStoreClass, cl);
+        Set storeNames = new HashSet();
+        //source config store
+        GBeanInfo configStoreInfo = GBeanInfo.getGBeanInfo(configurationStoreClass, cl);
         GBeanData storeGBean = bootstrap.addGBean("ConfigStore", configStoreInfo);
         if (configStoreInfo.getReference("Repository") != null) {
             storeGBean.setReferencePattern("Repository", repoGBean.getAbstractName());
         }
-        targetConfigStore = storeGBean.getAbstractName().toString();
+        storeNames.add(storeGBean.getAbstractName());
+
+        //target config store
+        GBeanInfo targetConfigStoreInfo = GBeanInfo.getGBeanInfo(targetConfigurationStoreClass,
cl);
+        GBeanData targetStoreGBean = bootstrap.addGBean("TargetConfigStore", targetConfigStoreInfo);
+        if (targetConfigStoreInfo.getReference("Repository") != null) {
+            targetStoreGBean.setReferencePattern("Repository", targetRepoGBean.getAbstractName());
+        }
+        storeNames.add(targetStoreGBean.getAbstractName());
+
+        targetConfigStore = targetStoreGBean.getAbstractName().toString();
 
         GBeanData attrManagerGBean = bootstrap.addGBean("AttributeStore", MavenAttributeStore.GBEAN_INFO);
 
         GBeanData configManagerGBean = bootstrap.addGBean("ConfigManager", KernelConfigurationManager.GBEAN_INFO);
-        configManagerGBean.setReferencePattern("Stores", storeGBean.getAbstractName());
+        configManagerGBean.setReferencePatterns("Stores", new ReferencePatterns(storeNames));
         configManagerGBean.setReferencePattern("AttributeStore", attrManagerGBean.getAbstractName());
         configManagerGBean.setReferencePattern("ArtifactManager", artifactManagerGBean.getAbstractName());
         configManagerGBean.setReferencePattern("ArtifactResolver", artifactResolverGBean.getAbstractName());
-        configManagerGBean.setReferencePattern("Repositories", repoGBean.getAbstractName());
+        configManagerGBean.setReferencePatterns("Repositories", repoPatterns);
 
         ConfigurationUtil.loadBootstrapConfiguration(kernel, bootstrap, cl);
 

Modified: geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java?rev=396048&r1=396047&r2=396048&view=diff
==============================================================================
--- geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java
(original)
+++ geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java
Fri Apr 21 18:33:27 2006
@@ -31,6 +31,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.system.repository.Maven1Repository;
+import org.apache.geronimo.system.repository.Maven2Repository;
+import org.apache.geronimo.system.configuration.RepositoryConfigurationStore;
 import org.apache.maven.jelly.MavenJellyContext;
 import org.apache.maven.project.Dependency;
 import org.apache.maven.repository.Artifact;
@@ -53,6 +55,7 @@
     private static ClassLoader classLoader;
 
     private File repository;
+    private File targetRepository;
     private Collection deploymentConfigList;
     private String deployerName;
 
@@ -78,6 +81,14 @@
         this.repository = repository;
     }
 
+    public File getTargetRepository() {
+        return targetRepository;
+    }
+
+    public void setTargetRepository(File targetRepository) {
+        this.targetRepository = targetRepository;
+    }
+
     public String getDeployerName() {
         return deployerName;
     }
@@ -231,6 +242,9 @@
             set("setRepository", repository, File.class, packageBuilder);
             set("setRepositoryClass", Maven1Repository.class.getName(), String.class, packageBuilder);
             set("setConfigurationStoreClass", MavenConfigStore.class.getName(), String.class,
packageBuilder);
+            set("setTargetRepository", targetRepository, File.class, packageBuilder);
+            set("setTargetRepositoryClass", Maven2Repository.class.getName(), String.class,
packageBuilder);
+            set("setTargetConfigurationStoreClass", RepositoryConfigurationStore.class.getName(),
String.class, packageBuilder);
             set("setExplicitResolutionLocation", explicitResolutionLocation, String.class,
packageBuilder);
 
             Method m = packageBuilder.getClass().getMethod("execute", new Class[]{});



Mime
View raw message