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

Commit

Permalink
Add spring-integration4
Browse files Browse the repository at this point in the history
This change adds the spring-integration4 plugin. This is just a copy
of the spring-integration2 plugin and does not properly build
  • Loading branch information
wjs-broadcom committed Oct 22, 2014
1 parent 9eafb7e commit f59a55a
Show file tree
Hide file tree
Showing 34 changed files with 2,338 additions and 0 deletions.
15 changes: 15 additions & 0 deletions collection-plugins/spring-integration4/README.textile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
h3. Spring Integration Plugin Spring Insight

This plugin provides information from the core Spring Integration libraries.
It provides a new endpoint for analysis.

h2. Compatibility

This plugin is compatible with the 1.9+ versions of insight.

h2. Installation

This is a core plugin of Insight 1.9+.

For both the Dashboard and Insight Agent. You should see the
plugin listed under the administration panel.
29 changes: 29 additions & 0 deletions collection-plugins/spring-integration4/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="insight-plugin-spring-integration" default="install">
<description>
Provides some useful ANT tasks involving the entire project
</description>

<dirname property="module.root.folder" file="${ant.file}"/>
<dirname property="collection.plugins.folder" file="${module.root.folder}"/>
<dirname property="insight.community.folder" file="${collection.plugins.folder}"/>
<dirname property="insight.root.folder" file="${insight.community.folder}"/>
<property name="insight.parent.folder" value="${insight.root.folder}${file.separator}parent"/>
<property name="module.artifact.name" value="${ant.project.name}"/>
<import file="${insight.parent.folder}${file.separator}build-insight.xml"/>

<target name="compile" depends="run-module-mvn"
description="Runs the mvn install command - including all the tests"/>
<target name="uncompile" depends="clean-module-mvn"
description="Runs the mvn clean command - including un-install the artifact from Maven local repository"/>

<!-- ############### Generic targets ############## -->
<target name="install" depends="compile,copy-collection-plugin-artifact"
description="Compiles (including all the tests) and deploys the required artifacts"/>

<target name="clean" depends="clean-module-mvn,clean-collection-plugin-artifact"
description="Runs the mvn clean command + undeploys the generated artifacts"/>

<target name="re-install" depends="clean,install"
description="Cleans the artifacts and re-creates them from scratch (including all the tests)"/>
</project>
137 changes: 137 additions & 0 deletions collection-plugins/spring-integration4/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.springsource.insight.plugins</groupId>
<artifactId>insight-plugin-spring-integration4</artifactId>
<name>com.springsource.insight.plugins:spring-integration</name>
<packaging>jar</packaging>

<parent>
<groupId>com.springsource.insight</groupId>
<artifactId>community-plugins</artifactId>
<version>2.0.0-CI-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

