geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r388868 - in /geronimo/trunk: configs/j2ee-system/src/plan/ modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/ modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/ modules/deploy-tool/src/java/org/apach...
Date Sun, 26 Mar 2006 01:09:55 GMT
Author: ammulder
Date: Sat Mar 25 17:09:54 2006
New Revision: 388868

URL: http://svn.apache.org/viewcvs?rev=388868&view=rev
Log:
Configuration installer works from the command line
 - use deploy tool argument install-configs and pass the Maven repo URL
   as an argument

Added:
    geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/GeronimoDeploymentManager.java
  (with props)
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
  (with props)
Modified:
    geronimo/trunk/configs/j2ee-system/src/plan/plan.xml
    geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployTool.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java

Modified: geronimo/trunk/configs/j2ee-system/src/plan/plan.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/configs/j2ee-system/src/plan/plan.xml?rev=388868&r1=388867&r2=388868&view=diff
==============================================================================
--- geronimo/trunk/configs/j2ee-system/src/plan/plan.xml (original)
+++ geronimo/trunk/configs/j2ee-system/src/plan/plan.xml Sat Mar 25 17:09:54 2006
@@ -82,9 +82,9 @@
         <reference name="ConfigurationInstallTarget">
             <name>Local</name>
         </reference>
-        <references name="AllConfigurations">
+        <references name="AllConfigStores">
           <pattern>
-            <gbean-name>geronimo.config:*</gbean-name>
+            <gbean-name>*:j2eeType=ConfigurationStore,*</gbean-name>
           </pattern>
         </references>
     </gbean>

Added: geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/GeronimoDeploymentManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/GeronimoDeploymentManager.java?rev=388868&view=auto
==============================================================================
--- geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/GeronimoDeploymentManager.java
(added)
+++ geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/GeronimoDeploymentManager.java
Sat Mar 25 17:09:54 2006
@@ -0,0 +1,29 @@
+/**
+ *
+ * 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.plugin;
+
+import org.apache.geronimo.system.configuration.ConfigurationInstaller;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+
+/**
+ * Enhanced features for Geronimo deployment manager
+ *
+ * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
+ */
+public interface GeronimoDeploymentManager extends DeploymentManager, ConfigurationInstaller
{
+}

Propchange: geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/GeronimoDeploymentManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java?rev=388868&r1=388867&r2=388868&view=diff
==============================================================================
--- geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
(original)
+++ geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
Sat Mar 25 17:09:54 2006
@@ -19,8 +19,13 @@
 import org.apache.geronimo.kernel.jmx.KernelDelegate;
 import org.apache.geronimo.deployment.plugin.local.DistributeCommand;
 import org.apache.geronimo.deployment.plugin.local.RedeployCommand;
+import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager;
+import org.apache.geronimo.system.configuration.ConfigurationMetadata;
+import org.apache.geronimo.system.configuration.DownloadResults;
+import org.apache.geronimo.gbean.GBeanQuery;
 
 import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
 import javax.management.remote.JMXConnector;
 import javax.enterprise.deploy.spi.Target;
 import javax.enterprise.deploy.spi.TargetModuleID;
@@ -29,14 +34,18 @@
 import java.io.InputStream;
 import java.net.InetAddress;
 import java.net.NetworkInterface;
+import java.net.URL;
+import java.net.URI;
 import java.util.Enumeration;
+import java.util.Set;
+import java.util.Iterator;
 
 /**
  * Connects to a Kernel in a remote VM (may or many not be on the same machine).
  *
  * @version $Rev$ $Date$
  */
