Browse Source

matthews fixes for 95517

tags/V1_5_0RC1
aclement 18 years ago
parent
commit
4ea0051376

+ 35
- 10
build/src/$installer$/org/aspectj/Main.java View File

@@ -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,12 +1563,23 @@ 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));
}

/**
* @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
*/
@@ -1574,13 +1587,25 @@ 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(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");

+ 16
- 0
docs/dist/doc/examples/ltw/HelloWorld.java View File

@@ -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!");
}
}

+ 29
- 10
docs/dist/doc/examples/ltw/README View File

@@ -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

+ 23
- 0
docs/dist/doc/examples/ltw/Tracing.aj View File

@@ -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);
}
}

Loading…
Cancel
Save