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;
18:
19: import java.lang.instrument.ClassFileTransformer;
20:
21: /**
22: * Defines the contract for adding one or more
23: * {@link ClassFileTransformer ClassFileTransformers} to a {@link ClassLoader}
24: * - typically the current context <code>ClassLoader</code>.
25: *
26: * <p>Implementations may of course provide their own <code>ClassLoader</code>
27: * as well.
28: *
29: * @author Rod Johnson
30: * @author Costin Leau
31: * @see java.lang.instrument.ClassFileTransformer
32: * @since 2.0
33: */
34: public interface LoadTimeWeaver {
35:
36: /**
37: * Add a <code>ClassFileTransformer</code> to be applied by this
38: * <code>LoadTimeWeaver</code>.
39: * @param transformer the <code>ClassFileTransformer</code> to add
40: */
41: void addTransformer(ClassFileTransformer transformer);
42:
43: /**
44: * Return a <code>ClassLoader</code> that supports instrumentation
45: * through AspectJ-style load-time weaving based on user-defined
46: * {@link ClassFileTransformer ClassFileTransformers}.
47: * <p>May be the current <code>ClassLoader</code>, or a
48: * <code>ClassLoader</code> created by this {@link LoadTimeWeaver}
49: * instance.
50: */
51: ClassLoader getInstrumentableClassLoader();
52:
53: /**
54: * Return a throwaway <code>ClassLoader</code>, enabling classes to be
55: * loaded and inspected without affecting the parent
56: * <code>ClassLoader</code>.
57: * <p>Should <i>not</i> return the same instance of the {@link ClassLoader}
58: * returned from an invocation of {@link #getInstrumentableClassLoader()}.
59: * @return a temporary throwaway <code>ClassLoader</code>; should return a
60: * new instance for each call, with no existing state
61: */
62: ClassLoader getThrowawayClassLoader();
63:
64: }
|