modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/StandaloneManagedDeploymentComponent.java
| 19 ++++++++++
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/JarContentDelegate.java
| 17 ++++++++
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java
| 19 ++++++++++
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/JarContentDelegate.java
| 16 ++++++++
4 files changed, 71 insertions(+)
New commits:
commit a24c60686a9a5aef505e864745d667d5c149d9b9
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Dec 21 11:36:07 2011 -0600
[BZ 767393] Update JBoss AS5 plugin to use display version for manifest versions.
diff --git
a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/StandaloneManagedDeploymentComponent.java
b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/StandaloneManagedDeploymentComponent.java
index a8eba4d..7d51d3f 100644
---
a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/StandaloneManagedDeploymentComponent.java
+++
b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/StandaloneManagedDeploymentComponent.java
@@ -60,6 +60,8 @@ import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.util.ZipUtil;
import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.core.util.file.ContentFileInfo;
+import org.rhq.core.util.file.JarContentFileInfo;
import org.rhq.plugins.jbossas5.util.DeploymentUtils;
import org.rhq.plugins.jbossas5.util.FileContentDelegate;
@@ -145,6 +147,8 @@ public class StandaloneManagedDeploymentComponent extends
AbstractManagedDeploym
String fileName = this.deploymentFile.getName();
String sha256 = getSHA256(this.deploymentFile);
String version = getVersion(sha256);
+ String displayVersion = getDisplayVersion(deploymentFile);
+
// Package name is the deployment's file name (e.g. foo.ear).
PackageDetailsKey key = new PackageDetailsKey(fileName, version, PKG_TYPE_FILE,
ARCHITECTURE);
ResourcePackageDetails packageDetails = new ResourcePackageDetails(key);
@@ -155,6 +159,7 @@ public class StandaloneManagedDeploymentComponent extends
AbstractManagedDeploym
packageDetails.setFileCreatedDate(null); // TODO: get created date via SIGAR
packageDetails.setSHA256(sha256);
packageDetails.setInstallationTimestamp(Long.valueOf(System.currentTimeMillis()));
+ packageDetails.setDisplayVersion(displayVersion);
Set<ResourcePackageDetails> packages = new
HashSet<ResourcePackageDetails>();
packages.add(packageDetails);
@@ -187,6 +192,20 @@ public class StandaloneManagedDeploymentComponent extends
AbstractManagedDeploym
return "[sha256=" + sha256 + "]";
}
+ /**
+ * Retrieve the display version for the component. The display version should be
stored
+ * in the manifest of the application (implementation and/or specification version).
+ * It will attempt to retrieve the version for both archived or exploded
deployments.
+ *
+ * @param file component file
+ * @return
+ */
+ private String getDisplayVersion(File file) {
+ //JarContentFileInfo extracts the version from archived and exploded deployments
+ ContentFileInfo contentFileInfo = new JarContentFileInfo(file);
+ return contentFileInfo.getVersion(null);
+ }
+
public RemovePackagesResponse removePackages(Set<ResourcePackageDetails>
packages) {
throw new UnsupportedOperationException("Cannot remove the package backing
an EAR/WAR resource.");
}
diff --git
a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/JarContentDelegate.java
b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/JarContentDelegate.java
index 3bb920a..da4ba86 100644
---
a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/JarContentDelegate.java
+++
b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/JarContentDelegate.java
@@ -36,6 +36,8 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.content.PackageDetailsKey;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
import org.rhq.core.util.MessageDigestGenerator;
+import org.rhq.core.util.file.ContentFileInfo;
+import org.rhq.core.util.file.JarContentFileInfo;
/**
* Discovers Jar files as artifacts including loading their manifest version into the
artifact config.
@@ -123,6 +125,7 @@ public class JarContentDelegate extends FileContentDelegate {
details.setFileSize(file.length());
details.setClassification(MIME_TYPE_JAR);
details.setSHA256(sha256);
+ details.setDisplayVersion(getDisplayVersion(file));
details.setExtraProperties(config);
} catch (IOException e) {
@@ -143,4 +146,18 @@ public class JarContentDelegate extends FileContentDelegate {
private String getVersion(String sha256) {
return "[sha256=" + sha256 + "]";
}
+
+ /**
+ * Retrieve the display version for the component. The display version should be
stored
+ * in the manifest of the application (implementation and/or specification version).
+ * It will attempt to retrieve the version for both archived or exploded
deployments.
+ *
+ * @param file component file
+ * @return
+ */
+ private String getDisplayVersion(File file) {
+ //JarContentFileInfo extracts the version from archived and exploded deployments
+ ContentFileInfo contentFileInfo = new JarContentFileInfo(file);
+ return contentFileInfo.getVersion(null);
+ }
}
commit 14352ceb1fb5468dd4718592fb7facd72693dac7
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Dec 21 11:20:58 2011 -0600
[BZ 767247] Update JBoss AS4 plugin to use display version for manifest set version.
diff --git
a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java
b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java
index bf7e925..b2e0185 100644
---
a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java
+++
b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java
@@ -54,6 +54,8 @@ import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.core.pluginapi.util.FileUtils;
import org.rhq.core.util.ZipUtil;
import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.core.util.file.ContentFileInfo;
+import org.rhq.core.util.file.JarContentFileInfo;
import org.rhq.plugins.jbossas.helper.MainDeployer;
import org.rhq.plugins.jbossas.util.FileContentDelegate;
import org.rhq.plugins.jmx.MBeanResourceComponent;
@@ -129,6 +131,8 @@ public class ApplicationComponent extends
MBeanResourceComponent<JBossASServerCo
String sha256 = getSHA256(file);
String version = getVersion(sha256);
+ String displayVersion = getDisplayVersion(file);
+
PackageDetailsKey key = new PackageDetailsKey(fileName, version,
PKG_TYPE_FILE, ARCHITECTURE);
ResourcePackageDetails details = new ResourcePackageDetails(key);
details.setFileName(fileName);
@@ -139,6 +143,7 @@ public class ApplicationComponent extends
MBeanResourceComponent<JBossASServerCo
details.setFileCreatedDate(file.lastModified()); // TODO: get created date
via SIGAR
details.setSHA256(sha256);
details.setInstallationTimestamp(Long.valueOf(System.currentTimeMillis()));
+ details.setDisplayVersion(displayVersion);
packages.add(details);
}
@@ -167,6 +172,20 @@ public class ApplicationComponent extends
MBeanResourceComponent<JBossASServerCo
return "[sha256=" + sha256 + "]";
}
+ /**
+ * Retrieve the display version for the component. The display version should be
stored
+ * in the manifest of the application (implementation and/or specification version).
+ * It will attempt to retrieve the version for both archived or exploded
deployments.
+ *
+ * @param file component file
+ * @return
+ */
+ private String getDisplayVersion(File file) {
+ //JarContentFileInfo extracts the version from archived and exploded deployments
+ ContentFileInfo contentFileInfo = new JarContentFileInfo(file);
+ return contentFileInfo.getVersion(null);
+ }
+
public RemovePackagesResponse removePackages(Set<ResourcePackageDetails>
packages) {
throw new UnsupportedOperationException("Cannot remove the package backing
an EAR/WAR resource.");
}
diff --git
a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/JarContentDelegate.java
b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/JarContentDelegate.java
index 9dd080e..33a2f02 100644
---
a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/JarContentDelegate.java
+++
b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/JarContentDelegate.java
@@ -36,6 +36,8 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.content.PackageDetailsKey;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
import org.rhq.core.util.MessageDigestGenerator;
+import org.rhq.core.util.file.ContentFileInfo;
+import org.rhq.core.util.file.JarContentFileInfo;
/**
* Discovers Jar files as artifacts including loading their manifest version into the
artifact config.
@@ -121,6 +123,7 @@ public class JarContentDelegate extends FileContentDelegate {
details.setFileSize(file.length());
details.setClassification(MIME_TYPE_JAR);
details.setSHA256(sha256);
+ details.setDisplayVersion(getDisplayVersion(file));
details.setExtraProperties(config);
} catch (IOException e) {
@@ -142,4 +145,17 @@ public class JarContentDelegate extends FileContentDelegate {
return "[sha256=" + sha256 + "]";
}
+ /**
+ * Retrieve the display version for the component. The display version should be
stored
+ * in the manifest of the application (implementation and/or specification version).
+ * It will attempt to retrieve the version for both archived or exploded
deployments.
+ *
+ * @param file component file
+ * @return
+ */
+ private String getDisplayVersion(File file) {
+ //JarContentFileInfo extracts the version from archived and exploded deployments
+ ContentFileInfo contentFileInfo = new JarContentFileInfo(file);
+ return contentFileInfo.getVersion(null);
+ }
}
\ No newline at end of file
Show replies by date