• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Question

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let say you are in one class and you want to find out when another method is called and you want to call one of your methods right after.

Is that possible, can you use a thread to do that?
 
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

as 100% of the forum posts are questions, it would be a good idea to look for a more self explaining name for your post. "question" is a bit too vague... :-)

to answer your question: yes, it's possible. but not with a finger snip. the approach would be aop (aspect oriented programming, which was actually developed for such requirements. but that's too big to explain in one sentence (at least for me). have a look at the spring-framework, they give an excellent introduction, and see if this is of some use for you. aspectJ would be another alternative, but i consider spring to be easier to use.

oh, and yes - if all this is way too much, have a look at the proxy pattern in general and dynamic proxies in special.

hope it helps you to get started,
jan
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are allowed to design the class with the closely watched method, I think the observer pattern might be useful, if you don't want to go for the full monty of AOP/dynamic proxies:

http://en.wikipedia.org/wiki/Observer_pattern
reply
    Bookmark Topic Watch Topic
  • New Topic