<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss'><id>tag:blogger.com,1999:blog-4667121987470696359</id><updated>2009-11-06T20:01:14.223-07:00</updated><title type='text'>Sleepless in Salt Lake City</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default?start-index=26&amp;max-results=25'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>85</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-2671403880607569971</id><published>2009-11-02T19:15:00.002-07:00</published><updated>2009-11-06T20:01:14.237-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Bheeshma'/><category scheme='http://www.blogger.com/atom/ns#' term='Karna'/><category scheme='http://www.blogger.com/atom/ns#' term='Mahabharata'/><category scheme='http://www.blogger.com/atom/ns#' term='Drona'/><category scheme='http://www.blogger.com/atom/ns#' term='Archers of the Mahabharata'/><category scheme='http://www.blogger.com/atom/ns#' term='Arjuna'/><title type='text'>Mahabharata- a tribute to my favorite archers</title><content type='html'>&lt;div&gt;&lt;a href="http://en.wikipedia.org/wiki/Mahabharata"&gt;Mahabharata &lt;/a&gt;is one of the two great Indian Epics with the Ramayana being the other. I remember when in school and my history teacher asked "&lt;em&gt;Name the two world famous Epics&lt;/em&gt;" and I jumped to state "&lt;em&gt;The Ramayana and the Mahabharata&lt;/em&gt;". She corrected me by stating the the two world famous epics are the &lt;a href="http://en.wikipedia.org/wiki/Iliad"&gt;Illiad&lt;/a&gt; and the &lt;a href="http://en.wikipedia.org/wiki/Odyssey"&gt;Odyssey&lt;/a&gt;. Never the less, I think of the Mahabharata as a definite leader when it comes to Epics. I could go on describing the Mahabharata but that would be more than one blog :-).&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;The author of the Mahabharata epic was &lt;a href="http://en.wikipedia.org/wiki/Vyasa"&gt;Veda Vyasa&lt;/a&gt;.  Due to its voluminous and complex nature, it was impossible for any mortal to be able to scribe the epic. For this reason, the Vyasa approached &lt;a href="http://en.wikipedia.org/wiki/Ganesha"&gt;Lord Ganesha&lt;/a&gt; to assist with the same. Lord Ganesha, although agreed to do the same, had a condition that the entire epic must be dictated to him without a pause from the Vyasa and if the Vyasa did pause, then the epic would not be completed. The Vyasa in turn put forth a condition that Lord Ganesha would only write down a verse after understanding the meaning of it. This condition allowed the Vyasa some breathing room during the recitation.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.goelweb.com/diversions/mahabharat/mbharat01a.jpg"&gt;&lt;img style="cursor: pointer; width: 350px; height: 307px;" src="http://www.goelweb.com/diversions/mahabharat/mbharat01a.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The Mahabharata involves a classic battle between cousins on the fields of &lt;a href="http://en.wikipedia.org/wiki/Kurukshetra"&gt;Kurukshetra&lt;/a&gt;. A standard good versus evil scenario. On once side, there were the &lt;a href="http://en.wikipedia.org/wiki/Pandavas"&gt;Pandavas &lt;/a&gt;, and on the other, the &lt;a href="http://en.wikipedia.org/wiki/Kauravas"&gt;Kauravas&lt;/a&gt;. The Pandavas, can be considered the good and righteous guys of the epic while the Kauravas represented the exact opposite.&lt;br /&gt;&lt;br /&gt;I still remember the time growing up in India when a televised serial on the Mahabharata would play every Sunday afternoon.  The entire city would almost come to a standstill with everyone glued on the set. This was a SOAP opera, Action flick, romance, sex, polygamy all combined into one. Aah what memories :-)&lt;br /&gt;&lt;br /&gt;Anyway, in the Mahabharata, there were multiple valorous warriors, each skilled in different arts of combat.  There were supreme archers such as &lt;a href="http://en.wikipedia.org/wiki/Bhishma"&gt;Bheeshma&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Drona"&gt;Drona&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Karna"&gt;Karna&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Arjuna"&gt;Arjuna &lt;/a&gt;and &lt;a href="http://en.wikipedia.org/wiki/Ekalavya"&gt;Ekalavya&lt;/a&gt;. The popular vote regarding the best archer of the time would lean toward Arjuna, the son of Kunti and &lt;a href="http://en.wikipedia.org/wiki/Indra"&gt;Indra (The Indian Zeus)&lt;/a&gt;.  My primary focus is on the archers in this blog. Each of them have an Achilles heel that they cannot hide.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;&lt;a href="http://en.wikipedia.org/wiki/Bhishma"&gt;Bheeshma&lt;/a&gt;&lt;/span&gt;:&lt;/strong&gt; Bheeshma was a student of &lt;a href="http://en.wikipedia.org/wiki/Parashurama"&gt;Parashurama&lt;/a&gt;.  Bheeshma was granted a boon from his father on when he could die. Here was a man, who was a grand uncle to the warring cousins, the Pandavas and Kauravas. He loved them both, but forced by duty, was forced to fight on the side of the Kauravas. A major warrior considering his age when he fought in the Kurukshetra A restrained and troubled man, he did not use his total abilities when fighting the Pandavas as they were his kith and kin after all.  It is probable that Bheeshma was not the best archer of the land. However, vanquishing him would have been impossible by anyone as he just cannot die unless he choose to.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Death of Bheeshma:&lt;/span&gt;&lt;br /&gt;During the Kurukshetra battle Bheeshma was unstoppable, he was terror incarnate as he slaughtered the Pandava forces. Bheesma's Achilles heel was that he also was cursed that his death would be finally at the hands of a Eunuch. That Eunuch was &lt;a href="http://en.wikipedia.org/wiki/Shikhandi"&gt;Shikandi&lt;/a&gt;. Bheeshma had a policy wherein he would never fire his weapons on a woman and Shikandi bordered on the same. Although, Shikandi could never fire the weapons to kill the grand sire, Arjuna firing from behind Shikandi using Shikandi as a shield could easily hurt Bheeshma. And that is exactly what happened in the Kurukshetra war where Arjuna firing from behind Shikandi downed the grand sire with a bevy of arrows.&lt;br /&gt;&lt;br /&gt;In conclusion, if the grand sire had no weakness as mentioned above, the Pandava army would have been vanquished. There is one point to mention that Arjuna had sent the Grand sire packing during the battle when Arjuna was masquerading as a eunuch., i.e., the battle for Virata's kingdom. However, could that victory have been Arjuna's if the sire had chosen to fire on the Eunuch? During the Kurukshetra war, Bheesma would at many a time torment Arjuna with his fine tuned arrows. Arjuna would hesitate to fire on his grand uncle and that irked Lord Krishna (Arjuna's charioteer) who although had sworn to not fight in the Kuruskshetra war decided to attack Bheeshma himself. It is only after Arjuna swore to kill the grand sire did Krishna's wrath get appeased. A classic picture I found of the same with Krishna attacking the Grand Sire with a chariot wheel with Arjuna restraining him:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://shootfighter.files.wordpress.com/2009/05/bheeshma.jpg"&gt;&lt;img style="cursor: pointer; width: 800px; height: 600px;" src="http://shootfighter.files.wordpress.com/2009/05/bheeshma.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Archery Skills&lt;/span&gt; : 8&lt;div&gt;&lt;span style="font-weight: bold;"&gt;Character&lt;/span&gt;: 10&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;Achilles Heel&lt;/span&gt;: Unwilling to fight a woman in any form. Excessively duty bound.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;&lt;a href="http://en.wikipedia.org/wiki/Drona"&gt;Drona&lt;/a&gt;:&lt;/span&gt; &lt;/strong&gt;Drona, the Acharya, the teacher, the one who taught both the cousins, the Pandavas and Kauravas,  the art of warfare. Here was a man, again forced by duty to fight on the side of the Kauravas in the Kurukshetra war. This man was also a student of the great Parashurama. He had a favourite pupil in Arjuna. Drona was a complex individual, a man who had been insulted by a friend regarding his poverty and then gone on to own kingdoms and humble the man who had insulted him. Drona's lowest moment is probably when he asked Ekalavya to sacrifice his thumb. Drona served as the second commander of the Kaurava army after the fall of Bheeshma.&lt;br /&gt;Again, like Bheeshma, Drona did not want to participate in the Kurukshetra battle but was duty bound to do the same.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Death of Drona:&lt;/span&gt;&lt;br /&gt;Drona loved his son who also participated in the war. During the war, he like Bheeshma was routing the Pandavas. Arjuna had qualms about fighting his teacher and would often prefer to avoid the encounter.  The same left Drona in his element to devastate the Pandava army.  It is said that Drona used celestial weapons on foot soldiers, clearly inglorious. The only time that one could catch Drona of his guard was if he heard news of his son's death. The Pandavas gave Drona the false news regarding his sons death leading Drona to lay down his arms. When unarmed, he was beheaded.  A rather inglorious end to a great teacher.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_n_1crH7wjyM/STQ_gduHzoI/AAAAAAAAAbc/U5KZppppyjc/s320/drona.jpg"&gt;&lt;img style="cursor: pointer; width: 229px; height: 320px;" src="http://3.bp.blogspot.com/_n_1crH7wjyM/STQ_gduHzoI/AAAAAAAAAbc/U5KZppppyjc/s320/drona.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Archery Skills&lt;/span&gt;: 9 &lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Character&lt;/span&gt;: 6&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Achilles Heel&lt;/span&gt;: Loved his son, no special gifts apart from his archery.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;&lt;a href="http://en.wikipedia.org/wiki/Karna"&gt;Karna&lt;/a&gt;&lt;/span&gt;: &lt;/strong&gt;One of the most complex and torn personalities of the Mahabharata.  Karna was the son of Kunti and Surya, the son god.  At childbirth, he was cast away by his mother and raised by folks considered lowly at the time, charioteers.  The eldest brother of the Pandavas who even after knowing of his origins was forced to fight on the side of the Kauravas due to obligations from the favours he had obtained from the Kauravas. Considered by many, as the main nemesis of Arjuna. This was a man who was known for his generosity while still being a very ferocious archer who at every step of his life was reminded of his apparently lowly origin and denied his rightful place among the royals.  Karna was born with the &lt;strong&gt;Kavacha&lt;/strong&gt; and &lt;strong&gt;Kundala&lt;/strong&gt;, a divine &lt;strong&gt;body armour&lt;/strong&gt; and &lt;strong&gt;earrings&lt;/strong&gt; respectively which made him invulnerable to any weapon.  One important fact about Karna's life that needs mentioning is that he obtained the skills of archery by deceiving his master, the great Parashurama. When Parashuma figured out Karna's treachery, he cursed him saying that his acquired skills would desert him when he needed them the most!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.baka-raptor.com/wp-content/uploads/2008/12/karna2.jpg"&gt;&lt;img style="cursor: pointer; width: 542px; height: 690px;" src="http://www.baka-raptor.com/wp-content/uploads/2008/12/karna2.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Death of Karna:&lt;/span&gt;&lt;br /&gt;Before the start of the Kurukshetra war, Karna's mother Kunti had requested him to spare the life of her sons, i.e., Karna's younger brothers. Karna however promised to spare them all, except Arjuna whom he swore to fight till death. In addition, prior to the starting of the war, Karna parted with his impenetrable armour to a scheming Indra (Arjuna's father) and in turn got an all powerful weapon, the &lt;span style="font-weight: bold;"&gt;Shakti&lt;/span&gt;. Although stripped of his Kavacha and Kundala, Karna, the third commander of the Kaurava army after the fall Drona routed all the Pandava brothers in battle barring Arjuna and Bheema. During the Kurukshetra war, Krishna clouded Karna's mind whenever he met Arjuna so that he forgot about the Shakti weapon and never fired the same at Arjuna. Karna in an attempt to prevent a crisis, fired the same at a son of Bheema and killed him. The weapon could be used only once sadly. When Karna confronted Arjuna finally in the battlefield, they were evenly matched, however, Karna's chariot wheel got stuck in the mud and to accentuate the problem, he forgot his entire archery skill due to the curse by his teacher Parashurama. On this opportune moment, at the prompting of Krishna, Arjuna fired an arrow that ended the life of Karna.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Archery Skills&lt;/span&gt; : 9&lt;br /&gt;&lt;div&gt;&lt;span style="font-weight: bold;"&gt;Character&lt;/span&gt;: 8&lt;br /&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;Achilles Heel&lt;/span&gt;: Over generous individual. It is his generosity that finally costed him his life.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;strong&gt;&lt;a href="ttp://en.wikipedia.org/wiki/Arjuna"&gt;Arjuna&lt;/a&gt;: &lt;/strong&gt;&lt;/span&gt;The third son of Kunti born by the grace of the kings of gods, &lt;a href="http://en.wikipedia.org/wiki/Indra"&gt;Indra&lt;/a&gt; and considered by many as the most supreme archer of all time. He was considered equal with the gods with his mastery of the bow. This was a man along with &lt;a href="http://en.wikipedia.org/wiki/Krishna"&gt;Krishna &lt;/a&gt;had helped &lt;a href="http://en.wikipedia.org/wiki/Agni"&gt;Agni &lt;/a&gt; in consuming the &lt;a href="http://en.wikipedia.org/wiki/Khandava_Forest"&gt;Khandava &lt;/a&gt;forest, not even his father could stop the event from occurring. As a reward, Agni gave Arjuna the divine bow, &lt;a href="http://en.wikipedia.org/wiki/Gandiva"&gt;Gandeeva ,&lt;/a&gt; and an inexhaustible quiver of arrows.  Arjuna, had by severe penance won over the favour of gods and in turn the secrets of many a celestial weapon (think nukes here folks). He was granted the &lt;a href="http://en.wikipedia.org/wiki/Pashupata"&gt;Pashupata &lt;/a&gt;missile by none other than &lt;a href="http://en.wikipedia.org/wiki/Shiva"&gt;Shiva &lt;/a&gt;himself.  The most favourite student of Drona, Arjuna was responsible for the deaths of Bheeshma, Drona and Karna in the Kurukshetra war. Arjuna had Lord Krishna as his charioteer during the Kurukshetra war. Krishna had wowed not to take up arms during the war but he definitely provided strategic guidance to the Pandavas and worked miracles as Arjuna's charioteer providing him invaluable guidance about each and every adversary. Along with Bheema, his brother, Arjuna's contributions in the Kurukshetra war was the reason for the Pandava's victory. One of the most expected images is of Arjuna and Krishna blowing their conch proclaiming victory:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://shootfighter.files.wordpress.com/2009/05/arjuna.jpg"&gt;&lt;img style="cursor: pointer; width: 1024px; height: 768px;" src="http://shootfighter.files.wordpress.com/2009/05/arjuna.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-weight: bold;"&gt;Archery Skills&lt;/span&gt;: 10&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Character&lt;/span&gt;: 8&lt;br /&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;Achilles Heel&lt;/span&gt;: He believed himself to be the Archer of the time. High arrogance that he could vanquish the Kauravas very easily. He however had considerable hesitation when fighting his teacher or relatives. Without Krishna as his charioteer, I believe the Mahabharata would have reached a different outcome.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Death:&lt;/span&gt; Old age&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;&lt;a href="http://en.wikipedia.org/wiki/Ekalavya"&gt;Ekalavya&lt;/a&gt;:&lt;/span&gt; &lt;/strong&gt;Ekalavya was a forest dwelling individual who looked upon Drona as his teacher and practiced his archery without the personal tutelage of Drona. He practiced his art by consulting a stone sculpture of Drona. Ekalavya was a master of the art, even shocking his own master when the met face to face. Drona had made a wow that Arjuna would be remembered in history as the greatest archer of his time, but upon seeing the skill of Ekalavya, he felt that his wow might go unfulfilled. For this reason, he asked Ekalavya to provide him with his index finger as the price for being his student (even though her did not train him in person). The devout student that Ekalavya was, without a thought cut of his index finger and gave it to his teacher as fees for what he had learnt. Without the use of the index finger, Ekalavya was half the archer he could have been. A warrior who could have been the greatest if only he had never met his teacher!&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.columbia.edu/itc/mealac/pritchett/00routesdata/bce_299_200/mahabharata/ekalavya/ekalavya1.jpg"&gt;&lt;img style="cursor: pointer; width: 538px; height: 750px;" src="http://www.columbia.edu/itc/mealac/pritchett/00routesdata/bce_299_200/mahabharata/ekalavya/ekalavya1.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Archery Skills&lt;/span&gt;: 10&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Character&lt;/span&gt;: 10&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Achilles Heel&lt;/span&gt;: Equivalent of piracy. Gained knowledge without paying for it. Over honest in admitting to the same :-).&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Death:&lt;/span&gt; Unknown and unsung.&lt;br /&gt;&lt;br /&gt;Apart from the above, there were others who can be considered as "&lt;span style="font-style: italic;"&gt;Also Rans&lt;/span&gt;". The names of these other warriors are &lt;a href="http://en.wikipedia.org/wiki/Ashwatthama"&gt;Ashwathamma&lt;/a&gt; (Son of Drona) and &lt;a href="http://en.wikipedia.org/wiki/Abhimanyu"&gt;Abhimanyu&lt;/a&gt; (Son of Arjuna), &lt;a href="http://en.wikipedia.org/wiki/Kripa"&gt;Kripacharya&lt;/a&gt; (brother in law of Drona).&lt;br /&gt;&lt;br /&gt;History names Arjuna as the survivor of the Kurukshetra war and touts him as the greatest archer of the saga. However, whether he really was the greatest archer of the times is not beyond debate IMHO. Bheeshma had tutelage from the great Parashurama and had the option of choosing his time of death. Defeating Bheeshma in a fair fight would have been impossible. I however do not think that Bheeshma was as skilled as Arjuna as an archer. He might have been a greater warrior though. Drona, well I am not convinced that Drona was a better archer than Arjuna and neither do I think he was a better warrior. I however do think he was a calculating teacher at best. Ekalavya, now, this individual would have probably been the greatest archer of all time, if only he had the use of his thumb. The very fact that Drona demanded such a sacrifice from Ekalavya only exemplifies the fact of how he feared the skills of Ekalavya would make Arjuna look mediocre.  Karna, although great, I do not believe that he was better than Arjuna in archery. There are numerous occurrences in the Mahabharata where Arjuna has performed while Karna could not, and I mean in archery folks :-)))).  Karna would however have been unstoppable in the Kurukshetra war if he did have at his disposal the Kavacha and Kundalas.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;Do I have a face off here? I think the characters of the Mahabharata are very complex and interesting. I wish one day Hollywood decides to make an epic Movie on the same. If they can do the movie &lt;a href="http://en.wikipedia.org/wiki/Troy_%28film%29"&gt;Troy&lt;/a&gt;, then the story of the Mahabharata should be 10 times better :-) The Mahabharata is filled with so many moral stories as well. It is said, that reading the Mahabharata cleanses ones souls of their sins. If true, in my case, I might have multiple reads ahead and multiple sleepless nights in Salt Lake City ;-)&lt;br /&gt;&lt;br /&gt;Finally,  much respect to my favourite Lord Krishna, the coolest god one can find, forever your admirer. Scrub, scrub scrub...the soul cleansing begins :-)&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-2671403880607569971?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/2671403880607569971/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=2671403880607569971' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/2671403880607569971'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/2671403880607569971'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/11/mahabharata-tribute-to-my-favorite.html' title='Mahabharata- a tribute to my favorite archers'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_n_1crH7wjyM/STQ_gduHzoI/AAAAAAAAAbc/U5KZppppyjc/s72-c/drona.jpg' height='72' width='72'/><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-8283030766166391644</id><published>2009-10-31T20:16:00.006-06:00</published><updated>2009-10-31T20:43:47.041-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu Karmic'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows 7'/><title type='text'>Ubuntu Karmic and Windows 7</title><content type='html'>Did two upgrades this weekend. Upgraded a laptop from Vista to Windows 7 and a desktop from &lt;a href="http://www.ubuntu.com/"&gt;Ubuntu&lt;/a&gt; Jaunty to Karmic, both 64 bit. Pleased with both upgrades so far.  Vista was one of MS biggest lows as far as their OS version goes, Windows 7 seems more peppier in general so far.&lt;br /&gt;&lt;br /&gt;I have been very pleased with Ubuntu ever since I installed the same. Have previously been a user of &lt;a href="http://www2.mandriva.com"&gt;Mandriva&lt;/a&gt;, &lt;a href="http://fedoraproject.org/"&gt;Fedora&lt;/a&gt; and &lt;a href="http://www.opensuse.org/en/"&gt;Suse&lt;/a&gt;.  Found mandriva comprehensive in its software offering but not very stable. I feel that Suse may be great to compete with Redhat on the server market but is no where as user friendly as Ubuntu. What I like about Ubuntu is that its pretty solid, convenient and just so easy to use.  It detects the need for propriety drivers and installs in a breeze. Have dual monitor support without any xorg.conf tweaking. Printer, web cam all worked out of the box. Have it now running Skype as well without a problem.&lt;br /&gt;&lt;br /&gt;After installing Ubuntu, I followed the following &lt;a href="http://theindexer.wordpress.com/2009/10/25/to-do-list-after-installing-ubuntu-9-10-aka-karmic-koala/"&gt;BLOG on a TODO&lt;/a&gt; list that really helped.&lt;br /&gt;Anyway, got rid of the standard 1948 created Gnome menu in favour of &lt;a href="http://wiki.awn-project.org/"&gt;AWN&lt;/a&gt; and now my desktop rocks.&lt;br /&gt;&lt;br /&gt;A note for those installing eclipse 64 bit. One will find that clicking on some buttons does not work and one has use the keyboard actions to activate the buttons. The way around this problem is to set the following "&lt;span style="font-style: italic;"&gt;export GDK_NATIVE_WINDOWS=true&lt;/span&gt;" prior to launching eclipse.&lt;br /&gt;&lt;br /&gt;On the Windows 7 front, I prefer using Chrome over firefox or IE as its so much more faster on many sites that I frequent. The upgrade from Dell from Vista to Win 7 was pretty simple. Cannot watch youtube on 64 bit IE yet due to 64 flash plugin not available (no so on my Ubuntu though :-)) Don't get me wrong, I don't have anything against Win 7 (except $$$) but when compared with what &lt;span style="font-weight: bold;"&gt;FREE&lt;/span&gt; brings, I find it difficult to justify the extra $$$. I however do need to a Win machine due to the fact that there is no software for the iphone of any value on Linux and that there are sites that I go to such as CWTV to watch videos requiring Win or Mac.  Another seller for the Win 7 is my few PC games that I have. BTW, I did not buy Win 7, its a free upgrade option.&lt;br /&gt;&lt;br /&gt;The Mrs also is happy with Ubuntu...and as long as she is happy, I am as well :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-8283030766166391644?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/8283030766166391644/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=8283030766166391644' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/8283030766166391644'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/8283030766166391644'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/10/ubuntu-karmic-and-windows-7.html' title='Ubuntu Karmic and Windows 7'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-4177003207527319025</id><published>2009-10-16T21:37:00.036-06:00</published><updated>2009-10-23T20:33:09.777-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Exceptions with REST'/><category scheme='http://www.blogger.com/atom/ns#' term='Restlet JAXB'/><category scheme='http://www.blogger.com/atom/ns#' term='Restlet Spring 2.0'/><category scheme='http://www.blogger.com/atom/ns#' term='Restlet 2.0'/><title type='text'>Exceptions in RESTful HTTP with Restlet and JAXB</title><content type='html'>REST, or rather, RESTful HTTP and how exceptions can be handled therein is what this posting is about.&lt;br /&gt;&lt;br /&gt;For those of us who have worked with SOAP and faults, we are familiar with how exceptions are handled. SOAP Stacks upon encountering an exception will throw a SOAP fault which is then marshalled into an exception on the consumer end of the service. SOAP faults in a way provide a protocol over standard HTTP.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;When working with REST we have the concept of Resources and their Representations. An exception in a RESTful architecture is really a tuple of an HTTP Status Code and a Representation that describes the same.&lt;br /&gt;&lt;br /&gt;The HTTP Status code in themselves are quite indicative, delving a bit into the same:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;1XX Series - Informational - Request received and continuing processing&lt;/li&gt;&lt;li&gt;2XX Success - Action received, understood and accepted&lt;/li&gt;&lt;li&gt;3XX Redirection - Further action required to complete the request&lt;/li&gt;&lt;li&gt;4XX Client Error - Request is badly formatter or the server cannot process the request&lt;/li&gt;&lt;li&gt;5XX Server Error - Server failure on a a potentially valid request&lt;/li&gt;&lt;/ul&gt;When working with architectures that have Java on both ends of a Service, shying away from Exception handling is IMHO a self imposed handicap. In a RESTful system, one would typically have an expected representation of a resource and in the event of exceptions, have them represented as alternate results along with the appropriate error codes. The &lt;a href="http://jcp.org/en/jsr/detail?id=311"&gt;JAX-RS&lt;/a&gt; specification has the concept of a WebServiceException.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;What I am trying to do in this BLOG is a demonstrate how exception handling can be accomplished with a framework like Restlet. I am not demonstrating a specification by any means or a wrapper protocol.  For the sake of this demonstration, I will be using &lt;a href="http://www.restlet.org/"&gt;Restlet&lt;/a&gt; and &lt;a href="http://java.sun.com/developer/technicalArticles/WebServices/jaxb/"&gt;JAXB.&lt;/a&gt; In particular, the example will rely on the &lt;a href="http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/adapters/XmlAdapter.html"&gt;XmlAdapter&lt;/a&gt;s of JAXB extensively coupled with the Java Reflection API and Annotations. The XmlAdapters serve to translate to and from Exceptions to JAXB Representions&lt;/div&gt;&lt;br /&gt;The scope of this example is as follows:&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-weight: bold;"&gt;a. Exceptions supported are of a particular type and its subclasses only:&lt;/span&gt;&lt;br /&gt;Exceptions are restricted to &lt;span style="font-style: italic;"&gt; WebServiceException&lt;/span&gt; and its sub classes. In addition, the &lt;span style="font-style: italic;"&gt;WebServiceException&lt;/span&gt; is a &lt;span style="font-style: italic;"&gt;RuntimeException&lt;/span&gt;. No checked exceptions. Any exceptions thrown by a Restlet Resource that are not an instance of &lt;span style="font-style: italic;"&gt;WebServiceException&lt;/span&gt; will be converted to the same prior to being marshalled. Any &lt;span style="font-style: italic;"&gt;WebServiceException&lt;/span&gt; marshalled, must have a JAXB Object associated with it.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;@XmlJavaTypeAdapter(WebServiceExceptionAdapter.class)&lt;br /&gt;public class WebServiceException extends RuntimeException {&lt;br /&gt;// Http Status code&lt;br /&gt;private int status;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;// This class extends WebServiceException but has the same body as&lt;br /&gt;// WebServiceException. For this reason, there is no special XmlAdapter required.&lt;br /&gt;public class OrderException extends WebServiceException {&lt;br /&gt;..&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-weight: bold;"&gt;b. XML as the media type for Transferring Exceptions:&lt;/span&gt;&lt;br /&gt;XML is the sole media type supported for exceptions in this example. Note that it is quite trivial to change the same to accommodate additional media types like JSON etc if required. Every Exception's representation is wrapped around with a &lt;span style="font-style: italic; font-weight: bold;"&gt;WebServiceExceptionWrapperDto&lt;/span&gt;. The same is to allow for sub typing. Note that the &lt;span style="font-weight: bold;"&gt;targetException&lt;/span&gt; will be marshalled by an appropriate XmlAdapter at Runtime.&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;@XmlType(name = "ExceptionWrapper", propOrder = { "targetException" })&lt;br /&gt;@XmlRootElement&lt;br /&gt;public class WebServiceExceptionWrapperDto&amp;lt;E extends WebServiceException&amp;gt; {&lt;br /&gt;@XmlElement(name = "targetException", required = true)&lt;br /&gt;public E targetException;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-weight: bold;"&gt;c. Rich Exceptions:&lt;/span&gt;&lt;br /&gt;Exceptions that can be richer, i.e., more than just message, cause and stack. For example validation messages, codes, inner objects etc.  A simple example of the same is shown below where the OrderValidationException contains a description and a custom validation error code. The same could easily have been a complex object if required:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;@XmlJavaTypeAdapter(OrderValidationExceptionAdapter.class)&lt;br /&gt;public class OrderValidationException extends WebServiceException {&lt;br /&gt;// A code representing the error&lt;br /&gt;private int validationCode;&lt;br /&gt;&lt;br /&gt;// A description indicating the cause of the validation error&lt;br /&gt;private String validationMessage;&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;// Note that the OrderValidationException Adapter is behaving like a Template method pattern&lt;br /&gt;// Base marshalling to an exception is handled by the parent class with the child only providing&lt;br /&gt;// specific additions. The methods marshall() and unmarshall() are implemented in the parent class&lt;br /&gt;// and will populate the base properties of the Exception and representation accordingly&lt;br /&gt;public class OrderValidationExceptionAdapter extends&lt;br /&gt;AbstractExceptionXmlAdapter&amp;lt;OrderValidationExceptionDto,OrderValidationException&amp;gt; {&lt;br /&gt;&lt;br /&gt;@Override&lt;br /&gt;public OrderValidationException toException(OrderValidationException created,&lt;br /&gt;  OrderValidationExceptionDto dto) throws Exception {&lt;br /&gt;&lt;br /&gt; created.setValidationCode(dto.validationCode);&lt;br /&gt; created.setValidationMessage(dto.validationMessage);&lt;br /&gt; return created;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@Override&lt;br /&gt;public OrderValidationExceptionDto toRepresentation(OrderValidationExceptionDto created,&lt;br /&gt;  OrderValidationException t) throws Exception {&lt;br /&gt;&lt;br /&gt; created.validationCode = t.getValidationCode();&lt;br /&gt; created.validationMessage = t.getValidationMessage();&lt;br /&gt; return created;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-weight: bold;"&gt;d. Control over which parts of an Exception are marshalled:&lt;/span&gt;&lt;br /&gt;Provide server stack, cause and message to client. At the same time, ability to prevent certain exceptions from transmitting stack. One might or might not want to marshall server stack in certain cases. The same will be accomplished via an annotation that resides on an Exception  thrown. Note that the same can be enhanced for further control. In the example shown below, throwing of the &lt;span style="font-style: italic;"&gt;BarException&lt;/span&gt; will not result in the marshalling of the stack or cause:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;/**&lt;br /&gt;* Foo Exception when thrown should not include server stack and any cause&lt;br /&gt;*/&lt;br /&gt;@ExceptionMarshallingParams(includeStack=false, marshallCause=false)&lt;br /&gt;public class BarException extends WebServiceException {&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;e. Simple mechanism to throw exceptions on the Client:&lt;/span&gt;&lt;br /&gt;Clients are aware of the Exceptions that can be expected from a Service and can expect them to be thrown appropriately. For example:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public OrderDto createOrder(OrderDto order) throws OrderValidationException, OrderException {&lt;br /&gt;JaxbRepresentation&amp;lt;OrderDto&amp;gt; orderRep = new JaxbRepresentation&amp;lt;OrderDto&amp;gt;(order);&lt;br /&gt;Response response = client.post(baseUri + ORDERS_RESOURCE_URI, orderRep);&lt;br /&gt;if (response.getStatus().isSuccess()) {&lt;br /&gt;orderRep = new JaxbRepresentation&amp;lt;OrderDto&amp;gt;(response.getEntity(), OrderDto.class);&lt;br /&gt;try {&lt;br /&gt; return orderRep.getObject();&lt;br /&gt;}&lt;br /&gt;catch (IOException e) {&lt;br /&gt;throw new OrderException(e.getMessage(), e, response.getStatus());&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Not a Response we expected..throw one of the following exceptions expected instead&lt;br /&gt;throw ExceptionUtil&lt;br /&gt;.getWebServiceException(response.getEntity(), OrderValidationException.class,  OrderException.class);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public class ExceptionUtil {&lt;br /&gt;...&lt;br /&gt;public static WebServiceException getWebServiceException(Representation xmlRep,&lt;br /&gt;  Class... expectedExceptions) {&lt;br /&gt; StringBuilder packages = new StringBuilder(20);&lt;br /&gt; packages.append(WebServiceException.class.getPackage().getName());&lt;br /&gt;&lt;br /&gt; for (Class clazz : expectedExceptions) {&lt;br /&gt;   String ctxPath = getContextPath(clazz);&lt;br /&gt;   packages.append(":").append(ctxPath);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; JaxbRepresentation&amp;lt;WebServiceExceptionWrapperDto&amp;lt;WebServiceException&amp;gt;&amp;gt; wsRep&lt;br /&gt;   = new JaxbRepresentation&amp;lt;WebServiceExceptionWrapperDto&amp;lt;WebServiceException&amp;gt;&amp;gt;(&lt;br /&gt;     xmlRep, packages.toString());&lt;br /&gt; try {&lt;br /&gt;   return wsRep.getObject().targetException;&lt;br /&gt; }&lt;br /&gt; catch (IOException e) {&lt;br /&gt;   throw new RuntimeException("Error unmarshalling exception", e);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Note that it would have been nice if we could specify the exceptions that a method could throw using generics. That feature however is restricted to a single exception type and thus accommodating checked exceptions are hard.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;f. Resource Classes throw Exceptions on failed code states:&lt;/span&gt;&lt;br /&gt;Resource classes will be able to throw any type of &lt;span style="font-style: italic;"&gt;WebServiceException&lt;/span&gt; and have it marshalled to the client. The Resource classes must however ensure they populate the Exception with the appropriate Http Status Code. For example, an &lt;span style="font-style: italic;"&gt;OrderResource&lt;/span&gt; on create might throw an &lt;span style="font-style: italic;"&gt;OrderNotValidException&lt;/span&gt; or an &lt;span style="font-style: italic;"&gt;OrderException&lt;/span&gt; when a POST operation is invoked on it. At the same time, a GET on the &lt;span style="font-style: italic;"&gt;OrderResource&lt;/span&gt; might throw a &lt;span style="font-style: italic;"&gt;OrderNotFoundException&lt;/span&gt;.&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public class OrderResource extends ServerResource {&lt;br /&gt;@Post("xml")&lt;br /&gt;public OrderDto createOrder(OrderDto dto)  {&lt;br /&gt; try {&lt;br /&gt;   dto = persistOrder(dto);&lt;br /&gt;   setStatus(Status.SUCCESS_CREATED);&lt;br /&gt;   return dto;&lt;br /&gt; } catch (OrderValidationException ove) {&lt;br /&gt;   ove.setStatus(Status.CLIENT_ERROR_BAD_REQUEST);&lt;br /&gt;   throw ove;&lt;br /&gt; }&lt;br /&gt; catch (OrderException e) {&lt;br /&gt;   getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);&lt;br /&gt;   throw e;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;@Get("xml")&lt;br /&gt;public OrderDto getOrder() {&lt;br /&gt; ....&lt;br /&gt; Order order = null;&lt;br /&gt; try {&lt;br /&gt;   order = orderService.getOrder(orderId);&lt;br /&gt; }&lt;br /&gt; catch (OrderNotFoundException nfe) {&lt;br /&gt;   nfe.setStatus(Status.CLIENT_ERROR_NOT_FOUND);&lt;br /&gt;   throw nfe;&lt;br /&gt; }&lt;br /&gt; return (OrderDto) beanMapper.map(order, OrderDto.class);&lt;br /&gt;}&lt;br /&gt;....&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public class HealthResource extends ServerResource {&lt;br /&gt;private static int counter = 0;&lt;br /&gt;@Get&lt;br /&gt;public String isHealthy() {&lt;br /&gt;  // Simply to prove a point....&lt;br /&gt;  switch (counter) {&lt;br /&gt;    case 0:&lt;br /&gt;      counter++;&lt;br /&gt;      // Throw a WebServiceException&lt;br /&gt;      throw new WebServiceException("System is unhealthy", Status.CLIENT_ERROR_UNAUTHORIZED);&lt;br /&gt;&lt;br /&gt;    case 1:&lt;br /&gt;      counter++;&lt;br /&gt;      // throw a RuntimeExeception..this will be transparently marshalled&lt;br /&gt;      throw new RuntimeException("Some unexpected exception thrown as a Runtime");&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  getResponse().setStatus(Status.SUCCESS_OK);&lt;br /&gt;  return "OK YEAH!";&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;g. Marshalling of exceptions occurs via a Restlet Status Service:&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;A custom extension of the Restlet Status Service is responsible for marshalling all thrown Exceptions. The same is shown below:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public class JaxbExceptionStatusService extends StatusService {&lt;br /&gt;....&lt;br /&gt;public Status getStatus(Throwable throwable, Request request, Response response) {&lt;br /&gt;  Throwable cause = throwable.getCause();&lt;br /&gt;  WebServiceException exception;&lt;br /&gt;  String contextPath = ExceptionUtil.BASE_EXCEPTION_PACKAGE;&lt;br /&gt;&lt;br /&gt;  if (cause == null || !(cause instanceof WebServiceException)) {&lt;br /&gt;    // If not a WebService Exception then throw a WebService Exception&lt;br /&gt;    exception = new WebServiceException(..., Status.SERVER_ERROR_INTERNAL); &lt;br /&gt;   }  else {&lt;br /&gt;     exception = (WebServiceException) cause;&lt;br /&gt;     String clazzContext = ExceptionUtil.getContextPath(cause.getClass());&lt;br /&gt;&lt;br /&gt;     if (!contextPath.equals(cause.getClass().getPackage().getName())&lt;br /&gt;        &amp;amp;&amp;amp; !clazzContext.equals(contextPath)) {&lt;br /&gt;       contextPath = contextPath + ":" + clazzContext;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     if (exception.getStatus() == 0) {&lt;br /&gt;       exception.setStatus(Status.SERVER_ERROR_INTERNAL);&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   // Create the Exception Wrapper&lt;br /&gt;   WebServiceExceptionWrapperDto&amp;lt;WebServiceException&amp;gt; exceptionWrapper = new         WebServiceExceptionWrapperDto&amp;lt;WebServiceException&amp;gt;();&lt;br /&gt;   exceptionWrapper.targetException = exception;&lt;br /&gt;&lt;br /&gt;   JaxbRepresentation&amp;lt;WebServiceExceptionWrapperDto&amp;lt;?&amp;gt;&amp;gt; rep = new    JaxbRepresentation&amp;lt;WebServiceExceptionWrapperDto&amp;lt;?&amp;gt;&amp;gt;(&lt;br /&gt;     exceptionWrapper);&lt;br /&gt;&lt;br /&gt;   rep.setContextPath(contextPath);&lt;br /&gt;   response.setEntity(rep);&lt;br /&gt;   return Status.valueOf(exception.getStatus());&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I have included &lt;a href="http://home.comcast.net/%7Eacharya.s/java/RestletException.zip"&gt;herewith a Maven example&lt;/a&gt; that will demonstrate the client, service and exception management in use. The maven module titled "exceptionnmodule" contains the exception handling code. The integration will demonstrate different exceptions that are thrown by the server and re-thrown by the client code. In particular, you can see the the following abilities of the framework:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;a.&lt;/span&gt; Ability to throw a simple RuntimeException from the Service and see it marshalled/unmarshalled as WebServiceException&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;b.&lt;/span&gt; Ability to throw an instance of  WebServiceException&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;c. &lt;/span&gt;Ability to throw an exception that is a subtype of WebServiceException but without any addition body. For example, the OrderException.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;d.&lt;/span&gt; Ability to throw a sub type of the WebServiceException that has additional body elements. For example,  OrderValidationException.&lt;br /&gt;&lt;br /&gt;One can witness the server stack, cause, HTTP Status, specific exception types. Simply run a "&lt;span style="font-weight: bold;"&gt;mvn install&lt;/span&gt;" from the top level project.&lt;br /&gt;&lt;br /&gt;Although the example uses Restlet 2.0, the framework has no dependencies on the same. There might be many areas for improvement in the concept and I would like to hear about them if a reader of this blog has ideas. Also, in this example, I have used code from a posting by Ian Robertson on Artima regarding &lt;a href="http://www.artima.com/weblogs/viewpost.jsp?thread=208860"&gt;Reflecting Generics&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Finally, I don't know how this BLOG will format. I am trying something new, I hope it woiks!&lt;br /&gt;&lt;br /&gt;&lt;a href="http://home.comcast.net/%7Eacharya.s/java/RestletException.zip"&gt;Download the Code HERE!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-4177003207527319025?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/4177003207527319025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=4177003207527319025' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/4177003207527319025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/4177003207527319025'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/10/exceptions-in-restful-http-with-restlet.html' title='Exceptions in RESTful HTTP with Restlet and JAXB'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-7226916108904703456</id><published>2009-08-26T19:25:00.026-06:00</published><updated>2009-08-28T21:50:21.887-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Restlet 2.0 Maven example'/><category scheme='http://www.blogger.com/atom/ns#' term='Restlet ConverterService'/><category scheme='http://www.blogger.com/atom/ns#' term='Restlet 2.0'/><title type='text'>Restlet 2.0 example using Spring, Maven, Annotations and a Custom Converter</title><content type='html'>Its been some time since I posted regarding REST. &lt;a href="http://www.restlet.org"&gt;Restlet&lt;/a&gt; 2.0 is on its way, I figured its time I &lt;a href="http://sleeplessinslc.blogspot.com/2008/04/rest.html"&gt;updated the example I had created some time ago&lt;/a&gt; to a Restlet 2.0 milestone release. If you are continuing to read this BLOG, I would recommend a read of the Restlet 1.1 BLOG I mentioned prior to reading this one.&lt;br /&gt;&lt;br /&gt;So whats new with Restlet 2.0? A &lt;a href="http://wiki.restlet.org/developers/172-restlet/226-restlet.html"&gt;read of the Resource API refactoring page&lt;/a&gt; is recommended.&lt;br /&gt;&lt;br /&gt;One of the major features that I liked about &lt;a href="http://jcp.org/en/jsr/detail?id=311"&gt;JAX-RS&lt;/a&gt; over the core Restlet API while working with the former is that it is annotation driven versus class driven. Automatic content negotiation and the calling of the appropriate method in your Server Resource class for different Content-Types is really best left to the container. A method intended to serve content should not have &lt;span style="font-style:italic;"&gt;if/else&lt;/span&gt;  blocks for different content, something one would need to do in Restlet 1.1. Restlet 2.0 seems to take the same into consideration by providing the "&lt;span style="font-weight:bold;"&gt;best of both worlds&lt;/span&gt;"&lt;br /&gt;&lt;br /&gt;There were major changes that occurred on Restlet version 1.2 that the team at Restlet decided to change the release to a 2.0. Further details of the change can be obtained at &lt;a href="http://blog.noelios.com/2009/05/27/restlet-2-0-m3-released/"&gt;http://blog.noelios.com/2009/05/27/restlet-2-0-m3-released/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Restlet 2.0 has a major change in the way &lt;span style="font-style:italic;"&gt;Resources&lt;/span&gt; are viewed. In particular a split into a &lt;span style="font-style:italic;"&gt;ClientResource&lt;/span&gt; and a &lt;span style="font-style:italic;"&gt;ServerResource&lt;/span&gt;. Details of the same can be viewed on the &lt;a href="http://wiki.restlet.org/developers/172-restlet/226-restlet.html"&gt;Restlet Resource API refactoring WIKI page&lt;/a&gt;. In addition, there has been a refactoring of certain core classes to different packages. I also noticed that the Restlet API and Restlet engine are shipped as a single jar &lt;span style="font-style:italic;"&gt;org.restlet.jar&lt;/span&gt;. I could not find the &lt;span style="font-style:italic;"&gt;com.neolios&lt;/span&gt; packages any more.  Finally, there is a jse and j2ee edition of Restlet available.&lt;br /&gt;&lt;br /&gt;So, eager to try out the Restlet 2.0 annotations, I reworked my example to use Restlet 2.0 while simplifying the Spring integration present. &lt;br /&gt;&lt;br /&gt;Compared to my previous example, I have reduced my Spring &lt;span style="font-style:italic;"&gt;applicationContext.xml&lt;/span&gt; to be more thinner by using a more annotated approach. &lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;context:component-scan base-package=&amp;quot;com.welflex&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;/context:component-scan&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!--  Spring Application. Note there are no mapping of resources here --&amp;gt;&lt;br /&gt;&amp;lt;bean id=&amp;quot;application&amp;quot; class=&amp;quot;org.restlet.Application&amp;quot;&amp;gt;&lt;br /&gt;  &amp;lt;property name=&amp;quot;name&amp;quot; value=&amp;quot;orderApplication&amp;quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;  &amp;lt;property name=&amp;quot;root&amp;quot; ref=&amp;quot;root&amp;quot; /&amp;gt;&lt;br /&gt;   &amp;lt;!-- Added to handle Exceptions centrally --&amp;gt;&lt;br /&gt;  &amp;lt;property name=&amp;quot;statusService&amp;quot; ref=&amp;quot;applicationStatusService&amp;quot;/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id=&amp;quot;root&amp;quot; name=&amp;quot;router&amp;quot; class=&amp;quot;com.welflex.order.rest.SpringBeanRouter&amp;quot;/&amp;gt;&lt;br /&gt;&amp;lt;bean id=&amp;quot;beanMapper&amp;quot;&lt;br /&gt; class=&amp;quot;net.sf.dozer.util.mapping.DozerBeanMapper&amp;quot;&amp;gt;&lt;br /&gt;  &amp;lt;property name=&amp;quot;mappingFiles&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;list&amp;gt;&lt;br /&gt; &amp;lt;value&amp;gt;dozerBeanMapping.xml&amp;lt;/value&amp;gt;&lt;br /&gt;    &amp;lt;/list&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;The OrdersResource has changed to:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;@&lt;font color="#2040a0"&gt;Component&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;value&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;/orders&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;@&lt;font color="#2040a0"&gt;Scope&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;value&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;BeanDefinition&lt;/font&gt;.&lt;font color="#2040a0"&gt;SCOPE_PROTOTYPE&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrdersResource&lt;/font&gt; &lt;strong&gt;extends&lt;/strong&gt; &lt;font color="#2040a0"&gt;ServerResource&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  ......&lt;br /&gt;  @&lt;font color="#2040a0"&gt;Post&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;JaxbRepresentation&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;createOrder&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Representation&lt;/font&gt; &lt;font color="#2040a0"&gt;rep&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    ...&lt;br /&gt;    &lt;strong&gt;return&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;JaxbRepresentation&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;MediaType&lt;/font&gt;.&lt;font color="#2040a0"&gt;APPLICATION_XML&lt;/font&gt;, &lt;font color="#2040a0"&gt;dto&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;      &lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;Note that the &lt;span style="font-style:italic;"&gt;OrderResource&lt;/span&gt; class now extends &lt;span style="font-style:italic;"&gt;ServerResource&lt;/span&gt; unlike in my previous example which extended the &lt;span style="font-style:italic;"&gt;Resource&lt;/span&gt; class. Also note that the mapping of the resources to paths are defined in the &lt;span style="font-style:italic;"&gt;OrderResource&lt;/span&gt; class itself unlike in the xml file in my previous example. The POST method, called &lt;span style="font-style:italic;"&gt;createOrder()&lt;/span&gt; accepts and returns XML. The return type is a &lt;span style="font-style:italic;"&gt;JaxbRepresentation&lt;/span&gt;. If we desired, we could have another method in the code that accepts JSON content and returns JSON content that is titled &lt;span style="font-style:italic;"&gt;createJSONRepresentation()&lt;/span&gt;. Depending on the content type requested, the appropriate method would be called. This is much better than having an if/else block in an&lt;span style="font-style:italic;"&gt; acceptRepresentation(Variant v)&lt;/span&gt; method.&lt;br /&gt;&lt;br /&gt;Take a look at the Products Resource, that returns a JSON representation when a GET method is invoked. Note that this method will only return JSON content. &lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;@&lt;font color="#2040a0"&gt;Component&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;value&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;/products&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;@&lt;font color="#2040a0"&gt;Scope&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;value&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;BeanDefinition&lt;/font&gt;.&lt;font color="#2040a0"&gt;SCOPE_PROTOTYPE&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;ProductsResource&lt;/font&gt; &lt;strong&gt;extends&lt;/strong&gt; &lt;font color="#2040a0"&gt;ServerResource&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  ......&lt;br /&gt;  @&lt;font color="#2040a0"&gt;Get&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;JsonRepresentation&lt;/font&gt; &lt;font color="#2040a0"&gt;getProducts&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;   .....&lt;br /&gt;   &lt;strong&gt;return&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;JsonRepresentation&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;jsonString&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;Pretty nice, I would say. To spoil the party, one of the things I liked about the JAXRS implementations was that I could annotate a Resource with the media type it supported and if it were a JAXB object it would automatically marshall the XML, if it were JSON, it would automatically marshal the same as well. &lt;br /&gt;&lt;br /&gt;The same can be accomplished in Restlet by using a Converter Service that converts a java object to and from a media type. There are plans for adding &lt;a href="http://restlet.tigris.org/issues/show_bug.cgi?id=855"&gt;JAXB converters amongst others in 2.0 M5&lt;/a&gt;. In short, by using a Converter Service, I would like the &lt;span style="font-style:italic;"&gt;createOrder()&lt;/span&gt; method to have the following signature, i.e., method returns a JAXB Object, however the container knows how to marshal that into XML back to the caller:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;@&lt;font color="#2040a0"&gt;Post&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;xml&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;:&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;xml&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt; &lt;font color="#2040a0"&gt;createOrder&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt; &lt;font color="#2040a0"&gt;inOrder&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;outOrderDTO&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;  &lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;So what about the &lt;span style="font-style:italic;"&gt;ClientResource&lt;/span&gt; class? How does that work? Well with Restlet 2.0, one can continue to use the Restlet &lt;span style="font-style:italic;"&gt;Client&lt;/span&gt; class or use the &lt;span style="font-style:italic;"&gt;ClientResource&lt;/span&gt; class. The &lt;span style="font-style:italic;"&gt;ClientResource&lt;/span&gt; is not thread safe. An example of how the &lt;span style="font-style:italic;"&gt;ClientResource&lt;/span&gt; can be used is shown below in the &lt;span style="font-style:italic;"&gt;OrderClientImpl&lt;/span&gt; class:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderClientImpl&lt;/font&gt; &lt;strong&gt;implements&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderClient&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;static&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;ORDERS_RESOURCE_URI&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;/orders&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;baseUri&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderClientImpl&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;baseUri&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;this&lt;/strong&gt;.&lt;font color="#2040a0"&gt;baseUri&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;baseUri&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt; &lt;font color="#2040a0"&gt;createOrder&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt; &lt;font color="#2040a0"&gt;order&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;IOException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;ClientResource&lt;/font&gt; &lt;font color="#2040a0"&gt;ordersResource&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ClientResource&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;baseUri&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;ORDERS_RESOURCE_URI&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;ordersResource&lt;/font&gt;.&lt;font color="#2040a0"&gt;post&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;order&lt;/font&gt;, &lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ResourceException&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;IOException&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;updateOrder&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt; &lt;font color="#2040a0"&gt;order&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;JaxbRepresentation&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;orderCmd&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;JaxbRepresentation&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;MediaType&lt;/font&gt;.&lt;font color="#2040a0"&gt;APPLICATION_XML&lt;/font&gt;, &lt;font color="#2040a0"&gt;order&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;ClientResource&lt;/font&gt; &lt;font color="#2040a0"&gt;ordersResource&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ClientResource&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;baseUri&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;ORDERS_RESOURCE_URI&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;/&amp;quot;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;String&lt;/font&gt;.&lt;font color="#2040a0"&gt;valueOf&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;order&lt;/font&gt;.&lt;font color="#2040a0"&gt;getOrderId&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;ordersResource&lt;/font&gt;.&lt;font color="#2040a0"&gt;put&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;orderCmd&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ResourceException&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderException&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Order Update Failed&amp;quot;&lt;/font&gt;, &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt; &lt;font color="#2040a0"&gt;getOrder&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Long&lt;/font&gt; &lt;font color="#2040a0"&gt;orderId&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderNotFoundException&lt;/font&gt;, &lt;font color="#2040a0"&gt;IOException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;     ....&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;deleteOrder&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Long&lt;/font&gt; &lt;font color="#2040a0"&gt;orderId&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    ....&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;I quite like the use of &lt;span style="font-style:italic;"&gt;ClientResource&lt;/span&gt; versus the Restlet &lt;span style="font-style:italic;"&gt;Client&lt;/span&gt; as I feel its more RESTful, i.e., talking to a Resource using HTTP verbs. However, again we witness the JAXB representation creeping in as we saw with the service due to the lack of a converter.&lt;br /&gt;&lt;br /&gt;I decided to create my own Converter for JAXB to see if I can get it to work and simplify the code base. One of the things I wanted to add just for my pleasure is a way to propagate server stack traces to the client. This is &lt;span style="font-weight:bold;"&gt;NOT&lt;/span&gt; what one would typically include in a representation of a resource as one would not want clients getting details of the working of a server, however, as this is my playground, anything goes ;-). After some tinkering, the following is my Jaxb Converter, it assumes that all JAXB root level objects have the annotation&lt;span style="font-weight:bold;"&gt; @XmlRootElement&lt;/span&gt;:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;CustomXmlConverter&lt;/font&gt; &lt;strong&gt;extends&lt;/strong&gt; &lt;font color="#2040a0"&gt;XmlConverter&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  ......&lt;br /&gt;  @&lt;font color="#2040a0"&gt;Override&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;List&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Class&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;?&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getObjectClasses&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Variant&lt;/font&gt; &lt;font color="#2040a0"&gt;source&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;List&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Class&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;?&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;result&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;super&lt;/strong&gt;.&lt;font color="#2040a0"&gt;getObjectClasses&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;source&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;result&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;addObjectClass&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;result&lt;/font&gt;, &lt;font color="#2040a0"&gt;JaxbRepresentation&lt;/font&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;result&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;addObjectClass&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;result&lt;/font&gt;, &lt;font color="#2040a0"&gt;Object&lt;/font&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;result&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  @&lt;font color="#2040a0"&gt;Override&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;List&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;VariantInfo&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getVariants&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Class&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;?&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;source&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;List&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;VariantInfo&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;result&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;super&lt;/strong&gt;.&lt;font color="#2040a0"&gt;getVariants&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;source&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;source&lt;/font&gt;.&lt;font color="#2040a0"&gt;getAnnotation&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;XmlRootElement&lt;/font&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;!&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;|&lt;/font&gt;&lt;font color="4444FF"&gt;|&lt;/font&gt; &lt;font color="#2040a0"&gt;source&lt;/font&gt;.&lt;font color="#2040a0"&gt;isAssignableFrom&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;JaxbRepresentation&lt;/font&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;result&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;addVariant&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;result&lt;/font&gt;, &lt;font color="#2040a0"&gt;VARIANT_APPLICATION_ALL_XML&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;result&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;addVariant&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;result&lt;/font&gt;, &lt;font color="#2040a0"&gt;VARIANT_APPLICATION_XML&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;result&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;addVariant&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;result&lt;/font&gt;, &lt;font color="#2040a0"&gt;VARIANT_TEXT_XML&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;result&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  @&lt;font color="#2040a0"&gt;SuppressWarnings&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;unchecked&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  @&lt;font color="#2040a0"&gt;Override&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;T&lt;/font&gt; &lt;font color="#2040a0"&gt;toObject&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Representation&lt;/font&gt; &lt;font color="#2040a0"&gt;source&lt;/font&gt;, &lt;font color="#2040a0"&gt;Class&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;target&lt;/font&gt;, &lt;font color="#2040a0"&gt;UniformResource&lt;/font&gt; &lt;font color="#2040a0"&gt;resource&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;IOException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;    &lt;br /&gt;    .....    &lt;br /&gt;    &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;target&lt;/font&gt;.&lt;font color="#2040a0"&gt;getAnnotation&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;XmlRootElement&lt;/font&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;!&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;      &lt;br /&gt;      &lt;strong&gt;return&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;JaxbRepresentation&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;source&lt;/font&gt;, &lt;font color="#2040a0"&gt;target&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;.&lt;font color="#2040a0"&gt;getObject&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;IllegalStateException&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Should not have got here&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  @&lt;font color="#2040a0"&gt;Override&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Representation&lt;/font&gt; &lt;font color="#2040a0"&gt;toRepresentation&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Object&lt;/font&gt; &lt;font color="#2040a0"&gt;source&lt;/font&gt;, &lt;font color="#2040a0"&gt;Variant&lt;/font&gt; &lt;font color="#2040a0"&gt;target&lt;/font&gt;, &lt;font color="#2040a0"&gt;UniformResource&lt;/font&gt; &lt;font color="#2040a0"&gt;resource&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;IOException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Representation&lt;/font&gt; &lt;font color="#2040a0"&gt;result&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;source&lt;/font&gt;.&lt;font color="#2040a0"&gt;getClass&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;.&lt;font color="#2040a0"&gt;getAnnotation&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;XmlRootElement&lt;/font&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;!&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;result&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;JaxbRepresentation&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Object&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;source&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;else&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;result&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;super&lt;/strong&gt;.&lt;font color="#2040a0"&gt;toRepresentation&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;source&lt;/font&gt;, &lt;font color="#2040a0"&gt;target&lt;/font&gt;, &lt;font color="#2040a0"&gt;resource&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;result&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  .....&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;Great, so we have a Converter, how do we make Restlet use this converter for XML. In my &lt;span style="font-weight:bold;"&gt;common&lt;/span&gt; maven module (shared between client and web), I define a file in &lt;span style="font-style:italic;"&gt;META-INF/services/org.restlet.engine.converter.ConverterHelper&lt;/span&gt;, and in that file, I have a single entry defining my custom converter. Now when the client and service code use the &lt;span style="font-style:italic;"&gt;common&lt;/span&gt; library, they will use the Custom Converter I have defined for JAXB.&lt;br /&gt;Thus, to illustrate the change, my new resources for Orders and Order are shown below:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;@&lt;font color="#2040a0"&gt;Component&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;value&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;/orders&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;@&lt;font color="#2040a0"&gt;Scope&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;value&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;BeanDefinition&lt;/font&gt;.&lt;font color="#2040a0"&gt;SCOPE_PROTOTYPE&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrdersResource&lt;/font&gt; &lt;strong&gt;extends&lt;/strong&gt; &lt;font color="#2040a0"&gt;ServerResource&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt; &lt;br /&gt; ..... &lt;br /&gt; @&lt;font color="#2040a0"&gt;Post&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;xml&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt; &lt;font color="#2040a0"&gt;createOrder&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt; &lt;font color="#2040a0"&gt;dto&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;     ....&lt;br /&gt;     &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;createdOrderDto&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  ...&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;@&lt;font color="#2040a0"&gt;Component&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;value&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;/orders/{id}&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;@&lt;font color="#2040a0"&gt;Scope&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;value&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;BeanDefinition&lt;/font&gt;.&lt;font color="#2040a0"&gt;SCOPE_PROTOTYPE&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderResource&lt;/font&gt; &lt;strong&gt;extends&lt;/strong&gt; &lt;font color="#2040a0"&gt;ServerResource&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  @&lt;font color="#2040a0"&gt;Put&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;value&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;xml&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;updateOrder&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt; &lt;font color="#2040a0"&gt;orderDTO&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;id&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getRequest&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;.&lt;font color="#2040a0"&gt;getAttributes&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;.&lt;font color="#2040a0"&gt;get&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;id&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;orderDTO&lt;/font&gt;.&lt;font color="#2040a0"&gt;setOrderId&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Long&lt;/font&gt;.&lt;font color="#2040a0"&gt;parseLong&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;id&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;persistOrder&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;orderDTO&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;RuntimeException&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;getResponse&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;.&lt;font color="#2040a0"&gt;setStatus&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Status&lt;/font&gt;.&lt;font color="#2040a0"&gt;CLIENT_ERROR_BAD_REQUEST&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderException&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Failed to update an order&amp;quot;&lt;/font&gt;, &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    .....&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;We are no longer returning Representations in the above code. Quite similar to JAXRS, wouldn't you say ;-)? On the Client end, the OrderClientImpl no longer deals with Representations but only OrderDTOs as shown below:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderClientImpl&lt;/font&gt; &lt;strong&gt;implements&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderClient&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  ....&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt; &lt;font color="#2040a0"&gt;createOrder&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt; &lt;font color="#2040a0"&gt;order&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;ClientResource&lt;/font&gt; &lt;font color="#2040a0"&gt;ordersResource&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ClientResource&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;baseUri&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;ORDERS_RESOURCE_URI&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;ordersResource&lt;/font&gt;.&lt;font color="#2040a0"&gt;post&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;order&lt;/font&gt;, &lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ResourceException&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderException&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Error Creating an Order&amp;quot;&lt;/font&gt;, &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;updateOrder&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;OrderDTO&lt;/font&gt; &lt;font color="#2040a0"&gt;order&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;ClientResource&lt;/font&gt; &lt;font color="#2040a0"&gt;ordersResource&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ClientResource&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;baseUri&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;ORDERS_RESOURCE_URI&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;/&amp;quot;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;String&lt;/font&gt;.&lt;font color="#2040a0"&gt;valueOf&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;order&lt;/font&gt;.&lt;font color="#2040a0"&gt;getOrderId&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;ordersResource&lt;/font&gt;.&lt;font color="#2040a0"&gt;put&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;order&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ResourceException&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;OrderException&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Order Update Failed&amp;quot;&lt;/font&gt;, &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;br /&gt;I like the simplicity of the above and cannot wait to see the release of Restlet 2.0 that has the additional converters built in. &lt;br /&gt;&lt;br /&gt;For those interested, I have a &lt;a href="http://home.comcast.net/~acharya.s/java/Restlet2.0-jaxb-converter.zip"&gt;maven project example available for download&lt;/a&gt;. The project provided uses the custom JAXB converter. To execute the project, one would need to use JDK1.6.X and maven 2.0.9 or higher. To view an integration test in action execute, "&lt;span style="font-style:italic;"&gt;mvn install&lt;/span&gt;" from the root level of the project. The result should be something like:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;-------------------------------------------------------&lt;br /&gt; T E S T S&lt;br /&gt;-------------------------------------------------------&lt;br /&gt;Running com.welflex.order.IntegrationTest&lt;br /&gt;log4j:WARN No appenders could be found for logger (com.welflex.client.ProductClientImpl).&lt;br /&gt;log4j:WARN Please initialize the log4j system properly.&lt;br /&gt;Aug 28, 2009 8:59:55 PM org.restlet.engine.http.StreamClientHelper start&lt;br /&gt;INFO: Starting the HTTP client&lt;br /&gt;20:59:55 DEBUG - com.welflex.order.rest.ProductsResource.getProducts(44) | Getting Products in JSON Format&lt;br /&gt;Number of Available Products:3&lt;br /&gt;Product Id:663123&lt;br /&gt;Product Id:9912123&lt;br /&gt;Storing the order...&lt;br /&gt;Aug 28, 2009 8:59:55 PM org.restlet.engine.http.StreamClientHelper start&lt;br /&gt;INFO: Starting the HTTP client&lt;br /&gt;20:59:56 DEBUG - com.welflex.order.rest.OrdersResource.createOrder(45) | Call to post an order:..........&lt;br /&gt;Updating the order...&lt;br /&gt;Order successfully&lt;br /&gt;Retrieving the order...&lt;br /&gt;Deleting the order..&lt;br /&gt;20:59:56 DEBUG - com.welflex.order.rest.OrderResource.getOrder(86) | Requested order with id:5499731937442305515&lt;br /&gt;20:59:56 DEBUG - com.welflex.order.rest.ApplicationStatusService.getStatus(21) | In Order Status Service :class org.restlet.resource.ResourceException&lt;br /&gt;Expected Order to not be found. Look at the server stack we got back&lt;br /&gt;com.welflex.exception.OrderNotFoundException: Error obtaining Order&lt;br /&gt; at com.welflex.client.OrderClientImpl.getOrder(OrderClientImpl.java:60)&lt;br /&gt; at com.welflex.order.IntegrationTest.testLifeCycle(IntegrationTest.java:131)&lt;br /&gt; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;br /&gt; at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)&lt;br /&gt; at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)&lt;br /&gt; at java.lang.reflect.Method.invoke(Method.java:597)&lt;br /&gt; at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;More on Restlet 2.0 once its released. For now, maybe I should probably look toward cleaning up the JaxbConverter and submitting it to Restlet or better still head in the search of kindred spirits, if you know what I mean ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-7226916108904703456?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/7226916108904703456/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=7226916108904703456' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/7226916108904703456'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/7226916108904703456'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/08/restlet-20-example-using-spring-maven.html' title='Restlet 2.0 example using Spring, Maven, Annotations and a Custom Converter'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-1060837964620453214</id><published>2009-08-16T20:53:00.014-06:00</published><updated>2009-08-17T21:25:44.643-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='My name is Anthony Gonsalves'/><category scheme='http://www.blogger.com/atom/ns#' term='Amitabh Bachchan'/><title type='text'>Bollywood calling...I'm hanging up</title><content type='html'>Recently we got an invite to a party by some friends of ours. The theme of the party was &lt;a href="http://en.wikipedia.org/wiki/Bollywood"&gt;Bollywood&lt;/a&gt; stars. To add to the same, a mandate of the party was that every participant do a small skit based of the star they represent.&lt;br /&gt;&lt;br /&gt;I have not been on the stage since my school days where the last play I participated in was a silent one about Dr.Seuss. All mime, no dialogues.&lt;br /&gt;&lt;br /&gt;The wife and I were just not sure who we wanted to represent. Whenever the topic came about, I would divert the conversation as I didn't want to think about it.&lt;br /&gt;&lt;br /&gt;A day before D-Day, I am on YouTube desperately trying to get ideas. I see a song by my #1 hero of Bollywood, someone who's movies I grew up on, &lt;a href="http://en.wikipedia.org/wiki/Amitabh_Bachchan"&gt;Mr.Amitabh Bachchan&lt;/a&gt; and his all time classic role of &lt;a href="http://en.wikipedia.org/wiki/My_Name_Is_Anthony_Gonzalves"&gt;Anthony Gonsalves&lt;/a&gt; in the movie &lt;a href="http://en.wikipedia.org/wiki/Amar_Akbar_Anthony"&gt;Amar, Akbar, Anthony&lt;/a&gt;. After the movie, his character of Anthony Bhai achieved cult status in India. Now, the most famous image of Anthony Bhai is where he is dressed as a priest. Getting the same costume done would have been hard. However, there is another song of his that is a classic, "&lt;span style="font-style:italic;"&gt;My name is Anthony Gonsalves&lt;/span&gt;" where the main character of the movie, Anthony Gonsalves, is attempting to woo the heroine of the movie, Jenny, in an easter party.&lt;br /&gt;&lt;br /&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/uYEM7rgVpP8&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/uYEM7rgVpP8&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;Now the above song looked difficult but yet feasible, i.e., something the two of us can perform together. A coat, a hat, a gown, flower, umbrella, monocle...the prop search commences.&lt;br /&gt;&lt;br /&gt;We needed a coat with a tail. As I only had a black coat, the idea was to get some cardboard and attach it. During a visit to Walmart, we could not find any black cardboard. Improvising, we bought a yard of black cloth and attached the same to one of my old suits. The other props were easy (no monocles available though, decided on a pair of glasses). The hard part is doing the act. Hardly any time to practice or remember the lines. Its not easy to remember, "&lt;span style="font-style:italic;"&gt;You see the whole country of the system is......&lt;/span&gt;"&lt;br /&gt;&lt;br /&gt;We practiced an abridged version of the song a couple of times and then left it to chance.&lt;br /&gt;&lt;br /&gt;D-Day arrives, as we enter the party, we are surrounded with Bollywood stars, Bhiku Matre, Raj Kapoor, SRK , Sanjay Dutt, Salman Khan, Deepika Padukone, Rekha,..nice! The party is on, the hosts have taken considerable effort in making the party great. Now, due to certain spirits in the vicinity, my mind got clouded as the party moved forward resulting in me forgetting some of the lines. I watch the other stars perform and they perform admirably. Can't let Jenny down..got to remember, got to remember..go away you spirits..:-)&lt;br /&gt;&lt;br /&gt;Time to do the gig and we did something pretty close to what we had planned.&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/JaZscPvcyvU&amp;amp;hl=en&amp;amp;fs=1&amp;amp;"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;embed src="http://www.youtube.com/v/JaZscPvcyvU&amp;amp;hl=en&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" height="344" width="425"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;This was the first time my wife and I have done any skit together. We loved the party and managed to not totally embarrass ourselves in the process, at least so we believe :-) Finally, sorry Parveen, your Anthony might be cooler, but my Jenny is the best :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-1060837964620453214?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/1060837964620453214/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=1060837964620453214' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/1060837964620453214'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/1060837964620453214'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/08/bollywood-callingim-hanging-up.html' title='Bollywood calling...I&apos;m hanging up'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-5042330041353024208</id><published>2009-08-11T19:45:00.009-06:00</published><updated>2009-08-11T22:35:55.658-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Documenting Software'/><category scheme='http://www.blogger.com/atom/ns#' term='Documentation in IT'/><title type='text'>Documentating Software, my 2c</title><content type='html'>Documentation...&lt;span style="font-weight: bold;"&gt;.Aaargh.&lt;/span&gt;.why in heavens name would anyone waste time on it? The following few words are a window into my experiences and thoughts on documentation in IT organizations.&lt;br /&gt;&lt;br /&gt;Sadly, most organizations cannot or will not afford, the luxury of  an additional resource who is dedicated to just the task of documentation, i,e., a technical writer. So as developers and architects where does that leave us ?  I have heard statements such as:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;"&lt;span style="font-style: italic;"&gt;Your code should be clear enough such that documenting the same is redundant&lt;/span&gt;"&lt;/li&gt;&lt;li&gt;"&lt;span style="font-style: italic;"&gt;Documentation is not much value unless its kept up to date,  bad or expired documentation is worse than no documentation&lt;/span&gt;"&lt;/li&gt;&lt;li&gt;"&lt;span style="font-style: italic;"&gt;It is more important that the code has enough test coverage. The tests if good,  document the code use&lt;/span&gt;"&lt;/li&gt;&lt;li&gt;"&lt;span style="font-style: italic;"&gt;We do not have the time, it is lowest on our priority list. We got bigger fish to fry."&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Don't get me wrong, I am not in total disagreement regarding the above. Neither am I a subject matter expert on documentation. I am someone who often finds myself in the middle of this.&lt;br /&gt;&lt;br /&gt;What I find myself questioning is:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;If the code is so self documenting or clear, and if you find people keep asking the same question over an over, is it really so self documenting ?&lt;br /&gt;&lt;/li&gt;&lt;li&gt;If one created documentation, clearly it was considered important. If important, then it would need to updated with the same love when created.&lt;/li&gt;&lt;li&gt;And please, there is always time...:-)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;I have often entered an enterprise only to find that there is no Enterprise level documentation, stale or current. On the other hand, I have walked into an Enterprise only to be handed a thick set of pages to wade over to acclimatize myself.  Neither worked for me, what I was seeking as an entrant was to see the enterprise from the 2000 feet level and then drill down as appropriate.&lt;br /&gt;&lt;br /&gt;I am a very visual person, many a time a figure to me means more than a 1000 words. If there is a diagram that describes the stack the company uses, the applications, the services, even if partially wrong, immediately gives me a description of the architecture and/or project. That is a big win as far as acclimatising me to the environment.&lt;br /&gt;&lt;br /&gt;When different folk ask the same question to me many times over, to me, that is another clearly indication of a lack of documentation. If a topic is constantly questioned, it deserves a place IMHO for documentation such that the next time the question arises, I point the person posing the question to the documentation instead of the  repeated sermon that only I hold the copyrights to. &lt;span style="font-weight: bold;"&gt;DRY&lt;/span&gt; (Don't repeat yourself) does not apply to code alone...&lt;br /&gt;&lt;br /&gt;Documentation is often created with great detail and appears as a big win, however if it starts becoming stale, then it loses its value and significance and becomes more of a "&lt;span style="font-weight: bold;"&gt;White Elephant&lt;/span&gt;".  A conversation I had with someone in the past:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Someone:&lt;/span&gt; "&lt;span style="font-style: italic;"&gt;Can you help me with this?&lt;/span&gt;"&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Me:&lt;/span&gt; "&lt;span style="font-style: italic;"&gt;Sure, did you check the documentation on the same?&lt;/span&gt;"&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Someone:&lt;/span&gt; "&lt;span style="font-style: italic;"&gt;Yeah but that is so outdated, so I don't bother looking at it any more&lt;/span&gt;"&lt;br /&gt;&lt;br /&gt;The above conversation totally supports the argument that bad or documentation that are stale are definite deterrents to readers.&lt;br /&gt;&lt;br /&gt;The following represent a few directions regarding documentation that I will try to adhere to: &lt;ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Enterprise or Project Documentation or "The BIG Picture documentation":&lt;/span&gt;  From an Enterprise architect perspective, providing a high level description/diagram of the entire enterprise and how it all fits or works together can be valuable.  The documentation does not have to drill into the microscopic details but instead provide a more a high level view that helps an entrant understand how all the parts of an enterprise fit together. From the perspective of a team lead/lead developer, it would be beneficial if documentation were provided regarding the boundaries and dependencies of a particular project.   There is no need for details of a database schema, however there is need to indicate that the application talks to a particular schema on a particular database . These documents might even be able to help detect problems in the architecture, as now, you are looking at "&lt;span style="font-weight: bold;"&gt;The Big Picture&lt;/span&gt;" From previous experience, I also feel that documenting "&lt;span style="font-weight: bold;"&gt;Big&lt;/span&gt;" decisions that affect a project can have great value. With time, we tend to forget the reasons for choosing a direction. A place to consult back as to "Why?" can prove valuable.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Stack Documentation: &lt;/span&gt;A diagram and/or description indicating the various technology stack in play. For example, "JBoss - App Server, Spring Framework, HP UX - 10.2 deployment OS, ..". This might be encompassed within the scope of point no.1.  Again, stacks are rarely changed, and if they are, they probabaly require immediate attention&lt;span style="font-weight: bold;"&gt;.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Repeated Query Documentation: &lt;/span&gt;If any question posed to a developer or architect is being asked more than once, regardless of its longevity deserves due diligence in the documentation space. In lawyer terms, it would classify as "&lt;span style="font-style: italic;"&gt;Asked and answered&lt;/span&gt;" :-).  If you enjoy the interaction and enjoy repeating the same answer, well then more power to you , please disregard the documentation angle&lt;span style="font-weight: bold;"&gt;.&lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Redundant Documentation : &lt;/span&gt;Code that contains redundant or unnecessary documentation (i.e., code is self explanatory) serves no purpose. I violate this sometimes and need to stop. For example, getters and setter of a POJO (Plain Ole Java object) rarely requires documenting if the method name is clear. Institute naming standards that are enforced. Don't bother with class or schema diagrams, any developer worth his salt will be able to easily find free tools to reverse engineer classes or database schema's and be able to get the most current versions of the same.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Documenting Complex Code: &lt;/span&gt;Code that is unavoidably complex, deserve either strong documentation or better still refactoring.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Job security as it applies to documentation: &lt;/span&gt;Job security is not improved by keeping the details in your head. People are smart and folks that tend to do that will not last in a smart organization. Organizations lacking strong leaders, well get strong and smart leaders :-)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;When to document and how much ? : &lt;/span&gt;Things that are in constant flux are hard to document, wait for stabilization. However, do follow up after stabilization occurs. Make sure your code works first, then comes the documentation. If you have good documentation but code that is broken, thats not a win. In the same vein, I would go further to say, Unit Tests and Integration Tests are more valuable than documentation. Place yourself in the position of a person who will utilize the documentation, make the content detailed enough for your intended audience. For example, in an enterprise level document, do not bother listing individual Web Services or Database Schemas, it is enough to state that Web Services communicate with databases and or other Web Services. The detail in the documentation should also be only that much that you can afford to keep current moving forward. Finally piggy backing on this point, broken windows or no windows from the top can send a bad message. What I mean is, "If an architect or lead themselves do not document, then it becomes a hard sell to a developer that they need to document"&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Detail and Artistry of Documentation: &lt;/span&gt;Reiterating, "&lt;span style="font-style: italic;"&gt;Make it right before making it pretty&lt;/span&gt;". A straw diagram caught on a white board via a cell phone camera during the design, if posted on a WIKI is often as effective as a colorful work of art.  High ceremony documentation is almost too much and often unnecessary. Concise and to the point documentation works in most cases. People are smart, they often like a start. Its like being provided a map into Yellowstone regarding the sights to see. One does not require information on the concentration of sulfur at each site, just where the sites are located, we'll figure out the sulfur content at each site :-)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Tools for documentation: &lt;/span&gt;Use a tool that works for collaborative authoring such as a &lt;a href="http://en.wikipedia.org/wiki/Wiki"&gt;WIKI&lt;/a&gt;. Almost any software development project IMO deserves a WIKI or equivalent presence.&lt;a href="http://www.mediawiki.org/wiki/MediaWiki"&gt; Media WIKI&lt;/a&gt; and such are free to use, so a smart person would avail such tools. Use technology where applicable.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Collaborative Documentation: &lt;/span&gt;Documentation on IT projects should not belong to a single owner but be considered a collaborative effort. In other words, every member of the team should feel that they can add or correct toward the documentation. If a person comes asking a question and you give an answer, if you ask the person to document the same as you feels its valuable and is missing, you might be surprised as to how gladly they are willing to contribute. On the same note when you find documentation that is outdated and more importantly wrong, deprecate the documentation at the very top if you do not have the time to make it current.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;How to get started, documentation:&lt;/span&gt; As an entrant into a new IT environment, one often needs to get set up and be ready to get productive. A road map documentation that provides a user of "What, Why, Where, Who" can be quite useful.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Selling documentation to the business:&lt;/span&gt; Getting business to account for time slots for code testing itself can be a daunting task in some organizations, getting a time slot in the project budget for documentation can be harder sale. However, as a lead or person making an estimate of a project, it is important to bake in the same. Documentation is money, however you need to sell the same and its value to the business. Lack of critical documentation is something that can come back to haunt you. "&lt;span style="font-style: italic;"&gt;Protect your skin and those of your kinsmen&lt;/span&gt;" :-)&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;I am sure I have only touch the tip of what needs documentation. I cannot claim the title of a "&lt;span style="font-style: italic;"&gt;Documentation nazi&lt;/span&gt;" and/or authority, neither am I claiming a &lt;span style="font-style: italic;"&gt;"One set of rules fits all&lt;/span&gt;". People have probably written books on the same.....Easy to preach, hard to do, but hey, trying is not so hard, is it, and that is motive, trying ;-)...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-5042330041353024208?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/5042330041353024208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=5042330041353024208' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/5042330041353024208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/5042330041353024208'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/08/documentating-software-my-2c.html' title='Documentating Software, my 2c'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-3166976772702126967</id><published>2009-06-26T22:49:00.016-06:00</published><updated>2009-07-10T22:12:01.893-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Michael Jackson'/><title type='text'>Farewell Michael Jackson</title><content type='html'>There has been a spate of news flooding the media after the sudden demise of arguably the musical sensation of the century. There are people who still cannot get over his sudden demise, people who are sick of the continued media coverage and those who are indifferent. This BLOG is a few words from me to express my feelings on the passing of a man whose music I loved growing up and still do.&lt;br /&gt;&lt;br /&gt;Going back in time, one day during my schooling years, a friend of mine had this audio cassette that he said I must hear as the songs from it were just super. I heard "&lt;a href="http://en.wikipedia.org/wiki/Wanna_Be_Startin%27_Somethin%27"&gt;Wanna be starting something&lt;/a&gt;" and I was of gyrating to the beats. Not the most famous song of M.J, and I cannot claim I understood the lyrics, but I liked it. Especially, I had my own version of "&lt;span style="font-style: italic;"&gt;Mama-se, mama-sa, ma-ma-coo-sa&lt;/span&gt;" that I would be dancing to ;-)&lt;br /&gt;&lt;br /&gt;Then I heard&lt;a href="http://en.wikipedia.org/wiki/Beat_It"&gt; Beat It &lt;/a&gt;and &lt;a href="http://en.wikipedia.org/wiki/Billie_Jean"&gt;Billie Jean&lt;/a&gt;. Hearing the vocals and guitaring on the former (Eddie Van Halen on the guitar), hearing the introduction on the latter had me hooked! I must admit that the first time I heard him, I was of the impression that the singer was a female.&lt;br /&gt;&lt;br /&gt;Then started the research into who this artiste was. Steps back in time hearing "&lt;a href="http://en.wikipedia.org/wiki/Off_the_Wall_%28album%29"&gt;Off the wall&lt;/a&gt;" and others got me more interested in M.J. Following suite was trying to get videos of him performing, something not easily available in India at the time. I watched the &lt;a href="http://www.youtube.com/watch?v=MfIE3Rz6IgE"&gt;moon walk &lt;/a&gt;that he performed for the &lt;a href="http://www.motown.com/"&gt;Motown&lt;/a&gt; anniversary. Recollecting the time, I remember all my friends trying their very best to do this moon walk. What a dance step.  This person was more than just a singer that I liked, he was a dancer that I could never hope to be. I had found an artist who was a complete entertainer. Before you knew it, my brother and I had most of the Jackson songs in our collection, even if it meant begging my parents to buy a tape for one song considering we already had the rest in our collection. Thanks dad and mom for humoring us.&lt;br /&gt;&lt;br /&gt;At the time, in India one could either purchase L.P records or Tapes. Music quality from the tapes were not the best, however, even with the quality available I remember my brother and I enjoying the music and trying very hard to decipher the lyrics. No internet available at that time :-)&lt;br /&gt;&lt;br /&gt;Time flew, the next album we eagerly awaited and got was "&lt;a href="http://en.wikipedia.org/wiki/Bad_%28album%29"&gt;Bad&lt;/a&gt;". M.J had changed his face considerably by now, the songs were different compared to "&lt;a href="http://en.wikipedia.org/wiki/Thriller_%28album%29"&gt;Thriller&lt;/a&gt;". It took me time for the songs to grow on me, his looks although strange were not much of a deterrent for me, that was his personal life so to say.  M.J still rocked!&lt;br /&gt;&lt;br /&gt;Continued to watch sporadic news that trickled in about M.J, him sleeping in an Oxygen Chamber, "&lt;span style="font-style: italic;"&gt;Bubbles&lt;/span&gt;" the chimp, more surgeries etc etc....To be honest, again these oddities as reported by the media did not affect me in a way to reduce my admiration of the man.&lt;br /&gt;&lt;br /&gt;Time flew on, then came the "Pedophile" accusations and scandals. At this point, it was more than eccentric indulgences of a man who has more money than what he knew to do with. I really did not know what to believe. As a fan, I hoped that my childhood idol would be exonerated. As an evaluator, I was of the opinion, a man is innocent till proven guilty. Cut it anyway, the fact that he was a great artist could not be blemished by the results of the court cases. If you choose to, blame it on the legal system or the compromising accusers, there was no conviction. As a bystander, I can only accept the result. Guilty or otherwise, I primary held the parents of the children who claimed abuse responsible for allowing such a situation to present itself in the first place. Did they really need to let their children sleep over in a strangers home??? Come on!&lt;br /&gt;&lt;br /&gt;After all these incidents, one would hear of a one off concert where M.J would be in news and then silence ensuing for months, sometimes years on end. Financial problems, and the "Martin Bashir" interview are what I followed. M.J's appeal and record selling ability had dwindled, I however still like the song "&lt;a href="http://www.youtube.com/watch?v=e3wShd_bX8A&amp;amp;feature=fvst"&gt;Rock my world&lt;/a&gt;" though.&lt;br /&gt;&lt;br /&gt;Years pass, I hear that he is about to perform again in 2009; a curtains concert and that tickets are sold out like hot cakes. Happy for the man. Also hear that he is in the process of making a new album. Happy to hear the news and hoping he will be back with an album to match the genius of "Thriller".&lt;br /&gt;&lt;br /&gt;In my office, I hear, M.J has been hospitalized. Do not give much interest to the news as I do not feel it was serious. This is M.J we are talking about, a great dancer, a physically fit person, at least that was the impression imprinted in my brain growing up. Soon after a colleague of mine says that some sites are reporting M.J is dead. I refuse to believe saying its not been announced on "CNN", its not been announced on "BBC". Denial at work here...&lt;br /&gt;&lt;br /&gt;Soon after, my trusted news sites report that M.J has in fact passed away. Saddened now. This just felt chronologically wrong, out of order. How could M.J pass on when others that I had placed ahead of him in the passing order have not? Shocked and saddened at the loss...still not ready to believe the obvious. News that he died in a car accident, News that he was murdered were all acceptable outcomes for my sensibility, but sudden death by heart failure ???&lt;br /&gt;&lt;br /&gt;Reach home and am hooked on CNN watching the events unfold. M.J's demise reminded me of my own mortality in a way...the random factor had wreaked havoc for me.  Watching CNN get into news about his weirdness was not what I expected. I had hoped that a person such as M.J would be more remembered for his music and creative genius. Felt disappointed that the media were focusing more on the negativity involved in his life.&lt;br /&gt;&lt;br /&gt;In the end, there are people who hate him, have convicted him in their minds as a pedophile and there are people who believe he was innocent and then there are majority who simply respected the man for his immense talent.  I am part of the latter faction and I will miss the possible creative and artistic contributions he would have provided were he alive. The world has lost a great artiste.&lt;br /&gt;&lt;br /&gt;Everyone will remember M.J in their own way. Like one person said, one will remember where one was on the day M.J passed away, I for one definitely will. The man has done considerable work for charity and causes. Maybe more than many of will ever be able to do. Remember the man for what he did good. I admit that he was a strange bird....however please try to remember him for his abilities and contributions as an entertainer/singer.&lt;br /&gt;&lt;br /&gt;From my end, every time the song "&lt;span style="font-style: italic;"&gt;Billie Jean&lt;/span&gt;" or "&lt;span style="font-style: italic;"&gt;Beat It&lt;/span&gt;" starts on my Boxster, I will have a smile on my face and be in an upbeat mood...it takes me back to my childhood, it reminds me of the good times my brother and I had as kids...thanks M.J...I will miss your singing..Eddie Van Halen or Slash on the guitar..the pedal is hitting the floor....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-3166976772702126967?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/3166976772702126967/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=3166976772702126967' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/3166976772702126967'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/3166976772702126967'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/06/farewell-michael-jackson.html' title='Farewell Michael Jackson'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-7990014358279000372</id><published>2009-06-23T22:15:00.003-06:00</published><updated>2009-06-23T22:30:33.525-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JMS Topic Scaling'/><category scheme='http://www.blogger.com/atom/ns#' term='JMS Weblogic'/><category scheme='http://www.blogger.com/atom/ns#' term='JMS Patterns'/><category scheme='http://www.blogger.com/atom/ns#' term='Distributed Queues'/><title type='text'>Scaling in the JMS World...in particular Topics</title><content type='html'>Scalability and Availability in JMS. For the former, as load on the messaging system increases, one would want to be able to service the increased messages without performance degradation. For the latter, one should ensure the reduction if not elimination of single point of failures, i.e., ensuring system is available for use.&lt;br /&gt;&lt;br /&gt;Most JMS Providers have some sort of mechanism for addressing the above. This BLOG is however only going to concentrate on &lt;a href="http://www.oracle.com/appserver/weblogic/weblogic-suite.html"&gt;Oracle WebLogic&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;WebLogic has an interesting way in which JMS Destinations (Queues and Topics) are scaled via D&lt;a href="http://e-docs.bea.com/wls/docs103/jms/dds.html"&gt;istributed or Virtual Destinations&lt;/a&gt;. A Virtual Destination can be considered a sort of router/load balancer that distributes messages it receives over to actual or physical destinations. Each physical destination would reside in separate WebLogic instances on potentially separate hardware. See figure below where a virtual destination "test_queue" has physical members &lt;span style="font-style: italic;"&gt;test_queue_1,  test_queue_2&lt;/span&gt; and&lt;span style="font-style: italic;"&gt; test_queue_3&lt;/span&gt; on separate WebLogic instances:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_SqKefSIXc5Y/SjhIJjFcKgI/AAAAAAAAASw/pB8pElaRAo8/s1600-h/weblogic-cluster.png"&gt;&lt;img style="cursor: pointer; width: 320px; height: 126px;" src="http://1.bp.blogspot.com/_SqKefSIXc5Y/SjhIJjFcKgI/AAAAAAAAASw/pB8pElaRAo8/s320/weblogic-cluster.png" alt="" id="BLOGGER_PHOTO_ID_5348103886376544770" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As an example of Virtual Queues in action, in the conceptual figure shown below, Producers send messages to the Virtual Queue which then directs the message to one of the physical destinations&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_SqKefSIXc5Y/SjhNU5gkELI/AAAAAAAAATQ/v1FUtR6UdMk/s1600-h/dq.png"&gt;&lt;img style="cursor: pointer; width: 320px; height: 146px;" src="http://2.bp.blogspot.com/_SqKefSIXc5Y/SjhNU5gkELI/AAAAAAAAATQ/v1FUtR6UdMk/s320/dq.png" alt="" id="BLOGGER_PHOTO_ID_5348109578932588722" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;P&lt;/span&gt; : Producers&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;VQ&lt;/span&gt;: Virtual Queue&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;PQ-X&lt;/span&gt;: Physical Queue, where X is the number of the Queue&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;C&lt;/span&gt;: Consumer&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;M&lt;/span&gt;: Message&lt;br /&gt;&lt;br /&gt;In the case of a Virtual Topic, messages sent to the Virtual Topic are sprayed on to each and every physical member as shown in the figure below where VT and PT-X represent Virutal and Physical topics respectively:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_SqKefSIXc5Y/SjhMDeVF3-I/AAAAAAAAATI/fnov-7xSpuk/s1600-h/dt.png"&gt;&lt;img style="cursor: pointer; width: 320px; height: 153px;" src="http://1.bp.blogspot.com/_SqKefSIXc5Y/SjhMDeVF3-I/AAAAAAAAATI/fnov-7xSpuk/s320/dt.png" alt="" id="BLOGGER_PHOTO_ID_5348108180067311586" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Scaling Queues:&lt;/span&gt;&lt;br /&gt;From the figure shown regarding Queues, it is pretty simple to follow how the system scales and that it will continue to service new messages and consume them should one of the servers in the messaging cluster fails. A message will be consumed at most by one of many consumers  successfully. Adding Consumers to the end of the physical members allow the architecture to process messages rapidly, i.e., &lt;a href="http://www.enterpriseintegrationpatterns.com/CompetingConsumers.html"&gt;Competing Consumer Design Pattern&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Now, what if one of the servers having physical members went down, for example &lt;span class="Apple-style-span" style="font-style: italic;"&gt;VQ-1&lt;/span&gt; went down?  From the perspective of availability, messages are still flowing and getting consumed from the other available member, i.e., &lt;span class="Apple-style-span" style="font-style: italic;"&gt;VQ-2&lt;/span&gt;. What about the messages that were in the physical member whose server went down? One has multiple options. The first and most straight forward is to restart the server and re-connect the consumers to drain the queue. WebLogic allows for &lt;a href="http://e-docs.bea.com/wls/docs103/cluster/service_migration.html"&gt;auto-service migration&lt;/a&gt; in the event of failure. This is another feature that can assist in recovering from failure. Queues readily tend to present themselves for scaling. One note on the same, if &lt;a href="http://e-docs.bea.com/wls/docs103/jms/uoo.html"&gt;message ordering&lt;/a&gt; is put into play, all bets are off :-)..more on the same on a subsequent blog.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Scaling Topics:&lt;/span&gt;&lt;br /&gt;Topics unlike Queues present an interesting challenge. In the case of a topic, a message is delivered to all listeners of the topic and each listener is typically different than its peer in how it handles the message.  For example a message posted to an order topic, might have a consumer that processes the order while another one looks at inventory calculations:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_SqKefSIXc5Y/SkGURYpIL-I/AAAAAAAAATg/zvU40NY0v_E/s1600-h/orderproc.png"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://1.bp.blogspot.com/_SqKefSIXc5Y/SkGURYpIL-I/AAAAAAAAATg/zvU40NY0v_E/s320/orderproc.png" alt="" id="BLOGGER_PHOTO_ID_5350720858686500834" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Clearly we cannot have two consumers that process the same order and it is redundant to have duplicate consumers perform the same inventory calculations.&lt;br /&gt;&lt;br /&gt;Messaging systems have the concept of a &lt;a href="http://www.enterpriseintegrationpatterns.com/DurableSubscription.html"&gt;Durable Subscriber&lt;/a&gt;, i.e., a Message listener who registers with the topic such that they are delivered messages  sent to the topic even when the listener is not connected. Message providers store the message on behalf of the durable subscriber and forward the same when the subscriber comes back on line.&lt;br /&gt;&lt;br /&gt;In WebLogic one cannot connect to a durable subscriber using a distributed (virtual) destination JNDI. One has to explicitly register with a physical member. This is one gripe that I have with the WebLogic solution. Adding to the problem, should one connect to one physical member and if that member goes down, attempting to establish the durable subscription on other available members are treated like totally new subscriptions. In consolation, if the server goes down that contains durable subscriptions, then messages will be stored on other physical members of the virtual topic on behalf of the durable subscribers, and when the server is restored, messages get forwarded to the durable subscribers when they comes back on line as shown below:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_SqKefSIXc5Y/SjhbzQJA2rI/AAAAAAAAATY/CvpwxnPZ4h8/s1600-h/durable-failure.png"&gt;&lt;img style="cursor: pointer; width: 232px; height: 320px;" src="http://4.bp.blogspot.com/_SqKefSIXc5Y/SjhbzQJA2rI/AAAAAAAAATY/CvpwxnPZ4h8/s320/durable-failure.png" alt="" id="BLOGGER_PHOTO_ID_5348125493566692018" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now, as each subscriber of the topic has a unique agenda from the other subscribers, the fact that it is the sole entity that services the message, the same represents a single point of failure and a proves a scalability inhibitor as it cannot concurrently process multiple messages.&lt;br /&gt;&lt;br /&gt;So how can one scale a topic so that a message on a given type of subscriber can be rapidly processed?  One direction is have the consumer of a Topic post the message onto a Queue which can then be processed by competing consumers. One way this can be achieved is to have a Message Driven Bean withing the container whose sole purpose is to transfer the message from the topic to a queue for those consumers that need to scale. An example of the same is shown below:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_SqKefSIXc5Y/SkGZfmZVRtI/AAAAAAAAATw/iOceK1aX7vc/s1600-h/transferTopic.png"&gt;&lt;img style="cursor: pointer; width: 320px; height: 202px;" src="http://3.bp.blogspot.com/_SqKefSIXc5Y/SkGZfmZVRtI/AAAAAAAAATw/iOceK1aX7vc/s320/transferTopic.png" alt="" id="BLOGGER_PHOTO_ID_5350726600454653650" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In the above shown example, as one consumer of the topic needs processing to rapidly occur of messages received, an MDB (registered as a durable subscriber of the topic) is used to transfer every message onto a Queue which is then consumed by competing consumers. As other consumers, DC-1 and DC-2 are not in need of scaling, they remain durable single subscribers.&lt;br /&gt;&lt;br /&gt;The above solution works to scale the durable subscriber of a topic. However, in WebLogic when using distributed topics the durable MDB still represents a single point of failure.&lt;br /&gt;&lt;br /&gt;A question to ask at this point is, "&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Do you really need a topic for the use case at hand?&lt;/span&gt;" Topics are great IMO when the subscribers tend to be &lt;span style="font-weight: bold;"&gt;dynamic&lt;/span&gt; in nature or do not need to be durable, an example of the former is a stock quote topic and an example of the latter is a event listener that requires notification of an event.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;When the number of subscribers are a known or finite in amount, the use of a queue coupled with the MDB can easily achieve a scalable solution as shown below where the MDB transfers messages on the in-queue to subsequent out-queues where competing consumers can scale and consume the messages:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_SqKefSIXc5Y/SkGeHhnZIyI/AAAAAAAAAT4/dOJu4O6gSBY/s1600-h/transferQueue.png"&gt;&lt;img style="cursor: pointer; width: 320px; height: 255px;" src="http://3.bp.blogspot.com/_SqKefSIXc5Y/SkGeHhnZIyI/AAAAAAAAAT4/dOJu4O6gSBY/s320/transferQueue.png" alt="" id="BLOGGER_PHOTO_ID_5350731684412728098" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Transfer MDB:&lt;/span&gt;&lt;br /&gt;It is pretty trivial to create the Transfer MDB. One would typically like to re-use the Transfer MDB Java Code with only configuration changes for different applications. The same can easily achieved via separate projects where target destination can be provided via @Resource. A simple transfer MDB is shown below:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;@&lt;font color="#2040a0"&gt;MessageDriven&lt;/font&gt;&lt;br /&gt;@&lt;font color="#2040a0"&gt;TransactionAttribute&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;TransactionAttributeType&lt;/font&gt;.&lt;font color="#2040a0"&gt;REQUIRED&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;MessageRouterMdb&lt;/font&gt; &lt;strong&gt;implements&lt;/strong&gt; &lt;font color="#2040a0"&gt;MessageListener&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="#444444"&gt;&lt;i&gt;/**&lt;br /&gt;   * Map this jms connection factory to the actual one in the weblogic-ejb-jar.xml deployment&lt;br /&gt;   * descriptor of the ejb project. The Connection factory to be used will be the one that is&lt;br /&gt;   * specific to this mdb.&lt;br /&gt;   */&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;  @&lt;font color="#2040a0"&gt;Resource&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;name&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;jms/connectionFactory&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt; &lt;font color="#2040a0"&gt;connectionFactory&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="#444444"&gt;&lt;i&gt;/**&lt;br /&gt;   * Injected in Message Driven Context&lt;br /&gt;   */&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;  @&lt;font color="#2040a0"&gt;Resource&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;font color="#2040a0"&gt;MessageDrivenContext&lt;/font&gt; &lt;font color="#2040a0"&gt;mdc&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="#444444"&gt;&lt;i&gt;/**&lt;br /&gt;   * Define a comma separated list of destinations JNDI names in the ejb-jar.xml via an environment&lt;br /&gt;   * entry.&lt;br /&gt;   */&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;  @&lt;font color="#2040a0"&gt;Resource&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;targetDestinations&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="#444444"&gt;// Initialized&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;font color="#2040a0"&gt;List&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Destination&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;targetJmsDestinations&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;font color="#2040a0"&gt;MessageProducer&lt;/font&gt; &lt;font color="#2040a0"&gt;messageProducer&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;font color="#2040a0"&gt;Connection&lt;/font&gt; &lt;font color="#2040a0"&gt;connection&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;font color="#2040a0"&gt;Session&lt;/font&gt; &lt;font color="#2040a0"&gt;session&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  @&lt;font color="#2040a0"&gt;PostConstruct&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;init&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;InitialContext&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;InitialContext&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;connection&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;connectionFactory&lt;/font&gt;.&lt;font color="#2040a0"&gt;createConnection&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;session&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;connection&lt;/font&gt;.&lt;font color="#2040a0"&gt;createSession&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;false&lt;/strong&gt;, &lt;font color="#2040a0"&gt;Session&lt;/font&gt;.&lt;font color="#2040a0"&gt;AUTO_ACKNOWLEDGE&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;messageProducer&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;session&lt;/font&gt;.&lt;font color="#2040a0"&gt;createProducer&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;null&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;targetDestArray&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;StringUtils&lt;/font&gt;.&lt;font color="#2040a0"&gt;split&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;targetDestinations&lt;/font&gt;, &lt;font color="#008000"&gt;&amp;quot;,&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;targetJmsDestinations&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ArrayList&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Destination&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;for&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;targetDest&lt;/font&gt; &lt;font color="4444FF"&gt;:&lt;/font&gt; &lt;font color="#2040a0"&gt;targetDestArray&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;targetJmsDestinations&lt;/font&gt;.&lt;font color="#2040a0"&gt;add&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Destination&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;.&lt;font color="#2040a0"&gt;lookup&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;targetDest&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;connection&lt;/font&gt;.&lt;font color="#2040a0"&gt;start&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;     &lt;br /&gt;      &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;RuntimeException&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Error Initializing Message Router Mdb&amp;quot;&lt;/font&gt;, &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;onMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt; &lt;font color="#2040a0"&gt;message&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#444444"&gt;// Loop through target destinations and send message to each destination&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;for&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Destination&lt;/font&gt; &lt;font color="#2040a0"&gt;dest&lt;/font&gt; &lt;font color="4444FF"&gt;:&lt;/font&gt; &lt;font color="#2040a0"&gt;targetJmsDestinations&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;messageProducer&lt;/font&gt;.&lt;font color="#2040a0"&gt;send&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;dest&lt;/font&gt;, &lt;font color="#2040a0"&gt;message&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;mdc&lt;/font&gt;.&lt;font color="#2040a0"&gt;setRollbackOnly&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;br /&gt;  @&lt;font color="#2040a0"&gt;PreDestroy&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;cleanup&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#444444"&gt;// Close open jms resources here...&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;br /&gt;The CODE for the above MDB and an example Maven Project that uses WebLogic is &lt;a href="http://home.comcast.net/~acharya.s/java/routerMdbProject.zip"&gt;available for download HERE&lt;/a&gt;. Note that the code is not specific to WebLogic and can really be used in any container, for example JBoss. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Conclusion:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Scaling topics via an MDB and target queues just felt like an obvious pattern to me. WebLogic, like many JMS Providers has the concept of a Message Bridge. Initial investigation led me to believe that a message bridge more serves the purpose of transferring a message from one provider to to another rather than serving to scale a Topic and distributed messages to multiple destinations. &lt;br /&gt;&lt;br /&gt;There may be cases as mentioned where the number of subscribers are not known. In such a case, a topic might work and it becomes the responsibility of the subscribers to scale on their end, for example multi-threading upon receiving the message.&lt;br /&gt;&lt;br /&gt;What really would be nice if the JMS specification had the concept of "&lt;span style="font-weight:bold;"&gt;Durable Competing Consumers&lt;/span&gt;" where a Durable subscriber could register multiple instances of itself such that a message to a topic would be delivered to at most it or one of its clones :-). I believe there are some Messaging providers who permit such a pattern via customization that extend the JMS specifications.&lt;br /&gt;&lt;br /&gt;Before bidding adieu, this has been one of my most figurative blogs, all Ye artists, look at the diagrams with a forgiving eye, "I am a programmer not an artist!" :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-7990014358279000372?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/7990014358279000372/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=7990014358279000372' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/7990014358279000372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/7990014358279000372'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/06/scaling-in-jms-worldin-particular.html' title='Scaling in the JMS World...in particular Topics'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_SqKefSIXc5Y/SjhIJjFcKgI/AAAAAAAAASw/pB8pElaRAo8/s72-c/weblogic-cluster.png' height='72' width='72'/><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-1659668460817486104</id><published>2009-05-22T20:02:00.004-06:00</published><updated>2009-05-22T20:40:26.247-06:00</updated><title type='text'>Ending the drought...</title><content type='html'>Its been a month since I posted anything on my BLOG, cannot let May end with a drought. It has been rather a trying month for me,  the reasons I am saving for a later melodramatic post ;-)...&lt;br /&gt;&lt;br /&gt;Right now I am very happy. At the company I currently work at, we released out a JMS architecture with minimal hiccups. It was very gratifying to witness the entire team involved work and mesh so well in order to make the architecture work. Everyone from Architects, Developers, System Administrators, Testers worked so well together. I must state that my level of confidence in the team and players involved was so much that I did not even have to be there during the go live in person. Put it in a word, my current organization is so much about "WE" and not "ME". That is a motto that works IMHO. Guess my current organization is very talented in its selection process of the people they want on board.&lt;br /&gt;&lt;br /&gt;I truly enjoyed working with all the folks on the various facets involving the deployment of the architecture, frameworks, deployment, projects etc. We suffered a few hiccups after the deploy as well but the messaging solution itself was 100% solid. In fact in my own retarded way, I appreciated the fact that the failures occurred as they served to demonstrate that the failure path in fact worked  ;-)&lt;br /&gt;&lt;br /&gt;Personally, I have experienced considerable growth in the areas of JMS Messaging. However, every once so often I again am humbled by what I don't know or did not anticipate.&lt;br /&gt;&lt;br /&gt;The project as a whole was like our baby that finally saw the light..and danced on...I hope it keeps dancing :-))))))))))) Even if does not, I believe we have a team strong enough to put it on crutches to make it so...&lt;br /&gt;&lt;br /&gt;I can't wait for further adoption of the architecture...so thrilled, had a blast...&lt;br /&gt;&lt;br /&gt;More BLOG's coming up soon, the little GREY cells were on vacation (not dead, just vacationing), you should see something from them soon....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-1659668460817486104?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/1659668460817486104/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=1659668460817486104' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/1659668460817486104'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/1659668460817486104'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/05/ending-drought.html' title='Ending the drought...'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-1227234083829217332</id><published>2009-04-24T20:56:00.008-06:00</published><updated>2009-04-26T09:34:47.544-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Weblogic JMS QueueBrowser'/><category scheme='http://www.blogger.com/atom/ns#' term='Weblogic JMS Distributed Queue'/><category scheme='http://www.blogger.com/atom/ns#' term='Weblogic JMX example'/><title type='text'>Browsing Weblogic JMS Distrubuted Queues</title><content type='html'>On of the interesting features of Weblogic is that when&lt;span style="font-style: italic;"&gt; javax.jms.QueueBrowsers&lt;/span&gt; are created, they are pinned to a particular physical member of a distributed destination. What that means is that a QueueBrowser created for a distributed destination will only be able to browse messages on the member it gets pinned to and not the whole queue.&lt;br /&gt;&lt;br /&gt;One can try to create X number of queue browsers based of the number of servers in the provider URL, for example, "t3://localhost:8002, localhost:8003", and hope that no two queue browsers will pin to the same destination, i.e., at the mercy of Weblogic round robin if possible. Even if we do manage to do that, one still needs to iterate over X separate enumerations in order to manage the message. Consider an integration test where one sends a message to a distributed destination and would have to create X queue browsers to determine whether or not the message is present.&lt;br /&gt;&lt;br /&gt;What would be really nice is if the Weblogic runtime gave us a QueueBrowser that provided an &lt;span style="font-style: italic;"&gt;enumeration of enumerations&lt;/span&gt; of the physical members of a distributed queue. That however is not present. So, I decided to create a simple example that would help me with the same. At the same time, I am interested in understanding the &lt;span style="font-style: italic;"&gt;JMX&lt;/span&gt; capabilities of Weblogic.&lt;br /&gt;&lt;br /&gt;The example will create a QueueBrowser and obtain an enumeration from each of the physical members of the distributed destination and provide back an enumeration of the respective enumerations. In the case of uniformly created distributed destinations, the JNDI name of the physical members will be of the format &lt;span style="font-style: italic;"&gt;JMSServerName@JNDIName&lt;/span&gt;. If one knows the &lt;span style="font-style: italic;"&gt;JMSServerName&lt;/span&gt; thats great. However, one should not have to rely on the same as JMSServers might be added/removed. It would be nice if the distributed member JNDI names could be located on the fly by using &lt;a href="http://download.oracle.com/docs/cd/E11035_01/wls100/jmx/accessWLS.html#wp1112969"&gt;Weblogic's JMX capabilities&lt;/a&gt; and thats what I intend to do. Note that the enumerations obtained in Weblogic are snapshots of the current state of the queue and are not dynamic, i.e., new messages added being dynamically reflected in the enumeration. Finally, I am providing a java.util.Enumeration for the JMS messages instead of an java.util.Iterator as Enumeration does not have a &lt;span style="font-style: italic;"&gt;"remove"&lt;/span&gt; method and I hate putting an &lt;span style="font-style: italic;"&gt;"UnsupportedOperationException"&lt;/span&gt; in the Iterator and also I would like to be true to the JMS API.&lt;br /&gt;&lt;br /&gt;So first obtaining the JNDI name of physical members of a distributed queue. Weblogic JMX is a tree for objects.  Once we obtain the&lt;span style="font-style: italic;"&gt; ServerRuntimeMBean&lt;/span&gt; information, we can obtain information about the &lt;span style="font-style: italic;"&gt;JMSRuntimeMBeans&lt;/span&gt; and then the different &lt;span style="font-style: italic;"&gt;JMSServers&lt;/span&gt; and finally the JNDI names of the JMS Servers as shown below:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;WeblogicMBeanHelper&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;MBeanServerConnection&lt;/font&gt; &lt;font color="#2040a0"&gt;connection&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;JMXConnector&lt;/font&gt; &lt;font color="#2040a0"&gt;connector&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;ObjectName&lt;/font&gt; &lt;font color="#2040a0"&gt;service&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;WeblogicMBeanHelper&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;url&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;userName&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;password&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;service&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ObjectName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;          &lt;font color="#008000"&gt;&amp;quot;com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;MalformedObjectNameException&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;AssertionError&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;getMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    ......&lt;br /&gt;     ......&lt;br /&gt;    &lt;font color="#2040a0"&gt;JMXServiceURL&lt;/font&gt; &lt;font color="#2040a0"&gt;serviceURL&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;serviceURL&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;JMXServiceURL&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;t3&amp;quot;&lt;/font&gt;, &lt;font color="#2040a0"&gt;hostName&lt;/font&gt;, &lt;font color="#2040a0"&gt;Integer&lt;/font&gt;.&lt;font color="#2040a0"&gt;valueOf&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;port&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;, &lt;font color="#2040a0"&gt;jndiroot&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;mserver&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;Hashtable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;h&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;Hashtable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;h&lt;/font&gt;.&lt;font color="#2040a0"&gt;put&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Context&lt;/font&gt;.&lt;font color="#2040a0"&gt;SECURITY_PRINCIPAL&lt;/font&gt;, &lt;font color="#2040a0"&gt;userName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;h&lt;/font&gt;.&lt;font color="#2040a0"&gt;put&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Context&lt;/font&gt;.&lt;font color="#2040a0"&gt;SECURITY_CREDENTIALS&lt;/font&gt;, &lt;font color="#2040a0"&gt;password&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;h&lt;/font&gt;.&lt;font color="#2040a0"&gt;put&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;JMXConnectorFactory&lt;/font&gt;.&lt;font color="#2040a0"&gt;PROTOCOL_PROVIDER_PACKAGES&lt;/font&gt;, &lt;font color="#008000"&gt;&amp;quot;weblogic.management.remote&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;connector&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;JMXConnectorFactory&lt;/font&gt;.&lt;font color="#2040a0"&gt;connect&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;serviceURL&lt;/font&gt;, &lt;font color="#2040a0"&gt;h&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;connection&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;connector&lt;/font&gt;.&lt;font color="#2040a0"&gt;getMBeanServerConnection&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;RuntimeException&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Iterable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getDistributedMemberJndiNames&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;distributedDestJndiName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Iterable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;serverNames&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;getJmsServerNames&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Set&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;distributedDestNames&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;TreeSet&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;for&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;serverName&lt;/font&gt; &lt;font color="4444FF"&gt;:&lt;/font&gt; &lt;font color="#2040a0"&gt;serverNames&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;distributedDestNames&lt;/font&gt;.&lt;font color="#2040a0"&gt;add&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;serverName&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;@&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;distributedDestJndiName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;distributedDestNames&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Iterable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getJmsServerNames&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    .....&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Iterable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ObjectName&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getJMSServers&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    ....&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Iterable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ObjectName&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getJMSRuntimes&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;   ....&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;List&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ObjectName&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getServerRuntimeMBeans&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;Arrays&lt;/font&gt;.&lt;font color="#2040a0"&gt;asList&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ObjectName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;connection&lt;/font&gt;.&lt;font color="#2040a0"&gt;getAttribute&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;service&lt;/font&gt;, &lt;font color="#008000"&gt;&amp;quot;ServerRuntimes&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;RuntimeException&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Error obtaining Server Runtime Information&amp;quot;&lt;/font&gt;, &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;close&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#444444"&gt;// Close the connector&lt;/font&gt;&lt;br /&gt;    .... &lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;WeblogicMBeanHelper&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;MBeanServerConnection&lt;/font&gt; &lt;font color="#2040a0"&gt;connection&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;JMXConnector&lt;/font&gt; &lt;font color="#2040a0"&gt;connector&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;ObjectName&lt;/font&gt; &lt;font color="#2040a0"&gt;service&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;WeblogicMBeanHelper&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;url&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;userName&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;password&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;service&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ObjectName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;          &lt;font color="#008000"&gt;&amp;quot;com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;MalformedObjectNameException&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;AssertionError&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;getMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    ......&lt;br /&gt;     ......&lt;br /&gt;    &lt;font color="#2040a0"&gt;JMXServiceURL&lt;/font&gt; &lt;font color="#2040a0"&gt;serviceURL&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;serviceURL&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;JMXServiceURL&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;t3&amp;quot;&lt;/font&gt;, &lt;font color="#2040a0"&gt;hostName&lt;/font&gt;, &lt;font color="#2040a0"&gt;Integer&lt;/font&gt;.&lt;font color="#2040a0"&gt;valueOf&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;port&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;, &lt;font color="#2040a0"&gt;jndiroot&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;mserver&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;Hashtable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;h&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;Hashtable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;h&lt;/font&gt;.&lt;font color="#2040a0"&gt;put&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Context&lt;/font&gt;.&lt;font color="#2040a0"&gt;SECURITY_PRINCIPAL&lt;/font&gt;, &lt;font color="#2040a0"&gt;userName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;h&lt;/font&gt;.&lt;font color="#2040a0"&gt;put&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Context&lt;/font&gt;.&lt;font color="#2040a0"&gt;SECURITY_CREDENTIALS&lt;/font&gt;, &lt;font color="#2040a0"&gt;password&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;h&lt;/font&gt;.&lt;font color="#2040a0"&gt;put&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;JMXConnectorFactory&lt;/font&gt;.&lt;font color="#2040a0"&gt;PROTOCOL_PROVIDER_PACKAGES&lt;/font&gt;, &lt;font color="#008000"&gt;&amp;quot;weblogic.management.remote&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;connector&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;JMXConnectorFactory&lt;/font&gt;.&lt;font color="#2040a0"&gt;connect&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;serviceURL&lt;/font&gt;, &lt;font color="#2040a0"&gt;h&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;connection&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;connector&lt;/font&gt;.&lt;font color="#2040a0"&gt;getMBeanServerConnection&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;RuntimeException&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Iterable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getDistributedMemberJndiNames&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;distributedDestJndiName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Iterable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;serverNames&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;getJmsServerNames&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Set&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;distributedDestNames&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;TreeSet&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;for&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;serverName&lt;/font&gt; &lt;font color="4444FF"&gt;:&lt;/font&gt; &lt;font color="#2040a0"&gt;serverNames&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;distributedDestNames&lt;/font&gt;.&lt;font color="#2040a0"&gt;add&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;serverName&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;@&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;distributedDestJndiName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;distributedDestNames&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Iterable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getJmsServerNames&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    .....&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Iterable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ObjectName&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getJMSServers&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    ....&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Iterable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ObjectName&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getJMSRuntimes&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;   ....&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;List&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ObjectName&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getServerRuntimeMBeans&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;Arrays&lt;/font&gt;.&lt;font color="#2040a0"&gt;asList&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ObjectName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;connection&lt;/font&gt;.&lt;font color="#2040a0"&gt;getAttribute&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;service&lt;/font&gt;, &lt;font color="#008000"&gt;&amp;quot;ServerRuntimes&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;RuntimeException&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Error obtaining Server Runtime Information&amp;quot;&lt;/font&gt;, &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;close&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#444444"&gt;// Close the connector&lt;/font&gt;&lt;br /&gt;    .... &lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;br /&gt;Now that we have a way of obtaining the distributed members, the following represents the QueueBrowser that enumerates over the different members and consolidating the same into a single enumeration. I have a second enumeration that provides information regarding the JMServer that hosts the given message:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;DistribuedQueueBrowser&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  ...&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;Iterable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;queueNames&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;DistribuedQueueBrowser&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;adminUrl&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;providerUrl&lt;/font&gt;,&lt;br /&gt;      &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;distributedDestinationName&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;userName&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;password&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;ctx&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;getInitialContext&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;providerUrl&lt;/font&gt;, &lt;font color="#2040a0"&gt;userName&lt;/font&gt;, &lt;font color="#2040a0"&gt;password&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;WeblogicMBeanHelper&lt;/font&gt; &lt;font color="#2040a0"&gt;helper&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;helper&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;WeblogicMBeanHelper&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;adminUrl&lt;/font&gt;, &lt;font color="#2040a0"&gt;userName&lt;/font&gt;, &lt;font color="#2040a0"&gt;password&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;queueNames&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;helper&lt;/font&gt;.&lt;font color="#2040a0"&gt;getDistributedMemberJndiNames&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;distributedDestinationName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;finally&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;helper&lt;/font&gt; &lt;font color="4444FF"&gt;!&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;helper&lt;/font&gt;.&lt;font color="#2040a0"&gt;close&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;     &lt;br /&gt;    &lt;font color="#444444"&gt;// Set up connection/session..&lt;/font&gt;&lt;br /&gt;    ....&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;font color="#2040a0"&gt;InitialContext&lt;/font&gt; &lt;font color="#2040a0"&gt;getInitialContext&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;providerUrl&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;userName&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;password&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;     ....&lt;br /&gt;   &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;font color="#444444"&gt;// Retrun an Enumeration of Messages only&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;JMSException&lt;/font&gt;, &lt;font color="#2040a0"&gt;NamingException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;return&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;JmsMessageEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;getMessageEnumeratorMap&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  @&lt;font color="#2040a0"&gt;SuppressWarnings&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;unchecked&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;private&lt;/strong&gt; &lt;font color="#2040a0"&gt;Map&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;, &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getMessageEnumeratorMap&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;JMSException&lt;/font&gt;,&lt;br /&gt;    &lt;font color="#2040a0"&gt;NamingException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Map&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;, &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;serverMessageMap&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;HashMap&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;, &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;for&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;queueName&lt;/font&gt; &lt;font color="4444FF"&gt;:&lt;/font&gt; &lt;font color="#2040a0"&gt;queueNames&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;serverDq&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;StringUtils&lt;/font&gt;.&lt;font color="#2040a0"&gt;split&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;queueName&lt;/font&gt;, &lt;font color="#008000"&gt;&amp;quot;@&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;Queue&lt;/font&gt; &lt;font color="#2040a0"&gt;queue&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Queue&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;.&lt;font color="#2040a0"&gt;lookup&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;queueName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;javax&lt;/font&gt;.&lt;font color="#2040a0"&gt;jms&lt;/font&gt;.&lt;font color="#2040a0"&gt;QueueBrowser&lt;/font&gt; &lt;font color="#2040a0"&gt;qb&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;session&lt;/font&gt;.&lt;font color="#2040a0"&gt;createBrowser&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;queue&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;serverMessageMap&lt;/font&gt;.&lt;font color="#2040a0"&gt;put&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;serverDq&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;0&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt;, &lt;font color="#2040a0"&gt;qb&lt;/font&gt;.&lt;font color="#2040a0"&gt;getEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;serverMessageMap&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;font color="#444444"&gt;// Return an enumeration of ServerLocatedMessage that contains the &lt;/font&gt;&lt;br /&gt;  &lt;font color="#444444"&gt;// the jms server that houses the message&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ServerLocatedMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getServerLocatedEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;JMSException&lt;/font&gt;,&lt;br /&gt;    &lt;font color="#2040a0"&gt;NamingException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;return&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ServerLocatedMessageEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;getMessageEnumeratorMap&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;static&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;ServerLocatedMessage&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;Message&lt;/font&gt; &lt;font color="#2040a0"&gt;message&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;jmsServerName&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;ServerLocatedMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;jmsServerName&lt;/font&gt;, &lt;font color="#2040a0"&gt;Message&lt;/font&gt; &lt;font color="#2040a0"&gt;message&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;this&lt;/strong&gt;.&lt;font color="#2040a0"&gt;message&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;message&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;this&lt;/strong&gt;.&lt;font color="#2040a0"&gt;jmsServerName&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;jmsServerName&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    ...&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;static&lt;/strong&gt; &lt;strong&gt;abstract&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;AbstractMessageEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;strong&gt;implements&lt;/strong&gt; &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Map&lt;/font&gt;.&lt;font color="#2040a0"&gt;Entry&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;, &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;current&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;private&lt;/strong&gt; &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;currMessageEnumer&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;Iterator&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Map&lt;/font&gt;.&lt;font color="#2040a0"&gt;Entry&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;, &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;iterator&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;AbstractMessageEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Map&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;, &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;map&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;iterator&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;map&lt;/font&gt;.&lt;font color="#2040a0"&gt;entrySet&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;.&lt;font color="#2040a0"&gt;iterator&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;current&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;iterator&lt;/font&gt;.&lt;font color="#2040a0"&gt;hasNext&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;          ? &lt;font color="#2040a0"&gt;iterator&lt;/font&gt;.&lt;font color="#2040a0"&gt;next&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;          &lt;font color="4444FF"&gt;:&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;currMessageEnumer&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;current&lt;/font&gt; &lt;font color="4444FF"&gt;!&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;          ? &lt;font color="#2040a0"&gt;current&lt;/font&gt;.&lt;font color="#2040a0"&gt;getValue&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;          &lt;font color="4444FF"&gt;:&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;            &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;boolean&lt;/strong&gt; &lt;font color="#2040a0"&gt;hasMoreElements&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;              &lt;strong&gt;return&lt;/strong&gt; &lt;strong&gt;false&lt;/strong&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;            &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;            &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Message&lt;/font&gt; &lt;font color="#2040a0"&gt;nextElement&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;              &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;NoSuchElementException&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;            &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;          &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;getEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;current&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt; &lt;font color="4444FF"&gt;|&lt;/font&gt;&lt;font color="4444FF"&gt;|&lt;/font&gt; &lt;font color="#2040a0"&gt;currMessageEnumer&lt;/font&gt;.&lt;font color="#2040a0"&gt;hasMoreElements&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;currMessageEnumer&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;while&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;iterator&lt;/font&gt;.&lt;font color="#2040a0"&gt;hasNext&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;current&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;iterator&lt;/font&gt;.&lt;font color="#2040a0"&gt;next&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;currMessageEnumer&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;current&lt;/font&gt;.&lt;font color="#2040a0"&gt;getValue&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;currMessageEnumer&lt;/font&gt;.&lt;font color="#2040a0"&gt;hasMoreElements&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;          &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;currMessageEnumer&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;currMessageEnumer&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;boolean&lt;/strong&gt; &lt;font color="#2040a0"&gt;hasMoreElements&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;getEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;.&lt;font color="#2040a0"&gt;hasMoreElements&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;font color="#444444"&gt;// Wraps the JMS Message within a ServerLocatedMessage object&lt;/font&gt;&lt;br /&gt;  &lt;font color="#444444"&gt;// which contains the server name along with the message&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;static&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;ServerLocatedMessageEnumeration&lt;/font&gt; &lt;strong&gt;extends&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;AbstractMessageEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ServerLocatedMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;ServerLocatedMessageEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Map&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;, &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;map&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;super&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;map&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;ServerLocatedMessage&lt;/font&gt; &lt;font color="#2040a0"&gt;nextElement&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;Message&lt;/font&gt; &lt;font color="#2040a0"&gt;message&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;getEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;.&lt;font color="#2040a0"&gt;nextElement&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;return&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ServerLocatedMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;current&lt;/font&gt;.&lt;font color="#2040a0"&gt;getKey&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;, &lt;font color="#2040a0"&gt;message&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;static&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;JmsMessageEnumeration&lt;/font&gt; &lt;strong&gt;extends&lt;/strong&gt; &lt;font color="#2040a0"&gt;AbstractMessageEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;JmsMessageEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Map&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt;, &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;map&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;super&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;map&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Message&lt;/font&gt; &lt;font color="#2040a0"&gt;nextElement&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;getEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;.&lt;font color="#2040a0"&gt;nextElement&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;close&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    ......&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;Using this QueueBrowser is rather straight forward and can be done via:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// Note that the first argument is the admin url and the second is the &lt;/font&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// managed server url.&lt;/font&gt;&lt;br /&gt;&lt;font color="#2040a0"&gt;DistribuedQueueBrowser&lt;/font&gt; &lt;font color="#2040a0"&gt;qb&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;DistribuedQueueBrowser&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;t3://localhost:7001&amp;quot;&lt;/font&gt;,&lt;br /&gt;        &lt;font color="#008000"&gt;&amp;quot;t3://localhost:8001&amp;quot;&lt;/font&gt;,&lt;br /&gt;        &lt;font color="#008000"&gt;&amp;quot;test_queue&amp;quot;&lt;/font&gt;, &lt;font color="#008000"&gt;&amp;quot;weblogic&amp;quot;&lt;/font&gt;, &lt;font color="#008000"&gt;&amp;quot;weblogic&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Message&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;i&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;qb&lt;/font&gt;.&lt;font color="#2040a0"&gt;getEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;while&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;i&lt;/font&gt;.&lt;font color="#2040a0"&gt;hasMoreElements&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;Message&lt;/font&gt; &lt;font color="#2040a0"&gt;m&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;i&lt;/font&gt;.&lt;font color="#2040a0"&gt;nextElement&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Message:&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;m&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Enumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ServerLocatedMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;sli&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;qb&lt;/font&gt;.&lt;font color="#2040a0"&gt;getServerLocatedEnumeration&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;while&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;sli&lt;/font&gt;.&lt;font color="#2040a0"&gt;hasMoreElements&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;ServerLocatedMessage&lt;/font&gt; &lt;font color="#2040a0"&gt;m&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;sli&lt;/font&gt;.&lt;font color="#2040a0"&gt;nextElement&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;m&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://home.comcast.net/~acharya.s/java/wlbrowser.zip"&gt;The code for the same is available HERE&lt;/a&gt;. The zip file contains only the JAVA files. One would need to compile the same with weblogic's client jar's and then use them. Let me know if you have problems running the code or if you have any tips regarding the code. &lt;br /&gt;Later...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-1227234083829217332?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/1227234083829217332/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=1227234083829217332' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/1227234083829217332'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/1227234083829217332'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/04/browsing-weblogic-jms-distrubuted.html' title='Browsing Weblogic JMS Distrubuted Queues'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-5099533116342367200</id><published>2009-04-18T23:21:00.009-06:00</published><updated>2009-04-19T00:59:25.554-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AspectJ Logging'/><category scheme='http://www.blogger.com/atom/ns#' term='Aspect J'/><category scheme='http://www.blogger.com/atom/ns#' term='AspectJ Maven Plugin'/><title type='text'>Aspect J Maven and Logging</title><content type='html'>At my earlier job, I had looked at &lt;a href="http://static.springframework.org/spring/docs/2.5.x/reference/aop.html"&gt;Aspect Oriented programming with Spring&lt;/a&gt;. I used the same for transactions. I wanted to use it for Logging method enter/exits as well but abandoned the same as one would need to use Spring's native &lt;a href="http://www.eclipse.org/aspectj/"&gt;AspectJ&lt;/a&gt; weaving. I was not ready to take that on at the time. Another option was to use AspectJ compile-time weaving, again, not something I had the time for and simply settled on Transactional support with Spring Aspects.&lt;br /&gt;&lt;br /&gt;So what am I upto? I wanted to play with AspectJ and how compile time weaving on &lt;a href="http://maven.apache.org/"&gt;maven&lt;/a&gt; project would help me eliminate the logging. &lt;br /&gt;&lt;br /&gt;Enter and exit of methods are quite useful, especially when debugging. Another use case of debugging would be to trace the method arguments passed to a method. In addition, performance of profiling method executions has its benefits. In an earlier blog post &lt;a href="http://sleeplessinslc.blogspot.com/2008/09/java-instrumentation-with-jdk-16x-class.html"&gt;I had investigated the use of Java Instrumentation&lt;/a&gt; to assist with profiling.&lt;br /&gt;&lt;br /&gt;So I start by creating a logging Aspect. If the logging level is set as DEBUG, it will LOG entry and exit of a method. If the level is set as TRACE, then the time for method execution is also logged along with the method arguments to the method. The following represents the Aspect:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;font color="0000ff"&gt;&lt;strong&gt;import org.aspectj.lang.*;&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="0000ff"&gt;&lt;strong&gt;import org.apache.log4j.*;&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;aspect&lt;/font&gt; &lt;font color="#2040a0"&gt;LoggingAspect&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="#2040a0"&gt;Logger&lt;/font&gt; &lt;font color="#2040a0"&gt;LOG&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;Logger&lt;/font&gt;.&lt;font color="#2040a0"&gt;getLogger&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;trace&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;font color="#444444"&gt;// Execute on all methods except this Logging Aspect&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="#2040a0"&gt;pointcut&lt;/font&gt; &lt;font color="#2040a0"&gt;traceMethods&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;        &lt;font color="4444FF"&gt;:&lt;/font&gt; &lt;font color="#2040a0"&gt;execution&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;*&lt;/font&gt; &lt;font color="4444FF"&gt;*&lt;/font&gt;.&lt;font color="4444FF"&gt;*&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;..&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&amp;amp;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;amp;&lt;/font&gt; &lt;font color="4444FF"&gt;!&lt;/font&gt;&lt;font color="#2040a0"&gt;within&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;LoggingAspect&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="#444444"&gt;// Around each method do the following&lt;/font&gt;&lt;br /&gt;  &lt;font color="#2040a0"&gt;Object&lt;/font&gt; &lt;font color="#2040a0"&gt;around&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;:&lt;/font&gt; &lt;font color="#2040a0"&gt;traceMethods&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Signature&lt;/font&gt; &lt;font color="#2040a0"&gt;sig&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;thisJoinPointStaticPart&lt;/font&gt;.&lt;font color="#2040a0"&gt;getSignature&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;baseEnterMessage&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;Enter [&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;sig&lt;/font&gt;.&lt;font color="#2040a0"&gt;getDeclaringType&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;.&lt;font color="#2040a0"&gt;getName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;.&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;sig&lt;/font&gt;.&lt;font color="#2040a0"&gt;getName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;] &amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;LOG&lt;/font&gt;.&lt;font color="#2040a0"&gt;isTraceEnabled&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;Object&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;args&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;thisJoinPoint&lt;/font&gt;.&lt;font color="#2040a0"&gt;getArgs&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;br /&gt;      &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;args&lt;/font&gt;.&lt;font color="#2040a0"&gt;length&lt;/font&gt; &lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#FF0000"&gt;0&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;StringBuilder&lt;/font&gt; &lt;font color="#2040a0"&gt;argsBuilder&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;StringBuilder&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;20&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;argsBuilder&lt;/font&gt;.&lt;font color="#2040a0"&gt;append&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;baseEnterMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;.&lt;font color="#2040a0"&gt;append&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot; Args :&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;br /&gt;        &lt;strong&gt;for&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;int&lt;/strong&gt; &lt;font color="#2040a0"&gt;i&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#FF0000"&gt;0&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt; &lt;font color="#2040a0"&gt;i&lt;/font&gt; &lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt; &lt;font color="#2040a0"&gt;args&lt;/font&gt;.&lt;font color="#2040a0"&gt;length&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt; &lt;font color="#2040a0"&gt;i&lt;/font&gt;&lt;font color="4444FF"&gt;+&lt;/font&gt;&lt;font color="4444FF"&gt;+&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;          &lt;font color="#2040a0"&gt;argsBuilder&lt;/font&gt;.&lt;font color="#2040a0"&gt;append&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;{Index [&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;i&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;], Value [&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;args&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;i&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;]}&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;          &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;i&lt;/font&gt; &lt;font color="4444FF"&gt;!&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;args&lt;/font&gt;.&lt;font color="#2040a0"&gt;length&lt;/font&gt; &lt;font color="4444FF"&gt;-&lt;/font&gt; &lt;font color="#FF0000"&gt;1&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;            &lt;font color="#2040a0"&gt;argsBuilder&lt;/font&gt;.&lt;font color="#2040a0"&gt;append&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;,&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;          &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;        &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;        &lt;br /&gt;        &lt;font color="#2040a0"&gt;argsBuilder&lt;/font&gt;.&lt;font color="#2040a0"&gt;append&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;}&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;br /&gt;        &lt;font color="#2040a0"&gt;LOG&lt;/font&gt;.&lt;font color="#2040a0"&gt;trace&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;argsBuilder&lt;/font&gt;.&lt;font color="#2040a0"&gt;toString&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;  &lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;br /&gt;      &lt;strong&gt;else&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;LOG&lt;/font&gt;.&lt;font color="#2040a0"&gt;trace&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;baseEnterMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;else&lt;/strong&gt; &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;LOG&lt;/font&gt;.&lt;font color="#2040a0"&gt;isDebugEnabled&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#444444"&gt;// Print base debug without arguments&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;LOG&lt;/font&gt;.&lt;font color="#2040a0"&gt;debug&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;baseEnterMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;strong&gt;long&lt;/strong&gt; &lt;font color="#2040a0"&gt;start&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;currentTimeMillis&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;Object&lt;/font&gt; &lt;font color="#2040a0"&gt;result&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;proceed&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;     &lt;br /&gt;      &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;result&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;finally&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;baseMessage&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;Exiting [&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;sig&lt;/font&gt;.&lt;font color="#2040a0"&gt;getDeclaringType&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;.&lt;font color="#2040a0"&gt;getName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;.&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;sig&lt;/font&gt;.&lt;font color="#2040a0"&gt;getName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;].&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;     &lt;br /&gt;      &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;LOG&lt;/font&gt;.&lt;font color="#2040a0"&gt;isTraceEnabled&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;        &lt;font color="#444444"&gt;// If trace is enabled, print the time for execution.&lt;/font&gt;&lt;br /&gt;        &lt;strong&gt;long&lt;/strong&gt; &lt;font color="#2040a0"&gt;end&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;currentTimeMillis&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;LOG&lt;/font&gt;.&lt;font color="#2040a0"&gt;trace&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;baseMessage&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;Completed in:&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;end&lt;/font&gt; &lt;font color="4444FF"&gt;-&lt;/font&gt; &lt;font color="#2040a0"&gt;start&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot; millis&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;else&lt;/strong&gt; &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;LOG&lt;/font&gt;.&lt;font color="#2040a0"&gt;isDebugEnabled&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;        &lt;br /&gt;        &lt;font color="#2040a0"&gt;LOG&lt;/font&gt;.&lt;font color="#2040a0"&gt;debug&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;baseMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;Another nice use of Aspects is to be able to enforce compile time standard checks. Maybe Find Bugs has a way to already do this. Not sure. Anyway, say for example, we want to detect when there are &lt;span style="font-style:italic;"&gt;System.out.println()&lt;/span&gt; calls in the code or maybe the code in question is using some Class/Framework that we do not approve of, with Aspects and compile time checking there is a nice way out. I quite liked reading the blog by &lt;a href="http://www.theserverlabs.com/blog/2008/09/10/compile-time-architecture-enforcement-revisited-aspectj-maven-and-eclipse/"&gt;Jacob Matute on the compile time enforcement of standards&lt;/a&gt;.  What I envision is the inclusion of a simple jar in project that can/will enforce the standards one desires. I think this might be preferable over depending on IDE based configuration of plugins. &lt;br /&gt;&lt;br /&gt;What about method invocations where checks are performed? For example in many methods we repeat code that checks if an argument is null and throws some exception? What if one could declare an annotation on the method and an aspect check for the annotation to handle the same for you? The code becomes cleaner IMO. I think Java 7 will have this feature. Till then one can create an &lt;span style="font-style:italic;"&gt;@NotNull&lt;/span&gt; annotation on a parameter and have aspects handle the exception throwing part for you across your entire code base. &lt;a href="http://andrewclement.blogspot.com/2009/02/aspectj-advising-methods-with-parameter.html"&gt;Andy Clement's blog&lt;/a&gt; discusses the same very nicely.&lt;br /&gt;&lt;br /&gt;As I used maven for all my projects, there is a plugin from codehaus, for integrating &lt;a href="http://mojo.codehaus.org/aspectj-maven-plugin/"&gt;AspectJ into maven&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;For the sake of demonstration, I have a simple, fictional and potentially farcical objects that would undergo the tests of the Aspects:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;Order&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;Long&lt;/font&gt; &lt;font color="#2040a0"&gt;id&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;userName&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;Random&lt;/font&gt; &lt;font color="#2040a0"&gt;random&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;Random&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Order&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Long&lt;/font&gt; &lt;font color="#2040a0"&gt;id&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;userName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;this&lt;/strong&gt;.&lt;font color="#2040a0"&gt;id&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;id&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;this&lt;/strong&gt;.&lt;font color="#2040a0"&gt;userName&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;userName&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;getUserName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;userName&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;int&lt;/strong&gt; &lt;font color="#2040a0"&gt;getTotalCost&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;int&lt;/strong&gt; &lt;font color="#2040a0"&gt;range&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Calculating Cost...&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;Thread&lt;/font&gt;.&lt;font color="#2040a0"&gt;sleep&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;2000L&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;InterruptedException&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;getRandom&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;range&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;int&lt;/strong&gt; &lt;font color="#2040a0"&gt;getRandom&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;int&lt;/strong&gt; &lt;font color="#2040a0"&gt;range&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;random&lt;/font&gt;.&lt;font color="#2040a0"&gt;nextInt&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;range&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;An even trivial use of the Order object which is not even a unit test is shown below:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;@&lt;font color="#2040a0"&gt;Test&lt;/font&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;testOrderModel&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; &lt;font color="#2040a0"&gt;Order&lt;/font&gt; &lt;font color="#2040a0"&gt;order&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;Order&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;23L&lt;/font&gt;, &lt;font color="#008000"&gt;&amp;quot;Foo&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Order UserName:&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;order&lt;/font&gt;.&lt;font color="#2040a0"&gt;getUserName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Order Total cost:&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;order&lt;/font&gt;.&lt;font color="#2040a0"&gt;getTotalCost&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;113&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Util&lt;/font&gt;.&lt;font color="#2040a0"&gt;concatName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Sanjay&amp;quot;&lt;/font&gt;, &lt;font color="#008000"&gt;&amp;quot;Acharya&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;When I run "&lt;span style="font-weight:bold;"&gt;mvn install&lt;/span&gt;", I notice the following depending on the logging level I have setup in my log4j.properties, i.e., DEBUG or TRACE:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;-------------------------------------------------------&lt;br /&gt; T E S T S                                             &lt;br /&gt;-------------------------------------------------------&lt;br /&gt;Running com.welflex.model.ModelTest                    &lt;br /&gt;Enter [com.welflex.model.Order.getUserName]            &lt;br /&gt;Exiting [com.welflex.model.Order.getUserName].Completed in:0 millis&lt;br /&gt;Order UserName:Foo&lt;br /&gt;Enter [com.welflex.model.Order.getTotalCost]  Args :{Index [0], Value [113]}}&lt;br /&gt;Calculating Cost...&lt;br /&gt;Enter [com.welflex.model.Order.getRandom]  Args :{Index [0], Value [113]}}&lt;br /&gt;Exiting [com.welflex.model.Order.getRandom].Completed in:0 millis&lt;br /&gt;Exiting [com.welflex.model.Order.getTotalCost].Completed in:2000 millis&lt;br /&gt;Order Total cost:40&lt;br /&gt;Enter [com.welflex.model.Util.concatName]  Args :{Index [0], Value [Sanjay]},{Index [1], Value [Acharya]}}&lt;br /&gt;Exiting [com.welflex.model.Util.concatName].Completed in:1000 millis&lt;br /&gt;SanjayAcharya&lt;br /&gt;Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.12 sec&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Parting Thoughts:&lt;/span&gt;&lt;br /&gt;I think Aspects are rather powerful. There is plugin support for Aspects as well. For cross cutting concerns, use of Aspects is the way to go IMHO. Finally, although this is a maven project using JDK 1.5, there is no reason why this applies to maven only or cannot be used on previous versions of the JDK.&lt;br /&gt;&lt;a href="http://home.comcast.net/~acharya.s/java/aspectJTest.zip"&gt;&lt;br /&gt;A maven project that demonstrates the above is available for download HERE&lt;/a&gt;. One problem that I faced was getting the maven-aspectj plugin to install correctly. If you do install the same, you might want to add the codehaus repository to the pom.xml to ensure that the plugin is downloaded. To execute the project, from your command line, issue a "&lt;span style="font-style:italic;"&gt;mvn install&lt;/span&gt;". There is a &lt;span style="font-style:italic;"&gt;log4j.properties&lt;/span&gt; file in the project whose logging level you can tweak to see differences.&lt;br /&gt;&lt;br /&gt;Enjoy :-)!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-5099533116342367200?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/5099533116342367200/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=5099533116342367200' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/5099533116342367200'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/5099533116342367200'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/04/aspect-j-maven-and-logging.html' title='Aspect J Maven and Logging'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-1550124349701890351</id><published>2009-04-11T21:38:00.007-06:00</published><updated>2009-04-12T21:19:54.569-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jms security weblogic'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring Framework Weblogic JMS Security'/><title type='text'>Weblogic JMS  Standalone Multi-threaded Client Security</title><content type='html'>I have been building a helper library that provides some convenience functionalities and all of a sudden it started failing with authentication exceptions. Not on obtaining Jms artifacts but during the send of a message. Jeez! One part of me says let go, deal with it on Monday, the other part is hungry to find out why. No prizes for guessing which part of me won :-)&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;The story so far:&lt;/span&gt;&lt;br /&gt;Weblogic client runtime stores credentials in a &lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ThreadLocal.html"&gt;ThreadLocal&lt;/a&gt; of the Thread that creates an InitialContext to obtain a jms resource, i.e., equivalent of saying the thread that has the credentials can execute privileged operations on certain JMS resource but as other threads do not have the credentials and thus, they cannot. Weblogic's security will obtain the information from the ThreadLocal and use the credentials therein for send/receive operations.  &lt;br /&gt;&lt;br /&gt;Now, in a Jms environment, one would like to create multiple javax.jms.Session, javax.jms.MessageProducer and use multi-threading where appropriate, sharing the same JMS connection. Think of a Servlet container that has multiple threads. If Jms artifacts (Connection factories, Destinations) are obtained only once using a Singleton by one of the Container's thread's, then it is only this thread that can send/receive messages from a JMS destination if the destination has security enabled on the same. The operation of creating a Context places a javax.security.auth.Subject in the ThreadLocal of the thread creating the Context. If the context is closed, the Subject is removed.&lt;br /&gt;&lt;br /&gt;Consider the following example where the jms artifacts are obtained in a single thread of execution and a message is sent in the same thread:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;sameThreadCreateSend&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;InitialContext&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;getInitialContext&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt; &lt;font color="#2040a0"&gt;connectionFactory&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        .&lt;font color="#2040a0"&gt;lookup&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Connectionfactory&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Destination&lt;/font&gt; &lt;font color="#2040a0"&gt;destination&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Destination&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;.&lt;font color="#2040a0"&gt;lookup&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;test_queue&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#444444"&gt;// Closing the context causes the send authentication exception&lt;/font&gt;&lt;br /&gt;    &lt;font color="#444444"&gt;// ctx.close();&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Connection&lt;/font&gt; &lt;font color="#2040a0"&gt;connection&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;connectionFactory&lt;/font&gt;.&lt;font color="#2040a0"&gt;createConnection&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;connection&lt;/font&gt;.&lt;font color="#2040a0"&gt;start&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Session&lt;/font&gt; &lt;font color="#2040a0"&gt;session&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;connection&lt;/font&gt;.&lt;font color="#2040a0"&gt;createSession&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;false&lt;/strong&gt;, &lt;font color="#2040a0"&gt;Session&lt;/font&gt;.&lt;font color="#2040a0"&gt;AUTO_ACKNOWLEDGE&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;MessageProducer&lt;/font&gt; &lt;font color="#2040a0"&gt;producer&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;session&lt;/font&gt;.&lt;font color="#2040a0"&gt;createProducer&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;destination&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#444444"&gt;// Fails to send message as closing of the context removes the security information&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#444444"&gt;// from the Thread local. If the context is kept open, then it works great.&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;producer&lt;/font&gt;.&lt;font color="#2040a0"&gt;send&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;session&lt;/font&gt;.&lt;font color="#2040a0"&gt;createTextMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Sent message when send was called on thread that created context...&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;br /&gt;In the above example, the message gets sent successfully, What about a case where the Jms artifacts are created on one thread and a thread created from the creator thread tries to send a message? Will the permissions get propagated to the child thread? Look at the code below:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;testInheritableThreadSend&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;InitialContext&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;getInitialContext&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#444444"&gt;// Current Thread has the security information&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt; &lt;font color="#2040a0"&gt;connectionFactory&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        .&lt;font color="#2040a0"&gt;lookup&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;connectionfactory&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;Destination&lt;/font&gt; &lt;font color="#2040a0"&gt;destination&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Destination&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;.&lt;font color="#2040a0"&gt;lookup&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;test_queue&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#444444"&gt;// This thread will have the security as well due to Inheritable thread local&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Thread&lt;/font&gt; &lt;font color="#2040a0"&gt;t&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;Thread&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      @&lt;font color="#2040a0"&gt;Override&lt;/font&gt; &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;run&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;        &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;          &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;Connection&lt;/font&gt; &lt;font color="#2040a0"&gt;connection&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;connectionFactory&lt;/font&gt;.&lt;font color="#2040a0"&gt;createConnection&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;          &lt;font color="#2040a0"&gt;connection&lt;/font&gt;.&lt;font color="#2040a0"&gt;start&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;          &lt;font color="#2040a0"&gt;Session&lt;/font&gt; &lt;font color="#2040a0"&gt;session&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;connection&lt;/font&gt;.&lt;font color="#2040a0"&gt;createSession&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;false&lt;/strong&gt;, &lt;font color="#2040a0"&gt;Session&lt;/font&gt;.&lt;font color="#2040a0"&gt;AUTO_ACKNOWLEDGE&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;          &lt;font color="#2040a0"&gt;MessageProducer&lt;/font&gt; &lt;font color="#2040a0"&gt;producer&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;session&lt;/font&gt;.&lt;font color="#2040a0"&gt;createProducer&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;destination&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;          &lt;font color="#2040a0"&gt;producer&lt;/font&gt;.&lt;font color="#2040a0"&gt;send&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;session&lt;/font&gt;.&lt;font color="#2040a0"&gt;createTextMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;          &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Sent message using inheritable thread local...&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;        &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;          &lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;printStackTrace&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;t&lt;/font&gt;.&lt;font color="#2040a0"&gt;start&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;t&lt;/font&gt;.&lt;font color="#2040a0"&gt;join&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;Yes the above code sent a message successfully as the credentials in the parent are propagated to the child thread via Inheritable thread local.&lt;br /&gt;&lt;br /&gt;Now what about a case where the creation of the Jms artifacts are created on a thread that is not the parent of the thread that sends the message using those artifacts? Look at the sample below:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;createOnSeparateThread&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#444444"&gt;// First thread opens a context and had the credentials&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;ResourceCreator&lt;/font&gt; &lt;font color="#2040a0"&gt;c&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ResourceCreator&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;c&lt;/font&gt;.&lt;font color="#2040a0"&gt;start&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;c&lt;/font&gt;.&lt;font color="#2040a0"&gt;join&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#444444"&gt;// Second thread is not a child of the first, thus does not have the security&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;NonCreatorThreadRunner&lt;/font&gt; &lt;font color="#2040a0"&gt;n&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;NonCreatorThreadRunner&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;c&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;n&lt;/font&gt;.&lt;font color="#2040a0"&gt;start&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;n&lt;/font&gt;.&lt;font color="#2040a0"&gt;join&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;ResourceCreator&lt;/font&gt; &lt;strong&gt;extends&lt;/strong&gt; &lt;font color="#2040a0"&gt;Thread&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;InitialContext&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Destination&lt;/font&gt; &lt;font color="#2040a0"&gt;destination&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Connection&lt;/font&gt; &lt;font color="#2040a0"&gt;connection&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    @&lt;font color="#2040a0"&gt;Override&lt;/font&gt; &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;run&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;ctx&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;Example&lt;/font&gt;.&lt;strong&gt;this&lt;/strong&gt;.&lt;font color="#2040a0"&gt;getInitialContext&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;connection&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;.&lt;font color="#2040a0"&gt;lookup&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;connectionfactory&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;            .&lt;font color="#2040a0"&gt;createConnection&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;destination&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Destination&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;.&lt;font color="#2040a0"&gt;lookup&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;test_queue&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;printStackTrace&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;NonCreatorThreadRunner&lt;/font&gt; &lt;strong&gt;extends&lt;/strong&gt; &lt;font color="#2040a0"&gt;Thread&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;ResourceCreator&lt;/font&gt; &lt;font color="#2040a0"&gt;resourceCreator&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;NonCreatorThreadRunner&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ResourceCreator&lt;/font&gt; &lt;font color="#2040a0"&gt;resourceCreator&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;this&lt;/strong&gt;.&lt;font color="#2040a0"&gt;resourceCreator&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;resourceCreator&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    @&lt;font color="#2040a0"&gt;Override&lt;/font&gt; &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;run&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;resourceCreator&lt;/font&gt;.&lt;font color="#2040a0"&gt;connection&lt;/font&gt;.&lt;font color="#2040a0"&gt;start&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;Session&lt;/font&gt; &lt;font color="#2040a0"&gt;session&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;resourceCreator&lt;/font&gt;.&lt;font color="#2040a0"&gt;connection&lt;/font&gt;.&lt;font color="#2040a0"&gt;createSession&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;false&lt;/strong&gt;,&lt;br /&gt;          &lt;font color="#2040a0"&gt;Session&lt;/font&gt;.&lt;font color="#2040a0"&gt;AUTO_ACKNOWLEDGE&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;MessageProducer&lt;/font&gt; &lt;font color="#2040a0"&gt;producer&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;session&lt;/font&gt;.&lt;font color="#2040a0"&gt;createProducer&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;resourceCreator&lt;/font&gt;.&lt;font color="#2040a0"&gt;destination&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;producer&lt;/font&gt;.&lt;font color="#2040a0"&gt;send&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;session&lt;/font&gt;.&lt;font color="#2040a0"&gt;createTextMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Sent message when context was created on a separate thread...huh ???&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;printStackTrace&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;So the above send operation failed. Why? Because the second thread does not have the security credentials in its ThreadLocal. Now what if we could use the security information from the first thread on the second thread? We can, using weblogic security classes and using the javax.security.auth.Subject to execute a javax.security.PrivilidgedAction. &lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;SubjectHoldingResourceCreator&lt;/font&gt; &lt;strong&gt;extends&lt;/strong&gt; &lt;font color="#2040a0"&gt;ResourceCreator&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Subject&lt;/font&gt; &lt;font color="#2040a0"&gt;subject&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;     &lt;font color="#444444"&gt;// Obtain the Subject from the thread&lt;/font&gt;&lt;br /&gt;    @&lt;font color="#2040a0"&gt;Override&lt;/font&gt; &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;run&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;super&lt;/strong&gt;.&lt;font color="#2040a0"&gt;run&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;subject&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;weblogic&lt;/font&gt;.&lt;font color="#2040a0"&gt;security&lt;/font&gt;.&lt;font color="#2040a0"&gt;Security&lt;/font&gt;.&lt;font color="#2040a0"&gt;getCurrentSubject&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;SubjectUsingNonCreatorThreadRunner&lt;/font&gt; &lt;strong&gt;extends&lt;/strong&gt; &lt;font color="#2040a0"&gt;Thread&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;SubjectHoldingResourceCreator&lt;/font&gt; &lt;font color="#2040a0"&gt;creator&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;SubjectUsingNonCreatorThreadRunner&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;SubjectHoldingResourceCreator&lt;/font&gt; &lt;font color="#2040a0"&gt;creator&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;this&lt;/strong&gt;.&lt;font color="#2040a0"&gt;creator&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;creator&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    @&lt;font color="#2040a0"&gt;Override&lt;/font&gt; &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;run&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;        &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;Session&lt;/font&gt; &lt;font color="#2040a0"&gt;session&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;creator&lt;/font&gt;.&lt;font color="#2040a0"&gt;connection&lt;/font&gt;.&lt;font color="#2040a0"&gt;createSession&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;false&lt;/strong&gt;, &lt;font color="#2040a0"&gt;Session&lt;/font&gt;.&lt;font color="#2040a0"&gt;AUTO_ACKNOWLEDGE&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;MessageProducer&lt;/font&gt; &lt;font color="#2040a0"&gt;producer&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;session&lt;/font&gt;.&lt;font color="#2040a0"&gt;createProducer&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;creator&lt;/font&gt;.&lt;font color="#2040a0"&gt;destination&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="#444444"&gt;// Execute a secure action using the Subject from the previous thread.&lt;/font&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;weblogic&lt;/font&gt;.&lt;font color="#2040a0"&gt;security&lt;/font&gt;.&lt;font color="#2040a0"&gt;Security&lt;/font&gt;.&lt;font color="#2040a0"&gt;runAs&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;creator&lt;/font&gt;.&lt;font color="#2040a0"&gt;subject&lt;/font&gt;, &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;PrivilegedAction&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Void&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;          &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Void&lt;/font&gt; &lt;font color="#2040a0"&gt;run&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;            &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;              &lt;font color="#2040a0"&gt;producer&lt;/font&gt;.&lt;font color="#2040a0"&gt;send&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;session&lt;/font&gt;.&lt;font color="#2040a0"&gt;createTextMessage&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;              &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Sent using Subject created on separate thread....&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;            &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;            &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;JMSException&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;              &lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;printStackTrace&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;            &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;            &lt;strong&gt;return&lt;/strong&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;          &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;        &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;printStackTrace&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;testCreationOnSeparateUsingSubject&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;SubjectHoldingResourceCreator&lt;/font&gt; &lt;font color="#2040a0"&gt;c&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;SubjectHoldingResourceCreator&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;c&lt;/font&gt;.&lt;font color="#2040a0"&gt;start&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;c&lt;/font&gt;.&lt;font color="#2040a0"&gt;join&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;SubjectUsingNonCreatorThreadRunner&lt;/font&gt; &lt;font color="#2040a0"&gt;r&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;SubjectUsingNonCreatorThreadRunner&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;c&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;r&lt;/font&gt;.&lt;font color="#2040a0"&gt;start&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;r&lt;/font&gt;.&lt;font color="#2040a0"&gt;join&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;The above example worked and sent the message. I have seen others facing a similar issue when using &lt;a href="http://www.springframework.org"&gt;Spring&lt;/a&gt; classes such as &lt;a href="http://www.agitar.com/openquality/spring/org/springframework/jms/core/JmsTemplate.java.html"&gt;JmsTemplate&lt;/a&gt; and DefaultMessageListenerContainer with Weblogic where this security issue bites them. Some folks have taken the route of initializing the Context before every send/receive of a message. This is clearly not optimal as the creation of an InitialContext is not cheap and can lead to degradation of performance.&lt;br /&gt;&lt;br /&gt;My recommendation is to use the P&lt;a href="http://en.wikipedia.org/wiki/Proxy_pattern"&gt;roxy Pattern&lt;/a&gt; and have proxied versions of javax.jms.MessageProducer(s) and javax.jms.MessageConsumer(s) which ensure that calls to send/receive are executed within a PrivilidgedAction.&lt;br /&gt;&lt;a href="http://sleeplessinslc.blogspot.com/2009/01/spring-jmstemplate-weblogic.html"&gt;Look at my posting on Weblogic Jms Template&lt;/a&gt; to see how Proxies can be used.&lt;br /&gt;&lt;br /&gt;The javax.security.auth.Subject can be obtained once in a multi-threaded environment for a particular user authenticator (userName/pass) and then be held for use by all the threads in the environment. &lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Subject&lt;/font&gt; &lt;font color="#2040a0"&gt;createSingleSubject&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;providerUrl&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;userName&lt;/font&gt;, &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;passsword&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Subject&lt;/font&gt; &lt;font color="#2040a0"&gt;subject&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;Subject&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#444444"&gt;// Weblogic env class&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Environment&lt;/font&gt; &lt;font color="#2040a0"&gt;env&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;Environment&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;env&lt;/font&gt;.&lt;font color="#2040a0"&gt;setProviderUrl&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;providerUrl&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;env&lt;/font&gt;.&lt;font color="#2040a0"&gt;setSecurityPrincipal&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;userName&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;env&lt;/font&gt;.&lt;font color="#2040a0"&gt;setSecurityCredentials&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;password&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#444444"&gt;// Weblogic Authenticate class will populate and Seal the subject &lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;Authenticate&lt;/font&gt;.&lt;font color="#2040a0"&gt;authenticate&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;env&lt;/font&gt;, &lt;font color="#2040a0"&gt;subject&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;subject&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;LoginException&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;RuntimeException&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Unable to Authenticate User&amp;quot;&lt;/font&gt;, &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;RuntimeException&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Error authenticating user&amp;quot;&lt;/font&gt;, &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;If the above method is invoked once to set up a Subject, then the same Subject can be used by Proxies to invoke PrivilidgedActions. &lt;br /&gt;&lt;br /&gt;One thing I don't like is that on closing of the obtained Context, the ThreadLocal object is not cleared of all allocated permission related objects. It is only the Subject that is detached. I am looking for a way prevent the caching of security information in the ThreadLocal by WebLogic.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Some Links:&lt;/span&gt;&lt;br /&gt;1. &lt;a href="http://jira.springframework.org/browse/SPR-4720?page=com.atlassian.jira.ext.fisheye%3Afisheye-issuepanel"&gt;Spring JIRA&lt;/a&gt; &lt;br /&gt;2. &lt;a href="http://download.oracle.com/docs/cd/E12840_01/wls/docs103/security/index.html"&gt;Weblogic Security Documentation&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-1550124349701890351?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/1550124349701890351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=1550124349701890351' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/1550124349701890351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/1550124349701890351'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/04/weblogic-jms-standalone-multi-threaded.html' title='Weblogic JMS  Standalone Multi-threaded Client Security'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-7055203404332672446</id><published>2009-04-08T23:38:00.002-06:00</published><updated>2009-04-08T23:48:44.807-06:00</updated><title type='text'>Vote for Adam Lambert..a vote more importantant than your vote for Obama</title><content type='html'>I am not an Idol fanatic by any means, very far from it. I am however following this season. American Idol IMHO is a package, a singer with a great voice, who is sellable, has a dynamic persona, can get the chicks! Once in a while comes a singer who just does it freakin right. Adam Lambert from this seasons American Idol is the man. His rendition of "&lt;a href="http://www.americanidol.com/videos/season_8/performances/"&gt;Mad World&lt;/a&gt;" is just super.&lt;br /&gt;&lt;br /&gt;This guy has it all. The persona, the package, the voice for the next idol. I have found my American Idol, its Adam...Vote on! We need this guy at No.1. My theory is this person is Elvis reborn. Elvis lives!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-7055203404332672446?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/7055203404332672446/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=7055203404332672446' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/7055203404332672446'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/7055203404332672446'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/04/vote-for-adam-lamberta-vote-more.html' title='Vote for Adam Lambert..a vote more importantant than your vote for Obama'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-400901520457637983</id><published>2009-04-01T21:38:00.004-06:00</published><updated>2009-04-01T22:04:26.133-06:00</updated><title type='text'>Liking Emma and FindBugs Eclipse Plugins</title><content type='html'>I have found myself liking two helpers as I continue to develop,  Code Coverage and Finding Bugs. I usually use plugins in &lt;span style="font-style:italic;"&gt;maven&lt;/span&gt; reporting to help me find issues and coverage information after issuing a "&lt;span style="font-style:italic;"&gt;mvn site&lt;/span&gt;".&lt;br /&gt;&lt;br /&gt;I however prefer to catch the same without having to generate the maven site though and in my IDE. I see two nice eclipse plugins for the same. For the Code Coverage part, I quite like the &lt;a href="http://www.eclemma.org/"&gt;Emma Eclipse plugin&lt;/a&gt; which allows me to run my unit tests in "Coverage" mode and helps me determine the amount of code coverage my unit tests are providing. The coloring is pretty good, green for fully covered code, red for missed code and yellow for partially covered code. Trying to be green...&lt;br /&gt;&lt;br /&gt;I have also started to use the &lt;a href="http://findbugs.sourceforge.net/manual/eclipse.html#d0e1644"&gt;Find Bugs eclipse plugin&lt;/a&gt;.  Professional "Hara Kiri" here but I often get pleasantly surprised by what the utility finds for me :-). It would have been nice if the "Problems" tab in Eclipse showed the issues found by "Find Bugs" via a different icon. Also I am refraining from showing results of either plugin here for obvious reasons :-))))&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-400901520457637983?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/400901520457637983/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=400901520457637983' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/400901520457637983'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/400901520457637983'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/04/liking-emma-and-findbugs-eclipse.html' title='Liking Emma and FindBugs Eclipse Plugins'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-852940678995178724</id><published>2009-03-30T22:30:00.001-06:00</published><updated>2009-03-31T07:41:47.652-06:00</updated><title type='text'>Java Closure(s) but no cigar?</title><content type='html'>It has now been a year since I have been working with &lt;a href="http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html"&gt;Java 5+ features&lt;/a&gt;. During development, I have welcomed auto-boxing, the concise for loop, vargs, enums and Generics. In particular the last feature has been rather appreciated as type safe programming makes life for a developer so much easier. That said, I will also state that there have been many times that I have been troubled by the wild cards in generics and erasure.  However, I find the take aways I get from generics far out weigh the few times I need to stress my brain with wild cards and erasure.&lt;br /&gt;&lt;br /&gt;Like Generics, one equally important feature that the Java language has been wanting is &lt;a href="http://en.wikipedia.org/wiki/Closure_%28computer_science%29"&gt;Closures.   &lt;/a&gt;A &lt;a href="http://www.javac.info/consensus-closures-jsr.html"&gt;JSR&lt;/a&gt; for closures resulted in multiple proposals. Notably,&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Full Closures by the &lt;a href="http://www.javac.info/"&gt;BGGA&lt;/a&gt; proposal&lt;/li&gt;&lt;li&gt;&lt;a href="http://docs.google.com/View?docid=k73_1ggr36h"&gt;CICE&lt;/a&gt; Simplified inner classes and&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.jroller.com/scolebourne/entry/fcm_prototype_available"&gt;FCM&lt;/a&gt; First Class methods.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;As a note a poll taken to determine which proposal Java developers would welcome led to, BGGA taking the lead. Interestingly enough, a large percentage of Java developers felt that they do not want Closures in Java.  My intuition tells me that a large percentage of the latter voters are saying "&lt;span style="font-style: italic;"&gt;I do not want BGGA closures in Java&lt;/span&gt;" rather than "&lt;span style="font-style: italic;"&gt;I do not want Closures at all&lt;/span&gt;".&lt;br /&gt;&lt;br /&gt;A famous debate between &lt;a href="http://gafter.blogspot.com/"&gt;Neal Gafter&lt;/a&gt; who has come forth as the major spokesperson for the BGGA closures proposal and &lt;a href="http://en.wikipedia.org/wiki/Joshua_Bloch"&gt;Josh Bloch&lt;/a&gt;, a supporter of the CICE proposal has ensued via presentations and blogs. The same can be googled for.&lt;br /&gt;&lt;br /&gt;A bit about my stance,  I definitely see the power of Closures. However as the saying from Spiderman, the movie goes, "&lt;span style="font-style: italic;"&gt;With great power comes great responsibility&lt;/span&gt;." I want the power that Closures offer in Java, and I want an implementation that I can understand and be productive with. I want intuitive compilation errors that will immediately alert me to the problem without straining the few &lt;span style="font-style: italic;"&gt;@deprecated&lt;/span&gt; Grey cells that are still struggling to function in my brain.&lt;br /&gt;&lt;br /&gt;I want conciseness, but not at the cost of readability and maintainability. In short, I want power with clarity and brevity. One cannot always get everything they want, sad but true, however, my stance is that if I can benefit considerably &lt;span style="font-weight: bold;"&gt;most&lt;/span&gt; of the time, I do not mind the pain for a little of the time. Think of it like a marriage ;-)))..luckily, the wife does not read my technical blogs lol!  A better parallel; (Gain Factor &gt;&gt;&gt;&gt; Pain Factor == Adoption)&lt;br /&gt;&lt;br /&gt;One can read about what a Closure is, what a &lt;a href="http://en.wikipedia.org/wiki/Lambda_calculus"&gt;Lambda&lt;/a&gt; expression is and I will not spend time on the same. Primary reason being, I cannot understand the same myself :-(&lt;br /&gt;&lt;br /&gt;What I want to do in this Blog is to understand Closures by BGGA and try for myself how hard or how easy is it to work with them.  I do not use an IDE but revert to using &lt;a href="http://www.gnu.org/software/emacs/"&gt;emacs&lt;/a&gt; and the command line for this exercise.&lt;br /&gt;&lt;br /&gt;I downloaded the BGGA propopal and ran some of the &lt;a href="http://tronicek.blogspot.com/2007/12/java-closures-tutorial.html"&gt;examples from the Java Closures Tutorial&lt;/a&gt; so very well explained by&lt;span style="font-weight: bold;"&gt; Zdeněk Troníček&lt;/span&gt;.  Then I tried to apply the same to cases I have encountered before or am working with now to see for myself how easy/difficult the proposal is and problems I faced, if any.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Function Types:&lt;/span&gt;&lt;br /&gt;I think function types would be a great addition to the language. I understand Mr.Bloch's concern that they might tend to lead to an exotic style of programming, however, I feel exotic styles of programming can even be developed with the simplest of constructs should developers choose to.  It is possible for a psychotic developer as myself to take the simplest of problems and provide the most convoluted but workable solutions for the same. If I were introduced to the book Java Puzzlers prior to learning Java, I might have fled the scene. Sure, there will be puzzling cases but thats what code reviews, documentation, etc are all for after all. I am not sure I buy the argument, that "&lt;span style="font-style: italic;"&gt;BGGA closures lend themselves to an exotic programming style&lt;/span&gt;". One can easily be exotic with the simplest of language constructs IMHO.&lt;br /&gt;&lt;br /&gt;Lets look at a couple of examples, I have an &lt;span style="font-style: italic;"&gt;eachEntry() &lt;/span&gt;&lt;span&gt;method &lt;/span&gt;that runs through an &lt;span style="font-style: italic;"&gt;java.lang.Iterable&lt;/span&gt; and executes the &lt;span style="font-weight: bold;"&gt;block&lt;/span&gt; provided. I also a have a simple &lt;span style="font-style: italic;"&gt;filter()&lt;/span&gt; that can be used to filter an &lt;span style="font-style: italic;"&gt;Iterable&lt;/span&gt; which delegates to the &lt;span style="font-style: italic;"&gt;eachEntry().&lt;/span&gt;&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;static&lt;/strong&gt; &lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;Collection&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;filter&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Iterable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;input&lt;/font&gt;, &lt;br /&gt;        &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;strong&gt;boolean&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;filterBlock&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;       &lt;br /&gt;   &lt;font color="#2040a0"&gt;Collection&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;filteredItems&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ArrayList&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;   &lt;font color="#2040a0"&gt;eachEntry&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;input&lt;/font&gt;, &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt; &lt;font color="#2040a0"&gt;item&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;br /&gt;       &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;filterBlock&lt;/font&gt;.&lt;font color="#2040a0"&gt;invoke&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;item&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;filteredItems&lt;/font&gt;.&lt;font color="#2040a0"&gt;add&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;item&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;   &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;matched&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;static&lt;/strong&gt; &lt;strong&gt;for&lt;/strong&gt; &lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;, &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;E&lt;/font&gt; &lt;strong&gt;extends&lt;/strong&gt; &lt;font color="#2040a0"&gt;Exception&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;br /&gt;    &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;eachEntry&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Iterable&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;items&lt;/font&gt;, &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;E&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;block&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;E&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; &lt;strong&gt;for&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt; &lt;font color="#2040a0"&gt;item&lt;/font&gt; &lt;font color="4444FF"&gt;:&lt;/font&gt; &lt;font color="#2040a0"&gt;items&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;     &lt;font color="#2040a0"&gt;block&lt;/font&gt;.&lt;font color="#2040a0"&gt;invoke&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;item&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;An example usage of the above where Employee objects are filtered:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// Static import the utility functions, filter and eachEntry&lt;/font&gt;&lt;br /&gt;&lt;font color="0000ff"&gt;&lt;strong&gt;import static com.welflex.util.Utils.*;&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#2040a0"&gt;List&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Employee&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;emps&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; ...&lt;font color="#444444"&gt;// Get employees&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// A closure that uses the Function type of eachEntry to dump out the&lt;/font&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// information about each employee&lt;/font&gt;&lt;br /&gt;&lt;font color="#2040a0"&gt;eachEntry&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;emps&lt;/font&gt;, &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Employee&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Id:&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;getId&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;           &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;, Manager:&amp;quot;&lt;/font&gt; &lt;br /&gt;           &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;isManager&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;br /&gt;           &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;, Salary:&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;getSalary&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// Filter out only employees who are managers &lt;/font&gt;&lt;br /&gt;&lt;font color="#2040a0"&gt;Collection&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Employee&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;managers&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;filter&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;emps&lt;/font&gt;, &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Employee&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;isManager&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// Filter out only managers who earn gt 60000 using a filter of filters&lt;/font&gt;&lt;br /&gt;&lt;font color="#2040a0"&gt;Collection&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Employee&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;mgrsGt&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;filter&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;filter&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;emps&lt;/font&gt;, &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Employee&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;isManager&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;, &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Employee&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;getSalary&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#FF0000"&gt;60000&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// The above one re-written&lt;/font&gt;&lt;br /&gt;&lt;font color="#2040a0"&gt;mgrsGt&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;filter&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;emps&lt;/font&gt;, &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Employee&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;isManager&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&amp;amp;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;amp;&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;getSalary&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#FF0000"&gt;60000&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;I find the above pretty concise and powerful. I also find the same rather easy to read as well.  So no complaints from me there. For those reading, hey I never claimed I was invincible as far as programming goes, close to invincible, yes ;-)&lt;br /&gt;&lt;br /&gt;Now the negative, some things I could however not understand,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;a.&lt;/span&gt;  &lt;span style="font-weight: bold;"&gt;for&lt;/span&gt; construct did not work for me:&lt;br /&gt;"&lt;a href="http://tronicek.blogspot.com/2008/08/modifier-for.html"&gt;for&lt;/a&gt;" construct did not work for me.  I might not have done it correctly, but the &lt;span style="font-style: italic;"&gt;eachEntry()&lt;/span&gt; that uses the&lt;span style="font-weight: bold;"&gt; "for" &lt;/span&gt;construct compiled just fine. Compiling the following should have worked, I am not sure what I am missing:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;strong&gt;for&lt;/strong&gt; &lt;font color="#2040a0"&gt;eachEntry&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Employee&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt; &lt;font color="4444FF"&gt;:&lt;/font&gt;  &lt;font color="#2040a0"&gt;emps&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Id:&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;.&lt;font color="#2040a0"&gt;getId&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;A compilation error leading to:&lt;br /&gt;"&lt;span style="font-style: italic;"&gt;Filter.java:20: method forEach in class Filter cannot be applied to given types&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;required: java.lang.Iterable&lt;/span&gt;&lt;br /&gt;&lt;t&gt;&lt;span style="font-style: italic;"&gt;,javax.lang.function.OO,java.lang.Class&lt;/span&gt;&lt;r&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;found: java.util.Collection&lt;/span&gt;&lt;t&gt;&lt;span style="font-style: italic;"&gt;,{T =&gt; void},java.lang.Class&lt;/span&gt;&lt;java.lang.boolean&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  forEach(orig, {T item =&gt; if (block.invoke(item)) matched.add(item);},&lt;/span&gt;"&lt;br /&gt;&lt;br /&gt;The above was not very instructive for me in addressing the issue :-(&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;b.&lt;/span&gt; Static Inner Class when used in the example caused compiler error:&lt;br /&gt;&lt;br /&gt;When my Employee class was a static inner class, I ended up with the following exception when I tried to compile the examples class, leading me take it the Employee class to its own separate compilation unit:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;exception has occurred in the compiler (1.6.0_11). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.&lt;/span&gt; &lt;span style="font-style: italic;"&gt;java.lang.NullPointerException&lt;/span&gt; &lt;span style="font-style: italic;"&gt;       at com.sun.tools.javac.comp.Resolve.isAccessible(Resolve.java:140)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I would like to also provide another example where I am using an ARM block to obtain a JMS Object from JNDI and subsequently closing the context. Note that I am not using actual &lt;span style="font-weight: bold;"&gt;javax.naming.Context&lt;/span&gt; classes but have instead modeled my own for the sake of demonstration. Without closures and using anonymous classes, I have the following:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;strong&gt;private&lt;/strong&gt; &lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;T&lt;/font&gt; &lt;font color="#2040a0"&gt;executeContextTask&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ContextTask&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;task&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;LookupException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;   &lt;font color="#2040a0"&gt;Context&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;   &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt; &lt;br /&gt;     &lt;font color="#2040a0"&gt;ctx&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ContextImpl&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt; &lt;br /&gt;     &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;task&lt;/font&gt;.&lt;font color="#2040a0"&gt;executeWithContext&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ctx&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;   &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;finally&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;     &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ctx&lt;/font&gt; &lt;font color="4444FF"&gt;!&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;       &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;         &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;.&lt;font color="#2040a0"&gt;close&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;       &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;         &lt;font color="#444444"&gt;//log this&lt;/font&gt;&lt;br /&gt;       &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;     &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;br /&gt;   &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;static&lt;/strong&gt; &lt;strong&gt;interface&lt;/strong&gt; &lt;font color="#2040a0"&gt;ContextTask&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;T&lt;/font&gt; &lt;font color="#2040a0"&gt;executeWithContext&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Context&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;LookupException&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt; &lt;font color="#2040a0"&gt;getConnectionFactory&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;name&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;LookupException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;   &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;executeContextTask&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ContextTask&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;       &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt; &lt;font color="#2040a0"&gt;executeWithContext&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Context&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;br /&gt;  &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;LookupException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;         &lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt; &lt;font color="#2040a0"&gt;c&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;.&lt;font color="#2040a0"&gt;lookup&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;name&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="#444444"&gt;// Do something with Connection Factory before returning&lt;/font&gt;&lt;br /&gt;        &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;c&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;       &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;   &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;....&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Destination&lt;/font&gt; &lt;font color="#2040a0"&gt;getDestination&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;name&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;br /&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;LookupException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  ... &lt;font color="#444444"&gt;// Similar to above..except returns a Destination..//&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;The same above example when done using BGGA closures is simplified to:&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;static&lt;/strong&gt; &lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt;, &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;E&lt;/font&gt; &lt;strong&gt;extends&lt;/strong&gt; &lt;font color="#2040a0"&gt;LookupException&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;br /&gt;     &lt;font color="#2040a0"&gt;T&lt;/font&gt; &lt;font color="#2040a0"&gt;withContext&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Context&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;T&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;E&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;contextTaskBlock&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;E&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="#2040a0"&gt;Context&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;ctx&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ContextImpl&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;contextTaskBlock&lt;/font&gt;.&lt;font color="#2040a0"&gt;invoke&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ctx&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt; &lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;finally&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ctx&lt;/font&gt; &lt;font color="4444FF"&gt;!&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;try&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;.&lt;font color="#2040a0"&gt;close&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;catch&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Exception&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;font color="#444444"&gt;// Log error                &lt;/font&gt;&lt;br /&gt;      &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// Note name is no longer final, neither is there a class called&lt;/font&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// Context Task and the anonymous class has been replaced by the &lt;/font&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// closure.&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt; &lt;font color="#2040a0"&gt;getConnectionFactory&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;name&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;br /&gt;   &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;LookupException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;withContext&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Context&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;br /&gt;     &lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt; &lt;font color="#2040a0"&gt;c&lt;/font&gt;  &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;ctx&lt;/font&gt;.&lt;font color="#2040a0"&gt;lookup&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;name&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt; &lt;font color="#2040a0"&gt;c&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;.. &lt;font color="#2040a0"&gt;Similar&lt;/font&gt; &lt;font color="#2040a0"&gt;code&lt;/font&gt; &lt;strong&gt;for&lt;/strong&gt; &lt;font color="#2040a0"&gt;Destination&lt;/font&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Closure Conversion:&lt;/span&gt;&lt;br /&gt;I quite like &lt;a href="http://tronicek.blogspot.com/2007/12/closure-conversion.html"&gt;Closure Conversion&lt;/a&gt;. For example, I have an interface called Read that reads in an Employee Record. Assigning a closure to the interface type we have the below:&lt;br /&gt;&lt;/java.lang.boolean&gt;&lt;/t&gt;&lt;/r&gt;&lt;/t&gt;&lt;br /&gt;&lt;t&gt;&lt;r&gt;&lt;t&gt;&lt;java.lang.boolean&gt;I am liking the conciseness presented by the above over writing an anonymous inner class + method definition + body (although the conversion is translated to the same).&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;    &lt;strong&gt;interface&lt;/strong&gt; &lt;font color="#2040a0"&gt;Read&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt; &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;Employee&lt;/font&gt; &lt;font color="#2040a0"&gt;read&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;criteria&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;font color="#2040a0"&gt;Read&lt;/font&gt; &lt;font color="#2040a0"&gt;readRecord&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;criteria&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;br /&gt;                       &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Criteria:&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;criteria&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;                       &lt;font color="#2040a0"&gt;Random&lt;/font&gt; &lt;font color="#2040a0"&gt;r&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;Random&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;         &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;Employee&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;r&lt;/font&gt;.&lt;font color="#2040a0"&gt;nextInt&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;5&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;,&lt;br /&gt;        &lt;font color="#2040a0"&gt;r&lt;/font&gt;.&lt;font color="#2040a0"&gt;nextBoolean&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;, &lt;br /&gt;        &lt;font color="#2040a0"&gt;r&lt;/font&gt;.&lt;font color="#2040a0"&gt;nextInt&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;10000&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;closureConversion&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt; &lt;font color="#2040a0"&gt;Employee&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;readRecord&lt;/font&gt;.&lt;font color="#2040a0"&gt;read&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;select * from Emp where id=&lt;font color="#77dd77"&gt;\&amp;quot;&lt;/font&gt;20&lt;font color="#77dd77"&gt;\&amp;quot;&lt;/font&gt;&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Employee Read:&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;e&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Arrays:&lt;/span&gt;&lt;br /&gt;Arrays have boggle my mind in Generics, Arrays continue to boggle my mind with BGGA closures.&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// Will not compile&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;strong&gt;int&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;closures&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;strong&gt;int&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;10&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt; &lt;br /&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// Will not compile&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;strong&gt;int&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;closures&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt;  &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;5&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;, &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;6&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// Compiles&lt;/font&gt;&lt;br /&gt;&lt;font color="#2040a0"&gt;List&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;strong&gt;int&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;list&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ArrayList&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;strong&gt;int&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#444444"&gt;// But no way of&lt;/font&gt;&lt;br /&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;strong&gt;int&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;closures&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;list&lt;/font&gt;.&lt;font color="#2040a0"&gt;toArray&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;strong&gt;int&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;closures&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;0&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Non local returns:&lt;/span&gt;&lt;br /&gt;When returning from a Closure, should the&lt;span style="font-weight: bold;"&gt; "return" &lt;/span&gt; result in returning from the method itself? That is not very intuitive to me.  I am of the opinion that returns from a closure, should only be local and not result in exiting the method. That is room for accidental programing with disastrous results.&lt;br /&gt;&lt;br /&gt;Consider the following Code, what do you thing will be the result of the invocation?&lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;   &lt;strong&gt;static&lt;/strong&gt; &lt;strong&gt;boolean&lt;/strong&gt; &lt;font color="#2040a0"&gt;testBooleanLocal&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;boolean&lt;/strong&gt; &lt;font color="#2040a0"&gt;input&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;boolean&lt;/strong&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;strong&gt;boolean&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;closure&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;boolean&lt;/strong&gt; &lt;font color="#2040a0"&gt;args&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;           &lt;font color="#2040a0"&gt;args&lt;/font&gt;&lt;br /&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;       &lt;br /&gt; &lt;strong&gt;boolean&lt;/strong&gt; &lt;font color="#2040a0"&gt;result&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;  &lt;font color="4444FF"&gt;!&lt;/font&gt;&lt;font color="#2040a0"&gt;closure&lt;/font&gt;.&lt;font color="#2040a0"&gt;invoke&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;input&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Test Boolean Local Result: &amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;result&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt; &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;result&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;strong&gt;static&lt;/strong&gt; &lt;strong&gt;boolean&lt;/strong&gt; &lt;font color="#2040a0"&gt;testBooleanNonLocal&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;boolean&lt;/strong&gt; &lt;font color="#2040a0"&gt;input&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;boolean&lt;/strong&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;strong&gt;boolean&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;closure&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;boolean&lt;/strong&gt; &lt;font color="#2040a0"&gt;arg&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;       &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;arg&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt; &lt;br /&gt; &lt;strong&gt;boolean&lt;/strong&gt; &lt;font color="#2040a0"&gt;result&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt;  &lt;font color="4444FF"&gt;!&lt;/font&gt;&lt;font color="#2040a0"&gt;closure&lt;/font&gt;.&lt;font color="#2040a0"&gt;invoke&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;input&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Test Boolean NonLocal Result:&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;result&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt; &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;result&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;static&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;font color="#2040a0"&gt;main&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;args&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Local:&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;testBooleanLocal&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;true&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; &lt;font color="#2040a0"&gt;System&lt;/font&gt;.&lt;font color="#2040a0"&gt;out&lt;/font&gt;.&lt;font color="#2040a0"&gt;println&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;quot;Non Local:&amp;quot;&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; &lt;font color="#2040a0"&gt;testBooleanNonLocal&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;true&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;The answer is:&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Test Boolean Local Result: false&lt;br /&gt;Local:false&lt;br /&gt;Non Local:true&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;What just happened to the second &lt;span style="font-style: italic;"&gt;println()&lt;/span&gt;? All because I had a&lt;span style="font-weight: bold;"&gt; ==&gt;&lt;/span&gt; versus a&lt;span style="font-weight: bold;"&gt; =&gt; &lt;/span&gt;along with a return statement?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The Syntax&lt;/span&gt;:&lt;br /&gt;Without the assistance of an IDE, I had a few growing pains where I was accidentally doing "= &gt;" instead of "=&gt;", i.e, a space in between. Surely any IDE ready to support BGGA will catch the same. What about "&lt;span style="font-weight: bold;"&gt;==&gt;&lt;/span&gt; "versus "&lt;span style="font-weight: bold;"&gt;=&gt;&lt;/span&gt;"?  Will an IDE be able to warn regarding the difference? I sure hope so :-)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Running the Examples:&lt;/span&gt;&lt;br /&gt;As always, I am sharing my playground. For the ones interested, I tried the same using:&lt;br /&gt;Download the ...., install the same and then set your PATH to include the existing JDK 1.6. For example,&lt;br /&gt;export PATH=/.../jdk1.6.12/bin:$PATH. Then compile the provided code using the "javac" from the BGGA proposal, for example, "$BGGA_HOME/bin/javac -classpath .:com/welflex/utils:com/welflex/model:com/welflex/example *.java" and run the same using the similar syntax.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parting Thoughts:&lt;br /&gt;&lt;/span&gt;Sadness that Java does not have closures. Visual Basic developers are benefitting and thriving with the same, something I heard. Closures are a construct that has been around since ages, Java compromised at the time of inception via Anonymous classes rather then deal with the complexity of Closures, maybe a good decision for the time.  However, time is now neigh for change. If Java has to survive, Closures need to enter the language. One cannot wait between JDK7 to JDK8 without knowing closures will or will not find a place in Java. Java folk are tending to gravitate toward other languages like &lt;a href="http://www.scala-lang.org/"&gt;Scala, &lt;/a&gt;&lt;a href="http://clojure.org/"&gt;Clojure&lt;/a&gt; etc.  IMHO we need to stop this abandonement. My rationale for the same is (based purely on sentiments), I love Java, its been the reason for my  bread and butter over the years, I love developing with it and I want to continue to develop with it. More importantly, its represents Coffee, I cannot wake up without my shot of the same. Scala or Clojure doesn't inspire me as much, maybe an alternate VM language called &lt;span style="font-weight: bold;"&gt;Nicotine&lt;/span&gt; could cut it and spark my interest ;-)&lt;br /&gt;&lt;br /&gt;BGGA is not perfect. Sadly, nothing ever is. In my own humble opinion, the warring factions of Gafter/Bloch need to join forces to improve the compiler warnings, syntax and any other ambiguities in the features of BGGA present and look toward introducing it as part of JDK 8.X.  Come on guys, you are super smart chaps (Phd's don't come easy) that have collectively led to the creation/enhancement of this great language, make my life easy and do not let me leave my favorite language for some pretenders to the throne :-(. If not, I propose that Gosling take the place of a dictator and get this in..I will welcome the same! Maybe IBM buying Sun will change things... Got to cut em beers when I post, for all you know I might have made a case for "&lt;span style="font-style: italic;"&gt;No closures ever in Java via my misadventures :-)&lt;/span&gt;", lol!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://home.comcast.net/%7Eacharya.s/java/closure-example.zip"&gt;Sample Code that I have used can be downloaded from here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Resources:&lt;/span&gt;&lt;br /&gt;&lt;/java.lang.boolean&gt;&lt;/t&gt;&lt;/r&gt;&lt;/t&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.javac.info/"&gt;&lt;t&gt;&lt;r&gt;&lt;t&gt;&lt;java.lang.boolean&gt;BGGA Closures&lt;/java.lang.boolean&gt;&lt;/t&gt;&lt;/r&gt;&lt;/t&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.infoq.com/interviews/joshua-bloch"&gt;Bloch on Info Q about problems with BGGA&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.infoq.com/presentations/gafter-jvm-closures"&gt;Gafter: Language Parity and the JVM&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.google.com/"&gt;Google!&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-852940678995178724?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/852940678995178724/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=852940678995178724' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/852940678995178724'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/852940678995178724'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/03/java-closures-but-no-cigar.html' title='Java Closure(s) but no cigar?'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-3449866488289532537</id><published>2009-03-24T21:46:00.003-06:00</published><updated>2009-03-24T22:06:19.232-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='facebook'/><title type='text'>Facebook is so very active</title><content type='html'>Have not been much of a On line Social Networking enthusiast. Primarily as it goes against my "Anti Social" primal nature :-).  Its something I deeply value and something that is woven in my genetic code :-) Anyway,  I am amazed by the number of my friends who are rather active there. I decided to login and post a couple of messages and before I could sign off, I had responses back.&lt;br /&gt;&lt;br /&gt;People really digg Social networking, a late realization on my behalf. Go figure.  I would have never put my money on such a site like &lt;a href="http://www.facebook.com"&gt;Facebook. &lt;/a&gt;I must admit I quite like their Web 2.0 design. Very Web 2.0 with a lot of &lt;a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29"&gt;Ajax&lt;/a&gt;ian features and especially Ajaxian features that are responsive and done well.&lt;br /&gt;&lt;br /&gt;One thing that has discouraged me from these social networking sites is that none of the folks that I knew growing up are on them. I seem to be the only one from my groups that has a presence on any of these places. Were my friends/generation just not technically savvy or am I just hated that people appear as invisible via some rule that says "&lt;span style="font-style: italic;"&gt;boolean result =  {String user = &gt; user.equals("sanjay") ? false : true}.invoke("sanjay")&lt;/span&gt;"&lt;br /&gt;&lt;br /&gt;Am seeing myself engage more on Facebook, and yes, this is one of my split personalities that likes socializing which is becoming the dominant personality....Scary times ahead!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-3449866488289532537?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/3449866488289532537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=3449866488289532537' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/3449866488289532537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/3449866488289532537'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/03/facebook-is-so-very-active.html' title='Facebook is so very active'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-1106748263726347611</id><published>2009-03-10T22:27:00.003-06:00</published><updated>2009-03-10T22:30:43.243-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Bruce Lee'/><title type='text'>Gems of Bruce Lee</title><content type='html'>Growing up, I always wanted to be like Bruce Lee. Fate had other plans, neither did I get my black belt and neither did I acquire his wisdom...still much respect for Mr.Lee and a fan forever...&lt;div&gt;&lt;br /&gt;&lt;div&gt;Found this link rather interesting and felt like sharing... &lt;a href="http://www.junauza.com/2009/03/15-inspiring-bruce-lee-quotes-that.html"&gt;http://www.junauza.com/2009/03/15-inspiring-bruce-lee-quotes-that.html&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-1106748263726347611?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/1106748263726347611/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=1106748263726347611' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/1106748263726347611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/1106748263726347611'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/03/gems-of-bruce-lee.html' title='Gems of Bruce Lee'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-4222131662587222627</id><published>2009-03-04T18:40:00.015-07:00</published><updated>2009-03-05T09:06:42.897-07:00</updated><title type='text'>The Case of the Missing Lego - A mystery solved</title><content type='html'>My earlier blog was regarding my tooth, this one is about a nose. The lead actor of this story is not about me, but is instead my dear son. This incident has to be blogged for posterity.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Well its around 10:30 p.m, I have posted my blog and sitting on the couch watching TV. My dear nutritionist, i.e., my wife is preparing dinner. Sounds like &lt;a href="http://www.imdb.com/title/tt0120789/"&gt;Pleasantville&lt;/a&gt;..Well not anymore...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There are cries of my son that I hear, followed by my wife agitatedly bringing him to me. Initial thoughts were, my daughter and my son have had some battle regarding some toy and my daughter has won, leaving the young man disgruntled. Err...not quite!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Flash back to January 1st 2009, my brother had gifted my kids with a &lt;a href="http://www.lego.com/en-US/default.aspx"&gt;Lego &lt;/a&gt;Set for ages 4+.  Please note that my wife and I were also involved in the selection of the gift. My kids are reaching that 4 year window shortly, so it made for a great toy.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Flash forward to now. The Lego Set had some very &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;small,  &lt;/span&gt;smooth, disc shaped pieces and my dear son decided to experiment with "&lt;span class="Apple-style-span" style="font-style: italic;"&gt;What would happen if I blocked one of my nasal passages with this Green foreign thingy?&lt;/span&gt;". The experiment worked, he had placed it in one of his nostrils and sucked the same in. Now with blood on his nostrils and realizing that the piece is probably inside him somewhere, he is upset.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Panic time! Where did the piece go?  Is he having difficulty breathing? Is he choking? Did he drop the Lego piece on the carpet? I give you ladies and gentlemen,  "&lt;span class="Apple-style-span" style="font-style: italic;"&gt;The Case of the missing Lego&lt;/span&gt;" . As Jeremy Brett would have said, "&lt;span class="Apple-style-span" style="font-style: italic;"&gt;A mystery is afoo&lt;/span&gt;t".&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Well my wife and I definitely did not want any part of this mystery. All we wanted was a solution.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We ask for explanations from my son. In the best way he can, he describes that he placed in his nose, and inhaled it and it vanished. I run my fingers over his nose, testing to see if I can feel the particle anywhere, I cannot feel a thing!  We ask him to blow his nose in the hope that the missing Lego is evicted. No luck, nothing is thrown out! As he is able to breathe fine without coughing or choking, one thought is that my son must have inhaled it so forcefully that the piece has gone through his nasal passage and finally into his stomach. Another theory is that he really did not inhale it but instead may have dropped it on the carpet somewhere. Scanning the carpets and trash cans for the piece yielded no results. If we had found it, it would have brought closure to the case right then and there.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So what next?  My wife calls "&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Poison Control&lt;/span&gt;". They recommend that since we have determined that my son is able to breathe well, we should  take him to the doctor the next day for examination and keep observing him for the night. Well, as worried parents, we call our Pediatrician as well in order to obtain information regarding whether or not to head to the ER. After some discussion, she too states that there is no need for the ER as he is able to drink and eat without a problem. She however recommends that we bring him in for a check up the next day. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;An incident less night ensues. The next day we re-think whether or not a Doctors visit is in fact validated. The closure seeker that I am, I request my wife to take him to the Doctors office to ensure the Lego is not present within. Call it peace of mind or closure. I chose not go to the Doctor's office as I was backing the theory that my son must have swallowed the Lego piece and the examination would not turn up any leads in the case.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;My wife helps out and takes my son to the Doctor's office. The incidents that follow are total hearsay as I was not at the venue where they occurred.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;At the Doctors office, the Doctor (she is a really good Doc) asks my son to explain the incident, he does so in court room level detail.  The Doctor then places a magnifying glass instrument under his nose to check for the missing Lego piece. Sure enough, there it is, visible in all its glory !! My wife is stunned. The Doctor wants to remove the particle as leaving it in there could lead to infections etc. The Doctor finds the incident amusing as she has dealt with similar cases multiple times and takes my son to a different room to perform the extraction.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;She attempts to remove it via an instrument that looked like sharp tongs but accidentally pokes my son during the process, that clearly is the end of that strategy for extraction. She deliberates on the next strategy, they do have multiple ones apparently. One direction is to use a reverse blower technique where she sets a blower in the child's mouth causing a force that will throw out the particle through the nose, another is to use a glue attached to the end of a fine stick that can be used to attach to the particle and thus removing it. Think of it as using Super-Glue. The Doctor decides to use the latter. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Please note that while all this is ensuing, my son is not exactly &lt;span class="Apple-style-span" style="font-style: italic;"&gt;Cooperation Exemplified&lt;/span&gt; (expected of him as he has suffered pain) by any means :-). He is quite agitated and makes everyone around know his intentions. My daughter on the other hand is seeing her brother in pain and has an extremely sad expression on her face.  So, in come a couple of more nurses, joining my wife to hold my son down while the second extraction procedure is attempted.  &lt;/div&gt;&lt;div&gt;The doctor sends the instrument in, attaches it to the Lego and manages to pull it down all the way till the nostril. Before she can get it out though, my son breathes in again sucking the Lego all the way back up. Darn! She tries the process again, and this time she manages to get the piece out. However, in the process, she accidentally gets some of the glue under my sons eyes. We have solved the mystery of the missing Lego and put it where it belongs, i.e., in a trash can.  My son however will not consider the process complete until the glue is removed from under his eyes, so the cleaning process and  finally closure. He still has some of the glue in his nose but that will come off in time. I feel bad thinking of all the pain he suffered...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Back home,  my wife debriefs me regarding the incident to my utter disbelief. Boy, am I glad that we went to the Doctor to check on it. I am rather pleased at the way my wife and I handled this minor crisis, i.e., calling poison control, calling the doc, the follow up etc.  I am aware this happens to many kids all the time and thankful that my son did not suffer a  life threatening emergency. I feel bad for the pain he has suffered though.  I wonder how many of my friends have faced something similar where their kids have ingested foreign particles :-)&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Take aways from the incident:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;- Kids are genetically designed to give their parents heart palpitations once in a while, regardless of age ...:-)&lt;/div&gt;&lt;div&gt;- Be careful regarding small particles, kids tend to experiment regardless of age&lt;/div&gt;&lt;div&gt;- Keep important numbers handy when kids are at home&lt;/div&gt;&lt;div&gt;- Recommend that one never pass up on a full examination from the Doctor when it involves an incident regarding your child&lt;/div&gt;&lt;div&gt;- Even the smallest of things can be deadly&lt;/div&gt;&lt;div&gt;- There is no happiness that compares to knowing your child is healthy&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Some links that might be of use:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://health.indiamart.com/emergencies/accidental.html"&gt;http://health.indiamart.com/emergencies/accidental.html&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.defenselink.mil/news/newsarticle.aspx?id=42255"&gt;http://www.defenselink.mil/news/newsarticle.aspx?id=42255&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.aupairinamerica.com/resources/safety_tips/toys.asp"&gt;http://www.aupairinamerica.com/resources/safety_tips/toys.asp&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-4222131662587222627?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/4222131662587222627/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=4222131662587222627' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/4222131662587222627'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/4222131662587222627'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/03/case-of-missing-lego-mystery-solved.html' title='The Case of the Missing Lego - A mystery solved'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-3856347655365226246</id><published>2009-03-04T13:17:00.007-07:00</published><updated>2009-10-22T17:32:44.994-06:00</updated><title type='text'>Found this funny...</title><content type='html'>What if programming languages ran the airlines, a blog on theserverside.com&lt;br /&gt;&lt;a href="http://www.theserverside.com/news/thread.tss?thread_id=53820"&gt;    http://www.theserverside.com/news/thread.tss?thread_id=53820&lt;br /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-3856347655365226246?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/3856347655365226246/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=3856347655365226246' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/3856347655365226246'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/3856347655365226246'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/03/found-this-funny.html' title='Found this funny...'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-4268647037697960598</id><published>2009-03-02T21:23:00.005-07:00</published><updated>2009-03-02T23:26:56.008-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jersey jax-rs example maven'/><category scheme='http://www.blogger.com/atom/ns#' term='JAXRS'/><category scheme='http://www.blogger.com/atom/ns#' term='jaxs-caching response'/><category scheme='http://www.blogger.com/atom/ns#' term='jax-rs'/><category scheme='http://www.blogger.com/atom/ns#' term='REST Caching'/><title type='text'>An Example of Caching with REST using Jersey JAX-RS</title><content type='html'>One of the constraints/benefits of a RESTful architecture is the use of Cache's where possible. REST architecture gains from the use of cache's by reducing network bandwidth and unnecessary I/O. In short, caching of information has a direct impact on the scalability of the RESTful architecture.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Service Side Cache:&lt;/span&gt;&lt;br /&gt;When a request is made to retrieve a data set, if the data set information does not change over a fixed duration as determined via non-functional requirements, then caching the data set on the Server side has the benefit of not having to suffer for example, database I/O for every client request. Network bandwidth utilization from Client to Server is of course suffered with a Server only cache.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Client Side Cache:&lt;/span&gt;&lt;br /&gt;HTTP has a very cool construct in terms of information that a server can provide to a client saying &lt;span style="font-weight: bold;"&gt;cache&lt;/span&gt; or &lt;span style="font-weight: bold;"&gt;do not cache &lt;/span&gt;the payload provided by the server via HTTP Header attributes. In addition, client's can also utilize &lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html"&gt;Conditional GET'&lt;/a&gt;s to only obtain payload if the data has changed on the server. With Conditional GET one could also only return the changes that have occurred and a Client could easily compute the delta and update its local cached copy of the data.&lt;br /&gt;&lt;br /&gt;I wonder how many organizations utilize these features provided by HTTP. The Server side cache can easily be accommodated via using &lt;a href="http://www.squid-cache.org/"&gt;Squid&lt;/a&gt; or some other tool.&lt;br /&gt;&lt;br /&gt;On the Client side, now thats a bit of discussion. As part of HTTP response, a server can let the client know whether or not to Cache the provided representation via the &lt;span style="font-weight: bold;"&gt;"Expires"&lt;/span&gt; HTTP header attribute. As an example, when a Product Client or Web Browser, requests a list of Products from the server, if the server knows that the Product data will not be refreshed for some time, it can inform the client to cache the payload representing Products for the duration until expiration. What I like about this control is that the Server and not the Client is instructing the duration for which the data is valid and can be cached. Client's in a Client-Server environment that decide to cache data based of non-functional requirements is a bad way to cache IMO. The duration logic should IMO emanate from the service or server.&lt;br /&gt;&lt;br /&gt;Using the &lt;span style="font-weight: bold;"&gt;"Expires"&lt;/span&gt; header the server can tell the client to cache the data till a particular date  or provide a time duration to cache. The former can be a problem if the client and server clocks are not in sync. For example, the server tells the client to cache a piece of data till Dec 20th, 2012. However, the Client clock is 10 mins behind the server. So although the data on the client has not expired, the server data has. For this reason, setting a duration for expiration via a time duration such as 10 mins will allow both Client/Server to be in sync regarding expiration of the cache.&lt;br /&gt;&lt;br /&gt;What about a case when caching is recommended on the client but there is a certain amount of volatility involved with the data. For example, lets say we have an &lt;span style="font-style: italic;"&gt;OrderClient&lt;/span&gt; that &lt;span style="font-weight: bold;"&gt;GETs&lt;/span&gt; order information about a particular order from the server. The Order information could potentially be updated by a user subsequently, for example, adding a new line item to the Order. In such a case one could avail the Conditional GET features of HTTP to obtain new payload &lt;span style="font-weight: bold;"&gt;only if the data cached by the Client is stale&lt;/span&gt;. The server determines whether the data has changed between the last time the client requested the payload and either provides the entire data or responds back with a HTTP status of &lt;span style="font-weight: bold;"&gt;304,&lt;/span&gt; indicating &lt;span style="font-weight: bold;"&gt;UN-Modified&lt;/span&gt; payload. The client in turn can in turn as a result of a 304 returned from the server, respond the consumer with the data it has previously cached. This reduces the amount of data transferred between client and server and thus alleviates network bandwidth utilization. Conditional HTTP GET can be availed using either &lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html"&gt;&lt;span style="font-weight: bold;"&gt;Etags&lt;/span&gt;&lt;/a&gt; or &lt;span style="font-weight: bold;"&gt;Last-Modified &lt;/span&gt;header attributes.&lt;br /&gt;&lt;br /&gt;As an example of the above, let us look at a &lt;a href="http://wikis.sun.com/display/Jersey/Overview+of+JAX-RS+1.0+Features"&gt;Jersey, JAX-RS&lt;/a&gt; example. In the example, we have two clients, a &lt;span style="font-style: italic;"&gt;ProductClient&lt;/span&gt; that obtains information about Products and an &lt;span style="font-style: italic;"&gt;OrderClient&lt;/span&gt; used to manage the life cycle of an Order. The Product Client will cache the Products until the time has come to re-fetch the products due to expiration while the &lt;span style="font-style: italic;"&gt;OrderClient&lt;/span&gt; will cache the payload obtained an issue a &lt;span style="font-weight: bold;"&gt;Conditional&lt;/span&gt; GET to only obtain the payload if the data has changed on the server since its last request.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-weight: bold;"&gt;ProductsResource&lt;/span&gt; as shown below for the sake of demonstration, sets the Products to expire 3 seconds after its invocation:&lt;br /&gt;&lt;pre&gt;@&lt;span style="color:#2040a0;"&gt;GET&lt;/span&gt; @&lt;span style="color:#2040a0;"&gt;Produces&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"application/json"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;strong&gt;public&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;Response&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;getProducts&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   ...&lt;br /&gt;   &lt;span style="color:#2040a0;"&gt;ProductListDto&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;productListDto&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;ProductListDto&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;productDtos&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;   &lt;span style="color:#2040a0;"&gt;Response&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;ResponseBuilder&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;response&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;Response&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;ok&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;productListDto&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;type&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;MediaType&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;APPLICATION_JSON&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="color:#444444;"&gt;// Expires 3 seconds from now..this would be ideally based &lt;/span&gt;&lt;br /&gt;   &lt;span style="color:#444444;"&gt;// of some pre-determined non-functional requirement.&lt;/span&gt;&lt;br /&gt;   &lt;span style="color:#2040a0;"&gt;Date&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;expirationDate&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;Date&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;System&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;currentTimeMillis&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;+&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;3000&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="color:#2040a0;"&gt;response&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;expires&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;expirationDate&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;strong&gt;return&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;response&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;build&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;hr /&gt;&lt;br /&gt;The &lt;span style="font-weight: bold;"&gt;OrderResource&lt;/span&gt; on the other hand based of an &lt;span style="font-weight: bold;"&gt;etag&lt;/span&gt; determines if the order has been modified since the last GET request by the client and returns back a status of 304 or the entire order body as shown below:&lt;br /&gt;&lt;hr /&gt;&lt;pre&gt;@&lt;span style="color:#2040a0;"&gt;GET&lt;/span&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;Produces&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"application/xml"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;Response&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;getOrder&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;@&lt;span style="color:#2040a0;"&gt;Context&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;HttpHeaders&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;hh&lt;/span&gt;, @&lt;span style="color:#2040a0;"&gt;Context&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;Request&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;request&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;OrderNotFoundException&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="color:#2040a0;"&gt;Order&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;order&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;orderService&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getOrder&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;orderId&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="color:#2040a0;"&gt;LOG&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;debug&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"Checking if there an Etag and whether there is a change in the order..."&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="color:#2040a0;"&gt;EntityTag&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;etag&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;computeEtagForOrder&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;order&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;span style="color:#2040a0;"&gt;Response&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;ResponseBuilder&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;responseBuilder&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;request&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;evaluatePreconditions&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;etag&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;strong&gt;if&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;responseBuilder&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;!&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#444444;"&gt;// Etag match&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color:#2040a0;"&gt;LOG&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;debug&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"Order has not changed..returning unmodified response code"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;strong&gt;return&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;responseBuilder&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;build&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color:#2040a0;"&gt;LOG&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;debug&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"Returning full Order to the Client"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#2040a0;"&gt;OrderDto&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;orderDto&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;OrderDto&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;beanMapper&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;map&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;order&lt;/span&gt;, &lt;span style="color:#2040a0;"&gt;OrderDto&lt;/span&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color:#2040a0;"&gt;responseBuilder&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;Response&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;ok&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;orderDto&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;tag&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;etag&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;return&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;responseBuilder&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;build&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;From the Perspective of the &lt;span style="font-weight: bold;"&gt;ProductClient,&lt;/span&gt; it looks to see whether the cached data has expired before issuing a new request to the server as shown below:&lt;br /&gt;&lt;hr /&gt;&lt;pre&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;ProductListDto&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;getProducts&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="color:#444444;"&gt;// Key into the cache&lt;/span&gt;&lt;br /&gt; &lt;span style="color:#2040a0;"&gt;String&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;path&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;resource&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getURI&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getPath&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="color:#2040a0;"&gt;CacheEntry&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;entry&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;CacheManager&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;get&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;path&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;span style="color:#2040a0;"&gt;ProductListDto&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;productList&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;if&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;entry&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;!&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#2040a0;"&gt;LOG&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;debug&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"Product Entry in cache is not null...checking expiration date.."&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span style="color:#2040a0;"&gt;Date&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;cacheTillDate&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;entry&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getCacheTillDate&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#2040a0;"&gt;Date&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;now&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;Date&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;strong&gt;if&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;now&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;before&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;cacheTillDate&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;       &lt;span style="color:#2040a0;"&gt;LOG&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;debug&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"Product List is not stale..using cached value"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="color:#2040a0;"&gt;productList&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt;  &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;ProductListDto&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;entry&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getObject&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt; &lt;strong&gt;else&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="color:#2040a0;"&gt;LOG&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;debug&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"Product List is stale..will request server for new Product List.."&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;   &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;strong&gt;if&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;productList&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span style="color:#2040a0;"&gt;LOG&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;debug&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"Fetching Product List from Service..."&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#2040a0;"&gt;ClientResponse&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;response&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;resource&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;accept&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;MediaType&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;APPLICATION_JSON&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;get&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;ClientResponse&lt;/span&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;strong&gt;if&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;response&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getResponseStatus&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;equals&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;Status&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;OK&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="color:#2040a0;"&gt;productList&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;response&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getEntity&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;ProductListDto&lt;/span&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;       &lt;span style="color:#2040a0;"&gt;String&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;cacheDate&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;response&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getMetadata&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getFirst&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"Expires"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;strong&gt;if&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;cacheDate&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;!&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;         &lt;span style="color:#2040a0;"&gt;Date&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;ccDate&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;         &lt;strong&gt;try&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;           &lt;span style="color:#2040a0;"&gt;ccDate&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;DATE_FORMAT&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;parse&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;cacheDate&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;           &lt;span style="color:#2040a0;"&gt;entry&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;CacheEntry&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;productList&lt;/span&gt;, &lt;strong&gt;null&lt;/strong&gt;, &lt;span style="color:#2040a0;"&gt;ccDate&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;           &lt;span style="color:#2040a0;"&gt;CacheManager&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;cache&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;path&lt;/span&gt;, &lt;span style="color:#2040a0;"&gt;entry&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;         &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;         &lt;strong&gt;catch&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;ParseException&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;e&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;           &lt;span style="color:#2040a0;"&gt;LOG&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;error&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"Error Parsing returned cache date..no caching will occur"&lt;/span&gt;, &lt;span style="color:#2040a0;"&gt;e&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;         &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;       &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt; &lt;strong&gt;else&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;       &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;RuntimeException&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"Error Getting Products...."&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;   &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;strong&gt;return&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;productList&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;hr /&gt;The Order Client on the other hand uses the &lt;span style="font-weight: bold;"&gt;etag&lt;/span&gt; and sends that as part of every request to the server as shown below:&lt;br /&gt;&lt;hr /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;OrderDto&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;getOrder&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;Long&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;orderId&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;OrderNotFoundException&lt;/span&gt;, &lt;span style="color:#2040a0;"&gt;IOException&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;    &lt;strong&gt;try&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#2040a0;"&gt;String&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;path&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;resource&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;path&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;orderId&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;toString&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getURI&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getPath&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span style="color:#2040a0;"&gt;CacheEntry&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;entry&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;CacheManager&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;get&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;path&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#2040a0;"&gt;Builder&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;wr&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;resource&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;path&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;orderId&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;toString&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;accept&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;MediaType&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;APPLICATION_XML&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;strong&gt;if&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;entry&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;!&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;strong&gt;null&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&amp;amp;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&amp;amp;&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;entry&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getEtag&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;!&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="color:#444444;"&gt;// Set the etag&lt;/span&gt;&lt;br /&gt;       &lt;span style="color:#2040a0;"&gt;wr&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;header&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"If-None-Match"&lt;/span&gt;, &lt;span style="color:#2040a0;"&gt;entry&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getEtag&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getValue&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span style="color:#2040a0;"&gt;ClientResponse&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;response&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;wr&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;get&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;ClientResponse&lt;/span&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;strong&gt;if&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;response&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getResponseStatus&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;equals&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;Status&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;NOT_MODIFIED&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="color:#2040a0;"&gt;LOG&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;debug&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"Order has not been modified..returning Cached Order..."&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;       &lt;strong&gt;return&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;OrderDto&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;entry&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getObject&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;     &lt;strong&gt;else&lt;/strong&gt; &lt;strong&gt;if&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;response&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getResponseStatus&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;equals&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;Status&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;OK&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="color:#2040a0;"&gt;LOG&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;debug&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"Obtained full Order from Service...Caching it.."&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;       &lt;span style="color:#2040a0;"&gt;OrderDto&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;dto&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;response&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getEntity&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;OrderDto&lt;/span&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="color:#2040a0;"&gt;CacheManager&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;cache&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;path&lt;/span&gt;, &lt;strong&gt;new&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;CacheEntry&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;dto&lt;/span&gt;, &lt;span style="color:#2040a0;"&gt;response&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getEntityTag&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;, &lt;strong&gt;null&lt;/strong&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;strong&gt;return&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;dto&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;     &lt;strong&gt;else&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;       &lt;span style="color:#2040a0;"&gt;LOG&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;debug&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"Order not found on server...removing from cache"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="color:#2040a0;"&gt;CacheManager&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;remove&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;path&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;       &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;UniformInterfaceException&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;response&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;   &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;   &lt;strong&gt;catch&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;UniformInterfaceException&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;e&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;strong&gt;if&lt;/strong&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;e&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getResponse&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getStatus&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;Status&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;NOT_FOUND&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getStatusCode&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;OrderNotFoundException&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;e&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getResponse&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getEntity&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;String&lt;/span&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;     &lt;strong&gt;throw&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;RuntimeException&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;e&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;   &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr /&gt;Seeing the above in action, for the Products; we obtain Products in the first call, this should result in caching of the same, the second request executed immediately after the first should obtain the cached Products. Sleeping for sometime will allow the data to become stale and a subsequent request should re-fetch the data. The logs when the tests are run look like:&lt;br /&gt;&lt;hr /&gt;1 Request, cache Products:&lt;br /&gt;&lt;pre&gt;20:37:33 DEBUG - com.welflex.client.CacheManager.cache(14) | Caching Object with key [/IntegrationTest/products]&lt;br /&gt;&lt;br /&gt;2. Request, Product Cache still good:&lt;br /&gt;20:37:33 DEBUG - com.welflex.client.CacheManager.get(19) | Getting Object from Cache for Key:/IntegrationTest/products&lt;br /&gt;20:37:33 DEBUG - com.welflex.client.ProductClientImpl.getProducts(49) | Product Entry in cache is not null...checking cache till date&lt;br /&gt;20:37:33 DEBUG - com.welflex.client.ProductClientImpl.getProducts(54) | Product List is not stale..using cached value&lt;br /&gt;&lt;br /&gt;3. Request, Products have expired:&lt;br /&gt;20:37:43 DEBUG - com.welflex.client.CacheManager.get(19) | Getting Object from Cache for Key:/IntegrationTest/products&lt;br /&gt;20:37:43 DEBUG - com.welflex.client.CacheManager.get(21) | Object in Cache for Key [/IntegrationTest/products] is :com.welflex.client.CacheEntry@1bf3d87&lt;br /&gt;20:37:43 DEBUG - com.welflex.client.ProductClientImpl.getProducts(49) | Product Entry in cache is not null...checking cache till date&lt;br /&gt;20:37:43 DEBUG - com.welflex.client.ProductClientImpl.getProducts(57) | Product List is stale..will request server for new Product List..&lt;br /&gt;20:37:43 DEBUG - com.welflex.client.ProductClientImpl.getProducts(62) | Fetching Product List from Service...&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr /&gt;From the Order Client Perspective, the first request to obtain the order results in the Order being cached with the etag. When a subsequent request is sent, the server only responds back with a status of 304, i.e, un-modified and then the Order Client responds back with the cached copy. After this second request, the order is updated and the etag is no longer valid therefore a subsequent GET of the order results in the full order being fetched and re-cached as shown below:&lt;br /&gt;&lt;hr /&gt;&lt;pre&gt;1. First time Order is retreived, Order is cached:&lt;br /&gt;Retrieving the order...&lt;br /&gt;22:33:13 DEBUG - com.welflex.client.CacheManager.get(19) | Getting Object from Cache for Key:/IntegrationTest/orders/3443274629940897628&lt;br /&gt;22:33:13 DEBUG - com.welflex.client.OrderClientImpl.getOrder(68) | Obtained full Order from Service...Caching it..&lt;br /&gt;&lt;br /&gt;2. Second Request, Order not changed on Server, 304 returned to Client:&lt;br /&gt;22:33:13 DEBUG - com.welflex.order.rest.resource.OrderResource.getOrder(68) | Order Resource 22:33:13 DEBUG - com.welflex.order.rest.resource.OrderResource.getOrder(79) | Order has not changed..returning unmodified response code&lt;br /&gt;22:33:13 DEBUG - com.welflex.client.OrderClientImpl.getOrder(64) | Order has not been modified..returning Cached Order...&lt;br /&gt;&lt;br /&gt;3. Issue a PUT to update the Order, thus changing it:&lt;br /&gt;Updating the order...&lt;br /&gt;22:33:13 DEBUG - com.welflex.order.rest.resource.OrderResource.updateOrder(106) | Enter Update Order, Id=3443274629940897628&lt;br /&gt;&lt;br /&gt;4. Retrieve the Order the etag should no longer be valid:&lt;br /&gt;Retrieving the order..should not obtained cached copy...&lt;br /&gt;22:33:13 DEBUG - com.welflex.order.rest.resource.OrderResource.getOrder(73) | Checking if there an Etag and whether there is a change in the order...&lt;br /&gt;22:33:13 DEBUG - com.welflex.order.rest.resource.OrderResource.getOrder(83) | Returning full Order to the Client&lt;br /&gt;22:33:13 DEBUG - com.welflex.client.OrderClientImpl.getOrder(68) | Obtained full Order from Service...Caching it..&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr /&gt;Attached &lt;a href="http://home.comcast.net/%7Eacharya.s/java/SpringJersey-caching.zip"&gt;HERE is the sample Maven Jersey JAX-RS sample &lt;/a&gt;that will allow you to witness the above. The caching implemented is primitive at best and the attached code is only an EXAMPLE. One could easily delegate the caching to some caching framework such as ehcache, oscache, jcs etc. One can even potentially get more exotic and think of Aspects that will intercept calls to GET and transparently provide the caching.&lt;br /&gt;&lt;br /&gt;To execute the example, from the command line, at the root of the project, execute a "&lt;span style="font-weight: bold;"&gt;mvn install&lt;/span&gt;". Note that one needs JDK5.X+ in order to execute the code.&lt;br /&gt;&lt;br /&gt;Caching is a very critical feature of REST.  Without using the same is like saying one is doing RES without the T. As always, if a reader of this blog has any comments, I'd appreciate the same.  If I am wrong, I would like comments on the same as that will help me improve..or else forever hold ur breath :-) If you cannot run the example, ping me...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-4268647037697960598?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/4268647037697960598/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=4268647037697960598' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/4268647037697960598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/4268647037697960598'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/03/example-of-caching-with-rest-using.html' title='An Example of Caching with REST using Jersey JAX-RS'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-5877227119805670152</id><published>2009-03-02T20:47:00.005-07:00</published><updated>2009-03-04T18:36:52.775-07:00</updated><title type='text'>Sub-Resources with Jersey,Spring, jax-rs</title><content type='html'>A simple example on how to use Sub-Resources with Jersey and Spring.&lt;br /&gt;&lt;br /&gt;For the sake of discussion, consider a Resource &lt;span style="color: rgb(51, 51, 255);"&gt;/orders&lt;/span&gt;. One would typically POST to the resource to create an Order, update the Order at the Resource &lt;span style="color: rgb(51, 51, 255);"&gt;/orders/{id}&lt;/span&gt;, GET the Resource from the URI&lt;span style="color: rgb(51, 51, 255);"&gt; /orders/{id}&lt;/span&gt; and also delete the order at the Resource&lt;span style="color: rgb(51, 51, 255);"&gt; /orders/{id}&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;One can therefore state that &lt;span style="color: rgb(51, 51, 255);"&gt;/orders/{id}&lt;/span&gt; is a &lt;span style="font-weight: bold;"&gt;Sub-Resource &lt;/span&gt;of &lt;span style="color: rgb(51, 51, 255);"&gt;/orders.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In &lt;span style="font-weight: bold;"&gt;jax-rs&lt;/span&gt;, sub-resources are obtained from the parent resource. A parent resource will not define a HTTP method for the sub-resource, but instead simple have a &lt;span style="font-weight: bold;"&gt;@Path&lt;/span&gt; annotation indicating a sub-resource.&lt;br /&gt;&lt;br /&gt;For example,&lt;br /&gt;&lt;hr /&gt;&lt;pre&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;Path&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"/orders"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;Component&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;Scope&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"singleton"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;OrdersResource&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;Context&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;private&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;ResourceContext&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;resourceContext&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;Path&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"/{id}"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;OrderResource&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;subResource&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;@&lt;span style="color:#2040a0;"&gt;PathParam&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"id"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;String&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;id&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color:#2040a0;"&gt;OrderResource&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;resource&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;resourceContext&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;getResource&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;OrderResource&lt;/span&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color:#2040a0;"&gt;resource&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;setOrderId&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;Long&lt;/span&gt;.&lt;span style="color:#2040a0;"&gt;parseLong&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;id&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;return&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;resource&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;...&lt;br /&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;In the above example, we have an &lt;span style="font-weight: bold;"&gt;OrdersResource&lt;/span&gt; that services the URI pattern of &lt;span style="color: rgb(51, 51, 255);"&gt;/orders&lt;/span&gt;. Calls to &lt;span style="color: rgb(51, 51, 255);"&gt;/orders/{id}&lt;/span&gt; are delegated to a sub-resource of the Order&lt;span style="font-weight: bold;"&gt;s&lt;/span&gt;Resource called &lt;span style="font-weight: bold;"&gt;OrderResource&lt;/span&gt; as shown below:&lt;br /&gt;&lt;hr /&gt;&lt;pre&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;PerRequest&lt;/span&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;Component&lt;/span&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;Scope&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"prototype"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;OrderResource&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;private&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;Long&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;orderId&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#444444;"&gt;// Jersey injected&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;Context&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;private&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;ResourceContext&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;resourceContext&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#444444;"&gt;// Spring injected&lt;/span&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;Autowired&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;private&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;OrderService&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;orderService&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;Autowired&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;private&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;MapperIF&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;beanMapper&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;....&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;setOrderId&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#2040a0;"&gt;Long&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;orderId&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;  &lt;strong&gt;this&lt;/strong&gt;.&lt;span style="color:#2040a0;"&gt;orderId&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;=&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;orderId&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#444444;"&gt;// @Context are Jersey injected&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;GET&lt;/span&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;Produces&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"application/xml"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;Response&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;getOrder&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;@&lt;span style="color:#2040a0;"&gt;Context&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;HttpHeaders&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;hh&lt;/span&gt;,&lt;br /&gt;    @&lt;span style="color:#2040a0;"&gt;Context&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;Request&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;request&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;    &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt; ... &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;Consumes&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"application/xml"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;PUT&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;updateOrder&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;@&lt;span style="color:#2040a0;"&gt;PathParam&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"id"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;String&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;id&lt;/span&gt;, &lt;span style="color:#2040a0;"&gt;OrderDto&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;orderDto&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; ....&lt;br /&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;DELETE&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;void&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;deleteOrder&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;@&lt;span style="color:#2040a0;"&gt;PathParam&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"id"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;String&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;id&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  ....&lt;br /&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;@&lt;span style="color:#2040a0;"&gt;Path&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;"/lineItems"&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;LineItemListDto&lt;/span&gt; &lt;span style="color:#2040a0;"&gt;getLineItems&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;span style="color:#2040a0;"&gt;OrderNotFoundException&lt;/span&gt; &lt;span style="color:#4444ff;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; .....&lt;br /&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#4444ff;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;hr /&gt;&lt;br /&gt;Both the above mentioned Resources are beautifully managed by Spring and Jersey interoperability. Jersey Resources are injected by Jersey and Spring resources are injected by Spring auto-wiring. So cool!!!!&lt;br /&gt;&lt;br /&gt;As shown above the OrderResource is following a Prototype pattern and is obtained via a called to &lt;span style="font-style: italic;"&gt;resourceContext.getResource(OrderResource.class). &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I quite like the fact that the &lt;span style="font-style: italic;"&gt;OrderResource&lt;/span&gt; is declared as sub-resource of the &lt;span style="font-style: italic;"&gt;OrdersResource&lt;/span&gt; and the creation of the Sub-Resource via the prototype pattern matches so beautifully within jax-rs. It becomes a trivial exercise to trace the flow of a uri-call from the parent resource to sub-resources.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-5877227119805670152?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/5877227119805670152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=5877227119805670152' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/5877227119805670152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/5877227119805670152'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/03/sub-resources-with-jerseyspring-jax-rs.html' title='Sub-Resources with Jersey,Spring, jax-rs'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-4799024965632829554</id><published>2009-02-18T21:19:00.005-07:00</published><updated>2009-02-18T22:26:34.390-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Jeremy Brett'/><category scheme='http://www.blogger.com/atom/ns#' term='Granada Sherlock Holmes'/><category scheme='http://www.blogger.com/atom/ns#' term='Sherlock Holmes'/><title type='text'>Jeremy Brett was the best..Downey Jr. Back off</title><content type='html'>Apparently, &lt;a href="http://en.wikipedia.org/wiki/Robert_Downey,_Jr."&gt;Robert Downey Jr&lt;/a&gt; and Ex.Mr.Madonna, i.e., Guy Ritchie are in the process of making a &lt;a href="http://en.wikipedia.org/wiki/Sherlock_Holmes"&gt;Sherlock Holmes&lt;/a&gt; movie. All good, I have no doubts that the movie will be fun to watch, after all its about the most famous sleuth of our times.&lt;br /&gt;&lt;br /&gt;My bone lies with, Mr.Downey Jr thinking he can do &lt;a href="http://justjared.buzznet.com/2008/10/10/robert-downey-jr-as-sherlock-holmes-first-pictures/"&gt;Holmes better than it has ever been done before&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;Go ahead, attempt the same Mr.Jr. However, there is one man you can never be better than and that is &lt;a href="http://en.wikipedia.org/wiki/Jeremy_Brett"&gt;Jeremy Brett&lt;/a&gt;. Steve Martin attempted to do &lt;a href="http://inspectorclouseau.com/"&gt;Clouseau&lt;/a&gt; but sensibly acknowledged that &lt;a href="http://www.petersellers.com/"&gt;Peter Sellers &lt;/a&gt;is the original master. Arrogance is great but dear god, how do you even think you can ever compare to Jeremy's portrayal of Holmes let alone surpass it. If you even come close, it would be my utmost pleasure to eat my words and admit the same.&lt;br /&gt;&lt;br /&gt;For those unfamiliar with Jeremy Brett, he played Sherlock Holmes in a series developed for television by &lt;a href="http://en.wikipedia.org/wiki/Granada_Television"&gt;Granada&lt;/a&gt;. Those productions were superb to say the least, the detail representing the times, the screenplay, the direction and the performances were all superlative. I have seen &lt;a href="http://www.basilrathbone.net/"&gt;Basil Rathbone&lt;/a&gt; and others as Holmes but Jeremy is the quintessential Holmes by a mile. The twitching and dismissing smile, the touch of an eccentric genius, the desperation to crack a case, the deductive explanations, hell, this was Holmes as &lt;a href="http://en.wikipedia.org/wiki/Arthur_Conan_Doyle"&gt;A.C.Doyle&lt;/a&gt; would have picturized in his mind while writing the content. I could totally identify with him. Solving "The Musgrave Ritual with Trigonometry", "The Final Problem at the &lt;a href="http://en.wikipedia.org/wiki/Reichenbach_Falls"&gt;Reichenbach&lt;/a&gt; falls" or the "The Speckled Band", Jeremy's portrayal were dot on.&lt;br /&gt;&lt;br /&gt;Sadly Jeremy was taken away from us due to a debilitating disease. If not, we might have seen the making of missed episodes by Granada. &lt;br /&gt;&lt;br /&gt;For any doubters, I recommend you take a look at the Televised series by Granada. You will not be disappointed. I personally am not into buying DVD collections but the Granda series are worth the $$$.&lt;br /&gt;&lt;br /&gt;A role is often open ended. Everyone has a chance to play it by adding their own flavor in the realms provided for creativity, James Bond has been played by many, each one adding their own flavor to Bond. Very few among those actors would claim they represented or did Bond better than the others. &lt;br /&gt;&lt;br /&gt;Bond is debatable, Holmes is not. I am a Connery fan but I can see Pierce in the role easily. Not bettering Connery, but bringing a different flavor to the portrayal. A stupid statement saying "I will be the best Holmes ever" in the company of such greats like Jeremy and Basil is IMO just plain food for ridicule.&lt;br /&gt;&lt;br /&gt;Jeremy, you cannot be surpassed.! If Mr.Downey Jr is smart, he is watching your portrayal and hopefully learning...&lt;br /&gt;&lt;br /&gt;As a student of Logic, a deficiency I am trying to fill, I try to deduct, "Attempting to surpass Mr.Brett in the portrayal of Mr.Holmes is like an exercise in attempting to prove Crows are Green!" Painted crows are discounted from the logical reasoning of course :-)&lt;br /&gt;&lt;br /&gt;Thanks Mr.Brett for hours of wonderful viewing..Let the pretenders to the throne claim away, I for one, know who is king!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4667121987470696359-4799024965632829554?l=sleeplessinslc.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sleeplessinslc.blogspot.com/feeds/4799024965632829554/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=4667121987470696359&amp;postID=4799024965632829554' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/4799024965632829554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4667121987470696359/posts/default/4799024965632829554'/><link rel='alternate' type='text/html' href='http://sleeplessinslc.blogspot.com/2009/02/jeremy-brett-was-bestdowney-jr-back-off.html' title='Jeremy Brett was the best..Downey Jr. Back off'/><author><name>Sanjay Acharya</name><uri>http://www.blogger.com/profile/01933976956977901677</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09790815780330466750'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4667121987470696359.post-1184579259574641591</id><published>2009-01-30T20:50:00.019-07:00</published><updated>2009-02-02T21:26:09.551-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spring JmsTemplate'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring WebLogic JmsTemplate'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring JmsTemplate WebLogic'/><title type='text'>Spring JmsTemplate WebLogic</title><content type='html'>In an&lt;a href="http://sleeplessinslc.blogspot.com/2009/01/spring-jms-support.html"&gt; earlier blog&lt;/a&gt;, I had expressed my concern regarding the &lt;a href="http://static.springframework.org/spring/docs/2.5.3/api/org/springframework/jms/core/JmsTemplate.html"&gt;JmsTemplate&lt;/a&gt; from the &lt;a href="http://static.springframework.org/spring/docs/2.0.x/reference/index.html"&gt;Spring Framework&lt;/a&gt; and that it promotes a bad design pattern, i.e., where JMS artifacts are created and closed across every send/receive.&lt;br /&gt;&lt;br /&gt;Spring's &lt;a href="http://static.springframework.org/spring/docs/2.5.3/api/org/springframework/jms/connection/SingleConnectionFactory.html"&gt;SingleConnectionFactory&lt;/a&gt; class pools a single connection for every template nicely and tends to alleviate the problem. However, it fails to pool &lt;span style="FONT-STYLE: italic"&gt;Session,&lt;/span&gt; &lt;span style="FONT-STYLE: italic"&gt;Producer&lt;/span&gt; and &lt;span style="FONT-STYLE: italic"&gt;Consumer&lt;/span&gt; artifacts. As mentioned by James Strachan and others, the same can lead to performance degradation.&lt;br /&gt;&lt;br /&gt;With the &lt;span style="FONT-STYLE: italic"&gt;SingleConnectionFactory,&lt;/span&gt; Spring definitely started off on the right foot, however, the same is not enough. The other artifacts derived from &lt;span style="FONT-STYLE: italic"&gt;javax.jms.Connection&lt;/span&gt; bring their own penalty and the cost of the same is probabaly different depending on the JMS Provider used.&lt;br /&gt;&lt;br /&gt;When using &lt;span style="FONT-STYLE: italic"&gt;WebLogic,&lt;/span&gt; I found that clearly the most performant way to send messages is without using the &lt;span style="FONT-STYLE: italic"&gt;JmsTemplate,&lt;/span&gt; i.e., obtaining a &lt;em&gt;Connection&lt;/em&gt;, &lt;em&gt;Session&lt;/em&gt;, &lt;em&gt;Producer/Consumer&lt;/em&gt; and re-using the same across multiple sends or receives. Using the &lt;span style="FONT-STYLE: italic"&gt;JmsTemplate&lt;/span&gt; does impact the performance even though Spring's &lt;span style="FONT-STYLE: italic"&gt;SingleConnectionFactory&lt;/span&gt; re-uses the &lt;em&gt;Connection&lt;/em&gt; object, there seems to be a penalty that is encountered due to &lt;em&gt;Session&lt;/em&gt; and &lt;em&gt;Producer/Consumers&lt;/em&gt; not being re-used.&lt;br /&gt;&lt;br /&gt;Is it is possible to re-use the &lt;em&gt;Session&lt;/em&gt; and &lt;em&gt;Producer/Consumers&lt;/em&gt; via the &lt;em&gt;JmsTemplate&lt;/em&gt; ? Sure, a simple custom implementation of the Connection Factory that proxies and re-uses the &lt;em&gt;Session&lt;/em&gt; and &lt;em&gt;Producer/Consumer&lt;/em&gt; artifacts can lead to a performance gain.&lt;br /&gt;&lt;br /&gt;Using the &lt;a href="http://www.ibm.com/developerworks/java/library/j-jtp08305.html"&gt;Dynamic Proxy&lt;/a&gt; pattern, one can create a custom &lt;em&gt;ConnectionFactory&lt;/em&gt; that wraps the connection factory that is obtained from the JMS Provider. The custom Connection factory like Spring's SingleConnectionFactory class maintains a single JMS Connection which is re-used across every send/receive. However, unlike Spring's &lt;em&gt;SingleConnectionFactory&lt;/em&gt;, the connection returned is a &lt;strong&gt;&lt;em&gt;Proxy&lt;/em&gt;&lt;/strong&gt; that will attempt to&lt;strong&gt; re-use Session objects&lt;/strong&gt;. The Session objects created by the Connection Proxy are also Proxies and will &lt;strong&gt;&lt;em&gt;pool Producer/Consumer&lt;/em&gt;&lt;/strong&gt; objects. Doing pooling all the way down allows for re-use of created JMS Objects. I created a simple example of the same that does the pooling. Nothing too exotic, just a simple, and most likely bug filled ;-) library as shown below:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Custom Connection Factory that Creates a Single Connection:&lt;/strong&gt; &lt;br /&gt;&lt;hr/&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;font color="#2040a0"&gt;SingleConnectionFactory&lt;/font&gt; &lt;strong&gt;implements&lt;/strong&gt; &lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt;, &lt;font color="#2040a0"&gt;QueueConnectionFactory&lt;/font&gt;,&lt;br /&gt;    &lt;font color="#2040a0"&gt;TopicConnectionFactory&lt;/font&gt;, &lt;font color="#2040a0"&gt;DisposableBean&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;final&lt;/strong&gt; &lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt; &lt;font color="#2040a0"&gt;delegate&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;font color="#2040a0"&gt;Connection&lt;/font&gt; &lt;font color="#2040a0"&gt;singleConnection&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;font color="#2040a0"&gt;String&lt;/font&gt; &lt;font color="#2040a0"&gt;clientID&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;font color="#2040a0"&gt;ConnectionInvocationHandler&lt;/font&gt; &lt;font color="#2040a0"&gt;dynamicConnectionProxy&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;public&lt;/strong&gt; &lt;font color="#2040a0"&gt;SingleConnectionFactory&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;ConnectionFactory&lt;/font&gt; &lt;font color="#2040a0"&gt;delegate&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt;strong&gt;this&lt;/strong&gt;.&lt;font color="#2040a0"&gt;delegate&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;delegate&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="#444444"&gt;// Create the sole connection&lt;/font&gt;&lt;br /&gt;  &lt;strong&gt;private&lt;/strong&gt; &lt;strong&gt;synchronized&lt;/strong&gt; &lt;font color="#2040a0"&gt;Connection&lt;/font&gt; &lt;font color="#2040a0"&gt;createSingleConnection&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;throws&lt;/strong&gt; &lt;font color="#2040a0"&gt;JMSException&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;singleConnection&lt;/font&gt; &lt;font color="4444FF"&gt;!&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;strong&gt;return&lt;/strong&gt; &lt;font color="#2040a0"&gt;singleConnection&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;Connection&lt;/font&gt; &lt;font color="#2040a0"&gt;conn&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;delegate&lt;/font&gt;.&lt;font color="#2040a0"&gt;createConnection&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;clientID&lt;/font&gt; &lt;font color="4444FF"&gt;!&lt;/font&gt;&lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;null&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;conn&lt;/font&gt;.&lt;font color="#2040a0"&gt;setClientID&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;clientID&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;List&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Class&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;? &lt;strong&gt;extends&lt;/strong&gt; &lt;font color="#2040a0"&gt;Connection&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#2040a0"&gt;classes&lt;/font&gt; &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;strong&gt;new&lt;/strong&gt; &lt;font color="#2040a0"&gt;ArrayList&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Class&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;lt;&lt;/font&gt;? &lt;strong&gt;extends&lt;/strong&gt; &lt;font color="#2040a0"&gt;Connection&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;3&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;font color="#2040a0"&gt;classes&lt;/font&gt;.&lt;font color="#2040a0"&gt;add&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;Connection&lt;/font&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;conn&lt;/font&gt; &lt;strong&gt;instanceof&lt;/strong&gt; &lt;font color="#2040a0"&gt;QueueConnection&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;classes&lt;/font&gt;.&lt;font color="#2040a0"&gt;add&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;QueueConnection&lt;/font&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;if&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;conn&lt;/font&gt; &lt;strong&gt;instanceof&lt;/strong&gt; &lt;font color="#2040a0"&gt;TopicConnection&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;      &lt;font color="#2040a0"&gt;classes&lt;/font&gt;.&lt;font color="#2040a0"&gt;add&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#2040a0"&gt;TopicConnection&lt;/font&gt;.&lt;strong&gt;class&lt;/strong&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;    &lt