You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by am...@apache.org on 2006/05/02 06:09:07 UTC

svn commit: r398798 - in /geronimo/branches/1.1: applications/console-standard/src/java/org/apache/geronimo/console/car/ modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/

Author: ammulder
Date: Mon May  1 21:09:04 2006
New Revision: 398798

URL: http://svn.apache.org/viewcvs?rev=398798&view=rev
Log:
Fixes to plugin handling
 - better auto-generation for Maven 2 servlet (GERONIMO-1964)
 - tweaks to command-line installation

Modified:
    geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java
    geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java
    geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java

Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java?rev=398798&r1=398797&r2=398798&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java (original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java Mon May  1 21:09:04 2006
@@ -59,6 +59,9 @@
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.kernel.repository.Version;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.geronimo.system.configuration.ConfigurationInstaller;
+import org.apache.geronimo.system.configuration.ConfigurationArchiveData;
+import org.apache.geronimo.system.configuration.ConfigurationMetadata;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Text;
@@ -202,6 +205,7 @@
         ServerInfo serverInfo = helper.getServers(helper.getDomains()[0])[0].getServerInfo();
         String version = serverInfo.getVersion();
         ConfigurationManager mgr = ConfigurationUtil.getConfigurationManager(kernel);
+        ConfigurationInstaller installer = getInstaller(kernel);
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         DocumentBuilder builder = factory.newDocumentBuilder();
         Document doc = builder.newDocument();
@@ -213,28 +217,42 @@
             List configs = mgr.listConfigurations(name);
             for (int j = 0; j < configs.size(); j++) {
                 ConfigurationInfo info = (ConfigurationInfo) configs.get(j);
+                ConfigurationArchiveData archiveData = installer.getPluginMetadata(info.getConfigID());
+                ConfigurationMetadata data = archiveData.getConfiguration();
                 Element config = doc.createElement("configuration");
                 root.appendChild(config);
-                createText(doc, config, "name", info.getConfigID().toString());
-                createText(doc, config, "config-id", info.getConfigID().toString());
+                createText(doc, config, "name", data.getName());
+                createText(doc, config, "config-id", data.getConfigId().toString());
                 createText(doc, config, "category", "Geronimo Deployments");
-                createText(doc, config, "geronimo-version", version);
-                if(info.getConfigID().toString().indexOf("jetty") > -1) {
-                    writePrerequisite(doc, config, "geronimo/jetty/*/car", "Jetty", "Tomcat");
-                    createText(doc, config, "prerequisite", "geronimo/jetty/car");
-                } else if(info.getConfigID().toString().indexOf("tomcat") > -1) {
-                    createText(doc, config, "prerequisite", "geronimo/tomcat/car");
-                    writePrerequisite(doc, config, "geronimo/tomcat/*/car", "Tomcat", "Jetty");
+                createText(doc, config, "description", data.getCategory().equals("Unknown") ? "Automatically generated plugin metadata" : data.getDescription());
+                for (int k = 0; k < data.getLicenses().length; k++) {
+                    ConfigurationMetadata.License license = data.getLicenses()[k];
+                    Element lic = doc.createElement("license");
+                    lic.setAttribute("osi-approved", Boolean.toString(license.isOsiApproved()));
+                    createText(doc, lic, license.getName());
+                    config.appendChild(lic);
                 }
-                try {
-                    ConfigurationData data = mgr.getStoreForConfiguration(info.getConfigID()).loadConfiguration(info.getConfigID());
-                    List deps = data.getEnvironment().getDependencies();
-                    for (int k = 0; k < deps.size(); k++) {
-                        Dependency dep = (Dependency) deps.get(k);
-                        createText(doc, config, "dependency", dep.getArtifact().toString());
-                    }
-                } catch (Exception e) {
-                    log.warn("Unable to generate dependencies for configuration "+info.getConfigID(), e);
+                String[] versions = data.getGeronimoVersions();
+                for (int k = 0; k < versions.length; k++) {
+                    String ver = versions[k];
+                    createText(doc, config, "geronimo-version", ver);
+                }
+                versions = data.getJvmVersions();
+                for (int k = 0; k < versions.length; k++) {
+                    String ver = versions[k];
+                    createText(doc, config, "jvm-version", ver);
+                }
+                for (int k = 0; k < data.getPrerequisites().length; k++) {
+                    ConfigurationMetadata.Prerequisite prereq = data.getPrerequisites()[k];
+                    writePrerequisite(doc, config, prereq);
+                }
+                for (int k = 0; k < data.getDependencies().length; k++) {
+                    String dep = data.getDependencies()[k];
+                    createText(doc, config, "dependency", dep);
+                }
+                for (int k = 0; k < data.getObsoletes().length; k++) {
+                    String obs = data.getObsoletes()[k];
+                    createText(doc, config, "obsoletes", obs);
                 }
             }
         }
@@ -244,6 +262,14 @@
         xform.transform(new DOMSource(doc), new StreamResult(out));
     }
 
+    private ConfigurationInstaller getInstaller(Kernel kernel) {
+        Set names = kernel.listGBeans(new AbstractNameQuery(ConfigurationInstaller.class.getName()));
+        if(names.size() == 0) {
+            return null;
+        }
+        return (ConfigurationInstaller) kernel.getProxyManager().createProxy((AbstractName) names.iterator().next(), ConfigurationInstaller.class);
+    }
+
     private void generateMavenFile(Kernel kernel, PrintWriter writer, String groupId, String artifactId, boolean reply) throws ParserConfigurationException, TransformerException {
         ConfigurationManager mgr = ConfigurationUtil.getConfigurationManager(kernel);
         Artifact[] artifacts = mgr.getArtifactResolver().queryArtifacts(new Artifact(groupId, artifactId, (Version)null, null));
@@ -275,15 +301,12 @@
         xform.transform(new DOMSource(doc), new StreamResult(writer));
     }
 
-    private void writePrerequisite(Document doc, Element config, String configId, String server, String notServer) {
+    private void writePrerequisite(Document doc, Element config, ConfigurationMetadata.Prerequisite req) {
         Element prereq = doc.createElement("prerequisite");
         config.appendChild(prereq);
-        createText(doc, prereq, "id", configId);
-        createText(doc, prereq, "description",
-                "This is a web application or web-related module, configured for the " +
-                server +" web container.  It will not run on "+notServer+" versions of " +
-                "Geronimo.  If you need a "+notServer+" version of this application, " +
-                "you'll need to get it from another "+notServer+" Geronimo installation.");
+        createText(doc, prereq, "id", req.getConfigId().toString());
+        createText(doc, prereq, "resource-type", req.getResourceType());
+        createText(doc, prereq, "description", req.getDescription());
     }
 
     private void createText(Document doc, Element parent, String name, String text) {
@@ -291,5 +314,10 @@
         parent.appendChild(child);
         Text node = doc.createTextNode(text);
         child.appendChild(node);
+    }
+
+    private void createText(Document doc, Element parent, String text) {
+        Text node = doc.createTextNode(text);
+        parent.appendChild(node);
     }
 }

Modified: 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=398798&r1=398797&r2=398798&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java (original)
+++ geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java Mon May  1 21:09:04 2006
@@ -87,7 +87,7 @@
         }
     }
 
