KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > persistence > spi > ClassTransformer


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package javax.persistence.spi;
24
25 import java.security.ProtectionDomain JavaDoc;
26 import java.lang.instrument.IllegalClassFormatException JavaDoc;
27 /**
28  * A persistence provider supplies an instance of this
29  * interface to the {@link PersistenceUnitInfo#addTransformer
30  * PersistenceUnitInfo.addTransformer}
31  * method. The supplied transformer instance will get
32  * called to transform entity class files when they are
33  * loaded or redefined. The transformation occurs before
34  * the class is defined by the JVM.
35  *
36  * @since Java Persistence 1.0
37  */

38 public interface ClassTransformer {
39     /**
40     * Invoked when a class is being loaded or redefined.
41     * The implementation of this method may transform the
42     * supplied class file and return a new replacement class
43     * file.
44     *
45     * @param loader The defining loader of the class to be
46     * transformed, may be null if the bootstrap loader
47     * @param className The name of the class in the internal form
48     * of fully qualified class and interface names
49     * @param classBeingRedefined If this is a redefine, the
50     * class being redefined, otherwise null
51     * @param protectionDomain The protection domain of the
52     * class being defined or redefined
53     * @param classfileBuffer The input byte buffer in class
54     * file format - must not be modified
55     * @return A well-formed class file buffer (the result of
56     * the transform), or null if no transform is performed
57     * @throws IllegalClassFormatException If the input does
58     * not represent a well-formed class file
59     */

60     byte[] transform(ClassLoader JavaDoc loader, String JavaDoc className,
61         Class JavaDoc<?> classBeingRedefined, ProtectionDomain JavaDoc protectionDomain, byte[] classfileBuffer)
62         throws IllegalClassFormatException JavaDoc;
63 }
64
Popular Tags