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
This commit is contained in:
Donald J. Brown
2007-09-02 14:33:15 +00:00
parent af781d0079
commit 81d5ca327a
7 changed files with 142 additions and 10 deletions
-9
View File
@@ -40,13 +40,4 @@
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/plugins/config-browser/</url>
</scm>
<!--
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts-core</artifactId>
<version>1.3.5</version>
</dependency>
</dependencies>
-->
</project>
@@ -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) {
@@ -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<Properties> getJarProperties() throws IOException {
ResolverUtil resolver = new ResolverUtil();
List<Properties> poms = new ArrayList<Properties>();
resolver.findNamedResource("pom.properties", "META-INF/maven");
Set<URL> urls = resolver.getResources();
for (URL url : urls) {
Properties p = new Properties();
p.load(url.openStream());
poms.add(p);
}
return poms;
}
}
@@ -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<Properties> poms;
@Inject
public void setContainer(Container container) throws IOException {
poms = configHelper.getJarProperties();
}
public List<Properties> getJarPoms()
{
return poms;
}
public Iterator<URL> getPluginsLoaded()
{
try {
return ClassLoaderUtil.getResources("struts-plugin.xml", ShowJarsAction.class, false);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
@@ -55,6 +55,9 @@
<div><@s.url id="beansLink" action="showBeans" includeParams="none" />
<a href="${beansLink}">Beans</a>
</div>
<div><@s.url id="jarsLink" action="showJars" includeParams="none" />
<a href="${jarsLink}">Jars (requires Maven 2 data)</a>
</div>
</div>
</div>
<div id="projecttools" class="toolgroup">
@@ -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"/>
<h3>Jars and Struts Plugins</h3>
<table width="100%">
<tr>
<th>Artifact ID</th>
<th>Group ID</th>
<th>Version</th>
</tr>
<#list jarPoms as pom>
<tr <#if pom_index%2 gt 0>class="b"<#else>class="a"</#if>>
<td>${pom.artifactId}</td>
<td>${pom.groupId}</td>
<td>${pom.version}</td>
</tr>
</#list>
</table>
<br />
<h4> Discovered plugin XML</h4>
<ul>
<#list pluginsLoaded as url>
<li>${url}</li>
</#list>
</ul>
<@endPage />
@@ -62,6 +62,10 @@
<action name="showBeans" class="org.apache.struts2.config_browser.ShowBeansAction">
<result type="freemarker" name="success">/config-browser/showBeans.ftl</result>
</action>
<action name="showJars" class="org.apache.struts2.config_browser.ShowJarsAction">
<result type="freemarker" name="success">/config-browser/showJars.ftl</result>
</action>
<action name="showValidators" class="org.apache.struts2.config_browser.ListValidatorsAction">
<result name="error" type="freemarker">/config-browser/simple-error.ftl</result>