01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.instrument.classloading.weblogic;
18:
19: import java.lang.instrument.ClassFileTransformer;
20:
21: import org.springframework.instrument.classloading.LoadTimeWeaver;
22: import org.springframework.util.Assert;
23: import org.springframework.util.ClassUtils;
24:
25: /**
26: * {@link LoadTimeWeaver} implementation for WebLogic's instrumentable
27: * ClassLoader.
28: *
29: * <p><b>NOTE:</b> Requires BEA WebLogic version 10 or higher.
30: *
31: * @author Costin Leau
32: * @author Juergen Hoeller
33: * @since 2.5
34: */
35: public class WebLogicLoadTimeWeaver implements LoadTimeWeaver {
36:
37: private final WebLogicClassLoader classLoader;
38:
39: /**
40: * Creates a new instance of the {@link WebLogicLoadTimeWeaver} class using
41: * the default {@link ClassLoader class loader}.
42: * @see org.springframework.util.ClassUtils#getDefaultClassLoader()
43: */
44: public WebLogicLoadTimeWeaver() {
45: this (ClassUtils.getDefaultClassLoader());
46: }
47:
48: /**
49: * Creates a new instance of the {@link WebLogicLoadTimeWeaver} class using
50: * the supplied {@link ClassLoader}.
51: * @param classLoader the <code>ClassLoader</code> to delegate to for
52: * weaving (must not be <code>null</code>)
53: */
54: public WebLogicLoadTimeWeaver(ClassLoader classLoader) {
55: Assert.notNull(classLoader, "ClassLoader must not be null");
56: this .classLoader = new WebLogicClassLoader(classLoader);
57: }
58:
59: public void addTransformer(ClassFileTransformer transformer) {
60: this .classLoader.addTransformer(transformer);
61: }
62:
63: public ClassLoader getInstrumentableClassLoader() {
64: return this .classLoader.getInternalClassLoader();
65: }
66:
67: public ClassLoader getThrowawayClassLoader() {
68: return this.classLoader.getThrowawayClassLoader();
69: }
70:
71: }
|