alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.openide.compiler;

import java.util.*;

/** Provides support for compilation of
* CompilerJobs; not needed directly by modules.
* There is only one instance in the system,
* accessible via {@link #getDefault}.
*
* @author Jaroslav Tulach
*/
public abstract class CompilationEngine extends Object {
    /** Start asynchronous compilation of a compiler job.
    * @param job the job to compile
    * @return the task object representing the compilation
    */
    protected abstract CompilerTask start (CompilerJob job);

    /** Analyze dependencies between sets of compilers.
    *
    * Creates list of sets of compilers that describe the
    * levels that compose the compilation. Each level contains
    * a set of compilers that do not depend on each other.
    * The first level contains compilers that do not depend
    * on any other compiler; each next level holds compilers
    * that depend on at least one compiler from the previous level.
    *
    * @param job the compiler job to analyze
    * @return list of {@link Set}s of {@link Compiler}s
    * @exception DependencyException if there is a dependency between the
    *    compilers in the job
    */
    protected static List createComputationLevels (CompilerJob job)
    throws DependencyException {
        return job.computationLevels ();
    }

    /** Group a number of compilers together into compiler groups.
    * The groups then collect all tasks needed for compilation of those compilers.
    *
    * @param compilers collection of {@link Compiler}s
    * @return collection of {@link CompilerGroup}s
    * @exception CompilerGroupException if a compiler group instance cannot be created
    */
    protected static Collection createCompilerGroups (Collection compilers)
    throws CompilerGroupException {
        // map from Class to CompilerGroup
        HashMap groups = new HashMap ();

        Iterator it = compilers.iterator ();
        while (it.hasNext ()) {
            Compiler c = (Compiler)it.next ();
            if (c.isUpToDate()) {
                continue;
            }
            Object key = c.compilerGroupKey ();
            CompilerGroup group = (CompilerGroup)groups.get (key);
            if (group == null) {
                // create new group, register it
                Class clazz = c.compilerGroupClass ();
                try {
                    group = (CompilerGroup)clazz.newInstance ();
                } catch (Exception ex) {
                    throw new CompilerGroupException (clazz, ex);
                }
                groups.put (key, group);
            }

            // add the compiler to the group
            group.add (c);
        }

        // collection of compiler groups
        return groups.values ();
    }

    /** Method to obtain default instance of the engine.
     * @return the engine
     * @since 2.16
     */
    public static CompilationEngine getDefault () {
        return (CompilationEngine)
            org.openide.util.Lookup.getDefault().lookup(CompilationEngine.class);
    }

}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.