Wednesday, January 9, 2008

Sharing Session Data Across Different Webapps

I recently had an interesting task where a chunk of data had to be shared across different webapps in order for the application to do its job appropriately. The first thing that came to my mind was to implement caching and use that as the in-memory storage for storing frequently used data. By doing this we can store all the shared data and fetch it from the cache. However I was not very sure and this prompted me to have a discussion as well with couple of my friends and they felt that caching was a good idea too. They also suggested that i could also merge the other webapps into one single webapp. This was not an option as the other webapps were third party tools and the requirement was to only work on a very small portion of the third party tools.

If you guys have done it differently or have a better idea do let me know!! Another way of sharing session data is to add crossContext="true" to the context.xml in Tomcat which would allow you to access another context from a given context. The ServletContext would then be used as the in-memory storage for frequently used data. However if this approach is taken one would need to implement thread safety properly. Also according to the Servlet Specification Session is scoped to a ServletContext and ServletContext is per webapp and it is an in-memory or an object container if you like for the owning webapp. Hence this is a bad practice and probably not the best approach.

Swift Domain Name Search

Here is a link http://www.swiftdomainsearch.com I found on the web to quickly find out what domain names are available. It does a pretty neat job if it as well. Try it out in your spare time and let me know what you guys think of it as well.

Tuesday, January 8, 2008

Thoughtworks Geek Night Gaming Event

Thoughtworks has organized a gaming event for all you gamers out there. If you guys are interested in playing some really cool games then go ahead and register yourselves for this event. This event is being held in the pune office. For those of you who have not heard about Thoughtworks before here is the url to the company website. http://www.thoughtworks.com/




For more info click on the link below :-

http://groups.google.com/group/ThoughtWorks-Bangalore-Geek-Nights/browse_thread/thread/47c6d6db93c39cd4?hl=en

Thursday, January 3, 2008

Defining Interfaces Java

Below are the two variants of defining and declaring an identical interface. The interface is essentially the same but only differs in the way it is coded.

Snippet-1
------------

public interface UserManager {

public abstract void addUser(User user);

public abstract void removeUser(User user);

//blah blah

}

Snippet-2
------------

public interface UserManager {

void addUser(User user);

void removeUser(User user);

//blah blah

}

Snippet-1 is more detailed or explicit in terms of access specifiers whereas Snippet -2 is implicit in terms of access specifiers. Now the question to be asked here is how should we define interfaces in our code. I did look at the Java Coding standards and there was nothing much I could find over there.

Essentially even though they differ in the way it is coded the access specifiers are public and abstract implicitly even if you dont specify them explicitly according to the Java Language Specification. In my opinion I think its good practice and more clear if you define interfaces and its methods explicity the way its done in Snippet-1 as opposed to Snippet-2. What does the readers of my blog have to say about this? Please share your opinions about the same!!