Examples of AnnotationsAttribute


Examples of javassist.bytecode.AnnotationsAttribute

    private void addAnnotation(Annotation annotation)
    {
       
        final ClassFile classFile = getClassFile();
       
        AnnotationsAttribute attribute = (AnnotationsAttribute) classFile.getAttribute(AnnotationsAttribute.visibleTag);
       
        if (attribute == null)
        {
            attribute = new AnnotationsAttribute(getConstPool(), AnnotationsAttribute.visibleTag);
        }
       
        final javassist.bytecode.annotation.Annotation copy = toJavassistAnnotation(annotation);
       
       
        attribute.addAnnotation(copy);
       
        classFile.addAttribute(attribute);
       
    }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

   
    private void addMethodAnnotation(final CtMethod ctMethod, final Annotation annotation) {

        MethodInfo methodInfo = ctMethod.getMethodInfo();

        AnnotationsAttribute attribute = (AnnotationsAttribute) methodInfo
            .getAttribute(AnnotationsAttribute.visibleTag);

        if (attribute == null) {
            attribute = new AnnotationsAttribute(getConstPool(), AnnotationsAttribute.visibleTag);
        }

        final javassist.bytecode.annotation.Annotation copy = toJavassistAnnotation(annotation);

        attribute.addAnnotation(copy);

        methodInfo.addAttribute(attribute);

    }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

  
   protected static boolean hasAnnotations(ClassFile classFile, Set<Class<? extends Annotation>> annotationTypes)
   {
      if (annotationTypes.size() > 0)
      {
         AnnotationsAttribute visible = (AnnotationsAttribute) classFile.getAttribute( AnnotationsAttribute.visibleTag );
         if ( visible != null )
         {
            for (Class<? extends Annotation> annotationType : annotationTypes)
            {
               if (visible.getAnnotation(annotationType.getName()) != null)
               {
                  return true;
               }
            }
         }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

   }
  
   private void copyAnnotations(javassist.bytecode.MethodInfo src, javassist.bytecode.MethodInfo dest, String annotationTag)
   {
      AnnotationsAttribute attribute = (AnnotationsAttribute) src.getAttribute(annotationTag);
      if (attribute != null)
      {
         dest.addAttribute(attribute.copy(dest.getConstPool(), EMPTY_HASHMAP));
      }
   }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

      copyAnnotations(srcFile, destFile, AnnotationsAttribute.visibleTag);
   }
  
   private void copyAnnotations(ClassFile src, ClassFile dest, String annotationTag)
   {
      AnnotationsAttribute attribute = (AnnotationsAttribute) src.getAttribute(annotationTag);
      if (attribute != null)
      {
         dest.addAttribute(attribute.copy(dest.getConstPool(), EMPTY_HASHMAP));
      }
   }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

        log.info( "found package: " + pkgName );
        packages.add( pkgName );
        continue;
      }

      AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute( AnnotationsAttribute.visibleTag );
      if ( visible != null ) {
        boolean isEntity = visible.getAnnotation( Entity.class.getName() ) != null;
        if ( isEntity ) {
          log.info( "found EJB3 Entity bean: " + cf.getName() );
          entities.add( cf.getName() );
        }
        boolean isEmbeddable = visible.getAnnotation( Embeddable.class.getName() ) != null;
        if ( isEmbeddable ) {
          log.info( "found EJB3 @Embeddable: " + cf.getName() );
          entities.add( cf.getName() );
        }
        boolean isEmbeddableSuperclass = visible.getAnnotation( MappedSuperclass.class.getName() ) != null;
        if ( isEmbeddableSuperclass ) {
          log.info( "found EJB3 @MappedSuperclass: " + cf.getName() );
          entities.add( cf.getName() );
        }
      }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

    finally {
      dstream.close();
      is.close();
    }
    boolean match = false;
    AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute( AnnotationsAttribute.visibleTag );
    if ( visible != null ) {
      for ( Class annotation : filter.getAnnotations() ) {
        match = visible.getAnnotation( annotation.getName() ) != null;
        if ( match ) break;
      }
    }
    return match;
  }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

    }
  }

  @SuppressWarnings("SimplifiableIfStatement")
  private boolean containsClassAnnotationsOfInterest(ClassFile cf) {
    final AnnotationsAttribute visibleAnnotations = (AnnotationsAttribute) cf.getAttribute( AnnotationsAttribute.visibleTag );
    if ( visibleAnnotations == null ) {
      return false;
    }

    return visibleAnnotations.getAnnotation( Entity.class.getName() ) != null
        || visibleAnnotations.getAnnotation( MappedSuperclass.class.getName() ) != null
        || visibleAnnotations.getAnnotation( Embeddable.class.getName() ) != null
        || visibleAnnotations.getAnnotation( Converter.class.getName() ) != null;
  }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

      copySignature(mi, wmi);
   }

   private void moveAnnotations(MethodInfo src, MethodInfo dest, String annotationTag)
   {
      AnnotationsAttribute attribute = (AnnotationsAttribute) src.getAttribute(annotationTag);
      if (attribute != null)
      {
         @SuppressWarnings("unchecked")
         HashMap map = new HashMap();
         dest.addAttribute(attribute.copy(dest.getConstPool(), map));
         src.addAttribute(new AnnotationsAttribute(src.getConstPool(), annotationTag));
      }
   }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

    }
  }

  @SuppressWarnings("SimplifiableIfStatement")
  private boolean containsClassAnnotationsOfInterest(ClassFile cf) {
    final AnnotationsAttribute visibleAnnotations = (AnnotationsAttribute) cf.getAttribute( AnnotationsAttribute.visibleTag );
    if ( visibleAnnotations == null ) {
      return false;
    }

    return visibleAnnotations.getAnnotation( Entity.class.getName() ) != null
        || visibleAnnotations.getAnnotation( MappedSuperclass.class.getName() ) != null
        || visibleAnnotations.getAnnotation( Embeddable.class.getName() ) != null
        || visibleAnnotations.getAnnotation( Converter.class.getName() ) != null;
  }
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.