-public class RemoteDeploymentManager extends JMXDeploymentManager {
+public class RemoteDeploymentManager extends JMXDeploymentManager implements GeronimoDeploymentManager
{
     private JMXConnector jmxConnector;
     private boolean isSameMachine;
 
@@ -115,5 +124,47 @@
         } else {
             return new org.apache.geronimo.deployment.plugin.remote.RedeployCommand(kernel,
moduleIDList, moduleArchive, deploymentPlan);
         }
+    }
+
+    public ConfigurationMetadata[] listConfigurations(URL mavenRepository) throws IOException
{
+        Set set = kernel.listGBeans(new GBeanQuery(null, "org.apache.geronimo.system.configuration.ConfigurationInstaller"));
+        for (Iterator it = set.iterator(); it.hasNext();) {
+            ObjectName name = (ObjectName) it.next();
+            try {
+                return (ConfigurationMetadata[]) kernel.invoke(name, "listConfigurations",
new Object[]{mavenRepository}, new String[]{URL.class.getName()});
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw new IOException("Unable to list configurations: "+e.getMessage());
+            }
+        }
+        return null;
+    }
+
+    public ConfigurationMetadata loadDependencies(URL mavenRepository, ConfigurationMetadata
source) throws IOException {
+        Set set = kernel.listGBeans(new GBeanQuery(null, "org.apache.geronimo.system.configuration.ConfigurationInstaller"));
+        for (Iterator it = set.iterator(); it.hasNext();) {
+            ObjectName name = (ObjectName) it.next();
+            try {
+                return (ConfigurationMetadata) kernel.invoke(name, "loadDependencies", new
Object[]{mavenRepository, source}, new String[]{URL.class.getName(), ConfigurationMetadata.class.getName()});
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw new IOException("Unable to load dependencies: "+e.getMessage());
+            }
+        }
+        return null;
+    }
+
+    public DownloadResults install(URL mavenRepository, URI configId) throws IOException
{
+        Set set = kernel.listGBeans(new GBeanQuery(null, "org.apache.geronimo.system.configuration.ConfigurationInstaller"));
+        for (Iterator it = set.iterator(); it.hasNext();) {
+            ObjectName name = (ObjectName) it.next();
+            try {
+                return (DownloadResults) kernel.invoke(name, "install", new Object[]{mavenRepository,
configId}, new String[]{URL.class.getName(), URI.class.getName()});
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw new IOException("Unable to install configurations: "+e.getMessage());
+            }
+        }
+        return null;
     }
 }

