Package org.springframework.asm

Examples of org.springframework.asm.ClassReader


  }

  public static final EmptyVisitor EMPTY_VISITOR = new EmptyVisitor();

  public void visit(Resource resource) throws IOException {
    ClassReader cr = new ClassReader(resource.getInputStream());
    cr.accept(createClassVisitor(model), false);
  }
View Full Code Here


  public Object extractSource(Object sourceCandidate,
      Resource definingResource) {
    if (sourceCandidate instanceof FileSystemResource) {
      try {
        ClassReader  reader = classReaderFactory.
          getClassReader((FileSystemResource) sourceCandidate);
        ClassMetadataReadingVisitor v = new ClassMetadataReadingVisitor();
        reader.accept(v, ClassReader.SKIP_DEBUG);
        String className = v.getClassName();
        IType type = JdtUtils.getJavaType(project, className);
        if (type != null) {
          return new JavaModelSourceLocation(type);
        }
View Full Code Here

  private AnnotationMetadata getAnnotationMetadata(final ClassReaderFactory classReaderFactory, final IBean bean,
      final IType type) {
    final String className = type.getFullyQualifiedName();
    final AnnotationMetadata visitor = new AnnotationMetadata();
    try {
      ClassReader classReader = classReaderFactory.getClassReader(className);
      classReader.accept(visitor, 0);
    }
    catch (IOException e) {
      // ignore any missing files here as this will be
      // reported as missing bean class
    }
View Full Code Here

  }

  public ClassReader getClassReader(Resource resource) throws IOException {
    InputStream is = resource.getInputStream();
    try {
      return new ClassReader(is);
    }
    finally {
      is.close();
    }
  }
View Full Code Here

    this.type = type;

    this.visitor = new JdtConnectedAnnotationMetadataReadingVisitor(classloader, type);

    try {
      ClassReader classReader = classReaderFactory.getClassReader(type.getFullyQualifiedName());
      classReader.accept(this.visitor, 0);
    } catch (IOException e) {
      SpringCore.log(e);
    }
   
  }
View Full Code Here

    super(classLoader);
  }

  public ClassReader getClassReader(Resource resource) throws IOException {
    synchronized (this.classReaderCache) {
      ClassReader classReader = this.classReaderCache.get(resource);
      if (classReader == null) {
        classReader = super.getClassReader(resource);
        this.classReaderCache.put(resource, classReader);
      }
      return classReader;
View Full Code Here

      final IBean bean, final IType type, Set<String> requiredAnnotationTypes) {
    String className = type.getFullyQualifiedName();
    RequiredAnnotationMetadata visitor = new RequiredAnnotationMetadata(requiredAnnotationTypes);
    try {
      while (className != null && !Object.class.getName().equals(className)) {
        ClassReader classReader = classReaderFactory.getClassReader(className);
        classReader.accept(visitor, 0);
        className = visitor.getSuperClassName();
      }
    }
    catch (IOException e) {
      // ignore any missing files here as this will be
View Full Code Here

    String className = type.getFullyQualifiedName();
    try {
      while (className != null && !Object.class.getName().equals(className) && type != null
          && !type.isBinary()) {

        ClassReader classReader = classReaderFactory.getClassReader(className);
        annotationVisitor.setType(type);
        annotationVisitor.setClassloader(classLoader);

        classReader.accept((ClassVisitor) annotationVisitor, 0);

        className = annotationVisitor.getSuperClassName();
        type = JdtUtils.getJavaType(beansProject, className);
      }
    }
View Full Code Here

  }

  private void createAnnotationAspectDefinition(IBean bean, final String id, final String className,
      final List<IAspectDefinition> aspectInfos) throws Throwable {

    ClassReader classReader = getClassReader(className);
    if (classReader == null) {
      return;
    }

    AdviceAnnotationVisitor v = new AdviceAnnotationVisitor(id, className, bean.getElementStartLine(), bean
        .getElementEndLine());
    classReader.accept(v, 0);

    List<IAspectDefinition> aspectDefinitions = v.getAspectDefinitions();
    for (IAspectDefinition def : aspectDefinitions) {
      def.setResource(bean.getElementResource());
      addAspectDefinition(def, aspectInfos);
View Full Code Here

    }
  }

  private boolean validateAspect(String className) throws Throwable {

    ClassReader classReader = getClassReader(className);
    if (classReader == null) {
      return false;
    }
    AspectAnnotationVisitor v = new AspectAnnotationVisitor();
    classReader.accept(v, 0);

    if (!v.getClassInfo().hasAspectAnnotation()) {
      return false;
    }
    else {
      // we know it's an aspect, but we don't know whether it is an
      // @AspectJ aspect or a code style aspect.
      // This is an *unclean* test whilst waiting for AspectJ to
      // provide us with something better
      for (String m : v.getClassInfo().getMethodNames()) {
        if (m.startsWith(AJC_MAGIC)) {
          // must be a code style aspect
          return false;
        }
      }
      // validate supported instantiation models
      if (v.getClassInfo().getAspectAnnotation().getValue() != null) {
        if (v.getClassInfo().getAspectAnnotation().getValue().toUpperCase().equals(
            PerClauseKind.PERCFLOW.toString())) {
          return false;
        }
        if (v.getClassInfo().getAspectAnnotation().getValue().toUpperCase().toString().equals(
            PerClauseKind.PERCFLOWBELOW.toString())) {
          return false;
        }
      }

      // check if super class is Aspect as well and abstract
      if (v.getClassInfo().getSuperType() != null) {
        classReader = getClassReader(v.getClassInfo().getSuperType());
        if (classReader == null) {
          return false;
        }

        AspectAnnotationVisitor sv = new AspectAnnotationVisitor();
        classReader.accept(sv, 0);

        if (sv.getClassInfo().getAspectAnnotation() != null
            && !((sv.getClassInfo().getModifier() & Opcodes.ACC_ABSTRACT) != 0)) {
          return false;
        }
View Full Code Here

TOP

Related Classes of org.springframework.asm.ClassReader

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.