commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r290094 - in /jakarta/commons/sandbox/jci/trunk/src: java/org/apache/commons/jci/ java/org/apache/commons/jci/compilers/ java/org/apache/commons/jci/compilers/eclipse/ java/org/apache/commons/jci/compilers/groovy/ java/org/apache/commons/jc...
Date Mon, 19 Sep 2005 08:46:40 GMT
Author: tcurdt
Date: Mon Sep 19 01:46:24 2005
New Revision: 290094

URL: http://svn.apache.org/viewcvs?rev=290094&view=rev
Log:
introduced a CompilationResult, optional CompilatioProblemHandler to come

Added:
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/CompilationResult.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/Transactional.java
Removed:
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/ConsoleCompilationProblemHandler.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/DefaultCompilationProblemHandler.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/LogCompilationProblemHandler.java
Modified:
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/CompilingClassLoader.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompiler.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/groovy/GroovyJavaCompiler.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/CompilingListener.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/ReloadingListener.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/TransactionalResourceStore.java
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/CompilerUtils.java
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompilerTestCase.java
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/groovy/GroovyJavaCompilerTestCase.java
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/janino/JaninoJavaCompilerTestCase.java
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/problems/CompilationProblemTestCase.java

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/CompilingClassLoader.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/CompilingClassLoader.java?rev=290094&r1=290093&r2=290094&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/CompilingClassLoader.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/CompilingClassLoader.java
Mon Sep 19 01:46:24 2005
@@ -31,16 +31,10 @@
 
     private final TransactionalResourceStore transactionalStore;
     private final JavaCompiler compiler;
-
+    private CompilingListener listener;
+    
     public CompilingClassLoader(final ClassLoader pParent, final File pRepository) {
-        this(pParent, pRepository, new TransactionalResourceStore(
-                new MemoryResourceStore()) {
-                    public void onStart() {
-                        };
-                    public void onStop() {
-                        };
-                }
-        );
+        this(pParent, pRepository, new TransactionalResourceStore(new MemoryResourceStore()));
     }
 
     public CompilingClassLoader(final ClassLoader pParent, final File pRepository, final
TransactionalResourceStore pStore) {
@@ -56,8 +50,7 @@
 
     public void start() {
         fam = new FilesystemAlterationMonitor();
-        // FIXME keep reference for accessing errors/warnings
-        fam.addListener(new CompilingListener(
+        listener = new CompilingListener(
                 reader,
                 compiler,
                 transactionalStore
@@ -66,7 +59,9 @@
                 super.reload();
                 CompilingClassLoader.this.reload();
             }
-        }, repository);
+        };
+        
+        fam.addListener(listener, repository);
         thread = new Thread(fam);
         thread.start();
     }

Added: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/CompilationResult.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/CompilationResult.java?rev=290094&view=auto
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/CompilationResult.java
(added)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/CompilationResult.java
Mon Sep 19 01:46:24 2005
@@ -0,0 +1,36 @@
+package org.apache.commons.jci.compilers;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import org.apache.commons.jci.problems.CompilationProblem;
+
+
+public final class CompilationResult {
+    
+    final Collection errors = new ArrayList();
+    final Collection warnings = new ArrayList();
+
+    public CompilationResult( final Collection pProblems ) {
+        for (final Iterator it = pProblems.iterator(); it.hasNext();) {
+            final CompilationProblem problem = (CompilationProblem) it.next();
+            if (problem.isError()) {
+                errors.add(problem);
+            } else {
+                warnings.add(problem);
+            }
+        }
+    }
+    
+    public CompilationProblem[] getErrors() {
+        final CompilationProblem[] result = new CompilationProblem[errors.size()];
+        errors.toArray(result);
+        return result;
+    }
+
+    public CompilationProblem[] getWarnings() {
+        final CompilationProblem[] result = new CompilationProblem[warnings.size()];
+        warnings.toArray(result);
+        return result;
+    }
+}

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompiler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompiler.java?rev=290094&r1=290093&r2=290094&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompiler.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompiler.java
Mon Sep 19 01:46:24 2005
@@ -15,7 +15,6 @@
  */
 package org.apache.commons.jci.compilers;
 
-import org.apache.commons.jci.problems.CompilationProblemHandler;
 import org.apache.commons.jci.readers.ResourceReader;
 import org.apache.commons.jci.stores.ResourceStore;
 
@@ -25,10 +24,17 @@
  *
  */
 public interface JavaCompiler {
-    void compile(
+    // setCompilationProblemHandler( CompilationProblemHandler pHandler );
+
+    // addCompilationProblemHandler( CompilationProblemHandler pHandler );
+    // removeCompilationProblemHandler( CompilationProblemHandler pHandler );
+
+    // addCompilationProblemListener( CompilationProblemListener pListener );
+    // removeCompilationProblemListener( CompilationProblemListener pListener );
+
+    CompilationResult compile(
             final String[] pClazzNames,
             final ResourceReader pReader,
-            final ResourceStore pStore,
-            final CompilationProblemHandler pProblemHandler
-    );
+            final ResourceStore pStore
+            );
 }

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java?rev=290094&r1=290093&r2=290094&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java
Mon Sep 19 01:46:24 2005
@@ -19,13 +19,14 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
 import org.apache.commons.jci.compilers.JavaCompiler;
-import org.apache.commons.jci.problems.CompilationProblemHandler;
 import org.apache.commons.jci.readers.ResourceReader;
 import org.apache.commons.jci.stores.ResourceStore;
 import org.apache.commons.lang.StringUtils;
@@ -101,8 +102,11 @@
         }
     }
 
-    public void compile( final String[] pClazzNames, final ResourceReader pReader,
-            final ResourceStore pStore, final CompilationProblemHandler pProblemHandler )
{
+    public org.apache.commons.jci.compilers.CompilationResult compile(
+            final String[] pClazzNames,
+            final ResourceReader pReader,
+            final ResourceStore pStore
+            ) {
 
         final Map settingsMap = settings.getMap();
         final Set clazzIndex = new HashSet();
@@ -224,15 +228,15 @@
             }
         };
 
+        final Collection problems = new ArrayList();
         final ICompilerRequestor compilerRequestor = new ICompilerRequestor() {
             public void acceptResult( CompilationResult result ) {
                 if (result.hasProblems()) {
-                    if (pProblemHandler != null) {
-                        final IProblem[] problems = result.getProblems();
-                        for (int i = 0; i < problems.length; i++) {
-                            final IProblem problem = problems[i];
-                            pProblemHandler.handle(new EclipseCompilationProblem(problem));
-                        }
+                    final IProblem[] iproblems = result.getProblems();
+                    for (int i = 0; i < iproblems.length; i++) {
+                        final IProblem iproblem = iproblems[i];
+                        // call handler
+                        problems.add(new EclipseCompilationProblem(iproblem));
                     }
                 }
                 if (!result.hasErrors()) {
@@ -253,17 +257,11 @@
             }
         };
 
-        pProblemHandler.onStart();
-
-        try {
+        final Compiler compiler =
+            new Compiler(nameEnvironment, policy, settingsMap, compilerRequestor, problemFactory);
 
-            final Compiler compiler =
-                new Compiler(nameEnvironment, policy, settingsMap, compilerRequestor, problemFactory);
-    
-            compiler.compile(compilationUnits);
+        compiler.compile(compilationUnits);
 
-        } finally {
-            pProblemHandler.onStop();
-        }
+        return new org.apache.commons.jci.compilers.CompilationResult(problems);
     }
 }

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/groovy/GroovyJavaCompiler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/groovy/GroovyJavaCompiler.java?rev=290094&r1=290093&r2=290094&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/groovy/GroovyJavaCompiler.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/groovy/GroovyJavaCompiler.java
Mon Sep 19 01:46:24 2005
@@ -1,10 +1,12 @@
 package org.apache.commons.jci.compilers.groovy;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import org.apache.commons.jci.compilers.CompilationResult;
 import org.apache.commons.jci.compilers.JavaCompiler;
