// Path: flexmojos-sandbox/flexmojos-flex-compiler/src/main/java/net/flexmojos/oss/compiler/interceptor/FlexToolInterceptor.java
// public interface FlexToolInterceptor {
// 
//     String[] intercept(FlexToolGroup flexToolGroup, FlexTool flexTool, String[] args);
// 
// }


import net.flexmojos.oss.compiler.command.CommandUtil;
import net.flexmojos.oss.compiler.command.Result;
import net.flexmojos.oss.compiler.util.FlexCompilerArgumentParser;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import net.flexmojos.oss.compiler.interceptor.FlexToolInterceptor;
import org.apache.flex.tools.FlexTool;
import org.apache.flex.tools.FlexToolGroup;
import org.apache.flex.tools.FlexToolRegistry;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import net.flexmojos.oss.compiler.command.Command;
            try {
                Class<?> optimizer = Class.forName("flex2.tools.Optimizer");
                Method optimizerMain = optimizer.getMethod("main", String[].class);
                optimizerMain.invoke(null, new Object[]{args});
            } catch (Exception e1) {
                throw new Exception("Could not find 'org.apache.flex.compiler.clients.Optimizer' or " +
                        "'flex2.tools.Optimizer' in the current projects classpath.");
            }
        }
    }

    private int executeTool(String toolGroupName, String toolName, String[] args) throws Exception {
        // Initialize the tool registry.
        FlexToolRegistry toolRegistry = new FlexToolRegistry();

        // Get the desired tool group.
        FlexToolGroup toolGroup = toolRegistry.getToolGroup(toolGroupName);
        if(toolGroup == null) {
            throw new Exception("Unable to find compiler: " + toolGroupName + " in the plugin classpath. " +
                    "List of compiles found: " + toolRegistry.getToolGroupNames());
        }

        // Get the desired tool.
        if(!toolGroup.hasFlexTool(toolName)) {
            throw new Exception("Compiler: " + toolGroupName + " doesn't provide a tool named " + toolName);
        }
        FlexTool tool = toolGroup.getFlexTool(toolName);

        // If interceptors are provided, let each one process the argument list.
        if(interceptors != null) {
// Path: flexmojos-sandbox/flexmojos-flex-compiler/src/main/java/net/flexmojos/oss/compiler/interceptor/FlexToolInterceptor.java
// public interface FlexToolInterceptor {
// 
//     String[] intercept(FlexToolGroup flexToolGroup, FlexTool flexTool, String[] args);
// 
// }


// Path: flexmojos-sandbox/flexmojos-flex-compiler/src/main/java/net/flexmojos/oss/compiler/DefaultFlexCompiler.java
import net.flexmojos.oss.compiler.command.CommandUtil;
import net.flexmojos.oss.compiler.command.Result;
import net.flexmojos.oss.compiler.util.FlexCompilerArgumentParser;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import net.flexmojos.oss.compiler.interceptor.FlexToolInterceptor;
import org.apache.flex.tools.FlexTool;
import org.apache.flex.tools.FlexToolGroup;
import org.apache.flex.tools.FlexToolRegistry;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import net.flexmojos.oss.compiler.command.Command;

            try {
                Class<?> optimizer = Class.forName("flex2.tools.Optimizer");
                Method optimizerMain = optimizer.getMethod("main", String[].class);
                optimizerMain.invoke(null, new Object[]{args});
            } catch (Exception e1) {
                throw new Exception("Could not find 'org.apache.flex.compiler.clients.Optimizer' or " +
                        "'flex2.tools.Optimizer' in the current projects classpath.");
            }
        }
    }

    private int executeTool(String toolGroupName, String toolName, String[] args) throws Exception {
        // Initialize the tool registry.
        FlexToolRegistry toolRegistry = new FlexToolRegistry();

        // Get the desired tool group.
        FlexToolGroup toolGroup = toolRegistry.getToolGroup(toolGroupName);
        if(toolGroup == null) {
            throw new Exception("Unable to find compiler: " + toolGroupName + " in the plugin classpath. " +
                    "List of compiles found: " + toolRegistry.getToolGroupNames());
        }

        // Get the desired tool.
        if(!toolGroup.hasFlexTool(toolName)) {
            throw new Exception("Compiler: " + toolGroupName + " doesn't provide a tool named " + toolName);
        }
        FlexTool tool = toolGroup.getFlexTool(toolName);

        // If interceptors are provided, let each one process the argument list.
        if(interceptors != null) {
            for(FlexToolInterceptor interceptor : interceptors) {