KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > instrument > classloading > LoadTimeWeaver


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
20
21 /**
22  * Defines the contract for adding one or more
23  * {@link ClassFileTransformer ClassFileTransformers} to a
24  * {@link ClassLoader} - typically the current context class loader.
25  *
26  * <p>Implementations may of course provide their own class loader as well.
27  *
28  * @author Rod Johnson
29  * @author Costin Leau
30  * @since 2.0
31  */

32 public interface LoadTimeWeaver {
33
34     /**
35      * Add a class file transformer to be applied by this load-time weaver.
36      * @param transformer the class file transformer to add
37      */

38     void addTransformer(ClassFileTransformer JavaDoc transformer);
39     
40     /**
41      * Return a class loader that supports instrumentation through AspectJ-style load-time
42      * weaving based on user-defined {@link ClassFileTransformer ClassFileTransformers}.
43      * <p>May be the current class loader, or a class loader created by this
44      * {@link LoadTimeWeaver} instance.
45      * @return a class loader that supports instrumentation through AspectJ-style load-time
46      * weaving based on user-defined {@link ClassFileTransformer ClassFileTransformers}
47      */

48     ClassLoader JavaDoc getInstrumentableClassLoader();
49     
50     /**
51      * Return a throwaway class loader, enabling classes to be loaded and
52      * inspected without affecting the parent class loader.
53      * <p>Should <i>not</i> return the same instance of the {@link ClassLoader}
54      * returned from an invocation of {@link #getInstrumentableClassLoader()}.
55      * @return a temporary throwaway class loader; should return a new
56      * instance for each call, with no existing state
57      */

58     ClassLoader JavaDoc getThrowawayClassLoader();
59
60 }
61
Popular Tags