Package javassist.bytecode

Examples of javassist.bytecode.AnnotationsAttribute


    sb.append("return f;");
    sb.append("}");
    mnew = CtNewMethod.make(sb.toString(), mainClass);

    ConstPool cp = mnew.getMethodInfo().getConstPool();
    AnnotationsAttribute attr1 = new AnnotationsAttribute(cp,
        AnnotationsAttribute.visibleTag);
    javassist.bytecode.annotation.Annotation beanAnnotation = new javassist.bytecode.annotation.Annotation(
        "org.springframework.context.annotation.Bean", cp);
    ArrayMemberValue a = new ArrayMemberValue(cp);
    MemberValue[] m = new MemberValue[]{new StringMemberValue(beanName, cp)};
    a.setValue(m);
    beanAnnotation.addMemberValue("name", a);
    javassist.bytecode.annotation.Annotation lazyAnnotation = new javassist.bytecode.annotation.Annotation(
        "org.springframework.context.annotation.Lazy", cp);
    lazyAnnotation.addMemberValue("value", new BooleanMemberValue(true, cp));
    javassist.bytecode.annotation.Annotation scopeAnnotation = new javassist.bytecode.annotation.Annotation(
        "org.springframework.context.annotation.Scope", cp);
    EnumMemberValue enumValue = new EnumMemberValue(cp);
    enumValue.setType("org.springframework.context.annotation.ScopedProxyMode");
    enumValue.setValue("TARGET_CLASS");
    scopeAnnotation.addMemberValue("proxyMode", enumValue);
    scopeAnnotation.addMemberValue("value", new StringMemberValue("idspace", cp));
    attr1.addAnnotation(beanAnnotation);
    attr1.addAnnotation(lazyAnnotation);
    attr1.addAnnotation(scopeAnnotation);
    mnew.getMethodInfo().addAttribute(attr1);
    mnew.getMethodInfo().addAttribute(attr1);
    mnew.getMethodInfo().addAttribute(attr1);
    mainClass.addMethod(mnew);
    methodCounter += 1;
View Full Code Here


  private CtClass getZKComponentBeanMethodsClass(ClassPool cp) {
    CtClass mainClass = cp.makeClass("org.zkoss.spring.beans.zkcomponents.ZKComponentBeanMethods");
    ClassFile cFile = mainClass.getClassFile();
    ConstPool cPool = cFile.getConstPool();
    AnnotationsAttribute attr = new AnnotationsAttribute(cPool,
        AnnotationsAttribute.visibleTag);
    javassist.bytecode.annotation.Annotation configurationAnnotation = new javassist.bytecode.annotation.Annotation(
        "org.springframework.context.annotation.Configuration", cPool);
    attr.addAnnotation(configurationAnnotation);
    cFile.addAttribute(attr);
    return mainClass;
  }
View Full Code Here

            String entryName = entry.getName();

            if (entryName.endsWith(".class"))
            {
              ClassFile cf = new ClassFile(new DataInputStream(new BufferedInputStream(jar)));
              AnnotationsAttribute ai = (AnnotationsAttribute) cf
                      .getAttribute(AnnotationsAttribute.visibleTag);

              if (ai != null
                      && (ai.getAnnotation("javax.persistence.Entity") != null || ai
                              .getAnnotation("org.hibernate.annotations.GenericGenerators") != null))
              {
                add(cf.getName());
              }
            }
