Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

define method execute order in java

 
jim li
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class test{

public void test1(){}

public void test2(){}

public void test3(){}
}

when i call method test1(), i want test2() method to be executed before test1() is invoked, and test3() method be excuted after test1() finishes .

is there any annotation allow me to do this.

appreciate your help
 
Greg Charles
Sheriff
Posts: 3002
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general, no, I don't think so.

In the context of a testing framework like JUnit or TestNG, then yes. Can you be more specific what you're trying to do?
 
jim li
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Charles wrote:In general, no, I don't think so.

In the context of a testing framework like JUnit or TestNG, then yes. Can you be more specific what you're trying to do?


when i invoke the persist method in hibernate, i want to execute some methods before and after the persist method.

tx for the help
 
Rob Spoor
Sheriff
Pie
Posts: 20751
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jim li wrote:tx

Please UseRealWords: "thanks".

You could try to check out AspectJ. This allows you to surround method calls with other code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic