• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

After and before Advice Dosent Fire in spring

 
Ranch Hand
Posts: 300
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have made simple application which does the insert ,update and delete and works successfully now i would like to use AOP in the same application but couldnt achieve that.
Advice dosent fire in the web application as well it works properly from the stand alone application.I have add the code for the xml file here.Please help so i can continue learning with the spring..


UserController:



On the edit method Advice will fire.

My DAO Class:


Interface is UserDAO which contains the prototype for the methods.. and Advice class is as follow:


It dosent work in the web application but when i execute it from the stand alone application like:


IT works fine so i am not aware how can i get the "businesslogicbean" (proxyinterface) to execute the Advice it works perfect in stand alone code which i added here.Can somebody guide me how can i solve the problem.
Any alternate solution.

Regards
Jatan
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are learning from an old example. In newer versions of Spring your controllers should be the annotation based controllers (@Controller) and should not extend any Spring classes. Also the AOP paradigm has shifted and is now much easier than what you are trying to do here. Spring has introduced an AOP configuration namespace for XML and there is also the option of using AspectJ's annotation configuration. Either of these approaches are far easier to work with and less verbose. If I were you I would search for a more up to date example to learn from.

Thanks,
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill,

Thank you for your kind reply but i am not using annotation in my application.. I will be thankful to you if you can guide me without annotation .

Regards
Jatan
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well for an over simplified example with XML.

If you hit the controller the service will execute and the before advice will run resulting in the following output:

INFO : com.sample.app.advice.BeforeAdvice - Advice before the service
INFO : com.sample.app.service.SampleServiceImpl - Hello World!

I assume you are using STS, if you are create a new project from the spring-mvc project template that will generate the structure and the jsp and controller and most of the config. I started with this so you could easily reproduce it. I did change the spring version to 3.1.2

Now here is what I put in my root context




servlet-context



My Service interface and implementation




My advice



Controller

 
Marshal
Posts: 70224
282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to AOP forum.
 
What are you saying? I thought you said that Santa gave you that. And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic