aspose file tools
The moose likes Struts and the fly likes  Spring AOP: Define Pointcuts for Static methods ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Struts
Reply Bookmark " Spring AOP: Define Pointcuts for Static methods ?" Watch " Spring AOP: Define Pointcuts for Static methods ?" New topic
Author

Spring AOP: Define Pointcuts for Static methods ?

John Vergis
Ranch Hand

Joined: Feb 24, 2004
Posts: 59
Hi,

Could anybody help me in defining Advisors for static methods.

I was able to Proxy a class [MyTestBean] using BeanNameAutoProxyCreator and was able to get the Interceptors working for that class.

I have two issues:

Firstly,
The interceptors doesn't work when the methods intercepted are static. But I wanted to define pointcuts for those methods. Could you please let me know how to set the pointcuts for these methods.

Secondly,
I am proxying a Singleton class (my constructor is private). I am getting an exception as below when i try to proxy such a class called MyTestBean1.

-- org.springframework.beans.factory.support.BeanDefinitionValidationException: No public constructor in class [class com.springaop.test.MyTestBean1]


Could anybody please help me, as I stuck bcoz of these 2 issues.

Thanks in advance
Rosy
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by John Vergis:
The interceptors doesn't work when the methods intercepted are static. But I wanted to define pointcuts for those methods. Could you please let me know how to set the pointcuts for these methods.
I don't think you can. You could create a class that knows how to invoke those static methods, and apply advice against an instance of that wrapper class. But I would query the design, though - do you need these static methods? Static methods are evil. They can't implement interfaces. They are not polymorphic.

I am proxying a Singleton class (my constructor is private). I am getting an exception as below when i try to proxy such a class called MyTestBean1.
You can create a FactoryBean that knows how to instantiate your singleton. But why don't you let Spring manage this? Spring-managed beans are all singletons unless you dictate otherwise.

- Peter
[ June 02, 2004: Message edited by: Peter den Haan ]
 
IntelliJ Java IDE
 
subject: Spring AOP: Define Pointcuts for Static methods ?
 
Threads others viewed
final class vs final methods
EJB 3 - lifecycle callback interceptor - should not be final or static?
return type in web service
This week book give away
Problem with @Transactional annotation
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com