You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by si...@apache.org on 2008/09/16 17:46:04 UTC

svn commit: r695947 [1/2] - in /labs/magma/trunk/maven-magma-plugin: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/magma/ src/main/java/org/apache/magma/tools/ src/main/java/org/apache/magma/tool...

Author: simoneg
Date: Tue Sep 16 08:46:03 2008
New Revision: 695947

URL: http://svn.apache.org/viewvc?rev=695947&view=rev
Log:
Initial import.

Added:
    labs/magma/trunk/maven-magma-plugin/pom.xml
    labs/magma/trunk/maven-magma-plugin/src/
    labs/magma/trunk/maven-magma-plugin/src/main/
    labs/magma/trunk/maven-magma-plugin/src/main/java/
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyClassLoaderWeavingAdaptor.java
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyWeavingURLClassLoader.java
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcCompileMojo.java
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcCompleteCompileMojo.java
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcTestCompileMojo.java
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaJettyRun.java
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaTestAgent.java
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaTestMojo.java
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/ModulesPreparer.java
    labs/magma/trunk/maven-magma-plugin/src/main/resources/
    labs/magma/trunk/maven-magma-plugin/src/main/resources/META-INF/
    labs/magma/trunk/maven-magma-plugin/src/main/resources/META-INF/plexus/
    labs/magma/trunk/maven-magma-plugin/src/main/resources/META-INF/plexus/components.xml

Added: labs/magma/trunk/maven-magma-plugin/pom.xml
URL: http://svn.apache.org/viewvc/labs/magma/trunk/maven-magma-plugin/pom.xml?rev=695947&view=auto
==============================================================================
--- labs/magma/trunk/maven-magma-plugin/pom.xml (added)
+++ labs/magma/trunk/maven-magma-plugin/pom.xml Tue Sep 16 08:46:03 2008
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+-->
+<project
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<packaging>maven-plugin</packaging>
+	<groupId>org.apache.magma.tools</groupId>
+	<artifactId>maven-magma-plugin</artifactId>
+	<name>Magma Extension Mojo</name>
+	<version>0.0.1</version>
+	<description>
+		Extends the AspectJ compiler plugin, surefire test plugin and
+		jetty plugin to better suite magma components.
+	</description>
+	<dependencies>
+		<dependency>
+			<groupId>org.codehaus.mojo</groupId>
+			<artifactId>aspectj-maven-plugin</artifactId>
+			<version>1.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.mortbay.jetty</groupId>
+			<artifactId>maven-jetty-plugin</artifactId>
+			<version>6.1H.5-beta</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.maven.plugins</groupId>
+			<artifactId>maven-surefire-plugin</artifactId>
+			<version>2.4.2</version>
+		</dependency>
+		<dependency>
+			<groupId>org.aspectj</groupId>
+			<artifactId>aspectjweaver</artifactId>
+			<version>1.6.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.aspectj</groupId>
+			<artifactId>aspectjtools</artifactId>
+			<version>1.6.1</version>
+		</dependency>
+	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.5</source>
+					<target>1.5</target>
+				</configuration>
+			</plugin>
+     <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>2.2</version>
+        <configuration>
+          <archive>
+            <manifestEntries>
+				<Can-Redefine-Classes>true</Can-Redefine-Classes>
+				<Premain-Class>org.apache.magma.tools.maven.MagmaTestAgent</Premain-Class>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>			
+		</plugins>
+	</build>
+	<distributionManagement>
+		<repository>
+			<id>semeru-ssh-repository</id>
+			<url>
+				scp://svn.semeru.it:22/var/www/localhost/htdocs/maven-snaps
+			</url>
+		</repository>
+		<snapshotRepository>
+			<id>semeru-ssh-repository-snaps</id>
+			<url>
+				scp://svn.semeru.it:22/var/www/localhost/htdocs/maven-snaps
+			</url>
+		</snapshotRepository>
+	</distributionManagement>
+</project>

Added: labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyClassLoaderWeavingAdaptor.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyClassLoaderWeavingAdaptor.java?rev=695947&view=auto
==============================================================================
--- labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyClassLoaderWeavingAdaptor.java (added)
+++ labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyClassLoaderWeavingAdaptor.java Tue Sep 16 08:46:03 2008
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.magma.tools.maven;
+
+import org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor;
+import org.aspectj.weaver.loadtime.IWeavingContext;
+
+public class JettyClassLoaderWeavingAdaptor extends ClassLoaderWeavingAdaptor {
+
+	@Override
+	protected void initialize(ClassLoader classLoader, IWeavingContext context) {
+		// TODO Auto-generated method stub
+		super.initialize(classLoader, context);
+	}
+	
+}

