Package play.classloading.enhancers
Class Enhancer
- java.lang.Object
-
- play.classloading.enhancers.Enhancer
-
- Direct Known Subclasses:
ContinuationEnhancer,ControllersEnhancer,JPAEnhancer,LocalvariablesNamesEnhancer,MailerEnhancer,PropertiesEnhancer,SigEnhancer
public abstract class Enhancer extends java.lang.ObjectEnhancer support
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEnhancer.ApplicationClassesClasspathDumb classpath implementation for javassist hacking
-
Field Summary
Fields Modifier and Type Field Description protected javassist.ClassPoolclassPool
-
Constructor Summary
Constructors Constructor Description Enhancer()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static voidcreateAnnotation(javassist.bytecode.AnnotationsAttribute attribute, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)Create a new annotation to be dynamically inserted in the byte code.protected static voidcreateAnnotation(javassist.bytecode.AnnotationsAttribute attribute, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.util.Map<java.lang.String,javassist.bytecode.annotation.MemberValue> members)Create a new annotation to be dynamically inserted in the byte code.abstract voidenhanceThisClass(ApplicationClasses.ApplicationClass applicationClass)The magic happen here...protected static javassist.bytecode.AnnotationsAttributegetAnnotations(javassist.CtClass ctClass)Retrieve all class annotations.protected static javassist.bytecode.AnnotationsAttributegetAnnotations(javassist.CtField ctField)Retrieve all field annotations.protected static javassist.bytecode.AnnotationsAttributegetAnnotations(javassist.CtMethod ctMethod)Retrieve all method annotations.protected booleanhasAnnotation(javassist.CtClass ctClass, java.lang.String annotation)Test if a class has the provided annotationprotected booleanhasAnnotation(javassist.CtField ctField, java.lang.String annotation)Test if a field has the provided annotationprotected booleanhasAnnotation(javassist.CtMethod ctMethod, java.lang.String annotation)Test if a method has the provided annotationjavassist.CtClassmakeClass(ApplicationClasses.ApplicationClass applicationClass)Construct a javassist CtClass from an application class.static javassist.ClassPoolnewClassPool()
-
-
-
Method Detail
-
newClassPool
public static javassist.ClassPool newClassPool()
-
makeClass
public javassist.CtClass makeClass(ApplicationClasses.ApplicationClass applicationClass) throws java.io.IOException
Construct a javassist CtClass from an application class.- Parameters:
applicationClass- The application class to construct- Returns:
- The javassist CtClass construct from the application class
- Throws:
java.io.IOException- if problem occurred during construction
-
enhanceThisClass
public abstract void enhanceThisClass(ApplicationClasses.ApplicationClass applicationClass) throws java.lang.Exception
The magic happen here...- Parameters:
applicationClass- The application class to construct- Throws:
java.lang.Exception- if problem occurred during construction
-
hasAnnotation
protected boolean hasAnnotation(javassist.CtClass ctClass, java.lang.String annotation) throws java.lang.ClassNotFoundExceptionTest if a class has the provided annotation- Parameters:
ctClass- the javassist class representationannotation- fully qualified name of the annotation class eg."javax.persistence.Entity"- Returns:
- true if class has the annotation
- Throws:
java.lang.ClassNotFoundException- if class not found
-
hasAnnotation
protected boolean hasAnnotation(javassist.CtField ctField, java.lang.String annotation) throws java.lang.ClassNotFoundExceptionTest if a field has the provided annotation- Parameters:
ctField- the javassist field representationannotation- fully qualified name of the annotation class eg."javax.persistence.Entity"- Returns:
- true if field has the annotation
- Throws:
java.lang.ClassNotFoundException- if class not found
-
hasAnnotation
protected boolean hasAnnotation(javassist.CtMethod ctMethod, java.lang.String annotation) throws java.lang.ClassNotFoundExceptionTest if a method has the provided annotation- Parameters:
ctMethod- the javassist method representationannotation- fully qualified name of the annotation class eg."javax.persistence.Entity"- Returns:
- true if field has the annotation
- Throws:
java.lang.ClassNotFoundException- if class not found
-
createAnnotation
protected static void createAnnotation(javassist.bytecode.AnnotationsAttribute attribute, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.util.Map<java.lang.String,javassist.bytecode.annotation.MemberValue> members)Create a new annotation to be dynamically inserted in the byte code.- Parameters:
attribute- annotation attributeannotationType- Annotationmembers- Member of the annotation
-
createAnnotation
protected static void createAnnotation(javassist.bytecode.AnnotationsAttribute attribute, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)Create a new annotation to be dynamically inserted in the byte code.- Parameters:
attribute- annotation attributeannotationType- Annotation
-
getAnnotations
protected static javassist.bytecode.AnnotationsAttribute getAnnotations(javassist.CtClass ctClass)
Retrieve all class annotations.- Parameters:
ctClass- The given class- Returns:
- All class annotations
-
getAnnotations
protected static javassist.bytecode.AnnotationsAttribute getAnnotations(javassist.CtField ctField)
Retrieve all field annotations.- Parameters:
ctField- The given field- Returns:
- All field annotations.
-
getAnnotations
protected static javassist.bytecode.AnnotationsAttribute getAnnotations(javassist.CtMethod ctMethod)
Retrieve all method annotations.- Parameters:
ctMethod- The given methods- Returns:
- all method annotations.
-
-