Re: [aspectj-users] Re: java.lang.ArrayIndexOutOfBoundsException Error

2008-03-01 Thread Ramnivas Laddad
Terry,

I am quite sure if I understand the question. However, you shouldn't have to
do anything special to have arguments available to the ProceedingJoinPoint
object in an around advice; its getArgs() method will give you an array of
objects at the advised join point.

-Ramnivas

On Sat, Mar 1, 2008 at 1:19 AM, Lau Man Kwong <[EMAIL PROTECTED]>
wrote:

> Hi Eric,
>
> Thanks for your hints.
>
> From the stacktrace, I got the "com.at.aspect.LoggingAspect.log(Unknown
> Source)". That's related to the method of LoggingAspect class "public Object
> log(ProceedingJoinPoint call)". As you mentioned, the proceedingJoinPoint
> may has no value so it shows java.lang.ArrayIndexOutOfBoundsExceptionError.
>
> My question is that does aspectJ provide the argument to the
> ProceedingJoinPoint according to the spring configuration file? If yes, what
> setting that I have set incorrectly in the spring configuration file?
>
> Thanks!!!
>
> Regards,
> Terry
>
>
>
> On 3/1/08, [EMAIL PROTECTED] <
> [EMAIL PROTECTED]> wrote:
> >
> > Send aspectj-users mailing list submissions to
> >aspectj-users@eclipse.org
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > or, via email, send a message with subject or body 'help' to
> >[EMAIL PROTECTED]
> >
> > You can reach the person managing the list at
> >[EMAIL PROTECTED]
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of aspectj-users digest..."
> >
> >
> > Today's Topics:
> >
> >   1. aspect on a java API class ([EMAIL PROTECTED])
> >   2. java.lang.ArrayIndexOutOfBoundsException Error (Lau Man Kwong)
> >   3. Re: java.lang.ArrayIndexOutOfBoundsException Error (Eric Bodden)
> >
> >
> > --
> >
> > Message: 1
> > Date: Fri, 29 Feb 2008 17:59:18 +0100
> > From: [EMAIL PROTECTED]
> > Subject: [aspectj-users] aspect on a java API class
> > To: aspectj-users@eclipse.org
> > Message-ID:
> ><
> > [EMAIL PROTECTED]>
> > Content-Type: text/plain; charset="us-ascii"
> >
> > Hi all,
> >
> > I am (still) trying to put a joinpoint on a java API class :
> > java.math.BigDecimal
> > I try to do it with load time weaving LTW (with a JavaAgent)
> >
> > My aspect is like this :
> > @Aspect
> > public class AppAspect {
> >@After("execution(* java.math.BigDecimal.valueOf(..))")
> >public void afterBigDecimal(JoinPoint jp) {
> >System.out.println("grouik BigDecimal");
> >}
> > }
> >
> > And, because I know it is normally not authorized to do it,
> > I bypass the loading of the BigDecimal of the rt.jar, by bootloading an
> > extracted java.math.BigDecimal.
> > I do it by adding in the JVM parameters
> > -Xbootclasspath/p:"D:\...\target\test-classes\temp"
> > where ...\temp\ contains java\math\BigDecimal.class
> >
> > But when I execute this, the advise is not executed...
> >
> > Is the bypass a good solution ? If yes, why does it not working ? If no,
> > is there another way ?
> >
> > Thanks in advance.
> >
> > Laurent Delaforge
> >
> >
> >
> > ___
> >
> > L'integrite de ce message n'etant pas assuree sur Internet, les societes
> > du groupe Oddo ne peuvent ?tre tenues responsables de son contenu. Ce
> > message et  les eventuels fichiers attaches contiennent des informations
> > confidentielles. Au cas o? il ne vous serait pas destine, nous vous
> > remercions de bien vouloir le supprimer et en aviser l'expediteur.
> >
> > This message and the files that may be attached to it contain
> > confidential information. The Oddo group may not be held responsible for
> > their contents, whose accuracy and completeness cannot be guaranteed over
> > the internet. If the message is not addressed to you, kindly delete it and
> > notify the sender.
> >
> >
> > ___
> > -- next part --
> > An HTML attachment was scrubbed...
> > URL:
> > https://dev.eclipse.org/mailman/private/aspectj-users/attachments/20080229/1bdf3ab4/attachment.html
> >
> > --
> >
> > Message: 2
> > Date: Sat, 1 Mar 2008 01:40:38 +0800
> > From: "Lau Man Kwong" <[EMAIL PROTECTED]>
> > Subject: [aspectj-users] java.lang.ArrayIndexOutOfBoundsException
> >Error
> > To: aspectj 
> > Message-ID:
> ><[EMAIL PROTECTED]>
> > Content-Type: text/plain; charset="iso-8859-1"
> >
> >
> > Hi,
> >
> > I'm new to aspectj. When I do some practice on aspectj, an error "
> > java.lang.ArrayIndexOutOfBoundsException: 0 at
> > com.at.aspect.LoggingAspect.log(Unknown Source)" was encountered. I have
> > searched on internet but get no answer. Can you give me some hints for
> > this
> > error?
> >
> > I am using AspectJ 1.5.4, Spring 2.0 and JDK 5.0 on this project.
> >
> 

Re: [aspectj-users] Type pattern with annotation value checks

2008-03-03 Thread Ramnivas Laddad
Check out the very latest AspectJ 1.6.0m2 (
http://www.eclipse.org/aspectj/doc/released/README-160.html). The annotation
value feature might just do the trick for you.

-Ramnivas

On Sun, Mar 2, 2008 at 6:05 PM, Vladimir Tsukur aka _flush_dia_ <
[EMAIL PROTECTED]> wrote:

> Hello,
>
> May the type pattern declare a check for annotation value?
>
> Let's say we have following class definitions:
>
> @SupportsVersioning(isRoot = true)
> public class Configuration {
> ...
> }
>
> @SupportsVersioning(isRoot = false)
> public class Setting {
> ...
> }
>
> And *declare parents* statement must be applied for classes which are
> annotated with @SupportVersioning annotation having isRoot = true, but not
> for those which have the value of isRoot set to false.
> Is there a way to achieve this?
>
> It seems like presence of annotation may be analysed, but not its values,
> but I may be wrong.
> If there is no workaround for this problem I'll create two distinct
> parameterless annotations: one for roots and another one for non-roots.
>
> Thank you in advance.
> --
> Yours faithfully,
> Tsukur Vladimir aka _flush_dia_
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: re[aspectj-users] trieve method name from the joinPoint

2008-03-21 Thread Ramnivas Laddad
I think you will want to use thisJoinPoint.getSignature().getName(). There
is another object thisJoinPointEnclosingPart, but it won't give any new
information as yours is a method execution join point.

-Ramnivas

On Fri, Mar 21, 2008 at 10:07 AM, joss33 <[EMAIL PROTECTED]>
wrote:

>
> Hi all,
>
> Here is my code :
>
> pointcut oneCachedCall(int x):
>execution(long *(int))
>&& args(x);
>
> long around(int x) : oneCachedCall(x) {
>System.out.println(theSurroundedMethod); // of course
> theSurroundedMethod should be replaced by something else
>return proceed(x);
> }
>
> I wanted to know whether it is possible to retrieve the method, which will
> be woven, from the "around's body" or not.
>
> thanks in advance.
> --
> View this message in context:
> http://www.nabble.com/retrieve-method-name-from-the-joinPoint-tp16197930p16197930.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] type of around formal parameters

2008-03-24 Thread Ramnivas Laddad
How about

((CodeSignature)thisJoinPoint.getSignature()).getParameterTypes()?

-Ramnivas

On Mon, Mar 24, 2008 at 1:59 PM, joss <[EMAIL PROTECTED]>
wrote:

> Hi all,
>
> Do you know whether it is possible to recuperate the types of around's
> formal parameters in its own body or not ?
>
> example :
>
> long around(int x) {
> Object[] objs = thisJoinPoint.getArgs();
> Class[] types = new Class[objs.length];
>
> for(int i=0; itypes[i] = objsi[i].getClass(); // works only for the Class and not
> for the primitive types (like int here)
> }
>
> Thanks in advance.
>
> Jonathan Clairembault
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] overlapping pointcuts and a compiler bug

2008-04-02 Thread Ramnivas Laddad
There isn't a way to decide precedence during runtime.

I suppose you can have advice logic check for some condition to call
appropriate code based on some runtime state.

-Ramnivas

On Wed, Apr 2, 2008 at 3:58 AM, chris colombo <[EMAIL PROTECTED]> wrote:

> I restarted eclipse and everything worked fine...
>
> however i still have this question:
>
> if i have the following two advises:
>
> before(): (execution (* *.*())){} before(): (execution (* *.atest())){}
>
> can i somehow decide their precedence during runtime?
>
>
>
> - Original Message 
> From: Andy Clement <[EMAIL PROTECTED]>
> To: aspectj-users@eclipse.org
> Sent: Tuesday, April 1, 2008 7:51:21 AM
> Subject: Re: [aspectj-users] overlapping pointcuts and a compiler bug
>
> Any npe is a compiler bug - please open a bug report for it
>
> Andy.
>
> On 28/03/2008, chris colombo <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> > I am building a tool for runtime verification using AspectJ and I am
> > exploring the precedence between two pointcuts as follows: pointcut
> one():
> > (execution (* *.*())); pointcut two(): (execution (* *.atest()));
> ...ideally
> > I would like to know how many pointcuts are triggered for a single
> joinpoint
> > so that I can process them "concurrently" and decide the priority
> > dynamically...
> >
> > However, the AspectJ compiler returned the following exception:
> >
> > java.lang.NullPointerException
> > at
> > org.aspectj.weaver.ReferenceType.isAspect(ReferenceType.java:159)
> > at
> >
> org.aspectj.ajdt.internal.core.builder.AjBuildManager$4.addAspectName(AjBuildManager.java:1100)
> > at
> >
> org.aspectj.ajdt.internal.core.builder.AjBuildManager$4.acceptResult(AjBuildManager.java:1039)
> > at
> >
> org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.acceptResult(AjPipeliningCompilerAdapter.java:405)
> > at org.aspectj.ajdt.intern ... lugin$7.run(DebugUIPlugin.java:1102)
> > at
> > org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
> > Compile error: NullPointerException thrown: null
> >
> > The CODE:
> >
> >pointcut one(): (execution (* *.*()));
> >
> >pointcut two(): (execution (* *.atest()));
> >
> >before():one()
> >{
> >System.out.println("Before One");
> >}
> >
> >after():one()
> >{
> >System.out.println("After One");
> >}
> >
> >before():two()
> >{
> >System.out.println("Before Two");
> >}
> >
> >after():two()
> >{
> >System.out.println("After Two");
> >}
> >
> >  
> > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try
> it
> > now.
> > ___
> >  aspectj-users mailing list
> >  aspectj-users@eclipse.org
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
> --
> You rock. That's why Blockbuster's offering you one month of Blockbuster
> Total 
> Access,
> No Cost.
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Newbie -- Syntax error with field get/set pointcut

2008-04-25 Thread Ramnivas Laddad
Change your set pointcut to:

pointcut setMessage(String m) : set(String HelloWorld.message) && args(m);

-Ramnivas

On Fri, Apr 25, 2008 at 1:56 PM, kkraft <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I am using AspectJ in Eclipse with the AJDT plug-in.
>
> I have a basic HelloWorld.java class with a String attribute called
> "message". I was able to define a working execution pointcut on
> getMessage(), but when I attempt to define a get or set pointcut on the
> message field Eclipse reports a syntax error:
>
>Syntax error on token ";", invalid allowable token in pointcut or type
> pattern
>
> Here are my attempts at defining the get/set pointcuts::
>
>pointcut getMessage() : get(String HelloWorld.message);
>pointcut setMessage(String m) : set(String HelloWorld.message);
>
> I have tried all kinds of signatures inside the get/set calls, e.g. "String
> message", "* message", "String *", but I always get the syntax error. One
> other odd note it that the syntax error always appears at the end of the
> last pointcut (e.g. "setMessage()", in the above case). Also, the error
> only
> appears when I try to reference the pointcut in advice.
>
> Can anybody tell me what's going on here?
>
> Many thanks,
>
> Kevin
> --
> View this message in context:
> http://www.nabble.com/NewbieSyntax-error-with-field-get-set-pointcut-tp16898496p16898496.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Type patterns in "within" with class qualifiers

2008-05-16 Thread Ramnivas Laddad
Type patterns are not allowed to be qualified with modifiers in any
pointcut, not just within().

-Ramnivas

2008/5/15 Manuel Menezes de Sequeira <[EMAIL PROTECTED]>:

>  Hi all,
>
> Apparently it is not possible to write
>
> within(abstract *)
>
> or
>
> within(final *)
>
> Why?
>
> Thanks a lot,
>
> Manuel
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Type patterns in "within" with class qualifiers

2008-05-28 Thread Ramnivas Laddad
I don't think there is any reason. It may be just due to lack of good use
case to justify adding this feature.

-Ramnivas

On Wed, May 28, 2008 at 9:09 AM, Eric Bodden <[EMAIL PROTECTED]>
wrote:

> 2008/5/16 Ramnivas Laddad <[EMAIL PROTECTED]>:
> > Type patterns are not allowed to be qualified with modifiers in any
> > pointcut, not just within().
>
> Interesting. Is there a reason for this?
>
> Eric
> --
> Eric Bodden
> Sable Research Group
> McGill University, Montréal, Canada
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Integration of tracing aspect and Tomcat 5.5

2008-06-08 Thread Ramnivas Laddad
Hi,

Setting up LTW may be the best way to approach. There isn't much
Tomcat-specific setup involved, so that may be the reason for lack of
examples.
Just to outline, all you need to do:
- Create and compile aspects that you need to weave.
- Create a jar file that includes
  -- the aspects
  -- an aop.xml file listing that aspect (see AspectJ guide for the syntax)
2. Add -javaagent:path/to/aspectjweaver.jar to Tomcat's command line. I add
the following to startup.bat:
set ASPECTJ_WEAVING=-javaagent:%SPRING_HOME%\lib\aspectj\aspectjweaver.jar
set JAVA_OPTS=%ASPECTJ_WEAVING%

-Ramnivas

On Sat, Jun 7, 2008 at 11:57 AM, Jean-Louis.Pasturel <
[EMAIL PROTECTED]> wrote:

> It is certainly better to look first the trace of verbose GC of the JVM or
> the heapdump/ javacore if the JVM crashes .
> Tyler DeWitt a écrit :
>
>  Hello all,
>>   I'm new to AspectJ and Tomcat.  I'm working at a company that sells a
>> product which runs Tomcat 5.5 and runs approximately 20 servlets.   I need
>> to monitor cpu usage and memory usage of those servlets because they
>> occasionally crash and we want to know what servlet is crashing (instead of
>> just telling us that Tomcat is crashing).  I cannot recompile the servlets.
>>   Is there a way that I could do load-time weaving on the servlets?  Another
>> option would be to do load time weaving on Tomcat and then trace the threads
>> (servlets) as they are created.  Is it possible to do load time weaving on
>> Tomcat.  I've looked around, but so far have only run across outdated
>> examples or examples that I don't get.
>>
>> Thanks for the help!
>> Tyler
>>
>>
>> 
>>
>> ___
>> aspectj-users mailing list
>> aspectj-users@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Integration of tracing aspect and Tomcat 5.5

2008-06-09 Thread Ramnivas Laddad
I don't think you should be calling either aj or aj5. Instead, supply
-javaagent argument to Tomcat as I mentioned.

You will will META-INF/aop.xml on either Tomcat's common classpath (i.e. in
a jar in TOMCAT_HOME/lib directory) or your webapps (i.e in a jar in
TOMCAT_HOME/webapp/your-app/lib or direct text file in
TOMCAT_HOME/webapp/your-app/classes directory).

-Ramnivas

On Mon, Jun 9, 2008 at 1:38 PM, Tyler DeWitt <[EMAIL PROTECTED]>
wrote:

> Ramnivas,
>Thanks for the information.  That was the step by step guide I needed.
> My new problem is that I have never been able to make the syntax of the
> -javaagent: work correctly (ie in aj5).  I can call aj and the class gets
> LTW, but if I call aj5 with the same class file no weaving takes place.  Is
> there a difference between the syntax for aj and aj5?  Is the aop.xml
> different?
>
> Thanks for the help!
> Tyler
>
> On Sun, Jun 8, 2008 at 4:12 PM, Ramnivas Laddad <[EMAIL PROTECTED]>
> wrote:
>
>> Hi,
>>
>> Setting up LTW may be the best way to approach. There isn't much
>> Tomcat-specific setup involved, so that may be the reason for lack of
>> examples.
>> Just to outline, all you need to do:
>> - Create and compile aspects that you need to weave.
>> - Create a jar file that includes
>>   -- the aspects
>>   -- an aop.xml file listing that aspect (see AspectJ guide for the
>> syntax)
>> 2. Add -javaagent:path/to/aspectjweaver.jar to Tomcat's command line. I
>> add the following to startup.bat:
>> set ASPECTJ_WEAVING=-javaagent:%SPRING_HOME%\lib\aspectj\aspectjweaver.jar
>> set JAVA_OPTS=%ASPECTJ_WEAVING%
>>
>> -Ramnivas
>>
>>
>> On Sat, Jun 7, 2008 at 11:57 AM, Jean-Louis.Pasturel <
>> [EMAIL PROTECTED]> wrote:
>>
>>> It is certainly better to look first the trace of verbose GC of the JVM
>>> or the heapdump/ javacore if the JVM crashes .
>>> Tyler DeWitt a écrit :
>>>
>>>  Hello all,
>>>>   I'm new to AspectJ and Tomcat.  I'm working at a company that sells a
>>>> product which runs Tomcat 5.5 and runs approximately 20 servlets.   I need
>>>> to monitor cpu usage and memory usage of those servlets because they
>>>> occasionally crash and we want to know what servlet is crashing (instead of
>>>> just telling us that Tomcat is crashing).  I cannot recompile the servlets.
>>>>   Is there a way that I could do load-time weaving on the servlets?  
>>>> Another
>>>> option would be to do load time weaving on Tomcat and then trace the 
>>>> threads
>>>> (servlets) as they are created.  Is it possible to do load time weaving on
>>>> Tomcat.  I've looked around, but so far have only run across outdated
>>>> examples or examples that I don't get.
>>>>
>>>> Thanks for the help!
>>>> Tyler
>>>>
>>>>
>>>> 
>>>>
>>>> ___
>>>> aspectj-users mailing list
>>>> aspectj-users@eclipse.org
>>>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>>>
>>>>
>>>
>>>
>>> ___
>>> aspectj-users mailing list
>>> aspectj-users@eclipse.org
>>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>>
>>
>>
>> ___
>> aspectj-users mailing list
>> aspectj-users@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Pointcut on all fields in all subclasses?

2008-06-27 Thread Ramnivas Laddad
get(* Base+.*)

or

set(* Base+.*)

-Ramnivas

On Fri, Jun 27, 2008 at 12:42 PM, <[EMAIL PROTECTED]> wrote:

> Is there a way to indicate a pointcut on all fields of all subclasses
> of a given class?
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Calling proceed in a method

2008-07-13 Thread Ramnivas Laddad
A possible solution is to use the worker object pattern. It will get you
closer to the desired behavior.

Object around() : somePC() {
Runnable work = new Runnable() {
 public void run() { proceed(); }
}
refactoredMethod(work);
}

void refactoredMethod(Runnable work) {
   ...
   work.run(); // which will end up calling proceed() on the original join
point
   ...
}

-Ramnivas

On Sat, Jul 12, 2008 at 8:16 PM, Andy Clement <[EMAIL PROTECTED]>
wrote:

> Hi Ashley,
>
> ProceedingJoinPoint was only designed for use with annotation style
> advice, to allow the calling of proceed() in a legal java program.  I
> have no test programs that do what you are attempting, so I don't know
> if it'll work or not, but my feeling is that it will not.  Probably if
> it is going to work at all you will need to use annotation style
> around advice as that triggers different weaver paths that may set of
> the ProceedingJoinPoint correctly before you pass it around.
>
> Unfortunately the signature for proceed() on a ProceedingJoinPoint is
> effectively Object... - so if you have problems setting up the
> parameters for the proceed it will likely manifest as a runtime error
> rather than compile time error.
>
> If you think you have a suitable use case and it isn't working, please
> raise a bug for us to discuss/consider what we can do.
>
> Andy.
>
> 2008/7/11 Ashley Williams <[EMAIL PROTECTED]>:
> > Hi,
> >
> > I have two pieces of around advice in my code-style aspect that I would
> like
> > to refactor into an ordinary method in the same aspect. However I'm
> unsure
> > how to make the call to proceed() in this method.
> >
> > Am I supposed to cast thisJointPoint to the annotation-style
> > ProceedingJoinPoint and pass it as a paramter to the refactored method?
> If
> > so, is there a way of invoking its proceed method that would work
> > generically for the different sorts of args and return values in the two
> > pieces of advice that are delegating to it?
> >
> > Many thanks
> > - Ashley
> >
> > ---
> >
> > This e-mail may contain confidential and/or privileged information. If
> you
> > are not the intended recipient (or have received this e-mail in error)
> > please notify the sender immediately and delete this e-mail. Any
> > unauthorized copying, disclosure or distribution of the material in this
> > e-mail is strictly forbidden.
> >
> > Please refer to http://www.db.com/en/content/eu_disclosures.htm for
> > additional EU corporate and regulatory disclosures.
> >
> > ___
> > aspectj-users mailing list
> > aspectj-users@eclipse.org
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] LTW+cflow+after/arround advice

2008-07-24 Thread Ramnivas Laddad
It is a known weaver limitation (there is a bug report with full details).

You will need to add something like: '&& execution(* *(..))' to your
pointcut to select method execution join points (and avoid selecting handler
join points). In any case, your description specifies that you need to
profile method execution so the change will match that while fixing the
problem you see.

-Ramnivas

On Thu, Jul 24, 2008 at 2:58 AM, <[EMAIL PROTECTED]>
wrote:

