From: Erik Brakkee Date: Thu, 22 Jul 2010 11:53:47 +0000 (+0000) Subject: (no commit message) X-Git-Tag: wamblee-utils-0.7~221 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=e72743b6a9fac5a99b842f92b1687fba65ef3210;p=utils --- diff --git a/support/general/pom.xml b/support/general/pom.xml index 36e1e5a6..367da6e5 100644 --- a/support/general/pom.xml +++ b/support/general/pom.xml @@ -44,14 +44,17 @@ dom4j dom4j + true net.sf.ehcache ehcache + true jaxen jaxen + true diff --git a/support/general/src/main/java/org/wamblee/io/DirectoryMonitor.java b/support/general/src/main/java/org/wamblee/io/DirectoryMonitor.java index 13181975..a258f098 100644 --- a/support/general/src/main/java/org/wamblee/io/DirectoryMonitor.java +++ b/support/general/src/main/java/org/wamblee/io/DirectoryMonitor.java @@ -15,8 +15,6 @@ */ package org.wamblee.io; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import java.io.File; import java.io.FileFilter; @@ -26,6 +24,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.logging.Logger; /** * Monitors a directory for changes. @@ -35,7 +34,7 @@ import java.util.Set; * @author Erik Brakkee */ public class DirectoryMonitor { - private static final Log LOG = LogFactory.getLog(DirectoryMonitor.class); + private static final Logger LOG = Logger.getLogger(DirectoryMonitor.class.getName()); private File directory; @@ -70,7 +69,7 @@ public class DirectoryMonitor { * for the same changes. */ public void poll() { - LOG.debug("Polling " + directory); + LOG.fine("Polling " + directory); Map newContents = new HashMap(); File[] files = directory.listFiles(filter); diff --git a/support/general/src/main/java/org/wamblee/io/SimpleProcess.java b/support/general/src/main/java/org/wamblee/io/SimpleProcess.java index 5e18b16c..c08f001d 100644 --- a/support/general/src/main/java/org/wamblee/io/SimpleProcess.java +++ b/support/general/src/main/java/org/wamblee/io/SimpleProcess.java @@ -23,9 +23,8 @@ import java.io.InputStreamReader; import java.io.StringWriter; import java.io.Writer; import java.util.Arrays; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import java.util.logging.Level; +import java.util.logging.Logger; /** * @@ -33,7 +32,7 @@ import org.apache.commons.logging.LogFactory; * @version $Revision$ */ public class SimpleProcess { - private static final Log LOG = LogFactory.getLog(SimpleProcess.class); + private static final Logger LOG = Logger.getLogger(SimpleProcess.class.getName()); private File directory; @@ -88,7 +87,7 @@ public class SimpleProcess { fullcmd.append(" " + part); } - LOG.debug("Executing '" + fullcmd + "' in directory '" + directory + + LOG.fine("Executing '" + fullcmd + "' in directory '" + directory + "'"); java.lang.Process proc = Runtime.getRuntime().exec(cmd, null, @@ -119,9 +118,9 @@ public class SimpleProcess { stderr = myStderr.toString(); if (proc.exitValue() != 0) { - LOG.warn("Exit value was non-zero: " + this); + LOG.warning("Exit value was non-zero: " + this); } else { - LOG.debug("Process finished"); + LOG.fine("Process finished"); } return proc.exitValue(); @@ -138,8 +137,8 @@ public class SimpleProcess { aReaderThread.join(); } catch (InterruptedException e) { LOG - .warn(this + - ": error waiting for output stream reader of process to finish"); + .log(Level.WARNING, this + + ": error waiting for output stream reader of process to finish", e); } } @@ -156,18 +155,18 @@ public class SimpleProcess { String str; while ((str = br.readLine()) != null) { - LOG.debug(aPrefix + str); + LOG.fine(aPrefix + str); aOutput.write(str); } } catch (IOException e) { - LOG.warn(SimpleProcess.this + + LOG.log(Level.FINE, SimpleProcess.this + ": error reading input stream", e); } finally { if (br != null) { try { br.close(); } catch (IOException e) { - LOG.warn("Error closing stream " + aPrefix); + LOG.log(Level.WARNING, "Error closing stream " + aPrefix, e); } } } diff --git a/support/general/src/main/java/org/wamblee/ioc/BeanKernel.java b/support/general/src/main/java/org/wamblee/ioc/BeanKernel.java index 3118b5d5..54f7b3f3 100644 --- a/support/general/src/main/java/org/wamblee/ioc/BeanKernel.java +++ b/support/general/src/main/java/org/wamblee/ioc/BeanKernel.java @@ -12,12 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.ioc; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import org.wamblee.io.ClassPathResource; import org.wamblee.io.InputResource; @@ -25,6 +22,8 @@ import java.io.IOException; import java.io.InputStream; import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; /** * The standard means to obtain the bean factory. This works by reading a @@ -34,7 +33,8 @@ import java.util.Properties; * a no-arg constructor. */ public final class BeanKernel { - private static final Log LOG = LogFactory.getLog(BeanKernel.class); + private static final Logger LOG = Logger.getLogger(BeanKernel.class + .getName()); /** * Bean factory kernel properties file. @@ -120,7 +120,7 @@ public final class BeanKernel { is.close(); } catch (IOException e) { // last resort cannot do much now. - LOG.error("Error closing resource " + resource); + LOG.log(Level.WARNING, "Error closing resource " + resource, e); } } } diff --git a/support/general/src/main/java/org/wamblee/persistence/JpaMergeSupport.java b/support/general/src/main/java/org/wamblee/persistence/JpaMergeSupport.java index 4254dad6..5105d767 100644 --- a/support/general/src/main/java/org/wamblee/persistence/JpaMergeSupport.java +++ b/support/general/src/main/java/org/wamblee/persistence/JpaMergeSupport.java @@ -24,11 +24,10 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.Map.Entry; +import java.util.logging.Logger; import javax.persistence.EntityManager; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.wamblee.reflection.ReflectionUtils; /** @@ -54,7 +53,7 @@ import org.wamblee.reflection.ReflectionUtils; * @author Erik Brakkee */ public class JpaMergeSupport { - private static final Log LOG = LogFactory.getLog(JpaMergeSupport.class); + private static final Logger LOG = Logger.getLogger(JpaMergeSupport.class.getName()); /** * Constructs the object. @@ -112,7 +111,7 @@ public class JpaMergeSupport { aProcessed.add(elem); - LOG.debug("Setting pk/version on " + aPersistent + " from " + aMerged); + LOG.fine("Setting pk/version on " + aPersistent + " from " + aMerged); Persistent persistentWrapper = PersistentFactory.create(aPersistent); Persistent mergedWrapper = PersistentFactory.create(aMerged); diff --git a/support/general/src/main/java/org/wamblee/xml/DomUtils.java b/support/general/src/main/java/org/wamblee/xml/DomUtils.java index 356fd342..8c8128c4 100644 --- a/support/general/src/main/java/org/wamblee/xml/DomUtils.java +++ b/support/general/src/main/java/org/wamblee/xml/DomUtils.java @@ -15,9 +15,6 @@ */ package org.wamblee.xml; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.XMLSerializer; @@ -45,6 +42,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; @@ -60,7 +59,7 @@ import javax.xml.validation.SchemaFactory; * @author Erik Brakkee */ public final class DomUtils { - private static final Log LOG = LogFactory.getLog(DomUtils.class); + private static final Logger LOG = Logger.getLogger(DomUtils.class.getName()); /** * Disabled default constructor. @@ -110,7 +109,7 @@ public final class DomUtils { try { aIs.close(); } catch (Exception e) { - LOG.warn("Error closing XML file", e); + LOG.log(Level.WARNING, "Error closing XML file", e); } } } @@ -150,13 +149,13 @@ public final class DomUtils { try { aSchema.close(); } catch (Exception e) { - LOG.warn("Error closing schema", e); + LOG.log(Level.WARNING, "Error closing schema", e); } try { aIs.close(); } catch (Exception e) { - LOG.warn("Error closing XML file", e); + LOG.log(Level.WARNING, "Error closing XML file", e); } } } diff --git a/support/general/src/site/xdoc/index.xml b/support/general/src/site/xdoc/index.xml index e6056775..0d0bd3ea 100644 --- a/support/general/src/site/xdoc/index.xml +++ b/support/general/src/site/xdoc/index.xml @@ -28,6 +28,7 @@
+

The following maven dependency must be used:

@@ -38,6 +39,26 @@
groupIdwamblee-support-general
+

In addition there are optional dependencies on the following maven artifacts that need only + be used when Dom4j or EhCache utlities are used:

+ + + + + + + + + + + + + + + + + +
groupIdartifactId
dom4jdom4j
jaxenjaxen
net.sf.ehcacheehcache
diff --git a/support/general/src/test/java/org/wamblee/io/FileSystemUtils.java b/support/general/src/test/java/org/wamblee/io/FileSystemUtils.java index 4be787e7..7145c7f8 100644 --- a/support/general/src/test/java/org/wamblee/io/FileSystemUtils.java +++ b/support/general/src/test/java/org/wamblee/io/FileSystemUtils.java @@ -15,12 +15,6 @@ */ package org.wamblee.io; -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -28,14 +22,16 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; - import java.net.URL; import java.net.URLDecoder; - import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; - import java.security.CodeSource; +import java.util.logging.Level; +import java.util.logging.Logger; + +import junit.framework.Assert; +import junit.framework.TestCase; /** * File system utilities. @@ -43,7 +39,7 @@ import java.security.CodeSource; * @author Erik Brakkee */ public final class FileSystemUtils { - private static final Log LOG = LogFactory.getLog(FileSystemUtils.class); + private static final Logger LOG = Logger.getLogger(FileSystemUtils.class.getName()); /** * Test output directory relative to the sub project. @@ -119,7 +115,7 @@ public final class FileSystemUtils { CodeSource source = aTestClass.getProtectionDomain().getCodeSource(); if (source == null) { - LOG.warn("Could not obtain path for '" + aRelativePath + + LOG.warning("Could not obtain path for '" + aRelativePath + "' for class " + aTestClass + ", using relative path as is"); return new File(aRelativePath); @@ -129,7 +125,7 @@ public final class FileSystemUtils { String protocol = location.getProtocol(); if (!protocol.equals("file")) { - LOG.warn("protocol is not 'file': " + location); + LOG.warning("protocol is not 'file': " + location); return new File(aRelativePath); } @@ -140,7 +136,7 @@ public final class FileSystemUtils { path = URLDecoder.decode(location.getPath(), "UTF-8"); } catch (UnsupportedEncodingException e) { // ignore it.. just don't decode - LOG.warn("Decoding path failed: '" + location.getPath() + "'", e); + LOG.log(Level.WARNING, "Decoding path failed: '" + location.getPath() + "'", e); } return new File(new File(path).getParentFile(), aRelativePath); diff --git a/support/general/src/test/java/org/wamblee/test/AssertionUtils.java b/support/general/src/test/java/org/wamblee/test/AssertionUtils.java index 9c211b7a..b23eee93 100644 --- a/support/general/src/test/java/org/wamblee/test/AssertionUtils.java +++ b/support/general/src/test/java/org/wamblee/test/AssertionUtils.java @@ -19,19 +19,17 @@ import java.util.Arrays; import java.util.Map; import java.util.Set; import java.util.Map.Entry; +import java.util.logging.Logger; import junit.framework.TestCase; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** * Useful assertions for use in test cases. * * @author Erik Brakkee */ public final class AssertionUtils { - private static final Log LOG = LogFactory.getLog(AssertionUtils.class); + private static final Logger LOG = Logger.getLogger(AssertionUtils.class.getName()); /** * Disabled constructor. diff --git a/support/general/src/test/java/org/wamblee/test/EventTracker.java b/support/general/src/test/java/org/wamblee/test/EventTracker.java index e66d0147..c2b18f6d 100644 --- a/support/general/src/test/java/org/wamblee/test/EventTracker.java +++ b/support/general/src/test/java/org/wamblee/test/EventTracker.java @@ -15,14 +15,12 @@ */ package org.wamblee.test; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.logging.Logger; /** * Tracks the occurence of certain events in a test environment. Threads in a @@ -41,7 +39,7 @@ import java.util.Map; * @author Erik Brakkee */ public class EventTracker { - private static final Log LOG = LogFactory.getLog(EventTracker.class); + private static final Logger LOG = Logger.getLogger(EventTracker.class.getName()); /** * Map of Thread object to a list of events.