Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » Struggling with how to make a simple poincut
Struggling with how to make a simple poincut [message #543264] Mon, 28 June 2010 21:03 Go to next message
Daniel Kashtan is currently offline Daniel Kashtan
Messages: 15
Registered: March 2010
Junior Member
I would like for some code to be called after a certain JButton is created, in this case:

JButton commitButton = new JButton("Commit");

When that button is called, I would like to insert some lines of code right after that. I can do that based on it being a JButton or based on the fact that it is a JButton and the arg is "Commit" right?

Here is what I have so far, but it is syntactically incorrect. Any suggestions?

public aspect HelloAspect {
after() : call("new JButton("Commit")") && !within(HelloAspect)
{
System.out.println("Commit button constructed");
}
}


Also, I am kinda struggling with the AOP lingo, so correct me if I am wrong, but I am asking for help on how to write my pointcut on a JButton initialization join point?
Re: Struggling with how to make a simple poincut [message #543485 is a reply to message #543264] Tue, 29 June 2010 14:55 Go to previous messageGo to next message
Daniel Kashtan is currently offline Daniel Kashtan
Messages: 15
Registered: March 2010
Junior Member
I got it Smile

after(String s) : call(javax.swing.JButton.new(String))
&& args(s)
&& if(s.equals("Commit"))
&& !within(HelloAspect)
{
System.out.println("Commit button constructed");
}
Re: Struggling with how to make a simple poincut [message #601102 is a reply to message #543264] Tue, 29 June 2010 14:55 Go to previous message
Daniel Kashtan is currently offline Daniel Kashtan
Messages: 15
Registered: March 2010
Junior Member
I got it :)

after(String s) : call(javax.swing.JButton.new(String))
&& args(s)
&& if(s.equals("Commit"))
&& !within(HelloAspect)
{
System.out.println("Commit button constructed");
}
Previous Topic:Struggling with how to make a simple poincut
Next Topic:"Property marker value too long" exception during build
Goto Forum:
  


Current Time: Tue Sep 23 16:39:31 GMT 2014

Powered by FUDForum. Page generated in 0.02556 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software