[rhq] Branch 'release/jon3.1.x' - modules/plugins
lkrejci
lkrejci at fedoraproject.org
Fri Aug 17 18:03:15 UTC 2012
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstallationInfo.java | 47 ++++++++--
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java | 7 +
2 files changed, 48 insertions(+), 6 deletions(-)
New commits:
commit 34bfcba9e2c9d9e1a740fab63b8d871d1dc77310
Author: Lukas Krejci <lkrejci at redhat.com>
Date: Fri Aug 17 19:20:48 2012 +0200
[BZ 834353] - Distinguish between BRMS 5.(1|2).0 and EWP 5.1.x by looking
for BRMS specific jars in the client directory.
(cherry picked from commit 30c5e81759f5166873e49fd3486614c282203f47)
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstallationInfo.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstallationInfo.java
index cae73f3..a45237d 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstallationInfo.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstallationInfo.java
@@ -23,6 +23,7 @@
package org.rhq.plugins.jbossas5.helper;
import java.io.File;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
@@ -43,11 +44,11 @@ public class JBossInstallationInfo {
private static final String EPP_IMPL_VERSION_PREFIX = "JBoss-EPP";
private static final ComparableVersion VERSION_4_2 = new ComparableVersion("4.2");
- private final JBossProductType productType;
- private final String version;
- private final String defaultBindAddress;
- private final boolean isEap;
- private final String majorVersion;
+ private JBossProductType productType;
+ private String version;
+ private String defaultBindAddress;
+ private boolean isEap;
+ private String majorVersion;
public JBossInstallationInfo(File installationDir) throws IOException {
File binDir = new File(installationDir, "bin");
@@ -63,11 +64,47 @@ public class JBossInstallationInfo {
if (-1 == majorVersionIndex) {
throw new RuntimeException("Unexpected run.jar implementation version, can't parse: " + this.version);
}
+
+ fixProductTypeAndVersion(jarManifestAttributes, installationDir);
+
this.defaultBindAddress = getDefaultServerName(this.version);
this.isEap = determineEap(jarManifestAttributes);
this.majorVersion = version.substring(0, version.indexOf('.'));
}
+ /**
+ * Tries to make sense of the mess of JBoss product versioning.
+ *
+ * @param jarManifestAttributes
+ * @param installationDir
+ */
+ private void fixProductTypeAndVersion(Attributes jarManifestAttributes, File installationDir) {
+ //the main mess is with BRMS < 5.3.0 being advertised as EWP
+ if (productType == JBossProductType.EWP && version.startsWith("5.1")) {
+ //this still can be a BRMS server... We can check that by looking for drools jars
+ //in the client. Brittle you say? Yes, of course ;)
+ File client = new File(installationDir, "client");
+ if (client.exists() && client.isDirectory()) {
+ boolean containsBrmsJars = false;
+
+ for(String file : client.list()) {
+ if (file.endsWith("BRMS.jar")) {
+ containsBrmsJars = true;
+ break;
+ }
+ }
+
+ if (containsBrmsJars) {
+ productType = JBossProductType.BRMS;
+ if ("5.1.1".equals(version)) {
+ //BRMS 5.2.0 is based on EWP 5.1.1
+ version = "5.2.0";
+ }
+ }
+ }
+ }
+ }
+
public JBossProductType getProductType() {
return this.productType;
}
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java
index de5d837..312ea80 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java
@@ -54,7 +54,12 @@ public enum JBossProductType {
/**
* Determines the product type (AS, EAP, EWP, or SOA) based on the Implementation-Title MANIFEST.MF attribute.
- *
+ * <p>
+ * Note that this method is <b>NOT</b> always correct about the actual version of the product, because
+ * certain version of certain products don't advertise the correct product/version in the manifest.
+ * <p>
+ * Use {@link JBossInstallationInfo} for a more thorough detection of the type and version of a product.
+ *
* @param attributes the attributes from a manifest file (typically run.jar or jboss-j2ee.jar)
*
* @return the product type (AS, EAP, EWP, or SOA)
More information about the rhq-commits
mailing list