ch.elca.el4j.util.metadata
Class GenericMetaDataAdvisor

java.lang.Object
  extended by org.springframework.aop.support.StaticMethodMatcher
      extended by org.springframework.aop.support.StaticMethodMatcherPointcut
          extended by org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor
              extended by ch.elca.el4j.util.metadata.GenericMetaDataAdvisor
All Implemented Interfaces:
Serializable, Advisor, MethodMatcher, Pointcut, PointcutAdvisor, InitializingBean, Ordered

public class GenericMetaDataAdvisor
extends StaticMethodMatcherPointcutAdvisor
implements InitializingBean

This class simplifies the metadata programming.

One way to set up AOP in Spring is to define a DefaultAdvisorAutoProxyCreator bean which will create AOP proxies for all Advisors that are defined in the same BeanFactory. These advisors are the starting points for Attributes. For each attribute, at least 4 beans have to be defined:

Advisor:
Base interface holding AOP advice (action to take at a joinpoint).
Advice:
A possible advice is for example a MethodInterceptor which intercepts runtime events that occur within a base program. There is a link from the Advisor to the Advice.
Source:
Sources the attributes. There is a link from the Advice to the Source telling the Advice which attribute sources it has to consider.
Attributes:
The attributes implementation to use. There is a link from Source to Attributes to define where it has to take the attributes from.

This class simplifies the creation of attributes. By using it, only two beans have to be defined:

GenericMetaDataAdvisor:
This bean is an advisor implementing the matches(Method, Class) method. This advisor also creates a DefaultGenericAttributeSource in case no one is defined in the configuration file. The attributes to which the Advice will react also have to be defined in the configuration file.
Advice:
An advice which will be invoked by this Advisor has to be injected via the configuration file.

Author:
Raphael Boog (RBO), Martin Zeltner (MZE)
See Also:
Serialized Form
File-location:
GenericMetaDataAdvisor
Last check-in date:
2010-01-15 12:21:07 +0100 (Fr, 15. Jan 2010) by jonasha for revision 4091

Field Summary
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Fields inherited from interface org.springframework.aop.Pointcut
TRUE
 
Fields inherited from interface org.springframework.aop.MethodMatcher
TRUE
 
Constructor Summary
GenericMetaDataAdvisor()
          Default constructor.
GenericMetaDataAdvisor(org.aopalliance.aop.Advice advice)
          Constructor which sets the advice being received as parameter.
 
Method Summary
 void afterPropertiesSet()
          
 List<Class> getInterceptingMetaData()
           
 GenericMetaDataSource getMetaDataSource()
           
 org.aopalliance.intercept.MethodInterceptor getMethodInterceptor()
          A convenience getter method for the method interceptor.
 boolean matches(Method method, Class targetClass)
          Perform static checking.
 void setInterceptingMetaData(List<Class> interceptingMetaData)
           
 void setMetaDataSource(GenericMetaDataSource metaDataSource)
           
 void setMethodInterceptor(org.aopalliance.intercept.MethodInterceptor methodInterceptor)
          A convenience setter method for the method Interceptor.
 
Methods inherited from class org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor
getAdvice, getOrder, getPointcut, isPerInstance, setAdvice, setOrder
 
Methods inherited from class org.springframework.aop.support.StaticMethodMatcherPointcut
getClassFilter, getMethodMatcher, setClassFilter
 
Methods inherited from class org.springframework.aop.support.StaticMethodMatcher
isRuntime, matches
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericMetaDataAdvisor

public GenericMetaDataAdvisor()
Default constructor.


GenericMetaDataAdvisor

public GenericMetaDataAdvisor(org.aopalliance.aop.Advice advice)
Constructor which sets the advice being received as parameter.

Parameters:
advice - The advice to set.
Method Detail

getInterceptingMetaData

public List<Class> getInterceptingMetaData()
Returns:
Returns the interceptingMetaData.

setInterceptingMetaData

public void setInterceptingMetaData(List<Class> interceptingMetaData)
Parameters:
interceptingMetaData - Is the interceptingMetaData to set.

getMetaDataSource

public GenericMetaDataSource getMetaDataSource()
Returns:
Returns the metaDataSource.

setMetaDataSource

public void setMetaDataSource(GenericMetaDataSource metaDataSource)
Parameters:
metaDataSource - Is the metaDataSource to set.

getMethodInterceptor

public org.aopalliance.intercept.MethodInterceptor getMethodInterceptor()
A convenience getter method for the method interceptor.

Returns:
The methodInterceptor

setMethodInterceptor

public void setMethodInterceptor(org.aopalliance.intercept.MethodInterceptor methodInterceptor)
A convenience setter method for the method Interceptor.

Parameters:
methodInterceptor - The methodInterceptor to set.

matches

public boolean matches(Method method,
                       Class targetClass)
Perform static checking. If this returns false, no runtime check will be made.

Specified by:
matches in interface MethodMatcher
Parameters:
method - the candidate method
targetClass - target class (may be null, in which case the candidate class must be taken to be the method's declaring class)
Returns:
whether or not this method matches statically

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception


Copyright © 2005-2011 ELCA. All Rights Reserved.