Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] How to crosscut a servlet generated by a jsp ?

Hi all,

My objective is intercept the executions of a init() method of a JSP. but I am not getting.

  I am doing the following:

1) I pre-compile my jsps with the build.xml attached. The pre-compiled files (*_jsp.java) are put in tomcat_home/work......./.././../org/apache/jsp/gui, But the source files are in another place : "tomcat_home/webapps/abacoV6/gui.

 2) I put a init() method inside of my JSP and it is executed. For example:

<%!

         public void init()
	{
	        System.out.println ("This method was executed");
	}

   %>

 3) I am defining the following pointcut, but it is not working:

          pointcut point() : execution (* org.apache.jsp.gui.*.init()) ;


4) Another information that can be helpfull is that when I type the way, the only packages that appear are org and apache. The packages jsp, gui don´t appear. I am using the JBuilder 7.

  5) The classes and servlets of my application are in another directory.


6) I dont know what is happen, but it would be because of I am compiing them separately ?


Thanks in advance


Valter Camargo






--------------------------------------------------------*
Valter Vieira de Camargo
PhD candidate in Computer Science
LABES: Software Engineering Laboratory
USP - University of São Paulo (16)273-9375
São Carlos, SP - Brazil
HomePage: www.icmc.usp.br/~valter/
ICQ: 36325821
-------------------------------------------------------*





From: Jordi alvarez Canal <jalvarezc@xxxxxxx>
Reply-To: aspectj-users@xxxxxxxxxxx
To: "valtercamargo@xxxxxxxxxxx" <valtercamargo@xxxxxxxxxxx>,"aspectj-users@xxxxxxxxxxx" <aspectj-users@xxxxxxxxxxx>
Subject: RE: [aspectj-users] how to do Tomcat 5.0.12 do the ajc compiler ?
Date: Thu, 13 May 2004 16:06:31 +0200

Hi Valter, we have done that for Tomcat 4.1. What we have done is
to modify Tomcat 4.1 code in order to properly use AspectJ Ant
tasks.

I have not looked into Tomcat 5, and I do not know wether it is
necessary or not to go into Tomcat code (I am not sure about that).

Maybe I am wrong, but I think that the problem with your
modifications is that: AspectJ compiler produces the same result
as the Java compiler does, because it only receives as input the
Java file corresponding to the .jsp servlet.

I guess you need to tell to the executed ant task which aspects
you want to compile/weave with the servlet java file. One
possibility that could work fine is to define your own Ant task
extending the AspectJ Ant task. With this extension you could try
to fill these gaps and set the appropiate parameters for the
extended Ant task (I do not know if this would work for your
situation... but you can try/evaluate it).

greetings,
Jordi

:Hi All,
:
:
:   I am working with aspect-development to Web, thus I need
:to do the Tomcat
:5 use the ajc compiler....
:  I have modified the web.xml file the way showed below.
:After this, I
:copied the aspectjtools.jar to the common/lib directory and
:the
:aspectjrt.jar to jakarta-tomcat/bin. However, it´s not
:working.... I think
:that Tomcat is still using javac.
:
:  Somebody knows what´s wrong ?
:
:  <servlet>
:        <servlet-name>jsp</servlet-name>
:          ...
:                <init-param>
:                      <param-name>compiler</param-name>
:
:<param-value>org.aspectj.tools.ant.taskdefs.Ajc11CompilerAd
:apter</param-value>
:              </init-param>
:
:        <init-param>
:          ...
:        </init-param>
:
:	  <load-on-startup>3</load-on-startup>
:    </servlet>
:
:
:Thanks in advance,
:
:
:
:Valter Camargo
:
:
:
:
:>From: André Dantas Rocha <ad-rocha@xxxxxxxxxx>
:>Reply-To: aspectj-users@xxxxxxxxxxx
:>To: <aspectj-users@xxxxxxxxxxx>
:>Subject: RES: [aspectj-users] AspectJ 1.2 release
:candidate 2 now
:>available.
:>Date: Thu, 13 May 2004 09:42:16 -0300
:>
:>I'm currently using AJDT 1.1.8 and AspectJ 1.2rc1. How do
:I install the new
:>AspectJ version (1.2rc2) for use with AJDT/eclipse?
:>
:>Thanks
:>
:>-----Mensagem original-----
:>De: aspectj-users-admin@xxxxxxxxxxx
:>[mailto:aspectj-users-admin@xxxxxxxxxxx]
:>Em nome de Adrian Colyer
:>Enviada em: quinta-feira, 13 de maio de 2004 05:44
:>Para: aspectj-users@xxxxxxxxxxx;
:aspectj-announce@xxxxxxxxxxx
:>Cc: aspectj-dev@xxxxxxxxxxx
:>Assunto: [aspectj-users] AspectJ 1.2 release candidate 2
:now available.
:>
:>We are pleased to announce that the second release
:candidate for
:>AspectJ-1.2 is now available from the download page at
:>http://eclipse.org/aspectj or directly from
:>http://download.eclipse.org/technology/ajdt/aspectj-1.2rc2
:.jar
:>
:>We hope to release 1.2 shortly. As ever, please upgrade
:any old 1.1.1 or
:>1.2rc1 projects and help us flush out any remaining bugs
:before the final
:>release.
:>
:>The definition of the AspectJ language is unchanged in the
:1.2 release.
:>Instead, AspectJ 1.2 provides major improvements to the
:functionality of
:>the
:>supporting tools. Compilation times are greatly reduced,
:error messages
:>have
:>been improved, incremental compilation support is
:extended, and the ajdoc
:>tool is back. Detailed release notes for all these updates
:and more are
:>available at:
:>
:>http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/as
:pectj-home/doc/REA
:>DME-12.html
:>
:>
:>The biggest change since 1.2rc1 has been the provision of
:a new cflow
:>implementation that exploits ThreadLocals on JVMs that
:support them. This
:>results in a performance boost and memory usage reduction
:for heavily
:>threaded programs making use of cflow.
:>
:>Patches and contributions were submitted by George Harley,
:Matthew Webster,
:>Martin Lippert, and Arno Schmidmeier. We are always very
:grateful for these
:>contributions that help improve the compiler and
:supporting tools.
:>
:>Easy to reproduce bugs were submitted by Nicholas
:Lesiecki, Ramnivas
:>Laddad,
:>Ron Bodkin, Sian Whiting, Eric Bodden, Mariano Ceccato,
:Antti Karanta, Umit
:>Vardar, Nick Brett, Miguel Monteiro, Rafael Chaves, Eric
:Jain, Arno
:>Schmidmeier, Attila Lendvai, Daniel McAllansmith, Laurie
:Hendren and Oege
:>De
:>Moor.  We recognize the difficulty of producing clear
:minimal test cases
:>from bugs found in large systems and appreciate the work
:that goes into
:>these reports.
:>
:>We appreciate your help in squashing any bugs in this
:release before 1.2.0
:>(please also try out the new ajdoc on your projects).  If
:you find any
:>bugs,
:>please submit a reproducible test case to
:http://dev.eclipse.org (-> Bug
:>Reports) (product AspectJ, component Compiler).
:>
:>Thanks and stay in touch,
:>The AspectJ Team
:>_______________________________________________
:>aspectj-users mailing list
:>aspectj-users@xxxxxxxxxxx
:>http://dev.eclipse.org/mailman/listinfo/aspectj-users
:>_______________________________________________
:>aspectj-users mailing list
:>aspectj-users@xxxxxxxxxxx
:>http://dev.eclipse.org/mailman/listinfo/aspectj-users
:>
:>_______________________________________________
:>aspectj-users mailing list
:>aspectj-users@xxxxxxxxxxx
:>http://dev.eclipse.org/mailman/listinfo/aspectj-users
:
:___________________________________________________________
:______
:MSN Hotmail, o maior webmail do Brasil.
:http://www.hotmail.com
:
:_______________________________________________
:aspectj-users mailing list
:aspectj-users@xxxxxxxxxxx
:http://dev.eclipse.org/mailman/listinfo/aspectj-users

_________________________________________________________________
MSN Messenger: converse com os seus amigos online. http://messenger.msn.com.br
<project name="Precompile Tomcat JSPs" default="all" basedir="."> 

    <target name="all" depends="jspc,compile,move"/>

    <target name="info">

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

</echo>

  </target>
    
  <target name="init"> 
    <!-- declare these two on command-line -->
    <property 
        name="webapp.name"
        value="abacoV6" />
        
    <property 
        name="tomcat.home"
        location="C:\jakarta-tomcat-5.0.12" />
    
    <property 
        name="webapp.path"
        location="${tomcat.home}\webapps\${webapp.name}" />

    <property 
        name="webapp.src.dir"
        location="${tomcat.home}\webapps\${webapp.name}\gui"/>

    <property name="ASPECTJ_HOME"
        location="c:\aspectj1.2" />
    
  </target>
    
  <target name="jspc" depends="init"> 

    <taskdef classname="org.apache.jasper.JspC" name="jasper2" > 
      <classpath id="jspc.classpath"> 
        <pathelement location="${tomcat.home}/common/lib/jasper-compiler.jar"/> 
        <pathelement location="${tomcat.home}/bin/commons-logging-api.jar"/> 

        <fileset dir="${tomcat.home}/server/lib"> 
          <include name="*.jar"/> 
        </fileset> 
        <fileset dir="${tomcat.home}/common/lib"> 
          <include name="*.jar"/> 
        </fileset> 
      </classpath> 
    </taskdef> 

    <jasper2 
         validateXml="true" 
         uriroot="${tomcat.home}\webapps\${webapp.name}\gui" 
         webXmlFragment="c:\dest\generated_web.xml" 
         outputDir="${tomcat.home}\work\Catalina\localhost\${webapp.name}" /> 


  </target> 

  <target name="compile" depends="init">

  <path id="iajc.classpath"> 

        <fileset dir="${ASPECTJ_HOME}/lib"> 
           <include name="aspectjtools.jar"/> 
        </fileset> 

    </path> 

    <taskdef 

        resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
    
       <classpath refid="iajc.classpath"/> 
    
    </taskdef> 

    <!-- forking compile so it runs in Eclipse -->

    <iajc destdir="${tomcat.home}\work\Catalina\localhost\${webapp.name}"
           sourceroots="${webapp.src.dir}"
           debug="on" 
           verbose="true"
           fork="true" 
           forkclasspathRef="iajc.classpath"
           failonerror="true"
           >
      <classpath>
        <pathelement location="${tomcat.home}\webapp\${webapp.name}\WEB-INF\lib"/>

        <fileset dir="${basedir}">
          <include name="*.jar"/>
        </fileset>
        <pathelement location="${tomcat.home}/common/classes"/>
        <fileset dir="${tomcat.home}/common/lib">
          <include name="*.jar"/>
        </fileset>
        <pathelement location="${tomcat.home}/shared/classes"/>
        <fileset dir="${tomcat.home}/shared/lib">
          <include name="*.jar"/>
        </fileset>
      </classpath>
    </iajc>

  </target>

  <target name="move">
     <move todir="${tomcat.home}\work\Catalina\localhost\${webapp.name}\org\apache\jsp\gui"> 
              <fileset dir="${tomcat.home}\work\Catalina\localhost\${webapp.name}\org\apache\jsp"> 
			<include name="**/*.java"/>
 		  </fileset>
     </move> 
  </target>

</project>


Back to the top