Package javassist.bytecode.annotation

Examples of javassist.bytecode.annotation.StringMemberValue


              // adds @play.data.binding.As(lang={"*"}, value={"yyyy-MM-dd HH:mm:ss"})
              Map<String, MemberValue> map = new HashMap<String, MemberValue>();
              ConstPool cp = attr.getConstPool();
              // creates lang array
              MemberValue[] langArray = new MemberValue[1];
              langArray[0] = new StringMemberValue("*", cp);
              ArrayMemberValue langMember = new ArrayMemberValue(cp);
              langMember.setValue(langArray);             
                map.put("lang", langMember);
              // creates value array
              MemberValue[] valArray = new MemberValue[1];
              valArray[0] = new StringMemberValue("yyyy-MM-dd HH:mm:ss", cp);
              ArrayMemberValue valMember = new ArrayMemberValue(cp);
              valMember.setValue(valArray);             
                map.put("value", valMember);

                createAnnotation(
View Full Code Here


    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);
View Full Code Here

            }
         }

         if (annotation != null)
         {
            StringMemberValue mv = (StringMemberValue) annotation.getMemberValue("name");
            if (mv != null)
               ejbName = mv.getValue();
            else
               ejbName = ejbClass.getSimpleName();
         }
      }
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
View Full Code Here

         this.constPool = constPool;
      }

      public void addParameter(String name, String value)
      {
         annotation.addMemberValue(name, new StringMemberValue(value, constPool));
      }
View Full Code Here

      public void addParameter(String name, String[] values)
      {
         ArrayMemberValue member = new ArrayMemberValue(constPool);
         StringMemberValue[] members = new StringMemberValue[values.length];
         for (int i = 0; i < values.length; i++)
            members[i] = new StringMemberValue(values[i], constPool);
         member.setValue(members);
         annotation.addMemberValue(name, member);
      }
View Full Code Here

         this.constPool = constPool;
      }

      public void addParameter(String name, String value)
      {
         annotation.addMemberValue(name, new StringMemberValue(value, constPool));
      }
View Full Code Here

      public void addParameter(String name, String[] values)
      {
         ArrayMemberValue member = new ArrayMemberValue(constPool);
         StringMemberValue[] members = new StringMemberValue[values.length];
         for (int i = 0; i < values.length; i++)
            members[i] = new StringMemberValue(values[i], constPool);
         member.setValue(members);
         annotation.addMemberValue(name, member);
      }
View Full Code Here

    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()));   
    attrClass.addAnnotation(annotTable);
   
    // 1.2.1.3] Attach the annotation to the class
   
    ccFile.addAttribute(attrClass);
   
    // 1.2.2] Create an annotation for the field    
   
    // 1.2.2.1] Annotation Id
    AnnotationsAttribute attrIdField = new AnnotationsAttribute(constpool, AnnotationsAttribute.visibleTag);
   
    Annotation annotId = new Annotation("javax.persistence.Id", constpool);
    attrIdField.addAnnotation(annotId);
    idField.getFieldInfo().addAttribute(attrIdField);
   
    // 1.2.2.2] Annotation Column (name="testField")
    AnnotationsAttribute attrTestField = new AnnotationsAttribute(constpool, AnnotationsAttribute.visibleTag);
   
    Annotation annotCol = new Annotation("javax.persistence.Column", constpool);
    annotCol.addMemberValue("name", new StringMemberValue("TEST_FIELD", ccFile.getConstPool()));
    attrTestField.addAnnotation(annotCol);
    testField.getFieldInfo().addAttribute(attrTestField);
   
    if (null != testField2) {
      AnnotationsAttribute attrTestField2 = new AnnotationsAttribute(constpool, AnnotationsAttribute.visibleTag);
     
      Annotation annotCol2 = new Annotation("javax.persistence.Column", constpool);
      annotCol.addMemberValue("name", new StringMemberValue("TEST_FIELD2", ccFile.getConstPool()));
      attrTestField2.addAnnotation(annotCol2);
      testField2.getFieldInfo().addAttribute(attrTestField2);
    }
   
    // 1.3] Add methods
View Full Code Here

                strategy.setValue(InheritanceType.SINGLE_TABLE.name());
                inheritance.addMemberValue("strategy", strategy);
                annotationsAttribute.addAnnotation(inheritance);
                if (myInfo.getDiscriminatorName() != null) {
                    Annotation discriminator = new Annotation(DiscriminatorColumn.class.getName(), constantPool);
                    StringMemberValue name = new StringMemberValue(constantPool);
                    name.setValue(myInfo.getDiscriminatorName());
                    discriminator.addMemberValue("name", name);
                    EnumMemberValue discriminatorType = (EnumMemberValue) Annotation.createMemberValue(constantPool, pool.makeClass("DiscriminatorType"));
                    discriminatorType.setType(DiscriminatorType.class.getName());
                    discriminatorType.setValue(myInfo.getDiscriminatorType().name());
                    discriminator.addMemberValue("discriminatorType", discriminatorType);
View Full Code Here

TOP

Related Classes of javassist.bytecode.annotation.StringMemberValue

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.