rmangi,
If I understand what you said, deciding what interceptor to use depends on the entity and method called.
So lets configure our interceptors as plain POJOs
Now we create the uber-interceptor with a property of type map that holds the (entity, interceptor) pairsCode:<bean id="interceptor1" class="Interceptor1"/> <bean id="interceptor2" class="Interceptor2"/> ...
myInterceptor will lookup the interceptor to be used for each call using the interceptors map:Code:<bean id="myInterceptor" class="MyInterceptor"> <property name="interceptors"> <entry key="entity1"> <value>interceptor1</value> </entry> <entry key="entity2"> <value>interceptor2</value> </entry> <property> </bean>
I did not try this solution before, but It seems extensible.Code:public class MyInterceptor implements Interceptor, Serializable { private map interceptors; //getters and setters ... public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) { Interceptor interceptor = resolveInterceptor(entity); if (interceptor != null) interceptor.onDelete(entity, id, state, propertynames, types); } ... //interceptor resolver private Interceptor resolveInterceptor(Object entity) { //uses property interceptors, if not found returns null ... return interceptor; } }


Reply With Quote