You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Maczka Michal <mi...@imtf.ch> on 2005/07/29 11:47:02 UTC

m2 and aspectj

Hey!
 
Are there any official plans to create an aspectj plugin for m2?
 
What's special and not clear for me about aspectj is:
 
- there can be jars which contain  aspects - do we need another types/scopes
for them distinguishing them from ordinary jars? 
   if yes what values of those attributes should be actually used and how
new types/scopes can be registered.
 
- aspects can be applied at the build time and what's going to be officially
supported in aspectj 5 at the runtime (load-time weaving).  How to
distinguish those two case at the level of dependencies?  Can build time and
load-time weaving  be used for the same application - e.g. some aspects
applied at the build time some at the runtime?
 
Just to have something more concrete - my particular use case is:
 
I have an existing web application (war).  I want to  weave some aspects
into some jars (not all of them) 
which are used in that application. 
I have really no clue how it can be done in a proper way in m2.  
Is there anything done already to enabled this or a general vision how this
use case can be implemented in a correct way?
Any pointers where to start?
 
 
regards
 
Michal

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: m2 and aspectj

Posted by Michal Maczka <mm...@interia.pl>.
Hey Jason!


Jason van Zyl wrote:

>On Fri, 2005-07-29 at 11:47 +0200, Maczka Michal wrote:
>  
>
>>Hey!
>> 
>>Are there any official plans to create an aspectj plugin for m2?
>>    
>>
>
>The definitive list we have created is here:
>
>http://docs.codehaus.org/display/MAVEN/Maven+Plugin+Matrix
>
>It appears no one has stepped up for the AspectJ plugin yet for m2.
>  
>

I see. I was just hoping that somebody actually already did it :(

> 
>  
>
>>What's special and not clear for me about aspectj is:
>> 
>>- there can be jars which contain  aspects - do we need another types/scopes
>>for them distinguishing them from ordinary jars? 
>>    
>>
>
>Would they not simply be dependencies utilized by the AJ compiler?
>
>  
>
Hmm. I am not sure if this can be still called a compilation.

What I want to do is to make this mix of apects and jars  at the 
application level (war).
There I have no java sources or classes - At the moment I just have a 
selection of jars which I am using and I am not yet using aspectj :)

I suppose that in general case you can have:

<project>

    <!-- jars which won't  be processed by aspectj -->
  
     <!-- jars which will be processed by aspectj at build time-->
       ...
     <!-- jars which will be processed by aspectj at run time-->
      ...
     <!--aspects applied at build time-->
     ....
     <!--aspects applied at run time-->
      ....
</project>

I also don't have yet any experience with load time weaving and I don't 
know yet if this is a good idea or not , but I suppose
that the following simplfication of the problem would be sufficent for 
me (this is already supported by aspectj 1.2):

<project>
    <!-- jars which won't  be processed by aspectj -->
       ...
    <!-- jars which will be processed by aspectj at build time-->
       ...
      ...
     <!--aspects applied at the build time-->
     ....

</project>


>>   if yes what values of those attributes should be actually used and how
>>new types/scopes can be registered.
>>    
>>
>
>I'm not sure yet if we would need them.
>
>  
>
Me neither.  That's why I thought that it might be benefical for me to 
ask this question here :)
It just seems to me that in case of jars with aspects the assumption 
that compile time dependecy is a runtime dependency is not really working.
But I might be wrong.


>>- aspects can be applied at the build time and what's going to be officially
>>supported in aspectj 5 at the runtime (load-time weaving).  
>>    
>>
>
>I think another case to deal with is if people want to use the AJ
>compiler directly, or to compile their classes with the standard
>compiler and then weave aspects into the resulting bytecode. So one case
>would be changing the compiler to be used and in the other you would
>configure the AJ weaver in the process-classes phase. I not sure if the
>second option could work in all cases but that might make selectively
>using aspects easier.
>  
>
Sure. In that simple case there is no big conceptual diffrence between 
say jpox and aspectj. The only differnce is that aspectj
can can use artefacts which are provided in poms and for jpox this 
"list" is somehow "hardcoded".

>  
>
>>How to
>>distinguish those two case at the level of dependencies?  Can build time and
>>load-time weaving  be used for the same application - e.g. some aspects
>>applied at the build time some at the runtime?
>>    
>>
>
>As Maven deals with the build part of things I'm not sure how or why we
>would deal with runtime weaving. If you would like to use some aspects
>at runtime maybe that would be a separate project that just built
>aspects that you could package with your application. I'm not very
>familiar with AJ's new runtime weaving capabilities so I'm not sure
>either how best Maven fits in there.
>  
>
In fact what I am willing to is to create m2 tomcat runtime builder. I have one ready for m1.
(there was unaswered question regarding this subject last week).
At the level of runtime builer I would probably wish to make a choice what is going to happen
with an artefact by looking at its type and scope. 
Say if arefact has a type <type>ajr-runtime</type> I would know that I have to copy it to say ./common/lib-aspects/..
But really load time weaving is not that importand for me at the moment - just wanted to show a "big picture".