View Full Code Here

     * @param classFile
     */
    private void discoverAndIntimateForClassAnnotations (ClassFile classFile) {
      Set<Annotation> annotations = new HashSet<Annotation>();
     
    AnnotationsAttribute visible   = (AnnotationsAttribute) classFile.getAttribute(AnnotationsAttribute.visibleTag);
    AnnotationsAttribute invisible   = (AnnotationsAttribute) classFile.getAttribute(AnnotationsAttribute.invisibleTag);

    if (visible != null) {
      annotations.addAll(Arrays.asList(visible.getAnnotations()));
    }
    if (invisible != null) {
      annotations.addAll(Arrays.asList(invisible.getAnnotations()));
    }
   
    // now tell listeners
    for (Annotation annotation : annotations) {
      Set<ClassAnnotationDiscoveryListener> listeners = classAnnotationListeners.get(annotation.getTypeName());
View Full Code Here

    }
   
    for (FieldInfo fieldInfo : fields) {
      Set<Annotation> annotations = new HashSet<Annotation>();
     
      AnnotationsAttribute visible = (AnnotationsAttribute) fieldInfo.getAttribute(AnnotationsAttribute.visibleTag);
      AnnotationsAttribute invisible = (AnnotationsAttribute) fieldInfo.getAttribute(AnnotationsAttribute.invisibleTag);

      if (visible != null) {
        annotations.addAll(Arrays.asList(visible.getAnnotations()));
      }
      if (invisible != null) {
        annotations.addAll(Arrays.asList(invisible.getAnnotations()));
      }
     
      // now tell listeners
      for (Annotation annotation : annotations) {
        Set<FieldAnnotationDiscoveryListener> listeners = fieldAnnotationListeners.get(annotation.getTypeName());
View Full Code Here

    }
   
    for (MethodInfo methodInfo : methods) {
      Set<Annotation> annotations = new HashSet<Annotation>();
     
      AnnotationsAttribute visible   = (AnnotationsAttribute) methodInfo.getAttribute(AnnotationsAttribute.visibleTag);
      AnnotationsAttribute invisible   = (AnnotationsAttribute) methodInfo.getAttribute(AnnotationsAttribute.invisibleTag);
     
      if (visible != null) {
        annotations.addAll(Arrays.asList(visible.getAnnotations()));
      }
      if (invisible != null) {
        annotations.addAll(Arrays.asList(invisible.getAnnotations()));
      }
     
      // now tell listeners
      for (Annotation annotation : annotations) {
        Set<MethodAnnotationDiscoveryListener> listeners = methodAnnotationListeners.get(annotation.getTypeName());
View Full Code Here

        return false;
    }

    private static boolean findAnnotation(ClassFile cf, Log log, AttributeInfo classAttribute, String annotationName) {
        AnnotationsAttribute visible = new AnnotationsAttribute(classAttribute.getConstPool(),
                classAttribute.getName(),
                classAttribute.get());

        for (Annotation ann : visible.getAnnotations()) {
            if (annotationName.equals(ann.getTypeName())) {
                log.debug(cf.getName() + " IS an injection target");
                return true;
            }
        }
View Full Code Here

        cf.setAccessFlags(AccessFlag.of(mod));
    }

    public boolean hasAnnotation(Class clz) {
        ClassFile cf = getClassFile2();
        AnnotationsAttribute ainfo = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.invisibleTag)
        AnnotationsAttribute ainfo2 = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.visibleTag)
        return hasAnnotationType(clz, getClassPool(), ainfo, ainfo2);
    }
View Full Code Here

        return false;
    }

    public Object getAnnotation(Class clz) throws ClassNotFoundException {
        ClassFile cf = getClassFile2();
        AnnotationsAttribute ainfo = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.invisibleTag)
        AnnotationsAttribute ainfo2 = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.visibleTag)
        return getAnnotationType(clz, getClassPool(), ainfo, ainfo2);
    }
View Full Code Here

    private Object[] getAnnotations(boolean ignoreNotFound)
        throws ClassNotFoundException
    {
        ClassFile cf = getClassFile2();
        AnnotationsAttribute ainfo = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.invisibleTag)
        AnnotationsAttribute ainfo2 = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.visibleTag)
        return toAnnotationType(ignoreNotFound, getClassPool(), ainfo, ainfo2);
    }
View Full Code Here

TOP

Related Classes of javassist.bytecode.AnnotationsAttribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.