>  Read :
>
> In line 47, i define an after *advice*.
>
>
>
> Cordialement / Best regards
>
> [EMAIL PROTECTED]
>
>
>   --
>
> *De :* [EMAIL PROTECTED] [mailto:
> [EMAIL PROTECTED] *De la part de*
> [EMAIL PROTECTED]
> *Envoyé :* jeudi 24 juillet 2008 08:43
> *À :* aspectj-users@eclipse.org
> *Objet :* [aspectj-users] LTW+cflow+after/arround advice
>
>
>
> Hi,
>
> I want to catch duration of a method and the duration of the methods in the
> cflow scope of this method.
>
> I use LTW weaving.
>
>
>
> I try it with two kinds of  strategiy for the advice :
>
> - around ( Aspect in issingleton PerClause)
>
> - before+after ( Aspect in percflow PerClause)
>
>
>
> The implementation of the aspect in *aop.xml* looks like this:
>
>  name="iep.perf.aspects.abstractAspects.DurationSimpleMethodWithParentPercflow"
>
>
> extends="iep.perf.aspects.abstractAspects.AbstractDurationSimpleMethodWithParentPercflow"
> >
>
>   
> expression="
>
> cflow(
>
> call(public *
> pcm.metier.refarticles.CmRefArticles.offreORTHorsCatalogue(..))
>
> || call (public *
> pcm.metier.refarticles.CmRefArticles.offreORTStandard(..))
>
> || call (public *
> pcm.metier.commande.CmRechercheBCR.lister(..))
>
> || call (public *
> pcm.metier.codeadv.CodeADV.searchByCodeADV(..))
>
> || call (public *
> pcm.metier.refarticles.CmRefArticles.listerModelesHorsCatal(..))
>
> )" />
>
> 
>
>
>
>
>
> And I got this very explicit error:
>
>
>
> [EMAIL PROTECTED] warning at 
> iep/perf/aspects/abstractAspects/E:\eclipse\workspace\perfStats\src\iep\perf\aspects\abstractAspects\AbstractDurationSimpleMethodWithParentPercflow.aj:47::0
> Only before advice is supported on handler join points (compiler limitation)
>
> [EMAIL PROTECTED] warning at
> org/objectweb/jonas/server/Bootstrap.java:98::0 Only before advice is
> supported on handler join points (compiler limitation)
>
> [EMAIL PROTECTED] warning at
> iep/perf/aspects/abstractAspects/E:\eclipse\workspace\perfStats\src\iep\perf\aspects\abstractAspects\AbstractDurationSimpleMethodWithParentPercflow.aj:47::0
> Only before advice is supported on handler join points (compiler limitation)
>
> [EMAIL PROTECTED] warning at
> org/objectweb/jonas/server/Bootstrap.java:108::0 Only before advice is
> supported on handler join points (compiler limitation)
>
>
>
> In line 47 of the aspect, I define an after pointcut.
>
>
>
> I got the same error with the around advice.
>
>
>
> If my understanding is correct, it means that only before pointcut supports
> cflow pointcut. Am I right?
>
>
>
> With LTW, is there a workaround to track duration of method and duration of
> methods in the cfow scope of the first method?
>
>
>
> Cordialement / Best regards
>
>
>
> *Jean-Louis Pasturel*
>
> [EMAIL PROTECTED]
>
>
>
>
>  *
> This message and any attachments (the "message") are confidential and
> intended solely for the addressees.
> Any unauthorised use or dissemination is prohibited.
> Messages are susceptible to alteration.
> France Telecom Group shall not be liable for the message if altered,
> changed or falsified.
> If you are not the intended addressee of this message, please cancel it
> immediately and inform the sender.
> 
>  *
> This message and any attachments (the "message") are confidential and
> intended solely for the addressees.
> Any unauthorised use or dissemination is prohibited.
> Messages are susceptible to alteration.
> France Telecom Group shall not be liable for the message if altered,
> changed or falsified.
> If you are not the intended addressee of this message, please cancel it
> immediately and inform the sender.
> 
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Bug: Internal error in aspectj

2008-07-25 Thread Ramnivas Laddad
As a first step, you might want to try 1.6.1 (final, you seem to be using
the rc release).

If you still see the problem, it is best to open a bug.

-Ramnivas

On Fri, Jul 25, 2008 at 4:41 PM, 100ji <[EMAIL PROTECTED]> wrote:

> Hi all,
>
> I am instrumenting java.io.PrintWriter.println() call in an EchoClient
> and EchoServer example I downloaded from the internet. When I weave
> aspects: it fails with the error below. I have attached the complete
> directory as an attachment for your reference. This crash is
> intermittent. So, I am not sure if this happens on reweaving an
> already woven file.
>
> providence /u/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3
> % make -f ytrace/Makefile weave_client
> rm -rf
> /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3/ytrace/build/aspects/*
> python /u/suman/exercise/steve_rnr/ytrace/ytrace/python/genAspects.py
>
> /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3/ytrace/conf/echo_ytrace_config.xml
> >
> /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3/ytrace/build/aspects_src/AddTaintVarToThread.aj
> ajc -1.5 -classpath
>
> /u/suman/installs/libs/java/log4j-1.2.15.jar:/u/suman/installs/aspectj1.6//lib/aspectjrt.jar:/home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3:.
> -d
> /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3/ytrace/build/aspects
>
> /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3/ytrace/build/aspects_src/*.*
>
> /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3/ytrace/build/aspects_src/AddTaintVarToThread.aj:31
> [warning] advice defined in AddTaintVarToThread has not been applied
> [Xlint:adviceDidNotMatch]
>
>
> /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3/ytrace/build/aspects_src/YTraceNameThreadAspect.aj:17
> [warning] advice defined in YTraceNameThreadAspect has not been
> applied [Xlint:adviceDidNotMatch]
>
>
> /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3/ytrace/build/aspects_src/AddTaintVarToThread.aj:19
> [warning] advice defined in AddTaintVarToThread has not been applied
> [Xlint:adviceDidNotMatch]
>
>
> /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3/ytrace/build/aspects_src/YTraceNameThreadAspect.aj:8
> [warning] advice defined in YTraceNameThreadAspect has not been
> applied [Xlint:adviceDidNotMatch]
>
>
> 4 warnings
> ajc -1.5  -classpath
>
> /u/suman/installs/libs/java/log4j-1.2.15.jar:/u/suman/installs/aspectj1.6//lib/aspectjrt.jar:/home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3/ytrace/build/aspects:.
>  -aspectpath
> /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3/ytrace/build/aspects
> -inpath /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3
> -d
> /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3/ytrace/build/output/
> ; echo "Add this to classpath:
>
> /u/suman/installs/libs/java/log4j-1.2.15.jar:/u/suman/installs/aspectj1.6//lib/aspectjrt.jar:/home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3/ytrace/build/aspects:/home/suman/exercise/steve_rnr/ytrace/ytrace_examples/echo/echo3/ytrace/build/output"
> ABORT
>
> Exception thrown from AspectJ 1.6.1rc1
>
> This might be logged as a bug already -- find current bugs at
>
> http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&component=Compiler
>
> Bugs for exceptions thrown have titles File:line from the top stack,
> e.g., "SomeFile.java:243"
>
> If you don't find the exception below in a bug, please add a new bug
> at http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ
> To make the bug a priority, please include a test program
> that can reproduce this exception.
> bad WeaverState.Kind: -115.  File was :::0
>
> when batch building BuildConfig[null] #Files=0
> bad WeaverState.Kind: -115.  File was :::0
> java.lang.RuntimeException: bad WeaverState.Kind: -115.  File was
> :::0
>  at org.aspectj.weaver.WeaverStateInfo.read(WeaverStateInfo.java:142)
>  at org.aspectj.weaver.AjAttribute.read(AjAttribute.java:97)
>  at
> org.aspectj.weaver.bcel.BcelAttributes.readAjAttributes(BcelAttributes.java:106)
>  at
> org.aspectj.weaver.bcel.BcelObjectType.ensureAspectJAttributesUnpacked(BcelObjectType.java:333)
>  at
> org.aspectj.weaver.bcel.BcelObjectType.(BcelObjectType.java:151)
>  at
> org.aspectj.weaver.bcel.BcelWorld.buildBcelDelegate(BcelWorld.java:299)
>  at
> org.aspectj.weaver.bcel.BcelWorld.addSourceObjectType(BcelWorld.java:365)
>  at
> org.aspectj.weaver.bcel.BcelWeaver.addClassFile(BcelWeaver.java:433)
>  at
> org.aspectj.weaver.bcel.BcelWeaver.addClassFile(BcelWeaver.java:448)
>  at
> org.aspectj.ajdt.internal.core.builder.AjBuildManager.initBcelWorld(AjBuildManager.java:841)
>  at
> org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:248)
>  at
> org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:184)
>  a

Re: [aspectj-users] Pointcut based on field annotation

2008-08-04 Thread Ramnivas Laddad
It is not currently possible with AspectJ.

One problem with such potential pointcut is difficulty in supporting correct
semantics. For example, consider what should happen in the following cases:

1. item.values.add("foo");   // should this be advised?
2. Collection values = item.values;
...
values.add("foo"); // should this be advised?
3. Collection values = item.values;
operationThatAddsString(values);

...
public void operationThatAddsString(Collection values) {
values.add("foo");   // should this be advised?
}

The problem with 2 and 3 is that it is nearly impossible for the compiler to
figure out that the target object is been a @Weak field in some object. Then
supporting just one doesn't seem right as it won't survive even simple
refactoring as done in 2. Things become more complex if an object is set as
a field of two different objects with different annotations or no annotation
in one case.

-Ramnivas

On Sat, Aug 2, 2008 at 10:17 PM, zeroorone <[EMAIL PROTECTED]> wrote:

>
> I've searched around and looked through the documentation but can't seem to
> find a way to create a pointcut for the following situation.
>
> Is there a way to match any calls when the target of a function call is a
> field/member annotated with a particular annotation? I know this is very
> simple if the type of the field is annotated, as I would just add an
> @target
> pointcut. I have tried to play around with the cflow poincuts, but the
> function call I'd like to advise is not within the cflow of the field
> access, but after.
>
> Here is the situation expressed in code:
>
> public class TestItem {
>   @Weak public Collection values;
>   ...
> }
>
>
> TestItem item = new TestItem(...)
> item.values.add("foo"); // want to advise this function call add
>
>
> // my poor attempts thus far
> 1. after() : call(* *.*(..)) && @annotation(Weak)
> 2. after() : call(* *.*(..)) && @target(Weak) // the type isn't
> annotated, the field is
> 3. after() : cflowbelow(get(@Weak Object+ *.*)) && call(* *.*(..)) //
> the function call is not in the control flow of the field access
>
>
> Is this behavior supported by aspectj in any way? Have I overlooked a
> solution? It seems like another pointcut may be added, like @field(X),
> which
> matches join points where the target is a field/member annotated with X.
>
> Thanks in advance,
> Mike
> --
> View this message in context:
> http://www.nabble.com/Pointcut-based-on-field-annotation-tp18795275p18795275.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Pointcut based on field annotation

2008-08-05 Thread Ramnivas Laddad
It seems that your use case may be implementable with existing AspectJ
construct by keeping a journal of the fields. For example, you could advise
the write access to keep track of @Weak objects:

WeakHashSet weakReferencedCollections = ...

before(Collection obj) : set(@Weak * *) && args(obj) {
weakReferencedCollections .add(obj)
}


before(Collection obj) : call(* Collection.*(..)) && target(obj) {
if (weakReferencedCollections.get(obj) != null) {
...
}
}

Granted, this is not as straightforward. With the above code, you get all
cases implemented correctly. In fact, you may be able to detect if a
reference is shared in an inconsistent manner (@Weak in one place but
regular in others).

-Ramnivas

On Mon, Aug 4, 2008 at 11:29 PM, zeroorone <[EMAIL PROTECTED]> wrote:

>
> Thank you for responding. I definitely understand the semantic gap.
> Probably
> much to your dismay, I do actually want the 1 & 2 cases to be match.
> Explaining the functionality I am trying to accomplish may help you
> understand why I want this type of functional behavior.
>
> I am working on a master's thesis that uses aspectj to invisibly provide a
> memory management system by releasing memory into a persistent data store.
> Adding an annotation like @Weak would cause all field access to be
> monitored. Any set causes the value to be persisted to a database while
> caching a weak reference to the value. This weak reference provides some
> performance improvements as it effectively implements a cache for field
> access (helping with locality of reference). Once all strong references to
> the value are released, I let the garbage collector release the memory that
> would normally be maintained by the field. Further access to the field
> subsequently results in accessing the data from the database (or its
> cache).
>
> As you astutely point out, I am having trouble when the caller of the field
> get uses the reference, either through a subsequent invocation (case 1) or
> through assignment to another variable (case 2). All three cases relate to
> my inability to monitor modifications to the values through references,
> which I currently am able to do only within the context of a field-set.
>
> I understand how this is difficult, if not impossible, to implement with
> aspects. However, it seems to me like this is a behavior that those who are
> using aspectj may desire. In response to your scenarios, I believe one
> could
> implement the following behavior:
>
> // class-level variables
> @Weak
> public Collection values; // annotated
> public Collection referenceValues; // not annotated
>
> // 1, 2 - at compile time this seems plausible and pretty straight-forward
> values.add("foo"); // match
>
> ...
>
> // much more difficult, as the field referenceValues is not annotated;
> // in this case I would expect the pointcut to NOT match because
> // having the compiler understand referential assignment is a bit much
> referenceValues = values;
> referenceValues.add("bar"); // no match
>
> ...
>
> // what about a local variable that is annotated? I believe this would
> match
> // because the variable that has the function add() invoked is specifically
> annotated
>
> @Weak
> Collection refVals = values;
> refVals.add("foobar"); // match
>
> -
>
> // this would even work if the class-level variable was not annotated
> // but the local variable was, like so:
>
> refVals = referenceValues; // assign annotated variable to non-annotated
> class field
> refVals.add("hi"); // match
> referenceValues.add("there"); // no match
> values.add("bob"); // match
>
>
> Although this seems difficult to get right (semantically), it seems within
> reason. It all boils down to compile-time information--the context of the
> function call. I would not expect for the pointcut to understand the
> semantics of references, but it seem plausible to match the pointcut when
> the target happens to be a field/variable annotated as desired. This is why
> I see it as similar to @target, except that instead of saying the target
> class is annotated, the target field/variable is annotated.
>
> However, I do see a limitation to my suggested behavior, function chaining,
> like such:
>
> ((Collection)values.clone()).add("foo")
>
> Given my semantics, the clone() would possibly match (as it is called on a
> field that is annotated) but the add() in this case would not because the
> add function is invoked on another reference, not values. Although rather
> odd, this still seems acceptable semantically.
>
> I'd appreciate any comments or feedback on this idea. Without this type o

Re: [aspectj-users] Aspect Weaving GlassFish and Errors

2008-09-24 Thread Ramnivas Laddad
Indeed, either replace the first '*' with 'public' or remove the first
'*' altogether (reason: constructor pattern should not specify a return
type).
-Ramnivas

On Wed, Sep 24, 2008 at 8:27 AM, Dean Wampler <[EMAIL PROTECTED]>wrote:

> Try replacing the first '*' in each expression with "public". It's probably
> interpreting the '*' as the return type.
>
> On Sep 24, 2008, at 1:30 AM, Jason Weinstein wrote:
>
> Thanks for your reply. I just want to get it working first, before tuning
> the aspects.
>
> Both this
>
> execution(* com.sun.jbi..*+.new(..))
>
> and this
>
> initialization(* com.sun.jbi..*+.new(..))
>
> result in error
>
> Syntax error on token "new", "method name (not constructor)" expected
>
>
> Could i be using the wrong version? I am using 1.6.1
>
> Andrew Eisenberg wrote:
>
> That is quite an aggressive aspect that you have there.  :-)  First,
>
> are you sure that you want to use load time weaving?
>
>
> Yes
>
> It tends to be
>
> more difficult to develop LTW aspects because there is no tooling
>
> support for them (so you don't know if it works until you run your
>
> program).
>
>
> So, you want to trace every single method and constructor execution of
>
> a subclass of com.sun.jbi..*.
>
>
> javax.jbi..*
>
> execution(* com.sun.jbi..*+.*(..)) && execution(* com.sun.jbi..*+.new(..))
>
>
> Although, you may really want to advise the initialization of new
>
> classes, rather than the execution of constructors:
>
>
> initialization(* com.sun.jbi..*+.new(..))
>
>
> But, as I mentioned, try compile time weaving first to make sure this
>
> is doing what you want it to do.
>
>
> I am able to quickly test with LTW.
>
> Any idea on the other errors i receive that were in the original message?
>
> ___
>
> aspectj-users mailing list
>
> aspectj-users@eclipse.org
>
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
> *Dean Wampler, Ph.D.*
> dean at objectmentor.com
> http://www.objectmentor.com
> See also:
> http://www.polyglotprogramming.com  Multi-language and multi-paradigm
> programming
> http://www.aspectprogramming.comAOP advocacy site
> http://aquarium.rubyforge.org   AOP for Ruby
> http://www.contract4j.org   Design by Contract for Java5
>
> I want my tombstone to say:
>   Unknown Application Error in Dean Wampler.exe.
>   Application Terminated.
>   [Okay][Cancel]
>
>
>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] LTW and annotations

2008-10-02 Thread Ramnivas Laddad
I agree with Simone. There isn't a good way to effectively find out all
aspects using some classpath scanning mechanism. Note, however, that there
is an -outxml (or -outxmlfile ) option to 'ajc' that will create
aop.xml with an entry for all aspects.
-Ramnivas

2008/10/2 Simone Gianni <[EMAIL PROTECTED]>

> Hi Janos,
> unfortunately, at least AFAIK, there is no method in ClassLoader to find
> "all resources" in a package. The getResource (findResource,
> findResources etc..) only find resources if you already know the
> complete name of them (complete package). A number of tricks exists,
> like obtaining the path of the jar, then opening it as if it was a zip
> file, and scanning its content .. but they are not applicable in an
> "enterprise" like environment, where a hierarchy of classloaders may be
> in place and no direct access to jar files is possible (or even, there
> are no jar files at all). I also feel like this is a problem, but it's a
> ClassLoader problem in general, nothing AspectJ can easily fix.
>
> Anyway, exploring all possible classes for the presence of an annotation
> would be far too heavy. In even a simple web project there can be
> thousands of classes, scanning all of them so see which are aspects
> before even starting the "main" could require several seconds if not
> minutes.
>
> I can't think of any way to avoid the .xml file, maybe there is one, but
> without explicit support from the ClassLoader interface or some other
> java compiler internals (like a quick way to find all classes having a
> specific annotation, that would benefit quite a bit also JPA providers
> for example, which are also bound to XML based class listings in most
> cases) I think it's hard to do it in a reliable and standards compatible
> way. I don't think even a standard annotation processor could somehow
> ease this.
>
> Simone
>
> Háber János wrote:
> > Hmm!
> >
> > Tanks.
> >
> > " but have no idea that it exists an aspect"?
> >
> > Maybe a solution: Spring solve this probelm with a very simply way.
> > Get the selected package (maybe in aspectj possible using 
> > for this) and get all file-s and directories with
> > classloader.getResource method. And if the selected class is an
> > @Aspect... load it...
> >
> >
> > Janos
> >
> >
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Simone Gianni
> > Sent: Thursday, October 02, 2008 3:17 PM
> > To: aspectj-users@eclipse.org
> > Subject: Re: [aspectj-users] LTW and annotations
> >
> > If I understand how LTW works correctly, the problem is in class
> > loading.
> >
> > Consider the situation where you have a bean with a doSomething
> > method,
> > and then have an advice that does something before that method.
> >
> > You application starts, it will load the bean with a new Bean(). At
> > this
> > point, the class loader loads the bean, but have no idea that it
> > exists
> > an aspect, so will not weave the bean. This is because, you never call
> > (and have explicitly no way) to call "new MyAspect()".
> >
> > In fact, if you had such a way of instantiating aspects, another
> > situation could arise and cause problems. Suppose you have also a
> > tracing aspect, that will intercept all calls to all methods. If this
> > tracing aspect gets loaded AFTER the bean has already been loaded, the
> > class loader is not able anymore to modify the bean, because it has
> > already been loaded.
> >
> > (in reality, there are some ways to do class redefining in recent
> > classloaders, but that brings another lot of problems)
> >
> > So, yes, you have to define your aspects in the aop.xml file. Since
> > this
> > is tedious, the ajc compiler can perform this task for you. If you are
> > using AJDT in Eclipse, there is an option for generating aop.xml on
> > the
> > fly under the AspectJ section of you settings. If you are compiling
> > from
> > command line using ajc, the -outxml option will generate it for you
> > (see
> > http://www.eclipse.org/aspectj/doc/released/devguide/ajc-ref.html ).
> > Also, the maven2 plugin for aspectj will generate the aop.xml file for
> > you.
> >
> > Hope this helps,
> > Simone
> >
> >
> >
> > Háber János wrote:
> >
> >> Hi!
> >>
> >> I have a question. I want to write an application. I using javaagent
> >> vm option to LTW. But in this case what needed in aop.xml (aop.xml
> >> required in this case if I not want to set any special weaving
> >> options?)
> >> If I only write:
> >> 
> >> 
> >> 
> >>
> >> I get: "no aspects registered. Disabling weaver for class loader..."
> >> WTF? I need to set the aspects both aop.xml and annotation in java
> >> file? Why?
> >> If Yes, why? The classloader can't detect the annotations?
> >>
> >>
> >> Janos Haber
> >>
> >> ___
> >> aspectj-users mailing list
> >> aspectj-users@eclipse.org
> >> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >>
> >>
> >
> >
> >
>
>
> --
> Simone Gianni   

Re: [aspectj-users] question on ajlib:

2008-10-16 Thread Ramnivas Laddad
It looks like there is a bug in Log4jExecutionTracing. You need to change
pertypewithin(Traced) to pettypewithin(Traced+) in Log4jExecutionTracing.

Once I do that, I get the following output:
trace enter: com.AjlibTest.DummyObject() , this:
[EMAIL PROTECTED]
trace exit: com.AjlibTest.DummyObject()
trace enter: int com.AjlibTest.DummyObject.someMethod(int) , this:
[EMAIL PROTECTED], args: arg 0 = 5
trace exit: int com.AjlibTest.DummyObject.someMethod(int), return = 7

BTW, the runtime check that you see is due to the if() pointcut used to
enable/disable the tracing.

-Ramnivas

2008/10/16 Owen Corpening <[EMAIL PROTECTED]>

> Well I repeat I am still coming up to speed on some of the non-beginner
> spots in aspectj ... so I put a println in the before advice
> in Log4jExecutionTracing -- it never printed anything.
> So I hacked it by removing the "staticinitialization(*) && " and it prints,
> and I get the weaveinfo output as before but in addition I get
>
> Join point 'constructor-execution(void com.AjlibTest.DummyObject.())'
> in Type 'com.AjlibTest.DummyObject' (DummyObject.java:2) advised by before
> advice from 'com.AjlibTest.TestTraceAspect' (Log4jExecutionTracing.aj:17)
> [with runtime test]
> Join point 'method-execution(int
> com.AjlibTest.DummyObject.someMethod(int))' in Type
> 'com.AjlibTest.DummyObject' (DummyObject.java:4) advised by before advice
> from 'com.AjlibTest.TestTraceAspect' (Log4jExecutionTracing.aj:17) [with
> runtime test]
>
> So it defintely was not weaving the Log4jExecutionTracing before advice.
> For verboseness here is my hacked Log4jExecutionTracing and my aspect
> extending it:
>
> /**
>  * @author Ron Bodkin with code drawn from Matthew Webster's example posted
> to aj-users 1/28/2005
>  */
> package org.codehaus.ajlib.util.tracing;
>
> /**
>  * Typical idiom of log4j tracing of method execution: trace to a different
> logger for
>  * each type.
>  */
> public abstract aspect Log4jExecutionTracing extends ExecutionTracing  {
> protected interface Traced {}
>  public pointcut scope() : within(Traced+);
>  //TODO: test, e.g., what if staticinitialization of a type when tracing
> something?!
> //before(): staticinitialization(*) && inScope() {
> before(): inScope() {
>  System.out.println("in log4j");
> String name =
> thisJoinPointStaticPart.getSignature().getDeclaringTypeName();
> tracer = new Log4jTracer(name);
> }
> }
>
> package com.AjlibTest;
> import org.codehaus.ajlib.util.tracing.Log4jExecutionTracing;
> public aspect TestTraceAspect extends Log4jExecutionTracing {
> declare parents: com.AjlibTest.DummyObject implements Traced;
> }
>
> Since this posting is as long as the Magna Carta already here are my
> HelloWorld and DummyObject classes:
>
> package com.AjlibTest;
> public class HelloWorld
> {
> public static void main(String[] args)
> {
> DummyObject ao = new DummyObject();
> ao.someMethod(5);
> }
> }
>
> package com.AjlibTest;
> public class DummyObject
> {
> public int someMethod(int i)
> {
> return 7;
> }
> }
>
> thanks,
> owen
>
> - Original Message 
> From: Ron Bodkin <[EMAIL PROTECTED]>
> To: aspectj-users@eclipse.org
> Sent: Wednesday, October 15, 2008 9:11:51 PM
> Subject: RE: [aspectj-users] question on ajlib:
>
>  Hi Owen,
>
>
>
> This indicates that the before advice is in fact applying in your test.
> Could it be that you aren't seeing log output because the
> Log4jExecutionTracing aspect traces to a log4j logger at debug level, and
> that you need to enable debug output in your log4j configuration?
>
>
>
> *From:* [EMAIL PROTECTED] [mailto:
> [EMAIL PROTECTED] *On Behalf Of *Owen Corpening
> *Sent:* Wednesday, October 15, 2008 4:24 PM
> *To:* aspectj-users@eclipse.org
> *Subject:* Re: [aspectj-users] question on ajlib:
>
>
>
> Well it seems to have put the Traced interface on my DummyObject class ...
>
>
>
> Description  Resource Path Location Type
>
> Extending interface set for type 'com.AjlibTest.DummyObject'
> (DummyObject.java) to include
> 'org.codehaus.ajlib.util.tracing.Log4jExecutionTracing$Traced'
> (TestTraceAspect.aj)  aspectLibUnknown  Java Problem
>
> Join point 'constructor-execution(void com.AjlibTest.DummyObject.())'
> in Type 'com.AjlibTest.DummyObject' (DummyObject.java:2) advised by
> afterReturning advice from 'com.AjlibTest.TestTraceAspect'
> (ExecutionTracing.aj:56) [with runtime test]aspectLibUnknown  Java
> Problem
>
> Join point 'constructor-execution(void com.AjlibTest.DummyObject.())'
> in Type 'com.AjlibTest.DummyObject' (DummyObject.java:2) advised by
> afterThrowing advice from 'com.AjlibTest.TestTraceAspect'
> (ExecutionTracing.aj:76) [with runtime test]aspectLibUnknown  Java
> Problem
>
> Join point 'constructor-execution(void com.AjlibTest.DummyObject.())'
> in Type 'com.AjlibTest.DummyObject' (DummyObject.java:2) advised by before
> advice from 'com.AjlibTest.TestTraceAspect' (ExecutionTracing.aj:45) [with
> runtime test]   aspectLibUnk

Re: [aspectj-users] LTW and [Xlint:unmatchedSuperTypeInCall]

2008-10-19 Thread Ramnivas Laddad
You will need to specify the -nowarn option in the  section in
aop.xml as follows:

  ...

-Ramnivas

On Sun, Oct 19, 2008 at 11:59 AM, Mauro Baluda <[EMAIL PROTECTED]> wrote:

> On Sun, Oct 19, 2008 at 5:04 PM, Andrew Eisenberg <[EMAIL PROTECTED]>
> wrote:
> > Yes.  Go into the project's compiler options, and turn off warnings.
>
> I did it but I still get the warnings during load time weaving
>
> Mauro
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Method not visible using this in pointcut

2008-10-22 Thread Ramnivas Laddad
You may mark the aspect as 'privileged'.
public privileged aspect ... {
   ...
}

Alternatively, you may use reflection along with the
AccessibleObject.setAccessible() method.
-Ramnivas

On Wed, Oct 22, 2008 at 4:45 PM, Luiz Antonio Soares Filho <
[EMAIL PROTECTED]> wrote:

> Hello,
>
> I have a join point that need to expose the type of the instance.
> I used this(type) pointcut. When I call the method getRequest() from the
> type this error occurs:
> "The method getRequest() from the type FlowController is not visible"
>
> I think this error is happening possibly because getRequest is a private
> method from FlowController. How can I solve this?
>
> Here is my code:
>
> private pointcut tratarExcecao(Exception ex, String actionName,
> PageFlowController page) :
> execution(* *Controller.exception(..)) &&
> args(ex, actionName, *, *) && this(page);
>
> before(Exception ex, String actionName, PageFlowController page) :
> tratarExcecao(ex, actionName, page) {
> String displayMessage;
> if (AppException.isMensagemNegocio(ex)) {
> String keyError = AppException.obtemKeyErro(ex);
> displayMessage = "Erro: " + actionName;
> page.getRequest().setAttribute("errorMessage",displayMessage);
> //ERROR HERE
> }
> }
>
>
> Luiz Antonio
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] How can you access an aspect from a normal java class

2008-10-31 Thread Ramnivas Laddad
The code seems right. Check your import statements and/or your Eclipse
setting (AspectJ nature, inclusion of TestAspect on source path, etc.)
You may define pointcuts in a class (just as you would do in an aspect).
Then you may refer to those pointcuts as MyClass.myPointcut().

-Ramnivas

On Fri, Oct 31, 2008 at 5:46 AM, Piers Powlesland <
[EMAIL PROTECTED]> wrote:

> Hi
>
> I would like to get access to an aspect from a java class so that I can set
> some of its fields.
>
> I have tried the following form but Eclipse gives the error "TestAspect
> cannot be resolved".
>
> Class G{
>
>public void setAspectField(){
>TestAspect.aspectOf().x = 0;
>}
>
> }
>
> aspect TestAspect{
>public int x;
> }
>
>
> Also is there some way to define a pointcut in an normal class and then
> pass it to an aspect to use for some predefined advice.
>
> Thank you for your help
>
> Piers
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Another ITD question

2008-10-31 Thread Ramnivas Laddad
Dave,

I had the same question a long time back, so I am pasting that discussion
(obtained from the old list archive at
http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/archives/users.zip;
I couldn't find a direct link to posts in it on the Internet).
The follow ups have some ideas and flaws with them, should we consider this
feature once again.

-Ramnivas

== Orig ==
>From [EMAIL PROTECTED]  Mon Sep 10 14:14:04 2001
Received: from alpha.xerox.com (alpha.Xerox.COM [13.1.64.93])
by aspectj.org (8.9.3/8.8.7) with SMTP id OAA10522
for <[EMAIL PROTECTED]>; Mon, 10 Sep 2001 14:14:04 -0700
Received: from web10403.mail.yahoo.com ([216.136.130.95]) by
alpha.xerox.comwith SMTP id <130077(1)>; Mon, 10 Sep 2001 14:19:22 PDT
Message-ID: <[EMAIL PROTECTED]>
Received: from [207.181.251.173] by web10403.mail.yahoo.com via HTTP; Mon,
10 Sep 2001 14:19:22 PDT
Date: Mon, 10 Sep 2001 14:19:22 PDT
From: Ramnivas Laddad <[EMAIL PROTECTED]>
Subject: Behavior of super.method() w.r.t. introduced method in an interface
To: [EMAIL PROTECTED]
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Sender: [EMAIL PROTECTED]
Errors-To: [EMAIL PROTECTED]
X-BeenThere: [EMAIL PROTECTED]
X-Mailman-Version: 2.0.5
Precedence: bulk
List-Help: <mailto:[EMAIL PROTECTED]>
List-Post: <mailto:[EMAIL PROTECTED]>
List-Subscribe: <http://aspectj.org/mailman/listinfo/users>,
<mailto:[EMAIL PROTECTED]>
List-Id: 
List-Unsubscribe: <http://aspectj.org/mailman/listinfo/users>,
<mailto:[EMAIL PROTECTED]>
List-Archive: <http://aspectj.org/pipermail/users/>

Hello,

With AspectJ, a method implementation may be introduced to an
interface. I have a question related to the way it behaves and
wondering if it is the right behavior/specification or a bug?

For example, consider:

interface MyIf {
}

class MyClass implements MyIf {
}

aspect IntroduceFooToMyIf {
   public void MyIf.foo() {
   System.out.println("This is MyIf.foo()");
   }
}

This results in a foo() in MyIf and foo() with implementation
in MyClass. So far so good.

Now I change MyClass to:
class MyClass implements MyIf {
   public void foo() {
   System.out.println("This is MyClass.foo()");
   }
}

This result in not replacing MyClass.foo() by one specified in aspect.
This is ok too because, MyClass.foo() overrides introduced
MyIf.foo().

Now, I change MyClass to:
class MyClass implements MyIf {
   public void foo() {
   super.foo(); // <--- !!!
   System.out.println("This is MyClass.foo()");
   }
}

I get a compiler error, saying there is no foo() in super (MyIf).
Now, this would be correct from pure Java point-of-view. But
with AspectJ, I expected to result in _equivalent_ of
class MyClass implements MyIf {
   public void foo() {
   System.out.println("This is MyIf.foo()");  <---
   System.out.println("This is MyClass.foo()");
   }
}

That is, super.foo() should have been replaced with the introduced
code. In other words, introducing a method in MyIf should have
behaved as if that method was indeed there.

The replaced code for super.foo() would probably have to be coded
as a method (just like other code in AspectJ) so that a "return"
statement in it will not result in an incorrect behavior. But,
that's just details.

I am interested knowing your opinions.

Thanks and regards.

-Ramnivas

== Jim Hugunin's reply ==

This is a great question.  What it boils down to is whether or not
"super.m()" in AspectJ should be allowed to see concrete methods in
interfaces or not.  In AspectJ-1.0beta1 the answer is no.  super.m() has
exactly the same behavior as in pure Java, and it can only see methods in a
super class -- NOT in a super-interface.



I think that you're probably right and that super.m() should be allowed to
access concrete methods in interfaces.  However, I don't think that we
should add this functionality until after AspectJ-1.0.  Multiple-inheritance
is a well-known quagmire of complexity in OO language design, and is
something that should be approached carefully.  I'd like to have some calm
time to think carefully about any proposal that would expand the power (and
the complexity) of AspectJ's current very limited and simple form of
multiple-inheritance.  As an example of increasing complexity, if we provide
the power you suggest here, I can easily see people asking for qualified
super calls to disambiguate multiply inherited methods of the same name,
something like "ColorMixin.super.getColor()".

Fortunately, your proposal for increasing the power of super can be added to
AspectJ-1.1 or some other future version in a mostly backwards compatible
way.  Therefore, my recommendation is that we mostly table this discussion
until after AspectJ-1.0.0 is released.

The part that I'd like to talk about today is the mostly-backwards
compatible issu

Re: [aspectj-users] Pointcuts as a type?

2008-11-01 Thread Ramnivas Laddad
A pointcut serves as an intermediate program construct so that AspectJ can
weave crosscutting action at join points selected by it.
Can you provide a use case that will benefit from implementing pointcuts as
a Java type?

-Ramnivas

On Sat, Nov 1, 2008 at 10:18 AM, Piers Powlesland <
[EMAIL PROTECTED]> wrote:

> Hi All
>
> I was wondering why pointcuts have been implemented in the way that they
> have and not as a usual java type?
>
> Currently I keep on having cause to wish for the ability to pass pointcuts
> as parameters to advice and also to store them in a list.
>
> Will pointcuts be modified in the future to allow these operations or is
> there some good reason for not allowing this?
>
> Thank You
>
> Piers
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Another ITD question

2008-11-02 Thread Ramnivas Laddad
I think, AspectJ should support the super.m() call part of the proposal
restricted to situations where the super.m() can
be unambiguously deduced. Essentially, the m() method must be *implemented*
in only one of the direct parent types (class or interfaces with
implementation-introducing aspects). We can leave out the A.super.m() kind
of support for now. I believe that will cover the majority of the cases that
require augmentative override.
-Ramnivas

On Sat, Nov 1, 2008 at 5:32 PM, Dave Whittaker <[EMAIL PROTECTED]> wrote:

> Thanks Ramnivas.  It's good to know that I'm not the only one who is
> interested in this type of feature.  Since a few years have passed since
> that thread ended, what are your thoughts on how this could best be
> accomplished now?
>
>
> On Oct 31, 2008, at 4:17 PM, Ramnivas Laddad wrote:
>
> Dave,
>
> I had the same question a long time back, so I am pasting that discussion
> (obtained from the old list archive at
> http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/archives/users.zip;
> I couldn't find a direct link to posts in it on the Internet).
> The follow ups have some ideas and flaws with them, should we consider this
> feature once again.
>
> -Ramnivas
>
> == Orig ==
> From [EMAIL PROTECTED]  Mon Sep 10 14:14:04 2001
> Received: from alpha.xerox.com (alpha.Xerox.COM [13.1.64.93])
> by aspectj.org (8.9.3/8.8.7) with SMTP id OAA10522
>  for <[EMAIL PROTECTED]>; Mon, 10 Sep 2001 14:14:04 -0700
> Received: from web10403.mail.yahoo.com ([216.136.130.95]) by
> alpha.xerox.com with SMTP id <130077(1)>; Mon, 10 Sep 2001 14:19:22 PDT
> Message-ID: <[EMAIL PROTECTED]>
> Received: from [207.181.251.173] by web10403.mail.yahoo.com via HTTP; Mon,
> 10 Sep 2001 14:19:22 PDT
> Date: Mon, 10 Sep 2001 14:19:22 PDT
> From: Ramnivas Laddad <[EMAIL PROTECTED]>
> Subject: Behavior of super.method() w.r.t. introduced method in an
> interface
> To: [EMAIL PROTECTED]
> MIME-Version: 1.0
> Content-Type: text/plain; charset=us-ascii
> Sender: [EMAIL PROTECTED]
> Errors-To: [EMAIL PROTECTED]
> X-BeenThere: [EMAIL PROTECTED]
> X-Mailman-Version: 2.0.5
> Precedence: bulk
> List-Help: <mailto:[EMAIL PROTECTED]>
> List-Post: <mailto:[EMAIL PROTECTED]>
> List-Subscribe: <http://aspectj.org/mailman/listinfo/users>,
>  <mailto:[EMAIL PROTECTED]>
> List-Id: 
> List-Unsubscribe: <http://aspectj.org/mailman/listinfo/users>,
> <mailto:[EMAIL PROTECTED]>
> List-Archive: <http://aspectj.org/pipermail/users/>
>
> Hello,
>
> With AspectJ, a method implementation may be introduced to an
> interface. I have a question related to the way it behaves and
> wondering if it is the right behavior/specification or a bug?
>
> For example, consider:
>
> interface MyIf {
> }
>
> class MyClass implements MyIf {
> }
>
> aspect IntroduceFooToMyIf {
>public void MyIf.foo() {
>System.out.println("This is MyIf.foo()");
>}
> }
>
> This results in a foo() in MyIf and foo() with implementation
> in MyClass. So far so good.
>
> Now I change MyClass to:
> class MyClass implements MyIf {
>public void foo() {
>System.out.println("This is MyClass.foo()");
>}
> }
>
> This result in not replacing MyClass.foo() by one specified in aspect.
> This is ok too because, MyClass.foo() overrides introduced
> MyIf.foo().
>
> Now, I change MyClass to:
> class MyClass implements MyIf {
>public void foo() {
>super.foo(); // <--- !!!
>System.out.println("This is MyClass.foo()");
>}
> }
>
> I get a compiler error, saying there is no foo() in super (MyIf).
> Now, this would be correct from pure Java point-of-view. But
> with AspectJ, I expected to result in _equivalent_ of
> class MyClass implements MyIf {
>public void foo() {
>System.out.println("This is MyIf.foo()");  <---
>System.out.println("This is MyClass.foo()");
>}
> }
>
> That is, super.foo() should have been replaced with the introduced
> code. In other words, introducing a method in MyIf should have
> behaved as if that method was indeed there.
>
> The replaced code for super.foo() would probably have to be coded
> as a method (just like other code in AspectJ) so that a "return"
> statement in it will not result in an incorrect behavior. But,
> that's just details.
>
> I am interested knowing your opinions.
>
> Thanks and regards.
>
> -Ramnivas
>
> == Jim Hugunin's reply ==
>
> This is a great question.  What it boils down to is whether or not
> "super.m()" in 

Re: [aspectj-users] newbie question about @target

2008-11-04 Thread Ramnivas Laddad
You probably need to use the following pointcut:
execution(@Loggable * *.*(..)) || execution(* (@Loggable *).*(..))

-Ramnivas

On Tue, Nov 4, 2008 at 8:06 AM, Miguel Alcalde <[EMAIL PROTECTED]>wrote:

> Hi all.
>
> I'm trying to implement a declarative logging system. For that I have
> created @Loggable annotation:
>
> @Target({ElementType.TYPE, ElementType.METHOD})
> @Inherited
> @Retention(RetentionPolicy.RUNTIME)
> public @interface Loggable {
>LoggableLevel normalLevel()default LoggableLevel.INFO;
>LoggableLevel errorLevel()default LoggableLevel.ERROR;
>boolean verbose() default false;
> }
>
> I have not idea how to build pointcut expression to captura  calls to
> 'loggable' classes or 'loggable' methods.
>
> After done many test using combinations of execution, call, @target,
> @annotation, @withincode.
> For my point of view this should work fine, but... nothing happens
>
> @Pointcut("execution(* *.*(..)) && (
> @target(es.git.sistem.commons.Loggable) ||
> @withincode(es.git.sistem.commons.Loggable)) && (!within(LoggingAspect))
>  ")
>private void loggedMethods(){}
>
> Could you help me?
>
> Note: A using maven-aspect-plugin
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] can arg names be accessed at a joinpoint?

2008-11-12 Thread Ramnivas Laddad
You get get the associated CodeSignature object as follows:
CodeSignature codeSignature = (CodedSignature) thisJoinPoint.getSignature();
String[] argNames = codeSignature.getParameterNames();

-Ramnivas

On Wed, Nov 12, 2008 at 10:48 PM, Owen Corpening <[EMAIL PROTECTED]>wrote:

> I am using a tracing aspect and it is printing the method arg values upon
> entry, but without arg names:
> trace enter: int com.AjlibTest.DummyObject.someMethod(int) , this:
> [EMAIL PROTECTED], args: arg 0 = 5
>
> using joinPoint.getArgs() - I can see in the debugger that the arg names
> are not in the joinpoint - is there a way an aspect can capture that info?
>
> Owen Corpening
> 10911 Watchful Fox Drive
> Austin, TX 78748
>
> 512 280-1753 Home
> 512 634-5148 Office
> 512 659-5300 Cell
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] can arg names be accessed at a joinpoint?

2008-11-14 Thread Ramnivas Laddad
If you compile your code using ajc or javac with -g (for binary weaving
purpose), you will get the original argument names.
-Ramnivas

On Fri, Nov 14, 2008 at 8:19 AM, rmahmood <[EMAIL PROTECTED]> wrote:

>
> But this will give the argument names as saved in .class file, normally
> arg0,
> arg1 etc.
> not the original names as in source code.
>
> Is there any way to get original names as specified in source code?
>
>
> Ramnivas Laddad wrote:
> >
> > You get get the associated CodeSignature object as follows:
> > CodeSignature codeSignature = (CodedSignature)
> > thisJoinPoint.getSignature();
> > String[] argNames = codeSignature.getParameterNames();
> >
> > -Ramnivas
> >
> > On Wed, Nov 12, 2008 at 10:48 PM, Owen Corpening
> > <[EMAIL PROTECTED]>wrote:
> >
> >> I am using a tracing aspect and it is printing the method arg values
> upon
> >> entry, but without arg names:
> >> trace enter: int com.AjlibTest.DummyObject.someMethod(int) , this:
> >> [EMAIL PROTECTED], args: arg 0 = 5
> >>
> >> using joinPoint.getArgs() - I can see in the debugger that the arg names
> >> are not in the joinpoint - is there a way an aspect can capture that
> >> info?
> >>
> >> Owen Corpening
> >> 10911 Watchful Fox Drive
> >> Austin, TX 78748
> >>
> >> 512 280-1753 Home
> >> 512 634-5148 Office
> >> 512 659-5300 Cell
> >>
> >>
> >> ___
> >> aspectj-users mailing list
> >> aspectj-users@eclipse.org
> >> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >>
> >>
> >
> > ___
> > aspectj-users mailing list
> > aspectj-users@eclipse.org
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/can-arg-names-be-accessed-at-a-joinpoint--tp20474387p20500385.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] can arg names be accessed at a joinpoint?

