@the project developer: minor improvements, tidy sourcecode
Thorsten Möller <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <00ef01c3aed5$58753810$33d71e8d@Thoro> |
Hi, I've made some small improvements: 1. The thread in DefaultEventPool has now a name (useful inside debugger to identify threads). 2. ListValidator now validates any instance of java.util.List instead of only ArrayList before. Since the changes do not alter specifications (ListValidator is backward compatible) it should be no risk to apply them to the CVS head. On the attachement you will find the patches. The second thing is a "bit" more extensive ;-) First, some words about the background: I use Eclipse as my development environment. I configured the compiler settings to tell unused imports, never read variables, and so on. After I checked out the CVS head I realized that the sourcecode is full of unused imports (nearly any class), never read variables are here and there too. It would be around 5 clicks away to tidy this (Eclipse has a function "organize imports"). Also the unused variables could be comment out. But then I should have CVS commit rights to update the classes. I would be very pleased if I'am welcome as a new contributor. If you have more questions on me before, feel free to ask. For the moment I can tell just two things: "the Servlet Spec is pasted one the inside of my eyeballs" (quote which I found on Jakarta site) but my english is not the best because it's not my mother tongue. Regards, Thorsten
DefaultEventPool_patch.txt
(text/plain, 1.5 KB)
Index: DefaultEventPool.java
===================================================================
RCS file: /var/cvs/Barracuda/src/org/enhydra/barracuda/core/event/DefaultEventPool.java,v
retrieving revision 1.11
diff -u -r1.11 DefaultEventPool.java
--- DefaultEventPool.java 16 Sep 2003 22:48:09 -0000 1.11
+++ DefaultEventPool.java 19 Nov 2003 18:10:25 -0000
@@ -22,10 +22,13 @@
*/
package org.enhydra.barracuda.core.event;
-import java.util.*;
-import java.lang.reflect.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
-import org.apache.log4j.*;
+import org.apache.log4j.Logger;
/**
* This class acts as a pool for Events. Should significantly improve
@@ -92,6 +95,7 @@
//start the cleanup thread
thread = new Thread(new EventListCleanerUpper());
+ thread.setName("Barracuda event pool cleanup thread");
thread.start();
}
@@ -211,8 +215,8 @@
//wait until there's a free event. If the wait exceeds
//the timeout period, somethign is wrong so throw an exception
- long stime = System.currentTimeMillis();
- int cntr = 0;
+// never read long stime = System.currentTimeMillis();
+// never read int cntr = 0;
if (freeList.size()<1 && lockedList.size()>=poolSize) throw new NoAvailableEventsException("No available events:"+event);
//try and get the next available event
ListValidator_patch.txt
(text/plain, 2.2 KB)
Index: ListValidator.java =================================================================== RCS file: /var/cvs/Barracuda/src/org/enhydra/barracuda/core/forms/validators/ListValidator.java,v retrieving revision 1.6 diff -u -r1.6 ListValidator.java --- ListValidator.java 16 Sep 2003 22:48:09 -0000 1.6 +++ ListValidator.java 19 Nov 2003 18:17:52 -0000 @@ -22,13 +22,19 @@ */ package org.enhydra.barracuda.core.forms.validators; -import java.util.*; +import java.util.List; -import org.enhydra.barracuda.core.forms.*; -import org.enhydra.barracuda.plankton.*; +import org.enhydra.barracuda.core.forms.AbstractFormValidator; +import org.enhydra.barracuda.core.forms.DefaultFormElement; +import org.enhydra.barracuda.core.forms.FormElement; +import org.enhydra.barracuda.core.forms.FormMap; +import org.enhydra.barracuda.core.forms.FormValidator; +import org.enhydra.barracuda.core.forms.ParseException; +import org.enhydra.barracuda.core.forms.ValidationException; /** - * This validator validates all items even if OrigVal is an ArrayList + * This validator validates all items even if OrigVal is an instance of + * <code>java.util.List</code> * * @author Iman L Crawford ([email protected]) */ @@ -81,8 +87,8 @@ public void validate(FormElement element, FormMap formMap, boolean deferExceptions) throws ValidationException { if (localLogger.isDebugEnabled()) localLogger.debug("Validating one or more items"); - if (element.getOrigVal() instanceof ArrayList) { - ArrayList origList = (ArrayList)element.getOrigVal(); + if (element.getOrigVal() instanceof List) { + List origList = (List)element.getOrigVal(); for (int i = 0; i < origList.size(); i++) { FormElement newElement = this.getNewElement(i, element); @@ -106,8 +112,8 @@ */ private FormElement getNewElement(int index, FormElement element) { DefaultFormElement newElement = new DefaultFormElement(); - Object origVal = ((ArrayList)element.getOrigVal()).get(index); - Object val = ((ArrayList)element.getVal()).get(index); + Object origVal = ((List)element.getOrigVal()).get(index); + Object val = ((List)element.getVal()).get(index); newElement.setOrigVal(origVal); newElement.setVal(val);