• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JavassistBuildException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javassist.build.JavassistBuildException的典型用法代码示例。如果您正苦于以下问题:Java JavassistBuildException类的具体用法?Java JavassistBuildException怎么用?Java JavassistBuildException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JavassistBuildException类属于javassist.build包,在下文中一共展示了JavassistBuildException类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
  }
}
 
开发者ID:stephanenicolas,项目名称:injectresource,代码行数:24,代码来源:InjectResourceProcessor.java


示例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);
  }
}
 
开发者ID:stephanenicolas,项目名称:injectextra,代码行数:22,代码来源:InjectExtraProcessor.java


示例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);
  }
}
 
开发者ID:stephanenicolas,项目名称:injectextra,代码行数:19,代码来源:InjectExtraProcessor.java


示例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);
  }
}
 
开发者ID:emmby,项目名称:easy-a,代码行数:10,代码来源:LxgLifeCycleProcessor.java


示例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);
}
 
开发者ID:emmby,项目名称:easy-a,代码行数:15,代码来源:LxgLifeCycleProcessor.java


示例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);
    }
}
 
开发者ID:inloop,项目名称:Knight,代码行数:13,代码来源:KnightWeaver.java


示例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);
    }
}
 
开发者ID:inloop,项目名称:Knight,代码行数:33,代码来源:KnightWeaver.java


示例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();
}
 
开发者ID:inloop,项目名称:Knight,代码行数:15,代码来源:AWeaver.java


示例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);
  }
}
 
开发者ID:stephanenicolas,项目名称:injectresource,代码行数:28,代码来源:InjectResourceProcessor.java


示例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);
   }
 }
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:12,代码来源:ExampleProcessor.java


示例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);
  }
}
 
开发者ID:stephanenicolas,项目名称:loglifecycle,代码行数:11,代码来源:LogLifeCycleProcessor.java


示例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);
  }
}
 
开发者ID:stephanenicolas,项目名称:injectview,代码行数:31,代码来源:InjectViewProcessor.java


示例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();
}
 
开发者ID:stephanenicolas,项目名称:injectview,代码行数:14,代码来源:InjectViewProcessor.java


示例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();
}
 
开发者ID:stephanenicolas,项目名称:injectview,代码行数:13,代码来源:InjectViewProcessor.java


示例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)
      + "}";
}
 
开发者ID:stephanenicolas,项目名称:injectview,代码行数:10,代码来源:InjectViewProcessor.java


示例16: createInjectedBody

import javassist.build.JavassistBuildException; //导入依赖的package包/类
private String createInjectedBody(CtClass clazz, List<ViewBinding> views,
    List<FragmentBinding> fragments, ContentViewBinding contentViewBinding)
    throws ClassNotFoundException, NotFoundException, JavassistBuildException {

  boolean isActivity = isActivity(clazz);
  boolean isFragment = isFragment(clazz);
  boolean isSupportFragment = isSupportFragment(clazz);
  boolean isView = isView(clazz);

  StringBuilder builder = new StringBuilder();

  if (contentViewBinding != null) {
    injectContentView(contentViewBinding, builder);
  }

  if (!views.isEmpty()) {
    injectViewStatements(clazz, views, builder);
  }

  if (!fragments.isEmpty()) {
    if (isView) {
      throw new JavassistBuildException(
          "Impossible to use InjectFragments in views. View: " + clazz.getName());
    } else if (isActivity || isFragment || isSupportFragment) {
      injectFragmentStatements(fragments, builder);
    }
  }

  return builder.toString();
}
 
开发者ID:stephanenicolas,项目名称:injectview,代码行数:31,代码来源:InjectViewProcessor.java


示例17: needTransformation

import javassist.build.JavassistBuildException; //导入依赖的package包/类
public abstract boolean needTransformation(CtClass candidateClass) throws JavassistBuildException; 
开发者ID:inloop,项目名称:Knight,代码行数:2,代码来源:AWeaver.java



注:本文中的javassist.build.JavassistBuildException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VisImageButton类代码示例发布时间:2022-05-22
下一篇:
Java StringMetrics类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap