From 20bc4f08171d8c513cea0f242f817de56bee5aef Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Thu, 23 Oct 2008 10:17:23 +0000 Subject: [PATCH] Added agent module --- org.springframework.agent/build.xml | 6 ++ org.springframework.agent/ivy.xml | 21 +++++++ org.springframework.agent/pom.xml | 28 +++++++++ .../InstrumentationSavingAgent.java | 59 +++++++++++++++++++ .../src/main/java/overview.html | 7 +++ .../src/test/resources/log4j.xml | 28 +++++++++ org.springframework.agent/template.mf | 5 ++ 7 files changed, 154 insertions(+) create mode 100644 org.springframework.agent/build.xml create mode 100644 org.springframework.agent/ivy.xml create mode 100644 org.springframework.agent/pom.xml create mode 100644 org.springframework.agent/src/main/java/org/springframework/instrument/InstrumentationSavingAgent.java create mode 100644 org.springframework.agent/src/main/java/overview.html create mode 100644 org.springframework.agent/src/test/resources/log4j.xml create mode 100644 org.springframework.agent/template.mf diff --git a/org.springframework.agent/build.xml b/org.springframework.agent/build.xml new file mode 100644 index 0000000000..1cec08a2e6 --- /dev/null +++ b/org.springframework.agent/build.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/org.springframework.agent/ivy.xml b/org.springframework.agent/ivy.xml new file mode 100644 index 0000000000..3fd4f5f112 --- /dev/null +++ b/org.springframework.agent/ivy.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + diff --git a/org.springframework.agent/pom.xml b/org.springframework.agent/pom.xml new file mode 100644 index 0000000000..f820fa6d69 --- /dev/null +++ b/org.springframework.agent/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + org.springframework + org.springframework.agent + jar + Spring Agent + 3.0.0.M1 + + + com.springsource.repository.bundles.external + SpringSource Enterprise Bundle Repository - External Bundle Releases + http://repository.springsource.com/maven/bundles/external + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + + \ No newline at end of file diff --git a/org.springframework.agent/src/main/java/org/springframework/instrument/InstrumentationSavingAgent.java b/org.springframework.agent/src/main/java/org/springframework/instrument/InstrumentationSavingAgent.java new file mode 100644 index 0000000000..90c1dfb24d --- /dev/null +++ b/org.springframework.agent/src/main/java/org/springframework/instrument/InstrumentationSavingAgent.java @@ -0,0 +1,59 @@ +/* + * Copyright 2002-2008 the original author or authors. + * + * 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 org.springframework.instrument; + +import java.lang.instrument.Instrumentation; + +/** + * Java agent that saves the {@link Instrumentation} interface from the JVM + * for later use. + * + * @author Rod Johnson + * @author Juergen Hoeller + * @since 2.0 + * @see org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver + */ +public class InstrumentationSavingAgent { + + private static volatile Instrumentation instrumentation; + + + /** + * Save the {@link Instrumentation} interface exposed by the JVM. + */ + public static void premain(String agentArgs, Instrumentation inst) { + instrumentation = inst; + } + + + /** + * Return the {@link Instrumentation} interface exposed by the JVM. + *

Note that this agent class will typically not be available in the classpath + * unless the agent is actually specified on JVM startup. If you intend to do + * conditional checking with respect to agent availability, consider using + * {@link org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver#getInstrumentation()} + * instead - which will work without the agent class in the classpath as well. + * @return the Instrumentation instance previously saved when + * the {@link #premain} method was called by the JVM; will be null + * if this class was not used as Java agent when this JVM was started. + * @see org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver#getInstrumentation() + */ + public static Instrumentation getInstrumentation() { + return instrumentation; + } + +} diff --git a/org.springframework.agent/src/main/java/overview.html b/org.springframework.agent/src/main/java/overview.html new file mode 100644 index 0000000000..1eb7a2e8c1 --- /dev/null +++ b/org.springframework.agent/src/main/java/overview.html @@ -0,0 +1,7 @@ + + +

+The Spring Data Binding framework, an internal library used by Spring Web Flow. +

+ + \ No newline at end of file diff --git a/org.springframework.agent/src/test/resources/log4j.xml b/org.springframework.agent/src/test/resources/log4j.xml new file mode 100644 index 0000000000..767b96d620 --- /dev/null +++ b/org.springframework.agent/src/test/resources/log4j.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/org.springframework.agent/template.mf b/org.springframework.agent/template.mf new file mode 100644 index 0000000000..98fc53157e --- /dev/null +++ b/org.springframework.agent/template.mf @@ -0,0 +1,5 @@ +Bundle-SymbolicName: org.springframework.agent +Bundle-Name: Spring Core +Bundle-Vendor: SpringSource +Bundle-ManifestVersion: 2 +Premain-Class: org.springframework.instrument.InstrumentationSavingAgent