From b24abe458a36ad1100070bfb1cbda415bac62f94 Mon Sep 17 00:00:00 2001 From: maximebeck Date: Wed, 13 May 2015 16:31:11 +0200 Subject: [PATCH 1/2] Fix JWS-54 - Add Tomcat7 support --- .../on/plugins/tomcat/TomcatWarComponent.java | 82 ++++++++++++++++++- 1 file changed, 78 insertions(+), 4 deletions(-) diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java index b09cce6f809..d1d40a9dad8 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java @@ -26,10 +26,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; +import java.util.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -43,6 +40,10 @@ import org.jboss.on.plugins.tomcat.helper.TomcatApplicationDeployer; import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; +import org.rhq.core.domain.configuration.definition.PropertyDefinition; +import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; import org.rhq.core.domain.content.PackageDetailsKey; import org.rhq.core.domain.content.PackageType; import org.rhq.core.domain.content.transfer.ContentResponseResult; @@ -104,6 +105,7 @@ public class TomcatWarComponent extends MBeanResourceComponent obsoleteAttributesInTomcat8 = Collections.unmodifiableMap( + new HashMap() {{ + put("allowLinking", AttributeTypes.BOOLEAN); + put("antiJarLocking", AttributeTypes.BOOLEAN); + put("cachingAllowed", AttributeTypes.BOOLEAN); + put("cacheTTL", AttributeTypes.INTEGER); + put("cacheMaxSize", AttributeTypes.INTEGER); + put("compilerClasspath", AttributeTypes.STRING); + put("saveConfig", AttributeTypes.BOOLEAN); + }}); + private final Log log = LogFactory.getLog(this.getClass()); /** @@ -196,6 +215,61 @@ public void start(ResourceContext resourceContext) { } } + @Override + public Configuration loadResourceConfiguration() { + Configuration configuration = new Configuration(); + ConfigurationDefinition configurationDefinition = this.getResourceContext().getResourceType() + .getResourceConfigurationDefinition(); + + try { + EmsConnection jmxConnection = getEmsConnection(); + + String webmoduleMBeanNames = QUERY_TEMPLATE_WEBMODULE; + Configuration config = getResourceContext().getPluginConfiguration(); + webmoduleMBeanNames = webmoduleMBeanNames.replace("%name%", config.getSimpleValue(PROPERTY_NAME, "")); + ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(webmoduleMBeanNames); + List mBeans = jmxConnection.queryBeans(queryUtility.getTranslatedQuery()); + + if (mBeans.size() > 0) { + EmsBean bean = mBeans.get(0); + Boolean isTomcat8 = false; + + for (PropertyDefinition property : configurationDefinition.getPropertyDefinitions().values()) { + if (property instanceof PropertyDefinitionSimple) { + EmsAttribute attribute = bean.getAttribute(property.getName()); + if (attribute != null) { + configuration.put(new PropertySimple(property.getName(), attribute.refresh())); + } else { + if(obsoleteAttributesInTomcat8.containsKey(property.getName())) + isTomcat8 = true; + } + } + + // Set obsolete attributes to a default value for Tomcat 8 + if(isTomcat8) { + for (Map.Entry entry : obsoleteAttributesInTomcat8.entrySet()) { + switch (entry.getValue()) { + case BOOLEAN: + configuration.put(new PropertySimple(entry.getKey(), false)); + break; + case INTEGER: + configuration.put(new PropertySimple(entry.getKey(), 0)); + break; + case STRING: + configuration.put(new PropertySimple(entry.getKey(), "")); + break; + } + } + } + } + } + } catch (Exception e) { + log.debug("Unable to load mod_cluster configuration file.", e); + } + + return configuration; + } + @Override public void getValues(MeasurementReport report, Set schedules) { From b42a1f953aea453cb4c5c668c9c9f1941767747e Mon Sep 17 00:00:00 2001 From: maximebeck Date: Wed, 13 May 2015 16:44:55 +0200 Subject: [PATCH 2/2] Fix JWS-54 - Fix plugin descriptor --- .../main/resources/META-INF/rhq-plugin.xml | 102 +++++++++++------- 1 file changed, 64 insertions(+), 38 deletions(-) diff --git a/modules/plugins/tomcat/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/tomcat/src/main/resources/META-INF/rhq-plugin.xml index 4660d56990e..d6480e73587 100644 --- a/modules/plugins/tomcat/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/tomcat/src/main/resources/META-INF/rhq-plugin.xml @@ -60,7 +60,7 @@ type="string" required="false" default="SCRIPT" - description="The method used to execute the control operations. When set to RPM the + description="The method used to execute the control operations. When set to RPM the system will use a System V init script via the 'service' command. The script properties will be ignored."> @@ -96,7 +96,7 @@ required="false" description="The path to the script used by the 'Shutdown' operation to shutdown this Tomcat server; if the path is not absolute it will be resolved relative to {installationPath}." /> - + @@ -110,12 +110,12 @@ - - Define the environment variables to be set when executing the start script. + Define the environment variables to be set when executing the start script. @@ -123,12 +123,12 @@ - - Define the environment variables to be set when executing the shutdown script. + Define the environment variables to be set when executing the shutdown script. @@ -493,14 +493,40 @@ + + + + + + - + - + description="Number of idle connections in the pool" /> + + description="The minimum number of connections that can remain idle in the pool, without extra ones being created, or zero to create none. Default is 0." /> + description="Enable prepared statement pooling for this pool. Default is false." /> + description="The maximum number of open statements that can be allocated from the statement pool at the same time, or zero for no limit. Default is unlimited." /> + description="Flag to remove abandoned connections if they exceed the removeAbandonedTimout. If set to true a connection is considered abandoned and eligible for removal if it has been idle longer than the removeAbandonedTimeout. Setting this to true can recover db connections from poorly written applications which fail to close a connection. Default is false." /> + description="Timeout in seconds before an abandoned connection can be removed. Default is 300." /> + description="Flag to log stack traces for application code which abandoned a Statement or Connection. Logging of abandoned Statements and Connections adds overhead for every Connection open or new Statement because a stack trace has to be generated. Default is false." /> - - + + - + @@ -708,8 +734,8 @@ + readOnly="true" /> + default="200" /> + default="http" /> + required="false" /> + default="ISO-8859-1" /> + default="true" /> + default="4" /> + default="lf" /> + default="true" /> @@ -1048,7 +1074,7 @@ name="trustStoreType" type="string" description="Add this element if your are using a different format for the TrustStore then you are using for the KeyStore." - required="false" /> + required="false" />