View Full Version : Can I intercept Abstract classes?
Mar 23rd, 2005, 11:29 PM
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?
Mar 24th, 2005, 03:06 AM
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.
Mar 28th, 2005, 12:13 AM
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
Mar 28th, 2005, 01:50 AM
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/developerworks/java/library/j-aopwork1/
It's a comparison of AOP frameworks.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.