• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

define method execute order in java

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic