Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.context.weaving;
|
||||
|
||||
|
||||
import java.lang.instrument.ClassFileTransformer;
|
||||
import java.lang.instrument.IllegalClassFormatException;
|
||||
import java.security.ProtectionDomain;
|
||||
@@ -44,12 +43,13 @@ import org.springframework.instrument.classloading.LoadTimeWeaver;
|
||||
public class AspectJWeavingEnabler
|
||||
implements BeanFactoryPostProcessor, BeanClassLoaderAware, LoadTimeWeaverAware, Ordered {
|
||||
|
||||
public static final String ASPECTJ_AOP_XML_RESOURCE = "META-INF/aop.xml";
|
||||
|
||||
|
||||
private ClassLoader beanClassLoader;
|
||||
|
||||
private LoadTimeWeaver loadTimeWeaver;
|
||||
|
||||
public static final String ASPECTJ_AOP_XML_RESOURCE = "META-INF/aop.xml";
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
@@ -71,6 +71,12 @@ public class AspectJWeavingEnabler
|
||||
enableAspectJWeaving(this.loadTimeWeaver, this.beanClassLoader);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable AspectJ weaving with the given {@link LoadTimeWeaver}.
|
||||
* @param weaverToUse the LoadTimeWeaver to apply to (or {@code null} for a default weaver)
|
||||
* @param beanClassLoader the class loader to create a default weaver for (if necessary)
|
||||
*/
|
||||
public static void enableAspectJWeaving(LoadTimeWeaver weaverToUse, ClassLoader beanClassLoader) {
|
||||
if (weaverToUse == null) {
|
||||
if (InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) {
|
||||
@@ -80,8 +86,8 @@ public class AspectJWeavingEnabler
|
||||
throw new IllegalStateException("No LoadTimeWeaver available");
|
||||
}
|
||||
}
|
||||
weaverToUse.addTransformer(new AspectJClassBypassingClassFileTransformer(
|
||||
new ClassPreProcessorAgentAdapter()));
|
||||
weaverToUse.addTransformer(
|
||||
new AspectJClassBypassingClassFileTransformer(new ClassPreProcessorAgentAdapter()));
|
||||
}
|
||||
|
||||
|
||||
@@ -108,4 +114,5 @@ public class AspectJWeavingEnabler
|
||||
return this.delegate.transform(loader, className, classBeingRedefined, protectionDomain, classfileBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user