geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r355299 - in /geronimo/trunk/plugins/geronimo-packaging-plugin: ./ src/java/org/apache/geronimo/plugin/packaging/
Date Fri, 09 Dec 2005 01:23:46 GMT
Author: djencks
Date: Thu Dec  8 17:23:43 2005
New Revision: 355299

URL: http://svn.apache.org/viewcvs?rev=355299&view=rev
Log:
GERONIMO-1312 make packaging plugin able to deploy app clients.  Also include an experimental
class for offline deployer

Added:
    geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackagingCommandLine.java
Modified:
    geronimo/trunk/plugins/geronimo-packaging-plugin/project.xml
    geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
    geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
    geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java

Modified: geronimo/trunk/plugins/geronimo-packaging-plugin/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-packaging-plugin/project.xml?rev=355299&r1=355298&r2=355299&view=diff
==============================================================================
--- geronimo/trunk/plugins/geronimo-packaging-plugin/project.xml (original)
+++ geronimo/trunk/plugins/geronimo-packaging-plugin/project.xml Thu Dec  8 17:23:43 2005
@@ -35,6 +35,15 @@
         </dependency>
 
         <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-system</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <properties>
+                <packaging.classpath>true</packaging.classpath>
+            </properties>
+        </dependency>
+
+        <dependency>
             <groupId>cglib</groupId>
             <artifactId>cglib-nodep</artifactId>
             <version>2.1_2</version>

Modified: geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java?rev=355299&r1=355298&r2=355299&view=diff
==============================================================================
--- geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
(original)
+++ geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
Thu Dec  8 17:23:43 2005
@@ -37,6 +37,7 @@
 import org.apache.geronimo.kernel.config.ManageableAttributeStore;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.system.configuration.ExecutableConfigurationUtil;
 
 /**
  * Implementation of ConfigurationStore that loads Configurations from a repository.
@@ -126,7 +127,13 @@
     }
 
     public void install(ConfigurationData configurationData, File source) throws IOException,
InvalidConfigException {
-        throw new UnsupportedOperationException();
+        if (!source.isDirectory()) {
+            throw new InvalidConfigException("Source must be a directory: source=" + source);
+        }
+        URI configId = configurationData.getId();
+        URL targetURL = repository.getURL(configId);
+        File targetFile = new File(targetURL.getPath());
+        ExecutableConfigurationUtil.createExecutableConfiguration(configurationData, null,
source, targetFile);
     }
 
     public void uninstall(URI configID) throws NoSuchConfigException, IOException {

Modified: geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java?rev=355299&r1=355298&r2=355299&view=diff
==============================================================================
--- geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
(original)
+++ geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
Thu Dec  8 17:23:43 2005
@@ -20,17 +20,19 @@
 import java.net.URI;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
 import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GReferenceInfo;
+import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelFactory;
 import org.apache.geronimo.kernel.KernelRegistry;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.config.ConfigurationManagerImpl;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
-import org.apache.geronimo.kernel.config.InvalidConfigException;
 import org.apache.log4j.BasicConfigurator;
 
 /**
@@ -89,6 +91,9 @@
         }
     }
 
+    private String repositoryClass;
+    private String configurationStoreClass;
+
     private File repository;
     private String deploymentConfigString;
     private URI[] deploymentConfig;
@@ -102,6 +107,23 @@
     private String endorsedDirs;
     private String extensionDirs;
 
+    public String getRepositoryClass() {
+        return repositoryClass;
+    }
+
+    public void setRepositoryClass(String repositoryClass) {
+        this.repositoryClass = repositoryClass;
+    }
+
+    public String getConfigurationStoreClass() {
+        return configurationStoreClass;
+    }
+
+    public void setConfigurationStoreClass(String configurationStoreClass) {
+        this.configurationStoreClass = configurationStoreClass;
+    }
+
+
     public File getRepository() {
         return repository;
     }
@@ -228,7 +250,7 @@
     }
 
     public void execute() throws Exception {
-        Kernel kernel = createKernel(repository);
+        Kernel kernel = createKernel(repository, repositoryClass, configurationStoreClass);
 
         // start the Configuration we're going to use for this deployment
         ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
@@ -260,7 +282,7 @@
     /**
      * Create a Geronimo Kernel to contain the deployment configurations.
      */
-    private static synchronized Kernel createKernel(File repository) throws Exception {
+    private static synchronized Kernel createKernel(File repository, String repoClass, String
configStoreClass) throws Exception {
         // first return our cached version
         if (kernel != null) {
             return kernel;
@@ -271,13 +293,13 @@
         if (kernel != null) {
             return kernel;
         }
-        
+
         BasicConfigurator.configure();
         // boot one ourselves
         kernel = KernelFactory.newInstance().createKernel(KERNEL_NAME);
         kernel.boot();
 
-        bootDeployerSystem(kernel, repository);
+        bootDeployerSystem(kernel, repository, repoClass, configStoreClass);
 
         return kernel;
     }
@@ -287,15 +309,24 @@
      * This contains Repository and ConfigurationStore GBeans that map to
      * the local maven installation.
      */
-    private static void bootDeployerSystem(Kernel kernel, File repository) throws Exception
{
+    private static void bootDeployerSystem(Kernel kernel, File repository, String repoClass,
String configStoreClass) throws Exception {
         ClassLoader cl = PackageBuilder.class.getClassLoader();
-        GBeanData repoGBean = new GBeanData(REPOSITORY_NAME, MavenRepository.GBEAN_INFO);
+        GBeanInfo repoInfo = GBeanInfo.getGBeanInfo(repoClass, cl);
+        GBeanData repoGBean = new GBeanData(REPOSITORY_NAME, repoInfo);
         repoGBean.setAttribute("root", repository);
         kernel.loadGBean(repoGBean, cl);
         kernel.startGBean(REPOSITORY_NAME);
 
-        GBeanData storeGBean = new GBeanData(CONFIGSTORE_NAME, MavenConfigStore.GBEAN_INFO);
-        storeGBean.setReferencePattern("Repository", REPOSITORY_NAME);
+        GBeanInfo configStoreInfo = GBeanInfo.getGBeanInfo(configStoreClass, cl);
+        GBeanData storeGBean = new GBeanData(CONFIGSTORE_NAME, configStoreInfo);
+        Set refs = configStoreInfo.getReferences();
+        for (Iterator iterator = refs.iterator(); iterator.hasNext();) {
+            GReferenceInfo refInfo = (GReferenceInfo) iterator.next();
+            if ("Repository".equals(refInfo.getName())) {
+                storeGBean.setReferencePattern("Repository", REPOSITORY_NAME);
+                break;
+            }
+        }
         kernel.loadGBean(storeGBean, cl);
         kernel.startGBean(CONFIGSTORE_NAME);
 

Modified: geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java?rev=355299&r1=355298&r2=355299&view=diff
==============================================================================
--- geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java
(original)
+++ geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java
Thu Dec  8 17:23:43 2005
@@ -211,6 +211,8 @@
         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("setConfigurationStoreClass", MavenConfigStore.class.getName(), String.class,
packageBuilder);
 
         Method m = packageBuilder.getClass().getMethod("execute", new Class[]{});
         m.invoke(packageBuilder, new Object[]{});

Added: geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackagingCommandLine.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackagingCommandLine.java?rev=355299&view=auto
==============================================================================
--- geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackagingCommandLine.java
(added)
+++ geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackagingCommandLine.java
Thu Dec  8 17:23:43 2005
@@ -0,0 +1,92 @@
+/**
+ *
+ * Copyright 2005 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.InputStream;
+import java.io.FileInputStream;
+import java.util.Properties;
+
+/**
+ * @version $Rev:  $ $Date:  $
+ */
+public class PackagingCommandLine {
+
+
+    public static void Main(String[] args) throws Exception {
+        File configFile = new File("packaging.properties");
+        Properties config = new Properties();
+        InputStream in = new FileInputStream(configFile);
+        try {
+            config.load(in);
+        } finally {
+            in.close();
+        }
+        mergeArgs(config, args);
+
+        new PackagingCommandLine(config).execute();
+
+    }
+
+
+    private static void mergeArgs(Properties config, String[] args) throws Exception {
+        if (args.length % 2 != 0) {
+            throw new Exception("There must be an even number of args, --<name> followed
by value");
+        }
+        for (int i = 0; i < args.length; i++) {
+            String key = args[i++];
+            String value = args[i];
+            if (!key.startsWith("--")) {
+                throw new Exception("Keys must be preceded by '--'");
+            }
+            key = key.substring(2);
+            config.put(key, value);
+        }
+    }
+
+    private final Properties config;
+
+    public PackagingCommandLine(Properties config) {
+        this.config = config;
+    }
+
+    public void execute() throws Exception {
+        PackageBuilder builder = new PackageBuilder();
+        builder.setClassPath(config.getProperty("classPath"));
+        builder.setConfigurationStoreClass(config.getProperty("configurationStoreClass"));
+        builder.setDeployerName(config.getProperty("deployerName"));
+        builder.setDeploymentConfig(config.getProperty("deploymentConfig"));
+        builder.setEndorsedDirs(config.getProperty("endorsedDirs"));
+        builder.setExtensionDirs(config.getProperty("extensionDirs"));
+        builder.setMainClass(config.getProperty("mainClass"));
+        builder.setModuleFile(getFile(config.getProperty("moduleFile")));
+        builder.setPackageFile(getFile(config.getProperty("packageFile")));
+        builder.setPlanFile(getFile(config.getProperty("planFile")));
+        builder.setRepository(getFile(config.getProperty("repository")));
+        builder.setRepositoryClass(config.getProperty("repositoryClass"));
+        builder.execute();
+    }
+
+    private File getFile(String fileName) {
+        if (fileName == null) {
+            return null;
+        }
+        return new File(fileName);
+    }
+
+
+}



Mime
View raw message