-    private DownloadResults showProgress(GeronimoDeploymentManager mgr, Object key) {
+    static DownloadResults showProgress(GeronimoDeploymentManager mgr, Object key) {
         System.out.println("Checking for status every 1000ms:");
         String last = null, status;
         while(true) {

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=398798&r1=398797&r2=398798&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 Mon May  1 21:09:04 2006
@@ -86,8 +86,8 @@
                 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));
+                out.println();
+                out.print(DeployUtils.reformat(category, 4, 72));
                 for (int i = 0; i < items.size(); i++) {
                     ConfigurationMetadata metadata = (ConfigurationMetadata) items.get(i);
                     String prefix = "    ";
@@ -99,13 +99,18 @@
                         }
                         prefix += ": ";
                     }
-                    System.out.print(DeployUtils.reformat(prefix+metadata.getName()+" ("+metadata.getVersion()+")", 8, 72));
-                    System.out.flush();
+                    out.print(DeployUtils.reformat(prefix+metadata.getName()+" ("+metadata.getVersion()+")", 8, 72));
+                    out.flush();
                 }
             }
-            System.out.println();
-            System.out.print("Install Service [enter number or 'q' to quit]: ");
-            System.out.flush();
+            if(available.size() == 0) {
+                out.println();
+                out.println("No plugins from this site are eligible for installation.");
+                return;
+            }
+            out.println();
+            out.print("Install Service [enter number or 'q' to quit]: ");
+            out.flush();
             try {
                 BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                 String answer = in.readLine();
@@ -116,25 +121,25 @@
                 ConfigurationMetadata target = ((ConfigurationMetadata) available.get(selection - 1));
                 long start = System.currentTimeMillis();
                 Object key = mgr.startInstall(ConfigurationList.createInstallList(data, target.getConfigId()), null, null);
-                DownloadResults results = showProgress(mgr, key);
+                DownloadResults results = CommandInstallCAR.showProgress(mgr, key);
                 int time = (int)(System.currentTimeMillis() - start) / 1000;
-                System.out.println();
+                out.println();
                 if(!results.isFailed()) {
-                    System.out.println(DeployUtils.reformat("**** Installation Complete!", 4, 72));
+                    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));
+                        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));
+                        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));
+                    out.println();
+                    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()) {
-                    System.out.print(DeployUtils.reformat("Now starting "+target.getConfigId()+"...", 4, 72));
-                    System.out.flush();
+                    out.print(DeployUtils.reformat("Now starting "+target.getConfigId()+"...", 4, 72));
+                    out.flush();
                     new CommandStart().execute(out, connection, new String[]{target.getConfigId().toString()});
                 }
             } catch (IOException e) {
@@ -144,31 +149,6 @@
             }
         } else {
             throw new DeploymentException("Cannot list repositories 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;
-            }
         }
     }
 }