Jan 03
A lot of times I need to load data from configuration files which are supposed to be on the classpath. I also find the need to often change the configuration files for a variety of unit tests. Here’s a useful trick I borrowed and restructured from Sun Java Forum Thread Java Runtime Environment (JRE) - Modify Classpath At Runtime
The following is a Utility class with a static method that gets a class name. In this particular case the assumption is that the directory that needs to be added is same as that in which the class resides (Not necessarily always true - but its a convention I like and have adopted)
public class TestUtils
{
public static void addURL(Class<?> clazz)
{
try
{
URLClassLoader sysloader = (URLClassLoader) ClassLoader
.getSystemClassLoader();
Class<URLClassLoader> sysclass = URLClassLoader.class;
String path = sysloader.getResource(
clazz.getCanonicalName().replace('.', '/') + ".class")
.getPath();
int lastSlash = path.lastIndexOf('/');
path = path.substring(0, lastSlash+1);
URL url = new URL("file://" + path);
Method method = sysclass.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);
method.invoke(sysloader, new Object[] { url });
}
catch (Throwable t)
{
t.printStackTrace();
}
}
}
Continue reading »
Jan 03
Google set off this new term knol (unless it has been around before and I am not aware of it) in this blog post .
First of all the screenshot is both attractive and impressive. While this has more to do with the folks who created it rather than the concept of a knol, it sure seems like a screen design worthy to take on Wikipedia .
As an aside seems to be that four letter words are rather becoming the in thing in the recent contribution to english language : blog, wiki, and now knol.
There’s already some speculation out there whether this will mean a google taking on wikipedia, about , or a whole host of other sites that are being talked about.. I don’t intend to speculate on that here. One of the apparently salient points about a knol is the fact that each knol is authored or primarily edited by one person, whose information is boldly displayed.
There are cases where content needs to be personalised and others when it needs to primarily collaborative. Wikipedia and many community maintained wikis are a great example of collaborative content, whereas blogs under most circumstances offer very personalised (ie. individually authored – not individually tailored) content. This is a reflection of whether the content needs to be a community or an individual view.
Another dimension is the targeted persistence duration of the content. A blog posting like this may be far less relevant a year down the road, than say an article that I write on this blog.
Wiki or Knol
Continue reading »
Jan 03
My earlier blog is now offline. However I had consolidated some of the content in there and written this article. Thought it might be helpful to link to the article A beginners guide to Dependency Injection from this blog.
Jan 03
Here’s a nice error message I ran across