2008-11-15 Thread Ramnivas Laddad
It seems that it is all working correctly. Does your method is
declared as someMethod(int i)? Is so, the output seems to correctly
print "i". You are getting "arg 0" part because you are printing "arg
"+i. Right?

-Ramnivas

On Sat, Nov 15, 2008 at 3:26 PM, Owen Corpening <[EMAIL PROTECTED]> wrote:
>
> Lord have mercy, ever wish you could take back a posting? I corrected my 
> code, same results, the two lines below should have read:
> logStr.append(", args using CodeSignature: "+arguments(argNames));
> logStr.append(", args using getArgs: "+arguments(getargs));
> output is same
> darnit all
> owen
> 
> From: Owen Corpening <[EMAIL PROTECTED]>
> To: aspectj-users@eclipse.org
> Sent: Saturday, November 15, 2008 2:00:05 PM
> Subject: Re: [aspectj-users] can arg names be accessed at a joinpoint?
>
> I not only compile with -g, I am running within the eclipse debugger and I 
> still get "arg 0".
> Plus doesn't thisJoinPoint.getArgs() do the same thing? Seems to, sorry I 
> didn't read the aspectj src to confirm, I am downloading that today.
>if (joinPoint.getArgs() != null && joinPoint.getArgs().length>0) {
> Object getargs[] = joinPoint.getArgs();
> CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();
> String[] argNames = codeSignature.getParameterNames();
> logStr.append(", args using CodeSignature: "+arguments(argNames));
> logStr.append(", args using getArgs: "+arguments(argNames));
>}
> return logStr.toString();
> }
> protected String arguments(Object[] arguments) {
> StringBuffer logStr = new StringBuffer();
> for (int i = 0; i < arguments.length; i++) {
> logStr.append((i>0 ? ", ":"")+ "arg "+i+" = 
> "+traceString(arguments[i]));
> }
> return logStr.toString();
> }
> console output:
> INFO  com.AjlibTest.DummyObject  - trace enter: int 
> com.AjlibTest.DummyObject.someMethod(int) , this: [EMAIL PROTECTED], args 
> using CodeSignature: arg 0 = i, args using getArgs: arg 0 = i
> -3[main]
> owen
> Ramnivas Laddad wrote:
> If you compile your code using ajc or javac with -g (for binary weaving 
> purpose), you will get the original argument names.
> -Ramnivas
>
> On Fri, Nov 14, 2008 at 8:19 AM, rmahmood <[EMAIL PROTECTED]> wrote:
>>
>> But this will give the argument names as saved in .class file, normally arg0,
>> arg1 etc.
>> not the original names as in source code.
>>
>> Is there any way to get original names as specified in source code?
>>
>>
>> Ramnivas Laddad wrote:
>> >
>> > You get get the associated CodeSignature object as follows:
>> > CodeSignature codeSignature = (CodedSignature)
>> > thisJoinPoint.getSignature();
>> > String[] argNames = codeSignature.getParameterNames();
>> >
>> > -Ramnivas
>> >
>> > On Wed, Nov 12, 2008 at 10:48 PM, Owen Corpening
>> > <[EMAIL PROTECTED]>wrote:
>> >
>> >> I am using a tracing aspect and it is printing the method arg values upon
>> >> entry, but without arg names:
>> >> trace enter: int com.AjlibTest.DummyObject.someMethod(int) , this:
>> >> [EMAIL PROTECTED], args: arg 0 = 5
>> >>
>> >> using joinPoint.getArgs() - I can see in the debugger that the arg names
>> >> are not in the joinpoint - is there a way an aspect can capture that
>> >> info?
>> >>
>> >> Owen Corpening
>> >> 10911 Watchful Fox Drive
>> >> Austin, TX 78748
>> >>
>> >> 512 280-1753 Home
>> >> 512 634-5148 Office
>> >> 512 659-5300 Cell
>> >>
>> >>
>> >> ___
>> >> aspectj-users mailing list
>> >> aspectj-users@eclipse.org
>> >> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>> >>
>> >>
>> >
>> > ___
>> > aspectj-users mailing list
>> > aspectj-users@eclipse.org
>> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
>> >
>> >
>>
>> --
>> View this message in context: 
>> http://www.nabble.com/can-arg-names-be-accessed-at-a-joinpoint--tp20474387p20500385.html
>> Sent from the AspectJ - users mailing list archive at Nabble.com.
>>
>> ___
>> aspectj-users mailing list
>> aspectj-users@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Problem with annotation pointcut in WebSpere

2008-11-26 Thread Ramnivas Laddad
WebSphere ships with an older version of aspectjrt.jar (in the lib
directory). I wonder if that is causing the problem. You may want to
try replacing it with a newer version.

-Ramnivas

On Wed, Nov 26, 2008 at 2:47 AM,  <[EMAIL PROTECTED]> wrote:
> Hi
>
> I have an aspect that works just fine when run in a standalone test (JDK
> 1.5), but fails to work when run under WebSphere 6.1 (Also JDK 1.5)
>
> Timeable.java
> @Retention(RetentionPolicy.RUNTIME)
> @Documented
> public @interface Timeable {
>
> }
>
> TimerAspect.aj:
>
> public aspect TimerAspect extends BaseAspect perthis(timedExecution()) {
>
>public pointcut timedExecution() : execution(@Timeable * *());
>
>before() : timedExecution() {
>System.out.println("Before");
>}
>
>before() : timedExecution() {
>System.out.println("After");
>}
> }
>
> With -showWeaveInfo -verbose -debug I get in the log
>
> [EMAIL PROTECTED] info successfully verified type
> aa.bb.cc.TimerAspect exists.  Originates from 
> [EMAIL PROTECTED] info register aspect aa.bb.cc.TimerAspect
>
> So it is loading it, but it does never get applied any of the methods I
> have annotated with @Timeable
>
> Anybody else had problems with this. Is there any other way I can out
> info about what is failing.
>
> Hermod
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
>
> This email with attachments is solely for the use of the individual or
> entity to whom it is addressed. Please also be aware that the DnB NOR Group
> cannot accept any payment orders or other legally binding correspondence with
> customers as a part of an email.
>
> This email message has been virus checked by the anti virus programs used
> in the DnB NOR Group.
>
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Introducing JDT Weaving

2008-12-03 Thread Ramnivas Laddad
This is wonderful!

Updating as I write.

-Ramnivas

On Wed, Dec 3, 2008 at 9:58 AM, Simone Gianni <[EMAIL PROTECTED]> wrote:
> Andrew Eisenberg wrote:
>> Hi all,
>>
>> We would like to introduce the latest developments for AJDT.  We will
>> be release some exciting new features including Java searches that
>> include Aspects elements, ITD aware content assist and type
>> hierarchies.
>>
> Hurrray
>> We are asking the AspectJ and AJDT community to please try this new
>> version out and report any bugs on this list or on bugzilla.  The
>> update site is here:
>> http://download.eclipse.org/tools/ajdt/34/dev/weaving
>>
>>
> Will do asap!
>
> Great work!
>
> Simone
>> This is a pre-release of AJDT 1.6.2 and therefore requires Eclipse
>> 3.4.x.  AJDT 1.6.2 will be release towards the end of this month.
>>
>> In order to implement this we were left with no choice but to apply
>> AspectJ to the Eclipse framework itself.  We created the JDT Weaving
>> plugin that uses uses Equinox Aspects [1] to do the cross-plugin
>> weaving.
>>
>> For more information on how to use and install see the Eclipse Wiki:
>> http://wiki.eclipse.org/JDT_weaving_features
>>
>> As always we appreciate all feedback from the community.
>>
>> sincerely,
>> The AJDT team
>>
>>
>> [1] http://www.eclipse.org/equinox/incubator/aspects/index.php
>> ___
>> aspectj-users mailing list
>> aspectj-users@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>
>
> --
> Simone GianniCEO Semeru s.r.l.   Apache Committer
> http://www.simonegianni.it/
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] ITD syntax

2008-12-04 Thread Ramnivas Laddad
I like this proposal.

Here is an alternative syntax suggestion that
- addresses Dave's use case
- addresses a use case that is easy to implement in @AspectJ but not
in code style
- avoids new keywords

public aspect ITDAspect{

/* don't have define the class here, don't need to make it private;
but defining it that way matches Dave's example
   */
private static class ITDDefaultImpl {
private String string;

public String getString(){
return string;
}

public void setString(String string){
this.string = string;
}
}

/* declare that ITDInterface should be introduced with
all fields and methods in ITDDefaultImpl
Not sure about the choice of using "extends"
(trying to avoid new keyword)
Alternatives: declare implements? declare default?
*/
declare extends: ITDInterface, ITDDefaultImpl;
}

This makes a common use case implemented by the following @AspectJ
snippet available in the code style syntax. Essentially, I get to
reuse the implementation available from an existing class.

@DeclareParents(value="com.myco.domain.*",
 defaultImpl= ITDDefaultImpl.class)
ITDInterface something;

How does this sound?

-Ramnivas

