File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 2771
    
  10

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: 19543
    
  16

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
 
Similar Threads
class and public
protected field
Reference Variable Casting
inheritance for Object class
Inheritance Confusion