>>Just to have something more concrete - my particular use case is:
>> 
>>I have an existing web application (war).  I want to  weave some aspects
>>into some jars (not all of them) 
>>which are used in that application. 
>>I have really no clue how it can be done in a proper way in m2.  
>>Is there anything done already to enabled this or a general vision how this
>>use case can be implemented in a correct way?
>>Any pointers where to start?
>>    
>>
>
>Scenerio #1
>
>1/ Create an AJ compiler Mojo and build your aspects in a separate
>project and create an artifact that contains your aspects.
>
>  
>
That's easy:)! Just a natural question which can be rised here is: what 
type should be used for such artiafcts?
I don't know if there exists something like ajr (Aspect J aRchive)... 
and if this is a good idea to have something like that.
Don't you feel that it would be benefical to distunguish jars with 
aspects from ordinary jars?


>2/ Create an AJ Mojo that hooks into the process-classes phase where you
>can weave those aspects into your compiled classes.
>
>  
>
I don't know how it might work for wars.

Again - I have _no java source files  _ in war projects - so I have no 
classes available. I just use jars. 
In case I would define those jars as normal dependencies in my pom - war 
plugin would pick them up
and copy them to WEB-INF/lib folder.  I can use some made up type which 
is grasped by aspectj plugin
but not understood by war which won't process arefacts of that type 
Other possiblity would be to let war plugin to do its job
and then do something with jars inWEB-INF/lib folder.
Other option would be to work with wars which are taken from the 
repository  - for me that option is not
that bAd as I am planning to do this anyway with my tomcat runtime builder.

>You might want to do this all in one project though, but at any rate I
>think you'll need to make a start at creating some AJ Mojos. I'm not
>familiar with AJ 5 so I'm not much help yet there. I'm interested in the
>AJ plugin but have no time right now. Even if there is a single front-
>end to the AJ processing you might want to make separate mojos for
>different behaviour like compiling the aspects in upfront vs weaving
>aspects into class files.
>
>Carlos might also have some ideas, but that's my cursory take on the
>situation.
>
>  
>
anyway thanks for hints!

Michal

----------------------------------------------------------------------
Najlepszy serwis MOTO w Polsce! >>> http://link.interia.pl/f18a8


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: m2 and aspectj

Posted by Jason van Zyl <ja...@maven.org>.
On Fri, 2005-07-29 at 11:47 +0200, Maczka Michal wrote:
> Hey!
>  
> Are there any official plans to create an aspectj plugin for m2?

The definitive list we have created is here:

http://docs.codehaus.org/display/MAVEN/Maven+Plugin+Matrix

It appears no one has stepped up for the AspectJ plugin yet for m2.
 
> What's special and not clear for me about aspectj is:
>  
> - there can be jars which contain  aspects - do we need another types/scopes
> for them distinguishing them from ordinary jars? 

Would they not simply be dependencies utilized by the AJ compiler?

>    if yes what values of those attributes should be actually used and how
> new types/scopes can be registered.

I'm not sure yet if we would need them.

> - aspects can be applied at the build time and what's going to be officially
> supported in aspectj 5 at the runtime (load-time weaving).  

I think another case to deal with is if people want to use the AJ
compiler directly, or to compile their classes with the standard
compiler and then weave aspects into the resulting bytecode. So one case
would be changing the compiler to be used and in the other you would
configure the AJ weaver in the process-classes phase. I not sure if the
second option could work in all cases but that might make selectively
using aspects easier.

> How to
> distinguish those two case at the level of dependencies?  Can build time and
> load-time weaving  be used for the same application - e.g. some aspects
> applied at the build time some at the runtime?

As Maven deals with the build part of things I'm not sure how or why we
would deal with runtime weaving. If you would like to use some aspects
at runtime maybe that would be a separate project that just built
aspects that you could package with your application. I'm not very
familiar with AJ's new runtime weaving capabilities so I'm not sure
either how best Maven fits in there.

> Just to have something more concrete - my particular use case is:
>  
> I have an existing web application (war).  I want to  weave some aspects
> into some jars (not all of them) 
> which are used in that application. 
> I have really no clue how it can be done in a proper way in m2.  
> Is there anything done already to enabled this or a general vision how this
> use case can be implemented in a correct way?
> Any pointers where to start?

Scenerio #1

1/ Create an AJ compiler Mojo and build your aspects in a separate
project and create an artifact that contains your aspects.

2/ Create an AJ Mojo that hooks into the process-classes phase where you
can weave those aspects into your compiled classes.

You might want to do this all in one project though, but at any rate I
think you'll need to make a start at creating some AJ Mojos. I'm not
familiar with AJ 5 so I'm not much help yet there. I'm interested in the
AJ plugin but have no time right now. Even if there is a single front-
end to the AJ processing you might want to make separate mojos for
different behaviour like compiling the aspects in upfront vs weaving
aspects into class files.

Carlos might also have some ideas, but that's my cursory take on the
situation.

> 
> regards
>  
> Michal
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
-- 
jvz.

Jason van Zyl
jason at maven.org
http://maven.apache.org

happiness is like a butterfly: the more you chase it, the more it will
elude you, but if you turn your attention to other things, it will come
and sit softly on your shoulder ...

 -- Thoreau 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org