-import org.apache.commons.jci.problems.CompilationProblemHandler;
 import org.apache.commons.jci.readers.ResourceReader;
 import org.apache.commons.jci.stores.ResourceStore;
 import org.apache.commons.logging.Log;
@@ -22,11 +24,10 @@
 
     private final static Log log = LogFactory.getLog(GroovyJavaCompiler.class);
     
-    public void compile(
+    public CompilationResult compile(
             final String[] clazzNames,
             final ResourceReader reader,
-            final ResourceStore store,
-            final CompilationProblemHandler problemHandler
+            final ResourceStore store
             ) {
      
         final CompilerConfiguration configuration = new CompilerConfiguration();
@@ -47,7 +48,8 @@
             unit.addSource(source[i]);
         }
         
-        problemHandler.onStart();
+        final Collection problems = new ArrayList();
+
         try {
             log.debug("compiling");
             unit.compile();
@@ -61,27 +63,20 @@
             }
         } catch (final CompilationFailedException e) {
             final ErrorCollector col = e.getUnit().getErrorCollector();
-            
-            final List warnings = col.getWarnings();
-            log.debug("handling " + warnings.size() + " warnings");
+
+            final Collection warnings = col.getWarnings();
             for (final Iterator it = warnings.iterator(); it.hasNext();) {
                 final WarningMessage warning = (WarningMessage) it.next();
-                problemHandler.handle(
-                        new GroovyCompilationProblem(warning)
-                        );
+                problems.add(new GroovyCompilationProblem(warning));
             }
 
-            final List errors = col.getErrors();
-            log.debug("handling " + errors.size() + " errors");
+            final Collection errors = col.getErrors();
             for (final Iterator it = errors.iterator(); it.hasNext();) {
                 final Message message = (Message) it.next();
-                problemHandler.handle(
-                        new GroovyCompilationProblem(message)
-                        );                
+                problems.add(new GroovyCompilationProblem(message));                
             }
-        } finally {
-            problemHandler.onStop();
         }
         
+        return new CompilationResult(problems);
     }
 }

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java?rev=290094&r1=290093&r2=290094&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java
Mon Sep 19 01:46:24 2005
@@ -20,17 +20,18 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
-
+import org.apache.commons.jci.compilers.CompilationResult;
 import org.apache.commons.jci.compilers.JavaCompiler;
 import org.apache.commons.jci.problems.CompilationProblemHandler;
 import org.apache.commons.jci.readers.ResourceReader;
 import org.apache.commons.jci.stores.ResourceStore;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.codehaus.janino.ClassLoaderIClassLoader;
 import org.codehaus.janino.CompileException;
 import org.codehaus.janino.DebuggingInformation;
@@ -43,14 +44,14 @@
 import org.codehaus.janino.Scanner;
 import org.codehaus.janino.UnitCompiler;
 import org.codehaus.janino.WarningHandler;
-import org.codehaus.janino.UnitCompiler.ErrorHandler;
 import org.codehaus.janino.Scanner.LocatedException;
+import org.codehaus.janino.UnitCompiler.ErrorHandler;
 import org.codehaus.janino.util.ClassFile;
 
 /**
  * @author art@gramlich-net.com
  */
