本文整理汇总了Java中javassist.build.JavassistBuildException类的典型用法代码示例。如果您正苦于以下问题:Java JavassistBuildException类的具体用法?Java JavassistBuildException怎么用?Java JavassistBuildException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JavassistBuildException类属于javassist.build包,在下文中一共展示了JavassistBuildException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyTransformations
import javassist.build.JavassistBuildException; //导入依赖的package包/类
@Override
public void applyTransformations(final CtClass classToTransform) throws JavassistBuildException {
// Actually you must test if it exists, but it's just an example...
log.debug("Analyzing " + classToTransform.getSimpleName());
try {
final List<CtField> fields =
getAllInjectedFieldsForAnnotation(classToTransform, InjectResource.class);
String getResourceString = getResourceString();
String injectViewStatements = injectResourceStatements(fields, classToTransform);
StringBuffer buffer = new StringBuffer();
buffer.append(getResourceString).append(injectViewStatements);
String preliminaryBody = buffer.toString();
log.debug("Preliminary body (before insertion) :" + preliminaryBody);
injectStuff(classToTransform, preliminaryBody);
} catch (Exception e) {
String message = format("Error while processing class %s", classToTransform.getName());
log.debug(message, e);
throw new JavassistBuildException(message, e);
}
}
示例2: shouldTransform
import javassist.build.JavassistBuildException; //导入依赖的package包/类
@Override
public boolean shouldTransform(CtClass candidateClass) throws JavassistBuildException {
try {
final List<CtField> fields =
getAllInjectedFieldsForAnnotation(candidateClass, InjectExtra.class);
if (fields.isEmpty()) {
return false;
}
boolean isValid = isValidClass(candidateClass);
log.debug(
format("Class %s will get transformed: %b", candidateClass.getSimpleName(), isValid));
return isValid;
} catch (Exception e) {
String message = format("Error while filtering class %s", candidateClass.getName());
log.debug(message, e);
throw new JavassistBuildException(message, e);
}
}
示例3: applyTransformations
import javassist.build.JavassistBuildException; //导入依赖的package包/类
@Override
public void applyTransformations(final CtClass classToTransform) throws JavassistBuildException {
// Actually you must test if it exists, but it's just an example...
log.debug("Analyzing " + classToTransform.getSimpleName());
try {
final List<CtField> fields =
getAllInjectedFieldsForAnnotation(classToTransform, InjectExtra.class);
String injectExtraStatements = createInjectExtraStatements(fields, classToTransform);
log.debug("Preliminary body (before insertion) :" + injectExtraStatements);
injectStuff(classToTransform, injectExtraStatements);
} catch (Exception e) {
String message = format("Error while processing class %s", classToTransform.getName());
log.debug(message, e);
throw new JavassistBuildException(message, e);
}
}
示例4: shouldTransform
import javassist.build.JavassistBuildException; //导入依赖的package包/类
@Override
public boolean shouldTransform(CtClass candidateClass) throws JavassistBuildException {
try {
return isSupported(candidateClass);
} catch (Exception e) {
logMoreIfDebug("Should transform filter failed for class " + candidateClass.getName(), e);
throw new JavassistBuildException(e);
}
}
示例5: applyTransformations
import javassist.build.JavassistBuildException; //导入依赖的package包/类
@Override
public void applyTransformations(CtClass classToTransform) throws JavassistBuildException {
String classToTransformName = classToTransform.getName();
try {
log.info("Transforming " + classToTransformName);
ClassPool pool = classToTransform.getClassPool();
Set<CtMethod> methodSet = getAllLifeCycleMethods(pool, classToTransform.getName());
debugLifeCycleMethods(classToTransform, methodSet.toArray(new CtMethod[methodSet.size()]));
} catch (Exception e) {
logMoreIfDebug("Transformation failed for class " + classToTransformName, e);
throw new JavassistBuildException(e);
}
log.info("Transformation successful for " + classToTransformName);
}
示例6: needTransformation
import javassist.build.JavassistBuildException; //导入依赖的package包/类
@Override
public boolean needTransformation(CtClass candidateClass) throws JavassistBuildException {
try {
//log("needTransformation ? %s", candidateClass.getName());
return candidateClass.hasAnnotation(KnightApp.class)
|| hasInjectField(candidateClass);
} catch (Exception e) {
log("needTransformation - failed");
e.printStackTrace();
throw new JavassistBuildException(e);
}
}
示例7: applyTransformations
import javassist.build.JavassistBuildException; //导入依赖的package包/类
@Override
public void applyTransformations(CtClass classToTransform) throws JavassistBuildException {
log("applyTransformations - %s", classToTransform.getName());
try {
// APP
if (classToTransform.hasAnnotation(KnightApp.class)) {
weaveKnightApp(classToTransform);
}
// SERVICE
else if (isSubclassOf(classToTransform, Class.SERVICE)) {
weaveService(classToTransform);
}
// FRAGMENT
else if (isSubclassOf(classToTransform, Class.FRAGMENT)
|| isSubclassOf(classToTransform, Class.SUPPORT_FRAGMENT)) {
weaveFragment(classToTransform);
}
// VIEW
else if (isSubclassOf(classToTransform, Class.VIEW)) {
weaveView(classToTransform);
}
// nothing done
else {
log("applyTransformations - NOTHING done");
}
log("applyTransformations - done");
} catch (Exception e) {
log("applyTransformations - failed");
e.printStackTrace();
throw new JavassistBuildException(e);
}
}
示例8: checkStackedClasses
import javassist.build.JavassistBuildException; //导入依赖的package包/类
private void checkStackedClasses() throws JavassistBuildException {
// transform previously stacked classes
for (CtClass ctClass : mStack) {
if (ctClass.isFrozen()) ctClass.defrost();
applyTransformations(ctClass);
try {
ctClass.writeFile(mDestinationDir);
} catch (Exception e) {
e.printStackTrace();
throw new JavassistBuildException(e);
}
}
mStack.clear();
}
示例9: shouldTransform
import javassist.build.JavassistBuildException; //导入依赖的package包/类
@Override
public boolean shouldTransform(CtClass candidateClass) throws JavassistBuildException {
try {
final List<CtField> fields =
getAllInjectedFieldsForAnnotation(candidateClass, InjectResource.class);
if (fields.isEmpty()) {
return false;
}
boolean isAcceptedClass = supportedCtClassFiter.isValid(candidateClass);
if (!isAcceptedClass) {
List<CtConstructor> ctConstructors =
extractValidConstructors(candidateClass, supportedCtClassFiter);
isAcceptedClass = !ctConstructors.isEmpty();
}
log.debug(format("Class %s will get transformed: %b", candidateClass.getSimpleName(),
isAcceptedClass));
return isAcceptedClass;
} catch (Exception e) {
String message = format("Error while filtering class %s", candidateClass.getName());
log.debug(message, e);
throw new JavassistBuildException(message, e);
}
}
示例10: applyTransformations
import javassist.build.JavassistBuildException; //导入依赖的package包/类
@Override
public void applyTransformations(CtClass classToTransform) throws JavassistBuildException {
log.info("Transforming " + classToTransform.getName());
try {
afterBurner.afterOverrideMethod(classToTransform, "doStuff", "System.out.println(\"Inside doStuff\");");
} catch (Exception e) {
throw new JavassistBuildException(e);
}
}
示例11: shouldTransform
import javassist.build.JavassistBuildException; //导入依赖的package包/类
@Override
public boolean shouldTransform(CtClass candidateClass) throws JavassistBuildException {
try {
boolean isSupported = isSupported(candidateClass);
return candidateClass.hasAnnotation(LogLifeCycle.class) && isSupported;
} catch (Exception e) {
logMoreIfDebug("Should transform filter failed for class " + candidateClass.getName(), e);
throw new JavassistBuildException(e);
}
}
示例12: applyTransformations
import javassist.build.JavassistBuildException; //导入依赖的package包/类
@Override
public void applyTransformations(final CtClass classToTransform) throws JavassistBuildException {
// Actually you must test if it exists, but it's just an example...
String classToTransformName = classToTransform.getSimpleName();
log.debug("Analyzing " + classToTransformName);
try {
final List<ViewBinding> viewBindings = binder.getViewBindings(classToTransform);
final List<FragmentBinding> fragmentBindings = binder.getFragmentBindings(classToTransform);
if (isActivity(classToTransform)) {
log.debug("Activity detected %s", classToTransformName);
injectStuffInActivity(classToTransform, viewBindings, fragmentBindings);
} else if (isFragment(classToTransform) || isSupportFragment(classToTransform)) {
log.debug("Fragment detected %s", classToTransformName);
injectStuffInFragment(classToTransform, viewBindings, fragmentBindings);
} else if (isView(classToTransform)) {
log.debug("View detected %s", classToTransformName);
injectStuffInView(classToTransform, viewBindings);
} else {
log.debug("Other class detected %s", classToTransformName);
// in other classes (like view holders)
injectStuffInClass(classToTransform, viewBindings, fragmentBindings);
}
log.debug("Class successfully transformed: " + classToTransformName);
} catch (Throwable e) {
log.error("Impossible to transform class." + classToTransform.getName(), e);
throw new JavassistBuildException(e);
}
}
示例13: injectStuffInFragment
import javassist.build.JavassistBuildException; //导入依赖的package包/类
private void injectStuffInFragment(final CtClass classToTransform, List<ViewBinding> views,
List<FragmentBinding> fragments)
throws NotFoundException, ClassNotFoundException, CannotCompileException,
AfterBurnerImpossibleException, JavassistBuildException {
afterBurner.afterOverrideMethod(classToTransform, "onViewCreated",
createInjectedBody(classToTransform, views, fragments, null));
afterBurner.afterOverrideMethod(classToTransform, "onDestroyView",
destroyViewStatements(views));
classToTransform.detach();
}
示例14: injectStuffInView
import javassist.build.JavassistBuildException; //导入依赖的package包/类
private void injectStuffInView(final CtClass classToTransform, List<ViewBinding> viewBindings)
throws NotFoundException, ClassNotFoundException, CannotCompileException,
AfterBurnerImpossibleException, JavassistBuildException {
if (viewBindings.isEmpty()) {
return;
}
afterBurner.afterOverrideMethod(classToTransform, "onFinishInflate",
createInjectedBody(classToTransform, viewBindings, new ArrayList<FragmentBinding>(), null));
classToTransform.detach();
}
示例15: createOnCreateMethod
import javassist.build.JavassistBuildException; //导入依赖的package包/类
private String createOnCreateMethod(CtClass clazz, List<ViewBinding> views,
List<FragmentBinding> fragments, ContentViewBinding contentViewBinding)
throws ClassNotFoundException, NotFoundException, JavassistBuildException {
return "public void onCreate(android.os.Bundle savedInstanceState) { \n"
+ "super.onCreate(savedInstanceState);\n"
+ createInjectedBody(clazz, views, fragments, contentViewBinding)
+ "}";
}