This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes define method execute order  in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "define method execute order  in java" Watch "define method execute order  in java" New topic
Author

define method execute order in java

jim li
Ranch Hand

Joined: May 20, 2008
Posts: 180
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

Joined: Oct 01, 2001
Posts: 2849
    
  11

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

Joined: May 20, 2008
Posts: 180
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

Joined: Oct 27, 2005
Posts: 19684
    
  20

jim li wrote:tx

Please UseRealWords: "thanks".

You could try to check out AspectJ. This allows you to surround method calls with other code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: define method execute order in java