Package javassist.bytecode.annotation

Examples of javassist.bytecode.annotation.Annotation


     */
    private void retrieveCustomAttributes(final AttributeInfo attributeInfo, final List listToPutAttributesIn) {
        if (attributeInfo.getName().equals(RUNTIME_INVISIBLE_ANNOTATIONS)) {
            AnnotationsAttribute annotationAttribute = (AnnotationsAttribute)attributeInfo;
            for (int i = 0; i < annotationAttribute.getAnnotations().length; i++) {
                Annotation annotation = annotationAttribute.getAnnotations()[i];
                // TODO: stuff is hard coded here - dump it with AW 2.0
                // TODO: when Javassist support primitive type array, then do not use BASE64
                if (annotation.getTypeName().equals(CUSTOM_ATTRIBUTE_CLASSNAME)) {
                    String value = ((StringMemberValue)annotation.getMemberValue(VALUE)).getValue();
                    byte[] bytes = Base64.decode(value);
                    listToPutAttributesIn.add(CustomAttributeHelper.extractCustomAnnotation(bytes));
                }
            }
        }
View Full Code Here


         public void visit(CtClass ctClass) {

            try {
               if (ctClass.hasAnnotation(PatchClass.class)) {

                  Annotation annotation = JavassistUtils.getAnnotation(ctClass, PatchClass.class);

                  String classToPatchName = PatchClass.class.getName();

                  ClassMemberValue value = (ClassMemberValue) annotation.getMemberValue("value");

                  if (value != null) {
                     classToPatchName = value.getValue();
                  }

                  if (classToPatchName.equals(PatchClass.class.getName())) {
                     StringMemberValue target = (StringMemberValue) annotation.getMemberValue("target");
                     classToPatchName = (target != null) ? target.getValue() : "";
                  }

                  if (!"".equals(classToPatchName)) {
                     addPatchClass(classToPatchName, ctClass);
View Full Code Here

   public static String getAspectDomain(AnnotationsAttribute visible, String defaultContainerName)
   {
      if (visible != null )
      {
         Annotation dinfo = visible.getAnnotation(org.jboss.ejb3.annotation.AspectDomain.class
                                      .getName());
         if (dinfo != null)
         {
            StringMemberValue dmv = (StringMemberValue) dinfo
                    .getMemberValue("value");
            if (dmv != null)
            {
               return dmv.getValue();
            }
View Full Code Here

        String arquillianClassName = Arquillian.class.getName();

        constPool.addUtf8Info(runWithClassName);
        constPool.addUtf8Info(arquillianClassName);

        Annotation annotation = new Annotation(runWithClassName, constPool);
        annotation.addMemberValue("value", new ClassMemberValue(arquillianClassName, constPool));
        attr.addAnnotation(annotation);

        ccFile.addAttribute(attr);
    }
View Full Code Here

        before.setBody("{" + setUpSrc() + "}");
        before.setExceptionTypes(new CtClass[]{exceptionClass});
        AnnotationsAttribute attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
        String beforeClassName = Before.class.getName();
        constPool.addUtf8Info(beforeClassName);
        Annotation annotation = new Annotation(beforeClassName, constPool);
        attr.addAnnotation(annotation);
        before.getMethodInfo().addAttribute(attr);
        clazz.addMethod(before);

        CtMethod after = new CtMethod(voidClass, "after" + random.nextInt(), new CtClass[]{}, clazz);
        after.setModifiers(Modifier.PUBLIC);
        after.setBody("{" + tearDownSrc() + "}");
        after.setExceptionTypes(new CtClass[]{exceptionClass});
        attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
        String afterClassName = After.class.getName();
        constPool.addUtf8Info(afterClassName);
        annotation = new Annotation(afterClassName, constPool);
        attr.addAnnotation(annotation);
        after.getMethodInfo().addAttribute(attr);
        clazz.addMethod(after);
    }
View Full Code Here

            attr = AnnotationsAttribute.class.cast(info);
        }

        constPool.addUtf8Info(annotationClassName);

        Annotation annotation = new Annotation(annotationClassName, constPool);
        attr.addAnnotation(annotation);

        method.getMethodInfo().addAttribute(attr);
    }
View Full Code Here

            return true;
        }

        AnnotationsAttribute aa = (AnnotationsAttribute) mi.getAttribute(AnnotationsAttribute.visibleTag);
        if (aa != null) {
            Annotation annotation = aa.getAnnotation(Deprecated.class.getName());
            if (annotation != null) {
                return true;
            }
        }
View Full Code Here

    protected void checkAnnotations(String clazz, String member, AnnotationsAttribute aa, int line) {
        if (aa != null) {
            for (Map.Entry<String, Boolean> entry : annotations.entrySet()) {
                String annotation = entry.getKey();
                Annotation ann = aa.getAnnotation(annotation);
                if (ann != null) {
                    checkAnnotation(clazz, member, line, entry.getValue(), annotation, ann);
                }
            }
        }
View Full Code Here

       
        for (CtField cf: ctClass.getDeclaredFields()) {
            if (hasAnnotation(cf, siena.Max.class.getName())) {
              // retrieves @siena.Max value
              AnnotationsAttribute attr = getAnnotations(cf);
              Annotation orig = attr.getAnnotation(Max.class.getName());
              int val = ((IntegerMemberValue)orig.getMemberValue("value")).getValue();

              // adds @play.data.validation.MaxSize value
              Map<String, MemberValue> map = new HashMap<String, MemberValue>();
              map.put("value", new IntegerMemberValue(attr.getConstPool(), val));
View Full Code Here

  
   public void visitAnnotationMemberValue(AnnotationMemberValue node)
   {
      try
      {
         Annotation ann = node.getValue();
         value = AnnotationProxy.createProxy(ann);
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
View Full Code Here

TOP

Related Classes of javassist.bytecode.annotation.Annotation

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.