modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java
| 83 +++---
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
| 4
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java
| 2
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarComponent.java
| 119 ++++------
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/WarDiscoveryHelper.java
| 65 ++---
publish.sh
| 4
6 files changed, 125 insertions(+), 152 deletions(-)
New commits:
commit 12d26d21ff46c3575baa7fdf3f8409f3287e460f
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Feb 28 10:44:19 2012 -0600
Turn off maven publishing. Not fully implemented ...
diff --git a/publish.sh b/publish.sh
index a1b1c1e..266f1d8 100755
--- a/publish.sh
+++ b/publish.sh
@@ -341,8 +341,8 @@ build_from_source()
#========================================================================================
publish_external_maven_repository()
{
- mvn -Ddbsetup-do-not-check-schema=true -Dmaven.test.skip=true -P publish
$MAVEN_RELEASE_PERFORM_GOAL
- [ "$?" -ne 0 ] && abort "Release build failed. Please see above
Maven output for details, fix any issues, then try again."
+ #mvn -Ddbsetup-do-not-check-schema=true -Dmaven.test.skip=true -P publish
$MAVEN_RELEASE_PERFORM_GOAL
+ #[ "$?" -ne 0 ] && abort "Release build failed. Please see
above Maven output for details, fix any issues, then try again."
}
commit 247456ce168e31728e4f94f9441c24240972f524
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Feb 29 09:38:07 2012 -0600
Light refactoring on JBoss AS4 plugin code.
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 b2e0185..4c66a6b 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
@@ -93,7 +93,6 @@ public class ApplicationComponent extends
MBeanResourceComponent<JBossASServerCo
// ContentFacet Implementation --------------------------------------------
public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
-
Configuration pluginConfiguration =
getResourceContext().getPluginConfiguration();
String fullFileName =
pluginConfiguration.getSimpleValue(FILENAME_PLUGIN_CONFIG_PROP, null);
@@ -103,8 +102,9 @@ public class ApplicationComponent extends
MBeanResourceComponent<JBossASServerCo
if (packageFile.isDirectory()) {
fileToSend = File.createTempFile("rhq", ".zip");
ZipUtil.zipFileOrDirectory(packageFile, fileToSend);
- } else
+ } else {
fileToSend = packageFile;
+ }
return new BufferedInputStream(new FileInputStream(fileToSend));
} catch (IOException e) {
throw new RuntimeException("Failed to retrieve package bits for " +
packageDetails, e);
@@ -112,7 +112,6 @@ public class ApplicationComponent extends
MBeanResourceComponent<JBossASServerCo
}
public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type)
{
-
Set<ResourcePackageDetails> packages = new
HashSet<ResourcePackageDetails>();
Configuration pluginConfiguration =
getResourceContext().getPluginConfiguration();
@@ -151,41 +150,6 @@ public class ApplicationComponent extends
MBeanResourceComponent<JBossASServerCo
return packages;
}
- private String getSHA256(File file) {
-
- String sha256 = null;
-
- try {
- FileContentDelegate fileContentDelegate = new FileContentDelegate(file, null,
null);
- sha256 = fileContentDelegate.getSHA(file);
- } catch (Exception iex) {
- //log exception but move on, discovery happens often. No reason to hold up
anything.
- if (log.isDebugEnabled()) {
- log.debug("Problem calculating digest of package [" +
file.getPath() + "]." + iex.getMessage());
- }
- }
-
- return sha256;
- }
-
- 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);
- }
-
public RemovePackagesResponse removePackages(Set<ResourcePackageDetails>
packages) {
throw new UnsupportedOperationException("Cannot remove the package backing
an EAR/WAR resource.");
}
@@ -252,7 +216,6 @@ public class ApplicationComponent extends
MBeanResourceComponent<JBossASServerCo
}
// Deploy was successful!
-
deleteBackupOfOriginalFile(backupOfOriginalFile);
DeployPackagesResponse response = new
DeployPackagesResponse(ContentResponseResult.SUCCESS);
@@ -293,7 +256,6 @@ public class ApplicationComponent extends
MBeanResourceComponent<JBossASServerCo
} else {
log.info("deleteResource: File [" + fullFileName + "] was not
found - ignoring.");
}
-
}
// MeasurementFacet Implementation --------------------------------------------
@@ -355,7 +317,7 @@ public class ApplicationComponent extends
MBeanResourceComponent<JBossASServerCo
return
pluginConfiguration.getSimple(FILENAME_PLUGIN_CONFIG_PROP).getStringValue();
}
- public JBossASServerComponent getParentResourceComponent() {
+ public JBossASServerComponent<?> getParentResourceComponent() {
return getResourceContext().getParentResourceComponent();
}
@@ -378,10 +340,10 @@ public class ApplicationComponent extends
MBeanResourceComponent<JBossASServerCo
}
backup = new File(fileName + ".bak");
-
if (!backup.exists()) {
throw new FileNotFoundException("Backup file " + backup + "
does not exist");
}
+
File directory = backup.getParentFile();
if (!directory.canWrite()) {
throw new IOException("Can not modify directory " + directory);
@@ -396,7 +358,6 @@ public class ApplicationComponent extends
MBeanResourceComponent<JBossASServerCo
}
// Now that we have moved the original to a backup, try to move the real backup
in
-
good = backup.renameTo(file);
if (!good) {
// move backup in failed
@@ -409,8 +370,8 @@ public class ApplicationComponent extends
MBeanResourceComponent<JBossASServerCo
// installing from backup worked
FileUtils.purge(tmpBackup, true);
}
- getParentResourceComponent().deployFile(file);
+ getParentResourceComponent().deployFile(file);
}
/**
@@ -500,4 +461,38 @@ public class ApplicationComponent extends
MBeanResourceComponent<JBossASServerCo
}
return tempFile;
}
+
+ private String getSHA256(File file) {
+ String sha256 = null;
+
+ try {
+ FileContentDelegate fileContentDelegate = new FileContentDelegate(file, null,
null);
+ sha256 = fileContentDelegate.getSHA(file);
+ } catch (Exception iex) {
+ //log exception but move on, discovery happens often. No reason to hold up
anything.
+ if (log.isDebugEnabled()) {
+ log.debug("Problem calculating digest of package [" +
file.getPath() + "]." + iex.getMessage());
+ }
+ }
+
+ return sha256;
+ }
+
+ 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);
+ }
}
diff --git
a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
index 45de746..73b4072 100644
---
a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
+++
b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
@@ -924,6 +924,7 @@ public class JBossASServerComponent<T extends
ResourceComponent<?>> implements M
deployFile(path);
} catch (MainDeployer.DeployerException e) {
log.debug("Failed to deploy [" + path + "] - undeploying and
deleting [" + path + "]...");
+ report.setStatus(CreateResourceStatus.FAILURE);
try {
undeployFile(path);
FileUtils.purge(path, true);
@@ -950,7 +951,8 @@ public class JBossASServerComponent<T extends
ResourceComponent<?>> implements M
if (entry != null) {
is = jfile.getInputStream(entry);
SAXBuilder saxBuilder = new SAXBuilder();
- SelectiveSkippingEntityResolver entityResolver =
SelectiveSkippingEntityResolver.getDtdAndXsdSkippingInstance();
+ SelectiveSkippingEntityResolver entityResolver =
SelectiveSkippingEntityResolver
+ .getDtdAndXsdSkippingInstance();
saxBuilder.setEntityResolver(entityResolver);
Document doc = saxBuilder.build(is);
diff --git
a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java
b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java
index 8283423..d1b9910 100644
---
a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java
+++
b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java
@@ -102,7 +102,7 @@ public class JBossASTomcatDiscoveryComponent implements
ResourceDiscoveryCompone
boolean pre42 = jbossWebDir.getName().startsWith(EMBEDDED_TOMCAT_PRE42_DIR);
String jarFileName = (pre42) ? "catalina.jar" :
"jbossweb.jar";
File jarFile = new File(jbossWebDir, jarFileName);
- ClassLoader classLoader = new URLClassLoader(new URL[] { jarFile.toURL() });
+ ClassLoader classLoader = new URLClassLoader(new URL[] { jarFile.toURI().toURL()
});
InputStream stream =
classLoader.getResourceAsStream(SERVER_INFO_PROPERTIES_RESOURCE);
String version = null;
if (stream != null) {
diff --git
a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarComponent.java
b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarComponent.java
index 1993e7b..514e75e 100644
--- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarComponent.java
+++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarComponent.java
@@ -1,25 +1,25 @@
- /*
- * Jopr Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
+/*
+ * Jopr Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
package org.rhq.plugins.jbossas;
import java.io.File;
@@ -44,8 +44,8 @@ import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.measurement.calltime.CallTimeData;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.core.pluginapi.util.ResponseTimeConfiguration;
@@ -55,12 +55,12 @@ import org.rhq.plugins.jbossas.util.WarDeploymentInformation;
import org.rhq.plugins.jbossas.util.WarDiscoveryHelper;
import org.rhq.plugins.jmx.util.ObjectNameQueryUtility;
- /**
- * A resource component for managing a web application (WAR) deployed to a JBossAS
server.
- *
- * @author Ian Springer
- * @author Heiko W. Rupp
- */
+/**
+* A resource component for managing a web application (WAR) deployed to a JBossAS
server.
+*
+* @author Ian Springer
+* @author Heiko W. Rupp
+*/
public class WarComponent extends ApplicationComponent implements OperationFacet,
DeleteResourceFacet {
private static final String SERVLET_PREFIX = "Servlet.";
public static final String CONTEXT_ROOT_CONFIG_PROP = "contextRoot";
@@ -84,7 +84,7 @@ public class WarComponent extends ApplicationComponent implements
OperationFacet
private static final String SESSION_NAME_BASE_TEMPLATE =
"jboss.web:host=%HOST%,type=Manager,path=%PATH%";
- // WebModule=//localhost/test-simple,service=ClusterManager
+ //WebModule=//localhost/test-simple,service=ClusterManager
private static final String CLUSTER_SESSION_NAME_BASE_TEMPLATE =
"jboss.web:service=ClusterManager,WebModule=//%HOST%%PATH%";
private static final String SESSION_PREFIX = "Session.";
private static final String VHOST_PREFIX = "Vhost";
@@ -94,24 +94,17 @@ public class WarComponent extends ApplicationComponent implements
OperationFacet
private final Log log = LogFactory.getLog(this.getClass());
+ //Mapping non-clustered names -> attribute name in the cluster manager
+ private final String[] CLUSTER_SESSION_ATTRIBUTE_NAMES = {
"maxInactiveInterval", "MaxInactiveInterval",
+ "activeSessions", "ActiveSessionCount",
"sessionCounter", "CreatedSessionCount",
"sessionAverageAliveTime", "",
+ "processingTime", "ProcessingTime", "maxActive",
"MaxActiveSessionCount", "maxActiveSessions",
+ "MaxActiveAllowed", "expiredSessions",
"ExpiredSessionCount", "rejectedSessions",
"RejectedSessionCount",
+ "sessionIdLength", "SessionIdLength" };
+
private EmsBean jbossWebMBean;
private ResponseTimeLogParser logParser;
- String vhost;
+ private String vhost;
private String contextRoot;
- // Mapping non-clustered names -> attribute name in the cluster manager
- private final String[] CLUSTER_SESSION_ATTRIBUTE_NAMES = {
- "maxInactiveInterval","MaxInactiveInterval",
- "activeSessions","ActiveSessionCount",
- "sessionCounter","CreatedSessionCount",
- "sessionAverageAliveTime","",
- "processingTime","ProcessingTime",
- "maxActive","MaxActiveSessionCount",
- "maxActiveSessions","MaxActiveAllowed",
- "expiredSessions","ExpiredSessionCount",
- "rejectedSessions","RejectedSessionCount",
- "sessionIdLength","SessionIdLength"
- };
-
@Override
public AvailabilityType getAvailability() {
@@ -146,13 +139,13 @@ public class WarComponent extends ApplicationComponent implements
OperationFacet
this.vhost = pluginConfig.getSimple(VHOST_CONFIG_PROP).getStringValue();
this.contextRoot =
pluginConfig.getSimple(CONTEXT_ROOT_CONFIG_PROP).getStringValue();
ResponseTimeConfiguration responseTimeConfig = new
ResponseTimeConfiguration(pluginConfig);
+
File logFile = responseTimeConfig.getLogFile();
if (logFile != null) {
this.logParser = new ResponseTimeLogParser(logFile);
this.logParser.setExcludes(responseTimeConfig.getExcludes());
this.logParser.setTransforms(responseTimeConfig.getTransforms());
}
-
}
@Override
@@ -212,21 +205,20 @@ public class WarComponent extends ApplicationComponent implements
OperationFacet
EmsConnection jmxConnection = getEmsConnection();
String servletMBeanNames =
SESSION_NAME_BASE_TEMPLATE.replace("%PATH%",
- WarDiscoveryHelper.getContextPath(this.contextRoot));
+ WarDiscoveryHelper.getContextPath(this.contextRoot));
servletMBeanNames = servletMBeanNames.replace("%HOST%", vhost);
ObjectNameQueryUtility queryUtility = new
ObjectNameQueryUtility(servletMBeanNames);
List<EmsBean> mBeans =
jmxConnection.queryBeans(queryUtility.getTranslatedQuery());
- if (mBeans.size()==0) {
+ if (mBeans.size() == 0) {
// retry with the cluster manager TODO select the local vs cluster mode on
discovery
servletMBeanNames =
CLUSTER_SESSION_NAME_BASE_TEMPLATE.replace("%PATH%",
- WarDiscoveryHelper.getContextPath(this.contextRoot));
+ WarDiscoveryHelper.getContextPath(this.contextRoot));
servletMBeanNames = servletMBeanNames.replace("%HOST%", vhost);
queryUtility = new ObjectNameQueryUtility(servletMBeanNames);
mBeans = jmxConnection.queryBeans(queryUtility.getTranslatedQuery());
- if (mBeans.size()>0)
+ if (mBeans.size() > 0)
isClustered = true;
-
}
String property = metricName.substring(SESSION_PREFIX.length());
@@ -247,8 +239,7 @@ public class WarComponent extends ApplicationComponent implements
OperationFacet
if (o instanceof Long) {
Long l = (Long) o;
ret = Double.valueOf(l);
- }
- else {
+ } else {
Integer i = (Integer) o;
ret = Double.valueOf(i);
}
@@ -259,21 +250,18 @@ public class WarComponent extends ApplicationComponent implements
OperationFacet
}
private String lookupClusteredAttributeName(String property) {
- for (int i = 0; i < CLUSTER_SESSION_ATTRIBUTE_NAMES.length ; i+=2) {
+ for (int i = 0; i < CLUSTER_SESSION_ATTRIBUTE_NAMES.length; i += 2) {
if (CLUSTER_SESSION_ATTRIBUTE_NAMES[i].equals(property))
- return CLUSTER_SESSION_ATTRIBUTE_NAMES[i+1];
+ return CLUSTER_SESSION_ATTRIBUTE_NAMES[i + 1];
}
return property;
}
private Double getServletMetric(String metricName) {
-
- EmsConnection jmxConnection = getEmsConnection();
-
String servletMBeanNames = SERVLET_NAME_BASE_TEMPLATE + ",WebModule=//"
+ this.vhost
- + WarDiscoveryHelper.getContextPath(this.contextRoot);
+ + WarDiscoveryHelper.getContextPath(this.contextRoot);
ObjectNameQueryUtility queryUtility = new
ObjectNameQueryUtility(servletMBeanNames);
- List<EmsBean> mBeans =
jmxConnection.queryBeans(queryUtility.getTranslatedQuery());
+ List<EmsBean> mBeans =
getEmsConnection().queryBeans(queryUtility.getTranslatedQuery());
long min = Long.MAX_VALUE;
long max = 0;
@@ -342,21 +330,16 @@ public class WarComponent extends ApplicationComponent implements
OperationFacet
throw new IllegalStateException("Could not find jboss.web MBean for WAR
'" + getApplicationName() + "'.");
}
- if (operation==WarOperation.REVERT) {
- // Lets see if we have a backup of ouselves. If so, install it.
-
+ if (operation == WarOperation.REVERT) {
try {
revertFromBackupFile();
return new OperationResult("Successfully reverted from
backup");
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new RuntimeException("Error reverting from Backup: " +
e.getMessage());
}
}
-
// The following are MBean operations.
-
EmsOperation mbeanOperation = this.jbossWebMBean.getOperation(name);
if (mbeanOperation == null) {
throw new IllegalStateException("Operation [" + name + "] not
found on bean ["
@@ -473,8 +456,6 @@ public class WarComponent extends ApplicationComponent implements
OperationFacet
return deploymentInformation;
}
-
-
private enum WarOperation {
START, STOP, RELOAD, REVERT
}
diff --git
a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/WarDiscoveryHelper.java
b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/WarDiscoveryHelper.java
index 48d4c46..152f2b2 100644
---
a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/WarDiscoveryHelper.java
+++
b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/WarDiscoveryHelper.java
@@ -42,8 +42,6 @@ import org.apache.commons.logging.LogFactory;
import org.mc4j.ems.connection.EmsConnection;
import org.mc4j.ems.connection.bean.EmsBean;
import org.mc4j.ems.connection.bean.attribute.EmsAttribute;
-
-import org.rhq.plugins.jmx.util.ObjectNameQueryUtility;
import org.xml.sax.InputSource;
import org.rhq.core.domain.configuration.Configuration;
@@ -55,6 +53,7 @@ import org.rhq.plugins.jbossas.JBossASServerComponent;
import org.rhq.plugins.jbossas.WarComponent;
import org.rhq.plugins.jbossas.WarDiscoveryComponent;
import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.jmx.util.ObjectNameQueryUtility;
/**
* Provides helper methods that are used by both {@link WarDiscoveryComponent} and {@link
EmbeddedWarDiscoveryComponent}
@@ -81,8 +80,8 @@ public class WarDiscoveryHelper {
}
public static Set<DiscoveredResourceDetails> initPluginConfigurations(
- JBossASServerComponent parentJBossASComponent,
Set<DiscoveredResourceDetails> warResources,
- ApplicationComponent parentEARComponent) {
+ JBossASServerComponent<?> parentJBossASComponent,
Set<DiscoveredResourceDetails> warResources,
+ ApplicationComponent parentEARComponent) {
EmsConnection jmxConnection = parentJBossASComponent.getEmsConnection();
File configPath = parentJBossASComponent.getConfigurationPath();
@@ -146,24 +145,23 @@ public class WarDiscoveryHelper {
String resourceName = baseResourceName + " (" +
webModuleName + ")";
String resourceDescription = baseResourceDescription + "
(" + webModuleName + ")";
myDetail = new
DiscoveredResourceDetails(discoResDetail.getResourceType(), key, resourceName,
- discoResDetail.getResourceVersion(), resourceDescription,
pluginConfigClone,
- discoResDetail.getProcessInfo());
+ discoResDetail.getResourceVersion(), resourceDescription,
pluginConfigClone,
+ discoResDetail.getProcessInfo());
initPluginConfiguration(info, rtLogDir, warResourcesIterator,
myDetail);
resultingResources.add(myDetail); // the cloned one
}
}
} else { // Our war was not in the list, the main deployer's
listDeployedModules()
- if (parentEARComponent==null) {
+ if (parentEARComponent == null) {
// WAR has no associated context root, so remove it from the list of
discovered resources...
// @todo Might not want to call remove, because, as an example, in
EC, the EC war file would end up being removed because this happens before it is
completely deployed
- warResourcesIterator.remove();
+ warResourcesIterator.remove();
if
(!discoResDetail.getResourceName().equals(ROOT_WEBAPP_RESOURCE_NAME)) {
- LOG
- .debug("The deployed WAR '"
- + discoResDetail.getResourceName()
- + "' does not have a jboss.web MBean (i.e.
context root) associated with it; it will not be added to inventory.");
+ LOG.debug("The deployed WAR '"
+ + discoResDetail.getResourceName()
+ + "' does not have a jboss.web MBean (i.e. context
root) associated with it; it will not be added to inventory.");
}
} else { // WAR within an EAR and distributable flag set in the war
@@ -175,14 +173,14 @@ public class WarDiscoveryHelper {
if (m.find()) {
warName = m.group(1);
}
- String contextRoot =
getContextRootFromEar(parentEARComponent,parentJBossASComponent,warName);
- warConfig.put(new
PropertySimple(WarComponent.CONTEXT_ROOT_CONFIG_PROP,contextRoot));
+ String contextRoot = getContextRootFromEar(parentEARComponent,
parentJBossASComponent, warName);
+ warConfig.put(new
PropertySimple(WarComponent.CONTEXT_ROOT_CONFIG_PROP, contextRoot));
- String webName =
getJbossWebNameFromContextRoot(contextRoot,parentJBossASComponent);
- warConfig.put(new
PropertySimple(WarComponent.JBOSS_WEB_NAME,webName));
+ String webName = getJbossWebNameFromContextRoot(contextRoot,
parentJBossASComponent);
+ warConfig.put(new PropertySimple(WarComponent.JBOSS_WEB_NAME,
webName));
- warConfig.put(new
PropertySimple(WarComponent.VHOST_CONFIG_PROP,"localhost"));
-
setRtLogInPluginConfig(rtLogDir,warConfig,contextRoot,"localhost"); // TODO
check if vhost can be != localhost
+ warConfig.put(new PropertySimple(WarComponent.VHOST_CONFIG_PROP,
"localhost"));
+ setRtLogInPluginConfig(rtLogDir, warConfig, contextRoot,
"localhost"); // TODO check if vhost can be != localhost
resultingResources.add(discoResDetail);
}
@@ -191,8 +189,6 @@ public class WarDiscoveryHelper {
return resultingResources;
}
-
-
/**
* Try to get the context root from the ear file this war is embedded in
* @param parentEARComponent the ApplicationComponent representing the EAR
@@ -201,17 +197,17 @@ public class WarDiscoveryHelper {
* @return context root of the war file
*/
private static String getContextRootFromEar(ApplicationComponent parentEARComponent,
- JBossASServerComponent
parentJBossASComponent,
- String warName) {
+ JBossASServerComponent<?> parentJBossASComponent, String warName) {
- String contextRoot =" - invalid - ";
+ String contextRoot = " - invalid - ";
// Get the ear and then the deploymentDescriptor attribute from it - this
directly contains the one and
// only context-root
- String objectNameTemplate =
"jboss.management.local:J2EEServer=Local,j2eeType=J2EEApplication,name=" +
parentEARComponent.getApplicationName();
+ String objectNameTemplate =
"jboss.management.local:J2EEServer=Local,j2eeType=J2EEApplication,name="
+ + parentEARComponent.getApplicationName();
ObjectNameQueryUtility queryUtility = new
ObjectNameQueryUtility(objectNameTemplate);
List<EmsBean> mBeans =
parentJBossASComponent.getEmsConnection().queryBeans(queryUtility.getTranslatedQuery());
- if (mBeans.size() ==1) {
+ if (mBeans.size() == 1) {
EmsBean theBean = mBeans.get(0);
EmsAttribute ddAttr =
theBean.getAttribute("deploymentDescriptor");
ddAttr.refresh();
@@ -224,29 +220,27 @@ public class WarDiscoveryHelper {
XPath xp = XPathFactory.newInstance().newXPath();
try {
- contextRoot =
xp.evaluate("/application/module/web/web-uri['" + warName
+"']/../context-root",is);
- }
- catch (XPathException xpe) {
+ contextRoot =
xp.evaluate("/application/module/web/web-uri['" + warName +
"']/../context-root", is);
+ } catch (XPathException xpe) {
xpe.printStackTrace(); // TODO fix this
}
}
-
return contextRoot;
}
-
private static String getJbossWebNameFromContextRoot(String contextRoot,
- JBossASServerComponent
parentJBossASComponent) {
+ JBossASServerComponent<?> parentJBossASComponent) {
if (contextRoot.startsWith("/"))
contextRoot = contextRoot.substring(1);
- String objectNameTemplate =
"jboss.web:j2eeType=WebModule,name=//localhost/"+ contextRoot +
",J2EEApplication=none,J2EEServer=none";
+ String objectNameTemplate =
"jboss.web:j2eeType=WebModule,name=//localhost/" + contextRoot
+ + ",J2EEApplication=none,J2EEServer=none";
ObjectNameQueryUtility queryUtility = new
ObjectNameQueryUtility(objectNameTemplate);
List<EmsBean> mBeans =
parentJBossASComponent.getEmsConnection().queryBeans(queryUtility.getTranslatedQuery());
- if (mBeans.size() ==1) {
+ if (mBeans.size() == 1) {
EmsBean theMBean = mBeans.get(0);
return theMBean.getBeanName().getCanonicalName();
}
@@ -267,7 +261,8 @@ public class WarDiscoveryHelper {
}
public static String getContextPath(String contextRoot) {
- return ((contextRoot == null ||
contextRoot.equals(WarComponent.ROOT_WEBAPP_CONTEXT_ROOT)) ? "/" : "/"
+ contextRoot);
+ return ((contextRoot == null ||
contextRoot.equals(WarComponent.ROOT_WEBAPP_CONTEXT_ROOT)) ? "/" :
"/"
+ + contextRoot);
}
private static void initPluginConfiguration(WarDeploymentInformation
deploymentInformation, File rtLogDir,
@@ -297,7 +292,7 @@ public class WarDiscoveryHelper {
}
private static void setRtLogInPluginConfig(File rtLogDir, Configuration pluginConfig,
String contextRoot,
- String vHost) {
+ String vHost) {
if (!contextRoot.equals("/")) {
contextRoot = contextRoot.replace('/', '_');
}