Once upon a time we had a school project where we had to implement SIP stateful proxy. I took this serious and created rich document describing possible problems and solutions working with JainSIP for Java.
Without further adduce I present you google doc containing questions and answers.
I have also implemented SIP to XMPP gateway. If anyone is ever interested in this, feel free to contact me and I can provide you source code of my solution.