<dependencies>
<!-- Provided dependencies (part of the user application) -->
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-ip</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-amqp</artifactId>
<scope>provided</scope>
<version>${spring.integration.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-stream</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-amqp</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<scope>provided</scope>
</dependency>

<!-- Test dependencies -->
<dependency> <!-- required for the FreeMarkerConfigurationFactory -->
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>test</scope>
</dependency>
<dependency> <!-- for IDK tests -->
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Insight-Plugin-Descriptor>
com.springsource.insight.plugin.integration.IntegrationPluginRuntimeDescriptor
</Insight-Plugin-Descriptor>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<configuration>
<header>../../aslHeader.txt</header>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* Copyright (c) 2009-2011 VMware, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.springsource.insight.plugin.integration;

import java.lang.reflect.Field;
import java.util.Map;
import java.util.logging.Level;

import org.springframework.integration.Message;
import org.springframework.integration.MessageHeaders;

import com.springsource.insight.collection.AbstractOperationCollectionAspect;
import com.springsource.insight.collection.OperationCollector;
import com.springsource.insight.intercept.color.ColorManager.ColorParams;
import com.springsource.insight.intercept.operation.Operation;
import com.springsource.insight.util.ExtraReflectionUtils;
import com.springsource.insight.util.ReflectionUtils;
import com.springsource.insight.util.logging.InsightLogManager;

/**
*
*/
public abstract aspect AbstractIntegrationOperationCollectionAspect extends AbstractOperationCollectionAspect {
private static final Field headersMapField;

static {
if ((headersMapField = ExtraReflectionUtils.getAccessibleField(MessageHeaders.class, "headers", Map.class)) == null) {
InsightLogManager.getLogger(AbstractIntegrationOperationCollectionAspect.class.getName())
.warning("Cannot find message headers field")
;
}
}

protected AbstractIntegrationOperationCollectionAspect() {
super();
}

protected AbstractIntegrationOperationCollectionAspect(OperationCollector collector) {
super(collector);
}

protected void colorForward(final Operation op, final Message<?> msg) {
colorForward(op, (msg == null) ? null : msg.getHeaders());
}

protected void colorForward(final Operation op, final MessageHeaders hdrs) {
colorForward(new ColorParams() {
@SuppressWarnings("synthetic-access")
public void setColor(String key, String value) {
if ((hdrs == null) || (headersMapField == null)) {
return;
}

try {
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) ReflectionUtils.getField(headersMapField, hdrs);
Object prev = map.put(key, value);
if (prev != null) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("colorForward(" + key + ")[" + prev + "] => " + value);
}
}
} catch (RuntimeException e) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("colorForward(" + key + ")[" + value + "]"
+ " failed (" + e.getClass().getSimpleName() + ")"
+ " to access headers field: " + e.getMessage());
}
}
}

public Operation getOperation() {
return op;
}
});
}

@Override
public final String getPluginName() {
return IntegrationPluginRuntimeDescriptor.PLUGIN_NAME;
}

@Override
public boolean isMetricsGenerator() {
return true; // This provides an external resource
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright (c) 2009-2011 VMware, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.springsource.insight.plugin.integration;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import com.springsource.insight.intercept.endpoint.AbstractEndPointAnalyzer;
import com.springsource.insight.intercept.endpoint.EndPointAnalysis;
import com.springsource.insight.intercept.endpoint.EndPointAnalyzer;
import com.springsource.insight.intercept.endpoint.EndPointName;
import com.springsource.insight.intercept.operation.Operation;
import com.springsource.insight.intercept.operation.OperationType;
import com.springsource.insight.intercept.trace.Frame;

/**
* {@link EndPointAnalyzer} for Spring Integration traces.
* Integration 'Transformer' operations are never considered.
*/
public class IntegrationEndPointAnalyzer extends AbstractEndPointAnalyzer {
// NOTE - order matters here!
// the first ServiceActivator frame beats the first Gateway frame which beats the first Channel frame
public static final List<OperationType> SI_OPS = Collections.unmodifiableList(Arrays.asList(
SpringIntegrationDefinitions.SI_OP_SERVICE_ACTIVATOR_TYPE, SpringIntegrationDefinitions.SI_OP_GATEWAY_TYPE,
SpringIntegrationDefinitions.SI_OP_CHANNEL_TYPE));
private static final IntegrationEndPointAnalyzer INSTANCE = new IntegrationEndPointAnalyzer();
public static final int ANALYSIS_SCORE = EndPointAnalysis.CEILING_LAYER_SCORE + 2;

private IntegrationEndPointAnalyzer() {
super(SI_OPS);
}

public static final IntegrationEndPointAnalyzer getInstance() {
return INSTANCE;
}

@Override
protected EndPointAnalysis makeEndPoint(Frame si, int depth) {
Operation op = si.getOperation();
String exampleRequest = op.get(SpringIntegrationDefinitions.SI_COMPONENT_TYPE_ATTR, String.class);
String opLabel = op.getLabel();
EndPointName name = EndPointName.valueOf(opLabel);
String label = name.getName();
return new EndPointAnalysis(name, label, exampleRequest, ANALYSIS_SCORE, op);
}
}
Loading

0 comments on commit f59a55a

Please sign in to comment.