Examples of AnnotationFinder


Examples of edu.cmu.cs.crystal.annotations.AnnotationFinder

              num_jobs + " total compilation units.";
          monitor.beginTask(task, num_jobs);
        }

        AnnotationDatabase annoDB = new AnnotationDatabase();
        AnnotationFinder finder = new AnnotationFinder(annoDB);

        // register annotations with database
        registerAnnotationsWithDatabase(annoDB);

        // run the annotation finder on everything
        if (monitor != null)
          monitor.subTask("Scanning annotations of analyzed compilation units");
        if (logger.isLoggable(Level.FINER))
          logger.finer("Scanning annotations of analyzed compilation units");
        for (ICompilationUnit compUnit : command.compilationUnits()) {
          if (compUnit == null)
            continue;
          ASTNode node = WorkspaceUtilities.getASTNodeFromCompilationUnit(compUnit);
          if (monitor != null && monitor.isCanceled())
            // cancel here in case cancellation can produce null or incomplete ASTs
            return;
          if (!(node instanceof CompilationUnit))
            continue;

          // Dummy analysis input
          IAnalysisInput input = new IAnalysisInput() {
            private AnnotationDatabase annoDB = new AnnotationDatabase();

            public AnnotationDatabase getAnnoDB() {
              return annoDB;
            }
           
            public Option<IProgressMonitor> getProgressMonitor() {
              // don't give progress monitor to annotation finder
              return Option.none();
            }

            public Option<CompilationUnitTACs> getComUnitTACs() {
              // don't give 3-address code to annotation finder
              return Option.none();
            }
          };

          // Run annotation finder
          finder.runAnalysis(command.reporter(), input, compUnit, (CompilationUnit) node);
        }

        // tell analyses that the analysis is about to begin!
        for (ICrystalAnalysis analysis : analyses_to_use ) {
          analysis.beforeAllCompilationUnits();
View Full Code Here

Examples of org.apache.openejb.util.AnnotationFinder

                return ClientModule.class;
            }
        }

        if (searchForDescriptorlessApplications) {
            AnnotationFinder classFinder = new AnnotationFinder(classLoader, baseUrl);

            AnnotationFinder.Filter filter = new AnnotationFinder.Filter() {
                public boolean accept(String annotationName) {
                    if (annotationName.startsWith("javax.ejb.")) {
                        if ("javax.ejb.Stateful".equals(annotationName)) return true;
                        if ("javax.ejb.Stateless".equals(annotationName)) return true;
                        if ("javax.ejb.Singleton".equals(annotationName)) return true;
                        if ("javax.ejb.MessageDriven".equals(annotationName)) return true;
                    }
                    return false;
                }
            };

            if (classFinder.find(filter)) {
                return EjbModule.class;
            }
        }

        if (descriptors.containsKey("persistence.xml")) {
View Full Code Here

Examples of org.apache.openejb.util.AnnotationFinder

    }

    private Class<? extends DeploymentModule> checkAnnotations(final URL urls, final ClassLoader classLoader, final boolean scanPotentialEjbModules, final boolean scanPotentialClientModules) {
        Class<? extends DeploymentModule> cls = null;
        if (scanPotentialEjbModules || scanPotentialClientModules) {
            final AnnotationFinder classFinder = new AnnotationFinder(classLoader, urls);

            final Set<Class<? extends DeploymentModule>> otherTypes = new LinkedHashSet<Class<? extends DeploymentModule>>();

            final AnnotationFinder.Filter filter = new AnnotationFinder.Filter() {
                final String packageName = LocalClient.class.getName().replace("LocalClient", "");

                @Override
                public boolean accept(final String annotationName) {
                    if (scanPotentialClientModules && annotationName.startsWith(packageName)) {
                        if (LocalClient.class.getName().equals(annotationName)) otherTypes.add(ClientModule.class);
                        if (RemoteClient.class.getName().equals(annotationName)) otherTypes.add(ClientModule.class);
                    } else if (scanPotentialEjbModules) {
                        if (annotationName.startsWith("javax.ejb.")) {
                            if ("javax.ejb.Stateful".equals(annotationName)) return true;
                            if ("javax.ejb.Stateless".equals(annotationName)) return true;
                            if ("javax.ejb.Singleton".equals(annotationName)) return true;
                            if ("javax.ejb.MessageDriven".equals(annotationName)) return true;
                        } else if (scanManagedBeans && "javax.annotation.ManagedBean".equals(annotationName)) {
                            return true;
                        }
                    }
                    return false;
                }
            };

            if (classFinder.find(filter)) {
                cls = EjbModule.class;
            }

            if (otherTypes.size() > 0) {
                // We may want some ordering/sorting if we add more type scanning
View Full Code Here

Examples of org.apache.openejb.util.AnnotationFinder

                if (mainClass != null) {
                    return false;
                }
            }

            AnnotationFinder classFinder = new AnnotationFinder(classLoader, urls);

            AnnotationFinder.Filter filter = new AnnotationFinder.Filter() {
                public boolean accept(String annotationName) {
                    if (annotationName.startsWith("javax.ejb.")) {
                        if ("javax.ejb.Stateful".equals(annotationName)) return true;
                        if ("javax.ejb.Stateless".equals(annotationName)) return true;
                        if ("javax.ejb.Singleton".equals(annotationName)) return true;
                        if ("javax.ejb.MessageDriven".equals(annotationName)) return true;
                    } else if ("javax.annotation.ManagedBean".equals(annotationName)) {
                        return true;
                    }
                    return false;
                }
            };

            return classFinder.find(filter);

        } catch (Exception e) {
            log.warn("Unable to determine module type for jar: " + baseUrl.toExternalForm(), e);
            return false;
        }
View Full Code Here

Examples of org.apache.openejb.util.AnnotationFinder

                return ClientModule.class;
            }
        }

        if (searchForDescriptorlessApplications) {
            AnnotationFinder classFinder = new AnnotationFinder(classLoader, baseUrl);

            final Set<Class<? extends DeploymentModule>> otherTypes = new LinkedHashSet();

            AnnotationFinder.Filter filter = new AnnotationFinder.Filter() {
                final String packageName = LocalClient.class.getName().replace("LocalClient", "");
                public boolean accept(String annotationName) {
                    if (annotationName.startsWith("javax.ejb.")) {
                        if ("javax.ejb.Stateful".equals(annotationName)) return true;
                        if ("javax.ejb.Stateless".equals(annotationName)) return true;
                        if ("javax.ejb.Singleton".equals(annotationName)) return true;
                        if ("javax.ejb.MessageDriven".equals(annotationName)) return true;
                    } else if (annotationName.startsWith(packageName)){
                        if (LocalClient.class.getName().equals(annotationName)) otherTypes.add(ClientModule.class);
                        if (RemoteClient.class.getName().equals(annotationName)) otherTypes.add(ClientModule.class);
                    }
                    return false;
                }
            };

            if (classFinder.find(filter)) {
                return EjbModule.class;
            }

            if (otherTypes.size() > 0){
                // We may want some ordering/sorting if we add more type scanning
View Full Code Here

Examples of org.apache.openejb.util.AnnotationFinder

    }

    private Class<? extends DeploymentModule> checkAnnotations(URL urls, ClassLoader classLoader, final boolean scanPotentialEjbModules, final boolean scanPotentialClientModules) {
        Class<? extends DeploymentModule> cls = null;
        if (scanPotentialEjbModules || scanPotentialClientModules) {
            AnnotationFinder classFinder = new AnnotationFinder(classLoader, urls);

            final Set<Class<? extends DeploymentModule>> otherTypes = new LinkedHashSet<Class<? extends DeploymentModule>>();

            AnnotationFinder.Filter filter = new AnnotationFinder.Filter() {
                final String packageName = LocalClient.class.getName().replace("LocalClient", "");

                public boolean accept(String annotationName) {
                    if (scanPotentialEjbModules) {
                        if (annotationName.startsWith("javax.ejb.")) {
                            if ("javax.ejb.Stateful".equals(annotationName)) return true;
                            if ("javax.ejb.Stateless".equals(annotationName)) return true;
                            if ("javax.ejb.Singleton".equals(annotationName)) return true;
                            if ("javax.ejb.MessageDriven".equals(annotationName)) return true;
                        } else if (scanManagedBeans && "javax.annotation.ManagedBean".equals(annotationName)) {
                            return true;
                        }
                    } else if (scanPotentialClientModules && annotationName.startsWith(packageName)) {
                        if (LocalClient.class.getName().equals(annotationName)) otherTypes.add(ClientModule.class);
                        if (RemoteClient.class.getName().equals(annotationName)) otherTypes.add(ClientModule.class);
                    }
                    return false;
                }
            };

            if (classFinder.find(filter)) {
                cls = EjbModule.class;
            }

            if (otherTypes.size() > 0) {
                // We may want some ordering/sorting if we add more type scanning
View Full Code Here

Examples of org.apache.openejb.util.AnnotationFinder

                if (mainClass != null) {
                    return false;
                }
            }

            AnnotationFinder classFinder = new AnnotationFinder(classLoader, urls);

            AnnotationFinder.Filter filter = new AnnotationFinder.Filter() {
                public boolean accept(String annotationName) {
                    if (annotationName.startsWith("javax.ejb.")) {
                        if ("javax.ejb.Stateful".equals(annotationName)) return true;
                        if ("javax.ejb.Stateless".equals(annotationName)) return true;
                        if ("javax.ejb.Singleton".equals(annotationName)) return true;
                        if ("javax.ejb.MessageDriven".equals(annotationName)) return true;
                    } else if ("javax.annotation.ManagedBean".equals(annotationName)) {
                        return true;
                    }
                    return false;
                }
            };

            return classFinder.find(filter);

        } catch (Exception e) {
            log.warn("Unable to determine module type for jar: " + baseUrl.toExternalForm(), e);
            return false;
        }
View Full Code Here

Examples of org.apache.xbean.finder.AnnotationFinder

                    {
                        archives.add(new GovernatorFileArchive(classLoader, thisUrl, basePackage));
                    }
                }
                CompositeArchive compositeArchive = new CompositeArchive(archives);
                AnnotationFinder annotationFinder = new AnnotationFinder(compositeArchive);
                for ( Class<? extends Annotation> annotation : annotations )
                {
                    localClasses.addAll(annotationFinder.findAnnotatedClasses(annotation));
                    localConstructors.addAll(annotationFinder.findAnnotatedConstructors(annotation));
                    localMethods.addAll(annotationFinder.findAnnotatedMethods(annotation));
                    localFields.addAll(annotationFinder.findAnnotatedFields(annotation));
                }
            }
        }
        catch ( IOException e )
        {
View Full Code Here

Examples of org.apache.xbean.finder.AnnotationFinder

            if (!(finder instanceof FinderFactory.ModuleLimitedFinder)) return finder.getAnnotatedClassNames();

            final IAnnotationFinder delegate = ((FinderFactory.ModuleLimitedFinder) finder).getDelegate();
            if (!(delegate instanceof AnnotationFinder)) return finder.getAnnotatedClassNames();

            final AnnotationFinder annotationFinder = (AnnotationFinder) delegate;

            final Archive archive = annotationFinder.getArchive();
            if (!(archive instanceof WebappAggregatedArchive)) return finder.getAnnotatedClassNames();

            final List<String> classes = new ArrayList<String>();

            final WebappAggregatedArchive aggregatedArchive = (WebappAggregatedArchive) archive;
View Full Code Here

Examples of org.apache.xbean.finder.AnnotationFinder

        }

        // the result
        final Set<String> classes = new TreeSet<String>();
        try {
            final AnnotationFinder finder = new AnnotationFinder(archive);
            finder.link();

            //
            // find classes
            //

            for (Profile profile : profileToUse) {
                if (profile.getAnnotations() != null) {
                    for (String annotation : profile.getAnnotations()) {
                        final Class<? extends Annotation> annClazz;
                        try {
                            annClazz = (Class<? extends Annotation>) load(loader, annotation);
                        } catch (MojoFailureException mfe) {
                            getLog().warn("can't find " + annotation);
                            continue;
                        }

                        if (!useMeta) {
                            for (Class<?> clazz : finder.findAnnotatedClasses(annClazz)) {
                                classes.add(clazz.getName());
                            }
                        } else {
                            for (Annotated<Class<?>> clazz : finder.findMetaAnnotatedClasses(annClazz)) {
                                classes.add(clazz.get().getName());
                            }
                        }

                        if (!useMeta) {
                            for (Field clazz : finder.findAnnotatedFields(annClazz)) {
                                classes.add(clazz.getDeclaringClass().getName());
                            }
                        } else {
                            for (Annotated<Field> clazz : finder.findMetaAnnotatedFields(annClazz)) {
                                classes.add(clazz.get().getDeclaringClass().getName());
                            }
                        }

                        if (!useMeta) {
                            for (Method clazz : finder.findAnnotatedMethods(annClazz)) {
                                classes.add(clazz.getDeclaringClass().getName());
                            }
                        } else {
                            for (Annotated<Method> clazz : finder.findMetaAnnotatedMethods(annClazz)) {
                                classes.add(clazz.get().getDeclaringClass().getName());
                            }
                        }
                    }
                }

                if (profile.getSubclasses() != null) {
                    for (String subclass : profile.getSubclasses()) {
                        try {
                            for (Class<?> clazz : finder.findSubclasses(load(loader, subclass))) {
                                classes.add(clazz.getName());
                            }
                        } catch (MojoFailureException mfe) {
                            getLog().warn("can't find " + subclass);
                        }
                    }
                }

                if (profile.getImplementations() != null) {
                    for (String implementation : profile.getImplementations()) {
                        try {
                            for (Class<?> clazz : finder.findImplementations(load(loader, implementation))) {
                                classes.add(clazz.getName());
                            }
                        } catch (MojoFailureException mfe) {
                            getLog().warn("can't find " + implementation);
                        }
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.