On Wed, Dec 3, 2008 at 9:40 PM, Andy Clement <[EMAIL PROTECTED]> wrote:
> I could be wrong but I think I recall someone talking about something
> like this a while ago - possibly Ramnivas.  Although having just
> trawled through our enhancement requests, I only found this:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=240011 which is about
> saving typing but isn't quite the same thing.  What you propose is
> interesting, what do others think?
>
> cheers,
> Andy.
>
> 2008/12/3 Dave Whittaker <[EMAIL PROTECTED]>
>>
>> I've been wondering recently is there a reason that ITDs are defined the 
>> way they are?  I don't know how others tend to use them, but for me I'm 
>> pretty likely to have an aspect that contains ITD fields and methods that 
>> apply to a single interface within a given aspect.  This makes me wonder why 
>> we have a syntax like:
>>
>> public aspect ITDAspect{
>>
>>private String ITDInterface.string;
>>
>>public String ITDInterface.getString(){
>>return string;
>>}
>>
>>public void ITDInterface.setString(String string){
>>this.string = string;
>>}
>>
>> }
>>
>> Instead of:
>>
>> public aspect ITDAspect{
>>
>>intertype(ITDInterface){
>>
>>
>>private String string;
>>
>>public String getString(){
>>return string;
>>}
>>
>>public void setString(String string){
>>this.string = string;
>>}
>>
>>}
>> }
>>
>> Or something similar.  Something that involved less typing, consolidated 
>> code that is defined for another type and looked more like plain java code 
>> (not to mention more like other AJ definitions in this case).  At the 
>> very least it would allow for something that I've wanted many times: cut and 
>> paste between classes and ITDs without having to post process with some sort 
>> of wacky regex.  Am I missing a reason why it's desirable or even necessary 
>> to type out the full interface name on each line?
>> ___
>> aspectj-users mailing list
>> aspectj-users@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Basic AspectJ question

2008-12-04 Thread Ramnivas Laddad
You need to modify your aspect :

aspect PathChannelHack {

   after(PathChanInst pathchannel) : set(private CircPathInst
parentPathInst) && this(pathchannel) {
   
pathchannel.setParentPathHumid(pathchannel.getParentPathInst().getPathHumId());
   }
}

I suggest that you get this working with a standalone example first
and then weave into the jar (binary weaving).

-Ramnivas

On Thu, Dec 4, 2008 at 11:18 AM, Sebestyén Zoltán <[EMAIL PROTECTED]> wrote:
> Hi,
>
>  I've got the following problem (I've got JDK 1.5 + AspectJ 1.5.3). There's
> a class for which I can't modify the source however I've got to have an
> extra field which should be updated whenever an certain other field is set.
> I tried to create a small aspect for that without any success. Could please
> someone show me how to do it? I'd like to have this modification in the
> class file since it's part of a JAR used in several projects so the
> solutions should be portable.
> The field in question is only set in the constructor and it's setter method.
> Both fields have setter and getter methods.
>
> The relevant source is the following:
>
> ...
>
> /** @author Hibernate CodeGenerator */
> public class PathChanInst implements Serializable {
>
> ...
>/** This is the source field, it should be monitored. */
>private CircPathInst parentPathInst;
>
>/** The extra field, it should be updated whenever parentPathInst is
> changed */
>private String parentPathHumid;
> ...
>
>/** full constructor */
>public PathChanInst(...) {
> ...
>// Here's the first occasion, after that should parentPathHumid set.
>this.parentPathInst = parentPathInst;
> ...
>}
>
> ...
>
>public void setParentPathInst(CircPathInst parentPathInst) {
>
>// Here's the second occasion, after that should parentPathHumid set.
>this.parentPathInst = parentPathInst;
>}
> }
>
> The aspect I did:
>
> aspect PathChannelHack {
>
>after(PathChanInst pathchannel) : set(private CircPathInst
> parentPathInst) {
>
>  
> pathchannel.setParentPathHumid(pathchannel.getParentPathInst().getPathHumId());
>}
> }
>
>
> Thanks in advance,
>
> Zoltan
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: R: Re: [aspectj-users] ITD syntax

2008-12-05 Thread Ramnivas Laddad
That's quite a good discussion we've had!

There are indeed two different model for implementation for ITDs as
Herman distilled well: the classic member introduction (the current
code-style AspectJ model and Dave's original proposal) and delegation
model (the one implemented in @AspectJ's @DeclareParents and most
likely implementation of my "declare extends" proposal)

So I guess we have two questions to ponder:
1. Do both model make sense. If yes, how to best present them to avoid
confusing users (ss Simone pointed). If not, what should be the status
of @DeclareParents in @AspectJ.
2. (Back to Dave's original question) What is best syntax for "bulk
ITD" i.e. introducing a set of members with a simpler syntax.

-Ramnivas


2008/12/5 Simone Gianni <[EMAIL PROTECTED]>:
>
>
>> Hi Herman,
>> you perfectly got the point. We are moving from IDT to something else, and
>> that what I felt in the first place without being able to express it with
>> the clarity you had. I agree on splitting this thread on "A simpler syntax
>> for IDTs" and "A delegation approach to IDTs".
>>
>> As long as the simpler syntax for IDTs in involved, I like Dave's
>> proposal, also because it uses a construct very similar to the "with", which
>> is present in a number of languages but missing in Java, and many
>> programmers are already used to it. Also, it simply requires less typing
>> without changing the semnatics of the IDT.
>>
>> There can be better ways of doing mixins/IDTs, including the delegation
>> based ones, but that's another discussion.
>>
>> Simone
>>
>> - Messaggio originale -
>> Da: Ichthyostega <[EMAIL PROTECTED]>
>> A: aspectj-users@eclipse.org
>> Posta Inviata: giovedì 4 dicembre 2008 22.42.08 GMT+0100 Europe/Berlin
>> Oggetto: Re: [aspectj-users] ITD syntax
>>
>> -BEGIN PGP SIGNED MESSAGE-
>> Hash: SHA1
>>
>> Hi Dave,
>>
>> > I'm glad for this discussion because it's helped me in refining how I
>> > think
>> > this would work best.
>> Same here. I saw your answer just after posting mine.
>> Probably we are facing a decision on two possible routes to take:
>>
>> - - provide some convenience for Delegation using AspectJ
>> - - stick to the ITD semantics but provide a better syntax.
>>
>> My feeling is we would be best off if we took a clear decision on
>> one of those routes and don't try to mix them up. Even if we were
>> able to come with a combined solution, it will confuse people.
>>
>> Thus, if we go the "Delegation" route, "this" should be really rebound
>> the moment we are within the scope of the delegate to mean the delegate,
>> the same way as if all of this was just implemented in plain Java.
>> OTOH, when going the "ITD" route, the source class (ITDDefaultImpl
>> or DoSomethingImpl) is rather sort-of a template for code woven into
>> the target. I.e., at runtime, no class DoSomethingImpl will be loaded.
>> Then the question remains what should happen with private fields.
>> Consider, both the class Doer and class DoSomethingImpl may use
>> a private field with the same name for their implementation.
>>
>> Hermann
>>
>>
>>
>>
>>
>> -BEGIN PGP SIGNATURE-
>> Version: GnuPG v1.4.6 (GNU/Linux)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>> iD8DBQFJOE6wZbZrB6HelLIRAjRcAJ9lpaNl/nFsSX/dTl34LL364s5qyQCfQ8wS
>> CmLlX5bTe+LvoI6V8sh29K8=
>> =EYAe
>> -END PGP SIGNATURE-
>> ___
>> aspectj-users mailing list
>> aspectj-users@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: R: Re: [aspectj-users] ITD syntax

2008-12-05 Thread Ramnivas Laddad
Dave,

One of the issues we will need to work through is the mapping between
the two syntax styles. Perhaps, the only issue we need to work through
is clarifying the supported models (insertion and delegation) through
appropriate syntax. I think your option c (or a variation of it--that
explicitly mentions "defaultImpl" or "defaultDelegate" or something to
the same effect) clarifies that better that my "declare extends". You
option c also better mirrors the semantics associated with
@DeclareParents in that it combined parenting and delegation in one
declaration.

Assuming the delegate model is supported with code-style syntax, do we
need simplified syntax for the insertion model (option a)?

-Ramnivas

On Fri, Dec 5, 2008 at 1:59 PM, Dave Whittaker <[EMAIL PROTECTED]> wrote:
> Ramnivas,
> Hmmm... now I think I'm a bit confused.  I haven't used the @DeclareParents
> annotation, as a matter of fact I wasn't aware it existed until you
> mentioned it, but if it already uses delegation to accomplish what we're
> talking about then that's a different story.  If both methods (delegation
> and direct insertion) already exist within AspectJ I would think that it's
> less confusing to allow delegation both through annotations and through
> declarations than to only allow it when using annotations.  It also would
> imply that the work involved in adding a delegation feature would be a lot
> less than what I would have expected otherwise.  Another thing to think
> about
> On Dec 5, 2008, at 1:44 PM, Ramnivas Laddad wrote:
>
> That's quite a good discussion we've had!
>
> There are indeed two different model for implementation for ITDs as
> Herman distilled well: the classic member introduction (the current
> code-style AspectJ model and Dave's original proposal) and delegation
> model (the one implemented in @AspectJ's @DeclareParents and most
> likely implementation of my "declare extends" proposal)
>
> So I guess we have two questions to ponder:
> 1. Do both model make sense. If yes, how to best present them to avoid
> confusing users (ss Simone pointed). If not, what should be the status
> of @DeclareParents in @AspectJ.
> 2. (Back to Dave's original question) What is best syntax for "bulk
> ITD" i.e. introducing a set of members with a simpler syntax.
>
> -Ramnivas
>
>
> 2008/12/5 Simone Gianni <[EMAIL PROTECTED]>:
>
>
> Hi Herman,
>
> you perfectly got the point. We are moving from IDT to something else, and
>
> that what I felt in the first place without being able to express it with
>
> the clarity you had. I agree on splitting this thread on "A simpler syntax
>
> for IDTs" and "A delegation approach to IDTs".
>
> As long as the simpler syntax for IDTs in involved, I like Dave's
>
> proposal, also because it uses a construct very similar to the "with", which
>
> is present in a number of languages but missing in Java, and many
>
> programmers are already used to it. Also, it simply requires less typing
>
> without changing the semnatics of the IDT.
>
> There can be better ways of doing mixins/IDTs, including the delegation
>
> based ones, but that's another discussion.
>
> Simone
>
> - Messaggio originale -
>
> Da: Ichthyostega <[EMAIL PROTECTED]>
>
> A: aspectj-users@eclipse.org
>
> Posta Inviata: giovedì 4 dicembre 2008 22.42.08 GMT+0100 Europe/Berlin
>
> Oggetto: Re: [aspectj-users] ITD syntax
>
> -BEGIN PGP SIGNED MESSAGE-
>
> Hash: SHA1
>
> Hi Dave,
>
> I'm glad for this discussion because it's helped me in refining how I
>
> think
>
> this would work best.
>
> Same here. I saw your answer just after posting mine.
>
> Probably we are facing a decision on two possible routes to take:
>
> - - provide some convenience for Delegation using AspectJ
>
> - - stick to the ITD semantics but provide a better syntax.
>
> My feeling is we would be best off if we took a clear decision on
>
> one of those routes and don't try to mix them up. Even if we were
>
> able to come with a combined solution, it will confuse people.
>
> Thus, if we go the "Delegation" route, "this" should be really rebound
>
> the moment we are within the scope of the delegate to mean the delegate,
>
> the same way as if all of this was just implemented in plain Java.
>
> OTOH, when going the "ITD" route, the source class (ITDDefaultImpl
>
> or DoSomethingImpl) is rather sort-of a template for code woven into
>
> the target. I.e., at runtime, no class

Re: [aspectj-users] pointcut with parameters definition

2008-12-08 Thread Ramnivas Laddad
Not directly, but you may create another pointcut and use the original from it:

pointcut myMethodCall2() : myMethodCall(*);

-Ramnivas

On Mon, Dec 8, 2008 at 10:16 AM, Marco Poggi <[EMAIL PROTECTED]> wrote:
> Hi all,
> I need a little help
>
> I have to write a pointcut to capture something like
>
>
> * *.method(Strring,...) && args(a) && checkParameter(a)
>
> checkParameter is a method with this signature
>
> static boolean checkParameter(String a)
>
> I have tried with
>
> myMethodCall(String a):
> call(* *.method(String,..)) && args(a) && checkParameter(a);
>
> and It works, I want know if is possible to write the same pointcut without
> declare
>
> myMethodCall(String a)
>
> but only myMethodCall()
>
>
> Thank You all
>
> Marco Poggi
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: R: Re: [aspectj-users] ITD syntax

2008-12-08 Thread Ramnivas Laddad
On Mon, Dec 8, 2008 at 2:30 PM, Andy Clement <[EMAIL PROTECTED]> wrote:
> I like the idea of simplifying the syntax but I keep changing my mind
> over the syntax I most prefer.  It is probably this actually:
>
>> intertype(AnotherClass){
>>
>>public String someVar;
>>
>>public String getSomeVar(){
>>return someVar;
>>}
>> }
>
> Since everything is there and it is clear.  I'm just nervous about new
> keywords and how easily I can persuade the compiler to deal with it.
> I would see this just as syntax sugar on the current ITD model though,
> and not change any semantics to say that it means anything like a
> mixin/delegation model.

How about this way to avoid a new keyword:

Options 1:
within(AnotherClass) {
public String someVar;

public String getSomeVar(){
return someVar;
}
 }

Pros: May read naturally --> "within AnotherClass, declare the following"
Cons: Will the use of within confuse developers with its usage in pointcut?

Options 2:
AnotheClass.{
public String someVar;

public String getSomeVar(){
return someVar;
}
}

Pros: Easy to explain the bulk ITD syntax compared to regular ITD
syntax-- dot and a member or dot and members.
Cons: Too subtle a use of "."?

-Ramnivas
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: R: Re: [aspectj-users] ITD syntax

2008-12-08 Thread Ramnivas Laddad
On second thought, I think option 1 is not good. It is very likely to
confuse users: besides confusion bought by two usage of within(), the
within(AnotherClass) pointcut won't select bulk ITDs introduced
through within(AnotherClass) {...}.

-Ramnivas

On Mon, Dec 8, 2008 at 3:03 PM, Ramnivas Laddad
<[EMAIL PROTECTED]> wrote:
> On Mon, Dec 8, 2008 at 2:30 PM, Andy Clement <[EMAIL PROTECTED]> wrote:
>> I like the idea of simplifying the syntax but I keep changing my mind
>> over the syntax I most prefer.  It is probably this actually:
>>
>>> intertype(AnotherClass){
>>>
>>>public String someVar;
>>>
>>>public String getSomeVar(){
>>>return someVar;
>>>}
>>> }
>>
>> Since everything is there and it is clear.  I'm just nervous about new
>> keywords and how easily I can persuade the compiler to deal with it.
>> I would see this just as syntax sugar on the current ITD model though,
>> and not change any semantics to say that it means anything like a
>> mixin/delegation model.
>
> How about this way to avoid a new keyword:
>
> Options 1:
> within(AnotherClass) {
>public String someVar;
>
>public String getSomeVar(){
>return someVar;
>}
>  }
>
> Pros: May read naturally --> "within AnotherClass, declare the following"
> Cons: Will the use of within confuse developers with its usage in pointcut?
>
> Options 2:
> AnotheClass.{
>public String someVar;
>
>public String getSomeVar(){
>return someVar;
>}
> }
>
> Pros: Easy to explain the bulk ITD syntax compared to regular ITD
> syntax-- dot and a member or dot and members.
> Cons: Too subtle a use of "."?
>
> -Ramnivas
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] advices for methods from packaged classes

2008-12-11 Thread Ramnivas Laddad
Yes, you can use binary weaving to weave into third-party jars. Check
documentation for ajc, particularly around the -injar option.

-Ramnivas

On Thu, Dec 11, 2008 at 9:19 PM, miro  wrote:
>
> Is it possible to  advice on a method call of a class which is packged in  a
> jar file.
> for example I want my advice to be called for any   method called for some
> class   in oracle driver  jar ?
> --
> View this message in context: 
> http://www.nabble.com/advices-for--methods-from-packaged-classes-tp20968822p20968822.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] using @declaredParents for annotations

2008-12-11 Thread Ramnivas Laddad
On Thu, Dec 11, 2008 at 10:12 PM, miro  wrote:
>
> I want to use @decalredParents   for  an annotation
>
> my aspect
>
>@DeclareParents("@annotation(gov.hhs.acf.aop.aspects.WorkflowAware)",
>defaultImpl=DefaultWorkflowMetaData.class)
>   public static WorkflowMetaData workflowMetaData1;
>

@DeclareParents(value="@gov.hhs.acf.aop.aspects.WorkflowAware *",
  defaultImpl=DefaultWorkflowMetaData.class)
public static WorkflowMetaData workflowMetaData1;

>
> @Target(ElementType.TYPE)
> @Retention(RetentionPolicy.CLASS)
> public @interface WorkflowAware {
>
> }
>
> what I want is all classes which have WorkflowAware  annotaton  should
> implement WorkflowMetaData   please help me write the proper syntax
>
>
>
>@DeclareParents(value="gov.hhs.acf.web.pages.auditprog.*",
>defaultImpl=DefaultWorkflowMetaData.class)
>public static WorkflowMetaData workflowMetaData;

This looks fine.

>
>
> this works for me can I add  to this all classes  with annotation
> WorkflowAware  ?
>
> --
> View this message in context: 
> http://www.nabble.com/using-%40declaredParents--for-annotations-tp20969256p20969256.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] using @declaredParents for annotations

2008-12-11 Thread Ramnivas Laddad
Did you try the code from my previous reply?

@DeclareParents(value="@gov.hhs.acf.aop.aspects.WorkflowAware *",
 defaultImpl=DefaultWorkflowMetaData.class)
public static WorkflowMetaData workflowMetaData1;

-Ramnivas

On Thu, Dec 11, 2008 at 11:46 PM, miro  wrote:
>
> I need all classes with some annotation to implement an interface
>
> my aspect code
>
>@DeclareParents(value="gov.hhs.acf.aop.aspects.WorkflowAware",
>defaultImpl=DefaultWorkflowMetaData.class)
>public static WorkflowMetaData workflowMetaData1;
>
>
> here gov.hhs.acf.aop.aspects.WorkflowAware  is an annotation.
>
> here the definitaion of annotation
>
>
> @Target(ElementType.TYPE)
> @Retention(RetentionPolicy.RUNTIME)
> public @interface WorkflowAware {
>
> }
>
>
> next I added this annotation  to a class
>
> @WorkflowAware
> public class AuditProgReviewDTO
>
>  i am assuming this make   AuditProgReviewDTO  implement   WorkflowMetaData
> , but this is not happening and here the output from aspectj:compile
>
> [WARNING] annotation type gov.hhs.acf.aop.aspects.WorkflowAware matches a
> declare parents type pattern but is being ignored
> [Xlint:annotationAsTargetForDecpIgnored]
>
> please tell me how  to use an annotation as a jointpoint
>
>
>
>
>
> Ramnivas Laddad wrote:
>>
>> On Thu, Dec 11, 2008 at 10:12 PM, miro  wrote:
>>>
>>> I want to use @decalredParents   for  an annotation
>>>
>>> my aspect
>>>
>>>
>>> @DeclareParents("@annotation(gov.hhs.acf.aop.aspects.WorkflowAware)",
>>>defaultImpl=DefaultWorkflowMetaData.class)
>>>   public static WorkflowMetaData workflowMetaData1;
>>>
>>
>> @DeclareParents(value="@gov.hhs.acf.aop.aspects.WorkflowAware *",
>>   defaultImpl=DefaultWorkflowMetaData.class)
>> public static WorkflowMetaData workflowMetaData1;
>>
>>>
>>> @Target(ElementType.TYPE)
>>> @Retention(RetentionPolicy.CLASS)
>>> public @interface WorkflowAware {
>>>
>>> }
>>>
>>> what I want is all classes which have WorkflowAware  annotaton  should
>>> implement WorkflowMetaData   please help me write the proper syntax
>>>
>>>
>>>
>>>@DeclareParents(value="gov.hhs.acf.web.pages.auditprog.*",
>>>defaultImpl=DefaultWorkflowMetaData.class)
>>>public static WorkflowMetaData workflowMetaData;
>>
>> This looks fine.
>>
>>>
>>>
>>> this works for me can I add  to this all classes  with annotation
>>> WorkflowAware  ?
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/using-%40declaredParents--for-annotations-tp20969256p20969256.html
>>> Sent from the AspectJ - users mailing list archive at Nabble.com.
>>>
>>> ___
>>> aspectj-users mailing list
>>> aspectj-users@eclipse.org
>>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>>
>> ___
>> aspectj-users mailing list
>> aspectj-users@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>>
>
> --
> View this message in context: 
> http://www.nabble.com/using-%40declaredParents--for-annotations-tp20969256p20969891.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] WebLogic 9.2 + AspectJ = boom?

2009-02-06 Thread Ramnivas Laddad
> The reason I am curious is the fact that the EAR deploys perfectly on one 9.2 
> cluster, but not another.

I am perhaps stating the oblivious, but there must be some difference
between the two clusters. That difference seems to be coming into the
play.

-Ramnivas

On Fri, Feb 6, 2009 at 1:36 PM, Michael Laccetti  wrote:
> I added the following to the WebLogic start command:
>
>
>
> -Dorg.aspectj.tracing.factory=default -Dorg.aspectj.tracing.enabled=true
> -Dorg.aspectj.tracing.messages=true
>
>
>
> I don't see any file matching *core* in the server directory, though.
>
>
>
> Mike
>
>
>
> From: aspectj-users-boun...@eclipse.org
> [mailto:aspectj-users-boun...@eclipse.org] On Behalf Of Andy Clement
> Sent: February-06-09 1:25 PM
> To: aspectj-users@eclipse.org
> Subject: Re: [aspectj-users] WebLogic 9.2 + AspectJ = boom?
>
>
>
> Oh - one thing - when you say you turned on AspectJ trace - how did you do
> that?  Did you put -verbose in the weaver option section of the aop.xml?  If
> not, then that may produce more debug information for us.  It would just be
> helpful to see the whole of the stack trace for the exception I think -
> which could come out in verbose mode or I'd expect to see it in a ajcore.*
>
> Andy.
>
> 2009/2/6 Michael Laccetti 
>
> I'm pretty confident – the Aspect and classes referenced by it are all
> packed in a common jar that is deployed in WEB-INF/lib (in turn part of an
> EAR).  The reason I am curious is the fact that the EAR deploys perfectly on
> one 9.2 cluster, but not another.
>
>
>
> I've pastebin'd some code – you can see the aspect in all of its hideous
> glory here: http://papernapkin.org/pastebin/view/4337/
>
>
>
> (Yes, I'm a noob with AOP.  Try not to burn me too much.)
>
>
>
> Mike
>
>
>
> From: aspectj-users-boun...@eclipse.org
> [mailto:aspectj-users-boun...@eclipse.org] On Behalf Of Andy Clement
> Sent: February-06-09 12:43 PM
> To: aspectj-users@eclipse.org
> Subject: Re: [aspectj-users] WebLogic 9.2 + AspectJ = boom?
>
>
>
> Hi Mike,
>
> Are you confident that
> 'com.cryptologic.bsg.model.communication.BsgResponseMessage' is on the
> classpath and accessible to the weaver?  Sometimes, as a 'last resort'
> AspectJ tries some of the imported prefixes on the front of types it is
> having trouble finding - to see if it can locate it.  A default imported
> prefix is 'java.lang'.  It might be that code which has added the rogue
> prefix, but the underlying symptom is likely to be that it couldn't find the
> 'com.cryptologic.bsg.model.communication.BsgResponseMessage' type.
>
> With the failure, is there an ajcore.* file produced containing more
> information?
>
> How is the BsgResponseMessage referenced? Are you binding it in a pointcut?
> Is that an annotation style pointcut '@Pointcut' or a code style pointcut
> 'pointcut'?
>
> cheers,
> Andy.
>
> 2009/2/6 Michael Laccetti 
>
> I deployed our application to a WebLogic 9.2 cluster, and ran into some
> problems.  In our development environment, everything worked okay, but in
> staging...  Not so much.  We use the same JDK, and the Spring Agent for LTW.
>  The application deploys okay, and the REST services function as expected,
> but the AOP stuff is non-operational.  There was no errors or warnings, so I
> turned on AspectJ logging.  Now, I see the following in the logs:
>
> 19:43:21.127 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default
> (self-tuning)' E Unable to find class
> 'java.lang.com.cryptologic.bsg.model.communication.BsgResponseMessage' in
> repository java.lang.ClassNotFoundException:
> java.lang.com.cryptologic.bsg.model.communication.BsgResponseMessage not
> found - unable to determine URL
>
> I'm not sure where the "java.lang" part is coming from - this isn't
> prepended on the development environment, since it works properly.  Anybody
> have a clue as to what is going on?
>
> Mike
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Why are you using LTW?

2009-02-10 Thread Ramnivas Laddad
Most use LTW as an easy way to get started with AspectJ (no build
script modifications). A few also need to weave into container classes
and LTW seems easier than performing offline binary weaving and
replacing original jars with woven jars. If that is not required, many
eventually move over to compile-time weaving.

I wouldn't worry about "official" compiler issue, since in the end the
VM sees essentially the same byte code regardless of the utilized
weaving mechanism.

-Ramnivas

On Tue, Feb 10, 2009 at 1:40 PM, Wim Deblauwe  wrote:
> Hi,
>
> I was wondering why other people use LTW (Load Time Weaving) instead of
> compile time?
>
> The main reason for me would be that with compile time you are not using the
> 'official' compiler of Java. Is this something I should worry about or is it
> just paranoia on my side?
>
> Another reason is that it seems attractive to be able to disable aspects
> when not needed, but so far I never felt the need to disable them.
>
> I am now thinking on switching to compile time, mainly to be able to do
> 'declare warning' and 'declare error', because I like to be able to lay down
> custom rules like this that are very specific to the project, but are easily
> enforced this way.
>
> regards,
>
> Wim
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Re: Why are you using LTW?

2009-02-14 Thread Ramnivas Laddad
That is because I did not evaluate this product...

Speaking of a hybrid solution, many project do apply a different kind
of hybrid scheme, where "core" aspect (such as dependency injection,
transaction management, and security--something you don't want to take
out) are woven using build-time weaving. For other aspects
(performance monitoring, debugging-oriented tracing, certain policy
enforcements) are woven using LTW. This allows baking in the core
aspects, while providing flexibility for other aspects.

-Ramnivas

On Sat, Feb 14, 2009 at 12:24 PM, William Louth (JINSPIRED.COM)
 wrote:
> I am surprised that Ramnivas did not point out that you can in effect have
> the best of both worlds with a hybrid solution which is extremely powerful
> when dealing with aspect libraries for diagnostics and resource monitoring
> as you can configure this without having to go through a complete build
> cycle. Test and Ops teams do not like to see two different versions of a
> library.
>
> http://www.infoq.com/news/2009/01/ramnivas-aop-choices
>
> JXInsight 5.6 extends it load-time weaving cache to now store the
> transformed bytecode image across application executions turning load-time
> weaving into binary weaving on consecutive executions. Our approach makes
> the switch between load-time weaving and binary weaving transparent - the
> first time an application is executed JXInsight will use load-time weaving
> the second time it uses binary weaving via the persisted transformed
> bytecode from the initial load-time weaving transformation. This reduces the
> (re)start-up time as well as the memory footprint - both which is extremely
> important in production environments.
>
> William
>
> Message: 1
> Date: Fri, 13 Feb 2009 14:06:02 -0500
> From: Dave Whittaker 
> Subject: Re: [aspectj-users] Why are you using LTW?
> To: aspectj-users@eclipse.org
>
> I agree with Ramnivas.  As an added benefit, if you're like me, you'll
> see a big speed increase in your app when you move over to compile
> time as well since runtime weaving can be costly.
>
> On Feb 10, 2009, at 4:36 PM, Ramnivas Laddad wrote:
>
>
>
> Most use LTW as an easy way to get started with AspectJ (no build
> script modifications). A few also need to weave into container classes
> and LTW seems easier than performing offline binary weaving and
> replacing original jars with woven jars. If that is not required, many
> eventually move over to compile-time weaving.
>
> I wouldn't worry about "official" compiler issue, since in the end the
> VM sees essentially the same byte code regardless of the utilized
> weaving mechanism.
>
> -Ramnivas
>
>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] within aspect or class

2009-02-18 Thread Ramnivas Laddad
You may do something like:
set(* *) && this(BaseClass)

-Ramnivas

On Wed, Feb 18, 2009 at 8:53 AM, Michael McCray  wrote:
> Hi All,
>
> When I use within(...), for an aspect that is introducing a method to
> another class, it seems that the within applies to the aspect as opposed to
> the class that a method is being introduced to.  Is there a way to specify
> an aspect applies to all "sets" of a class's fields example: set(*
> BaseClass+.*) from methods of that class hierarchy, whether they be locally,
> or introduced methods?
>
> Thanks,
> Mike
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Exceptions

2009-03-05 Thread Ramnivas Laddad
See another email thread for a solution.

In future, AspectJ may offer a better solution. See
https://bugs.eclipse.org/bugs/show_bug.cgi?id=240608

-Ramnivas

On Thu, Mar 5, 2009 at 5:01 PM, Andrica Silviu  wrote:
> Hello,
>  I was hoping you could help me with a problem I have:
> I want to instrument calls to InputStream.read(). This method migtht throw an 
> exception. The problem is that in the application I want to instrument 
> contains a class that
> implements InputStream but its read() method signature does not contain a 
> throw declaration. Thus, the compilation fails.
> I use an around advice which throws an IOException. If I declare the around 
> advice without the throws clause, then the application does not work 
> correctly.
>
> Thanks in advance,
>  Silviu
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Exceptions

2009-03-05 Thread Ramnivas Laddad
There is code in another thread today that allows throwing arbitrary
exception. Basically, your advice won't declare to throw any
exception, but using that code you throw checked exceptions anyway.
Please take a look.

-Ramnivas

On Thu, Mar 5, 2009 at 5:38 PM, Silviu ANDRICA  wrote:
> Hello,
>   thanks for the reply, but 'm too new to AspectJ to figure out how to do
> it...
> Do you have an example?
>
> Best regards,
>   Silviu ANDRICA
> Ramnivas Laddad wrote:
>
> See another email thread for a solution.
>
> In future, AspectJ may offer a better solution. See
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=240608
>
> -Ramnivas
>
> On Thu, Mar 5, 2009 at 5:01 PM, Andrica Silviu 
> wrote:
>
>
> Hello,
>  I was hoping you could help me with a problem I have:
> I want to instrument calls to InputStream.read(). This method migtht throw
> an exception. The problem is that in the application I want to instrument
> contains a class that
> implements InputStream but its read() method signature does not contain a
> throw declaration. Thus, the compilation fails.
> I use an around advice which throws an IOException. If I declare the around
> advice without the throws clause, then the application does not work
> correctly.
>
> Thanks in advance,
>  Silviu
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Does target() work when calling static methods

2009-03-09 Thread Ramnivas Laddad
That is correct interpretation. target() and this() work only for
non-static methods.

-Ramnivas

On Mon, Mar 9, 2009 at 4:16 AM, Jochen Wuttke  wrote:
> Hi,
>
> I have an aspect that does not do what I expect. The pointcut looks like
> this:
>
>    pointcut initMethod(): target(JspFactory)
>        && call(* javax.servlet.jsp.JspFactory.setDefaultFactory(..));
>
> The advice addressed by this joinpoint doesn't get woven and I start
> suspecting that this is because #setDefaultFactory is static, and hence
> there is no target object. Is that a correct interpretation or am I missing
> something else?
>
> Jochen
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] How to delete a method

