Announcement Announcement Module
Collapse
No announcement yet.
Can I intercept Abstract classes? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can I intercept Abstract classes?

    Hi ,

    i tried to intercept an abstract class.....

    using the following configuratiion...

    It is giving InstantiationException ( ob ,An abstract class cannot be instantiated )...

    as every action class of mine will be extending my abstract class......(which extends struts Action class)...

    i need to intercept some code to the Abstract class..to ensure something to happen whenever any of my action is called......


    Is there any solution to this problem?

    bye

    TOM

  • #2
    You need a concrete target. Spring AOP doesn't modify the byte code, so it won't make an abstract class concrete. You can achieve what I think you want by having no target, but intercepting methods against an interface, with your interceptors providing all behaviour.

    Comment


    • #3
      Hi Rod,

      My requirement is like this .

      I dont want my class which is to be intercepted invoked through spring.

      i.e i don't have any application context bean to instantiate my class.

      Can I specify in config.xml a class name . (for which i can only specify Interceptor names).

      So that whenever at runtime this class is invoked by some how ,not through spring ,i need some code to intercept.

      Thanks and Regards

      TOM

      Comment


      • #4
        Plain Spring AOP only works through configuring your classes in the application context or by using the AOP api programmatically. If you need to have plain Java aspects for classes not managed by Spring, you're going to need something like AspectJ. You are going to run into things like build-time processing or modifications of your JVM (adding additional libraries to the bootstrapping environment of the jvm, etcetera).

        Have a look at http://www-106.ibm.com/developerwork...ry/j-aopwork1/
        It's a comparison of AOP frameworks.

        regards,
        Alef Arendsen

        Comment

        Working...
        X