Hi Raphael
You can set interceptors with Spring using the BeanNameAutoProxyCreator
and its friends (they are other techniques but that's the one I know/use
the most)
The example below wraps a "blog.dao.blogManagerDAO" bean (defined
elsewhere in the Spring config) with a transaction interceptor named
"blog.dao.transactionInterceptor", which is an interceptor bean also
defined elsewhere.
The BeanNameAutoProxyCreator (Spring) class contains properties
"interceptorNames", and "beanNames" which
tell it which objects methods calls you want to wrap with which
interceptors. There is probably classes in Spring for selecting which
methods to intercept too, and other exotic things.
Example:
<bean
id="beanNameAutoProxyCreator1"
name="beanNameAutoProxyCreator1"
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="interceptorNames">
<list>
<value>blog.dao.transactionInterceptor</value>
</list>
</property>
<property name="beanNames">
<value>blog.dao.blogManagerDAO</value>
</property>
</bean>
So, basically, what you need to do is identify the bean in the Spring
config on which you want to set an interceptor. Create an interceptor
class with the behaviour you want to add, then use a
BeanNameAutoProxyCreator bean (or other Spring interceptor-related
candy) to set the interceptors when Spring creates its beans.
Please do not hesitate to contact me if you need more details.
Denis Balazuc
Raphaël Piéroni wrote:
Hi,
I would like to add a new behaviour just after a weblog entry is saved.
It seems to me that this should be achieved using spring aop.
But, i must admit not knowing anything to spring. (but aop
concepts are known to me - once i played with aspectj)
Can you please tell me how to do it?
My only need is to create an after-advice on the
WeblogManager.saveWeblogEntry(entry) method.
Many thanks in advance for any help.
Regards,
Raphaël
================================================================================
Les données et renseignements contenus dans ce message sont personnels,
confidentiels et secrets. Ce message est adressé à l'individu ou
l'entité dont les coordonnées figurent ci-dessus. Si vous n'êtes pas le
bon destinataire, nous vous demandons de ne pas lire, copier, utiliser
ou divulguer ce message. Nous vous prions de notifier cette erreur à
l'expéditeur et d'effacer immédiatement ce message de votre système.
The information contained in this message is privileged, confidential,
and protected from disclosure. This message is intended for the
individual or entity addressed herein.
If you are not the intended recipient, please do not read, copy, use or
disclose this communication to others.
Also please notify the sender by replying to this message, and then
delete it from your system.
================================================================================