• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Spring AOP program not running as expected

Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am referring to Spring In Action and I am at the end of the first chapter i.e. Springing into action.

I am trting to run the demo given for AOP introduction.

I am giving the code for all here including my xml file.

This is my employee class

This is my MyLogger class

This is the configuration file

What I expected is whenever I call embarkObQuest() method on the employee object it will first call the before() method of MyLogger and then the embarkOnquest() method execution and after that after() method on MyLogger object.
But when I run the program it shows only the output from embarkOnQuest() method and not from before() and after) method.

What may be wrong?

Here is the client code.

public class Main {

* @param args the command line arguments
public static void main(String[] args) {
// TODO code application logic here
BeanFactory factory = new XmlBeanFactory(new FileSystemResource("./config/employee.xml.xml"));
Employee emp = (Employee)factory.getBean("emp");
Object obj = emp.embarkOnQuest();

Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure that using a plain XmlBeanFactory works for this; I'd use an ApplicationContext (a ClassPathXmlApplicationContext, in this case) to make sure pre- and post-processors are registered.I'd also recommend using classpath-based configuration files (and avoiding filenames with doubled extensions ;)
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic