File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

define method execute order in java

 
jim li
Ranch Hand
Posts: 180
  • 0
  • 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: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 0
  • 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
  • 0
  • 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: 20368
43
Chrome Eclipse IDE Java Windows
  • 0
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic