From 81d5ca327a1000edba7713507a1b039c5ac6486a Mon Sep 17 00:00:00 2001 From: "Donald J. Brown" Date: Sun, 2 Sep 2007 14:33:15 +0000 Subject: [PATCH] Adding printing of jar and plugin info WW-2154 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@571991 13f79535-47bb-0310-9956-ffa450edef68 --- plugins/config-browser/pom.xml | 9 --- .../config_browser/ActionNamesAction.java | 2 +- .../config_browser/ConfigurationHelper.java | 22 +++++++ .../config_browser/ShowJarsAction.java | 62 +++++++++++++++++++ .../resources/config-browser/page-header.ftl | 3 + .../resources/config-browser/showJars.ftl | 50 +++++++++++++++ .../src/main/resources/struts-plugin.xml | 4 ++ 7 files changed, 142 insertions(+), 10 deletions(-) create mode 100644 plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ShowJarsAction.java create mode 100644 plugins/config-browser/src/main/resources/config-browser/showJars.ftl diff --git a/plugins/config-browser/pom.xml b/plugins/config-browser/pom.xml index 82fb704bb..525981846 100644 --- a/plugins/config-browser/pom.xml +++ b/plugins/config-browser/pom.xml @@ -40,13 +40,4 @@ http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/plugins/config-browser/ - diff --git a/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ActionNamesAction.java b/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ActionNamesAction.java index a98c02ffa..3ac51f259 100644 --- a/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ActionNamesAction.java +++ b/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ActionNamesAction.java @@ -44,7 +44,7 @@ public class ActionNamesAction extends ActionSupport { private Set namespaces; private String extension; - private ConfigurationHelper configHelper; + ConfigurationHelper configHelper; @Inject public void setConfigurationHelper(ConfigurationHelper cfg) { diff --git a/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ConfigurationHelper.java b/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ConfigurationHelper.java index 93695c2ea..43215b5d5 100644 --- a/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ConfigurationHelper.java +++ b/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ConfigurationHelper.java @@ -20,15 +20,24 @@ */ package org.apache.struts2.config_browser; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; import java.util.Collections; +import java.util.Iterator; +import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.Set; import org.apache.struts2.dispatcher.Dispatcher; +import org.apache.struts2.util.ClassLoaderUtils; import com.opensymphony.xwork2.config.Configuration; import com.opensymphony.xwork2.config.entities.ActionConfig; import com.opensymphony.xwork2.inject.Inject; +import com.opensymphony.xwork2.util.ClassLoaderUtil; +import com.opensymphony.xwork2.util.ResolverUtil; /** * ConfigurationHelper @@ -74,4 +83,17 @@ public class ConfigurationHelper { } return config; } + + public List getJarProperties() throws IOException { + ResolverUtil resolver = new ResolverUtil(); + List poms = new ArrayList(); + resolver.findNamedResource("pom.properties", "META-INF/maven"); + Set urls = resolver.getResources(); + for (URL url : urls) { + Properties p = new Properties(); + p.load(url.openStream()); + poms.add(p); + } + return poms; + } } diff --git a/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ShowJarsAction.java b/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ShowJarsAction.java new file mode 100644 index 000000000..70450afc9 --- /dev/null +++ b/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ShowJarsAction.java @@ -0,0 +1,62 @@ +/* + * $Id: ActionNamesAction.java 474191 2006-11-13 08:30:40Z mrdon $ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.struts2.config_browser; + +import java.io.IOException; +import java.net.URL; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import com.opensymphony.xwork2.inject.Container; +import com.opensymphony.xwork2.inject.Inject; +import com.opensymphony.xwork2.util.ClassLoaderUtil; + +/** + * Shows all constants as loaded by Struts + */ +public class ShowJarsAction extends ActionNamesAction { + + List poms; + + @Inject + public void setContainer(Container container) throws IOException { + poms = configHelper.getJarProperties(); + } + + public List getJarPoms() + { + return poms; + } + + public Iterator getPluginsLoaded() + { + try { + return ClassLoaderUtil.getResources("struts-plugin.xml", ShowJarsAction.class, false); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } +} diff --git a/plugins/config-browser/src/main/resources/config-browser/page-header.ftl b/plugins/config-browser/src/main/resources/config-browser/page-header.ftl index 2a58cb08f..abfba9db1 100644 --- a/plugins/config-browser/src/main/resources/config-browser/page-header.ftl +++ b/plugins/config-browser/src/main/resources/config-browser/page-header.ftl @@ -55,6 +55,9 @@
<@s.url id="beansLink" action="showBeans" includeParams="none" /> Beans
+
<@s.url id="jarsLink" action="showJars" includeParams="none" /> + Jars (requires Maven 2 data) +
diff --git a/plugins/config-browser/src/main/resources/config-browser/showJars.ftl b/plugins/config-browser/src/main/resources/config-browser/showJars.ftl new file mode 100644 index 000000000..557d73d97 --- /dev/null +++ b/plugins/config-browser/src/main/resources/config-browser/showJars.ftl @@ -0,0 +1,50 @@ +<#-- +/* + * $Id: pom.xml 559206 2007-07-24 21:01:18Z apetrelli $ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +--> +<#include "tigris-macros.ftl"/> +<@startPage pageTitle="Jars and Struts Plugins"/> +

Jars and Struts Plugins

+ + + + + + + + <#list jarPoms as pom> + class="b"<#else>class="a"> + + + + + +
Artifact IDGroup IDVersion
${pom.artifactId}${pom.groupId}${pom.version}
+ +
+

Discovered plugin XML

+
    + <#list pluginsLoaded as url> +
  • ${url}
  • + +
+ +<@endPage /> diff --git a/plugins/config-browser/src/main/resources/struts-plugin.xml b/plugins/config-browser/src/main/resources/struts-plugin.xml index 71181d23e..463b2b736 100644 --- a/plugins/config-browser/src/main/resources/struts-plugin.xml +++ b/plugins/config-browser/src/main/resources/struts-plugin.xml @@ -62,6 +62,10 @@ /config-browser/showBeans.ftl + + + /config-browser/showJars.ftl + /config-browser/simple-error.ftl