aboutsummaryrefslogtreecommitdiffstats
path: root/docs/sandbox/trails/j2ee.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/sandbox/trails/j2ee.html')
-rw-r--r--docs/sandbox/trails/j2ee.html87
1 files changed, 87 insertions, 0 deletions
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 @@
+<html>
+<body>
+
+This contains short notes on using AspectJ with various J2EE
+servers and deployment tools.
+
+<!-- @author Wes Isberg -->
+
+<h3>Using AspectJ in servlets</h3>
+<h4>Generally</h4>
+<!-- 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.
+
+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.
+
+<!-- END-SAMPLE j2ee-servlets-generally -->
+
+<h4>Running AspectJ servlets in Tomcat 4.x</h4>
+
+<!-- START-SAMPLE j2ee-tomcat4-servlets 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.
+<ol>
+<li>Use <code>ajc</code> to compile the servlets,
+ and deploy the classes as usual into
+ <code>{WebRoot}/WEB-INF/classes</code>.
+ </li>
+
+<li>If your web applications or aspects do not interact, deploy
+ <code>aspectjrt.jar</code> into
+ <code>{WebRoot}/WEB-INF/lib</code>.
+ </li>
+<li>If your web applications or aspects might interact, deploy
+ them to <code>${CATALINE_BASE}/shared/lib</code>.
+ </li>
+</ol>
+<!-- END-SAMPLE j2ee-tomcat4-servlets -->
+
+<!-- START-SAMPLE j2ee-tomcat4-jsp Running AspectJ JSP's in Tomcat 4.x -->
+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:
+<ol>
+<li>Put <code>aspectjtools.jar</code> in
+<code>${CATALINA_HOME}/common/lib</code> so that it can be loaded
+by Jasper.
+</li>
+<li>Update Jasper servlet parameters in
+ <code>${CATALINA_HOME}/conf/web.xml</code> to tell Ant to use
+ <code>ajc</code> by setting the compiler property to the
+ AspectJ compiler adapter:
+ <pre>
+ &lt;servlet>
+ &lt;servlet-name>jsp&lt;/servlet-name>
+ &lt;servlet-class>org.apache.jasper.servlet.JspServlet&lt;/servlet-class>
+ ...
+ &lt;init-param>
+ &lt;param-name>compiler&lt;/param-name>
+ &lt;param-value>org.aspectj.tools.ant.taskdefs.Ajc11CompilerAdapter&lt;/param-value>
+ &lt;/init-param>
+ </pre>
+</li>
+<li>The classpath is dynamically generated from the webapp deployment,
+so <code>aspectjrt.jar</code> should be in
+<code>{webapp}/WEB-INF/lib</code> or some shared or common
+directory supported by the server.
+</li>
+
+<li>Alternatively, you can precompile JSP's using
+<a href="#j2ee-tomcat4-precompileJsp">this Ant script</a>.
+That involves manually updating the <code>web.xml</code> file
+with the <code>Jasper</code>-generated servlet mappings.
+</li>
+</ol>
+<!-- END-SAMPLE j2ee-tomcat4-jsp -->
+
+
+<!-- START-SAMPLE j2ee-servlets-tomcat4-myeclipseide Running AspectJ servlets in Tomcat 4.x using MyEclipseIDE -->
+
+<!-- END-SAMPLE j2ee-servlets-tomcat4-myeclipseide -->
+
+</body>
+</html>