Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] AJC and JSP

Hi -

> Is it possible to develop JSP's and compile
> them with AJC inside Tomcat?

To pre-compile JSP's in Tomcat, see

  org.aspectj/modules/docs/sandbox/scripts/precompile-jsp.build.xml

in the AspectJ CVS repository.

Ron Bodkin helped a lot in coming to a solution for compiling
JSP's in Tomcat (many thanks!).  We think we have one, but
it's yet untested and (heretofore) undocumented.

To compile JSP's in Tomcat's Ant builder, use the Javac task's
${build.compiler} property to specify ajc as the compiler.
(1.1.1 should have the fix for the bug found by Ron --
setting the destination directory to "." when unspecified.)

Then somehow you want to add ajc- and project-specific entries
for -injars, -aspectpath, etc., in order to include aspects.
Since Tomcat uses a single build.xml file, you can only add one
set of extra arguments for ajc.  That would work if your projects
had exactly the same aspects.  To support projects with different
aspects, supply the iajc task a component that rewrites the
command line just before it invokes ajc.[1]  In that, you could,
e.g., extract entries from the classpath intended for -aspectpath
or -injars, if, e.g., you named them {module}-aspectpath.jar or
{module}-injars.jar.  That would give you one mechanism, but you'd
have to add pseudo-dependencies on the classpath and name the
libraries accordingly.[2]

That's the best of the approaches that Ron and I considered.
I'm hoping someone will contribute to the sample code repository
a concrete implementation of a command-line rewriter and
instructions for setting up Tomcat and one's projects.

Thanks -
Wes

P.S. - Some afterthoughts...

[1] The component is any public class that has a public
no-argument constructor and implements ICommandEditor:
---
package org.aspectj.tools.ant.taskdefs;

public interface ICommandEditor {
    String[] editCommand(String[] command);
}
---

Specify the fully-qualified class name to the iajc task:

  commandEditorClass="fully.qualified.Classname"

This attribute is not otherwise documented. (*sigh*)

[2]  One caveat here: ajc does not copy resources from
source directories, but in 1.1.1 it does copy resources from
input jars.  To copy resources from any -sourceroots,
use iajc's sourcerootsCopyFilter attribute.

[3] There's a FAQ entry on point - somewhat dated, but
mostly correct:

http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/faq.html#q:aspectjandj2ee

[4] MyEclipse is having a member contest, where they give
away cash or MyEclipse subscriptions for the best tutorials for
using MyEclipse.  Someone might want to do a tutorial on using
AJDT to develop a J2EE application in MyEclipse.  For more
information, see

http://www.myeclipseide.com/index.php?module=ContentExpress&func=display&ceid=26

For a MyEclipse discussion on AspectJ compatibility, see

http://myeclipseide.com/index.php?name=PNphpBB2&file=viewtopic&p=2800#2800


Cyrill Rüttimann wrote:

Hello,

I attended today a presentation about Servlets and JSP's after I presented my exam where I used AspectJ. Since Servlets and JSP's are the next technologies I like to look at; Are there any experiences in developing JSP's with AJC? Is it possible to develop JSP's and compile them with AJC inside Tomcat?

Any insight 's are welcome.


Regards,

Cyrill

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users




Back to the top