From 694e2d6c9f185774924d44975d6b9b8f90a42860 Mon Sep 17 00:00:00 2001 From: Thomas Segismont Date: Tue, 8 Mar 2016 13:44:27 +0100 Subject: [PATCH] Bug 1311140 - EAP7 - missing rt filter modules for eap7 Added new rtfilter-wfly-10-subsystem Added new rtfilter-wfly-10-subsystem to downloads section Fixed Web Runtime component (now at path subsystem=undertow) Verified Calltime metric collection --- .../connectors/README.txt | 4 +- .../src/main/scripts/rhq-container.build.xml | 6 +- modules/helpers/pom.xml | 1 + .../rtfilter-wfly-10-subsystem/pom.xml | 107 +++++++++ .../subsystem/wfly10/RtFilterExtension.java | 211 ++++++++++++++++++ .../wfly10/RtFilterSubsystemAdd.java | 60 +++++ .../wfly10/RtFilterSubsystemDefinition.java | 35 +++ .../wfly10/RtFilterSubsystemRemove.java | 33 +++ .../RtFilterDeploymentUnitProcessor.java | 134 +++++++++++ .../org.jboss.as.controller.Extension | 21 ++ .../src/main/resources/module/main/module.xml | 47 ++++ .../wfly10/LocalDescriptions.properties | 23 ++ .../resources/schema/rtfilter-subsystem.xsd | 149 +++++++++++++ .../src/main/scripts/module-assembly.xml | 51 +++++ .../main/resources/META-INF/rhq-plugin.xml | 6 +- pom.xml | 1 + 16 files changed, 883 insertions(+), 6 deletions(-) create mode 100644 modules/helpers/rtfilter-wfly-10-subsystem/pom.xml create mode 100644 modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterExtension.java create mode 100644 modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterSubsystemAdd.java create mode 100644 modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterSubsystemDefinition.java create mode 100644 modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterSubsystemRemove.java create mode 100644 modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/deployment/RtFilterDeploymentUnitProcessor.java create mode 100644 modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension create mode 100644 modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/module/main/module.xml create mode 100644 modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/org/rhq/helpers/rtfilter/subsystem/wfly10/LocalDescriptions.properties create mode 100644 modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/schema/rtfilter-subsystem.xsd create mode 100644 modules/helpers/rtfilter-wfly-10-subsystem/src/main/scripts/module-assembly.xml diff --git a/modules/enterprise/server/appserver/src/main/downloadable-resources/connectors/README.txt b/modules/enterprise/server/appserver/src/main/downloadable-resources/connectors/README.txt index c1dc783787c..fac21591df1 100644 --- a/modules/enterprise/server/appserver/src/main/downloadable-resources/connectors/README.txt +++ b/modules/enterprise/server/appserver/src/main/downloadable-resources/connectors/README.txt @@ -8,8 +8,8 @@ This is a servlet filter that can measure response times for HTTP requests made to servlets and write the response times to a logfile. The filter is compatible with any servlet 2.4 or later container running on Java 1.4 or later. However, since upport for parsing the response time logfiles is -only provided by the jboss-as, jboss-as-5, jboss-as-7, and tomcat RHQ -plugins, it typically is only of value to deploy the filter to JBoss AS +only provided by the jboss-as, jboss-as-5, jboss-as-7, wfly-10, and tomcat RHQ +plugins, it typically is only of value to deploy the filter to JBoss AS, Wildfly or Tomcat. Note, a commons-logging jar is supplied for use with Tomcat 6. It is not diff --git a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml index 5889a354647..033fd00e843 100644 --- a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml +++ b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml @@ -560,12 +560,16 @@ checkIfRunning(16);]]> - + + + diff --git a/modules/helpers/pom.xml b/modules/helpers/pom.xml index 80c88b90fde..a83ab6b7dc3 100644 --- a/modules/helpers/pom.xml +++ b/modules/helpers/pom.xml @@ -20,6 +20,7 @@ rtfilter rtfilter-subsystem + rtfilter-wfly-10-subsystem bundleGen jeeGen perftest-support diff --git a/modules/helpers/rtfilter-wfly-10-subsystem/pom.xml b/modules/helpers/rtfilter-wfly-10-subsystem/pom.xml new file mode 100644 index 00000000000..8839b491d23 --- /dev/null +++ b/modules/helpers/rtfilter-wfly-10-subsystem/pom.xml @@ -0,0 +1,107 @@ + + + + + + + 4.0.0 + + + org.rhq.helpers + rhq-helpers + 4.14.0-SNAPSHOT + + + rhq-rtfilter-wfly-10-subsystem + + RHQ Response-Time Filter - Wildfly 10 Subsystem + + + 10.0.0.Final + 2.0.10.Final + ${project.groupId}.${project.artifactId} + + + + + + + + src/main/resources + true + + + + + + + maven-compiler-plugin + + 1.6 + 1.6 + + + + + maven-assembly-plugin + + + src/main/scripts/module-assembly.xml + + + + + module-assembly + package + + single + + + + + + + + + + + org.wildfly.core + wildfly-controller + ${version.wildfly.core} + provided + + + org.wildfly + wildfly-undertow + ${version.wildfly} + provided + + + org.rhq.helpers + rhq-rtfilter + ${project.version} + provided + + + + diff --git a/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterExtension.java b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterExtension.java new file mode 100644 index 00000000000..785cd9b4eda --- /dev/null +++ b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterExtension.java @@ -0,0 +1,211 @@ +/* + * RHQ Management Platform + * Copyright 2016, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * 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 for more details. + * + * You should have received a copy of the GNU 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.helpers.rtfilter.subsystem.wfly10; + +import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*; + +import java.util.*; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; + +import org.jboss.as.controller.*; +import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver; +import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler; +import org.jboss.as.controller.parsing.ExtensionParsingContext; +import org.jboss.as.controller.parsing.ParseUtils; +import org.jboss.as.controller.persistence.SubsystemMarshallingContext; +import org.jboss.as.controller.registry.ManagementResourceRegistration; +import org.jboss.dmr.ModelNode; +import org.jboss.staxmapper.XMLElementReader; +import org.jboss.staxmapper.XMLElementWriter; +import org.jboss.staxmapper.XMLExtendedStreamReader; +import org.jboss.staxmapper.XMLExtendedStreamWriter; + +/** + * @author Thomas Segismont + */ +public class RtFilterExtension implements Extension { + + /** + * The name space used for the {@code subsystem} element + */ + public static final String NAMESPACE = "urn:rhq:rtfilter:1.0"; + + /** + * The name of our subsystem within the model. + */ + public static final String SUBSYSTEM_NAME = "rhq-rtfilter"; + + private final SubsystemReader reader = new SubsystemReader(); + private final SubsystemWriter writer = new SubsystemWriter(); + + protected static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME); + private static final String RESOURCE_NAME = RtFilterExtension.class.getPackage().getName() + ".LocalDescriptions"; + + public static final Map INIT_PARAMS = new LinkedHashMap(); + + public static StandardResourceDescriptionResolver getResourceDescriptionResolver(final String keyPrefix) { + String prefix = SUBSYSTEM_NAME + (keyPrefix == null ? "" : "." + keyPrefix); + return new StandardResourceDescriptionResolver(prefix, RESOURCE_NAME, RtFilterExtension.class.getClassLoader(), + true, false); + } + + @Override + public void initializeParsers(ExtensionParsingContext context) { + context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE, reader); + } + + @Override + public void initialize(ExtensionContext context) { + final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, ModelVersion.create(1)); + final ManagementResourceRegistration registration = subsystem + .registerSubsystemModel(RtFilterSubsystemDefinition.INSTANCE); + registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, + GenericSubsystemDescribeHandler.INSTANCE); + subsystem.registerXMLElementWriter(writer); + } + + /** + * The subsystem reader, which uses STAX to read the subsystem XML. + */ + private static class SubsystemReader implements XMLStreamConstants, XMLElementReader> { + + /** + * {@inheritDoc} + */ + @Override + public void readElement(XMLExtendedStreamReader reader, List list) throws XMLStreamException { + INIT_PARAMS.clear(); + + // Parse the 'subsystem' element... + ParseUtils.requireNoAttributes(reader); + + list.add(createAddSubsystemOperation()); + + // Read the child elements + while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { + if (reader.getLocalName().equals("init-param")) { + readInitParam(reader); + } else { + throw ParseUtils.unexpectedElement(reader); + } + // TODO: Add support for configuring filter mappings. + } + } + + private void readInitParam(XMLExtendedStreamReader reader) throws XMLStreamException { + String id = null; + for (int i = 0; i < reader.getAttributeCount(); i++) { + if (reader.getAttributeLocalName(i).equals("id")) { + if (id != null) { + throw ParseUtils.unexpectedAttribute(reader, i); + } + id = reader.getAttributeValue(i); + } else { + throw ParseUtils.unexpectedAttribute(reader, i); + } + } + + String description = null; + String paramName = null; + String paramValue = null; + while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { + if (reader.isStartElement()) { + if (reader.getLocalName().equals("description")) { + if (description != null) { + throw ParseUtils.unexpectedElement(reader); + } + description = reader.getElementText(); + } else if (reader.getLocalName().equals("param-name")) { + if (paramName != null) { + throw ParseUtils.unexpectedElement(reader); + } + paramName = reader.getElementText(); + } else if (reader.getLocalName().equals("param-value")) { + if (paramValue != null) { + throw ParseUtils.unexpectedElement(reader); + } + paramValue = reader.getElementText(); + } else { + throw ParseUtils.unexpectedElement(reader); + } + } + } + + Set missingRequiredElements = new HashSet(); + if (paramName == null) { + missingRequiredElements.add("param-name"); + } + if (paramValue == null) { + missingRequiredElements.add("param-value"); + } + if (!missingRequiredElements.isEmpty()) { + throw ParseUtils.missingRequiredElement(reader, missingRequiredElements); + } + + // There's no need for us to expose the init params via the AS7 management model. Just store them in a + // static Map that RtFilterDeploymentUnitProcessor will be able to access. + INIT_PARAMS.put(paramName, paramValue); + } + + private static ModelNode createAddSubsystemOperation() { + final ModelNode subsystem = new ModelNode(); + subsystem.get(OP).set(ADD); + subsystem.get(OP_ADDR).add(SUBSYSTEM, SUBSYSTEM_NAME); + return subsystem; + } + + } + + /** + * The subsystem writer, which uses STAX to write the subsystem XML. + */ + private static class SubsystemWriter implements XMLStreamConstants, XMLElementWriter { + + /** + * {@inheritDoc} + */ + @Override + public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) + throws XMLStreamException { + context.startSubsystemElement(RtFilterExtension.NAMESPACE, false); + + for (String paramName : INIT_PARAMS.keySet()) { + writer.writeStartElement("init-param"); + + writer.writeStartElement("param-name"); + writer.writeCharacters(paramName); + writer.writeEndElement(); // param-name + + writer.writeStartElement("param-value"); + String paramValue = INIT_PARAMS.get(paramName); + writer.writeCharacters(paramValue); + writer.writeEndElement(); // param-value + + writer.writeEndElement(); // init-param + } + + writer.writeEndElement(); // subsystem + } + + } + +} diff --git a/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterSubsystemAdd.java b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterSubsystemAdd.java new file mode 100644 index 00000000000..0d2131c0559 --- /dev/null +++ b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterSubsystemAdd.java @@ -0,0 +1,60 @@ +/* + * RHQ Management Platform + * Copyright 2016, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * 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 for more details. + * + * You should have received a copy of the GNU 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.helpers.rtfilter.subsystem.wfly10; + +import org.jboss.as.controller.AbstractAddStepHandler; +import org.jboss.as.controller.OperationContext; +import org.jboss.as.controller.OperationFailedException; +import org.jboss.as.controller.registry.Resource; +import org.jboss.as.server.AbstractDeploymentChainStep; +import org.jboss.as.server.DeploymentProcessorTarget; +import org.jboss.dmr.ModelNode; + +import org.rhq.helpers.rtfilter.subsystem.wfly10.deployment.RtFilterDeploymentUnitProcessor; + +/** + * @author Thomas Segismont + */ +class RtFilterSubsystemAdd extends AbstractAddStepHandler { + + static final RtFilterSubsystemAdd INSTANCE = new RtFilterSubsystemAdd(); + + private RtFilterSubsystemAdd() { + } + + @Override + protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { + model.setEmptyObject(); + } + + @Override + protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) + throws OperationFailedException { + context.addStep(new AbstractDeploymentChainStep() { + public void execute(DeploymentProcessorTarget processorTarget) { + processorTarget.addDeploymentProcessor(RtFilterExtension.SUBSYSTEM_NAME, + RtFilterDeploymentUnitProcessor.PHASE, RtFilterDeploymentUnitProcessor.PRIORITY, + new RtFilterDeploymentUnitProcessor()); + + } + }, OperationContext.Stage.RUNTIME); + } + +} diff --git a/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterSubsystemDefinition.java b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterSubsystemDefinition.java new file mode 100644 index 00000000000..1015d9e9463 --- /dev/null +++ b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterSubsystemDefinition.java @@ -0,0 +1,35 @@ +/* + * RHQ Management Platform + * Copyright 2016, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * 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 for more details. + * + * You should have received a copy of the GNU 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.helpers.rtfilter.subsystem.wfly10; + +import org.jboss.as.controller.SimpleResourceDefinition; + +/** + * @author Thomas Segismont + */ +class RtFilterSubsystemDefinition extends SimpleResourceDefinition { + + public static final RtFilterSubsystemDefinition INSTANCE = new RtFilterSubsystemDefinition(); + + private RtFilterSubsystemDefinition() { + super(RtFilterExtension.SUBSYSTEM_PATH, RtFilterExtension.getResourceDescriptionResolver(null), + RtFilterSubsystemAdd.INSTANCE, RtFilterSubsystemRemove.INSTANCE); + } +} diff --git a/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterSubsystemRemove.java b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterSubsystemRemove.java new file mode 100644 index 00000000000..35a5fe47629 --- /dev/null +++ b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/RtFilterSubsystemRemove.java @@ -0,0 +1,33 @@ +/* + * RHQ Management Platform + * Copyright 2016, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * 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 for more details. + * + * You should have received a copy of the GNU 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.helpers.rtfilter.subsystem.wfly10; + +import org.jboss.as.controller.AbstractRemoveStepHandler; + +/** + * @author Thomas Segismont + */ +class RtFilterSubsystemRemove extends AbstractRemoveStepHandler { + + static final RtFilterSubsystemRemove INSTANCE = new RtFilterSubsystemRemove(); + + private RtFilterSubsystemRemove() { + } +} diff --git a/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/deployment/RtFilterDeploymentUnitProcessor.java b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/deployment/RtFilterDeploymentUnitProcessor.java new file mode 100644 index 00000000000..dbb784e2502 --- /dev/null +++ b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/java/org/rhq/helpers/rtfilter/subsystem/wfly10/deployment/RtFilterDeploymentUnitProcessor.java @@ -0,0 +1,134 @@ +/* + * RHQ Management Platform + * Copyright 2016, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * 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 for more details. + * + * You should have received a copy of the GNU 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.helpers.rtfilter.subsystem.wfly10.deployment; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.jboss.as.ee.structure.DeploymentType; +import org.jboss.as.ee.structure.DeploymentTypeMarker; +import org.jboss.as.server.deployment.*; +import org.jboss.as.web.common.WarMetaData; +import org.jboss.logging.Logger; +import org.jboss.metadata.javaee.spec.ParamValueMetaData; +import org.jboss.metadata.web.spec.FilterMappingMetaData; +import org.jboss.metadata.web.spec.FilterMetaData; +import org.jboss.metadata.web.spec.FiltersMetaData; +import org.jboss.metadata.web.spec.WebMetaData; + +import org.rhq.helpers.rtfilter.filter.RtFilter; +import org.rhq.helpers.rtfilter.subsystem.wfly10.RtFilterExtension; + +/** + * @author Thomas Segismont + */ +public class RtFilterDeploymentUnitProcessor implements DeploymentUnitProcessor { + private static final Logger log = Logger.getLogger(RtFilterDeploymentUnitProcessor.class); + + private static final String RT_FILTER_NAME = "RHQ Response-Time Filter"; + /** + * See {@link Phase} for descriptions of the different phases. + */ + public static final Phase PHASE = Phase.DEPENDENCIES; + + /** + * The relative order of this processor within the {@link #PHASE}. + * The current number is large enough for it to happen after all + * the standard deployment unit processors that come with JBoss AS. + */ + public static final int PRIORITY = 0x4000; + + @Override + public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { + final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); + if (isWar(deploymentUnit)) { + log.debug("Configuring RHQ response-time servlet filter for WAR " + deploymentUnit.getName() + "..."); + + final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY); + WebMetaData webMetaData = warMetaData.getWebMetaData(); + + FilterMetaData rtFilter = null; + FiltersMetaData filters = webMetaData.getFilters(); + if (filters != null) { + for (FilterMetaData filter : filters) { + if (RtFilter.class.getName().equals(filter.getFilterClass())) { + // the filter's already configured in this webapp. + rtFilter = filter; + break; + } + } + } else { + filters = new FiltersMetaData(); + webMetaData.setFilters(filters); + } + if (rtFilter == null) { + rtFilter = new FilterMetaData(); + rtFilter.setFilterName(RT_FILTER_NAME); + rtFilter.setFilterClass(RtFilter.class.getName()); + filters.add(rtFilter); + } + + List initParams = rtFilter.getInitParam(); + if (initParams == null) { + initParams = new ArrayList(); + rtFilter.setInitParam(initParams); + } + for (String paramName : RtFilterExtension.INIT_PARAMS.keySet()) { + ParamValueMetaData initParam = new ParamValueMetaData(); + initParam.setParamName(paramName); + String paramValue = RtFilterExtension.INIT_PARAMS.get(paramName); + initParam.setParamValue(paramValue); + initParams.add(initParam); + } + + boolean filterMappingAlreadyConfigured = false; + List filterMappings = webMetaData.getFilterMappings(); + if (filterMappings != null) { + for (FilterMappingMetaData filterMapping : filterMappings) { + if (filterMapping.getFilterName().equals(rtFilter.getFilterName())) { + // a mapping for the filter's already configured in this webapp. + filterMappingAlreadyConfigured = true; + break; + } + } + } else { + filterMappings = new ArrayList(); + webMetaData.setFilterMappings(filterMappings); + } + + if (!filterMappingAlreadyConfigured) { + FilterMappingMetaData filterMapping = new FilterMappingMetaData(); + filterMapping.setFilterName(rtFilter.getFilterName()); + filterMapping.setUrlPatterns(Collections.singletonList("/*")); + filterMappings.add(filterMapping); + } + } + } + + @Override + public void undeploy(DeploymentUnit context) { + } + + private static boolean isWar(final DeploymentUnit deploymentUnit) { + return (DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)); + } + +} diff --git a/modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension new file mode 100644 index 00000000000..1a126d2781f --- /dev/null +++ b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension @@ -0,0 +1,21 @@ +# +# RHQ Management Platform +# Copyright 2016, Red Hat Middleware LLC, and individual contributors +# as indicated by the @author tags. See the copyright.txt file in the +# distribution for a full listing of individual contributors. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation version 2 of the License. +# +# 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 for more details. +# +# You should have received a copy of the GNU 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. +# + +org.rhq.helpers.rtfilter.subsystem.wfly10.RtFilterExtension diff --git a/modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/module/main/module.xml b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/module/main/module.xml new file mode 100644 index 00000000000..82f947ae5a7 --- /dev/null +++ b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/module/main/module.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/org/rhq/helpers/rtfilter/subsystem/wfly10/LocalDescriptions.properties b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/org/rhq/helpers/rtfilter/subsystem/wfly10/LocalDescriptions.properties new file mode 100644 index 00000000000..29c734af5f5 --- /dev/null +++ b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/org/rhq/helpers/rtfilter/subsystem/wfly10/LocalDescriptions.properties @@ -0,0 +1,23 @@ +# +# RHQ Management Platform +# Copyright 2016, Red Hat Middleware LLC, and individual contributors +# as indicated by the @author tags. See the copyright.txt file in the +# distribution for a full listing of individual contributors. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation version 2 of the License. +# +# 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 for more details. +# +# You should have received a copy of the GNU 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. +# + +rhq-rtfilter=RHQ Response-Time Servlet Filter Subsystem +rhq-rtfilter.add=Operation Adds subsystem +rhq-rtfilter.remove=Operation Removes subsystem diff --git a/modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/schema/rtfilter-subsystem.xsd b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/schema/rtfilter-subsystem.xsd new file mode 100644 index 00000000000..a1cd8cf9305 --- /dev/null +++ b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/resources/schema/rtfilter-subsystem.xsd @@ -0,0 +1,149 @@ + + + + + + + + + + + + + The init-param element contains a name/value pair as + an initialization param of the RHQ response-time servlet filter + + + + + + + + + + + + This type is a general type that can be used to declare + parameter/value lists. + + + + + + + + + The param-name element contains the name of a + parameter. + + + + + + + + The param-value element contains the value of a + parameter. + + + + + + + + + + + + + + The description type is used by a description element to + provide text describing the parent element. The elements + that use this type should include any information that the + Deployment Component's Deployment File file producer wants + to provide to the consumer of the Deployment Component's + Deployment File (i.e., to the Deployer). Typically, the + tools used by such a Deployment File consumer will display + the description when processing the parent element that + contains the description. + + The lang attribute defines the language that the + description is provided in. The default value is "en" (English). + + + + + + + + + + + + + + + + + This is a special string datatype that is defined by J2EE as + a base type for defining collapsed strings. When schemas + require trailing/leading space elimination as well as + collapsing the existing whitespace, this base type may be + used. + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:string. + + + + + + + + + + diff --git a/modules/helpers/rtfilter-wfly-10-subsystem/src/main/scripts/module-assembly.xml b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/scripts/module-assembly.xml new file mode 100644 index 00000000000..cfa1de9017e --- /dev/null +++ b/modules/helpers/rtfilter-wfly-10-subsystem/src/main/scripts/module-assembly.xml @@ -0,0 +1,51 @@ + + + + + + module-assembly + + zip + + false + ${project.build.finalName}-module + + + ${project.build.outputDirectory}/module + /org/rhq/helpers/${artifactId} + + main/module.xml + + 0644 + 0755 + + + ${project.build.directory} + /org/rhq/helpers/${artifactId}/main + + ${project.build.finalName}.jar + + 0644 + 0755 + + + + diff --git a/modules/plugins/wfly-10/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/wfly-10/src/main/resources/META-INF/rhq-plugin.xml index e852aa76442..58b5f13a5ce 100644 --- a/modules/plugins/wfly-10/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/wfly-10/src/main/resources/META-INF/rhq-plugin.xml @@ -10308,7 +10308,7 @@ - + + - ${rhq.pom.version} ${rhq.pom.version} ${rhq.pom.version} + ${rhq.pom.version} ${rhq.pom.version} ${rhq.pom.version} ${rhq.pom.version}