-public class JaninoJavaCompiler implements JavaCompiler {
+public final class JaninoJavaCompiler implements JavaCompiler {
 
     private final static Log log = LogFactory.getLog(JaninoJavaCompiler.class);
 
@@ -58,19 +59,20 @@
 
         private final Map types = new HashMap();
         private final ResourceReader resourceReader;
-        private final CompilationProblemHandler problemHandler;
         private final Map classes;
+        private final Collection problems = new ArrayList();
 
-        private CompilingIClassLoader(final ResourceReader pResourceReader,
-                                      final CompilationProblemHandler pProblemHandler,
-                                      final Map pClasses) {
+        private CompilingIClassLoader(final ResourceReader pResourceReader, final Map pClasses)
{
             super(new ClassLoaderIClassLoader());
             resourceReader = pResourceReader;
-            problemHandler = pProblemHandler;
             classes = pClasses;
             super.postConstruct();
         }
 
+        protected Collection getProblems() {
+            return problems;
+        }
+        
         protected IClass findIClass(final String pType) {
             final String className = Descriptor.toClassName(pType);
             if (types.containsKey(pType)) {
@@ -88,9 +90,16 @@
                 scanner = new Scanner(fileNameForClass, reader);
                 final Java.CompilationUnit unit = new Parser(scanner).parseCompilationUnit();
                 final UnitCompiler uc = new UnitCompiler(unit, this);
-                CompilationProblemHandlerAdapter adapter = new CompilationProblemHandlerAdapter(problemHandler);
-                uc.setCompileErrorHandler(adapter);
-                uc.setWarningHandler(adapter);
+                uc.setCompileErrorHandler(new ErrorHandler() {
+                    public void handleError(final String pMessage, final Location pOptionalLocation)
throws CompileException {
+                        problems.add(new JaninoCompilationProblem(pOptionalLocation, pMessage,
true));
+                    }
+                });
+                uc.setWarningHandler(new WarningHandler() {
+                    public void handleWarning(final String pHandle, final String pMessage,
final Location pOptionalLocation) {
+                        problems.add(new JaninoCompilationProblem(pOptionalLocation, pMessage,
false));
+                    }
+                });
                 log.debug("compile " + className);
                 final ClassFile[] classFiles = uc.compileUnit(DebuggingInformation.ALL);
                 for (int i = 0; i < classFiles.length; i++) {
@@ -103,9 +112,9 @@
                 }
                 return ic;
             } catch (final LocatedException e) {
-                problemHandler.handle(new JaninoCompilationProblem(e));
+                problems.add(new JaninoCompilationProblem(e));
             } catch (final IOException e) {
-                problemHandler.handle(new JaninoCompilationProblem(fileNameForClass, "IO:"
+ e.getMessage(), true));
+                problems.add(new JaninoCompilationProblem(fileNameForClass, "IO:" + e.getMessage(),
true));
             } finally {
                 if (scanner != null) {
                     try {
@@ -119,11 +128,13 @@
         }
     }
 
-    public void compile(final String[] pClasses, final ResourceReader pResourceReader,
-                        final ResourceStore pStore, final CompilationProblemHandler pProblemHandler)
{
+    public CompilationResult compile(
+            final String[] pClasses,
+            final ResourceReader pResourceReader,
+            final ResourceStore pStore
+            ) {
         final Map classFilesByName = new HashMap();
-        final IClassLoader icl = new CompilingIClassLoader(pResourceReader, pProblemHandler,
classFilesByName);
-        pProblemHandler.onStart();
+        final CompilingIClassLoader icl = new CompilingIClassLoader(pResourceReader, classFilesByName);
         for (int i = 0; i < pClasses.length; i++) {
             log.debug("compiling " + pClasses[i]);
             icl.loadIClass(Descriptor.fromClassName(pClasses[i]));
@@ -133,7 +144,8 @@
             final Map.Entry entry = (Map.Entry)i.next();
             pStore.write((String)entry.getKey(), (byte[])entry.getValue());
         }
-        pProblemHandler.onStop();
+        
+        return new CompilationResult(icl.getProblems());
     }
 
     private static final class CompilationProblemHandlerAdapter implements ErrorHandler,
WarningHandler {

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/CompilingListener.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/CompilingListener.java?rev=290094&r1=290093&r2=290094&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/CompilingListener.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/CompilingListener.java
Mon Sep 19 01:46:24 2005
@@ -20,10 +20,10 @@
 import java.util.Collection;
 import java.util.Iterator;
 import org.apache.commons.jci.ReloadingClassLoader;
+import org.apache.commons.jci.compilers.CompilationResult;
 import org.apache.commons.jci.compilers.JavaCompiler;
 import org.apache.commons.jci.monitor.FilesystemAlterationListener;
 import org.apache.commons.jci.problems.CompilationProblem;
-import org.apache.commons.jci.problems.DefaultCompilationProblemHandler;
 import org.apache.commons.jci.readers.ResourceReader;
 import org.apache.commons.jci.stores.TransactionalResourceStore;
 import org.apache.commons.logging.Log;
@@ -41,7 +41,7 @@
     private final JavaCompiler compiler;
     private final ResourceReader reader;
     private final TransactionalResourceStore transactionalStore;
-    private final DefaultCompilationProblemHandler problemHandler = new DefaultCompilationProblemHandler();
+    private CompilationResult lastResult;
     
     public CompilingListener(
             final ResourceReader pReader,
@@ -51,10 +51,11 @@
         compiler = pCompiler;
         reader = pReader;
         transactionalStore = pTransactionalStore;
+        lastResult = null;
     }
     
-    public DefaultCompilationProblemHandler getCompilationProblemHandler() {
-        return problemHandler;
+    public synchronized CompilationResult getCompilationResult() {
+        return lastResult;
     }
     
     public void onStart(final File pRepository) {
@@ -80,6 +81,7 @@
         }
                         
         final Collection compileables = new ArrayList();
+        // FIXME: only compile ".java" resources to support resource reloading
         compileables.addAll(created);
         compileables.addAll(changed);
 
@@ -91,19 +93,22 @@
             for (Iterator it = compileables.iterator(); it.hasNext();) {
                 final File file = (File) it.next();
                 clazzes[i] = ReloadingClassLoader.clazzName(pRepository, file);
-                //log.debug(clazzes[i]);
                 i++;
             }
             
-            compiler.compile(
+            final CompilationResult result =
+                compiler.compile(
                     clazzes,
                     reader,
-                    transactionalStore,
-                    problemHandler
+                    transactionalStore
                     );
             
-            final CompilationProblem[] errors = problemHandler.getErrors();
-            final CompilationProblem[] warnings = problemHandler.getWarnings();
+            synchronized(this) {
+                lastResult = result;
+            }
+            
+            final CompilationProblem[] errors = result.getErrors();
+            final CompilationProblem[] warnings = result.getWarnings();
             
             log.debug(
                     errors.length + " errors, " +
@@ -116,8 +121,7 @@
                 }
             }
             
-            reload = true;                    
-
+            reload = true;
         }
 
         transactionalStore.onStop();
@@ -128,16 +132,19 @@
     }
 
     public void onCreateFile( final File file ) {
+        // FIXME: to support resource reloading do the suffix filtering in onStop
         if (file.getName().endsWith(".java")) {
             created.add(file);
         }
     }
     public void onChangeFile( final File file ) {                
+        // FIXME: to support resource reloading do the suffix filtering in onStop
         if (file.getName().endsWith(".java")) {
             changed.add(file);
         }
     }
     public void onDeleteFile( final File file ) {
+        // FIXME: to support resource reloading do the suffix filtering in onStop
         if (file.getName().endsWith(".java")) {
             deleted.add(file);
         }

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/ReloadingListener.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/ReloadingListener.java?rev=290094&r1=290093&r2=290094&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/ReloadingListener.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/ReloadingListener.java
Mon Sep 19 01:46:24 2005
@@ -91,16 +91,19 @@
     }
 
     public void onCreateFile( final File file ) {
+        // FIXME: for resource reloading remove the filtering
         if (file.getName().endsWith(".class")) {
             created.add(file);
         }
     }
     public void onChangeFile( final File file ) {                
+        // FIXME: for resource reloading remove the filtering
         if (file.getName().endsWith(".class")) {
             changed.add(file);
         }
     }
     public void onDeleteFile( final File file ) {
+        // FIXME: for resource reloading remove the filtering
         if (file.getName().endsWith(".class")) {
             deleted.add(file);
         }

Added: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/Transactional.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/Transactional.java?rev=290094&view=auto
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/Transactional.java
(added)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/Transactional.java
Mon Sep 19 01:46:24 2005
@@ -0,0 +1,8 @@
+package org.apache.commons.jci.stores;
+
+public interface Transactional {
+
+    void onStart();
+
+    void onStop();
+}

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/TransactionalResourceStore.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/TransactionalResourceStore.java?rev=290094&r1=290093&r2=290094&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/TransactionalResourceStore.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/TransactionalResourceStore.java
Mon Sep 19 01:46:24 2005
@@ -20,7 +20,7 @@
  * @author tcurdt
  *
  */
-public abstract class TransactionalResourceStore implements ResourceStore {
+public class TransactionalResourceStore implements ResourceStore, Transactional {
 
     private final ResourceStore store;
     
@@ -28,18 +28,20 @@
         store = pStore;
     }
     
-    public abstract void onStart();
+    public void onStart() {
+    }
     
-    public abstract void onStop();
+    public void onStop() {
+    }
     
-    public byte[] read(String resourceName) {
-        return store.read(resourceName);
+    public byte[] read(final String pResourceName) {
+        return store.read(pResourceName);
     }
-    public void remove(String resourceName) {
-        store.remove(resourceName);
+    public void remove(final String pResourceName) {
+        store.remove(pResourceName);
     }
-    public void write(String resourceName, byte[] resourceData) {
-        store.write(resourceName, resourceData);
+    public void write(final String pResourceName, final byte[] pResourceData) {
+        store.write(pResourceName, pResourceData);
     }
     
     public String toString() {

Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/CompilerUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/CompilerUtils.java?rev=290094&r1=290093&r2=290094&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/CompilerUtils.java (original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/CompilerUtils.java Mon
Sep 19 01:46:24 2005
@@ -2,7 +2,6 @@
 
 import org.apache.commons.jci.compilers.JavaCompiler;
 import org.apache.commons.jci.compilers.eclipse.EclipseJavaCompiler;
-import org.apache.commons.jci.problems.LogCompilationProblemHandler;
 import org.apache.commons.jci.readers.ResourceReader;
 import org.apache.commons.jci.stores.MemoryResourceStore;
 import org.apache.commons.jci.stores.ResourceStore;
@@ -42,8 +41,7 @@
                         return false;
                     }
                 },
-                store,
-                new LogCompilationProblemHandler()
+                store
                 );
         return store.read(pClazzes[0]);
     }
@@ -61,8 +59,7 @@
                         return false;
                     }
                 },
-                store,
-                new LogCompilationProblemHandler()
+                store
                 );
         return store.read(pClazz);
     }

Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java?rev=290094&r1=290093&r2=290094&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java
Mon Sep 19 01:46:24 2005
@@ -2,7 +2,6 @@
 
 import java.io.File;
 import org.apache.commons.jci.AbstractTestCase;
-import org.apache.commons.jci.problems.DefaultCompilationProblemHandler;
 import org.apache.commons.jci.readers.FileResourceReader;
 import org.apache.commons.jci.stores.FileResourceStore;
 
@@ -10,7 +9,7 @@
 public abstract class AbstractCompilerTestCase extends AbstractTestCase {
 
         
-    protected DefaultCompilationProblemHandler compileWith( final JavaCompiler pCompiler,
final String pSource ) throws Exception {
+    protected CompilationResult compileWith( final JavaCompiler pCompiler, final String pSource
) throws Exception {
         final File srcDir = new File(directory, "src");
         final File dstDir = new File(directory, "dst");
         
@@ -20,17 +19,12 @@
         final FileResourceReader src = new FileResourceReader(srcDir);
         final FileResourceStore dst = new FileResourceStore(dstDir);
         
-        final DefaultCompilationProblemHandler handler = new DefaultCompilationProblemHandler();
-
         writeFile("src/jci/Simple.java", pSource);
         
-        pCompiler.compile(
+        return pCompiler.compile(
                 new String[] { "jci.Simple"},
                 src,
-                dst,
-                handler
+                dst
                 );
-        
-        return handler;
     }
 }

Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompilerTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompilerTestCase.java?rev=290094&r1=290093&r2=290094&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompilerTestCase.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompilerTestCase.java
Mon Sep 19 01:46:24 2005
@@ -1,30 +1,30 @@
 package org.apache.commons.jci.compilers.eclipse;
 
 import org.apache.commons.jci.compilers.AbstractCompilerTestCase;
+import org.apache.commons.jci.compilers.CompilationResult;
 import org.apache.commons.jci.compilers.JavaCompiler;
 import org.apache.commons.jci.compilers.JavaSources;
-import org.apache.commons.jci.problems.DefaultCompilationProblemHandler;
 
 
 public final class EclipseJavaCompilerTestCase extends AbstractCompilerTestCase {
     public void testSimpleCompilation() throws Exception {
         final JavaCompiler compiler = new EclipseJavaCompiler();
-        final DefaultCompilationProblemHandler handler = compileWith(compiler, JavaSources.simple);
-        assertTrue(handler.getWarnings().length == 0);
-        assertTrue(handler.getErrors().length == 0);
+        final CompilationResult result = compileWith(compiler, JavaSources.simple);
+        assertTrue(result.getWarnings().length == 0);
+        assertTrue(result.getErrors().length == 0);
     }
     
     public void testCompilationError() throws Exception {
         final JavaCompiler compiler = new EclipseJavaCompiler();
-        final DefaultCompilationProblemHandler handler = compileWith(compiler, JavaSources.error);
-        assertTrue(handler.getWarnings().length == 0);
-        assertTrue(handler.getErrors().length == 1);
+        final CompilationResult result = compileWith(compiler, JavaSources.error);
+        assertTrue(result.getWarnings().length == 0);
+        assertTrue(result.getErrors().length == 1);
     }
 
     public void testCompilationWarning() throws Exception {
         final JavaCompiler compiler = new EclipseJavaCompiler();
-        final DefaultCompilationProblemHandler handler = compileWith(compiler, JavaSources.warning);
-        assertTrue(handler.getWarnings().length == 1);
-        assertTrue(handler.getErrors().length == 0);
+        final CompilationResult result = compileWith(compiler, JavaSources.warning);
+        assertTrue(result.getWarnings().length == 1);
+        assertTrue(result.getErrors().length == 0);
    }    
 }

Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/groovy/GroovyJavaCompilerTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/groovy/GroovyJavaCompilerTestCase.java?rev=290094&r1=290093&r2=290094&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/groovy/GroovyJavaCompilerTestCase.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/groovy/GroovyJavaCompilerTestCase.java
Mon Sep 19 01:46:24 2005
@@ -1,29 +1,29 @@
 package org.apache.commons.jci.compilers.groovy;
 
 import org.apache.commons.jci.compilers.AbstractCompilerTestCase;
+import org.apache.commons.jci.compilers.CompilationResult;
 import org.apache.commons.jci.compilers.GroovySources;
 import org.apache.commons.jci.compilers.JavaCompiler;
-import org.apache.commons.jci.problems.DefaultCompilationProblemHandler;
 
 
 public final class GroovyJavaCompilerTestCase extends AbstractCompilerTestCase {
     public void testSimpleCompilation() throws Exception {
         final JavaCompiler compiler = new GroovyJavaCompiler();
-        final DefaultCompilationProblemHandler handler = compileWith(compiler, GroovySources.simple);
-        assertTrue(handler.getWarnings().length == 0);
-        assertTrue(handler.getErrors().length == 0);
+        final CompilationResult result = compileWith(compiler, GroovySources.simple);
+        assertTrue(result.getWarnings().length == 0);
+        assertTrue(result.getErrors().length == 0);
     }
     
     public void testCompilationError() throws Exception {
         final JavaCompiler compiler = new GroovyJavaCompiler();
-        final DefaultCompilationProblemHandler handler = compileWith(compiler, GroovySources.error);
-        assertTrue(handler.getWarnings().length == 0);
-        assertTrue(handler.getErrors().length == 1);
+        final CompilationResult result = compileWith(compiler, GroovySources.error);
+        assertTrue(result.getWarnings().length == 0);
+        assertTrue(result.getErrors().length == 1);
     }
 
     public void testCompilationWarning() throws Exception {
         final JavaCompiler compiler = new GroovyJavaCompiler();
-        final DefaultCompilationProblemHandler handler = compileWith(compiler, GroovySources.warning);
-        assertTrue(handler.getWarnings().length == 1);
-        assertTrue(handler.getErrors().length == 0);
+        final CompilationResult result = compileWith(compiler, GroovySources.warning);
+        assertTrue(result.getWarnings().length == 1);
+        assertTrue(result.getErrors().length == 0);
     }}

Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/janino/JaninoJavaCompilerTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/janino/JaninoJavaCompilerTestCase.java?rev=290094&r1=290093&r2=290094&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/janino/JaninoJavaCompilerTestCase.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/janino/JaninoJavaCompilerTestCase.java
Mon Sep 19 01:46:24 2005
@@ -1,30 +1,30 @@
 package org.apache.commons.jci.compilers.janino;
 
 import org.apache.commons.jci.compilers.AbstractCompilerTestCase;
+import org.apache.commons.jci.compilers.CompilationResult;
 import org.apache.commons.jci.compilers.JavaCompiler;
 import org.apache.commons.jci.compilers.JavaSources;
-import org.apache.commons.jci.problems.DefaultCompilationProblemHandler;
 
 
 public final class JaninoJavaCompilerTestCase extends AbstractCompilerTestCase {
     public void testSimpleCompilation() throws Exception {
         final JavaCompiler compiler = new JaninoJavaCompiler();
-        final DefaultCompilationProblemHandler handler = compileWith(compiler, JavaSources.simple);
-        assertTrue(handler.getWarnings().length == 0);
-        assertTrue(handler.getErrors().length == 0);
+        final CompilationResult result = compileWith(compiler, JavaSources.simple);
+        assertTrue(result.getWarnings().length == 0);
+        assertTrue(result.getErrors().length == 0);
     }
     
     public void testCompilationError() throws Exception {
         final JavaCompiler compiler = new JaninoJavaCompiler();
-        final DefaultCompilationProblemHandler handler = compileWith(compiler, JavaSources.error);
-        assertTrue(handler.getWarnings().length == 0);
-        assertTrue(handler.getErrors().length == 1);
+        final CompilationResult result = compileWith(compiler, JavaSources.error);
+        assertTrue(result.getWarnings().length == 0);
+        assertTrue(result.getErrors().length == 1);
     }
 
     public void testCompilationWarning() throws Exception {
         final JavaCompiler compiler = new JaninoJavaCompiler();
-        final DefaultCompilationProblemHandler handler = compileWith(compiler, JavaSources.warning);
-        assertTrue(handler.getWarnings().length == 1);
-        assertTrue(handler.getErrors().length == 0);
+        final CompilationResult result = compileWith(compiler, JavaSources.warning);
+        assertTrue(result.getWarnings().length == 1);
+        assertTrue(result.getErrors().length == 0);
     }
 }

Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/problems/CompilationProblemTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/problems/CompilationProblemTestCase.java?rev=290094&r1=290093&r2=290094&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/problems/CompilationProblemTestCase.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/problems/CompilationProblemTestCase.java
Mon Sep 19 01:46:24 2005
@@ -80,19 +80,6 @@
         assertFalse("wrong error level", problem.isError());
     }
 
-    public void testErrorHandling() {
-        final DefaultCompilationProblemHandler handler = new DefaultCompilationProblemHandler();
-        final CompilationProblem error = createJaninoCompilationProblem(true);
-        handler.handle(error);
-        assertEquals("wrong number of errors", 1, handler.getErrors().length);
-        assertEquals("wrong number of warnings", 0, handler.getWarnings().length);
-
-        final CompilationProblem warning = createJaninoCompilationProblem(false);
-        handler.handle(warning);
-        assertEquals("wrong number of errors", 1, handler.getErrors().length);
-        assertEquals("wrong number of warnings", 1, handler.getWarnings().length);
-    }
-
     private static JaninoCompilationProblem createJaninoCompilationProblem(final boolean
pError) {
         Location location = new Location(FILENAME, LINE, COLUMN);
         return new JaninoCompilationProblem(location, MESSAGE, pError);



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message