Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Use of aop.xml

I'll chip in on some of these - hopefully other users can offer you
additional information based on their experiences.

2009/4/7 Sudhar <sudhar.suba@xxxxxxxxx>:
> - Should I define all point cuts in a single abstract Aspect and have
> different concrete aspect with defined point cut and package name to be
> included? Or Should I build each point cut as a separate abstract Aspect? Is
> there a preference in one way or other?

I would say there is no requirement from the weaver forced on you
here.  Do whatever feels right in your setup.  Don't feel forced into
artificially grouping pointcuts together.

> - I can implement the available join points like method entry, exception
> handling etc., but how do I implement a particular object value logging
> functionality. Lets say if the client wants to print the hashmap value deep
> inside some methods, how do we do this?

Sometimes the code you are advising may need a refactoring to expose
suitable join points - maybe an 'extract method' refactoring to create
a method execution join point suitable for tracing.  Sometimes it is
also not necessary for the codebase to be entirely unaware of the
tracing infrastructure and so a trace call can be put directly into
the code (whilst leaving all the 'boring' trace like entry/exit to be
handled by the aspect).

> - Is there any performance bench mark study with LTW?

I can't think of one.  I do recall a paper on comparing tracing via
aspects with 'hand written' tracing - but that was using compile time
weaving and just measuring the runtime differences (so not looking at
startup time impact due to weaving at load time).  Also the paper I
vaguely recall is from years ago, so a little out of date.  The key
measure for tracing is, I think, the cost when it is switched off.  As
you are weaving at load time it should be free when switched off - but
you are paying a cost at startup for matching (and maybe or maybe not
weaving).  So make sure you are writing pointcuts that can be matched
quickly.  Always try and use within() clauses to scope where the
pointcut should try matching.

At runtime the impact (when the aspect is woven in) is always intended
to be close to what it would be if you implemented the feature by hand
in the codebase.  Any large variation is either due to a problem in
the aspect or a bug.

> - How do I exclude a point cut completely in LTW (concrete aspect definition
> in aop.xml)

You should be able to define it as empty in the XML "" (which matches
nothing) - or use "if(false)".

> - What is the use of weaver tag definition (exclude and include attributes)
> in aop.xml if we can filter everything thru concrete-aspect?

If your aspect does not use abstract pointcuts, the include/exclude
tags provide a way to scope the effect of the aspect.

>
> Thanks and appreciate your time and help,
> - Sudharsan.
>
>
>
> On Wed, Apr 1, 2009 at 1:13 PM, Andy Clement <andrew.clement@xxxxxxxxx>
> wrote:
>>
>> Hi,
>>
>> Did you see the documentation here?
>>
>>
>> http://www.eclipse.org/aspectj/doc/released/devguide/ltw-configuration.html
>>
>> The solution for you would appear to be leave the aspects partially
>> abstract in the traceAspect then concretize the pointcuts in the XML
>>
>> abstract aspect AbstractTraceAspect {
>>   abstract pointcut scopeForPointcutOne();
>>   pointcut traceOne(): execution(* *(..)) && scopeForPointcutOne();
>>
>>   abstract pointcut scopeForPointcutTwo();
>>   pointcut traceTwo(): execution(* *(..)) && scopeForPointcutTwo();
>> }
>>
>>   <aspectj>
>>     <aspects>
>>        <concrete-aspect name="Concrete"
>> extends="mypack.AbstractTraceAspect">
>>
>>
>>          <pointcut name="scopeForPointcutOne"
>> expression="within(com.util.services..*)"/>
>>          <pointcut name="scopeForPointcutTwo"
>> expression="within(com.all.services..*)"/>
>>
>>
>>        </concrete-aspect>
>>     <aspects>
>>   </aspectj>
>>
>> Andy.
>>
>> 2009/4/1 Sudhar <sudhar.suba@xxxxxxxxx>
>>>
>>> I am trying to use AspectJ as the standard framework for logging and
>>> tracing for my J2EE application. After going thru some of the tutorials and
>>> AspectJ project side, I have identified about 15 pointcust and implemented
>>> them in a single aspect class.
>>> But I want these pointcuts to be consumed by the client based on their
>>> package or class name pattern and found out that aop.xml offer this load
>>> time weaving functionality. But I couldn't succeed in getting it work and
>>> also I don't see much documentation on how to get this working.
>>> This is what I have
>>>   Aspect called TraceAspect contains 15 pointcuts with log4J api to log
>>> those point cuts execution.
>>>
>>> Need to have a configurable xml file to selectively specify pointcut to
>>> specific class or package pattern.
>>> Ii.e)  pointcut A should be applied to com.util.services.*
>>>        pointcut B should be applied to com.all.services.*
>>> etc..
>>>
>>> Thanks and greatly appreciate time and effort in answering this,
>>> - Sudharsan.
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> aspectj-users mailing list
>>> aspectj-users@xxxxxxxxxxx
>>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>>
>>
>>
>> _______________________________________________
>> aspectj-users mailing list
>> aspectj-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>


Back to the top