Added: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java?rev=388868&view=auto
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
(added)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
Sat Mar 25 17:09:54 2006
@@ -0,0 +1,148 @@
+/**
+ *
+ * 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 org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.util.SimpleEncryption;
+import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager;
+import org.apache.geronimo.system.configuration.ConfigurationMetadata;
+import org.apache.geronimo.system.configuration.DownloadResults;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import java.io.PrintWriter;
+import java.io.File;
+import java.io.InputStream;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.OutputStream;
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.Properties;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.net.URL;
+import java.net.URI;
+
+/**
+ * The CLI deployer logic to start.
+ *
+ * @version $Rev: 356097 $ $Date: 2005-12-11 20:29:03 -0500 (Sun, 11 Dec 2005) $
+ */
+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 "+
+                "is used to add new functionality to the Geronimo server.");
+    }
+
+    public CommandListConfigurations(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 Maven repository URL");
+        }
+        DeploymentManager dmgr = connection.getDeploymentManager();
+        if(dmgr instanceof GeronimoDeploymentManager) {
+            GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
+            ConfigurationMetadata[] data;
+            URL repository;
+            try {
+                repository = new URL(args[0]);
+                data = mgr.listConfigurations(repository);
+            } catch (IOException e) {
+                throw new DeploymentException("Unable to list configurations", e);
+            }
+            Map categories = new HashMap();
+            List available = new ArrayList();
+            for (int i = 0; i < data.length; i++) {
+                ConfigurationMetadata metadata = data[i];
+                List list = (List) categories.get(metadata.getCategory());
+                if(list == null) {
+                    list = new ArrayList();
+                    categories.put(metadata.getCategory(), list);
+                }
+                list.add(metadata);
+            }
+            for (Iterator it = categories.entrySet().iterator(); it.hasNext();) {
+                Map.Entry entry = (Map.Entry) it.next();
+                String category = (String) entry.getKey();
+                List items = (List) entry.getValue();
+                System.out.println();
+                System.out.print(DeployUtils.reformat(category, 4, 72));
+                for (int i = 0; i < items.size(); i++) {
+                    ConfigurationMetadata metadata = (ConfigurationMetadata) items.get(i);
+                    String prefix = "    ";
+                    if(!metadata.isInstalled()) {
+                        available.add(metadata);
+                        prefix = Integer.toString(available.size());
+                        if(available.size() < 10) {
+                            prefix += " ";
+                        }
+                        prefix += ": ";
+                    }
+                    System.out.print(DeployUtils.reformat(prefix+metadata.getDescription()+"
("+metadata.getVersion()+")", 8, 72));
+                    System.out.flush();
+                }
+            }
+            System.out.println();
+            System.out.print("Install Service [enter number or 'q' to quit]: ");
+            System.out.flush();
+            try {
+                BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+                String answer = in.readLine();
+                if(answer.equalsIgnoreCase("q")) {
+                    return;
+                }
+                int selection = Integer.parseInt(answer);
+                ConfigurationMetadata target = ((ConfigurationMetadata) available.get(selection
- 1));
+                DownloadResults results = mgr.install(repository, target.getConfigId());
+                for (int i = 0; i < results.getConfigurationsPresent().length; i++) {
+                    URI uri = results.getConfigurationsPresent()[i];
+                    System.out.print(DeployUtils.reformat("Using existing configuration "+uri,
4, 72));
+                }
+                for (int i = 0; i < results.getConfigurationsInstalled().length; i++)
{
+                    URI uri = results.getConfigurationsInstalled()[i];
+                    System.out.print(DeployUtils.reformat("Installed new configuration "+uri,
4, 72));
+                }
+                for (int i = 0; i < results.getDependenciesPresent().length; i++) {
+                    URI uri = results.getDependenciesPresent()[i];
+                    System.out.print(DeployUtils.reformat("Using existing library "+uri,
4, 72));
+                }
+                for (int i = 0; i < results.getDependenciesInstalled().length; i++) {
+                    URI uri = results.getDependenciesInstalled()[i];
+                    System.out.print(DeployUtils.reformat("Installed new library "+uri, 4,
72));
+                }
+                new CommandStart().execute(out, connection, new String[]{target.getConfigId().toString()});
+            } catch (IOException e) {
+                throw new DeploymentException("Unable to install configuration", e);
+            } catch(NumberFormatException e) {
+                throw new DeploymentException("Invalid response");
+            }
+        } else {
+            throw new DeploymentException("Cannot list repositories when connected to "+connection.getServerURI());
+        }
+    }
+}

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

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployTool.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployTool.java?rev=388868&r1=388867&r2=388868&view=diff
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployTool.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployTool.java
Sat Mar 25 17:09:54 2006
@@ -74,6 +74,7 @@
         registerCommand(new CommandStart());
         registerCommand(new CommandStop());
         registerCommand(new CommandUndeploy());