Added: labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyWeavingURLClassLoader.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyWeavingURLClassLoader.java?rev=695947&view=auto
==============================================================================
--- labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyWeavingURLClassLoader.java (added)
+++ labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyWeavingURLClassLoader.java Tue Sep 16 08:46:03 2008
@@ -0,0 +1,366 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.magma.tools.maven;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.instrument.ClassFileTransformer;
+import java.lang.instrument.IllegalClassFormatException;
+import java.lang.instrument.Instrumentation;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.CodeSource;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.aspectj.bridge.AbortException;
+import org.aspectj.weaver.ExtensibleURLClassLoader;
+import org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor;
+import org.aspectj.weaver.loadtime.DefaultWeavingContext;
+import org.aspectj.weaver.loadtime.WeavingURLClassLoader;
+import org.aspectj.weaver.tools.Trace;
+import org.aspectj.weaver.tools.TraceFactory;
+import org.aspectj.weaver.tools.WeavingAdaptor;
+import org.aspectj.weaver.tools.WeavingClassLoader;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.mortbay.log.Log;
+
+import sun.misc.CompoundEnumeration;
+
+public class JettyWeavingURLClassLoader extends ExtensibleURLClassLoader implements WeavingClassLoader {
+
+	public static final String WEAVING_CLASS_PATH = "aj.class.path"; 
+	public static final String WEAVING_ASPECT_PATH = "aj.aspect.path"; 
+	
+	private URL[] aspectURLs;
+	private WeavingAdaptor adaptor;
+	private boolean initializingAdaptor;
+	private Map generatedClasses = new HashMap(); /* String -> byte[] */ 
+	
+	private static Trace trace = TraceFactory.getTraceFactory().getTrace(WeavingURLClassLoader.class);
+
+	public JettyWeavingURLClassLoader (URL[] classURLs, URL[] aspectURLs, ClassLoader parent, WebAppContext context) {
+		super(classURLs,parent);
+		this.aspectURLs = aspectURLs;
+		
+		/* If either we nor our parent is using an ASPECT_PATH use a new-style
+		 * adaptor
+		 */ 
+		if (this.aspectURLs.length > 0 || getParent() instanceof WeavingClassLoader) {
+			try {
+				adaptor = new WeavingAdaptor(this);
+			}
+			catch (ExceptionInInitializerError ex) {
+				ex.printStackTrace(System.out);
+				throw ex;
+			}
+		}
+		this.context = context;
+	}
+	
+	private static String getAspectPath () {
+		return System.getProperty(WEAVING_ASPECT_PATH,"");
+	}
+	
+	private static String getClassPath () {
+		return System.getProperty(WEAVING_CLASS_PATH,"");
+	}
+	
+	private static URL[] getURLs (String path) {
+		List urlList = new ArrayList();
+		for (StringTokenizer t = new StringTokenizer(path,File.pathSeparator);
+			 t.hasMoreTokens();) {
+			File f = new File(t.nextToken().trim());
+			try {
+				if (f.exists()) {
+					URL url = f.toURL();
+					if (url != null) urlList.add(url);
+				}
+			} catch (MalformedURLException e) {}
+		}
+
+		URL[] urls = new URL[urlList.size()];
+		urlList.toArray(urls);
+		return urls;
+	}
+
+	protected void addURL(URL url) {
+		adaptor.addURL(url);
+		super.addURL(url);
+	}
+
+	/**
+	 * Override to weave class using WeavingAdaptor 
+	 */
+	protected Class defineClass(String name, byte[] b, CodeSource cs) throws IOException {
+		if (trace.isTraceEnabled()) trace.enter("defineClass",this,new Object[] { name, b, cs });
+
+		/* Avoid recursion during adaptor initialization */
+		if (!initializingAdaptor) {
+			
+			/* Need to defer creation because of possible recursion during constructor execution */
+			if (adaptor == null && !initializingAdaptor) {
+				createAdaptor();
+			}
+			
+			try {
+				b = adaptor.weaveClass(name,b,false);
+				if (!cftInited) {
+					cftInit();
+				}		
+				byte[] nb = null;
+				try {
+					if (cft != null) 
+						nb = cft.transform(this, name, null, null, b);
+					if (nb != null) {
+						System.out.println("OpenJPA enhanced the class " + name);
+						b = nb;
+					}
+				} catch (IllegalClassFormatException e) {
+					throw new IOException("Error transforming class " + name, e);
+				}
+			}
+			catch (AbortException ex) {
+	    		trace.error("defineClass",ex);
+	    		throw ex;
+			}
+			catch (Throwable th) {
+	    		trace.error("defineClass",th);
+			}
+		}
+		Class clazz = super.defineClass(name, b, cs);
+		if (trace.isTraceEnabled()) trace.exit("defineClass",clazz);
+		return clazz;
+	}
+	
+	private void createAdaptor () {
+		DefaultWeavingContext weavingContext = new DefaultWeavingContext (this) {
+
+			/* Ensures consistent LTW messages for testing */
+			public String getClassLoaderName() {
+				ClassLoader loader = getClassLoader();
+				return loader.getClass().getName();
+			}
+			
+		};
+		
+		JettyClassLoaderWeavingAdaptor clwAdaptor = new JettyClassLoaderWeavingAdaptor();
+		initializingAdaptor = true;
+		clwAdaptor.initialize(this,weavingContext);
+		initializingAdaptor = false;
+		adaptor = clwAdaptor;
+	}
+
+	/**
+	 * Override to find classes generated by WeavingAdaptor
+	 */
+	protected byte[] getBytes (String name) throws IOException {
+		byte[] bytes = super.getBytes(name);
+		
+		if (bytes == null) {
+//			return adaptor.findClass(name);
+			return (byte[])generatedClasses.remove(name);
+		}
+		
+		return bytes;
+	}
+
+	/**
+	 * Implement method from WeavingClassLoader
+	 */
+	public URL[] getAspectURLs() {
+		return aspectURLs;
+	}
+
+	public void acceptClass (String name, byte[] bytes) {
+		generatedClasses.put(name,bytes);
+	}
+
+	private WebAppContext context;
+	private ClassFileTransformer cft;
+	
+	private boolean cftInited = false;
+
+	@Override
+	public Enumeration<URL> getResources(String name) throws IOException {
+		Enumeration<URL> res = null;
+		res = this.findResources(name);
+		if (!res.hasMoreElements() && name.startsWith("/")) {
+			res = this.findResources(name.substring(1));
+		}
+	
+		if (getParent() != null) {
+			Enumeration<URL> par = null;
+			par = getParent().getResources(name);
+			if (!par.hasMoreElements() && name.startsWith("/")) {
+				par = getParent().getResources(name.substring(1));
+			}
+			res = new CompoundEnumeration<URL>(new Enumeration[] { res, par });
+		}
+		
+		return res;
+	}
+	
+	public URL getResource(String name) {
+		URL url = null;
+		boolean tried_parent = false;
+		if (isSystemPath(name)) {
+			tried_parent = true;
+
+			if (getParent() != null)
+				url = getParent().getResource(name);
+		}
+
+		if (url == null) {
+			url = this.findResource(name);
+
+			if (url == null && name.startsWith("/")) {
+				url = this.findResource(name.substring(1));
+			}
+		}
+
+		if (url == null && !tried_parent) {
+			if (getParent() != null)
+				url = getParent().getResource(name);
+		}
+
+		return url;
+	}
+
+	protected synchronized Class loadClass(String name, boolean resolve)
+			throws ClassNotFoundException {
+		Class c = findLoadedClass(name);
+		ClassNotFoundException ex = null;
+		boolean tried_parent = false;
+
+		if (c == null && super.getParent() != null && isSystemPath(name)) {
+			tried_parent = true;
+			try {
+				c = getParent().loadClass(name);
+			} catch (ClassNotFoundException e) {
+				ex = e;
+			}
+		}
+
+		if (c == null) {
+			try {
+				c = this.findClass(name);
+			} catch (ClassNotFoundException e) {
+				ex = e;
+			}
+		}
+
+		if (c == null && getParent() != null && !tried_parent
+				&& !isServerPath(name))
+			c = getParent().loadClass(name);
+
+		if (c == null)
+			throw ex;
+
+		if (resolve)
+			resolveClass(c);
+
+		return c;
+	}
+
+	public boolean isServerPath(String name) {
+		name = name.replace('/', '.');
+		while (name.startsWith("."))
+			name = name.substring(1);
+		String[] server_classes = context.getServerClasses();
+		if (server_classes != null) {
+			for (int i = 0; i < server_classes.length; i++) {
+				boolean result = true;
+				String c = server_classes[i];
+				if (c.startsWith("-")) {
+					c = c.substring(1); // TODO cache
+					result = false;
+				}
+
+				if (c.endsWith(".")) {
+					if (name.startsWith(c))
+						return result;
+				} else if (name.equals(c))
+					return result;
+			}
+		}
+		return false;
+	}
+
+	public boolean isSystemPath(String name) {
+		name = name.replace('/', '.');
+		while (name.startsWith("."))
+			name = name.substring(1);
+		String[] system_classes = context.getSystemClasses();
+		if (system_classes != null) {
+			for (int i = 0; i < system_classes.length; i++) {
+				boolean result = true;
+				String c = system_classes[i];
+
+				if (c.startsWith("-")) {
+					c = c.substring(1); // TODO cache
+					result = false;
+				}
+
+				if (c.endsWith(".")) {
+					if (name.startsWith(c))
+						return result;
+				} else if (name.equals(c))
+					return result;
+			}
+		}
+		return false;
+	}
+	
+	private void cftInit() {
+		if (cftInited) return;
+		cftInited = true;
+		// Register openjpa transformer if present
+		Class cftclass = null;
+		try {
+			cftclass = loadClass("org.apache.magma.database.openjpa.SupportTransformer");
+		} catch (ClassNotFoundException e) {
+		}
+		if (cftclass != null) {
+			try {
+				URL[] urls = this.getAspectURLs();
+				String paths = ""; 
+				for (URL url : urls) {
+					paths += url.toExternalForm() + ";";
+				}
+				this.cft = (ClassFileTransformer) cftclass.getMethod("getTransformer", new Class[] {String.class}).invoke(null, new Object[] {paths});
+			} catch (IllegalArgumentException e) {
+				e.printStackTrace();
+			} catch (SecurityException e) {
+				e.printStackTrace();
+			} catch (IllegalAccessException e) {
+				e.printStackTrace();
+			} catch (InvocationTargetException e) {
+				e.printStackTrace();
+			} catch (NoSuchMethodException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+}

Added: labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcCompileMojo.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcCompileMojo.java?rev=695947&view=auto
==============================================================================
--- labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcCompileMojo.java (added)
+++ labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcCompileMojo.java Tue Sep 16 08:46:03 2008
@@ -0,0 +1,290 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.magma.tools.maven;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.mojo.aspectj.AjcCompileMojo;
+import org.codehaus.mojo.aspectj.Module;
+
+/**
+* @goal magma-compile
+* @requiresDependencyResolution compile
+* @phase process-sources
+* @description Magma AspectJ Compiler Plugin.
+* @author <a href="mailto:simoneg@apache.org">Simone Gianni</a>
+*/
+public class MagmaAjcCompileMojo extends AjcCompileMojo {
+
+	protected void assembleArguments() throws MojoExecutionException {
+		super.aspectLibraries = ModulesPreparer.prepareModules(project);
+		super.weaveDependencies = this.weaveDependencies;
+		super.assembleArguments();
+	}
+
+	public void execute() throws MojoExecutionException {
+		super.project = this.project;
+		super.basedir = this.basedir;
+		super.setOutxml(true);
+		if (!this.ajcOptions.contains("-target")) {
+			super.setTarget("1.5");
+		}
+		if (!this.ajcOptions.contains("-source")) {
+			super.setSource("1.5");
+		}		
+		super.execute();
+	}
+
+	/*
+	 * Copied from AjcAbstractCompiler cause Maven does not yet support inheriting properties
+	 * without sources
+	 */
+	
+    /**
+     * The source directory for the aspects
+     * @parameter default-value="src/main/aspect"
+     */
+    protected String aspectDirectory = "src/main/aspect";
+
+    /**
+     * The source directory for the test aspects
+     * @parameter default-value="src/test/aspect"
+     */
+    protected String testAspectDirectory = "src/test/aspect";
+
+    /**
+     * List of ant-style patterns used to specify the aspects that should be included when 
+     * compiling. When none specified all .java and .aj files in the project source directories, or
+     * directories spesified by the ajdtDefFile property are included.
+     * 
+     * * @parameter
+     */
+    protected String[] includes;
+
+    /**
+     * List of ant-style patterns used to specify the aspects that should be excluded when 
+     * compiling. When none specified all .java and .aj files in the project source directories, or
+     * directories spesified by the ajdtDefFile property are included.
+     * 
+     * * @parameter
+     */
+    protected String[] excludes;
+
+    /**
+     * Where to find the ajdt build definition file.
+     * <i>If set this will override the use of project sourcedirs</i>.
+     * 
+     * @parameter
+     */
+    protected String ajdtBuildDefFile;
+
+    /**
+     * List of of modules to weave (into target directory). Corresponds to ajc
+     * -inpath option (or -injars for pre-1.2 (which is not supported)).
+     * 
+     * @parameter
+     */
+    protected Module[] weaveDependencies;
+
+    /**
+     * Weave binary aspects from the jars. 
+     * The aspects should have been output by the same version of the compiler. 
+     * The modules must also be dependencies of the project.
+     * Corresponds to ajc -aspectpath option
+     * 
+     * @parameter
+     */
+    protected Module[] aspectLibraries;
+
+    /**
+     * Generate aop.xml file for load-time weaving with default name.(/META-INF/aop.xml)
+     * 
+     * @parameter
+     */
+    protected boolean outxml;
+
+    /**
+     * Generate aop.xml file for load-time weaving with custom name.
+     * 
+     * @parameter
+     */
+    protected String outxmlfile;
+
+    /**
+     * Generate .ajesym symbol files for emacs support
+     * 
+     *  @parameter
+     */
+    protected boolean emacssym;
+
+    /**
+     * Set default level for messages about potential 
+     * programming mistakes in crosscutting code. 
+     * {level} may be ignore, warning, or error. 
+     * This overrides entries in org/aspectj/weaver/XlintDefault.properties 
+     * from aspectjtools.jar.
+     * 
+     *  @parameter
+     */
+    protected String Xlint;
+
+    /**
+     * Specify classfile target setting (1.1 to 1.5) default is 1.2
+     * 
+     *  @parameter
+     */
+    protected String target;
+
+    /**
+     * Toggle assertions (1.3, 1.4, or 1.5 - default is 1.4). 
+     * When using -source 1.3, an assert() statement valid under Java 1.4 
+     * will result in a compiler error. When using -source 1.4, 
+     * treat assert as a keyword and implement assertions 
+     * according to the 1.4 language spec. 
+     * When using -source 1.5, Java 5 language features are permitted.
+     * 
+     *  @parameter
+     */
+    protected String source;
+
+    /**
+     * Specify compiler compliance setting (1.3 to 1.5)
+     * default is 1.4
+     * 
+     *  @parameter
+     */
+    protected String complianceLevel;
+
+    /**
+     * Toggle warningmessages on deprecations
+     * 
+     * @parameter
+     */
+    protected boolean deprecation;
+
+    /**
+     * Emit no errors for unresolved imports;
+     * 
+     * @parameter
+     */
+    protected boolean noImportError;
+
+    /**
+     * Keep compiling after error, dumping class files with problem methods
+     * 
+     * @parameter
+     */
+    protected boolean proceedOnError;
+
+    /**
+     * Preserve all local variables during code generation (to facilitate debugging).
+     * 
+     * @parameter
+     */
+    protected boolean preserveAllLocals;
+
+    /**
+     * Compute reference information.
+     * 
+     * @parameter
+     */
+    protected boolean referenceInfo;
+
+    /**
+     * Specify default source encoding format. 
+     *      
+     * @parameter
+     */
+    protected String encoding;
+
+    /**
+     * Emit messages about accessed/processed compilation units
+     * 
+     * @parameter
+     */
+    protected boolean verbose;
+
+    /**
+     * Emit messages about weaving
+     * 
+     * @parameter
+     */
+    protected boolean showWeaveInfo;
+
+    /**
+     * Repeat compilation process N times (typically to do performance analysis).
+     * 
+     * @parameter
+     */
+    protected int repeat;
+
+    /**
+     * (Experimental) runs weaver in reweavable mode which causes it to create 
+     * woven classes that can be rewoven, subject to the restriction 
+     * that on attempting a reweave all the types that advised the woven 
+     * type must be accessible.
+     * 
+     * @parameter
+     */
+    protected boolean Xreweavable;
+
+    /**
+     * (Experimental) do not inline around advice
+     * 
+     * @parameter
+     */
+    protected boolean XnoInline;
+
+    /**
+     * (Experimental) Normally it is an error to declare aspects Serializable. This option removes that restriction.
+     * 
+     * @parameter
+     */
+    protected boolean XserializableAspects;
+
+    /**
+     * The filename to store build configuration in.
+     * This file will be placed in the project build output
+     * directory, and will contain all the arguments
+     * passed to the compiler in the last run, and also
+     * all the filenames included in the build. Aspects as
+     * well as java files.
+     * 
+     * @parameter default-value="builddef.lst"
+     */
+    protected String argumentFileName = "builddef.lst";
+
+    /**
+     * The maven project.
+     * 
+     * @parameter expression="${project}"
+     * @required @readonly
+     */
+    protected MavenProject project;
+
+    /**
+     * The basedir of the project.
+     * 
+     * @parameter expression="${basedir}"
+     * @required @readonly
+     */
+    protected File basedir;
+    
+}

Added: labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcCompleteCompileMojo.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcCompleteCompileMojo.java?rev=695947&view=auto
==============================================================================
--- labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcCompleteCompileMojo.java (added)
+++ labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcCompleteCompileMojo.java Tue Sep 16 08:46:03 2008
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.magma.tools.maven;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.mojo.aspectj.Module;
+
+/**
+* @goal magma-deploy
+* @requiresDependencyResolution compile
+* @phase process-sources
+* @description Magma AspectJ Compiler Plugin.
+* @author <a href="mailto:simoneg@apache.org">Simone Gianni</a>
+*/
+public class MagmaAjcCompleteCompileMojo extends MagmaAjcCompileMojo {
+
+	protected void assembleArguments() throws MojoExecutionException {
+		super.weaveDependencies = ModulesPreparer.prepareModules(project);
+		super.assembleArguments();
+		this.ajcOptions.add("-Xlint:warning");
+	}
+	
+}

Added: labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcTestCompileMojo.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcTestCompileMojo.java?rev=695947&view=auto
==============================================================================
--- labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcTestCompileMojo.java (added)
+++ labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaAjcTestCompileMojo.java Tue Sep 16 08:46:03 2008
@@ -0,0 +1,299 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.magma.tools.maven;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.mojo.aspectj.AjcTestCompileMojo;
+import org.codehaus.mojo.aspectj.Module;
+
+/**
+ * @goal magma-test-compile
+ * @requiresDependencyResolution test
+ * @phase process-test-sources
+ * @description Magma AspectJ Compiler Plugin.
+ * @author <a href="mailto:simoneg@apache.org">Simone Gianni</a>
+ */
+public class MagmaAjcTestCompileMojo extends AjcTestCompileMojo {
+
+	protected void assembleArguments() throws MojoExecutionException {
+		Module[] modules = ModulesPreparer.prepareModules(project);
+		//super.weaveDependencies = modules;
+		super.aspectLibraries = modules;
+		super.assembleArguments();
+	}
+
+	public void execute() throws MojoExecutionException {
+		super.project = this.project;
+		super.basedir = this.basedir;
+		super.setOutxml(true);		
+		if (!this.ajcOptions.contains("-target")) {
+			super.setTarget("1.5");
+		}
+		if (!this.ajcOptions.contains("-source")) {
+			super.setSource("1.5");
+		}
+		this.ajcOptions.add("-Xlint:warning");
+		super.weaveMainSourceFolder = true;
+		super.execute();
+	}
+
+	
+	/*
+	 * Copied from AjcAbstractCompiler cause Maven does not yet support inheriting properties
+	 * without sources
+	 */
+	
+    /**
+     * The source directory for the aspects
+     * @parameter default-value="src/main/aspect"
+     */
+    protected String aspectDirectory = "src/main/aspect";
+
+    /**
+     * The source directory for the test aspects
+     * @parameter default-value="src/test/aspect"
+     */
+    protected String testAspectDirectory = "src/test/aspect";
+
+    /**
+     * List of ant-style patterns used to specify the aspects that should be included when 
+     * compiling. When none specified all .java and .aj files in the project source directories, or
+     * directories spesified by the ajdtDefFile property are included.
+     * 
+     * * @parameter
+     */
+    protected String[] includes;
+
+    /**
+     * List of ant-style patterns used to specify the aspects that should be excluded when 
+     * compiling. When none specified all .java and .aj files in the project source directories, or
+     * directories spesified by the ajdtDefFile property are included.
+     * 
+     * * @parameter
+     */
+    protected String[] excludes;
+
+    /**
+     * Where to find the ajdt build definition file.
+     * <i>If set this will override the use of project sourcedirs</i>.
+     * 
+     * @parameter
+     */
+    protected String ajdtBuildDefFile;
+
+    /**
+     * List of of modules to weave (into target directory). Corresponds to ajc
+     * -inpath option (or -injars for pre-1.2 (which is not supported)).
+     * 
+     * @parameter
+     */
+    protected Module[] weaveDependencies;
+
+    /**
+     * Weave binary aspects from the jars. 
+     * The aspects should have been output by the same version of the compiler. 
+     * The modules must also be dependencies of the project.
+     * Corresponds to ajc -aspectpath option
+     * 
+     * @parameter
+     */
+    protected Module[] aspectLibraries;
+
+    /**
+     * Generate aop.xml file for load-time weaving with default name.(/META-INF/aop.xml)
+     * 
+     * @parameter
+     */
+    protected boolean outxml;
+
+    /**
+     * Generate aop.xml file for load-time weaving with custom name.
+     * 
+     * @parameter
+     */
+    protected String outxmlfile;
+
+    /**
+     * Generate .ajesym symbol files for emacs support
+     * 
+     *  @parameter
+     */
+    protected boolean emacssym;
+
+    /**
+     * Set default level for messages about potential 
+     * programming mistakes in crosscutting code. 
+     * {level} may be ignore, warning, or error. 
+     * This overrides entries in org/aspectj/weaver/XlintDefault.properties 
+     * from aspectjtools.jar.
+     * 
+     *  @parameter
+     */
+    protected String Xlint;
+
+    /**
+     * Specify classfile target setting (1.1 to 1.5) default is 1.2
+     * 
+     *  @parameter
+     */
+    protected String target;
+
+    /**
+     * Toggle assertions (1.3, 1.4, or 1.5 - default is 1.4). 
+     * When using -source 1.3, an assert() statement valid under Java 1.4 
+     * will result in a compiler error. When using -source 1.4, 
+     * treat assert as a keyword and implement assertions 
+     * according to the 1.4 language spec. 
+     * When using -source 1.5, Java 5 language features are permitted.
+     * 
+     *  @parameter
+     */
+    protected String source;
+
+    /**
+     * Specify compiler compliance setting (1.3 to 1.5)
+     * default is 1.4
+     * 
+     *  @parameter
+     */
+    protected String complianceLevel;
+
+    /**
+     * Toggle warningmessages on deprecations
+     * 
+     * @parameter
+     */
+    protected boolean deprecation;
+
+    /**
+     * Emit no errors for unresolved imports;
+     * 
+     * @parameter
+     */
+    protected boolean noImportError;
+
+    /**
+     * Keep compiling after error, dumping class files with problem methods
+     * 
+     * @parameter
+     */
+    protected boolean proceedOnError;
+
+    /**
+     * Preserve all local variables during code generation (to facilitate debugging).
+     * 
+     * @parameter
+     */
+    protected boolean preserveAllLocals;
+
+    /**
+     * Compute reference information.
+     * 
+     * @parameter
+     */
+    protected boolean referenceInfo;
+
+    /**
+     * Specify default source encoding format. 
+     *      
+     * @parameter
+     */
+    protected String encoding;
+
+    /**
+     * Emit messages about accessed/processed compilation units
+     * 
+     * @parameter
+     */
+    protected boolean verbose;
+
+    /**
+     * Emit messages about weaving
+     * 
+     * @parameter
+     */
+    protected boolean showWeaveInfo;
+
+    /**
+     * Repeat compilation process N times (typically to do performance analysis).
+     * 
+     * @parameter
+     */
+    protected int repeat;
+
+    /**
+     * (Experimental) runs weaver in reweavable mode which causes it to create 
+     * woven classes that can be rewoven, subject to the restriction 
+     * that on attempting a reweave all the types that advised the woven 
+     * type must be accessible.
+     * 
+     * @parameter
+     */
+    protected boolean Xreweavable;
+
+    /**
+     * (Experimental) do not inline around advice
+     * 
+     * @parameter
+     */
+    protected boolean XnoInline;
+
+    /**
+     * (Experimental) Normally it is an error to declare aspects Serializable. This option removes that restriction.
+     * 
+     * @parameter
+     */
+    protected boolean XserializableAspects;
+
+    /**
+     * The filename to store build configuration in.
+     * This file will be placed in the project build output
+     * directory, and will contain all the arguments
+     * passed to the compiler in the last run, and also
+     * all the filenames included in the build. Aspects as
+     * well as java files.
+     * 
+     * @parameter default-value="builddef.lst"
+     */
+    protected String argumentFileName = "builddef.lst";
+
+    /**
+     * The maven project.
+     * 
+     * @parameter expression="${project}"
+     * @required @readonly
+     */
+    protected MavenProject project;
+
+    /**
+     * The basedir of the project.
+     * 
+     * @parameter expression="${basedir}"
+     * @required @readonly
+     */
+    protected File basedir;
+    
+	
+}

Added: labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaJettyRun.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaJettyRun.java?rev=695947&view=auto
==============================================================================
--- labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaJettyRun.java (added)
+++ labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaJettyRun.java Tue Sep 16 08:46:03 2008
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.magma.tools.maven;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.ContextHandlerCollection;
+import org.mortbay.jetty.handler.DefaultHandler;
+import org.mortbay.jetty.handler.HandlerCollection;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.plugin.util.SystemProperty;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.mortbay.resource.Resource;
+import org.mortbay.util.Scanner;
+
+/**
+ * @goal run
+ * @requiresDependencyResolution runtime
+ * @execute phase="test-compile"
+ * @description Runs a jetty 6 servler, with proper load time weaving classloader
+ */
+public class MagmaJettyRun extends AbstractMojo {
+
+	/**
+	 * The maven project.
+	 * 
+	 * @parameter expression="${executedProject}"
+	 * @required
+	 * @readonly
+	 */
+	private MavenProject project;
+
+	/**
+	 * The context path for the webapp. Defaults to the name of the webapp's
+	 * artifact.
+	 * 
+	 * @parameter expression="/${project.artifactId}"
+	 * @required
+	 */
+	private String contextPath;
+
+	/**
+	 * The temporary directory to use for the webapp. Defaults to
+	 * target/work
+	 * 
+	 * @parameter expression="${project.build.directory}/work"
+	 * @required
+	 */
+	private File tmpDirectory;
+
+	/**
+	 * A scanner to check for changes to the webapp
+	 */
+	private Scanner scanner;
+
+	/**
+	 * List of files and directories to scan
+	 */
+	private ArrayList scanList;
+
+	/**
+	 * List of Listeners for the scanner
+	 */
+	private ArrayList scannerListeners;
+
+	/**
+	 * The directory containing generated classes.
+	 * 
+	 * @parameter expression="${project.build.outputDirectory}"
+	 * @required
+	 * 
+	 */
+	private File classesDirectory;
+	
+    /**
+     * System properties to set before execution. 
+     * Note that these properties will NOT override System properties 
+     * that have been set on the command line or by the JVM. Optional.
+     * @parameter 
+     */
+    private SystemProperty[] systemProperties;
+
+	public String PORT_SYSPROPERTY = "jetty.port";    
+    
+    public static int DEFAULT_PORT = 8080;
+    public static int DEFAULT_MAX_IDLE_TIME = 30000;
+	
+	public void execute() throws MojoExecutionException, MojoFailureException {
+		System.setProperty("magma.env", System.getProperty("magma.env", "devel"));
+		Server server = new Server();
+        server.setStopAtShutdown(true);
+        //make sure Jetty does not use URLConnection caches with the plugin
+        Resource.setDefaultUseCaches(false);
+
+        // Create the webapp
+        WebAppContext webapp = new WebAppContext();
+        webapp.setContextPath(this.contextPath);
+        webapp.setWar(this.classesDirectory.getAbsolutePath());
+        if (!tmpDirectory.exists()) {
+        	if (!tmpDirectory.mkdirs()) {
+        		throw new MojoExecutionException("Cannot create temporary directory " + tmpDirectory.getAbsolutePath());
+        	}
+        }
+        webapp.setTempDirectory(tmpDirectory);
+        tmpDirectory.deleteOnExit();
+        //webapp.setOverrideDescriptor(<the provided web.xml>);
+        /*
+        Class dispatchClazz = null;
+		try {
+			dispatchClazz = Class.forName("org.apache.magma.website.Dispatch");
+		} catch (ClassNotFoundException e1) {
+			throw new MojoExecutionException("Cannot find the magma dispatcher servlet, is magma-foundation-website a dependency?");
+		}
+        webapp.addServlet(dispatchClazz, "/*");
+        */
+		webapp.addServlet("org.apache.magma.website.Dispatch", "/*");
+        
+        // Setup the classloader
+        List urls = new ArrayList();
+		try {
+			List resources = project.getResources();
+			for (Iterator iterator = resources.iterator(); iterator.hasNext();) {
+				org.apache.maven.model.Resource res = (org.apache.maven.model.Resource) iterator.next();
+				urls.add(new File(res.getDirectory()).toURI().toURL());
+			}
+			urls.add(this.classesDirectory.toURI().toURL());
+			
+			Set artifacts = project.getArtifacts();
+			for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
+				Artifact art = (Artifact) iterator.next();
+				urls.add(art.getFile().toURI().toURL());
+			}
+		} catch (IOException e) {
+			throw new MojoExecutionException("Error setting up classloader url list", e);
+		}
+		
+		URL[] urlarray = (URL[]) urls.toArray(new URL[urls.size()]);
+        JettyWeavingURLClassLoader cl = new JettyWeavingURLClassLoader(urlarray, urlarray, Thread.currentThread().getContextClassLoader(), webapp);
+        webapp.setClassLoader(cl);
+
+
+        // Setup the handler chains
+        ContextHandlerCollection contexts = new ContextHandlerCollection();
+        contexts.addHandler(webapp);
+        HandlerCollection handlers = new HandlerCollection();
+        Handler defaultHandler = new DefaultHandler();
+        handlers.setHandlers(new Handler[]{contexts, defaultHandler});
+        server.setHandler(handlers);
+        
+        // Create the default connector
+        SelectChannelConnector connector = new SelectChannelConnector();
+        String portnum = System.getProperty(PORT_SYSPROPERTY, null);
+        int port = ((portnum==null||portnum.equals(""))?DEFAULT_PORT:Integer.parseInt(portnum.trim()));
+        connector.setPort(port);
+        connector.setMaxIdleTime(DEFAULT_MAX_IDLE_TIME);
+        server.addConnector(connector);
+        
+        try {
+			server.start();
+			server.join();
+		} catch (Exception e) {
+			throw new MojoExecutionException("Error starting server", e);
+		}
+	}
+    
+	
+}

Added: labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaTestAgent.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaTestAgent.java?rev=695947&view=auto
==============================================================================
--- labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaTestAgent.java (added)
+++ labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaTestAgent.java Tue Sep 16 08:46:03 2008
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.magma.tools.maven;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.instrument.ClassFileTransformer;
+import java.lang.instrument.Instrumentation;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+
+import sun.reflect.ReflectionFactory.GetReflectionFactoryAction;
+
+public class MagmaTestAgent {
+
+	public static void premain(String args, Instrumentation instr) {
+		// Register openjpa transformer if present
+		Class cftclass = null;
+		try {
+			cftclass = Class.forName("org.apache.magma.database.openjpa.SupportTransformer");
+		} catch (ClassNotFoundException e) {
+		}
+		if (cftclass != null) {
+			try {
+				InputStream ress = cftclass.getResourceAsStream("/magma-test-classpath.txt");
+				if (ress == null) {
+					System.out.println("Cannot find test classpath resource, aborting");
+					return;
+				}
+				InputStreamReader insr = new InputStreamReader(ress);
+				BufferedReader br = new BufferedReader(insr);
+				String paths = br.readLine();
+				br.close();
+				ClassFileTransformer cft = null;
+				cft = (ClassFileTransformer) cftclass.getMethod("getTransformer", new Class[] {String.class}).invoke(null, new Object[] {paths});
+				instr.addTransformer(cft);
+			} catch (IllegalArgumentException e) {
+				e.printStackTrace();
+			} catch (SecurityException e) {
+				e.printStackTrace();
+			} catch (IllegalAccessException e) {
+				e.printStackTrace();
+			} catch (InvocationTargetException e) {
+				e.printStackTrace();
+			} catch (NoSuchMethodException e) {
+				e.printStackTrace();
+			} catch (IOException e) {
+				e.printStackTrace();
+			} catch (Throwable t) {
+				t.printStackTrace();
+			}
+		}
+		
+	}
+	
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org