Remove trailing whitepsace.
diff --git a/compilers/eclipse/src/main/java/org/apache/commons/jci2/compilers/EclipseCompilationProblem.java b/compilers/eclipse/src/main/java/org/apache/commons/jci2/compilers/EclipseCompilationProblem.java
index 6650faa..ec9b56f 100755
--- a/compilers/eclipse/src/main/java/org/apache/commons/jci2/compilers/EclipseCompilationProblem.java
+++ b/compilers/eclipse/src/main/java/org/apache/commons/jci2/compilers/EclipseCompilationProblem.java
@@ -22,7 +22,7 @@
/**
* Wrapping an Eclipse compiler problem
- *
+ *
* @author tcurdt
*/
public final class EclipseCompilationProblem implements CompilationProblem {
diff --git a/compilers/eclipse/src/main/java/org/apache/commons/jci2/compilers/EclipseJavaCompiler.java b/compilers/eclipse/src/main/java/org/apache/commons/jci2/compilers/EclipseJavaCompiler.java
index f8fe7a7..fab2b3c 100644
--- a/compilers/eclipse/src/main/java/org/apache/commons/jci2/compilers/EclipseJavaCompiler.java
+++ b/compilers/eclipse/src/main/java/org/apache/commons/jci2/compilers/EclipseJavaCompiler.java
@@ -309,7 +309,7 @@
is.close();
} catch (final IOException ie) {
log.error("could not close input stream", ie);
- }
+ }
return false;
}
diff --git a/compilers/eclipse/src/main/java/org/apache/commons/jci2/compilers/EclipseJavaCompilerSettings.java b/compilers/eclipse/src/main/java/org/apache/commons/jci2/compilers/EclipseJavaCompilerSettings.java
index f240a58..56d3435 100644
--- a/compilers/eclipse/src/main/java/org/apache/commons/jci2/compilers/EclipseJavaCompilerSettings.java
+++ b/compilers/eclipse/src/main/java/org/apache/commons/jci2/compilers/EclipseJavaCompilerSettings.java
@@ -24,7 +24,7 @@
/**
* Native Eclipse compiler settings
- *
+ *
* @author tcurdt
*/
public final class EclipseJavaCompilerSettings extends JavaCompilerSettings {
@@ -37,15 +37,15 @@
defaultEclipseSettings.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE);
defaultEclipseSettings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
}
-
+
public EclipseJavaCompilerSettings( final JavaCompilerSettings pSettings ) {
super(pSettings);
-
+
if (pSettings instanceof EclipseJavaCompilerSettings) {
defaultEclipseSettings.putAll(((EclipseJavaCompilerSettings)pSettings).toNativeSettings());
}
}
-
+
public EclipseJavaCompilerSettings( final Map<String, String> pMap ) {
defaultEclipseSettings.putAll(pMap);
}
@@ -61,17 +61,17 @@
put("1.6", CompilerOptions.VERSION_1_6);
put("1.7", CompilerOptions.VERSION_1_7);
}};
-
+
private String toNativeVersion( final String pVersion ) {
final String nativeVersion = nativeVersions.get(pVersion);
-
+
if (nativeVersion == null) {
throw new RuntimeException("unknown version " + pVersion);
}
-
+
return nativeVersion;
}
-
+
Map<String, String> toNativeSettings() {
final Map<String, String> map = new HashMap<String, String>(defaultEclipseSettings);
@@ -83,7 +83,7 @@
return map;
}
-
+
@Override
public String toString() {
return toNativeSettings().toString();
diff --git a/compilers/groovy/src/main/java/org/apache/commons/jci2/compilers/GroovyCompilationProblem.java b/compilers/groovy/src/main/java/org/apache/commons/jci2/compilers/GroovyCompilationProblem.java
index d871b80..6e1d5fe 100755
--- a/compilers/groovy/src/main/java/org/apache/commons/jci2/compilers/GroovyCompilationProblem.java
+++ b/compilers/groovy/src/main/java/org/apache/commons/jci2/compilers/GroovyCompilationProblem.java
@@ -26,7 +26,7 @@
/**
* Groovy version of a CompilationProblem
- *
+ *
* @author tcurdt
*/
public final class GroovyCompilationProblem implements CompilationProblem {
diff --git a/compilers/groovy/src/main/java/org/apache/commons/jci2/compilers/GroovyJavaCompiler.java b/compilers/groovy/src/main/java/org/apache/commons/jci2/compilers/GroovyJavaCompiler.java
index 7450791..e6d509f 100644
--- a/compilers/groovy/src/main/java/org/apache/commons/jci2/compilers/GroovyJavaCompiler.java
+++ b/compilers/groovy/src/main/java/org/apache/commons/jci2/compilers/GroovyJavaCompiler.java
@@ -42,18 +42,18 @@
/**
* Groovy implementation of the JavaCompiler interface
- *
+ *
* @author tcurdt
*/
public final class GroovyJavaCompiler extends AbstractJavaCompiler {
private final Log log = LogFactory.getLog(GroovyJavaCompiler.class);
private final GroovyJavaCompilerSettings defaultSettings;
-
+
public GroovyJavaCompiler() {
defaultSettings = new GroovyJavaCompilerSettings(new CompilerConfiguration());
}
-
+
public CompilationResult compile(
final String[] pResourceNames,
final ResourceReader pReader,
@@ -78,13 +78,13 @@
);
unit.addSource(source[i]);
}
-
+
final Collection<CompilationProblem> problems = new ArrayList<CompilationProblem>();
try {
log.debug("compiling");
unit.compile(Phases.CLASS_GENERATION);
-
+
@SuppressWarnings("unchecked") // Groovy library is not yet generic
final List<GroovyClass> classes = unit.getClasses();
for (final GroovyClass clazz : classes) {
@@ -97,7 +97,7 @@
final Collection<WarningMessage> warnings = col.getWarnings();
if (warnings != null) {
for (final WarningMessage warning : warnings) {
- final CompilationProblem problem = new GroovyCompilationProblem(warning);
+ final CompilationProblem problem = new GroovyCompilationProblem(warning);
if (problemHandler != null) {
problemHandler.handle(problem);
}
@@ -109,7 +109,7 @@
final Collection<Message> errors = col.getErrors();
if (errors != null) {
for (final Message message : errors) {
- final CompilationProblem problem = new GroovyCompilationProblem(message);
+ final CompilationProblem problem = new GroovyCompilationProblem(message);
if (problemHandler != null) {
problemHandler.handle(problem);
}
diff --git a/compilers/groovy/src/main/java/org/apache/commons/jci2/compilers/GroovyJavaCompilerSettings.java b/compilers/groovy/src/main/java/org/apache/commons/jci2/compilers/GroovyJavaCompilerSettings.java
index 04ad9a8..efa3ba6 100644
--- a/compilers/groovy/src/main/java/org/apache/commons/jci2/compilers/GroovyJavaCompilerSettings.java
+++ b/compilers/groovy/src/main/java/org/apache/commons/jci2/compilers/GroovyJavaCompilerSettings.java
@@ -21,7 +21,7 @@
/**
* Native configuration for the Groovy compiler
- *
+ *
* @author tcurdt
*/
public final class GroovyJavaCompilerSettings extends JavaCompilerSettings {
diff --git a/compilers/groovy/src/test/java/org/apache/commons/jci2/compilers/GroovyJavaCompilerTestCase.java b/compilers/groovy/src/test/java/org/apache/commons/jci2/compilers/GroovyJavaCompilerTestCase.java
index 9d1e60a..8cbe9d7 100644
--- a/compilers/groovy/src/test/java/org/apache/commons/jci2/compilers/GroovyJavaCompilerTestCase.java
+++ b/compilers/groovy/src/test/java/org/apache/commons/jci2/compilers/GroovyJavaCompilerTestCase.java
@@ -18,7 +18,7 @@
package org.apache.commons.jci2.compilers;
/**
- *
+ *
* @author tcurdt
*/
public final class GroovyJavaCompilerTestCase extends AbstractCompilerTestCase {
diff --git a/compilers/janino/src/main/java/org/apache/commons/jci2/compilers/JaninoCompilationProblem.java b/compilers/janino/src/main/java/org/apache/commons/jci2/compilers/JaninoCompilationProblem.java
index 5756036..f934606 100755
--- a/compilers/janino/src/main/java/org/apache/commons/jci2/compilers/JaninoCompilationProblem.java
+++ b/compilers/janino/src/main/java/org/apache/commons/jci2/compilers/JaninoCompilationProblem.java
@@ -23,7 +23,7 @@
/**
* Janino version of a CompilationProblem
- *
+ *
* @author tcurdt
*/
public final class JaninoCompilationProblem implements CompilationProblem {
diff --git a/compilers/janino/src/main/java/org/apache/commons/jci2/compilers/JaninoJavaCompiler.java b/compilers/janino/src/main/java/org/apache/commons/jci2/compilers/JaninoJavaCompiler.java
index 9a5875c..660b238 100644
--- a/compilers/janino/src/main/java/org/apache/commons/jci2/compilers/JaninoJavaCompiler.java
+++ b/compilers/janino/src/main/java/org/apache/commons/jci2/compilers/JaninoJavaCompiler.java
@@ -55,21 +55,21 @@
public JaninoJavaCompiler() {
this(new JaninoJavaCompilerSettings());
}
-
+
public JaninoJavaCompiler( final JaninoJavaCompilerSettings pSettings ) {
defaultSettings = pSettings;
}
-
+
private final static class JciResource implements Resource {
private final String name;
private final byte[] bytes;
-
+
public JciResource( final String pName, final byte[] pBytes ) {
name = pName;
bytes = pBytes;
}
-
+
public String getFileName() {
return name;
}
@@ -98,15 +98,15 @@
super.close();
final byte[] bytes = toByteArray();
-
+
store.write(name, bytes);
}
}
-
+
public CompilationResult compile( final String[] pSourceNames, final ResourceReader pResourceReader, final ResourceStore pStore, final ClassLoader pClassLoader, final JavaCompilerSettings pSettings ) {
final Collection<CompilationProblem> problems = new ArrayList<CompilationProblem>();
-
+
final StringPattern[] pattern = StringPattern.PATTERNS_NONE;
final Compiler compiler = new Compiler(
@@ -114,32 +114,32 @@
@Override
public Resource findResource( final String pSourceName ) {
final byte[] bytes = pResourceReader.getBytes(pSourceName);
-
+
if (bytes == null) {
log.debug("failed to find source " + pSourceName);
return null;
}
-
+
log.debug("reading " + pSourceName + " (" + bytes.length + ")");
-
+
return new JciResource(pSourceName, bytes);
- }
+ }
},
new ClassLoaderIClassLoader(pClassLoader),
new ResourceFinder() {
@Override
public Resource findResource( final String pResourceName ) {
final byte[] bytes = pStore.read(pResourceName);
-
+
if (bytes == null) {
log.debug("failed to find " + pResourceName);
return null;
}
log.debug("reading " + pResourceName + " (" + bytes.length + ")");
-
+
return new JciResource(pResourceName, bytes);
- }
+ }
},
new ResourceCreator() {
public OutputStream createResource( final String pResourceName ) throws IOException {
@@ -151,7 +151,7 @@
pStore.remove(pResourceName);
return true;
- }
+ }
},
pSettings.getSourceEncoding(),
false,
@@ -165,11 +165,11 @@
problemHandler.handle(problem);
}
problems.add(problem);
- }
- })
+ }
+ })
);
-
-
+
+
compiler.setCompileErrorHandler(new ErrorHandler() {
public void handleError( final String pMessage, final Location pLocation ) throws CompileException {
final CompilationProblem problem = new JaninoCompilationProblem(pLocation.getFileName(), pLocation, pMessage, true);
@@ -179,7 +179,7 @@
problems.add(problem);
}
});
-
+
final Resource[] resources = new Resource[pSourceNames.length];
for (int i = 0; i < pSourceNames.length; i++) {
@@ -187,7 +187,7 @@
final byte[] source = pResourceReader.getBytes(pSourceNames[i]);
resources[i] = new JciResource(pSourceNames[i], source);
}
-
+
try {
compiler.compile(resources);
} catch ( final LocatedException e ) {
@@ -195,7 +195,7 @@
} catch ( final IOException e ) {
// low level problems reading or writing bytes
log.error("this error should have been cought before", e);
- }
+ }
final CompilationProblem[] result = new CompilationProblem[problems.size()];
problems.toArray(result);
return new CompilationResult(result);
@@ -204,5 +204,5 @@
public JavaCompilerSettings createDefaultSettings() {
return new JaninoJavaCompilerSettings(defaultSettings);
}
-
+
}
diff --git a/compilers/janino/src/main/java/org/apache/commons/jci2/compilers/JaninoJavaCompilerSettings.java b/compilers/janino/src/main/java/org/apache/commons/jci2/compilers/JaninoJavaCompilerSettings.java
index e11dcd2..1e2ff89 100644
--- a/compilers/janino/src/main/java/org/apache/commons/jci2/compilers/JaninoJavaCompilerSettings.java
+++ b/compilers/janino/src/main/java/org/apache/commons/jci2/compilers/JaninoJavaCompilerSettings.java
@@ -21,11 +21,11 @@
// TODO: implement the native janino compiler settings
public JaninoJavaCompilerSettings() {
-
+
}
public JaninoJavaCompilerSettings( final JaninoJavaCompilerSettings pSettings ) {
- super(pSettings);
+ super(pSettings);
}
}
diff --git a/compilers/janino/src/test/java/org/apache/commons/jci2/compilers/JaninoJavaCompilerTestCase.java b/compilers/janino/src/test/java/org/apache/commons/jci2/compilers/JaninoJavaCompilerTestCase.java
index 3b0e4b8..d498b61 100644
--- a/compilers/janino/src/test/java/org/apache/commons/jci2/compilers/JaninoJavaCompilerTestCase.java
+++ b/compilers/janino/src/test/java/org/apache/commons/jci2/compilers/JaninoJavaCompilerTestCase.java
@@ -18,7 +18,7 @@
package org.apache.commons.jci2.compilers;
/**
- *
+ *
* @author tcurdt
*/
public final class JaninoJavaCompilerTestCase extends AbstractCompilerTestCase {
diff --git a/compilers/jsr199/src/main/java/org/apache/commons/jci2/compilers/Jsr199JavaCompiler.java b/compilers/jsr199/src/main/java/org/apache/commons/jci2/compilers/Jsr199JavaCompiler.java
index 25e7144..afdc6ad 100644
--- a/compilers/jsr199/src/main/java/org/apache/commons/jci2/compilers/Jsr199JavaCompiler.java
+++ b/compilers/jsr199/src/main/java/org/apache/commons/jci2/compilers/Jsr199JavaCompiler.java
@@ -48,7 +48,7 @@
public final class Jsr199JavaCompiler extends AbstractJavaCompiler {
private final Log log = LogFactory.getLog(Jsr199JavaCompiler.class);
-
+
private class CompilationUnit extends SimpleJavaFileObject {
final private ResourceReader reader;
final private String name;
@@ -170,7 +170,7 @@
return false;
}
public String inferBinaryName(final JavaFileManager.Location location, final JavaFileObject file) {
- final String s = file.getName().replaceFirst(".java", ".class");
+ final String s = file.getName().replaceFirst(".java", ".class");
log.debug("inferBinaryName " + file.getName() + " -> " + s);
return s;
}
diff --git a/compilers/rhino/src/main/java/org/apache/commons/jci2/compilers/RhinoCompilationProblem.java b/compilers/rhino/src/main/java/org/apache/commons/jci2/compilers/RhinoCompilationProblem.java
index 2fa79bf..a56886e 100755
--- a/compilers/rhino/src/main/java/org/apache/commons/jci2/compilers/RhinoCompilationProblem.java
+++ b/compilers/rhino/src/main/java/org/apache/commons/jci2/compilers/RhinoCompilationProblem.java
@@ -20,7 +20,7 @@
import org.apache.commons.jci2.problems.CompilationProblem;
/**
- *
+ *
* @author tcurdt
*/
public final class RhinoCompilationProblem implements CompilationProblem {
diff --git a/compilers/rhino/src/main/java/org/apache/commons/jci2/compilers/RhinoJavaCompiler.java b/compilers/rhino/src/main/java/org/apache/commons/jci2/compilers/RhinoJavaCompiler.java
index 7b477dd..8b71cdf 100644
--- a/compilers/rhino/src/main/java/org/apache/commons/jci2/compilers/RhinoJavaCompiler.java
+++ b/compilers/rhino/src/main/java/org/apache/commons/jci2/compilers/RhinoJavaCompiler.java
@@ -52,12 +52,12 @@
private final Log log = LogFactory.getLog(RhinoJavaCompiler.class);
private final JavaCompilerSettings defaultSettings;
-
-
+
+
public RhinoJavaCompiler() {
defaultSettings = new RhinoJavaCompilerSettings();
}
-
+
/**
* based on code from dev.helma.org
* http://dev.helma.org/source/file/helma/branches/rhinoloader/src/org/helma/javascript/RhinoLoader.java/?revision=95
@@ -69,29 +69,29 @@
private final ResourceStore store;
private final Collection<CompilationProblem> problems = new ArrayList<CompilationProblem>();
-
+
private final class ProblemCollector implements ErrorReporter {
public void error(final String pMessage, final String pFileName, final int pLine, final String pScript, final int pColumn) {
- final CompilationProblem problem = new RhinoCompilationProblem(pMessage, pFileName, pLine, pScript, pColumn, true);
+ final CompilationProblem problem = new RhinoCompilationProblem(pMessage, pFileName, pLine, pScript, pColumn, true);
if (problemHandler != null) {
problemHandler.handle(problem);
}
- problems.add(problem);
+ problems.add(problem);
}
public void warning(final String pMessage, final String pFileName, final int pLine, final String pScript, final int pColumn) {
- final CompilationProblem problem = new RhinoCompilationProblem(pMessage, pFileName, pLine, pScript, pColumn, false);
+ final CompilationProblem problem = new RhinoCompilationProblem(pMessage, pFileName, pLine, pScript, pColumn, false);
if (problemHandler != null) {
problemHandler.handle(problem);
}
- problems.add(problem);
+ problems.add(problem);
}
public EvaluatorException runtimeError(final String pMessage, final String pFileName, final int pLine, final String pScript, final int pColumn) {
@@ -251,15 +251,15 @@
}
}
-
-
+
+
public CompilationResult compile( final String[] pResourcePaths, final ResourceReader pReader, final ResourceStore pStore, final ClassLoader pClassLoader, final JavaCompilerSettings pSettings ) {
final RhinoCompilingClassLoader cl = new RhinoCompilingClassLoader(pReader, pStore, pClassLoader);
for (final String pResourcePath : pResourcePaths) {
log.debug("compiling " + pResourcePath);
-
+
final String clazzName = ConversionUtils.convertResourceToClassName(pResourcePath);
try {
cl.loadClass(clazzName);
diff --git a/compilers/rhino/src/test/java/org/apache/commons/jci2/compilers/RhinoJavaCompilerTestCase.java b/compilers/rhino/src/test/java/org/apache/commons/jci2/compilers/RhinoJavaCompilerTestCase.java
index 2ade7a3..fea82eb 100644
--- a/compilers/rhino/src/test/java/org/apache/commons/jci2/compilers/RhinoJavaCompilerTestCase.java
+++ b/compilers/rhino/src/test/java/org/apache/commons/jci2/compilers/RhinoJavaCompilerTestCase.java
@@ -24,7 +24,7 @@
import org.apache.commons.jci2.stores.MemoryResourceStore;
/**
- *
+ *
* @author tcurdt
*/
public final class RhinoJavaCompilerTestCase extends AbstractCompilerTestCase {
@@ -41,7 +41,7 @@
@Override
public void testSimpleCompile() throws Exception {
- final JavaCompiler compiler = createJavaCompiler();
+ final JavaCompiler compiler = createJavaCompiler();
final ResourceReader reader = new ResourceReader() {
final private Map<String, byte[]> sources = new HashMap<String, byte[]>() {
@@ -87,7 +87,7 @@
@Override
public void testUppercasePackageNameCompile() throws Exception {
- final JavaCompiler compiler = createJavaCompiler();
+ final JavaCompiler compiler = createJavaCompiler();
final ResourceReader reader = new ResourceReader() {
final private Map<String, byte[]> sources = new HashMap<String, byte[]>() {
diff --git a/core/src/main/java/org/apache/commons/jci2/ReloadingClassLoader.java b/core/src/main/java/org/apache/commons/jci2/ReloadingClassLoader.java
index 771c274..13646c1 100644
--- a/core/src/main/java/org/apache/commons/jci2/ReloadingClassLoader.java
+++ b/core/src/main/java/org/apache/commons/jci2/ReloadingClassLoader.java
@@ -31,32 +31,32 @@
* classes to be reloaded. That means that loadClass calls may
* return different results if the class was changed in the underlying
* ResourceStore.
- *
+ *
* @author tcurdt
*/
public class ReloadingClassLoader extends ClassLoader implements ReloadNotificationListener {
-
+
private final Log log = LogFactory.getLog(ReloadingClassLoader.class);
-
+
private final ClassLoader parent;
private ResourceStore[] stores = new ResourceStore[0];
private ClassLoader delegate;
- public ReloadingClassLoader( final ClassLoader pParent ) {
+ public ReloadingClassLoader( final ClassLoader pParent ) {
super(pParent);
- parent = pParent;
+ parent = pParent;
delegate = new ResourceStoreClassLoader(parent, stores);
}
public boolean addResourceStore( final ResourceStore pStore ) {
- try {
+ try {
final int n = stores.length;
final ResourceStore[] newStores = new ResourceStore[n + 1];
System.arraycopy(stores, 0, newStores, 1, n);
newStores[0] = pStore;
stores = newStores;
- delegate = new ResourceStoreClassLoader(parent, stores);
+ delegate = new ResourceStoreClassLoader(parent, stores);
return true;
} catch ( final RuntimeException e ) {
log.error("could not add resource store " + pStore);
@@ -68,19 +68,19 @@
final int n = stores.length;
int i = 0;
-
+
// FIXME: this should be improved with a Map
// find the pStore and index position with var i
while ( ( i < n ) && ( stores[i] != pStore ) ) {
i++;
}
-
+
// pStore was not found
if ( i == n ) {
return false;
}
-
- // if stores length > 1 then array copy old values, else create new empty store
+
+ // if stores length > 1 then array copy old values, else create new empty store
final ResourceStore[] newStores = new ResourceStore[n - 1];
if (i > 0) {
System.arraycopy(stores, 0, newStores, 0, i);
@@ -88,17 +88,17 @@
if (i < n - 1) {
System.arraycopy(stores, i + 1, newStores, i, (n - i - 1));
}
-
+
stores = newStores;
delegate = new ResourceStoreClassLoader(parent, stores);
return true;
}
-
+
public void handleNotification() {
log.debug("reloading");
delegate = new ResourceStoreClassLoader(parent, stores);
}
-
+
@Override
public void clearAssertionStatus() {
delegate.clearAssertionStatus();
diff --git a/core/src/main/java/org/apache/commons/jci2/compilers/AbstractJavaCompiler.java b/core/src/main/java/org/apache/commons/jci2/compilers/AbstractJavaCompiler.java
index b26c90d..3d8600b 100644
--- a/core/src/main/java/org/apache/commons/jci2/compilers/AbstractJavaCompiler.java
+++ b/core/src/main/java/org/apache/commons/jci2/compilers/AbstractJavaCompiler.java
@@ -25,7 +25,7 @@
/**
* Base class for compiler implementations. Provides just a few
* convenience methods.
- *
+ *
* @author tcurdt
*/
public abstract class AbstractJavaCompiler implements JavaCompiler {
diff --git a/core/src/main/java/org/apache/commons/jci2/compilers/CompilationResult.java b/core/src/main/java/org/apache/commons/jci2/compilers/CompilationResult.java
index b48a680..4695dfc 100644
--- a/core/src/main/java/org/apache/commons/jci2/compilers/CompilationResult.java
+++ b/core/src/main/java/org/apache/commons/jci2/compilers/CompilationResult.java
@@ -26,14 +26,14 @@
* It includes errors (which failed the compilation) or warnings
* (that can be ignored and do not affect the creation of the
* class files)
- *
+ *
* @author tcurdt
*/
public final class CompilationResult {
-
+
private final CompilationProblem[] errors;
private final CompilationProblem[] warnings;
-
+
public CompilationResult( final CompilationProblem[] pProblems ) {
final Collection<CompilationProblem> errorsColl = new ArrayList<CompilationProblem>();
final Collection<CompilationProblem> warningsColl = new ArrayList<CompilationProblem>();
@@ -45,14 +45,14 @@
warningsColl.add(problem);
}
}
-
+
errors = new CompilationProblem[errorsColl.size()];
errorsColl.toArray(errors);
warnings = new CompilationProblem[warningsColl.size()];
warningsColl.toArray(warnings);
}
-
+
public CompilationProblem[] getErrors() {
final CompilationProblem[] res = new CompilationProblem[errors.length];
System.arraycopy(errors, 0, res, 0, res.length);
diff --git a/core/src/main/java/org/apache/commons/jci2/compilers/JavaCompiler.java b/core/src/main/java/org/apache/commons/jci2/compilers/JavaCompiler.java
index ca9391d..56216a8 100644
--- a/core/src/main/java/org/apache/commons/jci2/compilers/JavaCompiler.java
+++ b/core/src/main/java/org/apache/commons/jci2/compilers/JavaCompiler.java
@@ -26,14 +26,14 @@
* The general compiler interface. All compilers implementing
* this interface should read the resources from the reader
* and store the java class files into the ResourceStore.
- *
+ *
* The actual compilation language does not matter. But the
* contract is that the result of the compilation will be a
* class file.
- *
+ *
* If possible the compiler should notify the optional
* CompilationProblemHandler as soon as a problem is found.
- *
+ *
* @author tcurdt
*/
public interface JavaCompiler {
@@ -43,7 +43,7 @@
* or warning as soon as this information is available from
* the compiler.
* Note: Some compilers might not support this feature.
- *
+ *
* @param pHandler
*/
void setCompilationProblemHandler( final CompilationProblemHandler pHandler );
@@ -52,7 +52,7 @@
* factory method to create the underlying default settings
*/
JavaCompilerSettings createDefaultSettings();
-
+
/**
* uses the default compiler settings and the current classloader
*/
@@ -67,14 +67,14 @@
* Compiles the java resources "some/path/to/MyJava.java"
* read through the ResourceReader and then stores the resulting
* classes in the ResourceStore under "some/path/to/MyJava.class".
- * Note: As these are resource path you always have to use "/"
- *
+ * Note: As these are resource path you always have to use "/"
+ *
* The result of the compilation run including detailed error
* information is returned as CompilationResult. If you need to
* get notified already during the compilation process you can
* register a CompilationProblemHandler.
* Note: Not all compilers might support this notification mechanism.
- *
+ *
* @param pResourcePaths
* @param pReader
* @param pStore
diff --git a/core/src/main/java/org/apache/commons/jci2/compilers/JavaCompilerFactory.java b/core/src/main/java/org/apache/commons/jci2/compilers/JavaCompilerFactory.java
index 1027fda..9b5d623 100644
--- a/core/src/main/java/org/apache/commons/jci2/compilers/JavaCompilerFactory.java
+++ b/core/src/main/java/org/apache/commons/jci2/compilers/JavaCompilerFactory.java
@@ -25,9 +25,9 @@
/**
* Creates JavaCompilers
- *
+ *
* TODO use META-INF discovery mechanism
- *
+ *
* @author tcurdt
*/
public final class JavaCompilerFactory {
@@ -39,7 +39,7 @@
private static final JavaCompilerFactory INSTANCE = new JavaCompilerFactory();
private final Map<String, Class<?>> classCache = new HashMap<String, Class<?>>();
-
+
/**
* @deprecated will be remove after the next release, please create an instance yourself
*/
@@ -51,27 +51,27 @@
/**
* Tries to guess the class name by convention. So for compilers
* following the naming convention
- *
+ *
* org.apache.commons.jci2.compilers.SomeJavaCompiler
- *
+ *
* you can use the short-hands "some"/"Some"/"SOME". Otherwise
* you have to provide the full class name. The compiler is
* getting instanciated via (cached) reflection.
- *
+ *
* @param pHint
* @return JavaCompiler or null
*/
public JavaCompiler createCompiler(final String pHint) {
-
+
final String className;
if (pHint.indexOf('.') < 0) {
className = "org.apache.commons.jci2.compilers." + ConversionUtils.toJavaCasing(pHint) + "JavaCompiler";
} else {
className = pHint;
}
-
+
Class<?> clazz = classCache.get(className);
-
+
if (clazz == null) {
try {
clazz = Class.forName(className);
@@ -84,12 +84,12 @@
if (clazz == null) {
return null;
}
-
+
try {
return (JavaCompiler) clazz.newInstance();
} catch (final Throwable t) {
return null;
}
}
-
+
}
diff --git a/core/src/main/java/org/apache/commons/jci2/compilers/JavaCompilerSettings.java b/core/src/main/java/org/apache/commons/jci2/compilers/JavaCompilerSettings.java
index 2223368..64b2ed6 100644
--- a/core/src/main/java/org/apache/commons/jci2/compilers/JavaCompilerSettings.java
+++ b/core/src/main/java/org/apache/commons/jci2/compilers/JavaCompilerSettings.java
@@ -21,11 +21,11 @@
/**
* Most common denominator for JavaCompiler settings.
- *
+ *
* If you need more specific settings you have to provide
* the native compiler configurations to the compilers.
- * Writing of a custom factory is suggested.
- *
+ * Writing of a custom factory is suggested.
+ *
* @author tcurdt
*/
public class JavaCompilerSettings {
@@ -41,9 +41,9 @@
@Deprecated
private boolean verbose = false;
- public JavaCompilerSettings() {
+ public JavaCompilerSettings() {
}
-
+
public JavaCompilerSettings( final JavaCompilerSettings pSettings ) {
targetVersion = pSettings.targetVersion;
sourceVersion = pSettings.sourceVersion;
@@ -52,7 +52,7 @@
deprecations = pSettings.deprecations;
debug = pSettings.debug;
}
-
+
public void setTargetVersion( final String pTargetVersion ) {
targetVersion = pTargetVersion;
}
diff --git a/core/src/main/java/org/apache/commons/jci2/listeners/CompilingListener.java b/core/src/main/java/org/apache/commons/jci2/listeners/CompilingListener.java
index ca7b547..6bd9bdc 100644
--- a/core/src/main/java/org/apache/commons/jci2/listeners/CompilingListener.java
+++ b/core/src/main/java/org/apache/commons/jci2/listeners/CompilingListener.java
@@ -38,18 +38,18 @@
/**
* A CompilingListener is an improved version of the ReloadingListener.
* It even compiles the classes from source before doing the reloading.
- *
+ *
* @author tcurdt
*/
public class CompilingListener extends ReloadingListener {
private final Log log = LogFactory.getLog(CompilingListener.class);
-
+
private final JavaCompiler compiler;
private final TransactionalResourceStore transactionalStore;
private ResourceReader reader;
private CompilationResult lastResult;
-
+
public CompilingListener() {
this(new JavaCompilerFactory().createCompiler("eclipse"));
}
@@ -57,18 +57,18 @@
public CompilingListener( final JavaCompiler pCompiler ) {
this(pCompiler, new TransactionalResourceStore(new MemoryResourceStore()));
}
-
+
public CompilingListener( final JavaCompiler pCompiler, final TransactionalResourceStore pTransactionalStore ) {
super(pTransactionalStore);
compiler = pCompiler;
transactionalStore = pTransactionalStore;
lastResult = null;
}
-
+
public JavaCompiler getCompiler() {
return compiler;
}
-
+
public String getSourceFileExtension() {
return ".java";
}
@@ -80,7 +80,7 @@
public String getSourceNameFromFile( final FilesystemAlterationObserver pObserver, final File pFile ) {
return ConversionUtils.stripExtension(ConversionUtils.getResourceNameFromFileName(ConversionUtils.relative(pObserver.getRootDirectory(), pFile))) + getSourceFileExtension();
}
-
+
@Override
public ResourceStore getStore() {
return transactionalStore;
@@ -89,7 +89,7 @@
public synchronized CompilationResult getCompilationResult() {
return lastResult;
}
-
+
@Override
public void onStart( final FilesystemAlterationObserver pObserver ) {
super.onStart(pObserver);
@@ -104,13 +104,13 @@
final Collection<File> changed = getChangedFiles();
final Collection<String> resourceNames = new ArrayList<String>();
-
+
for (final File createdFile : created) {
if (createdFile.getName().endsWith(getSourceFileExtension())) {
resourceNames.add(getSourceNameFromFile(pObserver, createdFile));
}
}
-
+
for (final File changedFile : changed) {
if (changedFile.getName().endsWith(getSourceFileExtension())) {
resourceNames.add(getSourceNameFromFile(pObserver, changedFile));
@@ -121,7 +121,7 @@
resourceNames.toArray(result);
return result;
}
-
+
@Override
public boolean isReloadRequired( final FilesystemAlterationObserver pObserver ) {
boolean reload = false;
@@ -129,44 +129,44 @@
final Collection<File> created = getCreatedFiles();
final Collection<File> changed = getChangedFiles();
final Collection<File> deleted = getDeletedFiles();
-
+
log.debug("created:" + created.size() + " changed:" + changed.size() + " deleted:" + deleted.size() + " resources");
if (deleted.size() > 0) {
for (final File deletedFile : deleted) {
final String resourceName = ConversionUtils.getResourceNameFromFileName(ConversionUtils.relative(pObserver.getRootDirectory(), deletedFile));
-
+
if (resourceName.endsWith(getSourceFileExtension())) {
- // if source resource got removed delete the corresponding class
+ // if source resource got removed delete the corresponding class
transactionalStore.remove(ConversionUtils.stripExtension(resourceName) + ".class");
} else {
// ordinary resource to be removed
transactionalStore.remove(resourceName);
}
-
+
// FIXME: does not remove nested classes
-
+
}
reload = true;
}
-
+
final String[] resourcesToCompile = getResourcesToCompile(pObserver);
if (resourcesToCompile.length > 0) {
log.debug(resourcesToCompile.length + " classes to compile");
-
+
final CompilationResult result = compiler.compile(resourcesToCompile, reader, transactionalStore);
-
+
synchronized(this) {
lastResult = result;
}
-
+
final CompilationProblem[] errors = result.getErrors();
final CompilationProblem[] warnings = result.getWarnings();
-
+
log.debug(errors.length + " errors, " + warnings.length + " warnings");
-
+
if (errors.length > 0) {
// FIXME: they need to be marked for re-compilation
// and then added as compileables again
@@ -174,10 +174,10 @@
transactionalStore.remove(element);
}
}
-
+
reload = true;
}
-
+
return reload;
- }
+ }
}
diff --git a/core/src/main/java/org/apache/commons/jci2/listeners/FileChangeListener.java b/core/src/main/java/org/apache/commons/jci2/listeners/FileChangeListener.java
index 37a8188..395c2e4 100644
--- a/core/src/main/java/org/apache/commons/jci2/listeners/FileChangeListener.java
+++ b/core/src/main/java/org/apache/commons/jci2/listeners/FileChangeListener.java
@@ -23,17 +23,17 @@
/**
* The most simple implemenation of an FilesystemAlterationListener.
- *
+ *
* @author tcurdt
*/
public class FileChangeListener extends AbstractFilesystemAlterationListener {
private boolean changed;
-
+
public boolean hasChanged() {
return changed;
}
-
+
@Override
public void onStart( final FilesystemAlterationObserver pObserver ) {
changed = false;
@@ -45,7 +45,7 @@
super.onStop(pObserver);
}
-
+
@Override
public void onFileChange( final File pFile ) {
changed = true;
@@ -75,5 +75,5 @@
@Override
public void onDirectoryDelete( final File pDir ) {
}
-
+
}
diff --git a/core/src/main/java/org/apache/commons/jci2/listeners/ReloadNotificationListener.java b/core/src/main/java/org/apache/commons/jci2/listeners/ReloadNotificationListener.java
index 4cc9d6e..c3ee4d0 100644
--- a/core/src/main/java/org/apache/commons/jci2/listeners/ReloadNotificationListener.java
+++ b/core/src/main/java/org/apache/commons/jci2/listeners/ReloadNotificationListener.java
@@ -19,7 +19,7 @@
/**
* Classes implementing this interface can get notified by ReloadingListeners
- *
+ *
* @author tcurdt
*/
public interface ReloadNotificationListener {
diff --git a/core/src/main/java/org/apache/commons/jci2/listeners/ReloadingListener.java b/core/src/main/java/org/apache/commons/jci2/listeners/ReloadingListener.java
index 2c1ecd6..5f3c685 100644
--- a/core/src/main/java/org/apache/commons/jci2/listeners/ReloadingListener.java
+++ b/core/src/main/java/org/apache/commons/jci2/listeners/ReloadingListener.java
@@ -36,16 +36,16 @@
/**
* This Listener waits for FAM events to trigger a reload of classes
* or resources.
- *
+ *
* @author tcurdt
*/
public class ReloadingListener extends AbstractFilesystemAlterationListener {
private final Log log = LogFactory.getLog(ReloadingListener.class);
-
+
private final Set<ReloadNotificationListener> notificationListeners = new HashSet<ReloadNotificationListener>();
private final ResourceStore store;
-
+
public ReloadingListener() {
this(new MemoryResourceStore());
}
@@ -66,14 +66,14 @@
}
}
-
+
public boolean isReloadRequired( final FilesystemAlterationObserver pObserver ) {
boolean reload = false;
final Collection<File> created = getCreatedFiles();
final Collection<File> changed = getChangedFiles();
final Collection<File> deleted = getDeletedFiles();
-
+
log.debug("created:" + created.size() + " changed:" + changed.size() + " deleted:" + deleted.size() + " resources");
if (deleted.size() > 0) {
@@ -119,11 +119,11 @@
return reload;
}
-
+
@Override
public void onStop( final FilesystemAlterationObserver pObserver ) {
-
-
+
+
if (store instanceof Transactional) {
((Transactional)store).onStart();
}
@@ -133,11 +133,11 @@
if (store instanceof Transactional) {
((Transactional)store).onStop();
}
-
+
if (reload) {
notifyReloadNotificationListeners();
}
-
+
super.onStop(pObserver);
}
@@ -148,12 +148,12 @@
listener.handleNotification();
}
}
-
+
@Override
- public void onDirectoryCreate( final File pDir ) {
+ public void onDirectoryCreate( final File pDir ) {
}
@Override
- public void onDirectoryChange( final File pDir ) {
+ public void onDirectoryChange( final File pDir ) {
}
@Override
public void onDirectoryDelete( final File pDir ) {
diff --git a/core/src/main/java/org/apache/commons/jci2/problems/CompilationProblem.java b/core/src/main/java/org/apache/commons/jci2/problems/CompilationProblem.java
index a3b807e..40c91ac 100644
--- a/core/src/main/java/org/apache/commons/jci2/problems/CompilationProblem.java
+++ b/core/src/main/java/org/apache/commons/jci2/problems/CompilationProblem.java
@@ -19,7 +19,7 @@
/**
* An abstract definition of a compilation problem
- *
+ *
* @author tcurdt
*/
public interface CompilationProblem {
@@ -27,21 +27,21 @@
/**
* is the problem an error and compilation cannot continue
* or just a warning and compilation can proceed
- *
+ *
* @return true if the problem is an error
*/
boolean isError();
/**
* name of the file where the problem occurred
- *
+ *
* @return name of the file where the problem occurred
*/
String getFileName();
/**
* position of where the problem starts in the source code
- *
+ *
* @return position of where the problem starts in the source code
*/
int getStartLine();
@@ -49,7 +49,7 @@
/**
* position of where the problem stops in the source code
- *
+ *
* @return position of where the problem stops in the source code
*/
int getEndLine();
@@ -57,7 +57,7 @@
/**
* the description of the problem
- *
+ *
* @return the description of the problem
*/
String getMessage();
diff --git a/core/src/main/java/org/apache/commons/jci2/problems/CompilationProblemHandler.java b/core/src/main/java/org/apache/commons/jci2/problems/CompilationProblemHandler.java
index 3e6612c..6dfe01f 100644
--- a/core/src/main/java/org/apache/commons/jci2/problems/CompilationProblemHandler.java
+++ b/core/src/main/java/org/apache/commons/jci2/problems/CompilationProblemHandler.java
@@ -26,10 +26,10 @@
* The handler can be used to asynchronously update a
* GUI or stop compilation by returning false (e.g.
* when a maximum number of erros has been reached)
- *
+ *
* NOTE:
* has to be supported by the compiler implementation!!
- *
+ *
* @author tcurdt
*/
public interface CompilationProblemHandler {
diff --git a/core/src/main/java/org/apache/commons/jci2/readers/FileResourceReader.java b/core/src/main/java/org/apache/commons/jci2/readers/FileResourceReader.java
index aebe2a1..2829dc7 100644
--- a/core/src/main/java/org/apache/commons/jci2/readers/FileResourceReader.java
+++ b/core/src/main/java/org/apache/commons/jci2/readers/FileResourceReader.java
@@ -25,7 +25,7 @@
/**
* A simple file system based Reader implementation
- *
+ *
* @author tcurdt
*/
public final class FileResourceReader implements ResourceReader {
@@ -33,9 +33,9 @@
private final File root;
public FileResourceReader( final File pRoot ) {
- root = pRoot;
+ root = pRoot;
}
-
+
public boolean isAvailable( final String pResourceName ) {
return new File(root, pResourceName).exists();
}
@@ -47,7 +47,7 @@
return null;
}
}
-
+
/**
* @deprecated
*/
@@ -71,5 +71,5 @@
} else {
pFiles.add(pFile.getAbsolutePath().substring(root.getAbsolutePath().length()+1));
}
- }
+ }
}
diff --git a/core/src/main/java/org/apache/commons/jci2/readers/MemoryResourceReader.java b/core/src/main/java/org/apache/commons/jci2/readers/MemoryResourceReader.java
index 57e487a..7a113cc 100644
--- a/core/src/main/java/org/apache/commons/jci2/readers/MemoryResourceReader.java
+++ b/core/src/main/java/org/apache/commons/jci2/readers/MemoryResourceReader.java
@@ -22,11 +22,11 @@
/**
* A memory based reader to compile from memory
- *
+ *
* @author tcurdt
*/
public class MemoryResourceReader implements ResourceReader {
-
+
private Map<String, byte[]> resources = null;
public boolean isAvailable( final String pResourceName ) {
@@ -36,21 +36,21 @@
return resources.containsKey(pResourceName);
}
-
+
public void add( final String pResourceName, final byte[] pContent ) {
if (resources == null) {
resources = new HashMap<String, byte[]>();
}
-
+
resources.put(pResourceName, pContent);
}
-
+
public void remove( final String pResourceName ) {
if (resources != null) {
resources.remove(pResourceName);
- }
- }
-
+ }
+ }
+
public byte[] getBytes( final String pResourceName ) {
return resources.get(pResourceName);
diff --git a/core/src/main/java/org/apache/commons/jci2/readers/ResourceReader.java b/core/src/main/java/org/apache/commons/jci2/readers/ResourceReader.java
index 3465e99..ceac362 100644
--- a/core/src/main/java/org/apache/commons/jci2/readers/ResourceReader.java
+++ b/core/src/main/java/org/apache/commons/jci2/readers/ResourceReader.java
@@ -19,7 +19,7 @@
/**
* A ResourceReader provide acces to resource like e.g. source code
- *
+ *
* @author tcurdt
*/
public interface ResourceReader {
diff --git a/core/src/main/java/org/apache/commons/jci2/stores/FileResourceStore.java b/core/src/main/java/org/apache/commons/jci2/stores/FileResourceStore.java
index 003bf17..c72b527 100644
--- a/core/src/main/java/org/apache/commons/jci2/stores/FileResourceStore.java
+++ b/core/src/main/java/org/apache/commons/jci2/stores/FileResourceStore.java
@@ -31,7 +31,7 @@
/**
* Stores the results on disk
- *
+ *
* @author tcurdt
*/
public final class FileResourceStore implements ResourceStore {
@@ -41,7 +41,7 @@
public FileResourceStore( final File pFile ) {
root = pFile;
}
-
+
public byte[] read( final String pResourceName ) {
InputStream is = null;
try {
@@ -54,7 +54,7 @@
IOUtils.closeQuietly(is);
}
}
-
+
public void write( final String pResourceName, final byte[] pData ) {
OutputStream os = null;
try {
@@ -105,7 +105,7 @@
pFiles.add(pFile.getAbsolutePath().substring(root.getAbsolutePath().length()+1));
}
}
-
+
@Override
public String toString() {
return this.getClass().getName() + root.toString();
diff --git a/core/src/main/java/org/apache/commons/jci2/stores/MemoryResourceStore.java b/core/src/main/java/org/apache/commons/jci2/stores/MemoryResourceStore.java
index 84f1d92..99af9ce 100644
--- a/core/src/main/java/org/apache/commons/jci2/stores/MemoryResourceStore.java
+++ b/core/src/main/java/org/apache/commons/jci2/stores/MemoryResourceStore.java
@@ -27,7 +27,7 @@
/**
* Store just in memory
- *
+ *
* @author tcurdt
*/
public final class MemoryResourceStore implements ResourceStore {
@@ -60,14 +60,14 @@
return new String[0];
}
final List<String> names = new ArrayList<String>();
-
+
for (final String name : store.keySet()) {
names.add(name);
}
return names.toArray(new String[store.size()]);
}
-
+
@Override
public String toString() {
return this.getClass().getName() + store.toString();
diff --git a/core/src/main/java/org/apache/commons/jci2/stores/ResourceStore.java b/core/src/main/java/org/apache/commons/jci2/stores/ResourceStore.java
index ce94d84..fa3b7b7 100644
--- a/core/src/main/java/org/apache/commons/jci2/stores/ResourceStore.java
+++ b/core/src/main/java/org/apache/commons/jci2/stores/ResourceStore.java
@@ -18,7 +18,7 @@
/**
* A Store is where the compilers are storing the results
- *
+ *
* @author tcurdt
*/
public interface ResourceStore {
diff --git a/core/src/main/java/org/apache/commons/jci2/stores/ResourceStoreClassLoader.java b/core/src/main/java/org/apache/commons/jci2/stores/ResourceStoreClassLoader.java
index 0b8db35..ebba2a0 100644
--- a/core/src/main/java/org/apache/commons/jci2/stores/ResourceStoreClassLoader.java
+++ b/core/src/main/java/org/apache/commons/jci2/stores/ResourceStoreClassLoader.java
@@ -23,7 +23,7 @@
/**
* A ClassLoader backed by an array of ResourceStores
- *
+ *
* @author tcurdt
*/
public final class ResourceStoreClassLoader extends ClassLoader {
@@ -34,26 +34,26 @@
public ResourceStoreClassLoader( final ClassLoader pParent, final ResourceStore[] pStores ) {
super(pParent);
-
- stores = new ResourceStore[pStores.length];
- System.arraycopy(pStores, 0, stores, 0, stores.length);
+
+ stores = new ResourceStore[pStores.length];
+ System.arraycopy(pStores, 0, stores, 0, stores.length);
}
private Class<?> fastFindClass(final String name) {
-
+
if (stores != null) {
for (final ResourceStore store : stores) {
final byte[] clazzBytes = store.read(ConversionUtils.convertClassToResourcePath(name));
if (clazzBytes != null) {
log.debug(getId() + " found class: " + name + " (" + clazzBytes.length + " bytes)");
return defineClass(name, clazzBytes, 0, clazzBytes.length);
- }
+ }
}
}
-
- return null;
+
+ return null;
}
-
+
@Override
protected synchronized Class<?> loadClass(final String name, final boolean resolve) throws ClassNotFoundException {
// log.debug(getId() + " looking for: " + name);
@@ -61,7 +61,7 @@
if (clazz == null) {
clazz = fastFindClass(name);
-
+
if (clazz == null) {
final ClassLoader parent = getParent();
@@ -71,7 +71,7 @@
} else {
throw new ClassNotFoundException(name);
}
-
+
} else {
log.debug(getId() + " loaded from store: " + name);
}
@@ -92,7 +92,7 @@
}
return clazz;
}
-
+
private String getId() {
return "" + this + "[" + this.getClass().getClassLoader() + "]";
}
diff --git a/core/src/main/java/org/apache/commons/jci2/stores/Transactional.java b/core/src/main/java/org/apache/commons/jci2/stores/Transactional.java
index 0d80c8b..bba25e1 100644
--- a/core/src/main/java/org/apache/commons/jci2/stores/Transactional.java
+++ b/core/src/main/java/org/apache/commons/jci2/stores/Transactional.java
@@ -19,7 +19,7 @@
/**
* Receive start/stop events
- *
+ *
* @author tcurdt
*/
public interface Transactional {
diff --git a/core/src/main/java/org/apache/commons/jci2/stores/TransactionalResourceStore.java b/core/src/main/java/org/apache/commons/jci2/stores/TransactionalResourceStore.java
index cea0c3e..4273a92 100644
--- a/core/src/main/java/org/apache/commons/jci2/stores/TransactionalResourceStore.java
+++ b/core/src/main/java/org/apache/commons/jci2/stores/TransactionalResourceStore.java
@@ -21,23 +21,23 @@
/**
* A TransactionalResourceStore get signals of the compilation process as a whole.
* When it started and when the compiler finished.
- *
+ *
* @author tcurdt
*/
public class TransactionalResourceStore implements ResourceStore, Transactional {
private final ResourceStore store;
-
+
public TransactionalResourceStore( final ResourceStore pStore ) {
store = pStore;
}
-
+
public void onStart() {
}
-
+
public void onStop() {
}
-
+
public byte[] read( final String pResourceName ) {
return store.read(pResourceName);
}
@@ -47,7 +47,7 @@
public void write( final String pResourceName, final byte[] pResourceData ) {
store.write(pResourceName, pResourceData);
}
-
+
@Override
public String toString() {
return store.toString();
diff --git a/core/src/main/java/org/apache/commons/jci2/utils/ConversionUtils.java b/core/src/main/java/org/apache/commons/jci2/utils/ConversionUtils.java
index ff9016a..1592162 100644
--- a/core/src/main/java/org/apache/commons/jci2/utils/ConversionUtils.java
+++ b/core/src/main/java/org/apache/commons/jci2/utils/ConversionUtils.java
@@ -23,7 +23,7 @@
/**
* Mainly common path manipultation helper methods
* NOT FOR USE OUTSIDE OF JCI
- *
+ *
* @author tcurdt
*/
public final class ConversionUtils {
diff --git a/core/src/test/java/org/apache/commons/jci2/AbstractTestCase.java b/core/src/test/java/org/apache/commons/jci2/AbstractTestCase.java
index 6438d3a..3c2f735 100644
--- a/core/src/test/java/org/apache/commons/jci2/AbstractTestCase.java
+++ b/core/src/test/java/org/apache/commons/jci2/AbstractTestCase.java
@@ -27,13 +27,13 @@
import org.apache.commons.logging.LogFactory;
/**
- *
+ *
* @author tcurdt
*/
public abstract class AbstractTestCase extends TestCase {
private final Log log = LogFactory.getLog(AbstractTestCase.class);
-
+
protected File directory;
@Override
@@ -45,8 +45,8 @@
assertTrue(directory.exists());
assertTrue(directory.isDirectory());
}
-
-
+
+
protected File createDirectory( final String pName ) throws Exception {
final File newDirectory = new File(directory, pName);
assertTrue(newDirectory.mkdir());
@@ -54,7 +54,7 @@
assertTrue(newDirectory.isDirectory());
return newDirectory;
}
-
+
protected File writeFile( final String pName, final byte[] pData ) throws Exception {
final File file = new File(directory, pName);
final File parent = file.getParentFile();
@@ -63,14 +63,14 @@
}
log.debug("writing file " + pName + " (" + pData.length + " bytes)");
-
+
final FileOutputStream os = new FileOutputStream(file);
os.write(pData);
os.close();
-
+
assertTrue(file.exists());
assertTrue(file.isFile());
-
+
return file;
}
@@ -84,32 +84,32 @@
final FileWriter writer = new FileWriter(file);
writer.write(pText);
writer.close();
-
+
assertTrue(file.exists());
assertTrue(file.isFile());
-
+
return file;
}
-
+
protected void delay() {
try {
Thread.sleep(1500);
} catch (final InterruptedException e) {
}
}
-
+
protected File createTempDirectory() throws IOException {
final File tempFile = File.createTempFile("jci2", null);
-
+
if (!tempFile.delete()) {
throw new IOException();
}
-
+
if (!tempFile.mkdir()) {
throw new IOException();
}
-
- return tempFile;
+
+ return tempFile;
}
diff --git a/core/src/test/java/org/apache/commons/jci2/CompilingClassLoaderTestCase.java b/core/src/test/java/org/apache/commons/jci2/CompilingClassLoaderTestCase.java
index 566e216..6d92feb 100644
--- a/core/src/test/java/org/apache/commons/jci2/CompilingClassLoaderTestCase.java
+++ b/core/src/test/java/org/apache/commons/jci2/CompilingClassLoaderTestCase.java
@@ -36,7 +36,7 @@
import org.apache.commons.logging.LogFactory;
/**
- *
+ *
* @author tcurdt
*/
public final class CompilingClassLoaderTestCase extends AbstractTestCase {
@@ -46,7 +46,7 @@
private ReloadingClassLoader classloader;
private CompilingListener listener;
private FilesystemAlterationMonitor fam;
-
+
private final static class MockJavaCompiler implements JavaCompiler {
private final Log log = LogFactory.getLog(MockJavaCompiler.class);
@@ -105,63 +105,63 @@
}
}
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
-
+
classloader = new ReloadingClassLoader(this.getClass().getClassLoader());
- listener = new CompilingListener(new MockJavaCompiler());
+ listener = new CompilingListener(new MockJavaCompiler());
listener.addReloadNotificationListener(classloader);
-
+
fam = new FilesystemAlterationMonitor();
fam.addListener(directory, listener);
fam.start();
}
private void initialCompile() throws Exception {
- log.debug("initial compile");
+ log.debug("initial compile");
listener.waitForFirstCheck();
-
+
writeFile("jci2/Simple.java", "Simple1");
writeFile("jci2/Extended.java", "Extended");
-
- log.debug("waiting for compile changes to get applied");
+
+ log.debug("waiting for compile changes to get applied");
listener.waitForCheck();
-
- log.debug("*** ready to test");
+
+ log.debug("*** ready to test");
}
-
+
public void testCreate() throws Exception {
initialCompile();
-
- log.debug("loading Simple");
+
+ log.debug("loading Simple");
final Object simple = classloader.loadClass("jci2.Simple").newInstance();
assertEquals("Simple1", simple.toString());
-
- log.debug("loading Extended");
+
+ log.debug("loading Extended");
final Object extended = classloader.loadClass("jci2.Extended").newInstance();
assertEquals("Extended:Simple1", extended.toString());
}
- public void testChange() throws Exception {
+ public void testChange() throws Exception {
initialCompile();
final Object simple = classloader.loadClass("jci2.Simple").newInstance();
assertEquals("Simple1", simple.toString());
-
+
final Object extended = classloader.loadClass("jci2.Extended").newInstance();
assertEquals("Extended:Simple1", extended.toString());
delay();
writeFile("jci2/Simple.java", "Simple2");
listener.waitForCheck();
-
+
final Object simple2 = classloader.loadClass("jci2.Simple").newInstance();
assertEquals("Simple2", simple2.toString());
-
+
final Object newExtended = classloader.loadClass("jci2.Extended").newInstance();
assertEquals("Extended:Simple2", newExtended.toString());
}
@@ -171,17 +171,17 @@
final Object simple = classloader.loadClass("jci2.Simple").newInstance();
assertEquals("Simple1", simple.toString());
-
+
final Object extended = classloader.loadClass("jci2.Extended").newInstance();
assertEquals("Extended:Simple1", extended.toString());
-
+
listener.waitForCheck();
-
+
log.debug("deleting source file");
assertTrue(new File(directory, "jci2/Extended.java").delete());
-
+
listener.waitForCheck();
-
+
log.debug("loading Simple");
final Object oldSimple = classloader.loadClass("jci2.Simple").newInstance();
assertEquals("Simple1", oldSimple.toString());
@@ -192,8 +192,8 @@
fail();
} catch(final ClassNotFoundException e) {
assertEquals("jci2.Extended", e.getMessage());
- }
-
+ }
+
log.debug("deleting whole directory");
FileUtils.deleteDirectory(new File(directory, "jci2"));
@@ -209,15 +209,15 @@
}
- public void testDeleteDependency() throws Exception {
+ public void testDeleteDependency() throws Exception {
initialCompile();
final Object simple = classloader.loadClass("jci2.Simple").newInstance();
assertEquals("Simple1", simple.toString());
-
+
final Object extended = classloader.loadClass("jci2.Extended").newInstance();
assertEquals("Extended:Simple1", extended.toString());
-
+
log.debug("deleting source file");
assertTrue(new File(directory, "jci2/Simple.java").delete());
listener.waitForCheck();
@@ -229,7 +229,7 @@
} catch(final NoClassDefFoundError e) {
assertEquals("jci2/Simple", e.getMessage());
}
-
+
}
@Override
@@ -237,5 +237,5 @@
fam.removeListener(listener);
fam.stop();
super.tearDown();
- }
+ }
}
diff --git a/core/src/test/java/org/apache/commons/jci2/ReloadingClassLoaderRemoveTestCase.java b/core/src/test/java/org/apache/commons/jci2/ReloadingClassLoaderRemoveTestCase.java
index 8879017..4ce7eeb 100644
--- a/core/src/test/java/org/apache/commons/jci2/ReloadingClassLoaderRemoveTestCase.java
+++ b/core/src/test/java/org/apache/commons/jci2/ReloadingClassLoaderRemoveTestCase.java
@@ -32,7 +32,7 @@
public class ReloadingClassLoaderRemoveTestCase extends TestCase {
private final Log log = LogFactory.getLog(ReloadingClassLoaderRemoveTestCase.class);
-
+
private final byte[] clazzSimpleA;
private final MemoryResourceStore store1 = new MemoryResourceStore();
private final MemoryResourceStore store2 = new MemoryResourceStore();
@@ -48,7 +48,7 @@
protected void setUp() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
}
-
+
@Override
protected void tearDown() throws Exception {
}
@@ -227,8 +227,8 @@
// Check "jci2.Simple" class can now be loaded
try {
final Object simple2 = loader.loadClass("jci2.Simple").newInstance();
- assertNotNull("Found loadClass[2]", simple2);
- assertEquals("toString loadClass[2]", toStringValue, simple2.toString());
+ assertNotNull("Found loadClass[2]", simple2);
+ assertEquals("toString loadClass[2]", toStringValue, simple2.toString());
} catch(final Exception e) {
log.error(e);
fail("Error loadClass[2]: " + e);
diff --git a/core/src/test/java/org/apache/commons/jci2/ReloadingClassLoaderTestCase.java b/core/src/test/java/org/apache/commons/jci2/ReloadingClassLoaderTestCase.java
index 16b675b..f8cac5a 100644
--- a/core/src/test/java/org/apache/commons/jci2/ReloadingClassLoaderTestCase.java
+++ b/core/src/test/java/org/apache/commons/jci2/ReloadingClassLoaderTestCase.java
@@ -27,13 +27,13 @@
import org.apache.commons.logging.LogFactory;
/**
- *
+ *
* @author tcurdt
*/
public final class ReloadingClassLoaderTestCase extends AbstractTestCase {
private final Log log = LogFactory.getLog(ReloadingClassLoaderTestCase.class);
-
+
private ReloadingClassLoader classloader;
private ReloadingListener listener;
private FilesystemAlterationMonitor fam;
@@ -41,25 +41,25 @@
private final byte[] clazzSimple1;
private final byte[] clazzSimple2;
private final byte[] clazzExtended;
-
+
public ReloadingClassLoaderTestCase() throws Exception {
clazzSimple1 = SimpleDump.dump("Simple1");
clazzSimple2 = SimpleDump.dump("Simple2");
- clazzExtended = ExtendedDump.dump();
+ clazzExtended = ExtendedDump.dump();
assertTrue(clazzSimple1.length > 0);
assertTrue(clazzSimple2.length > 0);
assertTrue(clazzExtended.length > 0);
}
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
-
+
classloader = new ReloadingClassLoader(this.getClass().getClassLoader());
listener = new ReloadingListener();
-
+
listener.addReloadNotificationListener(classloader);
-
+
fam = new FilesystemAlterationMonitor();
fam.addListener(directory, listener);
fam.start();
@@ -68,15 +68,15 @@
public void testCreate() throws Exception {
listener.waitForFirstCheck();
- log.debug("creating class");
+ log.debug("creating class");
writeFile("jci2/Simple.class", clazzSimple1);
listener.waitForCheck();
-
+
final Object simple = classloader.loadClass("jci2.Simple").newInstance();
- assertEquals("Simple1", simple.toString());
+ assertEquals("Simple1", simple.toString());
}
- public void testChange() throws Exception {
+ public void testChange() throws Exception {
listener.waitForFirstCheck();
log.debug("creating class");
@@ -85,13 +85,13 @@
final Object simple1 = classloader.loadClass("jci2.Simple").newInstance();
assertEquals("Simple1", simple1.toString());
-
- log.debug("changing class");
+
+ log.debug("changing class");
writeFile("jci2/Simple.class", clazzSimple2);
listener.waitForEvent();
-
+
final Object simple2 = classloader.loadClass("jci2.Simple").newInstance();
- assertEquals("Simple2", simple2.toString());
+ assertEquals("Simple2", simple2.toString());
}
public void testDelete() throws Exception {
@@ -104,7 +104,7 @@
final Object simple = classloader.loadClass("jci2.Simple").newInstance();
assertEquals("Simple1", simple.toString());
- log.debug("deleting class");
+ log.debug("deleting class");
assertTrue(new File(directory, "jci2/Simple.class").delete());
listener.waitForEvent();
@@ -113,10 +113,10 @@
fail();
} catch(final ClassNotFoundException e) {
assertEquals("jci2.Simple", e.getMessage());
- }
+ }
}
- public void testDeleteDependency() throws Exception {
+ public void testDeleteDependency() throws Exception {
listener.waitForFirstCheck();
log.debug("creating classes");
@@ -126,11 +126,11 @@
final Object simple = classloader.loadClass("jci2.Simple").newInstance();
assertEquals("Simple1", simple.toString());
-
+
final Object extended = classloader.loadClass("jci2.Extended").newInstance();
assertEquals("Extended:Simple1", extended.toString());
- log.debug("deleting class dependency");
+ log.debug("deleting class dependency");
assertTrue(new File(directory, "jci2/Simple.class").delete());
listener.waitForEvent();
@@ -149,7 +149,7 @@
} catch(final ClassNotFoundException e) {
}
}
-
+
public void testDelegation() {
classloader.clearAssertionStatus();
classloader.setClassAssertionStatus("org.apache.commons.jci2.ReloadingClassLoader", true);
@@ -157,12 +157,12 @@
classloader.setPackageAssertionStatus("org.apache.commons.jci2", true);
// FIXME: compare with delegation
}
-
+
@Override
protected void tearDown() throws Exception {
fam.removeListener(listener);
fam.stop();
super.tearDown();
}
-
+
}
diff --git a/core/src/test/java/org/apache/commons/jci2/compilers/AbstractCompilerTestCase.java b/core/src/test/java/org/apache/commons/jci2/compilers/AbstractCompilerTestCase.java
index f5f1788..6805638 100644
--- a/core/src/test/java/org/apache/commons/jci2/compilers/AbstractCompilerTestCase.java
+++ b/core/src/test/java/org/apache/commons/jci2/compilers/AbstractCompilerTestCase.java
@@ -292,8 +292,8 @@
* https://issues.apache.org/jira/browse/JCI-59
*/
public void testAdditionalTopLevelClassCompile() throws Exception {
- final JavaCompiler compiler = createJavaCompiler();
-
+ final JavaCompiler compiler = createJavaCompiler();
+
final ResourceReader reader = new ResourceReader() {
final private Map<String, byte[]> sources = new HashMap<String, byte[]>() {
private static final long serialVersionUID = 1L;
@@ -311,24 +311,24 @@
" }\n" +
"}").getBytes());
}};
-
+
public byte[] getBytes( final String pResourceName ) {
return sources.get(pResourceName);
}
-
+
public boolean isAvailable( final String pResourceName ) {
return sources.containsKey(pResourceName);
}
};
-
+
final MemoryResourceStore store = new MemoryResourceStore();
final CompilationResult result = compiler.compile(
new String[] {
"jci2/Simple.java"
}, reader, store);
-
+
assertEquals("Unexpected errors(s): " + toString(result.getErrors()), 0, result.getErrors().length);
-
+
final byte[] clazzBytes = store.read("jci2/Simple.class");
assertNotNull("Expected to find jci2/Simple.class", clazzBytes);
assertTrue(clazzBytes.length > 0);
diff --git a/core/src/test/java/org/apache/commons/jci2/readers/ResourceReaderTestCase.java b/core/src/test/java/org/apache/commons/jci2/readers/ResourceReaderTestCase.java
index 13aea5c..22dc9f5 100644
--- a/core/src/test/java/org/apache/commons/jci2/readers/ResourceReaderTestCase.java
+++ b/core/src/test/java/org/apache/commons/jci2/readers/ResourceReaderTestCase.java
@@ -20,7 +20,7 @@
import org.apache.commons.jci2.AbstractTestCase;
/**
- *
+ *
* @author tcurdt
*/
public final class ResourceReaderTestCase extends AbstractTestCase {
@@ -44,7 +44,7 @@
assertTrue(reader.isAvailable("test"));
final byte[] content = reader.getBytes("test");
assertTrue(content != null);
- assertEquals("test", new String(content));
+ assertEquals("test", new String(content));
assertFalse(reader.isAvailable("bla"));
assertTrue(reader.getBytes("bla") == null);
diff --git a/core/src/test/java/org/apache/commons/jci2/stores/ResourceStoreTestCase.java b/core/src/test/java/org/apache/commons/jci2/stores/ResourceStoreTestCase.java
index fa4a4ee..3ca49fc 100644
--- a/core/src/test/java/org/apache/commons/jci2/stores/ResourceStoreTestCase.java
+++ b/core/src/test/java/org/apache/commons/jci2/stores/ResourceStoreTestCase.java
@@ -21,7 +21,7 @@
import org.apache.commons.lang3.ArrayUtils;
/**
- *
+ *
* @author tcurdt
*/
public final class ResourceStoreTestCase extends AbstractTestCase {
@@ -36,10 +36,10 @@
checkRemove(new FileResourceStore(directory));
}
- public void testTransactionalFileResourceStore() {
+ public void testTransactionalFileResourceStore() {
checkReadWrite(new TransactionalResourceStore(new FileResourceStore(directory)));
checkRemove(new TransactionalResourceStore(new FileResourceStore(directory)));
-
+
final ResourceStore rs = new FileResourceStore(directory);
final TransactionalResourceStore trs = new TransactionalResourceStore(rs);
assertEquals(rs.toString(), trs.toString());
@@ -48,9 +48,9 @@
private void checkReadWrite( final ResourceStore pStore ) {
final byte[] data = { 1, 2, 3 };
pStore.write("key", data);
-
+
final byte[] read = pStore.read("key");
-
+
assertTrue(read != null);
assertTrue(ArrayUtils.isEquals(data, read));
}
@@ -58,16 +58,16 @@
private void checkRemove( final ResourceStore pStore ) {
final byte[] data = { 1, 2, 3 };
pStore.write("key", data);
-
+
final byte[] read = pStore.read("key");
-
+
assertTrue(read != null);
assertTrue(ArrayUtils.isEquals(data, read));
pStore.remove("key");
final byte[] empty = pStore.read("key");
-
+
assertTrue(empty == null);
- }
+ }
}
diff --git a/examples/src/main/java/org/apache/commons/jci2/examples/commandline/CommandlineCompiler.java b/examples/src/main/java/org/apache/commons/jci2/examples/commandline/CommandlineCompiler.java
index f79d713..7e02780 100644
--- a/examples/src/main/java/org/apache/commons/jci2/examples/commandline/CommandlineCompiler.java
+++ b/examples/src/main/java/org/apache/commons/jci2/examples/commandline/CommandlineCompiler.java
@@ -45,7 +45,7 @@
* @author tcurdt
*/
public final class CommandlineCompiler {
-
+
public static void main( final String[] args ) throws Exception {
final Options options = new Options();
@@ -141,7 +141,7 @@
final ResourceReader reader = new FileResourceReader(sourcepath);
final ResourceStore store = new FileResourceStore(targetpath);
-
+
final int maxErrors = maxerrs;
final int maxWarnings = maxwarns;
compiler.setCompilationProblemHandler(new CompilationProblemHandler() {
@@ -172,15 +172,15 @@
return true;
}
});
-
+
final String[] resource = cmd.getArgs();
-
+
for (final String element : resource) {
System.out.println("compiling " + element);
}
-
+
final CompilationResult result = compiler.compile(resource, reader, store, classloader);
-
+
System.out.println( result.getErrors().length + " errors");
System.out.println( result.getWarnings().length + " warnings");
diff --git a/examples/src/main/java/org/apache/commons/jci2/examples/configuration/ConfigurationReloading.java b/examples/src/main/java/org/apache/commons/jci2/examples/configuration/ConfigurationReloading.java
index 463633a..e8683dd 100644
--- a/examples/src/main/java/org/apache/commons/jci2/examples/configuration/ConfigurationReloading.java
+++ b/examples/src/main/java/org/apache/commons/jci2/examples/configuration/ConfigurationReloading.java
@@ -31,7 +31,7 @@
import org.apache.commons.jci2.monitor.FilesystemAlterationObserver;
/**
- *
+ *
* @author tcurdt
*/
public final class ConfigurationReloading {
@@ -55,7 +55,7 @@
System.out.println("Configuration change detected " + configFile);
final Properties props = new Properties();
- InputStream is = null;
+ InputStream is = null;
try {
is = new FileInputStream(configFile);
props.load(is);
diff --git a/examples/src/main/java/org/apache/commons/jci2/examples/serverpages/JspGenerator.java b/examples/src/main/java/org/apache/commons/jci2/examples/serverpages/JspGenerator.java
index 11706ce..4f1befc 100644
--- a/examples/src/main/java/org/apache/commons/jci2/examples/serverpages/JspGenerator.java
+++ b/examples/src/main/java/org/apache/commons/jci2/examples/serverpages/JspGenerator.java
@@ -162,7 +162,7 @@
try {
output.close();
} catch (final IOException e) {
- }
+ }
}
}
diff --git a/examples/src/main/java/org/apache/commons/jci2/examples/serverpages/ServerPageServlet.java b/examples/src/main/java/org/apache/commons/jci2/examples/serverpages/ServerPageServlet.java
index 684f286..56e5cff 100644
--- a/examples/src/main/java/org/apache/commons/jci2/examples/serverpages/ServerPageServlet.java
+++ b/examples/src/main/java/org/apache/commons/jci2/examples/serverpages/ServerPageServlet.java
@@ -57,7 +57,7 @@
private final ReloadingClassLoader classloader = new ReloadingClassLoader(ServerPageServlet.class.getClassLoader());
private FilesystemAlterationMonitor fam;
- private CompilingListener jspListener;
+ private CompilingListener jspListener;
private Map<String, HttpServlet> servletsByClassname = new HashMap<String, HttpServlet>();
@@ -185,7 +185,7 @@
}
};
jspListener.addReloadNotificationListener(classloader);
-
+
fam = new FilesystemAlterationMonitor();
fam.addListener(serverpagesDir, jspListener);
fam.start();
diff --git a/fam/src/main/java/org/apache/commons/jci2/listeners/AbstractFilesystemAlterationListener.java b/fam/src/main/java/org/apache/commons/jci2/listeners/AbstractFilesystemAlterationListener.java
index 22cf842..b324c99 100644
--- a/fam/src/main/java/org/apache/commons/jci2/listeners/AbstractFilesystemAlterationListener.java
+++ b/fam/src/main/java/org/apache/commons/jci2/listeners/AbstractFilesystemAlterationListener.java
@@ -42,14 +42,14 @@
private final Collection<File> changedDirectories = new ArrayList<File>();
private final Collection<File> deletedDirectories = new ArrayList<File>();
-
+
private final static class Signal {
public boolean triggered;
}
private final Signal eventSignal = new Signal();
private final Signal checkSignal = new Signal();
-
+
protected FilesystemAlterationObserver observer;
public void onDirectoryCreate( final File pDir ) {
@@ -133,7 +133,7 @@
signals();
observer = null;
}
-
+
public void waitForEvent() throws Exception {
synchronized(eventSignal) {
eventSignal.triggered = false;
@@ -143,24 +143,24 @@
throw new Exception("timeout");
}
}
-
+
/**
* we don't reset the signal so if there was a check it is
* already true and exit immediatly otherwise it will behave just
* like waitForCheck()
- *
+ *
* @throws Exception in case of a timeout
*/
public void waitForFirstCheck() throws Exception {
log.debug("waiting for first check");
if (!waitForSignal(checkSignal, 10)) {
throw new Exception("timeout");
- }
+ }
}
/**
* wait for the next filesystem check to happen
- *
+ *
* @throws Exception in case of a timeout
*/
public void waitForCheck() throws Exception {
@@ -172,7 +172,7 @@
throw new Exception("timeout");
}
}
-
+
private boolean waitForSignal(final Signal pSignal, final int pSecondsTimeout) {
int i = 0;
while(true) {
@@ -187,13 +187,13 @@
log.error("timeout after " + pSecondsTimeout + "s");
return false;
}
-
+
} else {
pSignal.triggered = false;
break;
}
}
- }
+ }
return true;
}
diff --git a/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationListener.java b/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationListener.java
index 08b856e..71acb1b 100644
--- a/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationListener.java
+++ b/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationListener.java
@@ -23,7 +23,7 @@
* A listener that receives events of filesystem modifications.
* The observer basically represents the source of the events.
* The file root and its state. (see FilesystemAlterationObserver)
- *
+ *
* @author tcurdt
*/
public interface FilesystemAlterationListener {
diff --git a/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationMonitor.java b/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationMonitor.java
index 6ee8f9f..6ad348b 100644
--- a/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationMonitor.java
+++ b/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationMonitor.java
@@ -28,7 +28,7 @@
/**
* It's a runnable that spawns of a monitoring thread triggering the
* the observers and managing the their listeners.
- *
+ *
* @author tcurdt
*/
public final class FilesystemAlterationMonitor implements Runnable {
@@ -37,13 +37,13 @@
private final Object observersLock = new Object();
private Map<File, FilesystemAlterationObserver> observers = Collections.unmodifiableMap(new HashMap<File, FilesystemAlterationObserver>());
-
+
/** delay between calls to {@link FilesystemAlterationObserver#checkAndNotify()}, default 3000 ms */
private volatile long delay = 3000; // volatile because shared with daemon thread
private Thread thread = null;
private volatile boolean running = true;
-
+
public FilesystemAlterationMonitor() {
}
@@ -70,7 +70,7 @@
/**
* Set the delay between calls to the observers.
- *
+ *
* @param pDelay the delay in milliseconds (default if not set 3000 ms)
*/
public void setInterval( final long pDelay ) {
@@ -95,7 +95,7 @@
observer.addListener(pListener);
}
-
+
public void removeListener( final FilesystemAlterationListener pListener ) {
synchronized (observersLock) {
for (final FilesystemAlterationObserver observer : observers.values()) {
@@ -118,7 +118,7 @@
public void run() {
log.debug("fam running");
-
+
while (running) {
for (final FilesystemAlterationObserver observer : observers.values()) {
@@ -130,7 +130,7 @@
} catch (final InterruptedException e) {
}
}
-
+
log.debug("fam exiting");
}
diff --git a/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationObserver.java b/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationObserver.java
index bfaeb82..d3af07e 100644
--- a/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationObserver.java
+++ b/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationObserver.java
@@ -23,7 +23,7 @@
* FilesystemAlterationObserver represents the state of files
* below a certain root directory. It implements the code to
* check the filesystem and notify listeners.
- *
+ *
* @author tcurdt
*/
public interface FilesystemAlterationObserver {
diff --git a/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationObserverImpl.java b/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationObserverImpl.java
index bc4dd54..9f51cc5 100644
--- a/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationObserverImpl.java
+++ b/fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationObserverImpl.java
@@ -28,13 +28,13 @@
/**
* Implementation of a FilesystemAlterationObserver
- *
+ *
* @author tcurdt
*/
public class FilesystemAlterationObserverImpl implements FilesystemAlterationObserver {
private final Log log = LogFactory.getLog(FilesystemAlterationObserverImpl.class);
-
+
private interface MonitorFile {
long lastModified();
@@ -44,7 +44,7 @@
String getName();
}
-
+
private final static class MonitorFileImpl implements MonitorFile {
private final File file;
@@ -107,8 +107,8 @@
public String getName() {
return file.getName();
}
-
-
+
+
@Override
public String toString() {
return file.toString();
@@ -176,7 +176,7 @@
return true;
} else {
// exists
- final long currentModified = file.lastModified();
+ final long currentModified = file.lastModified();
if (currentModified != lastModified) {
// last modified has changed
@@ -185,7 +185,7 @@
// log.debug(file + " has new last modified");
// types only changes when also the last modified changes
- final int newType = (file.isDirectory()?TYPE_DIRECTORY:TYPE_FILE);
+ final int newType = (file.isDirectory()?TYPE_DIRECTORY:TYPE_FILE);
if (lastType != newType) {
// the type has changed
@@ -229,7 +229,7 @@
}
}
}
-
+
public MonitorFile getFile() {
return file;
}
@@ -312,22 +312,22 @@
}
}
-
+
public void checkAndNotify() {
synchronized(listenersSet) {
if (listeners.length == 0) {
return;
}
-
+
notifyOnStart();
-
+
checkEntries();
-
+
notifyOnStop();
}
}
-
+
public File getRootDirectory() {
return rootDirectory;
}
@@ -359,6 +359,6 @@
final FilesystemAlterationListener[] res = new FilesystemAlterationListener[listeners.length];
System.arraycopy(listeners, 0, res, 0, res.length);
return res;
- }
+ }
}
}
diff --git a/fam/src/test/java/org/apache/commons/jci2/monitor/FilesystemAlterationMonitorTestCase.java b/fam/src/test/java/org/apache/commons/jci2/monitor/FilesystemAlterationMonitorTestCase.java
index 1270bcc..daff01e 100644
--- a/fam/src/test/java/org/apache/commons/jci2/monitor/FilesystemAlterationMonitorTestCase.java
+++ b/fam/src/test/java/org/apache/commons/jci2/monitor/FilesystemAlterationMonitorTestCase.java
@@ -31,7 +31,7 @@
/**
- *
+ *
* @author tcurdt
*/
public final class FilesystemAlterationMonitorTestCase extends TestCase {
@@ -43,20 +43,20 @@
private File directory;
-
+
@Override
protected void setUp() throws Exception {
directory = createTempDirectory();
assertTrue(directory.exists());
assertTrue(directory.isDirectory());
}
-
+
@Override
protected void tearDown() throws Exception {
FileUtils.deleteDirectory(directory);
}
-
-
+
+
protected File createDirectory( final String pName ) throws Exception {
final File newDirectory = new File(directory, pName);
assertTrue(newDirectory.mkdir());
@@ -64,23 +64,23 @@
assertTrue(newDirectory.isDirectory());
return newDirectory;
}
-
+
protected File writeFile( final String pName, final byte[] pData ) throws Exception {
final File file = new File(directory, pName);
final File parent = file.getParentFile();
if (!parent.mkdirs() && !parent.isDirectory()) {
throw new IOException("could not create" + parent);
}
-
+
log.debug("writing file " + pName + " (" + pData.length + " bytes)");
-
+
final FileOutputStream os = new FileOutputStream(file);
os.write(pData);
os.close();
-
+
assertTrue(file.exists());
assertTrue(file.isFile());
-
+
return file;
}
@@ -94,25 +94,25 @@
final FileWriter writer = new FileWriter(file);
writer.write(pText);
writer.close();
-
+
assertTrue(file.exists());
assertTrue(file.isFile());
-
+
return file;
}
protected File createTempDirectory() throws IOException {
final File tempFile = File.createTempFile("jci2", null);
-
+
if (!tempFile.delete()) {
throw new IOException();
}
-
+
if (!tempFile.mkdir()) {
throw new IOException();
}
-
- return tempFile;
+
+ return tempFile;
}
@@ -124,7 +124,7 @@
}
-
+
private static class MyFilesystemAlterationListener extends AbstractFilesystemAlterationListener {
}
@@ -135,21 +135,21 @@
fam.start();
listener.waitForFirstCheck();
}
-
+
private void stop() {
fam.stop();
}
-
+
public void testListenerDoublication() throws Exception {
fam = new FilesystemAlterationMonitor();
listener = new MyFilesystemAlterationListener();
-
+
fam.addListener(directory, listener);
assertEquals(1, fam.getListenersFor(directory).length);
-
- fam.addListener(directory, listener);
+
+ fam.addListener(directory, listener);
assertEquals(1, fam.getListenersFor(directory).length);
-
+
fam.removeListener(listener);
assertEquals(0, fam.getListenersFor(directory).length);
}
@@ -157,28 +157,28 @@
public void testDirectoryDoublication() throws Exception {
fam = new FilesystemAlterationMonitor();
- fam.addListener(directory, new MyFilesystemAlterationListener());
+ fam.addListener(directory, new MyFilesystemAlterationListener());
assertEquals(1, fam.getListenersFor(directory).length);
-
- fam.addListener(directory, new MyFilesystemAlterationListener());
+
+ fam.addListener(directory, new MyFilesystemAlterationListener());
assertEquals(2, fam.getListenersFor(directory).length);
}
public void testCreateFileDetection() throws Exception {
start();
-
+
writeFile("file", "file");
-
+
listener.waitForCheck();
-
+
assertEquals(1, listener.getCreatedFiles().size());
-
+
stop();
}
public void testTimeout() throws Exception {
listener = new MyFilesystemAlterationListener();
-
+
try {
listener.waitForFirstCheck();
fail("should be an timeout");
@@ -194,7 +194,7 @@
} catch(final Exception e) {
assertEquals("timeout", e.getMessage());
}
-
+
stop();
try {
@@ -203,18 +203,18 @@
} catch(final Exception e) {
assertEquals("timeout", e.getMessage());
}
-
+
}
public void testCreateDirectoryDetection() throws Exception {
start();
createDirectory("dir");
-
+
listener.waitForCheck();
-
+
assertEquals(1, listener.getCreatedDirectories().size());
-
+
stop();
}
@@ -224,20 +224,20 @@
final File file = writeFile("file", "file");
assertTrue("file should exist", file.exists());
-
+
listener.waitForCheck();
-
+
assertEquals("expecting 1 file created", 1, listener.getCreatedFiles().size());
//assertEquals("expecting 0 directories changed", 0, listener.getChangedDirectories().size()); // todo investigate why this is failing on Windows
-
+
file.delete();
assertFalse("file should not exist", file.exists());
listener.waitForCheck();
-
+
assertEquals("expecting 1 file deleted", 1, listener.getDeletedFiles().size());
-
- stop();
+
+ stop();
}
public void testDeleteDirectoryDetection() throws Exception {
start();
@@ -247,18 +247,18 @@
final File file = writeFile("dir/sub/file", "file");
listener.waitForCheck();
-
+
assertEquals(2, listener.getCreatedDirectories().size());
assertEquals(1, listener.getCreatedFiles().size());
delay();
-
+
FileUtils.deleteDirectory(dir);
assertTrue(!dir.exists());
assertTrue(!file.exists());
listener.waitForCheck();
-
+
assertEquals(2, listener.getDeletedDirectories().size());
assertEquals(1, listener.getDeletedFiles().size());
@@ -269,9 +269,9 @@
start();
writeFile("file", "file");
-
+
listener.waitForCheck();
-
+
assertEquals(1, listener.getCreatedFiles().size());
delay();
@@ -279,9 +279,9 @@
writeFile("file", "changed file");
listener.waitForCheck();
-
+
assertEquals(1, listener.getChangedFiles().size());
-
+
stop();
}
@@ -289,11 +289,11 @@
final long modified = directory.lastModified();
delay();
-
+
createDirectory("directory");
delay();
-
+
assertTrue(directory.lastModified() != modified);
}
@@ -301,7 +301,7 @@
final long modified = directory.lastModified();
delay();
-
+
writeFile("file", "file");
delay();
@@ -327,12 +327,12 @@
final long modified = directory.lastModified();
delay();
-
+
writeFile("dir/file", "file");
assertTrue(directory.lastModified() == modified);
}
-
+
public void testInterval() throws Exception {
final long interval = 1000;
@@ -345,12 +345,12 @@
listener.waitForCheck();
final long t2 = System.currentTimeMillis();
-
+
final long diff = t2-t1;
-
+
// interval should be at around the same interval
assertTrue("the interval was set to " + interval + " but the time difference was " + diff, (diff > (interval-50)) && (diff < (interval+50)));
-
+
stop();
- }
+ }
}