From: wisberg Date: Thu, 7 Aug 2003 06:57:57 +0000 (+0000) Subject: - initial api-based tests X-Git-Tag: V1_1_1~141 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=94cb789115ddbbd149309759711e0e3b6515a36b;p=aspectj.git - initial api-based tests - initial J2EE samples (added support for XML/Ant scripts) --- diff --git a/docs/sandbox/readme-sandbox.html b/docs/sandbox/readme-sandbox.html index d8c874399..4745b98f2 100644 --- a/docs/sandbox/readme-sandbox.html +++ b/docs/sandbox/readme-sandbox.html @@ -2,7 +2,7 @@ README - AspectJ sandbox for sample code and instructions

README - AspectJ sandbox for sample code and instructions

-This directory is a place to put some scraps that might end up in the +This directory is a place to put scraps that might end up in the AspectJ documentation or on the web site: +

Happy coding!


diff --git a/docs/sandbox/sandbox-api-test.xml b/docs/sandbox/sandbox-api-test.xml new file mode 100644 index 000000000..959272592 --- /dev/null +++ b/docs/sandbox/sandbox-api-test.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/sandbox/sandbox-test.xml b/docs/sandbox/sandbox-test.xml index 332a4a9d1..fe0eb4110 100644 --- a/docs/sandbox/sandbox-test.xml +++ b/docs/sandbox/sandbox-test.xml @@ -13,7 +13,6 @@ - verify that RunTime and RuntimeWrites throw Errors - harness bug: errStreamIsError not false when not forked; fork? - check output/error stream against expected - - verify api-clients, using access to aspectjtools.jar... --> @@ -133,14 +132,4 @@ - \ No newline at end of file diff --git a/docs/sandbox/scripts/precompile-jsp.build.xml b/docs/sandbox/scripts/precompile-jsp.build.xml new file mode 100644 index 000000000..bdabff97b --- /dev/null +++ b/docs/sandbox/scripts/precompile-jsp.build.xml @@ -0,0 +1,137 @@ + + + + + + + + +This Ant script precompiles deployed .jsp files in Tomcat +using AspectJ 1.1. + +Usage: + + {ant} -f {this-script} \ + -Dtomcat.home=/home/tomcat \ + -Dwebapp.name=launchWeb \ + -DASPECTJ_HOME=/dev/tools/aspectj-1.1.0 + + +This defines the web application deployment $${webapp.dir} as + + $${tomcat.home}/webapps/$${webapp.name} + +, generates the Java source files to + + $${webapp.dir}/WEB-INF/src + +, uses iajc (AspectJ) to compile them to + + $${webapp.dir}/WEB-INF/classes, + +, and creates the mappings + + $${webapp.dir}/WEB-INF/generated_web.xml, + +which must be manually inserted into + + $${webapp.dir}/WEB-INF/generated_web.xml, + +at which point the web application can be reloaded. + +This assumes that aspectjrt.jar is already deployed in +any of places on the Tomcat application classpath +(the application, shared, or common classpath). +If ASPECTJ_HOME is not defined, it assumes that +aspectjtools.jar is in + + ${CATALINA_HOME}/common/lib + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/sandbox/trails/j2ee.html b/docs/sandbox/trails/j2ee.html new file mode 100644 index 000000000..dc99e0731 --- /dev/null +++ b/docs/sandbox/trails/j2ee.html @@ -0,0 +1,87 @@ + + + +This contains short notes on using AspectJ with various J2EE +servers and deployment tools. + + + +

Using AspectJ in servlets

+

Generally

+ +AspectJ programs work if run in the same namespace and with aspectjrt.jar. +Servlet runners and J2EE web containers should run AspectJ programs fine +if the classes and required libraries are deployed as usual. + +As with any shared library, if more than one application is using AspectJ, +then the aspectjrt.jar should be deployed where it will be loaded by a +common classloader. The same is true of any shared aspects. + + + +

Running AspectJ servlets in Tomcat 4.x

+ + +In Tomcat, you can deploy application servlets in WAR's +or in exploded web directories and share code across +applications. +
    +
  1. Use ajc to compile the servlets, + and deploy the classes as usual into + {WebRoot}/WEB-INF/classes. +
  2. + +
  3. If your web applications or aspects do not interact, deploy + aspectjrt.jar into + {WebRoot}/WEB-INF/lib. +
  4. +
  5. If your web applications or aspects might interact, deploy + them to ${CATALINE_BASE}/shared/lib. +
  6. +
