Lines 52-59
Link Here
|
52 |
*/ |
52 |
*/ |
53 |
public byte[] preProcess(String className, byte[] bytes, ClassLoader loader) { |
53 |
public byte[] preProcess(String className, byte[] bytes, ClassLoader loader) { |
54 |
//TODO AV needs to doc that |
54 |
//TODO AV needs to doc that |
55 |
if (loader == null || className == null) { |
55 |
if (loader == null || className == null || className.startsWith("org/aspectj/")) { |
56 |
// skip boot loader or null classes (hibernate) |
56 |
// skip boot loader, null classes (hibernate), and any AspectJ implementation classes (if weaving into aspectjweaver.jar) |
57 |
return bytes; |
57 |
return bytes; |
58 |
} |
58 |
} |
59 |
|
59 |
|
Lines 117-137
Link Here
|
117 |
|
117 |
|
118 |
static class ExplicitlyInitializedClassLoaderWeavingAdaptor { |
118 |
static class ExplicitlyInitializedClassLoaderWeavingAdaptor { |
119 |
private final ClassLoaderWeavingAdaptor weavingAdaptor; |
119 |
private final ClassLoaderWeavingAdaptor weavingAdaptor; |
120 |
private boolean isInitialized; |
120 |
private final static int NOT_INITIALIZED = 0; |
|
|
121 |
private final static int IS_INITIALIZING = 1; |
122 |
private final static int FINISHED_INITIALIZING = 2; |
123 |
private int initializationState; |
121 |
|
124 |
|
122 |
public ExplicitlyInitializedClassLoaderWeavingAdaptor(ClassLoaderWeavingAdaptor weavingAdaptor) { |
125 |
public ExplicitlyInitializedClassLoaderWeavingAdaptor(ClassLoaderWeavingAdaptor weavingAdaptor) { |
123 |
this.weavingAdaptor = weavingAdaptor; |
126 |
this.weavingAdaptor = weavingAdaptor; |
124 |
this.isInitialized = false; |
127 |
this.initializationState = NOT_INITIALIZED; |
125 |
} |
128 |
} |
126 |
|
129 |
|
127 |
private void initialize(ClassLoader loader, IWeavingContext weavingContext) { |
130 |
private void initialize(ClassLoader loader, IWeavingContext weavingContext) { |
128 |
if (!isInitialized) { |
131 |
//thread safety? |
129 |
isInitialized = true; |
132 |
if (initializationState == NOT_INITIALIZED) { |
|
|
133 |
initializationState = IS_INITIALIZING; |
130 |
weavingAdaptor.initialize(loader, weavingContext); |
134 |
weavingAdaptor.initialize(loader, weavingContext); |
|
|
135 |
initializationState = FINISHED_INITIALIZING; |
131 |
} |
136 |
} |
132 |
} |
137 |
} |
133 |
|
138 |
|
134 |
public ClassLoaderWeavingAdaptor getWeavingAdaptor(ClassLoader loader, IWeavingContext weavingContext) { |
139 |
public ClassLoaderWeavingAdaptor getWeavingAdaptor(ClassLoader loader, IWeavingContext weavingContext) { |
|
|
140 |
if (initializationState == IS_INITIALIZING) { |
141 |
// can't weave myself while initializing: the null return causes the system to return unwoven bytes |
142 |
return null; |
143 |
} |
135 |
initialize(loader, weavingContext); |
144 |
initialize(loader, weavingContext); |
136 |
return weavingAdaptor; |
145 |
return weavingAdaptor; |
137 |
} |
146 |
} |