hasan's blog (বল্গ)

work for fun!!!

Archive for the ‘Java’ Category

test first development, does it run fast on ruby on rails or java environment?

leave a comment »

i have been practicing test first development (from TDD) approach for last 1.5 years. i wrote a lot of junit test cases and wrote a lot of jmock based mock objects. it was amazing work with it these tools. specially jmock was fantastics and my most favorite mocking tool.

anyway, while i seriously started ruby on rails it is about 2/3 months ago, when i formed my own rails team and started working on first commercial rails project.

at the beginning i was working on IntelliJ IDEA 6M2 on windows environment, where i found running runit test cases are taking longer than we suppose to expect. it was really annoying.

good luck i got my mac book pro where i set up all rails stuff with IntelliJ IDEA 6M2. now i could see a lot more significant difference. now i am really feeling my test environment for rails project over this environment is running more than i expected. it really leads me to belief test driven approach over rails environment is really fast.

it must be some platform related significant changes, which only the expert on that platform can assure me.

by the way, i am really loving intelliJ IDEA and rails over my mac environment.

Written by nhm tanveer hossain khan

October 14, 2007 at 12:53 pm

setup maven on mac

leave a comment »

indeed nothing is special, but this post is about to remind me about the steps i followed to get my mac box with maven and jdk 1.5.

my requirements -

1. maven – 2.0.7
2. jdk 1.5
3. set maven bin to PATH variable.

i had 10.4.10 osx version.

to configure jdk 1.5 (jdk 1.4 is set as default jdk):

cd /System/Library/Frameworks/JavaVM.framework/Versions
sudo rm CurrentJDK
sudo ln -s 1.5 CurrentJDK

to configure maven:

download maven binaries, copy it in your preferred location.
in my case i had it in – /Applications/java/maven-2.0.7/bin/ here.

execute following line -

vi ~/.bash_profile

change PATH with following value -

PATH=/usr/local/bin:/Applications/java/maven-2.0.7/bin/:$PATH

test your configuration -

java -version
it should say – java version “1.5.0_0x”
mvn -version
it should say – Maven version: 2.0.7

thats all will make your maven and jdk 1.5 environment up and running.

Written by nhm tanveer hossain khan

October 14, 2007 at 12:31 am

IntelliJ IDEA and ruby plugin

leave a comment »

i belief, i should share this story, once i heard about apatana (eclipse based) ruby IDE i gave it a try without being late, later i heard Net beans got ruby supported, again i wasn’t late and gave it a try.

as you know, i am java developer, always like java stuff everywhere (if possible). anyway, later i returned to my favorite IDE IntelliJ idea.

my personal judgement in terms of usable and flexibility i must say, intelliJ idea with ruby plugin just rocks!!
currently i am developing a active record kind of things where i am using java based repository model in back end and my restful web service clients are developed on ruby.

i am pleased with intelliJ idea, as because the ruby plugin is too friendly, though i faced lot of internal code hints related problem, but i could see those problems were fixed on new release.

here is the ruby plugin details page

Written by nhm tanveer hossain khan

September 1, 2007 at 11:12 pm

Posted in Introduction, Java, Ruby

It seems LinkedIn moved on tomcat !

with one comment

after a long while i got myself on linked in site, as i got “Server spy” installed on my firefox browser, so i was getting the server name from the browser status menu.

anyway, today i found something different, actually “Server spy” said, linked in is using “Apache-Coyote/1.1″, as far i can remind, linked in was using sun application server previously.

i think it is really interesting, what led linked in to move over tomcat backed or tomcat based servlet container instead of sun application server?

anyway, if i find any info i would love to feed my blog :)

Written by nhm tanveer hossain khan

August 21, 2007 at 10:41 pm

Posted in Introduction, Java, server

Performance issue with tomcat 5.x.x series

with one comment

one of our escenic colleagues (Simen L. Haagenrud) just noticed a bottleneck with tomcat 5.x.x series containers. so we had a details digging to let find the reason.

as he mentioned it was because of recurring invocation of “getAttribute”, and tomcat 5.x.x series is using synchornization block inside “getAttribute” method, where lock is kept on “attributes” variable.
so i had a quick look on the source code of the 3 recent series -

1. 5.0.28
http://svn.apache.org/repos/asf/tomcat/container/tags/tc5.0.x/TOMCAT_5_0_28/catalina/src/share/org/apache/catalina/core/ApplicationContext.java

2. 5.5.24 (the last version from 5.5.x series)
http://svn.apache.org/repos/asf/tomcat/container/tags/tc5.5.x/TOMCAT_5_5_24/catalina/src/share/org/apache/catalina/core/ApplicationContext.java

3. 6.0.x (trunk)
http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java

so the code says 6.0.x series came with the fixes, the fix is the replacement of HashMap with ConcurrentHashMap.

in his case, recurring invocation of “getAttribute” was nearly reduced 50% server request handling capability.
best wishes,

Written by nhm tanveer hossain khan

August 6, 2007 at 8:36 am