+        registerCommand(new CommandListConfigurations());
     }
 
     private boolean failed = false;

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java?rev=388868&r1=388867&r2=388868&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java
(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java
Sat Mar 25 17:09:54 2006
@@ -24,6 +24,7 @@
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.ConfigurationInfo;
 import org.apache.geronimo.kernel.repository.WriteableRepository;
 
 import java.io.File;
@@ -53,13 +54,13 @@
  */
 public class ConfigInstallerGBean implements ConfigurationInstaller {
     private final static Log log = LogFactory.getLog(ConfigInstallerGBean.class);
-    private Collection configurations;
+    private Collection configStores;
     private WriteableRepository writeableRepo;
     private ConfigurationStore configStore;
     private Map configIdToFile = new HashMap();
 
-    public ConfigInstallerGBean(Collection configurations, WriteableRepository writeableRepo,
ConfigurationStore configStore) {
-        this.configurations = configurations;
+    public ConfigInstallerGBean(Collection configStores, WriteableRepository writeableRepo,
ConfigurationStore configStore) {
+        this.configStores = configStores;
         this.writeableRepo = writeableRepo;
         this.configStore = configStore;
     }
@@ -71,9 +72,13 @@
         }
         URL url = new URL(repository+"geronimo-configurations.properties");
         Set set = new HashSet();
-        for (Iterator it = configurations.iterator(); it.hasNext();) {
-            Configuration config = (Configuration) it.next();
-            set.add(config.getId().toString());
+        for (Iterator it = configStores.iterator(); it.hasNext();) {
+            ConfigurationStore store = (ConfigurationStore) it.next();
+            List list = store.listConfigurations();
+            for (int i = 0; i < list.size(); i++) {
+                ConfigurationInfo info = (ConfigurationInfo) list.get(i);
+                set.add(info.getConfigID().toString());
+            }
         }
         InputStream in = url.openStream();
         Properties props = new Properties();
@@ -121,9 +126,13 @@
 
     public DownloadResults install(URL mavenRepository, URI configId) throws IOException
{
         Set set = new HashSet();
-        for (Iterator it = configurations.iterator(); it.hasNext();) {
-            Configuration next = (Configuration) it.next();
-            set.add(next.getId());
+        for (Iterator it = configStores.iterator(); it.hasNext();) {
+            ConfigurationStore store = (ConfigurationStore) it.next();
+            List list = store.listConfigurations();
+            for (int i = 0; i < list.size(); i++) {
+                ConfigurationInfo info = (ConfigurationInfo) list.get(i);
+                set.add(info.getConfigID());
+            }
         }
         DownloadResults results = new DownloadResults();
         processConfiguration(configId,writeableRepo,mavenRepository.toString(),set,results);
@@ -134,6 +143,9 @@
 
 
     private String getURL(String configId, String baseRepositoryURL) {
+        if(!baseRepositoryURL.endsWith("/")) {
+            baseRepositoryURL += "/";
+        }
         String[] parts = configId.split("/");
         return baseRepositoryURL+parts[0]+"/"+parts[3]+"s/"+parts[1]+"-"+parts[2]+"."+parts[3];
     }
@@ -152,6 +164,9 @@
     }
 
     private void processConfiguration(URI configId, WriteableRepository repo, String repoURL,
Set configurations, DownloadResults results) throws IOException {
+        if(!repoURL.endsWith("/")) {
+            repoURL += "/";
+        }
         // Make sure we have a local copy of the CAR
         String id = configId.toString();
         File file;
@@ -187,13 +202,15 @@
                 results.addDependencyInstalled(dep);
             }
             // Download the parents
-            for (int i = 0; i < parentIds.length; i++) {
-                URI uri = parentIds[i];
-                if(configurations.contains(uri)) {
-                    results.addConfigurationPresent(uri);
-                    continue;
+            if(parentIds != null) {
+                for (int i = 0; i < parentIds.length; i++) {
+                    URI uri = parentIds[i];
+                    if(configurations.contains(uri)) {
+                        results.addConfigurationPresent(uri);
+                        continue;
+                    }
+                    processConfiguration(uri, repo, repoURL, configurations, results);
                 }
-                processConfiguration(uri, repo, repoURL, configurations, results);
             }
             // Install the configuration
             configStore.install(file.toURL());
@@ -210,12 +227,12 @@
 
     static {
         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(ConfigInstallerGBean.class);
-        infoFactory.addReference("AllConfigurations", Configuration.class);
         infoFactory.addReference("DependencyInstallTarget", WriteableRepository.class, "GBean");
         infoFactory.addReference("ConfigurationInstallTarget", ConfigurationStore.class,
"ConfigurationStore");
+        infoFactory.addReference("AllConfigStores", ConfigurationStore.class, "ConfigurationStore");
         infoFactory.addInterface(ConfigurationInstaller.class);
 
-        infoFactory.setConstructor(new String[]{"AllConfigurations", "DependencyInstallTarget",
"ConfigurationInstallTarget"});
+        infoFactory.setConstructor(new String[]{"AllConfigStores", "DependencyInstallTarget",
"ConfigurationInstallTarget"});
 
         GBEAN_INFO = infoFactory.getBeanInfo();
     }



Mime
View raw message