2009-03-16 Thread Ramnivas Laddad
You can't delete method, but advise it to bypass the original code:

void around() : execution(* MyClass.finalize()) {
  ... no proceed() here
}

-Ramnivas

On Mon, Mar 16, 2009 at 9:16 PM,   wrote:
>
> Hi
>
> I am working with a third party jar that seems to have classes that override
> the finalize() method, which seems to be causing GC issues.
>
> Is it possible to delete the finalize() methods using AspectJ?
>
> Thanks
> G. Patel
>
> 
>
> The information contained in this communication (including any attachments
> hereto) is confidential and is intended solely for the personal and
> confidential use of the individual or entity to whom it is addressed. If the
> reader of this message is not the intended recipient or an agent responsible
> for delivering it to the intended recipient, you are hereby notified that
> you have received this communication in error and that any review,
> dissemination, copying, or unauthorized use of this information, or the
> taking of any action in reliance on the contents of this information is
> strictly prohibited. If you have received this communication in error,
> please notify us immediately by e-mail, and delete the original message.
> Thank you
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Type introspection using joinpoints

2009-03-22 Thread Ramnivas Laddad
Take a look at how the Spring framework uses classpath scanning to
implement a similar idea. In its case, it uses classpath scanning
along with autowiring to compose the application.

-Ramnivas

On Sun, Mar 22, 2009 at 4:38 AM, Ruben Vermeersch  wrote:
> Hi,
>
> I am currently working on a masters thesis on aspect-oriented middleware
> platforms. In these platforms, services are usually composed with the
> application, by means of annotations. This makes aspects (and aspectj in
> particular, which I have chosen to be my platform to build upon) a
> perfect fit for inserting the middleware services into the application.
>
> The grand idea is that I separate each middleware service into an small
> module. Upon launching an application, dependency analysis is performed
> and the application is combined with exactly its needs, using load-time
> weaving. The effect being that the application runs in a just-in-time
> created middleware architecture, fit to its needs.
>
> This works fine for some cases, but in others I have found the joinpoint
> model lacking, or I am still looking for a good way to handle them.
>
> As an example: Declaring @WebService on a class might imply that this
> class is accessible as a SOAP service.
>
> To provide this SOAP endpoint, I have to register this class with the
> web stack. This has to occur when starting the application, so I need a
> way to match all classes annotated with @WebService and act upon them.
>
> If I understand correctly though, load-time weaving is only performed
> when actually loading the class, so there's no way to find these classes
> until they are invoked.
>
> Does anyone know a solution to this problem? Is it possible to do type
> introspection using joinpoints?
>
> All help appreciated!
>
> Thanks already,
>   Ruben Vermeersch
>
>
> --
> Ruben Vermeersch (rubenv)
> http://www.savanne.be/
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] pertarget instantiation && within

2009-04-19 Thread Ramnivas Laddad
I am not sure if I understand the question. What is the use case you
are trying to implement?

-Ramnivas

2009/4/18 Adam Przybylek :
> aspect XYZ pertarget(target(SomeClass) && !within(XYZ)) {
>  protected SomeClass sm;
>
>  public XYZ() {
>    sm = new SomeClass();
>  }
> }
>
> I would like not to instantiate the XYZ aspect when the object referred by
> sm is created. What do I do wrong?
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] AspectJ 1.6.4 released

2009-05-09 Thread Ramnivas Laddad
Can everyone on the list (especially those who want to/may want to use
Maven with AspectJ) please vote for the bug that Simone has added
(http://jira.codehaus.org/browse/MAVENUPLOAD-2433). Hopefully, it will
help in getting attention and a quicker resolution.

Thanks.

-Ramnivas

On Wed, Apr 22, 2009 at 11:27 AM, Simone Gianni  wrote:
> Hi Wim,
> just a followup to have you and others Maven users up to date. The modified
> ant script works correctly and uploads artifacts to the rsync repo. It will
> also be possible to a final user to modify deployment properties to deploy a
> modified or instable version of ApsectJ to it's own Maven repo. There are a
> few corner to round, but basically it is working.
>
> I just opened a request to Maven folks to add it to the list of rsync-ed
> spaces : http://jira.codehaus.org/browse/MAVENUPLOAD-2433
>
> We now just have to wait for them to add the rsync, and we will hopefully
> never have to wait more than 4 hours to have new releases of AspectJ on
> Maven in the future.
>
> Simone
>
> Wim Deblauwe wrote:
>>
>> ok, thank you for the effort already!
>>
>> 2009/4/16 Andy Clement > >
>>
>>    Simone has done the magic for my build script, I just need to find
>>    some time to run it - i will try and do it either today or tomorrow.
>>
>>    Not much longer Wim ! :)
>>
>>    Andy.
>>
>>    2009/4/16 Wim Deblauwe >    >:
>>    > Any updates on this?
>>    >
>>    > 2009/4/7 Simone Gianni >    >
>>    >>
>>    >> Hi Andy,
>>    >> I usually use the maven deploy plugin to send stuff to
>>    repositories, cause
>>    >> it generates the correct metadata xml files, merging previous
>>    ones if
>>    >> necessary. Your ant script is useful cause it generates also
>>    sources and
>>    >> javadoc jars. Can you send it to me? I will integrate it with
>>    calls to maven
>>    >> deploy, so that it automatically uploads stuff to the rsync
>>    area I've set
>>    >> up.
>>    >>
>>    >> Simone
>>    >>
>>    >> Andy Clement wrote:
>>    >>>
>>    >>> Hi Simone,
>>    >>>
>>    >>> that would be great !  I have already written the Ant scripts that
>>    >>> build a repo suitable for syncing (poms/digests/etc) - you can
>>    access
>>    >>> the already existing repo's for 1.6.3 and 1.6.4 through the
>>    jiras I
>>    >>> linked to earlier.
>>    >>>
>>    >>> Either you can build the repos using the Ant scripts with each
>>    >>> release, or if you let me have access I can publish them to
>>    your space
>>    >>> in some way and then maven can pick them up automagically.
>>    >>>
>>    >>> It'd be great to get them in more quickly as I'm sure we get
>>    many of
>>    >>> our downloads through maven.
>>    >>>
>>    >>> cheers,
>>    >>> Andy.
>>    >>>
>>    >>>
>>    >>> 2009/4/6 Simone Gianni >    >:
>>    >>>
>>    
>>     If no one raise any objection, I'd like to volunteer  to be
>>    "unofficial"
>>     maintainer of AspectJ on Maven. That means I'll set up an rsync
>>     accessible
>>     space, upload there AspectJ jars with pom files and the like,
>>    ask for it
>>     to
>>     be added to the list of repositories synced from the main
>>    repository,
>>     try to
>>     maintain it as update as possible :)
>>    
>>     It will not be super-fast, but will be faster than waiting
>>    for Maven
>>     guys to
>>     pick it up.
>>    
>>     I'll setup the rsync space and prepare the AspectJ stuff in
>>    it, for
>>     1.6.3
>>     and 1.6.4, if we all agree I'll ask for it to be added to the
>>    list.
>>    
>>     Simone
>>    
>>     Andy Clement wrote:
>>    
>>    >
>>    > As before - it is somewhere I can put them such that maven can
>>    > automatically sync (rsync or svn).  I don't have anywhere on the
>>    > eclipse servers to do this.  I'm open to suggestions.
>>    >
>>    > The 1.6.3 and 1.6.4 repos are all built ready, but I have to go
>>    > through the JIRA process to get them in:
>>    >
>>    > http://jira.codehaus.org/browse/MAVENUPLOAD-2411
>>    > http://jira.codehaus.org/browse/MAVENUPLOAD-2421
>>    >
>>    > cheers,
>>    > Andy.
>>    >
>>    > 2009/4/6 Simone Gianni >    >:
>>    >
>>    >
>>    >>
>>    >> Same here :D
>>    >>
>>    >> What's needed to have AspectJ releases more or less
>>    automatically
>>    >> updated
>>    >> on
>>    >> Maven?
>>    >>
>>    >> Simone
>>    >>
>>    >> Wim Deblauwe wrote:
>>    >>
>>    >>
>>    >>>
>>    >>> I was afraid to ask, but you know I want it too :)
>>    >>>
>>    >>> regards,
>>    >>>
>>    >>> Wim
>>    >>>
>>    >>> 2009/4/5 Olle Hallin >    
>>    >

Re: [aspectj-users] AspectJ 1.6.4 released

2009-05-09 Thread Ramnivas Laddad
Looks like Carlos Sanchez just fixed this (thanks, Carlos).

-Ramnivas

On Sat, May 9, 2009 at 5:04 PM, Ashley Williams  wrote:
> Looks like yes:
> https://svn.apache.org/repos/asf/maven/repository-tools/trunk/src/bin/synchronize/m2-sync/sync.csv
>
> Should be picked up automatically by rsync in the next 24 hours at most.
>
> On 9 May 2009, at 21:59, Andrew Eisenberg wrote:
>
>> I see the issue as Closed/Fixed.  Is it?
>>
>> On Sat, May 9, 2009 at 12:23 PM, Wim Deblauwe 
>> wrote:
>>>
>>> Yes, it does take quite some time. I already voted on the issue and added
>>> links to the now obsolete other requests, but no activity so far.
>>> Strange,
>>> because I added upload requests before and they used to react much
>>> faster.
>>>
>>> regards,
>>>
>>> Wim
>>>
>>> 2009/5/9 Ramnivas Laddad 
>>>>
>>>> Can everyone on the list (especially those who want to/may want to use
>>>> Maven with AspectJ) please vote for the bug that Simone has added
>>>> (http://jira.codehaus.org/browse/MAVENUPLOAD-2433). Hopefully, it will
>>>> help in getting attention and a quicker resolution.
>>>>
>>>> Thanks.
>>>>
>>>> -Ramnivas
>>
>> ___
>> aspectj-users mailing list
>> aspectj-users@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] AspectJ 1.6.4 released

2009-05-10 Thread Ramnivas Laddad
I now see it in the Maven central repository.

Thanks Andy, Simone, and Calros for taking care of this.

-Ramnivas

On Sat, May 9, 2009 at 5:11 PM, Ramnivas Laddad
 wrote:
> Looks like Carlos Sanchez just fixed this (thanks, Carlos).
>
> -Ramnivas
>
> On Sat, May 9, 2009 at 5:04 PM, Ashley Williams  wrote:
>> Looks like yes:
>> https://svn.apache.org/repos/asf/maven/repository-tools/trunk/src/bin/synchronize/m2-sync/sync.csv
>>
>> Should be picked up automatically by rsync in the next 24 hours at most.
>>
>> On 9 May 2009, at 21:59, Andrew Eisenberg wrote:
>>
>>> I see the issue as Closed/Fixed.  Is it?
>>>
>>> On Sat, May 9, 2009 at 12:23 PM, Wim Deblauwe 
>>> wrote:
>>>>
>>>> Yes, it does take quite some time. I already voted on the issue and added
>>>> links to the now obsolete other requests, but no activity so far.
>>>> Strange,
>>>> because I added upload requests before and they used to react much
>>>> faster.
>>>>
>>>> regards,
>>>>
>>>> Wim
>>>>
>>>> 2009/5/9 Ramnivas Laddad 
>>>>>
>>>>> Can everyone on the list (especially those who want to/may want to use
>>>>> Maven with AspectJ) please vote for the bug that Simone has added
>>>>> (http://jira.codehaus.org/browse/MAVENUPLOAD-2433). Hopefully, it will
>>>>> help in getting attention and a quicker resolution.
>>>>>
>>>>> Thanks.
>>>>>
>>>>> -Ramnivas
>>>
>>> ___
>>> aspectj-users mailing list
>>> aspectj-users@eclipse.org
>>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>> ___
>> aspectj-users mailing list
>> aspectj-users@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] AspectJ compile-time weaving in Maven not working

2009-05-25 Thread Ramnivas Laddad
Nothing jumps out from your Maven snippet. I am not a Maven expert,
but the following snippet works for me:



org.codehaus.mojo
aspectj-maven-plugin



compile



   1.5
   1.5



org.springframework

spring-aspects


   






Give it a try.

Also, how do you bootstrap Spring's application context?

-Ramnivas

On Sat, May 23, 2009 at 7:12 AM, Robert Campbell  wrote:
> Hello,
>
> I was using AspectJ LTW in my Spring application to inject
> dependencies in objects never created outside the Spring bean-factory.
> I have decided to switch to CTW, but I can't seem to get it working
> correctly in Eclipse or Maven. For Maven, I generally followed this
> guide: 
> http://www.chrissearle.org/blog/technical/spring_aspects_configurable_and_compile_time_weaving_using_maven
>
> I added aspectjrt-1.6.4 and spring-aspects-2.5.4 as dependencies, plus:
>
>        
>                
>                        
>                    
>                        org.codehaus.mojo
>                        aspectj-maven-plugin
>                        1.1
>                        
>                                1.6
>                                true
>                            
>                                
>                                                            
> org.springframework
>                                                            
> spring-aspects
>                                
>                            
>                            true
>                        
>                        
>                            
>                                
>                                    compile
>                                
>                            
>                       
>                   
>
> Unfortunately, my dependencies never get injected when I boot up. I
> also didn't notice any AspectJ-specific messages during the Maven
> compile.
>
> In Eclipse, I use the AspectJ plugin. I right-clicked on my existing
> project and selected something like "Add AspectJ Capability" or
> whatever it was. It then appeared with the little A on the icon. From
> this point I tried building and running the projects as normal, and no
> dependencies were injected. I then tried adding spring-aspects.jar to
> my Aspects Path, but that didn't help either.
>
> Any suggestions would be very welcome.
>
> Rob
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Please help with weaving not finding my class problem

2009-06-08 Thread Ramnivas Laddad
It appears that for some reason the classes to be woven are
(sometimes) getting loaded before Spring's application context is
initialized (which configures load-time weaving). You could try two
things (besides figuring out why is that class getting loaded sooner
and inconsistently).
1. Try AspectJ's load-time weaver i.e. use
-javaagent:/path/to/aspectjweaver.jar instead of spring-agent.jar (and
remove ).
2. Use compile-time weaving (it works). Recently there was a thread
showing how to configure Maven, so that may be a good place to start.

-Ramnivas

On Mon, Jun 8, 2009 at 7:35 AM,
fe.character.guide wrote:
> Hi everyone,
>
> I have a big problem using AspectJ and Spring, although I suspect this
> problem may be AspectJ-specific.  However, I can't be sure.
>
> I am trying to use Spring's @Configurable to add dependency injection to my
> domain objects. The reason I don't think I have a Spring issue is that I
> have this feature working fine - the one and only object that is being
> injected is working with the Spring aspect that comes out of the box.
>
> The problem I am having is that sometimes the AspectJ weaver does not "see"
> the object that I need weaved. When I turn on DEBUG in log4j, I sometimes
> see that my class isn't in the list of classes that the weaver is iterating
> through when it starts up. Do you know how this could happen? My class is
> obviously in the classpath, because it gets used in the tests or in the web
> container afterward.
>
> This happens in a variety of cases. When I test a class in
> project.domain.subpackage, the weaving works fine. If I even test the entire
> package with multiple test classes, it works great. However, when I test all
> the Test classes in project.domain.*, the weaver cannot find my class
> anymore. The same is true testing everything in project.*,
> project.controllers.*, etc.
>
> Before you say anything, I am using the exact jvm settings when I run JUnit,
> and the same thing happens when I test in Maven as well (so it's not IDE
> specific).
>
> This problem is annoying enough, but sometimes Tomcat calling aspectJ
> doesn't see the class either. I have to shut down and start up the server,
> hoping that each time aspectJ will weave the class I need it to. Right now,
> it's about a 30% success rate. Once AspectJ weaves my class, everything is
> golden.
>
> I can only assume that this is all the same problem. What could be causing
> this?
>
> These are the arguments I am passing into the JVM:
>
> -Xms256m -Xmx512m -javaagent:"C:\Documents and
> Settings\Username\.m2\repository\org\springframework\spring-agent\2.5.6.SEC01\spring-agent-2.5.6.SEC01.jar"
>
> This is my aop.xml:
>
> 
>     
>         
>         
>     
> 
>
> These are the spring application context lines to get it to work:
>
>     
>     
>     
>      base-package="jobprep.dao,jobprep.service,jobprep.domain.openended" />
>
> I really don't see what I'm doing wrong, and if I can't get this ramdom
> behaviour fixed... then I think I'm going to have to dump AOP/aspectJ
> completely. I really don't want to.
>
> Has anyone used @Configurable with compile-time weaving to good effect? If I
> can do this at compile time, I would LOVE to. I am only weaving 1 class, so
> the hit to compile time is a non-issue here.
>
> Please help.
>
> Ken
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Intercepting constructors that handle exceptions

2009-06-12 Thread Ramnivas Laddad
I am not entirely sure about the question, but I think you need
something along the following lines:

void around(Object uc, File f) throws Exception : Test(uc,f) {
   try {
proceed(uc, f);
   } catch (Exception ex) {
 ... your exception processing logic
  }
}

Or perhaps this:
after() throwing(ex) : Test(uc,f) {
 ... your exception processing logic
}

-Ramnivas

2009/6/12 João Paulo Sabino de Moraes :
> Hi Folks,
>
> I've made a pointcut that intercepts a constructor,:
>
> pointcut Test(Bank uc, File f) : execution(public Bank.new(File)) && args(f)
> && this(uc);
>
> the constructor handles an exception...but I don't know how to intercept it.
> I 've tried sorrounding proceed() whit try catch but it didn't run...
>
>
>     void around(Object uc, File f) throws Exception : Test(uc,f) {
>         
>     }
>
> so what goes inside around ?
>
> Thanks!!
>
> jp
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] using aspectj to check for correctness of the code when using HTTPSession

2009-06-13 Thread Ramnivas Laddad
Inline...

On Sat, Jun 13, 2009 at 10:02 AM, Jim Sellers wrote:
> Hello all.
>
> I'm new to writing AOP code and have only used it for common uses like
> transactions (in spring).  Please forgive me if I mess up the AOP terms, but
> feel free to correct me. ;-)
>
> Now I'm trying to solve an issues and I wanted to see if you guys have any
> advice about if I'm on the right track, "this is already done with lib X",
> ...  (aside: I use maven / eclipse for the projects)
>
> Background for the problem I'm trying to solve:
> I am trying to put in some AOP code that will intercept calls to
> HTTPSession.setAttribute(...).  Using this we will be able to verify that
> any code being put into session is serializable.  Also, for any object that
> implments HTTPSession, we'll trap the state of the object being set (using
> HashcodeBuilder to generate a hash), and then at the end of the test verify
> the the object in our mock session has not changed (has the same hashcode).
> In this way we are hoping to be able to verify if an application is
> clusterable without a tedious class by class inspection.
>
> Here are the issues that I currently have:
> 1) I'm a little confused on what code should be "woven" - the creating of a
> mock HTTPSession will only happen in testing code (src/test/java) while the
> *calls* to setAttribute(..) that I care about will only happen in prod code
> (src/main/java)

Which code is calling HttpSession.setAttribute()? If you control that
code (in production; in tests, you clearly control the calls).
Assuming that you control calls in production code as well, call seems
to be the correct join point in either case.

>
> 2) I only want to add this weaving for the tests, I don't want these checks
> making it into code running in production or for the project to have a
> non-test dependency on this code

You can have two build targets--one that includes aspects and other
that doesn't.

>
> 3) I think that I need to add a joinpoint (pointcut ?) to an "after return"
> on my @Test methods in order to check the state of the session.  Most of the
> examples are done using method name matching.  Can I mix a pattern match
> (public void test*) and an annotation, or is that 2 seperate join points?
> http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations-pointcuts-and-advice.html

You can write a pointcut that can mix name patterns with annotations.

>
> 4) in order to check the state of the mock session at the end of the test,
> I think that I will need to keep a reference to them in the advice.  Is this
> normally done or is there something wrong with this approach?  Would it need
> to be a static member variable of the advice (I'm not clear of the lifecycle
> / state of the advice yet)

