Author: ppitonak(a)redhat.com
Date: 2011-11-03 06:59:52 -0400 (Thu, 03 Nov 2011)
New Revision: 22871
Modified:
modules/tests/metamer/trunk/application/pom.xml
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/VersionBean.java
Log:
detection of JBoss AS 7 fixed
Modified: modules/tests/metamer/trunk/application/pom.xml
===================================================================
--- modules/tests/metamer/trunk/application/pom.xml 2011-11-02 16:29:54 UTC (rev 22870)
+++ modules/tests/metamer/trunk/application/pom.xml 2011-11-03 10:59:52 UTC (rev 22871)
@@ -12,7 +12,8 @@
02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-->
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -144,6 +145,14 @@
<artifactId>hibernate-validator</artifactId>
<version>4.1.0.Final</version>
</dependency>
+
+ <!-- JBoss AS7 management -->
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-process-controller</artifactId>
+ <version>[7.0.2.Final,)</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
@@ -180,7 +189,7 @@
<SCM-Revision>${buildNumber}</SCM-Revision>
<SCM-Timestamp>${timestamp}</SCM-Timestamp>
<!-- define SLF4J dependency in JBoss AS 7 -->
- <Dependencies>org.slf4j</Dependencies>
+
<Dependencies>org.slf4j,org.jboss.as.process-controller</Dependencies>
</manifestEntries>
</archive>
</configuration>
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/VersionBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/VersionBean.java 2011-11-02
16:29:54 UTC (rev 22870)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/VersionBean.java 2011-11-03
10:59:52 UTC (rev 22871)
@@ -69,7 +69,8 @@
InputStream inStream =
getClass().getClassLoader().getResourceAsStream("version.properties");
properties.load(inStream);
} catch (Exception e) {
- LOGGER.warn(
+ LOGGER
+ .warn(
"Unable to load version.properties using
PomVersion.class.getClassLoader().getResourceAsStream(...)",
e);
}
@@ -113,7 +114,7 @@
}
fullVersion = implementationTitle + " by " + implementationVendor +
", version " + implementationVersion
- + " SVN r. " + scmRevision;
+ + " SVN r. " + scmRevision;
return fullVersion;
}
@@ -155,7 +156,6 @@
public String getJsfVersion() {
-
if (jsfVersion != null) {
return jsfVersion;
}
@@ -182,7 +182,8 @@
}
public String getBrowserVersion() {
- HttpServletRequest request = (HttpServletRequest)
FacesContext.getCurrentInstance().getExternalContext().getRequest();
+ HttpServletRequest request = (HttpServletRequest)
FacesContext.getCurrentInstance().getExternalContext()
+ .getRequest();
return request.getHeader("user-agent");
}
@@ -198,13 +199,21 @@
String result = null;
try {
- result = getJBossASVersionInfo();
+ result = getJBossAS7VersionInfo();
} catch (FailToRetrieveInfo e) {
result = e.getMessage();
}
if (result == null) {
try {
+ result = getJBossAS6VersionInfo();
+ } catch (FailToRetrieveInfo e) {
+ result = e.getMessage();
+ }
+ }
+
+ if (result == null) {
+ try {
result = getTomcatVersionInfo();
} catch (FailToRetrieveInfo e) {
result = e.getMessage();
@@ -223,8 +232,8 @@
@Override
protected Object obtainInfo() throws ClassNotFoundException,
IllegalAccessException,
- InstantiationException, SecurityException, NoSuchMethodException,
IllegalArgumentException,
- InvocationTargetException {
+ InstantiationException, SecurityException, NoSuchMethodException,
IllegalArgumentException,
+ InvocationTargetException {
Class<?> clazz =
Class.forName("org.apache.catalina.util.ServerInfo");
return clazz.getMethod("getServerInfo").invoke(null);
@@ -234,9 +243,9 @@
return result.replace("/", " ");
}
- public static String getJBossASVersionInfo() {
- String versionNumber = (String) new
JBossASVersionInfoObtainer("getVersionNumber").getInfo();
- String buildNumber = (String) new
JBossASVersionInfoObtainer("getBuildID").getInfo();
+ public static String getJBossAS6VersionInfo() {
+ String versionNumber = (String) new
JBossAS6VersionInfoObtainer("getVersionNumber").getInfo();
+ String buildNumber = (String) new
JBossAS6VersionInfoObtainer("getBuildID").getInfo();
if (versionNumber == null) {
return null;
@@ -254,18 +263,27 @@
return buffer.toString();
}
- private static class JBossASVersionInfoObtainer extends InfoObtainer {
+ public static String getJBossAS7VersionInfo() {
+ try {
+ Class.forName("org.jboss.as.version.Version");
+ } catch (ClassNotFoundException e) {
+ return null;
+ }
+ return "JBoss AS " + org.jboss.as.version.Version.AS_VERSION;
+ }
+ private static class JBossAS6VersionInfoObtainer extends InfoObtainer {
+
private String methodName;
- public JBossASVersionInfoObtainer(String methodName) {
+ public JBossAS6VersionInfoObtainer(String methodName) {
super();
this.methodName = methodName;
}
@Override
protected Object obtainInfo() throws ClassNotFoundException,
IllegalAccessException, InstantiationException,
- SecurityException, NoSuchMethodException, IllegalArgumentException,
InvocationTargetException {
+ SecurityException, NoSuchMethodException, IllegalArgumentException,
InvocationTargetException {
Class<?> clazz =
Class.forName("org.jboss.bootstrap.impl.as.server.ASVersion");
Object classInstance =
clazz.getMethod("getInstance").invoke(null);
@@ -276,8 +294,8 @@
private abstract static class InfoObtainer {
protected abstract Object obtainInfo() throws ClassNotFoundException,
IllegalAccessException,
- InstantiationException, SecurityException, NoSuchMethodException,
IllegalArgumentException,
- InvocationTargetException;
+ InstantiationException, SecurityException, NoSuchMethodException,
IllegalArgumentException,
+ InvocationTargetException;
public final Object getInfo() {
try {