Examples of DependencyAnalyzer


Examples of com.dianping.cat.consumer.dependency.DependencyAnalyzer

public class DependencyPerformanceTest extends ComponentTestCase {

  @Test
  public void test() throws Exception {
    DependencyAnalyzer analyzer = (DependencyAnalyzer)lookup(MessageAnalyzer.class,DependencyAnalyzer.ID);
    MessageTree tree = buildMessage();

    long current = System.currentTimeMillis();

    int size = 10000000;
    for (int i = 0; i < size; i++) {
      analyzer.process(tree);
    }
    System.out.println(analyzer.getReport("cat"));
    System.out.println("Cost " + (System.currentTimeMillis() - current) / 1000);
    // cost 26
  }
View Full Code Here

Examples of net.sf.jcontracts.dependencyanalyzer.DependencyAnalyzer

            if (targets.isEmpty())
            {
                throw new RuntimeException(
                        "Java Contract Suite: error list of source files is empty or no matches for pattern(s), no files to process!");
            }
            DependencyAnalyzer da = new DependencyAnalyzer();
            Graph dependencyGraph = null;
            log.info("parsing input files to determine dependencies.");
            long start = System.currentTimeMillis();
            MultipleCompilationUnitState multipleCompilationUnitState = new MultipleCompilationUnitState();
            try
            {
                for (int targetIndex = 0; targetIndex < targets.size(); targetIndex++)
                {
                    String filename = ((Target) targets.elementAt(targetIndex)).getName();
                    try
                    {
                        Reader is = new FileReader(filename);
                        try
                        {
                            BufferedReader bufferedIs = new BufferedReader(is);
                            try
                            {
                                recent_file = filename;
                                if (++number_of_files % 50 == 0 && number_of_files > 0)
                                {
                                    log.info(" (" + number_of_files + " files parsed)");
                                }
                                net.sf.jcontracts.codeparser.Parser parser = new net.sf.jcontracts.codeparser.Parser(
                                        bufferedIs, filename, multipleCompilationUnitState);
                                MetaclassFactory metaclassFactory = new MetaclassFactory(filename);
                                parser.setMetaclassFactory(metaclassFactory);
                                Vector v = parser.getUsedTypes();
                                da.process(v);
                            }
                            finally
                            {
                                bufferedIs.close();
                            }
                        }
                        finally
                        {
                            is.close();
                        }
                    }
                    catch (FileNotFoundException _ex)
                    {
                        throw new RuntimeException("Java Contract Suite: error file " + filename + " not found!", _ex);
                    }
                }

                long end = System.currentTimeMillis();
                log.info("Analyzed " + targets.size() + " files in " + (end - start) / 1000D + " s.");
            }
            catch (Exception e)
            {
                log.error("parsing problem while looking at " + recent_file);
                throw e;
            }
            if (multipleCompilationUnitState.hasUnresolvedNames())
            {
                String unresolvedNames = multipleCompilationUnitState.getUnresolvedNamesAsString();
                log.error("could not resolve the following type names:\n" + unresolvedNames);
                throw new RuntimeException("could not resolve the following type names:\n" + unresolvedNames);
            }
            dependencyGraph = da.getGraph();
            log.info("found " + dependencyGraph.getSize() + " relavant types referenced in the " + targets.size()
                    + " files.");
            AllOption allOption = null;
            for (int i = 0; i < options.size(); i++)
            {
View Full Code Here

Examples of org.apache.tools.ant.util.depend.DependencyAnalyzer

                }
            }

            if (dependencyList == null) {
                // not cached - so need to read directly from the class file
                DependencyAnalyzer analyzer = new AntAnalyzer();
                analyzer.addRootClass(info.className);
                analyzer.addClassPath(destPath);
                analyzer.setClosure(false);
                dependencyList = new Vector();
                Enumeration depEnum = analyzer.getClassDependencies();
                while (depEnum.hasMoreElements()) {
                    dependencyList.addElement(depEnum.nextElement());
                }
                cacheDirty = true;
                dependencyMap.put(info.className, dependencyList);
View Full Code Here

Examples of org.apache.tools.ant.util.depend.DependencyAnalyzer

     * @exception IllegalStateException when basedir was set incorrectly.
     */
    public synchronized void scan() throws IllegalStateException {
        included = new Vector();
        String analyzerClassName = DEFAULT_ANALYZER_CLASS;
        DependencyAnalyzer analyzer = null;
        try {
            Class analyzerClass = Class.forName(analyzerClassName);
            analyzer = (DependencyAnalyzer) analyzerClass.newInstance();
        } catch (Exception e) {
            throw new BuildException("Unable to load dependency analyzer: "
                + analyzerClassName, e);
        }
        analyzer.addClassPath(new Path(null, basedir.getPath()));

        for (Enumeration e = rootClasses.elements(); e.hasMoreElements();) {
            String rootClass = (String) e.nextElement();
            analyzer.addRootClass(rootClass);
        }
        Enumeration e = analyzer.getClassDependencies();

        String[] parentFiles = parentScanner.getIncludedFiles();
        Hashtable parentSet = new Hashtable();
        for (int i = 0; i < parentFiles.length; ++i) {
            parentSet.put(parentFiles[i], parentFiles[i]);
View Full Code Here

Examples of org.apache.tools.ant.util.depend.DependencyAnalyzer

     * @exception IllegalStateException when basedir was set incorrecly
     */
    public void scan() throws IllegalStateException {
        included = new Vector();
        String analyzerClassName = DEFAULT_ANALYZER_CLASS;
        DependencyAnalyzer analyzer = null;
        try {
            Class analyzerClass = Class.forName(analyzerClassName);
            analyzer = (DependencyAnalyzer) analyzerClass.newInstance();
        } catch (Exception e) {
            throw new BuildException("Unable to load dependency analyzer: "
                + analyzerClassName, e);
        }
        analyzer.addClassPath(new Path(null, basedir.getPath()));
       
        for (Enumeration e = rootClasses.elements(); e.hasMoreElements();) {
            String rootClass = (String) e.nextElement();
            analyzer.addRootClass(rootClass);
        }

        Enumeration e = analyzer.getClassDependencies();

        String[] parentFiles = parentScanner.getIncludedFiles();
        Hashtable parentSet = new Hashtable();
        for (int i = 0; i < parentFiles.length; ++i) {
            parentSet.put(parentFiles[i], parentFiles[i]);
View Full Code Here

Examples of org.apache.tools.ant.util.depend.DependencyAnalyzer

                }
            }

            if (dependencyList == null) {
                // not cached - so need to read directly from the class file
                DependencyAnalyzer analyzer = new AntAnalyzer();
                analyzer.addRootClass(info.className);
                analyzer.addClassPath(destPath);
                analyzer.setClosure(false);
                dependencyList = new Vector();
                Enumeration depEnum = analyzer.getClassDependencies();
                while (depEnum.hasMoreElements()) {
                    dependencyList.addElement(depEnum.nextElement());
                }
                if (dependencyList != null) {
                    cacheDirty = true;
View Full Code Here

Examples of org.apache.tools.ant.util.depend.DependencyAnalyzer

     * @exception IllegalStateException when basedir was set incorrecly
     */
    public void scan() throws IllegalStateException {
        included = new Vector();
        String analyzerClassName = DEFAULT_ANALYZER_CLASS;
        DependencyAnalyzer analyzer = null;
        try {
            Class analyzerClass = Class.forName(analyzerClassName);
            analyzer = (DependencyAnalyzer) analyzerClass.newInstance();
        } catch (Exception e) {
            throw new BuildException("Unable to load dependency analyzer: "
                + analyzerClassName, e);
        }
        analyzer.addClassPath(new Path(null, basedir.getPath()));

        for (Enumeration e = rootClasses.elements(); e.hasMoreElements();) {
            String rootClass = (String) e.nextElement();
            analyzer.addRootClass(rootClass);
        }

        Enumeration e = analyzer.getClassDependencies();

        String[] parentFiles = parentScanner.getIncludedFiles();
        Hashtable parentSet = new Hashtable();
        for (int i = 0; i < parentFiles.length; ++i) {
            parentSet.put(parentFiles[i], parentFiles[i]);
View Full Code Here

Examples of org.apache.tools.ant.util.depend.DependencyAnalyzer

                }
            }

            if (dependencyList == null) {
                // not cached - so need to read directly from the class file
                DependencyAnalyzer analyzer = new AntAnalyzer();
                analyzer.addRootClass(info.className);
                analyzer.addClassPath(destPath);
                analyzer.setClosure(false);
                dependencyList = new Vector();
                Enumeration depEnum = analyzer.getClassDependencies();
                while (depEnum.hasMoreElements()) {
                    dependencyList.addElement(depEnum.nextElement());
                }
                if (dependencyList != null) {
                    cacheDirty = true;
View Full Code Here

Examples of org.apache.tools.ant.util.depend.DependencyAnalyzer

     * @exception IllegalStateException when basedir was set incorrectly.
     */
    public synchronized void scan() throws IllegalStateException {
        included = new Vector<String>();
        String analyzerClassName = DEFAULT_ANALYZER_CLASS;
        DependencyAnalyzer analyzer = null;
        try {
            Class<? extends DependencyAnalyzer> analyzerClass = Class.forName(analyzerClassName)
                    .asSubclass(DependencyAnalyzer.class);
            analyzer = analyzerClass.newInstance();
        } catch (Exception e) {
            throw new BuildException("Unable to load dependency analyzer: "
                                     + analyzerClassName, e);
        }
        analyzer.addClassPath(new Path(null, basedir.getPath()));
        for (Enumeration<File> e = additionalBaseDirs.elements(); e.hasMoreElements();) {
            File additionalBaseDir = e.nextElement();
            analyzer.addClassPath(new Path(null, additionalBaseDir.getPath()));
        }

        for (Enumeration<String> e = rootClasses.elements(); e.hasMoreElements();) {
            String rootClass = e.nextElement();
            analyzer.addRootClass(rootClass);
        }
        Enumeration<String> e = analyzer.getClassDependencies();

        String[] parentFiles = parentScanner.getIncludedFiles();
        Hashtable<String, String> parentSet = new Hashtable<String, String>();
        for (int i = 0; i < parentFiles.length; ++i) {
            parentSet.put(parentFiles[i], parentFiles[i]);
View Full Code Here

Examples of org.apache.tools.ant.util.depend.DependencyAnalyzer

     * @exception IllegalStateException when basedir was set incorrecly
     */
    public void scan() throws IllegalStateException {
        included = new Vector();
        String analyzerClassName = DEFAULT_ANALYZER_CLASS;
        DependencyAnalyzer analyzer = null;
        try {
            Class analyzerClass = Class.forName(analyzerClassName);
            analyzer = (DependencyAnalyzer) analyzerClass.newInstance();
        } catch (Exception e) {
            throw new BuildException("Unable to load dependency analyzer: "
                + analyzerClassName, e);
        }
        analyzer.addClassPath(new Path(null, basedir.getPath()));

        for (Enumeration e = rootClasses.elements(); e.hasMoreElements();) {
            String rootClass = (String) e.nextElement();
            analyzer.addRootClass(rootClass);
        }

        Enumeration e = analyzer.getClassDependencies();

        String[] parentFiles = parentScanner.getIncludedFiles();
        Hashtable parentSet = new Hashtable();
        for (int i = 0; i < parentFiles.length; ++i) {
            parentSet.put(parentFiles[i], parentFiles[i]);
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.