You could advise mock creation to keep references to those in a
ThreadLocal member of the aspect. You can also use the percflow()
association for the aspect (but, since you are just starting with
AspectJ, you may not want to venture into that area just yet). Then
you may advise the completion of test methods (an after returning
advice) to verify all mocks for which the aspect has a reference
(added by the earlier mentioned advice). It should also clear the
references as it checks.

>
> Thanks for your time in even reading this far. ;-)  Any help would be
> wonderful.
>
> Thanks for your time,
> Jim
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] is the source and target properties mandatory on the iajc task

2009-06-25 Thread Ramnivas Laddad
This is a manifestation of another underlying issue outlined in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=129989.
For now, you need to specify target and sources.

As an aside, I think specifying an explicit target and source level is a
good idea in any case. Even
http://ant.apache.org/manual/CoreTasks/javac.html mentions that "We highly
recommend to always specify this attribute.". So the only real issue here is
the asymmetry between  and  task in Ant.

-Ramnivas

On Thu, Jun 25, 2009 at 9:47 AM, antofmr  wrote:

>
> I am hoping not to have to specify the source or target properties for the
> iajc task. I have the correct jdk in my path so I was hoping it would just
> use properties for the underlying jdk found in the path.
>
>
> --
> View this message in context:
> http://www.nabble.com/is-the-source-and-target-properties-mandatory-on-the-iajc-task-tp24203603p24203603.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] is the source and target properties mandatory on the iajc task

2009-06-25 Thread Ramnivas Laddad
I agree that the default  behavior should match that of 
(although, we will need to be careful here, since this will break existing
builds). I was just pointing that relying on default behavior isn't a best
practice. For example, when we build the Spring Framework, we explicitly set
the source and target to 1.5, even though my machine has only Java 6
installed on it. Essentially, building an application need to consider
machines on which the application is going to be deployed and not the local
machine.
-Ramnivas

On Thu, Jun 25, 2009 at 11:15 AM, antofmr  wrote:

>
> Hi Ramnivas
>
> Thanks for your help. I just have one query. Would it not be better if the
> ajc had the capability to use the source and target available on the local
> machine in stead of being hard coded to use one .
>
> Anthony
>
>
> antofmr wrote:
> >
> > I am hoping not to have to specify the source or target properties for
> the
> > iajc task. I have the correct jdk in my path so I was hoping it would
> just
> > use properties for the underlying jdk found in the path.
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/is-the-source-and-target-properties-mandatory-on-the-iajc-task-tp24203603p24205195.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] AspectJ run-time licensing

2009-07-13 Thread Ramnivas Laddad
I am not a lawyer, but I do not think there are any restrictions on
redistributing aspectjrt.jar (or any of the the AspectJ jars). For example,
aspectjrt.jar is distributed with many SpringSource products (open source as
well as commercial).
-Ramnivas

On Mon, Jul 13, 2009 at 1:59 PM, Jacob Bower  wrote:

> Hi,
>
> I'm developing a Java library which will be distributed in jar form. In
> developing this library I have used AspectJ 1.6.5 and the resulting binary
> will include code woven in by the ajc compiler. To distribute this library I
> will need to distribute the AspectJ run-time. Users of the library will not
> need to use ajc to compile their code as all relevant joinpoints are
> internal to the library.
>
> In this case, what are the restrictions on distributing the AspectJ
> run-time. Can I include the aspectj.jar (or its conents) in my own jar with
> no notices?
>
> I've consulted the AspectJ FAQ on this matter, but I am unclear on how I'm
> supposed to preserve the warranty disclaimers in the license.
>
> Thanks,
> Jacob
>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Weaving on UI paint methods isn't working for me :f

2009-07-14 Thread Ramnivas Laddad
The problem is that the join points belong to the javax package that you do
not weave. Try call() pointcut instead of execution().
-Ramnivas

On Tue, Jul 14, 2009 at 9:52 AM, FraGMenT  wrote:

> Hello.
>
>
> Hello, I want to execute some code using aspectj before any element of the
> UI is drawn.
>
> To do that, I define the following pointcut:
>
> pointcut gonnaBeDrawn() :
> execution(public void java.awt.Component+.repaint()) ||
> execution(public void java.awt.Component+.update(Graphics))||
> execution(public void java.awt.Component+.paint(Graphics))||
> execution(public void java.awt.Component+.paintAll(Graphics));
>
> Then the advice:
>
> before() : gonnaBeDrawn()
> {
> System.out.println("Component drawn!");
> }
>
> As far as I know this should do the work, but I don't get any expected
> message on the console. I get the following warning at compile time though.
>
> *advice defined in main.Prueba has not been applied
> [Xlint:adviceDidNotMatch]* (The file's name is main.Prueba.aj)
>
> Other aspects are working fine, so I think it's not a problem of
> environment configuration.
> What am I doing wrong? Do I need to do *Load Time Weaving* or something?
>
>
> Thanks for your time! ^^'
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Weaving on UI paint methods isn't working for me :f

2009-07-14 Thread Ramnivas Laddad
Thinking more, call() may not work either, since those calls are most likely
in the javax package too. You may have to go for LTW with the option to
weave into javax types. Even this has potential issues (LTW is as good as
the chance it gets to weave in the required types).
-Ramnivas

On Tue, Jul 14, 2009 at 10:40 AM, Ramnivas Laddad
wrote:

> The problem is that the join points belong to the javax package that you do
> not weave. Try call() pointcut instead of execution().
> -Ramnivas
>
> On Tue, Jul 14, 2009 at 9:52 AM, FraGMenT  wrote:
>
>> Hello.
>>
>>
>> Hello, I want to execute some code using aspectj before any element of the
>> UI is drawn.
>>
>> To do that, I define the following pointcut:
>>
>> pointcut gonnaBeDrawn() :
>> execution(public void java.awt.Component+.repaint()) ||
>> execution(public void java.awt.Component+.update(Graphics))||
>> execution(public void java.awt.Component+.paint(Graphics))||
>> execution(public void java.awt.Component+.paintAll(Graphics));
>>
>> Then the advice:
>>
>> before() : gonnaBeDrawn()
>> {
>> System.out.println("Component drawn!");
>> }
>>
>> As far as I know this should do the work, but I don't get any expected
>> message on the console. I get the following warning at compile time though.
>>
>> *advice defined in main.Prueba has not been applied
>> [Xlint:adviceDidNotMatch]* (The file's name is main.Prueba.aj)
>>
>> Other aspects are working fine, so I think it's not a problem of
>> environment configuration.
>> What am I doing wrong? Do I need to do *Load Time Weaving* or something?
>>
>>
>> Thanks for your time! ^^'
>>
>> ___
>> aspectj-users mailing list
>> aspectj-users@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] JBOSS, LTW and SDK1.4.2

2009-07-15 Thread Ramnivas Laddad
This looks like a classloader issue. The aj.bat approach was meant mainly
for standalone applications and hasn't worked well with app/web servers due
to the classloading schemes they employ.
Can you try running the same server on Java 5 or 6 and pass it the
-javaagent:/path/to/aspectjweaver.jar.

-Ramnivas

On Fri, Jul 10, 2009 at 10:32 AM, Johnson Lu  wrote:

>  Greetings:
>
>
>
> I have been struggling to get JBOSS 4.0.5(on SDK1.4.2) to run with AspectJ,
> but thus far I have no success.
>
>
>
> The run.bat startup in JBOSS\bin has been patched to conformed to what is
> in aj.bat (i.e setting the system class loader, and adding aj.class.path and
> aj.aspect.path as System parameters). If I don’t include run.jar in the
> classpath Jboss will always terminate with something like this: (run.jar is
> in –Daj.class.path):
>
>
>
> Failed to boot JBoss:
>
> java.lang.NullPointerException
>
> at org.jboss.Main.boot(Main.java:112)
>
> at org.jboss.Main$1.run(Main.java:490)
>
> at java.lang.Thread.run(Thread.java:534)
>
>
>
> If I do put run.jar in the classpath, I get this:
>
>
>
> java.lang.NoClassDefFoundError: org/jboss/mx/util/Serialization
>
> at javax.management.ObjectName.(ObjectName.java:101)
>
> at
> org.jboss.mx.util.ObjectNameFactory.create(ObjectNameFactory.java:48)
>
> at org.jboss.system.server.ServerImpl.(ServerImpl.java:82)
>
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>
> at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
>
> at java.lang.Class.newInstance0(Class.java:308)
>
> at java.lang.Class.newInstance(Class.java:261)
>
> at
> org.jboss.system.server.ServerLoader.createServer(ServerLoader.java:288)
>
> at org.jboss.system.server.ServerLoader.load(ServerLoader.java:267)
>
> at org.jboss.Main.boot(Main.java:194)
>
> at org.jboss.Main$1.run(Main.java:490)
>
> at java.lang.Thread.run(Thread.java:534)
>
> Press any key to continue . . .
>
>
>
> Can anyone shed some light, helpful hints on my plight?
>
>
>
> Thanks.
>
>
>
> J.Lu
>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] JBOSS, LTW and SDK1.4.2

2009-07-16 Thread Ramnivas Laddad
There are ways (for example, see
http://rbodkin.blogs.com/ron_bodkins_blog/2005/10/websphere_loadt.html), but
they depend on application-server specific knowledge. Since JDK1.4 has been
end-of-lifed, such an implementation hasn't been a priority.
-Ramnivas

On Thu, Jul 16, 2009 at 8:03 AM, Johnson Lu  wrote:

>  Hi Ramnivas:
>
>
>
> Thanks for writing back.  Unfortunately it is impossible for us to run with
> Java 5 nor Java 6 due to constraints placed by our customers.  With Java 5
> and javaagent we have very little complaints.  So there are no ways around
> for App Servers using Java 4?
>
>
>
> Thanks.
>
>
>
> J.Lu
>
>
>
>
>
>
>
> *From:* aspectj-users-boun...@eclipse.org [mailto:
> aspectj-users-boun...@eclipse.org] *On Behalf Of *Ramnivas Laddad
> *Sent:* Wednesday, July 15, 2009 7:44 PM
> *To:* aspectj-users@eclipse.org
> *Subject:* Re: [aspectj-users] JBOSS, LTW and SDK1.4.2
>
>
>
> This looks like a classloader issue. The aj.bat approach was meant mainly
> for standalone applications and hasn't worked well with app/web servers due
> to the classloading schemes they employ.
>
>
>
> Can you try running the same server on Java 5 or 6 and pass it the
> -javaagent:/path/to/aspectjweaver.jar.
>
>
>
> -Ramnivas
>
> On Fri, Jul 10, 2009 at 10:32 AM, Johnson Lu 
> wrote:
>
> Greetings:
>
>
>
> I have been struggling to get JBOSS 4.0.5(on SDK1.4.2) to run with AspectJ,
> but thus far I have no success.
>
>
>
> The run.bat startup in JBOSS\bin has been patched to conformed to what is
> in aj.bat (i.e setting the system class loader, and adding aj.class.path and
> aj.aspect.path as System parameters). If I don’t include run.jar in the
> classpath Jboss will always terminate with something like this: (run.jar is
> in –Daj.class.path):
>
>
>
> Failed to boot JBoss:
>
> java.lang.NullPointerException
>
> at org.jboss.Main.boot(Main.java:112)
>
> at org.jboss.Main$1.run(Main.java:490)
>
> at java.lang.Thread.run(Thread.java:534)
>
>
>
> If I do put run.jar in the classpath, I get this:
>
>
>
> java.lang.NoClassDefFoundError: org/jboss/mx/util/Serialization
>
> at javax.management.ObjectName.(ObjectName.java:101)
>
> at
> org.jboss.mx.util.ObjectNameFactory.create(ObjectNameFactory.java:48)
>
> at org.jboss.system.server.ServerImpl.(ServerImpl.java:82)
>
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>
> at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
>
> at java.lang.Class.newInstance0(Class.java:308)
>
> at java.lang.Class.newInstance(Class.java:261)
>
> at
> org.jboss.system.server.ServerLoader.createServer(ServerLoader.java:288)
>
> at org.jboss.system.server.ServerLoader.load(ServerLoader.java:267)
>
> at org.jboss.Main.boot(Main.java:194)
>
> at org.jboss.Main$1.run(Main.java:490)
>
> at java.lang.Thread.run(Thread.java:534)
>
> Press any key to continue . . .
>
>
>
> Can anyone shed some light, helpful hints on my plight?
>
>
>
> Thanks.
>
>
>
> J.Lu
>
>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Misunderstanding : execution pointcut with thisJoinPointStaticPart and thisEnclosingJoinPointStaticPart

2009-07-21 Thread Ramnivas Laddad
This is the expected behavior. For an execution join point, there is no
lexical enclosing join point, hence it is the same as
thisJoinPointStaticPart.
-Ramnivas

On Tue, Jul 21, 2009 at 1:11 AM, wrote:

>  I misunderstand the returns of ( I construct a StringBuffer)  :
>
>
>
> append(*thisJoinPointStaticPart*
> .getSignature().getDeclaringTypeName()).append(".").append(*
> thisJoinPointStaticPart*.getSignature().getName())
>
> and
>
> append(*thisEnclosingJoinPointStaticPart*
> .getSignature().getDeclaringTypeName()).append(".").append(*
> thisEnclosingJoinPointStaticPart*.getSignature().getName())
>
>
>
> that are the same with and execution pointcut ( a call pointcut gives the
> parent of the called method).
>
>
>
> Is it normal ? or *thisEnclosingJoinPointStaticPart *has no effect with an
> execution pointcut?
>
>
>
> Cordialement / Best regards
>
>
>
> *Jean-Louis Pasturel*
> jeanlouis.pastu...@
>
>
>
>
>  *
> This message and any attachments (the "message") are confidential and
> intended solely for the addressees.
> Any unauthorised use or dissemination is prohibited.
> Messages are susceptible to alteration.
> France Telecom Group shall not be liable for the message if altered,
> changed or falsified.
> If you are not the intended addressee of this message, please cancel it
> immediately and inform the sender.
> 
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Softened exceptions

2009-07-21 Thread Ramnivas Laddad
You should be able to do the following:
declare soft : Exception && ! InterruptedException: ;

-Ramnivas


On Tue, Jul 21, 2009 at 7:55 AM, Ashley Williams  wrote:

> Hi,
>
> When using the declare soft feature, is it possible to exclude certain
> exceptions?
> I would like to soften all Exception types except for InterruptedException.
>
> Cheers
> - Ashley
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] AspectJ runtime weaving aspects not declared in aop.xml

2009-07-29 Thread Ramnivas Laddad
I agree that the error message from Spring about the treatment of aspects
compiled with 'ajc' could be improved. If you can file a JIRA issue (for
Spring), that will be great.
As for LTW picking up @Aspect aspects, it shouldn't really happen; only
aspects that are declared in aop,xml (and variations of it such as
aop-ajc.xml) are woven in as long as no exclude statements exclude it. So
something else is going on here. Do you have another aop.xml (or aop-ajc.xml
created by 'ajc -outxml' option). What happens when you explicitly exclude
the aspect?

-Ramnivas

On Wed, Jul 29, 2009 at 7:41 PM, Satish Terala wrote:

> I have an aop.xml that declares certain aspects that I would like to be
> woven by AspectJ LTW. I also have other aspects that I would like Spring
> to apply (i want regualr proxy based mechanism for these).
>
> Spring has a restriction that it will not apply any aspects that have
> been woven by AspectJ Compiler.It does these by checking for any fields
> that start with 'ajc$'.
>
> After struggling to understand why my Aspect that was not declared in
> aop.xml was not getting applied, I tried to apply the aspect
> programatically using
> AspectJProxyFactory aspectJProxyFactory=new AspectJProxyFactory(bean);
> aspectJProxyFactory.addAspect(DtExceptionHandlerAdvice.class);
>
> Then I get the exception
> org.springframework.aop.framework.AopConfigExcepti on: Advice must be
> declared inside an aspect type: Offending method 'public void
> ca..yy.remote.endpoint.impl.DtExceptionHandler
> Advice.runtimeError(java.lang.RuntimeException)' in class
> [ca..yy.remote.endpoint.impl.DtExceptionHandler Advice]
>
> Once I dig thru I find that the exception message is misleading because
> the advice is declared in an aspect type. The issue really is that when
> Spring checks if an advice class that is being applied is really an
> aspect type it checks for @Aspect to be present, or if its an aspect
> type and also if it has any ajc$ variables in it. Ideally the error
> message should have said that aspect has been woven by AspectJ Compiler,
> but thats another issue anyways.
>
> But really my problem is that AspectJ is weaving an aspect thats not
> been declared in its aop.xml file.
>
> Here is my aop.xml file
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>
> and My aspect is declared in a file
>
>
> package ca..yy.remote.endpoint.impl;
>
> @Aspect
> public class DtExceptionHandlerAdvice {
>
> @Log
> Logger logger;
> }
>
> In my debug log I see the line
>
> [appclassloa...@130c19b] debug weaving
> 'ca..yy.remote.endpoint.impl.DtExceptionHandle rAdvice'
>
> And when running thru my debugger i do see that the
> DtExceptionHandlerAdvice does have two variables starting with ajc$
> proving that it has indeed been woven by AspectJ load time weaver.
>
> Any reason why this might be happening, Does AspectJ LTW simply pick up
> all classes with @Aspect and consider them as aspects, if that is the
> case should I now have to exclude the ones that I don't want to be woven
> explicitly.
>
> Any help would be appreciated.
>
> Thanks
> -Satish
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] How to create "conditional ITDs"?

2009-08-04 Thread Ramnivas Laddad
Take a look at -Xhasmember option to ajc. You should be able to do something
along the following lines:
interface NeedsPrePersist {
}

declare parents: !hasfield(@PrePersist * *) && (@Entity *) extends
NeedPrePersist;

Then introduce fields and methods to only types that implement
NeedPrePersist.

-Ramnivas

On Tue, Aug 4, 2009 at 3:32 PM, Matthew Adams wrote:

> Hi all,
>
> I was wondering how it might be possible to achieve what I'm calling a
> conditional inter-type declaration.
>
> Here's a simple auditing example.  For a JPA entity, I want to
> introduce a @PrePersist method if and only if the target class doesn't
> have one because it's an error to have multiple @PrePersist methods on
> an entity.  If it already has a @PrePersist method, I want to execute
> advice after the target instance's @PrePersist method is invoked by
> the JPA implementation.  Same for @PreUpdate.
>
> The example below will work for Person, but not for Document --
> Document will end up with two @PrePersist methods.  How can I refactor
> this to work for both?
>
> 
> @Entity
> public class Document {
>  // ...
>  @PrePersist
>  private void prePersist() { /* ... */ }
> }
> 
> @Entity
> public class Person {
>  // ...
> }
> 
> // works only for an @Entity that DOES NOT define a @PrePersist or a
> @PreUpdate method
> public aspect AuditingItd {
>private interface Auditable {
>}
>
>declare parents:  (@javax.persistence.Entity *) implements
> Auditable;
>
>@Column(name = "updated")
>private Date Auditable.updated;
>
>@PrePersist
>private void Auditable.auditablePrePersist() {
>updated = new Date();
>}
>
>@PreUpdate
>private void Auditable.auditablePreUpdate() {
>updated = new Date();
>}
> }
> =
>
> -matthew
>
> --
> mailto:matt...@matthewadams.me
> skype:matthewadams12
> yahoo:matthewadams
> aol:matthewadams12
> google-talk:matthewadam...@gmail.com
> msn:matt...@matthewadams.me
> http://matthewadams.me
> http://www.linkedin.com/in/matthewadams
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] adding advice to 3rd party code

2009-08-05 Thread Ramnivas Laddad
You can use binary weaving to weave into third-party jars. Take a look at
the -inpath option to ajc.
-Ramnivas

On Wed, Aug 5, 2009 at 3:18 PM,  wrote:

> Is there a way I can put advice on code that is not
> mine (3rd party code already compiled in a JAR)?
> Use case: method a() calls b() which calls c() which calls d().
> a() is my code while b, c, and d are not.
>
>
> something like this:
>@AfterReturning(pointcut = "call(* com.foo.Bar.*(..))")
>public void logCall(JoinPoint thisJoinPoint) {
>log.info(thisJoinPoint);
>}
>
> works for b() but not d().  There are many paths to d(),
> so I really want to capture it at that level.
>
> I am using annotations and compiling with
> Eclipse 3.3 and Java 1.6.
> - Dan
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Compile Time Weaving a Constructor

2009-08-06 Thread Ramnivas Laddad
You may want to change your advice as follows:
@AfterReturning(value = "execution(WeaveMe.new(..)) && this(obj)")
public void aop(WeaveMe obj) {
**obj.setA(100);
}

-Ramnivas

On Wed, Aug 5, 2009 at 8:44 PM, Kay Kay  wrote:

> I am looking for a way to weave a constructor statically so that it calls
> some piece of code at the end of the instantiation process.
>
> I am using AspectJ 1.6.5 .
>
> I looked at the FAQ here at -
> http://www.eclipse.org/aspectj/doc/released/faq.html#q:adviseconstructors.
>
> I need to get the second option with the join point inside the constructor
> .
>
>
> import org.aspectj.lang.annotation.AfterReturning;
> import org.aspectj.lang.annotation.Aspect;
>
> @Aspect
> class ToInject {
>
> @AfterReturning(value = "execution(WeaveMe.new(..))", returning =
> "obj")
> public void aop(WeaveMe obj) {
> *// Warning: advice defined in poc.ToInject has not been applied.*
> obj.setA(100);
> }
> }
>
> class WeaveMe {
>
> private int a;
>
> public int getA() {
> return a;
> }
>
> public void setA(int a) {
> this.a = a;
> }
>
> }
>
> public class App {
>
> public static void main(String[] args) {
> WeaveMe weave = new WeaveMe();
> System.out.println(weave.getA());
> // Error: I am expecting 100 but am getting 0.
> }
> }
>
> The advice does not seem to be working but I get a compiler error in the
> IDE (AJDT 2.0.0 on Eclipse).
>
>
> What I prefer from the weaving is to see the bytecode of WeaveMe
> constructor changed. ( and not that of App , where it is getting called )
> since I need to use this in a larger context of Spring injection.
>
> Can somebody help with the same, as to if the advice is correct.  Thanks.
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Is @DeclareParents the only way to make inter-type field declaration in @AspectJ notation

2009-08-31 Thread Ramnivas Laddad
Due to the constraint that code must be compilable with 'javac',
@DeclareMixin/@DeclareParents in the only way.
-Ramnivas

2009/8/31 João Gonçalves 

> Greetings, I have a small doubt.
> In AspectJ's "traditional" notation, it is possible to declare a new field
> for a type this way:
> public aspect A {
> private FieldType  TargetType.field = ;
> }
> In @AspectJ notation do I have to create an interface (mixin) that has that
> field and use @DeclareParents/@DeclareMixin to make all instances of the
> type TargetType have that field.
> Is there a simpler way?
> Thanks
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Is it possible to declare new constructors with @DeclareParens/@DeclareMixins?

2009-09-04 Thread Ramnivas Laddad
Yes, you can. For example, this is how you will introduce a no-arg
constructor to the Account type.
public Account.new() {
   ...
}

-Ramnivas

2009/9/4 João Gonçalves 

> In traditional syntax, it is possible to declare members (fields, methods,
> and constructors) via inter-type declarations.
>
> With @DeclareParents/@DeclareMixins it is easy to emulate fields (with
> getter and setter methods).
>
> Is it also possible to declare new constructors for a type?
>
> Thanks
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


[aspectj-users] AspectJ in Action, second edition published

2009-09-09 Thread Ramnivas Laddad
Hi,

It gives me immense pleasure to announce that AspectJ in Action, 2nd
edition is now published (http://manning.com/laddad2/).

This is a totally revised edition that covers all AspectJ 6 features
including annotation-based @AspectJ syntax, load-time weaver,
annotation-based crosscutting. It also covers Spring-AspectJ
integration.

Currently only the eBook version is available; print book is scheduled
for September 22, around which it will also start to appear on
Amazon.com etc.

I hope you will enjoy the book and find it useful.

-Ramnivas
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] selecting join points using annotations

2009-09-18 Thread Ramnivas Laddad
This is easily possible:

pointcut encryptionOp(String data) : execution(@Encrypt void *(String)) &&
args(data);

void around(String data) : encryption(data) {
 proceed(encrypt(data));
}

pointcut decryptionOp() : execution(@Decrypt String *(..));

String around() : decryptionOp() {
 String encryptedData = proceed();
  return decrypt(encryptedData);
}

-Ramnivas


On Fri, Sep 18, 2009 at 6:47 PM, Robert Taylor wrote:

>  Greetings,
>
> I have a need to leverage AOP to encrypt certain POJO setter String args
> prior to persisting them to the database
> and to decrypt certain POJO getter methods return String values after they
> have retrieved String data from the database.
> I wanted to do this using annotations. For example:
>
> @Encrypt
> public void setCreditCardNumber(String ccn) ...
>
> @Decrypt
> public String getCreditCardNumber()...
>
> I've looked into the Security Annotations Framework 
> (http://safr.sourceforge.net/)
> 
> and it looked promising, however, it can only be used if you are using
> Maven to build
> your project. Unfortunately, I have no immediate plans to use Maven.
>
> I haven't found any similar projects which simply use Ant tags; so I'm
> attempting to "roll my own" solution.
>
> I've read through the AspectJ language docs and haven't found any
> information on selecting join points using annotations.
> I browsed the docs on AspectJ 5 Developers Notebook regarding annotations,
> but it doesn't look like what I need.
> I only want the methods selected by AspectJ if they have been properly
> identified using an annotation.
>
> Is this possible with the current AspectJ version?
>
> /robert
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] selecting join points using annotations

