Announcement Announcement Module
Collapse
No announcement yet.
Spring AOP and JSPs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring AOP and JSPs

    Hi,
    I have a system with lots of bad JSPs rife with procedural code. I'd like to advise some of the methods in these JSPs. Was wondering if anyone had attempted this with Spring AOP.

    I've done it before with AspectJ by precompiling the JSPs, painful and container specific but it worked.

    Thanks

  • #2
    AFAIK, Spring Framework does not use binary code manipulation to implement AOP. With this in mind, you can advise objects as long as you get instances of your objects from Spring Contexts.

    In response to your question, I am not aware of a way to instanciate JSPs/Servlets within Spring and provide instances to your Web Container without going in the deep hell of servlets life cycle.

    You can however rely on Spring Framework 1.1 support for AspectJ to reuse your actual development.

    Comment


    • #3
      You're right Spring doesn't use binary manipulation, but J2SE dynamic proxies (java.lang.reflect.Proxy) or CGLIB2. JDK dynamic proxies need an interface to proxy to, and CGLIB requires that it is possible to subclass the target. These proxies would then replace your target object.

      As the previous poster comments, to advise any object with Spring, Spring needs to manage creation of the target object so it can replace it with the proxy. Generally the web container will do JSP creation so you're probably out of luck.

      I'd recommend just moving the procedural code out into Java, which would be good practice anyway. If there is a cross cutting concern, then it would be possible to implement AOP on the Java objects.

      Comment

      Working...
      X