org.springframework.context.weaving
Class AspectJWeavingEnabler

java.lang.Object
  extended by org.springframework.context.weaving.AspectJWeavingEnabler
All Implemented Interfaces:
Aware, BeanClassLoaderAware, BeanFactoryPostProcessor, LoadTimeWeaverAware, Ordered

public class AspectJWeavingEnabler
extends java.lang.Object
implements BeanFactoryPostProcessor, BeanClassLoaderAware, LoadTimeWeaverAware, Ordered

Post-processor that registers AspectJ's org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter with the Spring application context's default LoadTimeWeaver.

Since:
2.5
Author:
Juergen Hoeller, Ramnivas Laddad

Nested Class Summary
private static class AspectJWeavingEnabler.AspectJClassBypassingClassFileTransformer
          ClassFileTransformer decorator that suppresses processing of AspectJ classes in order to avoid potential LinkageErrors.
 
Field Summary
static java.lang.String ASPECTJ_AOP_XML_RESOURCE
           
private  java.lang.ClassLoader beanClassLoader
           
private  LoadTimeWeaver loadTimeWeaver
           
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
AspectJWeavingEnabler()
           
 
Method Summary
static void enableAspectJWeaving(LoadTimeWeaver weaverToUse, java.lang.ClassLoader beanClassLoader)
           
 int getOrder()
          Return the order value of this object, with a higher value meaning greater in terms of sorting.
 void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
          Modify the application context's internal bean factory after its standard initialization.
 void setBeanClassLoader(java.lang.ClassLoader classLoader)
          Callback that supplies the bean class loader to a bean instance.
 void setLoadTimeWeaver(LoadTimeWeaver loadTimeWeaver)
          Set the LoadTimeWeaver of this object's containing ApplicationContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

beanClassLoader

private java.lang.ClassLoader beanClassLoader

loadTimeWeaver

private LoadTimeWeaver loadTimeWeaver

ASPECTJ_AOP_XML_RESOURCE

public static final java.lang.String ASPECTJ_AOP_XML_RESOURCE
See Also:
Constant Field Values
Constructor Detail

AspectJWeavingEnabler

public AspectJWeavingEnabler()
Method Detail

setBeanClassLoader

public void setBeanClassLoader(java.lang.ClassLoader classLoader)
Description copied from interface: BeanClassLoaderAware
Callback that supplies the bean class loader to a bean instance.

Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean's InitializingBean.afterPropertiesSet() method or a custom init-method.

Specified by:
setBeanClassLoader in interface BeanClassLoaderAware
Parameters:
classLoader - the owning class loader; may be null in which case a default ClassLoader must be used, for example the ClassLoader obtained via ClassUtils.getDefaultClassLoader()

setLoadTimeWeaver

public void setLoadTimeWeaver(LoadTimeWeaver loadTimeWeaver)
Description copied from interface: LoadTimeWeaverAware
Set the LoadTimeWeaver of this object's containing ApplicationContext.

Invoked after the population of normal bean properties but before an initialization callback like InitializingBean's afterPropertiesSet() or a custom init-method. Invoked after ApplicationContextAware's setApplicationContext(..).

NOTE: This method will only be called if there actually is a LoadTimeWeaver available in the application context. If there is none, the method will simply not get invoked, assuming that the implementing object is able to activate its weaving dependency accordingly.

Specified by:
setLoadTimeWeaver in interface LoadTimeWeaverAware
Parameters:
loadTimeWeaver - the LoadTimeWeaver instance (never null)
See Also:
InitializingBean.afterPropertiesSet(), ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)

getOrder

public int getOrder()
Description copied from interface: Ordered
Return the order value of this object, with a higher value meaning greater in terms of sorting.

Normally starting with 0, with Integer.MAX_VALUE indicating the greatest value. Same order values will result in arbitrary positions for the affected objects.

Higher values can be interpreted as lower priority. As a consequence, the object with the lowest value has highest priority (somewhat analogous to Servlet "load-on-startup" values).

Specified by:
getOrder in interface Ordered
Returns:
the order value

postProcessBeanFactory

public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
                            throws BeansException
Description copied from interface: BeanFactoryPostProcessor
Modify the application context's internal bean factory after its standard initialization. All bean definitions will have been loaded, but no beans will have been instantiated yet. This allows for overriding or adding properties even to eager-initializing beans.

Specified by:
postProcessBeanFactory in interface BeanFactoryPostProcessor
Parameters:
beanFactory - the bean factory used by the application context
Throws:
BeansException - in case of errors

enableAspectJWeaving

public static void enableAspectJWeaving(LoadTimeWeaver weaverToUse,
                                        java.lang.ClassLoader beanClassLoader)