+ + + +Tomcat 4.x uses the Jasper engine based on Ant to compile JSP's. +To set up ajc as the compiler, do the following before starting Tomcat: +
    +
  1. Put aspectjtools.jar in +${CATALINA_HOME}/common/lib so that it can be loaded +by Jasper. +
  2. +
  3. Update Jasper servlet parameters in + ${CATALINA_HOME}/conf/web.xml to tell Ant to use + ajc by setting the compiler property to the + AspectJ compiler adapter: +
    +    <servlet>
    +        <servlet-name>jsp</servlet-name>
    +        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    +        ...
    +        <init-param>
    +            <param-name>compiler</param-name>
    +            <param-value>org.aspectj.tools.ant.taskdefs.Ajc11CompilerAdapter</param-value>
    +        </init-param>
    +	
    +
  4. +
  5. The classpath is dynamically generated from the webapp deployment, +so aspectjrt.jar should be in +{webapp}/WEB-INF/lib or some shared or common +directory supported by the server. +
  6. + +
  7. Alternatively, you can precompile JSP's using +this Ant script. +That involves manually updating the web.xml file +with the Jasper-generated servlet mappings. +
  8. +
+ + + + + + + + + diff --git a/docs/sandbox/trails/j2ee.txt b/docs/sandbox/trails/j2ee.txt deleted file mode 100644 index 8685939b1..000000000 --- a/docs/sandbox/trails/j2ee.txt +++ /dev/null @@ -1,34 +0,0 @@ - -This contains short notes on using AspectJ with various J2EE -servers and deployment tools. - -// @author Wes Isberg - --------- START-SAMPLE j2ee-servlets-generally Using AspectJ in servlets -AspectJ programs work if run in the same namespace and with aspectjrt.jar. -Servlet runners and J2EE web containers should run AspectJ programs fine -if the classes and required libraries are deployed as usual. The runtime -classes and shared aspects might need to be deployed into a common -directory to work properly across applications, especially in containers -that use different class loaders for different applications or use -different class-loading schemes. - -As with any shared library, if more than one application is using AspectJ, -then the aspectjrt.jar should be deployed where it will be loaded by a -common classloader. - -Aspects which are used by two applications might be independent or shared. -Independent aspects can be deployed in each application-specific archive. -Aspects might be shared explicitly or implicitly, as when they are stateful -or staticly bound (however indirectly) to common classes. When in doubt, -it is safest to deploy the aspects in the common namespace. - --------- END-SAMPLE j2ee-servlets-generally - --------- START-SAMPLE j2ee-servlets-tomcat4 Running AspectJ servlets in Tomcat 4.x -To deploy an AspectJ program as a Tomcat servlet, -place aspectjrt.jar in shared/lib and deploy the required libraries -and AspectJ-compiled servlet classes as usual. - --------- END-SAMPLE j2ee-servlets-tomcat4 - diff --git a/docs/sandbox/trails/myeclipseide.html b/docs/sandbox/trails/myeclipseide.html new file mode 100644 index 000000000..daff02e49 --- /dev/null +++ b/docs/sandbox/trails/myeclipseide.html @@ -0,0 +1,87 @@ + + + + + +MyEclipseIde +(http://www.myeclipseide.com) +aims to make it easy to develop J2EE applications using Eclipse. +AJDT +(http://eclipse.org/ajdt) +is an Eclipse plug-in that supports AspectJ. + + + + + + +

Bugs in MyEclipseIDE

+
    +
  1. After refactoring to rename a servlet, have to manually update web.xml
  2. +
  3. Silent failure when unable to delete a duplicate resource during deployment.
  4. +
  5. Annoyingly modal UI for deployment. Use a view.
  6. +
  7. Need validation on saving Web.xml. E.g., servlet mapping names validated with declared servlet names.
  8. +
  9. Deployment dirty flag not working; not updated after editing web.xml or rebuilding project.
  10. +
  11. Apparantly false JSP error? using Sun page and template page, + got: + "Fatal error - The markup in the document preceding the root element + must be well-formed." + Error persisted even after replacing the entire contents of the file + with the template which worked by default. +
  12. +
  13. When using the exact template page, get no MyEclipseIDE error, + but do get compile errors in Tomcat. Using Javac, get compile-failed + stack trace with initial line number. Using ajc, just get stack trace. + But precompiling using Ant seems to work. +
  14. +
  15. Precompiling JSP's: +
      +
    • MyEclipseIDE has a command to compile all JSP's, but + I don't see (where or how) the updated servlet mappings + get into the deployed web.xml. + It would be great to get this working with AJDT. +
    • +
    • I adapted the Tomcat precompile script to use AspectJ's iajc. + This works fine, but like all Jasper2 solutions required the + generated servlet mappings be copied manually into the web.xml file. + See the Ant build script +
    • +
    +
  16. +
+ + + \ No newline at end of file