• 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

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
Hi,

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();
}


}
 
Author
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 ;)
reply
    Bookmark Topic Watch Topic
  • New Topic