geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r394579 - in /geronimo/branches/1.1/modules: deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/ deploy-tool/src/java/org/apache/geronimo/deployment/cli/ system/src/java/org/apache/geronimo/system/configuration/ system/src/java...
Date Sun, 16 Apr 2006 23:33:55 GMT
Author: ammulder
Date: Sun Apr 16 16:33:53 2006
New Revision: 394579

URL: http://svn.apache.org/viewcvs?rev=394579&view=rev
Log:
Now the configuration installer can handle a CAR file downloaded from
  the repository.  It must have a META-INF/geronimo-plugin.xml
  with some metadata like the repository to hit for downloading
  dependencies.
Deploy tool arguments for installing configurations changed to
  "search-plugins" (gives you a list from a repo) and "install-plugin"
  (install from a CAR file as described above).

Added:
    geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java
  (with props)
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationArchiveData.java
  (with props)
Modified:
    geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
    geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
    geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
    geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployTool.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationInstaller.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadPoller.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadResults.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java
    geronimo/branches/1.1/modules/system/src/schema/config-list.xsd

Modified: geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java?rev=394579&r1=394578&r2=394579&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
(original)
+++ geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
Sun Apr 16 16:33:53 2006
@@ -28,12 +28,17 @@
 
 import javax.enterprise.deploy.spi.Target;
 import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.status.ProgressListener;
+import javax.enterprise.deploy.spi.status.ProgressEvent;
+import javax.enterprise.deploy.shared.CommandType;
 import javax.management.MBeanServerConnection;
 import javax.management.remote.JMXConnector;
 
 import org.apache.geronimo.deployment.plugin.local.DistributeCommand;
 import org.apache.geronimo.deployment.plugin.local.RedeployCommand;
+import org.apache.geronimo.deployment.plugin.local.AbstractDeployCommand;
 import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager;
+import org.apache.geronimo.deployment.plugin.remote.RemoteDeployUtil;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.jmx.KernelDelegate;
@@ -175,6 +180,33 @@
             AbstractName name = (AbstractName) it.next();
             try {
                 return kernel.invoke(name, "startInstall", new Object[]{configsToInstall,
username, password}, new String[]{ConfigurationList.class.getName(), String.class.getName(),
String.class.getName()});
+            } catch (Exception e) {
+                System.err.println("Unable to start installing configurations: "+e.getMessage());
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
+
+    public Object startInstall(File carFile, String username, String password) {
+        File[] args = new File[]{carFile};
+        if(!isSameMachine) {
+            AbstractDeployCommand progress = new AbstractDeployCommand(CommandType.DISTRIBUTE,
kernel, null, null, null, null, false) {
+                public void run() {
+                }
+            };
+            progress.addProgressListener(new ProgressListener() {
+                public void handleProgressEvent(ProgressEvent event) {
+                    System.out.println(event.getDeploymentStatus().getMessage());
+                }
+            });
+            RemoteDeployUtil.uploadFilesToServer(args, progress);
+        }
+        Set set = kernel.listGBeans(new AbstractNameQuery("org.apache.geronimo.system.configuration.ConfigurationInstaller"));
+        for (Iterator it = set.iterator(); it.hasNext();) {
+            AbstractName name = (AbstractName) it.next();
+            try {
+                return kernel.invoke(name, "startInstall", new Object[]{args[0], username,
password}, new String[]{File.class.getName(), String.class.getName(), String.class.getName()});
             } catch (Exception e) {
                 System.err.println("Unable to start installing configurations: "+e.getMessage());
                 e.printStackTrace();

Modified: geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java?rev=394579&r1=394578&r2=394579&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
(original)
+++ geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
Sun Apr 16 16:33:53 2006
@@ -59,7 +59,7 @@
 
     protected ProgressObject runCommand(DeploymentManager mgr, PrintWriter out, boolean inPlace,
Target[] tlist, File module, File plan) throws DeploymentException {
         if (inPlace) {
-            if (false == mgr instanceof JMXDeploymentManager) {
+            if (!(mgr instanceof JMXDeploymentManager)) {
                 throw new DeploymentSyntaxException(
                         "Target DeploymentManager is not a Geronimo one. \n" +
                         "Cannot perform in-place deployment.");

Added: geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java?rev=394579&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java
(added)
+++ geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java
Sun Apr 16 16:33:53 2006
@@ -0,0 +1,112 @@
+/**
+ *
+ * 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.deployment.cli;
+
+import java.io.File;
+import java.io.PrintWriter;
+import javax.enterprise.deploy.spi.DeploymentManager;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.system.configuration.DownloadResults;
+
+/**
+ * The CLI deployer logic to start.
+ *
+ * @version $Rev: 356097 $ $Date: 2005-12-11 20:29:03 -0500 (Sun, 11 Dec 2005) $
+ */
+public class CommandInstallCAR extends AbstractCommand {
+    public CommandInstallCAR() {
+        super("install-plugin", "3. Geronimo Configurations", "PluginFile",
+                "Installs a Geronimo plugin you've exported from a Geronimo server " +
+                "or downloaded from an external repository.  The file must be a " +
+                "properly configured Geronimo CAR file.  This is used to add new " +
+                "functionality to the Geronimo server.");
+    }
+
+    //todo: provide a way to handle a username and password for the remote repo?
+
+    public CommandInstallCAR(String command, String group, String helpArgumentList, String
helpText) {
+        super(command, group, helpArgumentList, helpText);
+    }
+
+    public void execute(PrintWriter out, ServerConnection connection, String[] args) throws
DeploymentException {
+        if(args.length == 0) {
+            throw new DeploymentSyntaxException("Must specify Plugin CAR file");
+        }
+        DeploymentManager dmgr = connection.getDeploymentManager();
+        if(dmgr instanceof GeronimoDeploymentManager) {
+            GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
+            File carFile = new File(args[0]);
+            carFile = carFile.getAbsoluteFile();
+            if(!carFile.exists() || !carFile.canRead()) {
+                throw new DeploymentException("CAR file cannot be read: "+carFile.getAbsolutePath());
+            }
+            Object key = mgr.startInstall(carFile, null, null);
+            long start = System.currentTimeMillis();
+            DownloadResults results = showProgress(mgr, key);
+            int time = (int)(System.currentTimeMillis() - start) / 1000;
+            System.out.println();
+            if(!results.isFailed()) {
+                System.out.println(DeployUtils.reformat("**** Installation Complete!", 4,
72));
+                for (int i = 0; i < results.getDependenciesPresent().length; i++) {
+                    Artifact uri = results.getDependenciesPresent()[i];
+                    System.out.print(DeployUtils.reformat("Used existing: "+uri, 4, 72));
+                }
+                for (int i = 0; i < results.getDependenciesInstalled().length; i++) {
+                    Artifact uri = results.getDependenciesInstalled()[i];
+                    System.out.print(DeployUtils.reformat("Installed new: "+uri, 4, 72));
+                }
+                System.out.println();
+                System.out.println(DeployUtils.reformat("Downloaded "+(results.getTotalDownloadBytes()/1024)+"
kB in "+time+"s ("+results.getTotalDownloadBytes()/(1024*time)+" kB/s)", 4, 72));
+            }
+            if(results.isFinished() && !results.isFailed() && results.getInstalledConfigIDs().length
== 1) {
+                Artifact target = results.getInstalledConfigIDs()[0];
+                System.out.print(DeployUtils.reformat("Now starting "+target+"...", 4, 72));
+                System.out.flush();
+                new CommandStart().execute(out, connection, new String[]{target.toString()});
+            }
+        } else {
+            throw new DeploymentException("Cannot install plugins when connected to "+connection.getServerURI());
+        }
+    }
+
+    private DownloadResults showProgress(GeronimoDeploymentManager mgr, Object key) {
+        System.out.println("Checking for status every 1000ms:");
+        while(true) {
+            DownloadResults results = mgr.checkOnInstall(key);
+            if(results.getCurrentFile() != null) {
+                if(results.getCurrentFilePercent() > -1) {
+                    System.out.println(results.getCurrentMessage()+" ("+results.getCurrentFilePercent()+"%)");
+                } else {
+                    System.out.println(results.getCurrentMessage());
+                }
+            }
+            if(results.isFinished()) {
+                if(results.isFailed()) {
+                    System.err.println("Installation FAILED: "+results.getFailure().getMessage());
+                }
+                return results;
+            }
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+                return results;
+            }
+        }
+    }
+}

Propchange: geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java?rev=394579&r1=394578&r2=394579&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
(original)
+++ geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
Sun Apr 16 16:33:53 2006
@@ -42,9 +42,9 @@
  */
 public class CommandListConfigurations extends AbstractCommand {
     public CommandListConfigurations() {
-        super("install-configs", "3. Geronimo Configurations", "MavenRepoURL",
-                "Lists the Geronimo configurations available in a Maven repository "+
-                "and lets you select configurations to download and install.  This "+
+        super("search-plugins", "3. Geronimo Configurations", "MavenRepoURL",
+                "Lists the Geronimo plugins available in a Maven repository "+
+                "and lets you select a plugin to download and install.  This "+
                 "is used to add new functionality to the Geronimo server.");
     }
 

Modified: geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployTool.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployTool.java?rev=394579&r1=394578&r2=394579&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployTool.java
(original)
+++ geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployTool.java
Sun Apr 16 16:33:53 2006
@@ -75,6 +75,7 @@
         registerCommand(new CommandStop());
         registerCommand(new CommandUndeploy());
         registerCommand(new CommandListConfigurations());
+        registerCommand(new CommandInstallCAR());
     }
 
     private boolean failed = false;

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java?rev=394579&r1=394578&r2=394579&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java
(original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java
Sun Apr 16 16:33:53 2006
@@ -19,6 +19,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.FileNotFoundException;
+import java.io.File;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
@@ -33,6 +34,8 @@
 import java.util.Map;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.jar.JarFile;
+import java.util.jar.JarEntry;
 import javax.security.auth.login.FailedLoginException;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -118,6 +121,51 @@
         }
     }
 
+    private ConfigurationArchiveData loadConfigurationArchive(File file) throws IOException,
ParserConfigurationException, SAXException {
+        if(!file.canRead()) {
+            log.error("Cannot read from downloaded CAR file "+file.getAbsolutePath());
+            return null;
+        }
+        JarFile jar = new JarFile(file);
+        Document doc;
+        try {
+            JarEntry entry = jar.getJarEntry("META-INF/geronimo-plugin.xml");
+            if(entry == null) {
+                log.error("Downloaded CAR file does not contain META-INF/geronimo-plugin.xml
file");
+                jar.close();
+                return null;
+            }
+            InputStream in = jar.getInputStream(entry);
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder builder = factory.newDocumentBuilder();
+            doc = builder.parse(in);
+            in.close();
+        } finally {
+            jar.close();
+        }
+        Element root = doc.getDocumentElement();
+        NodeList configs = root.getElementsByTagName("configuration");
+        if(configs.getLength() != 1) {
+            log.error("Configuration archive "+file.getAbsolutePath()+" does not have exactly
one configuration in META-INF/geronimo-plugin.xml");
+            return null;
+        }
+        ConfigurationMetadata data = processConfiguration((Element) configs.item(0));
+        String repo = getChildText(root, "source-repository");
+        URL repoURL;
+        if(repo == null || repo.equals("")) {
+            log.warn("Configuration archive "+file.getAbsolutePath()+" does not list a repository
for downloading dependencies.");
+            repoURL = null;
+        } else {
+            repoURL = new URL(repo);
+        }
+        String[] others = getChildrenText(root, "backup-repository");
+        URL[] backups = new URL[others.length];
+        for (int i = 0; i < backups.length; i++) {
+            backups[i] = new URL(others[i]);
+        }
+        return new ConfigurationArchiveData(repoURL, backups, data);
+    }
+
     private ConfigurationList loadConfiguration(URL repo, InputStream in) throws ParserConfigurationException,
IOException, SAXException {
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         DocumentBuilder builder = factory.newDocumentBuilder();
@@ -128,64 +176,7 @@
         List results = new ArrayList();
         for (int i = 0; i < configs.getLength(); i++) {
             Element config = (Element) configs.item(i);
-            String configId = getChildText(config, "config-id");
-            NodeList licenseNodes = config.getElementsByTagName("license");
-            ConfigurationMetadata.License[] licenses = new ConfigurationMetadata.License[licenseNodes.getLength()];
-            for(int j=0; j<licenseNodes.getLength(); j++) {
-                Element node = (Element) licenseNodes.item(j);
-                licenses[j] = new ConfigurationMetadata.License(getText(node), Boolean.valueOf(node.getAttribute("osi-approved")).booleanValue());
-            }
-            boolean eligible = true;
-            NodeList preNodes = config.getElementsByTagName("prerequisite");
-            ConfigurationMetadata.Prerequisite[] prereqs = new ConfigurationMetadata.Prerequisite[preNodes.getLength()];
-            for(int j=0; j<preNodes.getLength(); j++) {
-                Element node = (Element) preNodes.item(j);
-                String originalConfigId = getChildText(node, "id");
-                Artifact artifact = Artifact.create(originalConfigId.replaceAll("\\*", ""));
-                boolean present = resolver.queryArtifacts(artifact).length > 0;
-                prereqs[j] = new ConfigurationMetadata.Prerequisite(artifact, present,
-                        getChildText(node, "resource-type"), getChildText(node, "description"));
-                if(!present) {
-                    log.debug(configId+" is not eligible due to missing "+prereqs[j].getConfigId());
-                    eligible = false;
-                }
-            }
-            String[] gerVersions = getChildrenText(config, "geronimo-version");
-            if(gerVersions.length > 0) {
-                String version = serverInfo.getVersion();
-                boolean match = false;
-                for (int j = 0; j < gerVersions.length; j++) {
-                    String gerVersion = gerVersions[j];
-                    if(gerVersion.equals(version)) {
-                        match = true;
-                        break;
-                    }
-                }
-                if(!match) eligible = false;
-            }
-            String[] jvmVersions = getChildrenText(config, "jvm-version");
-            if(jvmVersions.length > 0) {
-                String version = System.getProperty("java.version");
-                boolean match = false;
-                for (int j = 0; j < jvmVersions.length; j++) {
-                    String jvmVersion = jvmVersions[j];
-                    if(version.startsWith(jvmVersion)) {
-                        match = true;
-                        break;
-                    }
-                }
-                if(!match) eligible = false;
-            }
-            Artifact artifact = Artifact.create(configId);
-            boolean installed = configManager.isLoaded(artifact);
-            log.trace("Checking "+configId+": installed="+installed+", eligible="+eligible);
-            ConfigurationMetadata data = new ConfigurationMetadata(artifact, getChildText(config,
"name"),
-                    getChildText(config, "description"), getChildText(config, "category"),
installed, eligible);
-            data.setGeronimoVersions(gerVersions);
-            data.setJvmVersions(jvmVersions);
-            data.setLicenses(licenses);
-            data.setPrerequisites(prereqs);
-            data.setDependencies(getChildrenText(config, "dependency"));
+            ConfigurationMetadata data = processConfiguration(config);
             results.add(data);
         }
         String[] backups = getChildrenText(root, "backup-repository");
@@ -202,6 +193,68 @@
         return new ConfigurationList(repo, backupURLs, data);
     }
 
+    private ConfigurationMetadata processConfiguration(Element config) {
+        String configId = getChildText(config, "config-id");
+        NodeList licenseNodes = config.getElementsByTagName("license");
+        ConfigurationMetadata.License[] licenses = new ConfigurationMetadata.License[licenseNodes.getLength()];
+        for(int j=0; j<licenseNodes.getLength(); j++) {
+            Element node = (Element) licenseNodes.item(j);
+            licenses[j] = new ConfigurationMetadata.License(getText(node), Boolean.valueOf(node.getAttribute("osi-approved")).booleanValue());
+        }
+        boolean eligible = true;
+        NodeList preNodes = config.getElementsByTagName("prerequisite");
+        ConfigurationMetadata.Prerequisite[] prereqs = new ConfigurationMetadata.Prerequisite[preNodes.getLength()];
+        for(int j=0; j<preNodes.getLength(); j++) {
+            Element node = (Element) preNodes.item(j);
+            String originalConfigId = getChildText(node, "id");
+            Artifact artifact = Artifact.create(originalConfigId.replaceAll("\\*", ""));
+            boolean present = resolver.queryArtifacts(artifact).length > 0;
+            prereqs[j] = new ConfigurationMetadata.Prerequisite(artifact, present,
+                    getChildText(node, "resource-type"), getChildText(node, "description"));
+            if(!present) {
+                log.debug(configId+" is not eligible due to missing "+prereqs[j].getConfigId());
+                eligible = false;
+            }
+        }
+        String[] gerVersions = getChildrenText(config, "geronimo-version");
+        if(gerVersions.length > 0) {
+            String version = serverInfo.getVersion();
+            boolean match = false;
+            for (int j = 0; j < gerVersions.length; j++) {
+                String gerVersion = gerVersions[j];
+                if(gerVersion.equals(version)) {
+                    match = true;
+                    break;
+                }
+            }
+            if(!match) eligible = false;
+        }
+        String[] jvmVersions = getChildrenText(config, "jvm-version");
+        if(jvmVersions.length > 0) {
+            String version = System.getProperty("java.version");
+            boolean match = false;
+            for (int j = 0; j < jvmVersions.length; j++) {
+                String jvmVersion = jvmVersions[j];
+                if(version.startsWith(jvmVersion)) {
+                    match = true;
+                    break;
+                }
+            }
+            if(!match) eligible = false;
+        }
+        Artifact artifact = Artifact.create(configId);
+        boolean installed = configManager.isLoaded(artifact);
+        log.trace("Checking "+configId+": installed="+installed+", eligible="+eligible);
+        ConfigurationMetadata data = new ConfigurationMetadata(artifact, getChildText(config,
"name"),
+                getChildText(config, "description"), getChildText(config, "category"), installed,
eligible);
+        data.setGeronimoVersions(gerVersions);
+        data.setJvmVersions(jvmVersions);
+        data.setLicenses(licenses);
+        data.setPrerequisites(prereqs);
+        data.setDependencies(getChildrenText(config, "dependency"));
+        return data;
+    }
+
     private String getChildText(Element root, String property) {
         NodeList children = root.getChildNodes();
         for(int i=0; i<children.getLength(); i++) {
@@ -254,27 +307,44 @@
 
     public DownloadResults install(ConfigurationList list, String username, String password)
{
         DownloadResults results = new DownloadResults();
+        install(list, username, password, results);
+        return results;
+    }
+
+    public void install(ConfigurationList list, String username, String password, DownloadPoller
poller) {
         try {
             for (int i = 0; i < list.getConfigurations().length; i++) {
                 ConfigurationMetadata metadata = list.getConfigurations()[i];
                 downloadArtifact(metadata.getConfigId(), list.getMainRepository(), list.getBackupRepositories(),
-                        username, password, new ResultsFileWriteMonitor(results));
+                        username, password, new ResultsFileWriteMonitor(poller));
+                poller.addInstalledConfigID(metadata.getConfigId());
             }
         } catch (Exception e) {
-            results.setFailure(e);
+            poller.setFailure(e);
         } finally {
-            results.setFinished();
+            poller.setFinished();
         }
-        return results;
     }
 
-    public void install(ConfigurationList list, String username, String password, DownloadPoller
poller) {
+    /**
+     * Installs from a pre-downloaded CAR file
+     */
+    public void install(File carFile, String username, String password, DownloadPoller poller)
{
         try {
-            for (int i = 0; i < list.getConfigurations().length; i++) {
-                ConfigurationMetadata metadata = list.getConfigurations()[i];
-                downloadArtifact(metadata.getConfigId(), list.getMainRepository(), list.getBackupRepositories(),
-                        username, password, new ResultsFileWriteMonitor(poller));
+            // 1. Extract the configuration metadata
+            ConfigurationArchiveData data = loadConfigurationArchive(carFile);
+            if(data == null) {
+                throw new IllegalArgumentException("Invalid Configuration Archive "+carFile.getAbsolutePath()+"
see server log for details");
             }
+            
+            // 2. Install the CAR into the repository
+            ResultsFileWriteMonitor monitor = new ResultsFileWriteMonitor(poller);
+            writeableRepo.copyToRepository(carFile, data.getConfiguration().getConfigId(),
monitor);
+
+            // 3. Download all the dependencies
+            downloadArtifact(data.getConfiguration().getConfigId(), data.getRepository(),
data.getBackups(),
+                    username, password, monitor);
+            poller.addInstalledConfigID(data.getConfiguration().getConfigId());
         } catch (Exception e) {
             poller.setFailure(e);
         } finally {
@@ -288,6 +358,23 @@
         Runnable work = new Runnable() {
             public void run() {
                 install(configsToInstall, username, password, results);
+            }
+        };
+        asyncKeys.put(key, results);
+        try {
+            threadPool.execute("Configuration Installer", work);
+        } catch (InterruptedException e) {
+            throw new RuntimeException("Unable to start work", e);
+        }
+        return key;
+    }
+
+    public Object startInstall(final File carFile, final String username, final String password)
{
+        Object key = getNextKey();
+        final DownloadResults results = new DownloadResults();
+        Runnable work = new Runnable() {
+            public void run() {
+                install(carFile, username, password, results);
             }
         };
         asyncKeys.put(key, results);

Added: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationArchiveData.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationArchiveData.java?rev=394579&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationArchiveData.java
(added)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationArchiveData.java
Sun Apr 16 16:33:53 2006
@@ -0,0 +1,49 @@
+/**
+ *
+ * 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.system.configuration;
+
+import java.io.Serializable;
+import java.net.URL;
+
+/**
+ * The metadata included with a downloaded CAR file
+ *
+ * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
+ */
+public class ConfigurationArchiveData implements Serializable {
+    private final URL repository;
+    private final URL[] backups;
+    private final ConfigurationMetadata configuration;
+
+    public ConfigurationArchiveData(URL repository, URL[] backups, ConfigurationMetadata
configuration) {
+        this.repository = repository;
+        this.backups = backups;
+        this.configuration = configuration;
+    }
+
+    public URL getRepository() {
+        return repository;
+    }
+
+    public URL[] getBackups() {
+        return backups;
+    }
+
+    public ConfigurationMetadata getConfiguration() {
+        return configuration;
+    }
+}

Propchange: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationArchiveData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationInstaller.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationInstaller.java?rev=394579&r1=394578&r2=394579&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationInstaller.java
(original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationInstaller.java
Sun Apr 16 16:33:53 2006
@@ -17,6 +17,7 @@
 package org.apache.geronimo.system.configuration;
 
 import java.io.IOException;
+import java.io.File;
 import java.net.URL;
 import javax.security.auth.login.FailedLoginException;
 
@@ -70,7 +71,7 @@
 
     /**
      * Installs a configuration from a remote repository into the local Geronimo server,
-     * including all its dependencies.  The method return immediately, providing a key
+     * including all its dependencies.  The method returns immediately, providing a key
      * that can be used to poll the status of the download operation.  Note that the
      * installation does not throw exceptions on failure, but instead sets the failure
      * property of the DownloadResults that the caller can poll for.
@@ -84,6 +85,28 @@
      * @return A key that can be passed to checkOnInstall
      */
     public Object startInstall(ConfigurationList configsToInstall, String username, String
password);
+
+    /**
+     * Installs a configuration downloaded from a remote repository into the local Geronimo
+     * server, including all its dependencies.  The method returns immediately, providing
a
+     * key that can be used to poll the status of the download operation.  Note that the
+     * installation does not throw exceptions on failure, but instead sets the failure
+     * property of the DownloadResults that the caller can poll for.
+     *
+     * @param carFile   A CAR file downloaded from a remote repository.  This is a packaged
+     *                  configuration with included configuration information, but it may
+     *                  still have external dependencies that need to be downloaded
+     *                  separately.  The metadata in the CAR file includes a repository URL
+     *                  for these downloads, and the username and password arguments are
+     *                  used in conjunction with that.
+     * @param username  Optional username, if the maven repo uses HTTP Basic authentication.
+     *                  Set this to null if no authentication is required.
+     * @param password  Optional password, if the maven repo uses HTTP Basic authentication.
+     *                  Set this to null if no authentication is required.
+     *
+     * @return A key that can be passed to checkOnInstall
+     */
+    public Object startInstall(File carFile, String username, String password);
 
     /**
      * Gets the current progress of a download operation.  Note that once the

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadPoller.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadPoller.java?rev=394579&r1=394578&r2=394579&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadPoller.java
(original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadPoller.java
Sun Apr 16 16:33:53 2006
@@ -25,6 +25,8 @@
  * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
  */
 public interface DownloadPoller {
+    void addInstalledConfigID(Artifact dep);
+    
     void addDependencyPresent(Artifact dep);
 
     void addDependencyInstalled(Artifact dep);

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadResults.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadResults.java?rev=394579&r1=394578&r2=394579&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadResults.java
(original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadResults.java
Sun Apr 16 16:33:53 2006
@@ -28,6 +28,7 @@
  * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
  */
 public class DownloadResults implements Serializable, DownloadPoller {
+    private List installedConfigIDs = new ArrayList();
     private List dependenciesPresent = new ArrayList();
     private List dependenciesInstalled = new ArrayList();
     private String currentFile;
@@ -37,6 +38,10 @@
     private boolean finished;
     private long totalDownloadBytes = 0;
 
+    public void addInstalledConfigID(Artifact dep) {
+        installedConfigIDs.add(dep);
+    }
+
     public void addDependencyPresent(Artifact dep) {
         dependenciesPresent.add(dep);
     }
@@ -90,6 +95,17 @@
      */
     public Exception getFailure() {
         return failure;
+    }
+
+    /**
+     * Gets the list of the originally requested Config IDs that were
+     * successfully installed.  Ordinarily this is not necessary, but
+     * it may be important in case of failure midway through, or if the
+     * request passed previously downloaded configurations on the command
+     * line and the caller doesn't know what the Config IDs are.
+     */
+    public Artifact[] getInstalledConfigIDs() {
+        return (Artifact[]) installedConfigIDs.toArray(new Artifact[installedConfigIDs.size()]);
     }
 
     /**

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java?rev=394579&r1=394578&r2=394579&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java
(original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java
Sun Apr 16 16:33:53 2006
@@ -168,7 +168,7 @@
     }
 
     public void copyToRepository(InputStream source, Artifact destination, FileWriteMonitor
monitor) throws IOException {
-        // is this a wrtiable repository
+        // is this a writable repository
         if (!rootFile.canWrite()) {
             throw new IllegalStateException("This repository is not writable: " + rootFile.getAbsolutePath()
+ ")");
         }
@@ -187,7 +187,7 @@
 
         if (destination.getType().equalsIgnoreCase("car")) {
             System.out.println("############################################################");
-            System.out.println("# Installed artifact");
+            System.out.println("# Installed configuration");
             System.out.println("#   id = " + destination);
             System.out.println("#   location = " + location);
             System.out.println("############################################################");

Modified: geronimo/branches/1.1/modules/system/src/schema/config-list.xsd
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/schema/config-list.xsd?rev=394579&r1=394578&r2=394579&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/schema/config-list.xsd (original)
+++ geronimo/branches/1.1/modules/system/src/schema/config-list.xsd Sun Apr 16 16:33:53 2006
@@ -42,7 +42,7 @@
             </xs:documentation>
         </xs:annotation>
     </xs:element>
-    <xs:element name="geronimo-configuration" type="list:configuration-descriptorType">
+    <xs:element name="geronimo-plugin" type="list:configuration-descriptorType">
         <xs:annotation>
             <xs:documentation>
                 The geronimo-configuration root element is used as the config file



Mime
View raw message