Package javassist.bytecode

Examples of javassist.bytecode.AnnotationsAttribute.addAnnotation()


                                                classFile.getConstPool(), pool.get(member.getReturnType().getName()), value);
                                        ja.addMemberValue(member.getName(), memberValue);
                                    }
                                }
                            }
                            attribute.addAnnotation(ja);
                        }
                    }
                    String fieldName = method.getName() + "Argument" + i;
                    CtField ctField = CtField.make("public " + type.getCanonicalName() + " " + fieldName + ";", pool.getCtClass(parameterClassName));
                    ctField.getFieldInfo().addAttribute(attribute);
View Full Code Here


    if ( makeTransient ) {
      theField.setModifiers( theField.getModifiers() | Modifier.TRANSIENT );
    }
    theField.setModifiers( Modifier.setPrivate( theField.getModifiers() ) );
    AnnotationsAttribute annotationsAttribute = getVisibleAnnotations( theField.getFieldInfo() );
    annotationsAttribute.addAnnotation( new Annotation( Transient.class.getName(), constPool ) );
    return theField;
  }

  private void addGetter(CtClass targetClass, CtField theField, String getterName) {
    try {
View Full Code Here

                            // if help for this command is found - add GoGo descriptor for this shell command
                            if (help.containsKey(shellCommandName)) {
                                AnnotationsAttribute annotationsAttribute = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
                                Annotation annotation = new Annotation(Descriptor.class.getName(), constPool);
                                annotation.addMemberValue("value", new StringMemberValue(help.get(shellCommandName), constPool)); //todo: add help
                                annotationsAttribute.addAnnotation(annotation);
                                ctMethod.getMethodInfo().addAttribute(annotationsAttribute);
                            }

                            // add method to class
                            ctClass.addMethod(ctMethod);
View Full Code Here

   {
      FieldInfo fieldInfo = field.getFieldInfo();
      AnnotationsAttribute attribute = (AnnotationsAttribute) fieldInfo.getAttribute(AnnotationsAttribute.visibleTag);
      if (attribute == null)
         attribute = new AnnotationsAttribute(fieldInfo.getConstPool(), AnnotationsAttribute.visibleTag);
      attribute.addAnnotation(annotation);
      fieldInfo.addAttribute(attribute);
   }

   public static void addClassAnnotation(CtClass clazz, javassist.bytecode.annotation.Annotation annotation)
   {
View Full Code Here

   {
      ClassFile classFile = clazz.getClassFile();
      AnnotationsAttribute attribute = (AnnotationsAttribute) classFile.getAttribute(AnnotationsAttribute.visibleTag);
      if (attribute == null)
         attribute = new AnnotationsAttribute(classFile.getConstPool(), AnnotationsAttribute.visibleTag);
      attribute.addAnnotation(annotation);
      classFile.addAttribute(attribute);
   }

   public static Annotation createAnnotation(Class<? extends java.lang.annotation.Annotation> annotation, ConstPool constPool)
   {
View Full Code Here

   {
      FieldInfo fieldInfo = field.getFieldInfo();
      AnnotationsAttribute attribute = (AnnotationsAttribute) fieldInfo.getAttribute(AnnotationsAttribute.visibleTag);
      if (attribute == null)
         attribute = new AnnotationsAttribute(fieldInfo.getConstPool(), AnnotationsAttribute.visibleTag);
      attribute.addAnnotation(annotation);
      fieldInfo.addAttribute(attribute);
   }

   public static void addClassAnnotation(CtClass clazz, javassist.bytecode.annotation.Annotation annotation)
   {
View Full Code Here

   {
      ClassFile classFile = clazz.getClassFile();
      AnnotationsAttribute attribute = (AnnotationsAttribute) classFile.getAttribute(AnnotationsAttribute.visibleTag);
      if (attribute == null)
         attribute = new AnnotationsAttribute(classFile.getConstPool(), AnnotationsAttribute.visibleTag);
      attribute.addAnnotation(annotation);
      classFile.addAttribute(attribute);
   }

   public static Annotation createAnnotation(Class<? extends java.lang.annotation.Annotation> annotation, ConstPool constPool)
   {
View Full Code Here

                                    MemberValue memberValue = createMemberValue(
                                            classFile.getConstPool(), pool.getCtClass(member.getReturnType().getCanonicalName()), value);
                                    ja.addMemberValue(member.getName(), memberValue);
                                }
                            }
                            attribute.addAnnotation(ja);
                        }
                    }
                    String fieldName = method.getName() + "Argument" + i;
                    CtField ctField = CtField.make("public " + type.getCanonicalName() + " " + fieldName + ";", pool.getCtClass(parameterClassName));
                    ctField.getFieldInfo().addAttribute(attribute);
View Full Code Here

   
    AnnotationsAttribute attrClass = new AnnotationsAttribute(constpool, AnnotationsAttribute.visibleTag);
   
    // 1.2.1.1] Entity
    Annotation annotEntity = new Annotation("javax.persistence.Entity", constpool);
    attrClass.addAnnotation(annotEntity);
   
    // 1.2.1.2] Table info
    Annotation annotTable = new Annotation("javax.persistence.Table", constpool);
    annotTable.addMemberValue("name", new StringMemberValue("TEST_CLASS", ccFile.getConstPool()));
    annotTable.addMemberValue("schema", new StringMemberValue("KunderaTest@mongoPU", ccFile.getConstPool()));   
View Full Code Here

   
    // 1.2.1.2] Table info
    Annotation annotTable = new Annotation("javax.persistence.Table", constpool);
    annotTable.addMemberValue("name", new StringMemberValue("TEST_CLASS", ccFile.getConstPool()));
    annotTable.addMemberValue("schema", new StringMemberValue("KunderaTest@mongoPU", ccFile.getConstPool()));   
    attrClass.addAnnotation(annotTable);
   
    // 1.2.1.3] Attach the annotation to the class
   
    ccFile.addAttribute(attrClass);
   
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.