Monday, September 21, 2009

Loading Message Resources From Database

Instead of loading message resource from properties file, here is the code to how to use database as a message resource bundle in struts applcation.

public class DBPropertyMessageResources extends MessageResources {

public DBPropertyMessageResources(MessageResourcesFactory factory, String config,boolean returnNull) {

super(factory, config,returnNull);





public String getMessage(Locale locale, String key) {

String result = DBPropertyMessageService.getMessage(locale, key,


// we need to flush the cache of the super class MessageResource as

//we want to have real dynamic data here (no caches

//except the one in DBPropertyMessageService)


return result;



public class DBPropertyMessageResourcesFactory extends

MessageResourcesFactory {

public MessageResources createResources(String config) {

return new DBPropertyMessageResources(this, config, this.returnNull);



public class DBPropertyMessageService {

public static String getMessage(Locale locale, String key, boolean returnNull) {




// do the jdbc coding to get the value from the database using the key

return "sparkle software";




<message-resources factory="com.sparkle.resources.DBPropertyMessageResourcesFactory" parameter="param1"/>

Sunday, September 6, 2009

Search Engine for API Search

When I was doing research this morning, I came to know that there is a search engine for API search called They have got all kinds of api search like java, database, ajax, frameworks etc. And now, they have launched new beta version of this have got lot of new features and included more api's. It will be helpful for developers, so I thought of writing this post.

Friday, September 4, 2009

Java Magic Number

A numerical identifier for the class file. It should always be CAFEBABE, in hex, stored in the first 4 bytes of the class file. The easiest way to corrupt a class file’s magic number is to upload it to your website with FTP failing to turn on the binary option

Sometimes during the transmission of files, the connection may be aborted, or may be scrambled, causing class loading to fail. Sometimes when copying files over to a web server, they may become garbled or a disk error might occur. For this reason, special care is taken by the JVM and the class loader, to verify that classes are intact. One of the precautions is that every class definition contains at the beginning the magic number, a sequence of four bytes that identify a file as a Java class definition file.

Yahoo meme

Yahoo launches a microblogging platform which looks like twitter. Now in English version of Yahoo meme