Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Bug 1311140 - EAP7 - missing rt filter modules for eap7
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tsegismont committed Mar 8, 2016
1 parent d7eb5a2 commit 694e2d6
Show file tree
Hide file tree
Showing 16 changed files with 883 additions and 6 deletions.
Expand Up @@ -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
Expand Down
Expand Up @@ -560,12 +560,16 @@ checkIfRunning(16);]]>
</zipfileset>
</zip>

<!-- rtfilter AS7 modules -->
<!-- rtfilter modules -->
<copy file="${settings.localRepository}/org/rhq/helpers/rhq-rtfilter/${project.version}/rhq-rtfilter-${project.version}.zip"
tofile="${rhq.ear.dir}/rhq-downloads/connectors/rhq-rtfilter-module.zip" />

<copy file="${settings.localRepository}/org/rhq/helpers/rhq-rtfilter-subsystem/${rhq-rtfilter-subsystem.version}/rhq-rtfilter-subsystem-${rhq-rtfilter-subsystem.version}.zip"
tofile="${rhq.ear.dir}/rhq-downloads/connectors/rhq-rtfilter-subsystem-module.zip" />

<copy
file="${settings.localRepository}/org/rhq/helpers/rhq-rtfilter-wfly-10-subsystem/${rhq-rtfilter-wfly-10-subsystem.version}/rhq-rtfilter-wfly-10-subsystem-${rhq-rtfilter-wfly-10-subsystem.version}.zip"
tofile="${rhq.ear.dir}/rhq-downloads/connectors/rhq-rtfilter-wfly-10-subsystem-module.zip"/>
</target>

<target name="prepare-bin-dir">
Expand Down
1 change: 1 addition & 0 deletions modules/helpers/pom.xml
Expand Up @@ -20,6 +20,7 @@

<module>rtfilter</module>
<module>rtfilter-subsystem</module>
<module>rtfilter-wfly-10-subsystem</module>
<module>bundleGen</module>
<module>jeeGen</module>
<module>perftest-support</module>
Expand Down
107 changes: 107 additions & 0 deletions modules/helpers/rtfilter-wfly-10-subsystem/pom.xml
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ 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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.rhq.helpers</groupId>
<artifactId>rhq-helpers</artifactId>
<version>4.14.0-SNAPSHOT</version>
</parent>

<artifactId>rhq-rtfilter-wfly-10-subsystem</artifactId>

<name>RHQ Response-Time Filter - Wildfly 10 Subsystem</name>

<properties>
<version.wildfly>10.0.0.Final</version.wildfly>
<version.wildfly.core>2.0.10.Final</version.wildfly.core>
<moduleName>${project.groupId}.${project.artifactId}</moduleName>
</properties>


<build>

<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>

<plugins>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/scripts/module-assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>module-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-controller</artifactId>
<version>${version.wildfly.core}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-undertow</artifactId>
<version>${version.wildfly}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.rhq.helpers</groupId>
<artifactId>rhq-rtfilter</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
@@ -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<String, String> INIT_PARAMS = new LinkedHashMap<String, String>();

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<List<ModelNode>> {

/**
* {@inheritDoc}
*/
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> 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<String> missingRequiredElements = new HashSet<String>();
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<SubsystemMarshallingContext> {

/**
* {@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
}

}

}

0 comments on commit 694e2d6

Please sign in to comment.