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]>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] [[email protected]]
> On Behalf Of Ramnivas Laddad [[email protected]]
> Sent: Wednesday, June 30, 2010 9:48 PM
> To: [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]>> 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]> [[email protected]
> <mailto:[email protected]>] On Behalf Of Ramnivas Laddad [
> [email protected]<mailto:[email protected]>]
> Sent: Wednesday, June 30, 2010 5:30 PM
> To: [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]>>> 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]>>
> 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

Reply via email to