I quick cut and paste entry:
Re: Authorization via AOP
Oh, hey, I'd been meaning to post a follow up. Using the GenericORMController,
it was a piece of cake, but then I thought, "hey!", I should probably wrap it around
the reactor bits instead, since I've got OO queries and reads and whatnot.
Anyways, I haven't gotten around to that yet, but if you want an example of
before advice on the genericORMController, I'll put it up somewhere.
Only took like 10 minutes... I love this AOP stuff, man, love it.
I used "The AOP" example, (you can tell by the comments ;-) for a basis.
Hell, it might take me ages to blog some stuff...
Here's the relevant part of the customized Configuration.xml file (I called mine
mg.core.config.xml), just replace the projects.myproject aspect with your own
class (this bit, of course, replaces the original ormController bean):
<!--
This the controller to use for generic ORM interaction (uses the ormAdapter).
-->
<bean id="ormControllerTarget" class="ModelGlue.unity.controller.GenericORMController" autowire="false">
<constructor-arg name="modelGlue"><ref bean="modelGlue" /></constructor-arg>
<constructor-arg name="name"><value>ORMController</value></constructor-arg>
<constructor-arg name="debug"><value>false</value></constructor-arg>
</bean>
<!--define the loggingBeforeAdvice and set its logging service property to reference the ProxyFactoryBean bean below -->
<bean id="ormControllerBeforeAdvice" class=" projects.myproject.aspects.ORMControllerBeforeAdvice">
<property name="ormController">
<ref bean="ormController" />
</property>
</bean>
<!-- now define a NamedMethodPointcutAdvisor, set the advice property to the bean above, and set its mappedNames property to '*' which will create a pointcut to match all methods excluding any init method -->
<bean id="ormControllerAdvisor" class="coldspring.aop.support.NamedMethodPointcutAdvisor">
<property name="advice">
<ref bean="ormControllerBeforeAdvice" />
</property>
<property name="mappedNames">
<value>*</value>
</property>
</bean>
<!-- now create a ProxyFactoryBean with the id ormController, set the target to the ormControllerTarget bean above, and give it ,the id of the NamedMethodPointcutAdvisor above in the list of interceptorNames -->
<bean id="ormController" class="coldspring.aop.framework.ProxyFactoryBean">
<property name="target">
<ref bean="ormControllerTarget" />
</property>
<property name="interceptorNames">
<list>
<value>ormControllerAdvisor</value>
</list>
</property>
</bean>