public class CtClassBuilder extends Object implements org.apache.commons.lang3.builder.Builder<javassist.CtClass>
| 限定符和类型 | 字段和说明 |
|---|---|
protected javassist.bytecode.ClassFile |
classFile |
protected javassist.CtClass |
declaring |
protected javassist.ClassPool |
pool |
| 构造器和说明 |
|---|
CtClassBuilder(javassist.ClassPool pool,
String classname,
Class<?> superclass) |
CtClassBuilder(String classname) |
CtClassBuilder(String classname,
Class<?> superclass) |
| 限定符和类型 | 方法和说明 |
|---|---|
<T> CtClassBuilder |
autowired(Class<T> type,
String name,
boolean required)
添加字段注解 @Autowired 实现对象注入
|
<T> CtClassBuilder |
autowired(Class<T> type,
String name,
boolean required,
String qualifier)
添加字段注解 @Autowired @Qualifier 实现对象注入
|
CtClassBuilder |
autowiredHandler(boolean required,
String qualifier)
添加字段注解 @Autowired 实现对象注入
|
CtClassBuilder |
bind(MvcBound bound)
通过给动态类增加
@WebBound注解实现,数据的绑定 |
CtClassBuilder |
bind(String uid,
String json)
通过给动态类增加
@WebBound注解实现,数据的绑定 |
javassist.CtClass |
build() |
CtClassBuilder |
makeField(String src)
Compiles the given source code and creates a field.
|
CtClassBuilder |
makeMethod(String src)
Compiles the given source code and creates a method.
|
<T> CtClassBuilder |
newField(Class<T> fieldClass,
String fieldName,
String fieldValue) |
CtClassBuilder |
removeField(String fieldName) |
Class<?> |
toClass()
javassist在加载类时会用Hashtable将类信息缓存到内存中,这样随着类的加载,内存会越来越大,甚至导致内存溢出。
|
Object |
toInstance(InvocationHandler handler) |
protected javassist.ClassPool pool
protected javassist.CtClass declaring
protected javassist.bytecode.ClassFile classFile
public CtClassBuilder(String classname) throws javassist.CannotCompileException, javassist.NotFoundException
javassist.CannotCompileExceptionjavassist.NotFoundExceptionpublic CtClassBuilder(String classname, Class<?> superclass) throws javassist.CannotCompileException, javassist.NotFoundException
javassist.CannotCompileExceptionjavassist.NotFoundExceptionpublic <T> CtClassBuilder autowired(Class<T> type, String name, boolean required) throws javassist.CannotCompileException, javassist.NotFoundException
T - : 参数泛型type - : The type attribute value of @Autowiredname - : The name attribute value of @Autowiredrequired - : Declares whether the annotated dependency is required.CtClassBuilder instancejavassist.CannotCompileException - if can't compilejavassist.NotFoundException - if not foundpublic CtClassBuilder autowiredHandler(boolean required, String qualifier) throws javassist.CannotCompileException, javassist.NotFoundException
required - : Declares whether the annotated dependency is required.qualifier - : The qualifier attribute value of @AutowiredCtClassBuilder instancejavassist.CannotCompileException - if can't compilejavassist.NotFoundException - if not foundpublic <T> CtClassBuilder autowired(Class<T> type, String name, boolean required, String qualifier) throws javassist.CannotCompileException, javassist.NotFoundException
T - : 参数泛型type - : The type attribute value of @Autowiredname - : The name attribute value of @Autowiredrequired - : Declares whether the annotated dependency is required.qualifier - : The qualifier attribute value of @AutowiredCtClassBuilder instancejavassist.CannotCompileException - if can't compilejavassist.NotFoundException - if not foundpublic CtClassBuilder bind(String uid, String json)
@WebBound注解实现,数据的绑定uid - : The value of uidjson - : The value of jsonCtClassBuilder instancepublic CtClassBuilder bind(MvcBound bound)
@WebBound注解实现,数据的绑定bound - : The MvcBound instanceCtClassBuilder instancepublic CtClassBuilder makeField(String src) throws javassist.CannotCompileException
"public String name;" "public int k = 3;"
Note that the source code ends with ';'
(semicolon).
src - the source text.CtClassBuilder instancejavassist.CannotCompileException - if can't compilepublic <T> CtClassBuilder newField(Class<T> fieldClass, String fieldName, String fieldValue) throws javassist.CannotCompileException, javassist.NotFoundException
javassist.CannotCompileExceptionjavassist.NotFoundExceptionpublic CtClassBuilder removeField(String fieldName) throws javassist.NotFoundException
javassist.NotFoundExceptionpublic CtClassBuilder makeMethod(String src) throws javassist.CannotCompileException
"public Object id(Object obj) { return obj; }"src - the source text.CtClassBuilder instancejavassist.CannotCompileException - if can't compilepublic javassist.CtClass build()
build 在接口中 org.apache.commons.lang3.builder.Builder<javassist.CtClass>public Class<?> toClass() throws javassist.CannotCompileException
javassist.CannotCompileException - if can't compilepublic Object toInstance(InvocationHandler handler) throws javassist.CannotCompileException, javassist.NotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException
javassist.CannotCompileExceptionjavassist.NotFoundExceptionInstantiationExceptionIllegalAccessExceptionIllegalArgumentExceptionInvocationTargetExceptionNoSuchMethodExceptionSecurityExceptionCopyright © 2019. All rights reserved.