diff options
-rw-r--r-- | build/src/$installer$/org/aspectj/Main.java | 45 | ||||
-rw-r--r-- | docs/dist/doc/examples/ltw/HelloWorld.java | 16 | ||||
-rw-r--r-- | docs/dist/doc/examples/ltw/README | 39 | ||||
-rw-r--r-- | docs/dist/doc/examples/ltw/Tracing.aj | 23 |
4 files changed, 103 insertions, 20 deletions
diff --git a/build/src/$installer$/org/aspectj/Main.java b/build/src/$installer$/org/aspectj/Main.java index 65ba9be5a..073b8a792 100644 --- a/build/src/$installer$/org/aspectj/Main.java +++ b/build/src/$installer$/org/aspectj/Main.java @@ -705,7 +705,7 @@ class InstallContext { } public boolean onUnix() { - return !onMacintosh() && !onWindows(); + return !onWindows(); } static final String[] TEXT_EXTENSIONS = { @@ -1347,7 +1347,8 @@ class InstallPane extends WizardPane { // Moved to the bin dir in 1.2.1 // we should now come back and make the generation of this // script uniform with those above. - lsm.writeAJLaunchScript(); + lsm.writeAJLaunchScript("aj",false); + lsm.writeAJLaunchScript("aj5",true); } if (hasGui()) { progressBar.setValue(100); @@ -1517,8 +1518,7 @@ class LaunchScriptMaker { /** * */ - public void writeAJLaunchScript() throws IOException { - String name = "aj"; + public void writeAJLaunchScript(String name, boolean isJava5) throws IOException { if (!context.onUnix()) { if (context.onOS2()) { name += ".cmd"; @@ -1532,7 +1532,7 @@ class LaunchScriptMaker { File file = new File(destDir, name); PrintStream ps = getPrintStream(file); - writeAJLaunchScriptContent(ps); + writeAJLaunchScriptContent(ps,isJava5); ps.close(); if (context.onUnix()) { @@ -1543,14 +1543,16 @@ class LaunchScriptMaker { /** * @param ps */ - private void writeAJLaunchScriptContent(PrintStream ps) { + private void writeAJLaunchScriptContent(PrintStream ps, boolean isJava5) { if (context.onUnix()) { writeUnixHeader(ps); - writeAJUnixLaunchLine(ps); + if (isJava5) writeAJ5UnixLaunchLine(ps); + else writeAJUnixLaunchLine(ps); } else { writeWindowsHeader(ps); - writeAJWindowsLaunchLine(ps); + if (isJava5) writeAJ5WindowsLaunchLine(ps); + else writeAJWindowsLaunchLine(ps); } } @@ -1561,7 +1563,7 @@ class LaunchScriptMaker { ps.println( "\"%JAVA_HOME%\\bin\\java\" -classpath " + "\"%ASPECTJ_HOME%\\lib\\aspectjweaver.jar\"" + - " \"-Djava.system.class.loader=org.aspectj.weaver.WeavingURLClassLoader\"" + + " \"-Djava.system.class.loader=org.aspectj.weaver.loadtime.WeavingURLClassLoader\"" + " \"-Daj.class.path=%ASPECTPATH%;%CLASSPATH%\"" + " \"-Daj.aspect.path=%ASPECTPATH%\"" + " " + makeScriptArgs(false)); @@ -1570,17 +1572,40 @@ class LaunchScriptMaker { /** * @param ps */ + private void writeAJ5WindowsLaunchLine(PrintStream ps) { + ps.println( + "\"%JAVA_HOME%\\bin\\java\" -classpath " + + "\"%ASPECTJ_HOME%\\lib\\aspectjweaver.jar;%CLASSPATH%\"" + + " \"-javaagent:%ASPECTJ_HOME%\\lib\\aspectjweaver.jar\"" + + " " + makeScriptArgs(false)); + } + + /** + * @param ps + */ private void writeAJUnixLaunchLine(PrintStream ps) { ps.println( "\"$JAVA_HOME/bin/java\" -classpath" + " \"$ASPECTJ_HOME/lib/aspectjweaver.jar\"" + - " \"-Djava.system.class.loader=org.aspectj.weaver.WeavingURLClassLoader\"" + + " \"-Djava.system.class.loader=org.aspectj.weaver.loadtime.WeavingURLClassLoader\"" + " \"-Daj.class.path=$ASPECTPATH:$CLASSPATH\"" + " \"-Daj.aspect.path=$ASPECTPATH\"" + " " + makeScriptArgs(true)); } + /** + * @param ps + */ + private void writeAJ5UnixLaunchLine(PrintStream ps) { + ps.println( + "\"$JAVA_HOME/bin/java\" -classpath" + + " \"$ASPECTJ_HOME/lib/aspectjweaver.jar:$CLASSPATH\"" + + " \"-javaagent:$ASPECTJ_HOME/lib/aspectjweaver.jar\"" + + " " + + makeScriptArgs(true)); + } + private void writeWindowsHeader(PrintStream ps) { ps.println("@echo off"); ps.println("REM This file generated by AspectJ installer"); diff --git a/docs/dist/doc/examples/ltw/HelloWorld.java b/docs/dist/doc/examples/ltw/HelloWorld.java new file mode 100644 index 000000000..8201a8f68 --- /dev/null +++ b/docs/dist/doc/examples/ltw/HelloWorld.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Matthew Webster initial implementation + */ +public class HelloWorld { + + public static void main (String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/docs/dist/doc/examples/ltw/README b/docs/dist/doc/examples/ltw/README index 92011019e..f749692ac 100644 --- a/docs/dist/doc/examples/ltw/README +++ b/docs/dist/doc/examples/ltw/README @@ -1,23 +1,42 @@ -The bin directory of your AspectJ distribution contains a script "aj" to
-perform load-time weaving. Java classes on the CLASSPATH are loaded and
-woven with aspects on the ASPECTPATH.
-This feature is only supported on JDK 1.4 and later.
+For users of JDK 1.4 the bin directory of your AspectJ distribution
+contains a script "aj" to perform load-time weaving. Java classes on
+the CLASSPATH are loaded and woven with aspects also on the CLASSPATH
+which are declared in an aop.xml file. This file is either created by
+the user or generated by the compiler. Alternatively aspects can be
+loaded from an explicitly defined ASPECTPATH.
---To compile the tracing example--
+For users of JDK 1.5 the bin directory of your AspectJ distribution
+contains a script "aj5" to perform load-time weaving using an agent.
+This uses an aop.xml as described above.
- ant -f ../build.xml tracing-lt
+--To compile the HelloWorld program--
+
+ ajc -outjar hello.jar HelloWorld.java
+
+--To compile the Tracing aspect--
+
+ ajc -outjar tracing.jar -outxml Tracing.aj
--To run the example--
- set CLASSPATH to include "../jars/tracingApp.jar"
+ set CLASSPATH to include hello.jar
- aj tracing.ExampleMain
+ aj HelloWorld
--To run the example with tracing--
- set ASPECTPATH=../jars/tracingLib.jar
+ set CLASSPATH to include "tracing.jar"
+
+ aj HelloWorld
+
+--To run the example with tracing using ASPECTPATH--
+
+ set ASPECTPATH=tracing.jar
+
+ aj HelloWorld
- aj tracing.ExampleMain
+--To run the example with tracing using an agent--
+ aj5 HelloWorld
diff --git a/docs/dist/doc/examples/ltw/Tracing.aj b/docs/dist/doc/examples/ltw/Tracing.aj new file mode 100644 index 000000000..29268f348 --- /dev/null +++ b/docs/dist/doc/examples/ltw/Tracing.aj @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Matthew Webster initial implementation + */ +public aspect Tracing { + + private pointcut mainMethod () : + execution(public static void main(String[])); + + before () : mainMethod() { + System.out.println("> " + thisJoinPoint); + } + + after () : mainMethod() { + System.out.println("< " + thisJoinPoint); + } +} |