Posted in Fix, Java, java ee, server, tomcat

AsyncServlet (JSR-315) proposed by Greg

leave a comment »

Ajax based application is growing too fast, many frequent requests have to handle by application servers. this overhead is really one of the big concern to maintain ajax based application.

more over reading the instance reply is one of the biggest challenge. as all requests are asychronizely processed, so ajax based application send request to application server more frequent that it actually needs.

the good example can be a chat application or a system where we have frequent request to sync with our messaging or notification service.

thats what greg pointed to the JSR 315 proposal. if you already have heard about continuation i belief you have find some use case for using on your own ajax application.

the basic process in continuation is to send delay response. for example -

i had a ajax request, which is intended for receiving a bunch of incoming message from my application server. so my request won’t get disconnected unless they really have some data to notify me. in between this time my request thread will be in suspended mode. obviously you can apply certain timeout period.

following diagram show how a request cycle works -

http_contd_1

the following part shows the event model, which is used to wake up suspended request before it becomes dead and time out request.

http_contd_2

best wishes,

Written by nhm tanveer hossain khan

July 28, 2007 at 1:50 am

Delegation design pattern

with one comment

at our company (escenic bangladesh), we have some group learning process. learning or grilling design pattern is one of them.

last couple of weeks we had a lot of presentations on lot of design patterns.

today was my turn, i had the presentation on “Delegation pattern”, i have attached my slide with my blog post. hope you will enjoy.
presentation on delegation

screen1

best wishes,

Written by nhm tanveer hossain khan

July 19, 2007 at 12:10 am

Posted in Java, design pattern

My first impression “WoW!!”

with 5 comments

As you knew from my last post, you can guess where i was stucking for several days, yea, it was all about determining right jabber server. the pleasant news is i gotta out of my headache after getting in touch with openfire.

openfire is one of those rear projects which made me feel “Wow” on the first run.

as i have mentioned on my last post, i was seeking some way to intercept registration, authentication and authorization process. at least i could came up a solution.

openfire plugin architecture is very simple and much more agile. i have attached my first quick diarty java code which helped me to descide whether i should go with openfire or not.

i must congrats my honored reader and brother, mr. mozammel haque who helped me to find out this outstanding server.

my first experiment was just hooked itself with user registration event dispatcher, when someone register i get the notification and write down to a file which is hard coded to c:/out.txt

this was just 5 to 10 mins preparation to let’s dig inside the plugin architecture.

global-profile.zip

download instruction -

just download the “*.zip” file and extract to your “openfire/plugins/” directory. a new “global-profile.jar” will be created.

let’s look inside the code which made it possible to be notified during user registration process. source is bundled with in “src/” directory.
best wishes,

Written by nhm tanveer hossain khan

July 16, 2007 at 11:33 pm

Posted in Java, Java SE, jabber

Struggling with open source jabber server

with one comment

My on going project is based on jabber server. i was expecting following features from an open source jabber server implementation -

* Authentication, Authorization  and registration service must be taken from 3rd party. (here i am 3rd party)

* P2P and Group chatting

* HTTP Polling support (optionally  HTTP Binding support)

* Very scalable

* Very flexible user customization

* group messaging subscription

* group moderation role

also following features –  

* none blocking i/o

* optionally java based

* cluster support

thats all.

so after passing some hard time, i fought with “ejabberd”, the ERLang based jabber daemon. i must say this is the best open source implementation. (i didn’t test openfire).

the author really gave a lot of effort. i had a very bad time tough, i tried to invoke external authentication system. but i found php script but i couldn’t able to make it work.

anyway, still it didn’t full fill my requirement, i want to manage user A and A and Registration from my service.

secondly i gave a try Open-im, i show the source code and stuff, my first impression was very bad, i found it was stucking with an infinite loop. later traversing inside the code i found, it was because of the SSL socket initialization related code. code was seeking certificate to initiate a SSL socket. since i didn’t put any certificate it not suppose to do it.

anyway, after working with it i found, it is not complete even code were poorly written.

later i gave a try tigase, it seems very nice and very well written server. still i need my whole control over AA and Registration.

after stucking a lot, i am now cncerntrating on open-im, i am thinking to contribute on this project. first i will implement the following features -

1. move to spring framework

2. Refactor code base
2. move authentication based on JAAS

3. Support 3rd party profile service

4. Support none blocking I/O api

5. Support HTTP Pooling based on servlet container
thats all for now beside my other stuffs from my current project.

Written by nhm tanveer hossain khan

July 13, 2007 at 8:43 am

springmodule – lucene

with one comment

i was using lucene for indexing my textual content, when i removed all of my index files, i have been introduced with a strange “LuceneIndexAccessException(The index is locked)” exception. though my whole directory was empty. it was not suppose to show this kind of exception.
anyway, later i found there is a  property called “resolveLock” which is required to enable auto lock resolve option.

hope this will help to those who face such problem.

best wishes,

Written by nhm tanveer hossain khan

July 8, 2007 at 4:41 pm

Posted in Java, lucene