2009-09-20 Thread Ramnivas Laddad
Check your import statements. Do you have the Encrypt type imported?

-Ramnivas

On Sun, Sep 20, 2009 at 6:15 AM, Robert Taylor wrote:

>  Ok...I almost have it working.
>
> Here is my aspect:
>
> *
>
> public
> * *aspect* Encryption {
>
>  *  pointcut* encrypt(String data): *args*(data) && *execution*(*public* *
> void* com.company..model.*.set*(String));
>
> *  pointcut* decrypt(): *execution*(*public* String
> com.company.model.*.get*());
>
> *  void* *around*(String data) : encrypt(data) {
>
> String encryptedData = encryptData(data);
>
> *proceed*(encryptedData);
>
>   }
>
>   String
> *around*(): decrypt() {
>
> String encryptedData =
> *proceed*();
>
> String decryptedData = decryptData(encryptedData);
>
> *return* decryptedData;
>
>   }
>
> *  private* String encryptData(String data) {
>
> // dummy implementation
>
> *return* data;
>
>   }
>
> *  private* String decryptData(String data) {
>
> // dummy implementation
>
> *return* data;
>
>   }
>
> }
>
> This works...as in it picks out all model getter/setter methods.
>
>
>
> However, when I add the annotation selection criteria:
>
> *  pointcut* encrypt(String data): *args*
> (data) && *execution*(@Encrypt *public* 
> *void*com.company..model.*.set*(String));
>
> *  pointcut* decrypt(): *execution*(@Decrypt *public* String
> com.company.model.*.get*());
>
>  AJDT reports this as a warning and the selections no longer match.
>
> I get "no match for this type name: Encrypt[Xlint:invalidAbsoluteTypeName]"
>
> The @Encrypt annotation is defined and I have one method on a single model
> annotated.
>
>
>
> Any ideas on why the join point selection with the annotation doesn't seem
> to work?
>
>
>
> /robert
>
>
>
> - Original Message -
> *From:* Robert Taylor 
> *To:* aspectj-users@eclipse.org
> *Sent:* Saturday, September 19, 2009 6:58 AM
> *Subject:* Re: [aspectj-users] selecting join points using annotations
>
> I guess I didn't look enough:
>
>
> http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations-pointcuts-and-advice.html
>
> Thanks again Ramnivas.
>
>
>
> - Original Message -
> *From:* Robert Taylor 
> *To:* aspectj-users@eclipse.org
> *Sent:* Saturday, September 19, 2009 6:26 AM
> *Subject:* Re: [aspectj-users] selecting join points using annotations
>
> Perfect!
>
> I didn't see any selection examples using annotations so I was unsure on
> how to use them in the join point.
>
> Thank you Ramnivas
>
> /robert
>
> - Original Message -
> *From:* Ramnivas Laddad 
> *To:* aspectj-users@eclipse.org
> *Sent:* Friday, September 18, 2009 11:51 PM
> *Subject:* Re: [aspectj-users] selecting join points using annotations
>
> This is easily possible:
>
> pointcut encryptionOp(String data) : execution(@Encrypt void *(String)) &&
> args(data);
>
> void around(String data) : encryption(data) {
>  proceed(encrypt(data));
> }
>
> pointcut decryptionOp() : execution(@Decrypt String *(..));
>
> String around() : decryptionOp() {
>  String encryptedData = proceed();
>   return decrypt(encryptedData);
> }
>
> -Ramnivas
>
>
> On Fri, Sep 18, 2009 at 6:47 PM, Robert Taylor wrote:
>
>>  Greetings,
>>
>> I have a need to leverage AOP to encrypt certain POJO setter String args
>> prior to persisting them to the database
>> and to decrypt certain POJO getter methods return String values after they
>> have retrieved String data from the database.
>> I wanted to do this using annotations. For example:
>>
>> @Encrypt
>> public void setCreditCardNumber(String ccn) ...
>>
>> @Decrypt
>> public String getCreditCardNumber()...
>>
>> I've looked into the Security Annotations Framework 
>> (http://safr.sourceforge.net/)
>> <http://safr.sourceforge.net/%29>
>> and it looked promising, however, it can only be used if you are using
>> Maven to build
>> your project. Unfortunately, I have no immediate plans to use Maven.
>>
>> I haven't found any similar projects which simply use Ant tags; so I'm
>> attempting to "roll my own" solution.
>>
>> I've read through the AspectJ language docs and haven't found any
>> information on selecting join points using annotations.
>> I browsed the docs on AspectJ 5 Developers Notebook regarding annotations,
>> but it doesn't look like what I need.
>> I only want the methods selected by

Re: [aspectj-users] Method return value in case of exception

2009-09-23 Thread Ramnivas Laddad
You need to keep track of the logged exception and make sure that you don't
log it again. For an example, see source code of AspectJ in Action
(specifically exception logging example in chapter 10); you can download
code from http://manning.com/laddad2.
-Ramnivas

On Wed, Sep 23, 2009 at 2:59 AM, Nikolas Nehmer <
nneh...@informatik.uni-kl.de> wrote:

> Hi,
>
> currently I'm writing a tool logging method calls and corresponding return
> values (among other things). Using "after() throwing" capturing the result
> of a method in case of an exception is easily possible. Unfortunately (to
> capture the exception return value) AspectJ seems to inject try catch blocks
> around every method call on the propagation path.
> Example:
> A is calling B is calling C is calling D, an Exception is raised in D an
> caught in A
>
> Using JDI's ExceptionEvent (running the app in debugging mode) one would
> expect one single ExceptionEvent (caused by the Exception raised in D)  with
> ExceptionEvent.catchLocation() returning A...
>
> Using:
> after() throwing(Throwable o): methodCall() {
>   //doSomething
> }
> results in several ExceptionEvents caused by every propagation step on the
> exception propagation path. Obviously each method call is implicitly wrapped
> by a try catch block rethrowing the exception raised in D. Unfortunately
> this implicitly changes the exception propagation behaviour of the
> application.
>
> Any ideas on how to circumvent this implicit catch and rethrow mechanism
> while keeping the possibility to capture method calls and results in case of
> an exception?
>
> Cheers
> Nikolas
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] AspectJ run-time licensing

2009-10-05 Thread Ramnivas Laddad
SpringSource dm Server has a similar situation, so you may be interested in
the following:
http://www.springsource.com//products/dmserver/licensingfaq

-Ramnivas

On Mon, Oct 5, 2009 at 12:43 PM, Wim Deblauwe wrote:

> There is some information on the EPL on wikipedia:
> http://en.wikipedia.org/wiki/Eclipse_Public_License
>
> What i find most striking is that it is not compatible with the GPL, so as
> I understand it, you cannot build a GPL application or library using
> aspectJ. Can somebody confirm this?
>
> regards,
>
> Wim
>
> 2009/10/5 Andy Clement 
>
> Hi Mike,
>>
>> Unfortunately - I'm not a lawyer either and basically agree with
>> Ramnivas. But I would say the AspectJ FAQ is very overdue an update
>> (and wasn't written by a lawyer originally) - it still references the
>> CPL when we moved to EPL many releases ago.  However, I'd say there is
>> no intention to trick anyone here, and my interpretation is simply
>> that you need to ship aspectjrt.jar as-is (without removing any of
>> it).  We could maybe ask the Eclipse IP team for some guidance, but
>> I've not had to do that before and aspectjrt.jar has been shipped with
>> many products in the past (not just open source projects).
>>
>> Andy
>>
>>
>> 2009/10/2 McSherry, Mike :
>> > Greetings,
>> >
>> > I'm interested in the license exception noted in the FAQ, which Jacob
>> Bower
>> > also referenced.  If distributing only 'aspectjrt.jar' as part of my
>> > product, I read it as only the warranty disclaimers being applicable.
>> > Referring to the EPL license text, that would be solely the terms noted
>> in
>> > "Section 5: NO WARRANTY"?
>> >
>> > Is that indeed the extent of the terms which are applicable to
>> distributing
>> > ‘aspectjrt.jar’?
>> >
>> > I'd greatly appreciate clarification on this from the project leads,
>> since
>> > I'm not a lawyer either, but I have to work with them.
>> >
>> > --Mike
>> >
>> > Jacob Bower wrote:
>> >
>> > I had got the impression that distribution generally wasn't going to be
>> an
>> > issue.
>> >
>> > However, I'm trying to understand what my obligations are in terms of
>> for
>> > example making the end user view the EPL?
>> >
>> > - Jacob
>> >
>> > 2009/7/13 Ramnivas Laddad > > <mailto:ramni...@xxx>>
>> >
>> > I am not a lawyer, but I do not think there are any restrictions
>> >
>> > on redistributing aspectjrt.jar (or any of the the AspectJ jars).
>> >
>> > For example, aspectjrt.jar is distributed with many SpringSource
>> >
>> > products (open source as well as commercial).
>> >
>> > -Ramnivas
>> >
>> > On Mon, Jul 13, 2009 at 1:59 PM, Jacob Bower > >
>> > <mailto:ja...@xxx>> wrote:
>> >
>> > Hi,
>> >
>> > I'm developing a Java library which will be distributed in jar
>> >
>> > form. In developing this library I have used AspectJ 1.6.5 and
>> >
>> > the resulting binary will include code woven in by the ajc
>> >
>> > compiler. To distribute this library I will need to distribute
>> >
>> > the AspectJ run-time. Users of the library will not need to
>> >
>> > use ajc to compile their code as all relevant joinpoints are
>> >
>> > internal to the library.
>> >
>> > In this case, what are the restrictions on distributing the
>> >
>> > AspectJ run-time. Can I include the aspectj.jar (or its
>> >
>> > conents) in my own jar with no notices?
>> >
>> > I've consulted the AspectJ FAQ on this matter, but I am
>> >
>> > unclear on how I'm supposed to preserve the warranty
>> >
>> > disclaimers in the license.
>> >
>> > Thanks,
>> >
>> > Jacob
>> >
>> > ___
>> > aspectj-users mailing list
>> > aspectj-users@eclipse.org
>> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
>> >
>> >
>> ___
>> aspectj-users mailing list
>> aspectj-users@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Intertype declaration name mangling - for or against?

2009-11-20 Thread Ramnivas Laddad
I am all for this. Mangled names create problems with JPA and such.

I guess one issue to consider is what happens when two aspects want to
introduce a same-named field with a directive to not mangle, especially if
both aspects are from third-party libraries. This is quite unlikely to occur
in practice, but we may need to address it somehow. I wonder if the 'declare
precedence' can be an arbitrator here.

-Ramnivas

On Thu, Nov 19, 2009 at 10:54 AM, Andy Clement wrote:

> I'm possibly going to review our approach to intertype declaration
> naming.  The names are currently mangled deliberately to preserve some
> of the 'rules' that AspectJ defines.  For example, private field itds
> have mangled names because the field is private to the aspect and
> shouldn't be visible as a 'regular' private field in the target.  This
> also enables two aspects to ITD the same private field and there is no
> clash in the target type.
>
> However, since those rules were defined a long time ago, things have
> changed and various frameworks are looking at members via reflection,
> for purposes of invocation or automatic persistence.  The mangling is
> unhelpful here.
>
> I *thinking* about allowing non-mangled names, possibly with a
> directive annotation in the aspect that says "do not mangle these, I
> know what I'm doing and there won't be a problem".
>
> Basically I wanted to collect any thoughts from you guys?
>
> I suspect that the some of the scenarios AspectJ worries about rarely
> happen in practice - have you ever ITD'd the same named private field
> from two aspects onto the same type?  (AspectJ can continue to
> warn/error when it sees this about to happen of course)
>
> cheers,
> Andy
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Spring Advice Not getting applied

2009-11-24 Thread Ramnivas Laddad
Hi Ron,

I don't see any beans to which the aspect should be applied. Have you
declared those somewhere else?

-Ramnivas

On Tue, Nov 24, 2009 at 7:04 AM, Ron DiFrango  wrote:

> It has been a while since I applied AspectJ to Spring beans.  I have the
> following code:
>
> package com.demo.aop;
> import org.aspectj.lang.ProceedingJoinPoint;
> import org.aspectj.lang.annotation.Around;
> import org.aspectj.lang.annotation.Aspect;
> import org.aspectj.lang.annotation.Pointcut;
> @Aspect
> public class DemoTracingAspect {
>  @Pointcut("execution(public * *(..))")
>  public void tracing() {}
>  @Pointcut("within(com.demo..*)")
>  public void inDemo() {}
>  @Around("tracing() && inDemo()")
>  public Object trace(ProceedingJoinPoint pjp) throws Throwable {
>  // Log log = LogFactory.getLog(pjp.getClass());
>  String invocationDescription = getInvocationDescription(pjp);
>  // log.trace("Entering " + invocationDescription);
>  System.out.println("Entering " + invocationDescription);
>  try {
>   Object rval = pjp.proceed();
>   // log.trace("Exiting " + invocationDescription);
>   System.out.println("Exiting " + invocationDescription);
>   return rval;
>  } catch (Throwable ex) {
>   // log.trace("Exception thrown in " + invocationDescription, ex);
>   System.out.println("Exception thrown in " + invocationDescription
> + "\n" + ex.getStackTrace());
>   throw ex;
>  }
>  }
>  /**
>  * Return a description for the given method invocation.
>  *
>  * @param invocation
>  *the invocation to describe
>  * @return the description
>  */
>  protected String getInvocationDescription(ProceedingJoinPoint
> thisJoinPoint) {
>  return "method '" + thisJoinPoint.getSignature().getName()
>+ "' of class ["
>+ thisJoinPoint.getSignature().getClass().getName() + "]";
>  }
> }
>
> And the following Spring config:
>
> 
> 
> 
>
> I have tried with & without proxy-target-class and no matter what the
> Aspect never gets applied.
>
> Thoughts?___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] New intertype syntax ...new meaning?

2009-11-24 Thread Ramnivas Laddad
Andy,

I haven't used the 'declare warning' pattern with ITDs you showed in a
while. But you are right that there are use cases where the distinction
between the lexical scope of the introduced members matters.

I guess one if the question to ponder: what is the interaction between
within() and the new syntax-introduced members. For Roo-like usage, where
aspects are used in "open classes" spirit, it seems that selection through
within() should match even the code in the "intertype" (assuming that is the
syntax AspectJ goes with) blocks.

Alternatively, within() maintains its strict lexical scope selection
criteria and we introduce another pointcut (within+()?) to select intertyped
elements.

-Ramnivas

On Tue, Nov 24, 2009 at 11:37 AM, Matthew Adams wrote:

> I really like the idea of transparent advices/ITDs, and I think that
> the example that you've given is not something that I've come across.
> I don't know if it's a corner case or not for everyone, though.
>
> I'm not sure I understand the @Inline annotation.  Can you elaborate
> on that one?
>
> Here's the primary usage I have of ITDs:
>
> @Entity @Coded public class Thing { /* ... */ }
> 
> public interface Coded { String getCode(); }
> 
> public aspect CodedMixin {
>  public interface IntroducedCoded extends Coded {}
>  declare parents: ((@Entity *) && (@Coded *)) implements IntroducedCoded;
>
>  @Column(name="code") private String IntroducedCoded.code;
>
>  public String IntroducedCoded.getCode() { return code; }
>  public void IntroducedCoded.setCode(String code) { this.code = code; }
> }
>
> I do this to allow for any implementation of Coded, while introducing
> a specific implementation of Coded to those that I want to, in
> particular, @Entity's annotated with @Coded.  This results in a
> postweaving class declaration of Thing that implements
> IntroducedCoded, which uses a scary mangled name
> (...$CodedMixin$IntroducedCoded) and has a public field with a mangled
> field name for "code".
>
> With fully transparent ITDs, I'd like to be able to say that
> @Coded-annotated @Entity's implement Coded (not IntroducedCoded), with
> an implementation of the one in the aspect, with no indication that it
> was introduced, and with a non-mangled, non-public field name such
> that decompiling Thing after weaving would result in the following:
>
> public class Thing implements Coded {
>  protected String coded; // note non-public
>  public String getCode() { return code; }
>  public void setCode(String code) { this.code = code; }
> }
>
> Make sense?
>
> -matthew
>
>
> On Tue, Nov 24, 2009 at 11:14 AM, Andy Clement 
> wrote:
> > I'm nervous about making changes to what happens for weaving todays
> > ITD syntax - meaning the ongoing discussions about mangling,
> > visibility, etc.  A common request I am now seeing is that users want
> > completely transparent application of ITDs.  What does what mean?  It
> > would mean in the bytecode it looked *exactly* as if the user had made
> > the ITD declaration in the target type.  I am thinking about whether
> > the new syntax block (intertype X {}) could implement this new
> > functionality and the user makes a deliberate decision about whether
> > they need the features that come with non-transparent ITDs, or if they
> > are happy with full inlining (and so choose the new syntax):
> >
> > What goes wrong if fully inlined?  Here is a scenario:
> >
> > class Foo
> >  public void m() {
> >System.out.println("hey!");
> >  }
> > }
> >
> > aspect Bar {
> >  public void Foo.run2() {
> >System.out.println("hey2!");
> >  }
> > declare warning: execution(* run2(..)) && !within(Bar): "Only Bar
> > should be providing a run2 implementation";
> > }
> >
> > This is (a crude representation of) a common pattern where an aspect
> > and bunch of ITDs implement some feature, but there is also a guard
> > "declare warning" in the aspect to make sure no-one attempts to
> > duplicate what the ITDs are already responsible for.  The above works
> > because post compilation the implementation of run2() is still
> > considered to be in Bar, with various accessors/dispatchers added to
> > Foo to support running the code in Bar.
> >
> > If full inlining is performed, it would not be possible to tell that
> > Bar had provided the implementation of run2() into Foo - the bytecode
> > will look exactly like the code had been written:
> >
> > class Foo {
> >  public void m() {
> >System.out.println("hey!");
> >  }
> >
> >  public void run2() {
> >System.out.println("hey2!");
> >  }
> > }
> >
> > I *think* there is a certain class of aspect that does fit this model
> > and doesn't need the distinction to be maintained in the bytecode
> > (remember, AspectJ is a bytecode weaver and does not really allow
> > source knowledge to influence weaving).  If you use ITDs, do you use
> > declare warning guards that would be impacted by fully inlined ITDs?
> >
> > (Of course, even if this were happening, Aspe

Re: [aspectj-users] priviledged aspect

2009-12-02 Thread Ramnivas Laddad
This is really a Java reflection API question. Check
http://java.sun.com/javase/6/docs/api/java/lang/reflect/AccessibleObject.html#setAccessible(boolean)to
access non-public members. Also, if you go that route, you don't need
your aspect to be marked at privileged.

-Ramnivas

On Wed, Dec 2, 2009 at 6:40 PM, ivlev jenia  wrote:

> Hello.
> From a privileged AspectJ class I want to access the private fields of an
> object; lets call this object x.
> To do this I would do x.fieldname.
> Now I have fieldname stored in a String, lets call it y.
> So how can I do the equivalent of x.y ?
> Also I tried to go x.getClass().getField(y). This works fine for public
> fields, I need to do it for private fields.
>
> Thank you for your kind concner.
> Jenia Ivlev
>
> --
> The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo!
> *Get it Now for Free!* 
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Aspectj scope Singleton, moitoring ?

2009-12-28 Thread Ramnivas Laddad
It certainly can be useful. It really depends on if the aspect contains
shared state that can be used concurrently. In other words, the situation in
an advice isn't much different than a regular method.

-Ramnivas

On Mon, Dec 28, 2009 at 10:12 AM, Jean-Louis.Pasturel <
jean-louis.pastu...@orange.fr> wrote:

> Perhaps a stupid question ;-)
> In an advice of an aspect with the default modifier issingleton, is it
> usefull to monitor ( synchronized key word) the code bloc of the advice ?
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Aspectj scope Singleton, moitoring ?

2009-12-29 Thread Ramnivas Laddad
On Tue, Dec 29, 2009 at 9:40 AM, p...@ichthyostega.de 
wrote:
...

> Regarding Aspects, there is only one general advice I can give, based on
> my experience: You should be reluctant to do implementation-level stuff
> from Advice. It is always better to invoke an API or an existing service.
> (And following this reasoning, locking and managing the state would be
> the service's job, not the job of the aspect).
>
> Cheers,
> Hermann V.


That is indeed a good advice (no pun intended). In general, it is best if
aspects do minimal work by themselves. Essentially, I like aspects to act as
controllers and forward implementation details to normal objects (often
injected dependencies). Besides taking care of issues such as concurrency
(essentially, by making them nothing special than in the OO-only world),
such an arrangement facilitates better testing of the overall implemenation.

-Ramnivas
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] overridden method not caught

2010-01-06 Thread Ramnivas Laddad
I am guessing that you are using the AspectJ's byte code weaving (and not
Spring's proxy-based). Right?

If so, I just tried your example and it works fine for me (I removed Spring
related code as that is not significant here).

-Ramnivas

On Wed, Jan 6, 2010 at 12:40 AM,  wrote:

> I am experimenting with the Spring integration for Aspectj as documented
> at
> http://static.springsource.org/spring/docs/2.5.x/reference/aop.html#aop-
> using-aspectj and have come across a problem.
>
> If I alter the class invocation to override the method that I want to
> instrument, the method is no longer detected.
>
> So, my class is:
>
> package foo;
>
> public class EntitlementCalculationService {
>public void calculateEntitlement() {
>System.out.println("executing");
>try {
>Thread.sleep(200);
>} catch (InterruptedException e) {
>e.printStackTrace();
>}
>}
> }
>
> My aspect is:
>
> package foo;
>
> import org.aspectj.lang.ProceedingJoinPoint;
> import org.aspectj.lang.annotation.Aspect;
> import org.aspectj.lang.annotation.Around;
> import org.aspectj.lang.annotation.Pointcut;
> import org.springframework.util.StopWatch;
>
> @Aspect
> public class ProfilingAspect {
>@Around("methodsToBeProfiled()")
>public void profile(ProceedingJoinPoint pjp) throws Throwable {
>StopWatch sw = new StopWatch(getClass().getSimpleName());
>try {
>sw.start(pjp.getSignature().getName());
>pjp.proceed();
>} finally {
>sw.stop();
>System.out.println(sw.prettyPrint());
>}
>}
>
>@Pointcut("execution(public * foo..*.*(..))")
>public void methodsToBeProfiled(){}
> }
>
> And my code to test is:
>
> package foo;
>
> import org.springframework.context.ApplicationContext;
> import
> org.springframework.context.support.ClassPathXmlApplicationContext;
>
> public final class Main {
>public Main() {
>ApplicationContext ctx = new
> ClassPathXmlApplicationContext("/beans.xml", Main.class);
>
>EntitlementCalculationService
> entitlementCalculationService = new EntitlementCalculationService();{
>
>entitlementCalculationService.calculateEntitlement();
>}
>
>public static void main(String[] args) {
>new Main();
>}
> }
>
> This gives the correct output:
>
> [java] StopWatch 'ProfilingAspect': running time (millis) = 201
> [java] -
> [java] ms % Task name
> [java] -
> [java] 00201  100%  calculateEntitlement
>
> However, if I change the test code to override the calculateEntitlement
> method like this:
>
> package foo;
>
> import org.springframework.context.ApplicationContext;
> import
> org.springframework.context.support.ClassPathXmlApplicationContext;
>
>
> public final class Main {
>public Main() {
>ApplicationContext ctx = new
> ClassPathXmlApplicationContext("/beans.xml", Main.class);
>
>EntitlementCalculationService
> entitlementCalculationService = new EntitlementCalculationService(){
>@Override
>public void calculateEntitlement() {
>System.out.println("test1");
>}
>};
>
>entitlementCalculationService.calculateEntitlement();
>}
>
>public static void main(String[] args) {
>new Main();
>}
> }
>
> The aspect fails to trigger.
>
> Any ideas please?
>
> TIA,
>
> Adrian Smith
> BT Group
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] not able to hook individual class - proxy aspectj

2010-01-10 Thread Ramnivas Laddad
Priya,

I assume that by "proxy" you mean proxies created by Spring AOP. In that
case, Controllertest isn't probably a Spring bean. In Spring, only beans may
be advised by aspects. If you must advise non-beans, you will need to use
the AspectJ weaver.

-Ramnivas

On Sun, Jan 10, 2010 at 6:16 PM, priya j  wrote:

>
> Hi All,
>
> i am using proxy aspectj for my implementation.
> When my Pointcut is as follows:
> @Pointcut("execution(*
> org.springframework.web.servlet.mvc.Controller.handleRequest(..))")
> works fine. no problem.
>
> When i want to honk an individual class or method eg:
> @Pointcut("execution(* sg.test.Controllertest.doQuery(..))")
> No error, but i am not able to honk.
> Where my package is : sg.test
> Class is : Controllertest
> Method is : doQuery
>
> I am very new to aspectJ.
> Kindly help me on this.
>
> Regards,
> Priya
> --
> View this message in context:
> http://old.nabble.com/not-able-to-hook-individual-class---proxy-aspectj-tp27072353p27072353.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] not able to hook individual class - proxy aspectj

2010-01-12 Thread Ramnivas Laddad
Hi Priya,

eclipse.org/aspectj itself should be a good starting point.

-Ramnivas

On Mon, Jan 11, 2010 at 2:03 AM, priya j  wrote:

