<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
+ <optional>true</optional>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
+ <optional>true</optional>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
+ <optional>true</optional>
</dependency>
</dependencies>
*/
package org.wamblee.io;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import java.io.File;
import java.io.FileFilter;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.logging.Logger;
/**
* Monitors a directory for changes.
* @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;
* for the same changes.
*/
public void poll() {
- LOG.debug("Polling " + directory);
+ LOG.fine("Polling " + directory);
Map<File, Date> newContents = new HashMap<File, Date>();
File[] files = directory.listFiles(filter);
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;
/**
*
* @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;
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,
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();
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);
}
}
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);
}
}
}
* 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;
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
* 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.
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);
}
}
}
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;
/**
* @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.
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);
*/
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;
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;
* @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.
try {
aIs.close();
} catch (Exception e) {
- LOG.warn("Error closing XML file", e);
+ LOG.log(Level.WARNING, "Error closing XML file", e);
}
}
}
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);
}
}
}
</section>
<section name="Maven POM configuration">
+ <p>The following maven dependency must be used:</p>
<table>
<tr>
<th>groupId</th>
<td>wamblee-support-general</td>
</tr>
</table>
+ <p>In addition there are optional dependencies on the following maven artifacts that need only
+ be used when Dom4j or EhCache utlities are used: </p>
+ <table>
+ <tr>
+ <th>groupId</th>
+ <th>artifactId</th>
+ </tr>
+ <tr>
+ <td>dom4j</td>
+ <td>dom4j</td>
+ </tr>
+ <tr>
+ <td>jaxen</td>
+ <td>jaxen</td>
+ </tr>
+ <tr>
+ <td>net.sf.ehcache</td>
+ <td>ehcache</td>
+ </tr>
+ </table>
</section>
</body>
*/
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;
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.
* @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.
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);
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);
}
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);
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.
*/
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
* @author Erik Brakkee
*/
public class EventTracker<Event> {
- 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.