That works, I guess I just had tunnel-vision with trying to intercept
construction, thanks :)
________________________________________
From: [email protected] [[email protected]] On
Behalf Of Andy Clement [[email protected]]
Sent: Thursday, July 01, 2010 3:29 PM
To: [email protected]
Subject: Re: [aspectj-users] Question about @AspectJ and what it can do
How about just tracking the set of the field instead:
after(Object undoableFieldValue): set(@Undoable * *) &&
args(undoableFieldValue) {
Do you really need to intercept construction?
Andy
---
On 1 July 2010 11:35, Kashtan, Daniel <[email protected]> wrote:
> I am still struggling with this. I am not sure what you mean by using
> target() to pick the object on which the call is made and checking it.
>
> Just to be sure we are on the same page. I am trying to figure out how to
> match a join point of a new JTextField call with a specific annotation above
> it.
> ________________________________________
> From: [email protected] [[email protected]]
> On Behalf Of Ramnivas Laddad [[email protected]]
> Sent: Thursday, July 01, 2010 1:31 PM
> To: [email protected]
> Subject: Re: [aspectj-users] Question about @AspectJ and what it can do
>
> It looks like you are annotating a field with the UndoableJTextField
> annotation. If so, @annotation will select get/set join points associated
> with that field. Your other pointcut is picking up a call join point. Since a
> join point can be of exactly one kind, && leads to no match. You may have to
> use target() to pick the object on which the call is being made and check if
> a field (by searching through the enclosing class using reflection) matches
> that object. Then you can grab annotations from it.
>
> -Ramnivas
>
> On Thu, Jul 1, 2010 at 8:56 AM, Kashtan, Daniel
> <[email protected]<mailto:[email protected]>> wrote:
> I have been referring to those guides a lot so far :)
>
> Also I believe I am very close to getting the desired behaviour I have been
> after. I don't think I need @AsepctJ at all.
>
> pointcut testPC1() : @annotation(UndoableJTextField);
>
> pointcut testPC2(String s, int c) : call(javax.swing.JTextField.new(String,
> int)) && args(s, c);
>
> after(String s, int c) : testPC2(s, c) && testPC1()
> {
> System.out.println("undoableJTextField");
> }
>
>
> TestPC1() will match the JComponents everywhere they are used if they have
> the correct annotation and testPC2() will match wherever I create a new
> JTextField with those arg types, but I cannot get an intersection of the two.
> The && does not give me any matches. I am having a hard time finding the
> right syntax to get that intersection, any suggestions?
>
> ________________________________________
> From:
> [email protected]<mailto:[email protected]>
> [[email protected]<mailto:[email protected]>]
> On Behalf Of Ramnivas Laddad
> [[email protected]<mailto:[email protected]>]
> Sent: Thursday, July 01, 2010 11:43 AM
> To: [email protected]<mailto:[email protected]>
> Subject: Re: [aspectj-users] Question about @AspectJ and what it can do
>
> You might want to read
> http://www.eclipse.org/aspectj/doc/released/adk15notebook/index.html
> and
> http://www.eclipse.org/aspectj/doc/released/progguide/index.html
>
> You might also want to pick a good book on AspectJ :-)
>
> -Ramnivas
>
> On Thu, Jul 1, 2010 at 7:09 AM, Kashtan, Daniel
> <[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>
> wrote:
> The reason I would like to use @aspectj could be because of naiveness when it
> comes to AspectJ. The main goal I am pursuing is easy to show with some code.
>
> @Undoable
> JTextField tf = new JTextField();
>
> @Undoable
> JButton tf = new JButton();
>
> I would like to have the aspect get a reference to the new object created and
> have a clear and compact marker for showing in my code which JComponents are
> undoable.
>
> You mentioned that I could use a target pointcut, but I am looking at the
> docs and I still don't get how that one works yet. Would it accomplish what I
> need?
> ________________________________________
> From:
> [email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>
>
> [[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>]
> On Behalf Of Ramnivas Laddad
> [[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>]
> Sent: Wednesday, June 30, 2010 9:48 PM
> To:
> [email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>
> Subject: Re: [aspectj-users] Question about @AspectJ and what it can do
>
> The code you shown can be mapped to @AspectJ just fine.
>
> As for annotations, in Java (and thus in AspectJ) you cannot put annotations
> on a call site. Differentiating between JTextField and JButton is easy--all
> you need is a target() pointcut.
>
> BTW, is there a reason for pursuing the @AspectJ syntax? The traditional
> syntax is more powerful and there is nothing that you can do with @AspectJ
> that you cannot with traditional.
>
> -Ramnivas
>
> On Wed, Jun 30, 2010 at 5:21 PM, Kashtan, Daniel
> <[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>><mailto:[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>>
> wrote:
> In traditional AspectJ I would do something like below. I didn't get one
> working, but it was something like this.
>
> after(String s) : call(javax.swing.JTextField.new(s)) && args(s) &&
> if(s.equals("textField1") //find out where the JTextfield with text
> "textField1" is instantiated, and run the code below
> {
> //code here (is there a technical term to call the code block in here?)
> undoService.addCallback(new ActionListener()
> {
> public void actionPerformed(ActionEvent ae)
> {
> undoService.addEdit(new UndoableEditDocumentCustom(textField));
> }
> });
> }
>
> The point is to find the JTextField with a starting text of "textField1",
> which is not a good way to identify the JTextField I want, but this is just
> for proof of concept purposes. Once the correct JTextField is found, execute
> the code. With annotations, would it be simple to add this code for a
> specific JComponent? Can the annotation go right on top of the JComponent
> instantiation code? Can the annotation do some extra processing to know if
> the JComponent is a JTextField or JButton so I can call specific code for
> both? Sorry if I am not perfectly clear, I am still really green.
> ________________________________________
> From:
> [email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>><mailto:[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>
>
> [[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>><mailto:[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>]
> On Behalf Of Ramnivas Laddad
> [[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>><mailto:[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>]
> Sent: Wednesday, June 30, 2010 5:30 PM
> To:
> [email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>><mailto:[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>
> Subject: Re: [aspectj-users] Question about @AspectJ and what it can do
>
> Can you show what you intent to do with the traditional syntax? That will
> help in showing if and how it can be mapped to @AspectJ.
>
> -Ramnivas
>
> On Wed, Jun 30, 2010 at 1:47 PM, Kashtan, Daniel
> <[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>><mailto:[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>><mailto:[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>><mailto:[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>>>
> wrote:
> Hey all,
>
> I have AspectJ working real nice right now and I would like to see if
> @AspectJ can let me do those same things in a slicker fashion. I can
> illustrate want I am thinking about by showing my function:
>
> undoService.addCallback(new ActionListener()
> {
> public void actionPerformed(ActionEvent ae)
> {
> undoService.addEdit(new UndoableEditDocumentCustom(textField));
> }
> });
>
> Right now my actionPerformed is hard-wired to send my undoService that
> particular UndoableEdit for a JTextfield. I'd like to automate the process of
> adding these edits. Could I possibly add an annotation above my JComponents
> that would be able to call the code above based on the type of JComponent it
> is? I think I know how to do this in AspectJ, but I am having a hard time
> grasping how @AspectJ works, so any suggestions or pointers would be great :)
>
> This e-mail and any files transmitted with it may be proprietary and are
> intended solely for the use of the individual or entity to whom they are
> addressed. If you have received this e-mail in error please notify the sender.
> Please note that any views or opinions presented in this e-mail are solely
> those of the author and do not necessarily represent those of ITT
> Corporation. The recipient should check this e-mail and any attachments for
> the presence of viruses. ITT accepts no liability for any damage caused by
> any virus transmitted by this e-mail.
> _______________________________________________
> aspectj-users mailing list
> [email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>><mailto:[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>><mailto:[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>><mailto:[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>>
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>><mailto:[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]<mailto:[email protected]>
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users