>
> Hi Ramnivas,
>
> Thanks for your reply.
> Can you give me some suggestion or site to refer?
>
> Regards,
> Priya
>
>
> Ramnivas Laddad wrote:
> >
> > Priya,
> >
> > I assume that by "proxy" you mean proxies created by Spring AOP. In that
> > case, Controllertest isn't probably a Spring bean. In Spring, only beans
> > may
> > be advised by aspects. If you must advise non-beans, you will need to use
> > the AspectJ weaver.
> >
> > -Ramnivas
> >
> > On Sun, Jan 10, 2010 at 6:16 PM, priya j  wrote:
> >
> >>
> >> Hi All,
> >>
> >> i am using proxy aspectj for my implementation.
> >> When my Pointcut is as follows:
> >> @Pointcut("execution(*
> >> org.springframework.web.servlet.mvc.Controller.handleRequest(..))")
> >> works fine. no problem.
> >>
> >> When i want to honk an individual class or method eg:
> >> @Pointcut("execution(* sg.test.Controllertest.doQuery(..))")
> >> No error, but i am not able to honk.
> >> Where my package is : sg.test
> >> Class is : Controllertest
> >> Method is : doQuery
> >>
> >> I am very new to aspectJ.
> >> Kindly help me on this.
> >>
> >> Regards,
> >> Priya
> >> --
> >> View this message in context:
> >>
> http://old.nabble.com/not-able-to-hook-individual-class---proxy-aspectj-tp27072353p27072353.html
> >> Sent from the AspectJ - users mailing list archive at Nabble.com.
> >>
> >> ___
> >> aspectj-users mailing list
> >> aspectj-users@eclipse.org
> >> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >>
> >
> > ___
> > aspectj-users mailing list
> > aspectj-users@eclipse.org
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/not-able-to-hook-individual-class---proxy-aspectj-tp27072353p27108145.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Problem converting to annotation style

2010-02-11 Thread Ramnivas Laddad
In annotation-style, pointcut expressions must use fully-qualified type
names. So you will need to change your pointcut to something like:

@Pointcut("execution(* packageof.A.*(..)) || execution(*
packageof.C.*(..))")

Also, can you switch to the latest version AspectJ? A lot of bugs have been
fixed, especially for annotation-style aspects.

-Ramnivas

On Wed, Feb 10, 2010 at 4:28 PM, Mick Jordan  wrote:

> I am resurrecting an aspect that I developed a while ago in the
> non-annotation style and trying to convert it to annotation style. I've read
> the documents and made what seemed to be the appropriate changes, but the
> effect is that, while ajc compiles everything happily, no weaving occurs,
> confirmed by the -showWeaveInfo option. I've scanned the archives for
> relevant posts and come up empty, so I'm hoping someone can see what I
> assume is a trivial mistake.
>
> Here is the key part of the non-annotation version:
>
> public abstract aspect Trace {
> public abstract pointcut execAll();
>
> before() : execAll() {
>  doBefore(thisJoinPoint);
> }
> public void doBefore(JoinPoint jp) {
>  // the work
> }
> after() returning(Object result) : execAll() {
>  doAfter(thisJoinPoint, result, true);
> }
>
>  after() throwing(Throwable t) : execAll() {
>  doAfter(thisJoinPoint, t, false);
> }
>
> protected void doAfter(JoinPoint jp, Object result, boolean normalReturn) {
>  // the work
> }
> }
>
> This is coupled with a concrete aspect, e.g to trace code with classes A
> and C:
>
> aspect TraceAandCTest extends Trace {
>  public pointcut execAll() : execution(* A.*(..)) || execution(* C.*(..));
> }
>
> This all works just fine.
>
> Now here is the annotation version:
>
> import org.aspectj.lang.annotation.*;
> @Aspect
> public abstract class Trace {
>  @Pointcut("")
>  public abstract void execAll();
>  @Before("execAll()")
>  public void doBefore(JoinPoint jp) {
>// the work
>  }
>  @AfterReturning(pointcut="execAll()", returning="result")
>  public void doAfterNormalReturn(JoinPoint jp, Object result) {
>  doAfter(jp, result, true);
>  }
>
>  @AfterThrowing(pointcut="execAll()", throwing="result")
>  public void doAfterExceptionReturn(JoinPoint jp, Object result) {
>  doAfter(jp, result, false);
>  }
>  protected void doAfter(JoinPoint jp, Object result, boolean normalReturn)
> {
>// the work
>  }
> }
>
> Here is the corresponding concrete aspect:
>
> import org.aspectj.lang.annotation.*;
>
> @Aspect
> public class TraceAandCTest extends Trace {
>
>  @Pointcut("execution(* A.*(..)) || execution(* C.*(..))")
>  public void execAll() {
>  }
> }
>
> The build scripts for the two versions are identical. The behavior of the
> non-annotated version is that I see "weaveInfo joinPoint ..." traces from
> ajc, whereas no such traces occur for the annotated version. I have
> -source=1.5 set, of course.
>
> Appreciate any insight into what I'm missing. I'm using AspectJ 1.5.
>
> Thanks
> Mick Jordan
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Are static initializers of an aspect guaranteed to be called?

2010-02-16 Thread Ramnivas Laddad
In this regard, aspects behave just like classes. When an aspect type is
referenced for the first time, its static initializer will be called just as
for a class.

-Ramnivas

On Tue, Feb 16, 2010 at 10:33 AM, Gary Bisaga  wrote:

> I read (for example in AspectJ in Action) it emphasized that while an
> aspect is in many ways like a class, an aspect is *not* a class. What
> I would like to do is to write a static initializer block for my aspect:
>
> public aspect MyAspect {
>  private static SomeClass myObject;
>  static {
>   myObject = new SomeClass (...);
>  }
> }
>
> Here is my question: is my static initializer guaranteed to be called
> when the aspect is loaded? For that matter, are aspects loaded via
> normal ClassLoaders? Thanks.
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Simplest way to advice around java.sql.Statement.executeQuery?

2010-02-16 Thread Ramnivas Laddad
In case of JDBC objects (statements, connection etc.), if you use an
execution pointcut such as:
execution(* java.sql.Statement.*(..))
and
you weave in the JDBC driver (the jar), you should be good to go.

We use this approach in Spring Insight (
http://www.springsource.com/products/tcserver/devedition). There we use
load-time weaving, but even if you use build-time weaving, as long as you
manage to weave in JDBC driver jars, it should work for you.

-Ramnivas

On Mon, Feb 15, 2010 at 8:37 AM, Andy Clement wrote:

> The key thing to understand is who loads that class.  Given that it
> has a java prefix, it may or may not be loaded by a classloader
> against which a weaver can be attached.  Simplest way would be to
> create the aspect you want, define the aop.xml (include the setting to
> weave java prefixed packages (  options="-Xset:weaveJavaPackages=true" ), perhaps set the options for
> debug, verbose and showWeaveInfo, then launch the VM with the
> aspectjweaver agent attached.  You will discover which classloaders
> are getting a weaver instance and a debug line will be produced if the
> Statement class is ever passed to AspectJ.  If it is then the
> showWeaveInfo will tell you whether your advice matched.
>
> I know you mentioned you wanted to load time weave, but if it isn't
> loaded by a classloader you can hook into the simplest thing is a
> quick compile time weave of the jar containing it (you don't need the
> source for Statement or anything)
>
> Andy
>
> On 14 February 2010 15:18, Aldo Bucchi  wrote:
> > Hi,
> >
> > What's the simplest and less invasive way to advice around
> > java.sql.Statement.executeQuery using runtime weaving?
> >
> > ( I mention that specific class to clearly illustrate the general
> > case: A method on a 3rd party jar over which I have no control ).
> >
> > 1. I am not restricted to AspectJ, but I thought I'd start looking here
> > 2. I am looking for a quick one-off that does not impose too many
> > requirements, configurations and dependecies as the target project is
> > already using complex compilation phases to integrate Scala and some
> > DSLs PLUS we're using Maven. This is why RTW sounds like the right
> > choice so as to avoid falling into spaghettiland
> >
> > Ideally, something like Spring's annotation-based RTW but w/o the
> limitations.
> >
> > Thanks!
> > A
> >
> > --
> > Aldo Bucchi
> > skype:aldo.bucchi
> > http://www.univrz.com/
> > http://aldobucchi.com/
> >
> > PRIVILEGED AND CONFIDENTIAL INFORMATION
> > This message is only for the use of the individual or entity to which it
> is
> > addressed and may contain information that is privileged and
> confidential. If
> > you are not the intended recipient, please do not distribute or copy this
> > communication, by e-mail or otherwise. Instead, please notify us
> immediately by
> > return e-mail.
> > ___
> > aspectj-users mailing list
> > aspectj-users@eclipse.org
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Four Approaches of Mixins in Java with AspectJ

2010-02-17 Thread Ramnivas Laddad
+1 for a good blog (and +2 for mentioning my book!).

I think static crosscutting is a critical component of AOP, but dynamic
crosscutting usually steals the show! As shown in Spring Roo, when used
correctly, static crosscutting can really help boost productivity and create
clean code.

-Ramnivas

On Wed, Feb 17, 2010 at 9:17 AM, Andy Clement wrote:

> Really nice to see an article covering @DeclareMixin - I don't think
> that gets enough press as it is quite a recent change, people seem to
> still use the clunky old @DeclareParents.
>
> cheers,
> Andy
>
> On 16 February 2010 18:16, Hendy Irawan  wrote:
> >
> > Hi AspectJ users,
> >
> > I've written a blog post about different Approaches of Mixins in Java
> with
> > AspectJ.
> >
> > 1. non-AOP
> > 2. AspectJ syntax
> > 3. @AspectJ annotations
> > 4. Hybrid approach (AspectJ + proxy + impl)
> >
> > I detail the rationale, pros & cons of each, and code examples here:
> >
> >
> http://spring-java-ee.blogspot.com/2010/02/four-approaches-for-static-structure.html
> >
> > Hopefully this is useful for you. Take care. :-)
> >
> > -
> > http://www.Soluvas.com/ Soluvas - Making eCommerce Work for You
> > --
> > View this message in context:
> http://old.nabble.com/Four-Approaches-of-Mixins-in-Java-with-AspectJ-tp27618190p27618190.html
> > Sent from the AspectJ - users mailing list archive at Nabble.com.
> >
> > ___
> > aspectj-users mailing list
> > aspectj-users@eclipse.org
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] LTW with WebSphere message broker

2010-03-08 Thread Ramnivas Laddad
I haven't used WebSphere ESB, so can't say if/how well LTW will work with
it. For WebSphere itself, there is a classloader implementation (search
bugzilla) that implements LTW. However, I don't know how well it works with
the latest version of AspectJ.

Is there a reason why build-time weaving will not get the job done?

+1 for Andy's suggestion about Spring Forum. May be someone there has more
insight.

-Ramnivas

On Sun, Mar 7, 2010 at 4:51 PM, Andy Clement wrote:

> Hi,
>
> If you don't get (m)any answers on here (I don't know the answer), you
> could also try the Spring AOP forum:
>
>  http://forum.springsource.org/forumdisplay.php?f=31
>
> Andy
>
> On 6 March 2010 01:59, Rakesh Sharma  wrote:
> > I am wondering if it is possible to use AspectJ LTW in an WebSphere ESB
> > message flow. The idea is to get hold of the message payload in the flow
> at
> > differentb activites and extract some information.
> >
> > --
> > Sent using goWebtop from Laszlo Systems.
> > Try it yourself : http://www.gowebtop.com
> > ___
> > aspectj-users mailing list
> > aspectj-users@eclipse.org
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Can we access any static join point information in declare error/warning?

2010-03-17 Thread Ramnivas Laddad
Very nice, indeed!

-Ramnivas

On Wed, Mar 17, 2010 at 9:19 AM, Simone Gianni  wrote:

> Very very nice!!!
>
> Simone
>
> 2010/3/13 Andy Clement 
>
> This idea of mirroring the API usage is mentioned in bug 48080 (see
>> the first comment by Jim).  I have just committed the following
>> support:
>>
>>  declare warning: execution(* A.m(..)): "joinpoint location is
>> {joinpoint.sourcelocation.sourcefile}:{joinpoint.sourcelocation.line}";
>>  declare warning: execution(* A.m(..)): "joinpoint is {joinpoint}";
>>  declare warning: execution(* A.m(..)): "joinpoint kind is
>> '{joinpoint.kind}'";
>>  declare warning: execution(* A.m(..)): "joinpoint line is
>> '{joinpoint.sourcelocation.line}'";
>>  declare warning: get(int *) && within(A): "joinpoint signature is
>> {joinpoint.signature}";
>>  declare warning: execution(* A.m(..)): "joinpoint declaring type is
>> {joinpoint.signature.declaringType}";
>>  declare warning: execution(* A.m(..)): "advice sourcelocation is
>> {advice.sourcelocation.sourcefile}:{advice.sourcelocation.line}";
>>  declare warning: get(int *): "aspect is {advice.aspecttype}";
>>  declare warning: get(int *): "signature name for field is
>> {joinpoint.signature.name}";
>>  declare warning: execution(* A.m(..)): "signature name for method is
>> {joinpoint.signature.name}";
>>
>> Andy
>> ___
>> aspectj-users mailing list
>> aspectj-users@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] getting varargs to work in args and advise

2010-03-22 Thread Ramnivas Laddad
call(* myTestClass.setStrFld(String,int...)) will select the following
method

class myTestClass {
 setStrFld(String a, int... b) {
}
}

You probably want to use thisJoinPoint.getArgs() in the advice to access all
arguments.

-Ramnivas

On Mon, Mar 22, 2010 at 3:31 AM, Ashank  wrote:

>
> Hello,
>
> I was trying out the varargs feature in aspectJ but cannot get it to work
> unfortunately. I read through
> http://www.eclipse.org/aspectj//doc/next/adk15notebook/varargs-in-pcds.html
> and a few posts but tried to test the example but cannot get it to work.
> I'm
> not getting syntax errors but nothing is getting. I have pasted my simple
> code here. Please help me identify where I am going wrong.
>
> Class I am trying to advise:
>
> package arvind.AspectJTest;
>
> import java.util.ArrayList;
>
> public class myTestClass {
>String strFld = "InitVal";
>
>public String getStrFld() {
>return strFld;
>}
>
>public void setStrFld(String inStr) {
>strFld = inStr;
>}
>
>public void setStrFld(String inStr, String inStr2) {
>strFld = inStr + inStr2;
>}
>
>public void setStrFld(String inStr, int myInt) {
>strFld = inStr+","+Integer.toString(myInt);
>}
>
>public void setStrFld(String someStr, int dividend, int divisor) {
>strFld = someStr + "," + ((float)dividend/divisor);
>}
>
>public static void main(String[] args) {
>myTestClass d = new myTestClass();
>System.out.println("Initially, StrFld is  " + d.getStrFld()
> + ". Calling
> string,string");
>d.setStrFld(args[0],args[1]);
>System.out.println("Secondly, StrFld is  " + d.getStrFld()+
> ". Calling
> string,int");
>d.setStrFld(args[0],Integer.parseInt(args[1]));
>System.out.println("Thirdly, StrFld is  " + d.getStrFld()+
> ". Calling
> string,int,int");
>
>  d.setStrFld(args[0],Integer.parseInt(args[1]),Integer.parseInt(args[2]));
>System.out.println("Finally, StrFld is  " + d.getStrFld());
>}
> };
>
> Aspects that I am using for advice:
> 1.) InittAspect.java:
>
> package arvind.AspectJTest;
>
> abstract aspect InitAspect{
>pointcut PCpart1(): !within(arvind.*) &&
> within(arvind.AspectJTest.*);
>pointcut PCpart2(): !within(InitAspect);
>pointcut catchClasses(): PCpart1() && PCpart2();}
> }
>
> 2.) testProceed.java:
>
> package arvind.AspectJTest;
>
> aspect testProceed extends InitAspect{
>pointcut catchAllMethods(String myStr, int[] restOfArgs):
> catchClasses()&&
>call(* myTestClass.setStrFld(String,int...)) &&
>within(myTestClass) && args(myStr,restOfArgs);
>
>Object around(String myStr, int[] restOfArgs):catchAllMethods(myStr,
> restOfArgs) {
>
>
> System.out.println("--");
>System.out.println(thisJoinPoint);
>
>System.out.println("around Advice: before proceed: ");
>System.out.println("First string argument is " + myStr + ".
> Executing the
> method now...");
>Object result = proceed(myStr,restOfArgs);
>System.out.println("Result is " + result);
>
>System.out.println("around Advice: After proceed: ");
>
>
> System.out.println("--");
>return result;
>}
> }
>
> When I try to compile them using ajc as follows, I get no weave info:
> C:\arvind\AspectJTest>ajc -showWeaveInfo -outjar aspectjar.jar -outxml
> InitAspect.java testProceed.ja
> va myTestClass.java
>
> C:\arvind\AspectJTest>
>
> My classpath and path are correct.
>
> Please tell me where I am making mistakes. Also, eventually I would like to
> able to use args(String, Object+...) in the pointcut but i don't know if
> its
> possible. I read through the following code and got the impression that
> what
> i am trying to do should work now but I there is no weaving going on.
> Please
> help.
>
> Thanks.
> -Arvind
>
>
> http://old.nabble.com/Matching-varargs-with-subtypes%3A-call%28*-*.*%28Object%2B...%29%29-td22076248.html#a22076248
> --
> View this message in context:
> http://old.nabble.com/getting-varargs-to-work-in-args-and-advise-tp27984480p27984480.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Is it possible to mix Spring AOP (@Aspect) with AspectJ LTW?

2010-04-13 Thread Ramnivas Laddad
Yes this is possible and has been done many times. For example, Spring
Insight accepts applications that are typically based on Spring's
proxy-based AOP. But, Insight itself uses LTW to collect metric and other
insightful data.

-Ramnivas

On Tue, Apr 13, 2010 at 12:29 AM, Olle Hallin  wrote:

> Hi!
>
> We use Spring AOP extensively in our multi-module Spring project, both with
> Spring's @Transactional and some custom aspects.
>
> I've made an attempt to convert it to LTW, but skipped that because of the
> numer of ways we launch our adviced code; right-click any individual JUnit
> test inside Eclipse, right-click any individual JUnit test inside IntelliJ,
> mvn test for mvn jetty:run for 5 different webapps, mvn tomcat:run for 5
> different webapps and start scripts for 5 different webapps in a number of
> different test, stage and production environments.
> Did I hear snowball?
>
> The original reason that I wanted to enable LTW is that I want to advice
> object initialization (in addition to execution() which is the only kind
> Spring AOP supports).
>
> My aspect should collect runtime data about what classes that a) has been
> initialized and b) has actually been used in production.
> The output should be a data file that should be used by a Maven plugin for
> detecting truly dead Java code and JSPs.
>
> I have planned to let this dead-code aspect run for one month, and later
> use the collected data for deleting code in the next sprint.
>
> Now to the question:
>
>  Is it possible to mix Spring's  and @Aspect-style
> aspects with LTW and a separately compiled aspect jar produced with CTW?
>
> Olle Hallin
> Senior Java Developer and Architect
> olle.hal...@crisp.se
> www.crisp.se
> http://www.linkedin.com/in/ollehallin
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] How to match a Java build-in type?

2010-04-20 Thread Ramnivas Laddad
Those pointcuts look fine. Can you show the code (call site) where you
expected a match?

-Ramnivas

2010/4/20 ekinrf 

> Hi everyone,
>
> I was wondering if we could use AspectJ to match a Java build-in type, say
> String or Object. I tried pointcut like call(*.new(..)) and call(*
> Object.*(..)), but they didn't work. Anyone got a hint?
>
> Regards with thanks,
> Fang
>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: Re : [aspectj-users] Re: [groovy-user] AspectG?

2010-06-17 Thread Ramnivas Laddad
Indeed, that will be an interesting multi-paradigm language: functional
object aspect oriented :-)

-Ramnivas

On Thu, Jun 17, 2010 at 1:36 AM, Miles Sabin  wrote:

> On Wed, Jun 16, 2010 at 4:49 PM, Matthew Adams 
> wrote:
> > If you want this support, make sure to vote for these issues.  For
> > Scala support, you might want to enter your own issues at the AspectJ
> > and Scala projects.
>
> Aspects for Scala would be of interest to me.
>
> If I had unlimited free time I would most likely investigate the
> possibility of doing it via a combination of a Scala compiler plugin
> and a Scala internal DSL for specifying pointcuts, advice etc. rather
> than creating a whole new AspectS language akin to AspectJ. I would
> imagine that the standard AspectJ runtime could be reused pretty much
> as is.
>
> It'd be a pretty cool project to work on ...
>
> Cheers,
>
>
> Miles
>
> --
> Miles Sabin
> tel: +44 7813 944 528
> gtalk: mi...@milessabin.com
> skype: milessabin
> http://www.chuusai.com/
> http://twitter.com/milessabin
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] Dynamically disable a pointcut

2010-06-29 Thread Ramnivas Laddad
If indeed isTraceEnabled is set to 'false', your pointcut will not select
anything and you shouldn't get any tracing. Try printing isTraceEnabled in
your advice to see if it has been set to 'true'.

-Ramnivas

On Tue, Jun 29, 2010 at 8:37 AM, rampaadh  wrote:

>
> I am new user to AspectJ Programming. I am writing a custom aspect to trace
> method entry and exit points.
>
> I have a pointcut and a boolean variable isTraceEnabled to control it.
>
> --
> private static boolean isTraceEnabled = false;
> pointcut traceMethods(): if (isTraceEnabled)
>  && (execution(* *.*(..)) ||
> execution(*.new(..)))
> && !within(com.sample.TraceAspect)
> && !execution(* *.*$*(..))
> && !within(Pointcuts.*);
> --
>
> But though I have disabled the pointcut, still it evaluates all the method
> entries / exits.  Hence I am getting performance issues.  Is there any way
> to completely disable the pointcut and enable it whenever I want?
>
> I read few articles in this forum, everyone suggested having a boolean
> variable, but it seems not working to me.  Method entry/exits are still
> evaulated even the boolean variable value is false.
> --
> View this message in context:
> http://aspectj.2085585.n4.nabble.com/Dynamically-disable-a-pointcut-tp2272366p2272366.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] aspectJ big example!!

2010-06-29 Thread Ramnivas Laddad
If you are looking for bigger aspects, take a look at examples from the
second edition of AspectJ in Action (http://manning.com/laddad2). Also take
a look at the Spring project (its transaction management and domain-object
dependency injection aspects are fairly involved).

If you are looking at Java apps to include aspects, there are plenty open
source projects for you to try out.

-Ramnivas

On Thu, Jun 24, 2010 at 11:25 PM, akbar sana  wrote:

> hi
>
> i want to have a big project/ big example in aspectj. like the example of "
> transaction management (chapter 11)" given in "aspectj in action" (a book),
> with all code.
>
> plz can anybody tell me the source
>
> waiting for reply
> thanx
> bye
> sana
>
>
>
>
>
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Re: [aspectj-users] basic question regarding 'after throwing' advice

2010-06-30 Thread Ramnivas Laddad
Take a look at section 10.6 from AspectJ in Action (if you don't have the
book, you can download sources from manning.com/laddad2). It users a
thread-local for the same purpose.

-Ramnivas

On Wed, Jun 30, 2010 at 2:04 AM, Ashank  wrote:

>
> Hello All,
>
> I have a simple question regarding 'after throwing' advice. I'm trying to
> advice runtime exceptions/errors originating in my app. My aspect is as
> follows:
>
> aspect ExceptionHandlersAspect extends GenericAspect {
>
>pointcut AllMethsExecPC():execution(* *(..));
>
>after() throwing (RuntimeException rte): AllMethsExecPC() {
>String className =
> thisJoinPointStaticPart.getSignature().getDeclaringTypeName();
>String methName =
> thisJoinPointStaticPart.getSignature().getName();
>String methKey = className + "." + methName + "(" +
> AJUtils.getParamNames(thisJoinPointStaticPart) + ")";
>myLogger.fine("EXCEPTION " + rte + " : In Exception handler
> aspect,
> methkey is " + methKey);
>}
>
>after() throwing (Error err): AllMethsExecPC() {
>String className =
> thisJoinPointStaticPart.getSignature().getDeclaringTypeName();
>String methName =
> thisJoinPointStaticPart.getSignature().getName();
>String methKey = className + "." + methName + "(" +
> AJUtils.getParamNames(thisJoinPointStaticPart) + ")";
>myLogger.fine("ERROR: " + err + " In Exception handler
> aspect, methkey is
> " + methKey);
>}
> }
>
> Now, these advices detect implicit RuntimeExceptions like
> NullPointerExceptions or Divide by zero ArthimeticExceptions(thrown by the
> JVM) just fine but they capture the same exception everytime it is
> propogated up the call stack!
>
> For e.g.,
>
> int x = 1;
>
>void catchAndThrowException() {
>try {
>throwException();
>}
>catch(RuntimeException e) {
>throw e;
>}
>}
>
>void throwException() {
>if (x==1)
>throw new RuntimeException("EGSITE exception");
>}
>
> In the above code snippet, suppose I am calling catchAndThrowException()
> method.  I just want to detect the runtimeexception in the throwException()
> method and not in the catchAndThrowException() method. Currently, my advice
> matches both these joinpoints.
>
> I just want to capture them when they originate and be done with it.
> Something like !cflowbelow(...). What can I use?
>
> Secondly, my pointcut captures all method executions in my app. Could this
> bog down my application or significantly affect its performance? I cannot
> use within() or withincode() pointcuts although I have excluded some
> packages in my aop-ajc.xml file. Please suggest ideas/optimizations if
> possible! Thank you very much.
>
> -Arvind
>
> --
> View this message in context:
> http://aspectj.2085585.n4.nabble.com/basic-question-regarding-after-throwing-advice-tp2272690p2272690.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> ___
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
___
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users


  1   2   >