You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CompilerFactory.java 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /********************************************************************
  2. * Copyright (c) 2006 Contributors. All rights reserved.
  3. * This program and the accompanying materials are made available
  4. * under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution and is available at
  6. * http://eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: IBM Corporation - initial API and implementation
  9. * Helen Hawkins - initial version (bug 148190)
  10. *******************************************************************/
  11. package org.aspectj.systemtest.incremental.tools;
  12. import java.util.Collection;
  13. import java.util.Hashtable;
  14. import java.util.Iterator;
  15. import java.util.Map;
  16. import org.aspectj.ajde.core.AjCompiler;
  17. /**
  18. * Manages the different compilers for the different projects within one test run
  19. */
  20. public class CompilerFactory {
  21. private static Map compilerMap = new Hashtable();
  22. /**
  23. * If an AjCompiler exists for the given projectDir then returns
  24. * that, otherwise creates a new one.
  25. */
  26. public static AjCompiler getCompilerForProjectWithDir(String projectDir) {
  27. if (compilerMap.containsKey(projectDir)) {
  28. return (AjCompiler) compilerMap.get(projectDir);
  29. }
  30. AjCompiler compiler = new AjCompiler(
  31. projectDir,
  32. new MultiProjTestCompilerConfiguration(projectDir),
  33. new MultiProjTestBuildProgressMonitor(),
  34. new MultiProjTestMessageHandler());
  35. compilerMap.put(projectDir,compiler);
  36. return compiler;
  37. }
  38. /**
  39. * Clears the current map - before doing so clears the state of
  40. * each compiler (this ensures everything is cleaned up in the
  41. * IncrementalStateManager)
  42. */
  43. public static void clearCompilerMap() {
  44. Collection compilers = compilerMap.values();
  45. for (Iterator iterator = compilers.iterator(); iterator.hasNext();) {
  46. AjCompiler compiler = (AjCompiler) iterator.next();
  47. compiler.clearLastState();
  48. }
  49. compilerMap.clear();
  50. }
  51. }