<?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' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8148007777591375750</id><updated>2011-11-21T20:56:39.015Z</updated><title type='text'>AZA (Alvaro Vilaplana García) in JAVA</title><subtitle type='html'>Personal experience working with JEE professional environments</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>22</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-8109773221225594918</id><published>2011-06-20T21:18:00.004+01:00</published><updated>2011-06-20T21:22:15.808+01:00</updated><title type='text'>Template method and Command pattern, a good combination to create generic algorithms</title><content type='html'>&lt;span class="Apple-style-span" style="line-height: 18px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div align="JUSTIFY" class="western" style="line-height: 0.5cm; margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: x-small;"&gt;&lt;b&gt;Introduction&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: x-small;"&gt;With this post I want to share some strategies to face generic algorithms where each step is no tight with concepts. Just on the fly configuration (i.e. using IoC framework) is tight with a specific use case.&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: 'Times New Roman'; font-size: medium;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-family: 'Times New Roman'; font-size: medium; font-style: normal; line-height: 0.5cm; margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;b&gt;Definition of patterns&lt;/b&gt;&lt;span style="font-weight: normal;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-family: 'Times New Roman'; font-size: medium; font-style: normal; line-height: 0.5cm; margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;b&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;T&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;emplate method&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;b&gt;pattern&lt;/b&gt;&lt;span style="font-weight: normal;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-weight: normal;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;defines the&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-weight: normal;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;program skeleton&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-weight: normal;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;of an&amp;nbsp;algorithm&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-weight: normal;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;. One or more of the algorithm steps can be overridden by subclasses to allow differing behavio&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-weight: normal;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;u&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-weight: normal;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;rs while ensuring that the overarching algorithm is still followed.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-weight: normal; line-height: 0.5cm; margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-ZD4cc6Amd_I/Tf5lGqeSvoI/AAAAAAAABEc/1FF-2gfI_jQ/s1600/Template_Pattern.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-ZD4cc6Amd_I/Tf5lGqeSvoI/AAAAAAAABEc/1FF-2gfI_jQ/s1600/Template_Pattern.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-weight: normal; line-height: 0.5cm; margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-family: 'Times New Roman'; font-size: medium; font-style: normal; line-height: 0.5cm; margin-bottom: 0.21cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;b&gt;Command pattern&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-weight: normal;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;defines&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-weight: normal;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;an object used to represent and&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-weight: normal;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;encapsulate&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-weight: normal;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;all the information needed to call a method at a later time. This information includes the method name, the object that owns the method and values for the method parameters.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-weight: normal; line-height: 0.5cm; margin-bottom: 0.21cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;Three terms with the command pattern are:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-family: 'Times New Roman'; font-size: medium; font-style: normal; line-height: 0.5cm; margin-bottom: 0.21cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;The &lt;b&gt;client&lt;/b&gt; instantiates the command object and provides the information required to call the method at a later time.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-family: 'Times New Roman'; font-size: medium; font-style: normal; line-height: 0.5cm; margin-bottom: 0.21cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;The &lt;b&gt;invoker&lt;/b&gt; decides when the method should be called.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-family: 'Times New Roman'; font-size: medium; font-style: normal; line-height: 0.5cm; margin-bottom: 0.21cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;The &lt;b&gt;receiver&lt;/b&gt; is an instance of the class that contains the method's code.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-style: normal; font-weight: normal; line-height: 0.5cm; margin-bottom: 0.21cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 12px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-uqt52ecm9eo/Tf5lPXr0IWI/AAAAAAAABEg/NVTNJfSdk58/s1600/Command.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-uqt52ecm9eo/Tf5lPXr0IWI/AAAAAAAABEg/NVTNJfSdk58/s1600/Command.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-weight: normal; line-height: 0.5cm; margin-bottom: 0.21cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-family: 'Times New Roman'; font-size: medium; font-style: normal; line-height: 0.5cm; margin-bottom: 0.21cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;div style="font-weight: normal;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;b&gt;New Template method approach&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-weight: normal; line-height: 0.5cm; margin-bottom: 0.21cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;Both patterns used together can help to construct a generic algorithm that conceptually executes generic steps.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 12px;"&gt;From template, the idea of creating an algorithm that executes several steps to achieve a task.&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: x-small; line-height: 18px;"&gt;From the command, The idea of building general components that need to delegate, sequence or execute method calls at a time of their choosing without the need to know the owner of the method or the method parameters.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: x-small; line-height: 18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-MDgwVWzIPsI/Tf-r4UeCQNI/AAAAAAAABE4/mCl4A6XXnE8/s1600/Template_Pattern_With_Command.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="242" src="http://3.bp.blogspot.com/-MDgwVWzIPsI/Tf-r4UeCQNI/AAAAAAAABE4/mCl4A6XXnE8/s640/Template_Pattern_With_Command.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: x-small; line-height: 18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: x-small; line-height: 18px;"&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 12px; line-height: 18px;"&gt;With use of an &lt;b&gt;IoC framework&lt;/b&gt;, the instance variable&amp;nbsp;&lt;b&gt;List &lt;command&gt;&lt;/command&gt; steps&lt;/b&gt;&amp;nbsp;can be injected with specific implementations.&lt;/span&gt;&lt;br /&gt;&lt;div align="JUSTIFY" class="western" style="font-style: normal; line-height: 0.5cm; margin-bottom: 0.21cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;The next two sequence diagrams show the interactions between all the components.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;In the first, the template is injected with the following instances of&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 12px;"&gt;ConcreteCommand2&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 12px;"&gt;ConcreteCommand4&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 12px;"&gt;ConcreteCommand5&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-weight: normal; line-height: 0.5cm; margin-bottom: 0.21cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-xnzJFjJE1YU/Tf5pAW2t2mI/AAAAAAAABEs/Bzxk92yh-Yc/s1600/Template_Pattern_With_Command3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="154" src="http://1.bp.blogspot.com/-xnzJFjJE1YU/Tf5pAW2t2mI/AAAAAAAABEs/Bzxk92yh-Yc/s640/Template_Pattern_With_Command3.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div align="JUSTIFY" class="western" style="font-style: normal; font-weight: normal; line-height: 0.5cm; margin-bottom: 0.21cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;br /&gt;&lt;div align="JUSTIFY" class="western" style="font-style: normal; line-height: 0.5cm; margin-bottom: 0.21cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; widows: 2;"&gt;&lt;div style="font-family: 'Times New Roman'; font-size: medium; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;In the second, the template is injected with the following instances of&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: 'Times New Roman'; font-size: medium; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li style="font-family: 'Times New Roman'; font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 12px;"&gt;ConcreteCommand1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-family: 'Times New Roman'; font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 12px;"&gt;ConcreteCommand3&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-family: 'Times New Roman'; font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 12px;"&gt;ConcreteCommand5 &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 12px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-SKI87EGgNbc/Tf-pbvOZJBI/AAAAAAAABE0/nndIscLKhVg/s1600/Template_Pattern_With_Command2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="156" src="http://2.bp.blogspot.com/-SKI87EGgNbc/Tf-pbvOZJBI/AAAAAAAABE0/nndIscLKhVg/s640/Template_Pattern_With_Command2.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="font-family: 'Times New Roman'; font-size: medium; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: 'Times New Roman'; font-size: medium; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div style="font-family: 'Times New Roman'; font-size: medium;"&gt;&lt;/div&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/8148007777591375750-8109773221225594918?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/8109773221225594918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2011/06/template-method-and-command-pattern.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/8109773221225594918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/8109773221225594918'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2011/06/template-method-and-command-pattern.html' title='Template method and Command pattern, a good combination to create generic algorithms'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-ZD4cc6Amd_I/Tf5lGqeSvoI/AAAAAAAABEc/1FF-2gfI_jQ/s72-c/Template_Pattern.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-5992471227623943046</id><published>2010-03-29T18:01:00.003+01:00</published><updated>2010-03-29T18:02:04.946+01:00</updated><title type='text'>Java EE 5 Annotations and Resource Injection in some container managed components</title><content type='html'>&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;o:p&gt;The Annotations that are required by a Java EE technology compliant web container:&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 480;"&gt;&lt;tbody&gt;&lt;tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;"&gt;   &lt;td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;Annotations&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 1;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;@DeclareRoles   (*)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 2;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;@RunAs   (*)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 3;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;@EJB&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 4;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;@EJBs&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 5;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;@Resource&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 6;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;@Resources&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 7;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;@PersistenceContext&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 8;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;@PersistenceContexts&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 9;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;@PersistenceUnit&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 10;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;@PersistenceUnits&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 11;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;@PostConstruct&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 12;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;@PreDestroy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 13;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;@WebServiceRef&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 14; mso-yfti-lastrow: yes;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 221.4pt;" valign="top" width="295"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;@WebServiceRefs&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;Annotations must be supported on the following container managed classes that implement the following interfaces: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; margin-left: -65.25pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-table-layout-alt: fixed; mso-yfti-tbllook: 480;"&gt;&lt;tbody&gt;&lt;tr style="height: 27.15pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;"&gt;   &lt;td style="border: solid windowtext 1.0pt; height: 27.15pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 68.55pt;" valign="top" width="91"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Component   Type&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-left: none; border: solid windowtext 1.0pt; height: 27.15pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 242.85pt;" valign="top" width="324"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Component   Type Classes implementing the following interfaces&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-left: none; border: solid windowtext 1.0pt; height: 27.15pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 137.25pt;" valign="top" width="183"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Notes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="height: 17.35pt; mso-yfti-irow: 1;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; height: 17.35pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 68.55pt;" valign="top" width="91"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Servlets&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 17.35pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 242.85pt;" valign="top" width="324"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;javax.servlet.Servlet&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td rowspan="3" style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 17.35pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 137.25pt;" valign="top" width="183"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Java   Servlet Specification version 2.5&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;References   must be injected prior to any lifecycle methods being called and the   component instance being made available the application.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="height: 18.1pt; mso-yfti-irow: 2;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; height: 18.1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 68.55pt;" valign="top" width="91"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Filters&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 18.1pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 242.85pt;" valign="top" width="324"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;javax.servlet.Filter&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="height: 64.95pt; mso-yfti-irow: 3;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; height: 64.95pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 68.55pt;" valign="top" width="91"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Listeners&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 64.95pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 242.85pt;" valign="top" width="324"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;javax.servlet.ServletContextAttributeListener&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;javax.servlet.ServletRequestListener&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;javax.servlet.ServletRequestAttributeListener&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;javax.servlet.http.HttpSessionListener&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;javax.servlet.http.HttpSessionAttributeListener&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;javax.servlet.AsyncListener&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="height: 64.95pt; mso-yfti-irow: 4; mso-yfti-lastrow: yes;"&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; height: 64.95pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 68.55pt;" valign="top" width="91"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;ManagedBean&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td colspan="2" style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 64.95pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 380.1pt;" valign="top" width="507"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;JavaServer   Faces Specification v 2.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Only   beans declared to be in request, session, or application scope are eligible   for &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;resource injection&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Methods   on managed beans declared to be in request, view, session, or application   scope, annotated with &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;@PostConstruct&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;,   must be called by the JSF implementation after resource injection is   performed (if any) but before the bean is placed into scope.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Methods   on managed beans declared to be in request, session, or application scope,   annotated with &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;@PreDestroy&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;, must be called by   the JSF implementation before the bean is removed from its scope or before   the scope itself is destroyed, whichever comes first. In the case of a   managed bean placed in view scope, methods annotated with @PreDestroy must   only be called when the view scope is destroyed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;(*) Annotations not allowed in Managed Bean&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&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/8148007777591375750-5992471227623943046?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/5992471227623943046/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2010/03/annotations-that-are-required-by-java.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/5992471227623943046'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/5992471227623943046'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2010/03/annotations-that-are-required-by-java.html' title='Java EE 5 Annotations and Resource Injection in some container managed components'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-9142887022443639221</id><published>2010-03-18T17:51:00.000Z</published><updated>2010-03-18T17:51:24.487Z</updated><title type='text'>OO concepts: Adapter pattern</title><content type='html'>&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Introduction&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;In this post I sum up the Adapter pattern, an interesting OO pattern very useful in many situations. From my point of view, in the most enterprise situations where I needed to integrate with external systems, the idea of using adapter pattern provided to the systems a transparent way to communicate with other interfaces.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;It is relevant to mention that this pattern is very important to build the &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;ANTICORRUPTION LAYER&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; in &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;Domain Driven Design&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Description&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Convert the interface of a class into another interface clients expect. Adapter lets classes work together that could not otherwise because of incompatibles interfaces.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Scenario&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The figure shows a design of a Web search engine that queries the databases of multiple libraries.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Libray1SearchEngine&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt; and &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;Libray2SearchEngine&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;classes&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; have already implemented. These two classes implement &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;Searchable&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;interface&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; so that the &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;SearchInvoker&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;class&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; can call them interchangeably.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Let assume that a search implementation for a third library is wanted. Most of the code is already written in the &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;Libray3SearchEngine&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;class&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;This class is used in a previously developed client-server application. Unfortunately, Libray3SearchEngine does not have all the needed functionality and has a different interface than the other search engine classes. The library plans to continue using the previously developed client-server application, so if you modified Libray3SearchEngine, you would have to maintain two versions of the class. You don’t want to complicate SearchInvoker by making it deal with the different interfaces, so you need a way to adapt Libray3SearchEngine to the Searchable interface.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_0QFX4__VHgo/S6JnaAkkRmI/AAAAAAAAAf8/vXVEXD8EHUw/s1600-h/Adapter+-+Scenario.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="164" src="http://1.bp.blogspot.com/_0QFX4__VHgo/S6JnaAkkRmI/AAAAAAAAAf8/vXVEXD8EHUw/s640/Adapter+-+Scenario.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Solution&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The Adapter pattern recommends creating a new &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;Adapter class&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; that implements the &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;DesiredInterface&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; and propagates requests to the existing &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;Adaptee&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;class&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. The Client class calls methods on Adapter, not on Adaptee. If the DesiredInterface requires some functionality that is not supported by Adaptee, Adapter can implement that functionality directly.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Object Adapter Strategy Structure&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_0QFX4__VHgo/S6JniHXDkwI/AAAAAAAAAgE/WEXt1I-X5hU/s1600-h/adapter_solution_1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="261" src="http://4.bp.blogspot.com/_0QFX4__VHgo/S6JniHXDkwI/AAAAAAAAAgE/WEXt1I-X5hU/s400/adapter_solution_1.JPG" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Class Adapter Strategy Structure&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_0QFX4__VHgo/S6JnnFK5lkI/AAAAAAAAAgM/nzDDQ0qVzrw/s1600-h/adapter_solution_2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="261" src="http://2.bp.blogspot.com/_0QFX4__VHgo/S6JnnFK5lkI/AAAAAAAAAgM/nzDDQ0qVzrw/s400/adapter_solution_2.JPG" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Solution in this scenario&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_0QFX4__VHgo/S6Jnwo3ByAI/AAAAAAAAAgU/HY7zpASy3IM/s1600-h/Adapter+-+Scenario_Solution.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="356" src="http://4.bp.blogspot.com/_0QFX4__VHgo/S6Jnwo3ByAI/AAAAAAAAAgU/HY7zpASy3IM/s640/Adapter+-+Scenario_Solution.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Consequences&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The advantages of using the Adapter pattern are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l2 level1 lfo1; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The client class is not complicated by having to use a different interface and can use polymorphism to swap between different implementations of DesiredInterface.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l2 level1 lfo1; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The adaptee class is not modified.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The disadvantages of using the Object Adapter strategy are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;There are two objects involved, so you must create an additional object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo2; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;All requests are forwarded, so there is a slight increase in the overhead.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The disadvantages of using the Class Adapter strategy are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo3; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The interface of the adapter class also supports the interface of the adaptee class, so the client is coupled to the adaptee class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo3; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;In Java programming language, the single subclassing slot for a class is used up in adaptation. Therefore, you must use interfaces to support other features.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;References&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Gamma, Helm, Johnson, and Vlissides 2004. &lt;i style="mso-bidi-font-style: normal;"&gt;Design Patterns. Elements of Reusable Object-Oriented Software. &lt;/i&gt;Addison-Wesley.&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&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/8148007777591375750-9142887022443639221?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/9142887022443639221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2010/03/oo-concepts-adapter-pattern.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/9142887022443639221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/9142887022443639221'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2010/03/oo-concepts-adapter-pattern.html' title='OO concepts: Adapter pattern'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_0QFX4__VHgo/S6JnaAkkRmI/AAAAAAAAAf8/vXVEXD8EHUw/s72-c/Adapter+-+Scenario.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-2168623055205936277</id><published>2010-02-10T17:55:00.001Z</published><updated>2010-02-10T18:01:41.723Z</updated><title type='text'>OO concepts: Observer pattern</title><content type='html'>&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Introduction&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;In this post I sum up the Observer pattern, an interesting OO pattern very useful in many situations.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Description&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The Observer pattern describes how to establish these relationships. The key objects in this pattern are &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;subject&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; and &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;observer&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. A subject may have any number of dependent observers. All observers are notified whenever the subject undergoes a change in state. In response, each observer will query the subject to synchronize its state with the subject’s state.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;This kind of interaction is also known as &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;publish-subscribe&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. The subject is the publisher of notifications. It sends out these notifications without having to know who its observers are. Any number of observers can subscribe to receive notifications.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px; line-height: 13px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: medium; line-height: normal;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 13px;"&gt;Basic Pattern&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px; line-height: 13px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: medium; line-height: normal;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_0QFX4__VHgo/S3LyoIvku7I/AAAAAAAAAeE/aO06FAftovk/s1600-h/observer_pattern.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="203" src="http://1.bp.blogspot.com/_0QFX4__VHgo/S3LyoIvku7I/AAAAAAAAAeE/aO06FAftovk/s640/observer_pattern.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px; line-height: 13px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: medium; line-height: normal;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px; line-height: 13px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: medium; line-height: normal;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px; line-height: 13px;"&gt;&lt;b&gt;Complex Pattern&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px; line-height: 13px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_0QFX4__VHgo/S3LysSawYzI/AAAAAAAAAeM/ehGUkzw-00w/s1600-h/observer_pattern_advanced.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="344" src="http://2.bp.blogspot.com/_0QFX4__VHgo/S3LysSawYzI/AAAAAAAAAeM/ehGUkzw-00w/s640/observer_pattern_advanced.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px; line-height: 13px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px; line-height: 13px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Consequences&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The advantages are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;You can vary and independently reuse classes for the Subject and Observer objects.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The abstract classes (or interfaces) are coupled together. Therefore, the coupling is looser than if the concrete classes were coupled.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;You can easily add Observer objects without a single change to the Subject object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The disadvantages are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;An observer system can become flooded with updates if the granularity of the update is too fine or its frequency too high. This is a critical problem in distributed systems.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The observer system often calls the subject when it receives a notification. This can create a bottleneck, preventing the timely update of the other observer systems.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;References&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Gamma, Helm, Johnson, and Vlissides. &lt;i style="mso-bidi-font-style: normal;"&gt;Design Patterns. Elements of Reusable Object-Oriented Software. &lt;/i&gt;Addison-Wesley.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&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/8148007777591375750-2168623055205936277?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/2168623055205936277/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2010/02/oo-concepts-observer-pattern.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/2168623055205936277'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/2168623055205936277'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2010/02/oo-concepts-observer-pattern.html' title='OO concepts: Observer pattern'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_0QFX4__VHgo/S3LyoIvku7I/AAAAAAAAAeE/aO06FAftovk/s72-c/observer_pattern.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-1611895853835211142</id><published>2010-02-02T14:32:00.003Z</published><updated>2010-02-02T15:20:09.332Z</updated><title type='text'>Beyond Technologies: Domain Driven Design - Anticorruption layer</title><content type='html'>&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Introduction&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;In this post I sum up the most important concepts about Domain Driven Design.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;I recommend you when you read this post not to think in technologies. Put away the technical knowledge and think from an upper level, from an architectural level.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Scenario&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;On a large project, one subsystem will often have to interface with several other, independently developed subsystems. These will reflect the problem domain differently. When systems based on different models are combined, the need for the system to adapt to the semantics of the other system can lead to a &lt;b&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;corruption &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;of the new system’s own model. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;We should create an isolating layer, &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;ANTOCORRUPTION LAYER&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;, to provide clients with functionality in terms of their own domain model. The layer talks to other system through its existing interface, requiring little or no modification to other system. Internally, the layer translates in both directions as necessary between the two models.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Note: ANTOCORRUPTION LAYER is not a mechanism for sending messages to another system, is a means of linking two BOUNDED CONTEXTS. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Designing the interface &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The public interface of the ANTICORRUPTION LAYER usually appears as a set of &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;SERVICES&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. Building a whole new layer responsible for the translation between the semantics of the two systems gives us an opportunity to reabstract the other system’s behavior and offer its services and information to our system consistently with our model. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Implementation &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The ANTICORRUPTION LAYER is a combination of FAÇADES, ADAPTERS and translator, along with the communication and transport mechanisms needed to talk between systems.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;A &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;FAÇADE&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; is an interface for a subsystem that simplifies access for the client and makes the subsystem easier to use. It should be written strictly in accordance with the other system’s model. The FAÇADE belongs in the BOUNDED CONTEXT of the other system. It just presents a friendlier face specialized for your needs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;An &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;ADAPTER&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; is a wrapper that allows a client to use a different protocol than that understood by the implementer of the behavior. When a client sends a message to an ADAPTER, it is converted to a semantically equivalent message and sent on to the “adaptee”. The response is converted and passed back. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;For each &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;SERVICE&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; we define, we need an ADAPTER that supports the SERVICE’s interface and knows how to make equivalent requests of the other system or its FAÇADE.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The remaining element is the &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;translator&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. The ADAPTER’s job is to know how to make a request. The actual conversion of conceptual objects or data is a distinct, complex task that can be placed in its own object, making them both much easier to understand. A translator can be a lightweight object that is instantiated when needed. It needs no state and does not need to be distributed, because it belongs with the ADAPTER it serves.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_0QFX4__VHgo/S2g3MpCLYmI/AAAAAAAAAdk/XhktIPnB4Ic/s1600-h/Anticorruption_Layer.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="185" src="http://4.bp.blogspot.com/_0QFX4__VHgo/S2g3MpCLYmI/AAAAAAAAAdk/XhktIPnB4Ic/s640/Anticorruption_Layer.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;References&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Eric Evans 2004. &lt;i style="mso-bidi-font-style: normal;"&gt;Domain Driven Design. Tackling Complexity in the Heart of Software. &lt;/i&gt;Addison-Wesley.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&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/8148007777591375750-1611895853835211142?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/1611895853835211142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2010/02/beyond-technologies-domain-driven.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/1611895853835211142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/1611895853835211142'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2010/02/beyond-technologies-domain-driven.html' title='Beyond Technologies: Domain Driven Design - Anticorruption layer'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_0QFX4__VHgo/S2g3MpCLYmI/AAAAAAAAAdk/XhktIPnB4Ic/s72-c/Anticorruption_Layer.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-1613065136826724777</id><published>2010-01-15T17:23:00.020Z</published><updated>2010-01-15T17:31:29.379Z</updated><title type='text'>Beyond Technologies: Domain Driven Design - Factories and Repositories</title><content type='html'>&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Introduction&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;In this post I sum up the most important concepts about Domain Driven Design.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;I recommend you when you read this post not to think in technologies. Put away the technical knowledge and think from an upper level, from an architectural level.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 12px; line-height: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Encapsulating with FACTORIES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;A FACTORY encapsulates the knowledge needed to &lt;span style="color: red;"&gt;&lt;b&gt;&lt;i&gt;create a complex object or AGGREGATE&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;, which may itself have no responsibility in the domain model but is still part of the domain design. Provide an interface that encapsulates all complex assembly and that does not require the client to reference the concrete class of the objects being instantiated.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;There are some PATTERNS to design FACTORIES &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify; text-indent: 35.4pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;1. FACTORY METHOD&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify; text-indent: 35.4pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;2. ABSTRACT FACTORY&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify; text-indent: 35.4pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;3. BUILDER&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Requirements for a FACTORY are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Each creation method is &lt;span style="color: red;"&gt;&lt;b&gt;&lt;i&gt;atomic&lt;/i&gt;&lt;/b&gt;&lt;/span&gt; and enforces &lt;span style="color: red;"&gt;&lt;b&gt;&lt;i&gt;all invariants&lt;/i&gt;&lt;/b&gt;&lt;/span&gt; of the created object or AGGREGATE. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;A FACTORY should only be able to produce an object in a &lt;span style="color: red;"&gt;&lt;b&gt;&lt;i&gt;consistent state&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;For an ENTITY, this means the creation of the entire AGGREGATE, with all the invariants satisfied, but probably with optional elements still to be added. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;For an &lt;span style="color: red;"&gt;&lt;b&gt;&lt;i&gt;immutable VALUE OBJECT&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;, this means that all attributes are initialized to their correct final state. If the interface makes it possible to request an object that can not be created correctly, then an exception should be raised or some other mechanism should be invoked that will ensure that no improper return value is possible.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 9pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The FACTORY should be &lt;span style="color: red;"&gt;&lt;i&gt;&lt;b&gt;abstracted &lt;/b&gt;&lt;/i&gt;&lt;/span&gt;to the &lt;span style="color: red;"&gt;&lt;b&gt;&lt;i&gt;type&lt;/i&gt;&lt;/b&gt;&lt;/span&gt; desired, rather than the concrete classes created.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 12px; line-height: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Accessing with REPOSITORIES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;&lt;span style="color: red;"&gt;&lt;b&gt;&lt;i&gt;The goal of domain-driven design is to create better software by focusing on a model of the domain rather than the technology.&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;A REPOSITORY represents &lt;span style="color: red;"&gt;&lt;b&gt;&lt;i&gt;all objects of a certain type as a conceptual set&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;. It acts like a collection, except with more elaborate querying capability. Objects of the appropriate type are added and removed, and the machinery behind the REPOSITORY inserts them or deletes them from the database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Clients request objects from the REPOSITORY using query methods that select objects based on criteria specified by the client, typically the value of certain attributes. The REPOSITORY retrieves the requested object, encapsulating the machinery of database queries and metadata mapping. Repositories can implement a variety of queries that select objects based on whatever criteria the client requires. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 12px; line-height: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_0QFX4__VHgo/S1CkUFh984I/AAAAAAAAAbw/DVY9TZvhFSU/s1600-h/repositories-generic.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_0QFX4__VHgo/S1CkUFh984I/AAAAAAAAAbw/DVY9TZvhFSU/s640/repositories-generic.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 12px; line-height: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;A REPOSITORY lifts a huge burden from the client, which can now talk to a simple, intention-revealing &lt;span style="color: red;"&gt;&lt;b&gt;&lt;i&gt;interface&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;, and ask for what it needs in terms of the model. To support all this requires a lot of complex technical infrastructure, but the interface is simple and conceptually &lt;span style="color: red;"&gt;&lt;b&gt;&lt;i&gt;connected to the domain model&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;For each type of object that needs global access, create an object that can provide the illusion of an in-memory collection of all objects of that type. Set up access through a well-known global interface. Provide methods to add and remove objects, which will encapsulate the actual insertion or removal of data in the data store. Provide methods that select objects based on some criteria and return fully instantiated objects or collections of objects whose attribute values meet the criteria, thereby encapsulating the actual storage and query technology. Provide &lt;span style="color: red;"&gt;&lt;i&gt;&lt;b&gt;REPOSITORIES only for AGGREGATE roots&lt;/b&gt;&lt;/i&gt;&lt;/span&gt; that actually need direct access. Keep the client focused on the model, delegating all object storage and access to the REPOSITORIES.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 12px; line-height: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;REPOSITORIES have many advantages, including the following:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Symbol; font-size: 9pt; line-height: 115%;"&gt;·&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Symbol; font-size: 9pt; line-height: 115%;"&gt;&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style="font-family: 'Courier New'; font-size: 12px; line-height: 13px;"&gt;1.&amp;nbsp;They present clients with a simple model for obtaining persistent objects and managing their life cycle.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="margin-left: 0cm; mso-add-space: auto; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;2. They decouple application and domain design from persistence technology, multiple database strategies, or even multiple data sources.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="margin-left: 0cm; mso-add-space: auto; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;3. The communicate design decisions about object access.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpLast" style="margin-left: 0cm; mso-add-space: auto; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;4. They allow easy substitution of a dummy implementation, for use in testing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 12px; line-height: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;The REPOSITORY will &lt;span style="color: red;"&gt;&lt;i&gt;&lt;b&gt;delegate to the appropriate infrastructure&lt;/b&gt;&lt;/i&gt;&lt;/span&gt; services to get the job done.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Note: Leave the transaction control to the client who presumably has the context to correctly initiate and commit units of work. Transaction management will be simpler if the REPOSITORY keeps its hands off.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 12px; line-height: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_0QFX4__VHgo/S1CkZpYsxhI/AAAAAAAAAb4/RUkowRxo49k/s1600-h/repositories.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_0QFX4__VHgo/S1CkZpYsxhI/AAAAAAAAAb4/RUkowRxo49k/s640/repositories.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 12px; line-height: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 12px; line-height: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;References&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"&gt;Eric Evans 2004. &lt;i style="mso-bidi-font-style: normal;"&gt;Domain Driven Design. Tackling Complexity in the Heart of Software. &lt;/i&gt;Addison-Wesley.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8148007777591375750-1613065136826724777?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/1613065136826724777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2010/01/introduction-in-this-post-i-sum-up-most.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/1613065136826724777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/1613065136826724777'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2010/01/introduction-in-this-post-i-sum-up-most.html' title='Beyond Technologies: Domain Driven Design - Factories and Repositories'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_0QFX4__VHgo/S1CkUFh984I/AAAAAAAAAbw/DVY9TZvhFSU/s72-c/repositories-generic.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-189979639784709672</id><published>2010-01-06T16:17:00.012Z</published><updated>2010-01-06T16:33:49.373Z</updated><title type='text'>Beyond Technologies: Domain Driven Design - ENTITIES, VALUE OBJECTS, DOMAIN SERVICES AND AGGREGATES</title><content type='html'>&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 11px; font-weight: bold; line-height: 12px;"&gt;Introduction&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;In this post I sum up concepts about Domain Driven Design:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l3 level1 lfo3; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 8pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;Entities&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l3 level1 lfo3; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 8pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;Value Objects&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l3 level1 lfo3; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 8pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;Domain Services&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l3 level1 lfo3; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 8pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;Aggregates&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;I recommend you when you read this post not to think in technologies. Put away the technical knowledge and think from an upper level, from an architectural level.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-outline-level: 1; text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;ENTITY&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;An object defined primarily by its &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;identity&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; and not by their attributes. ENTITIES have life cycles that can change their form and content, but a thread of continuity must be maintained. Their class definitions, responsibilities, attributes, and associations should resolve around who they are, rather than the particular attributes they carry.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-outline-level: 1; text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;VALUE OBJECT &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;An object that represents a &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;descriptive aspect&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; of the domain with no conceptual identity and we care about only for what they are, not who or which they are.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;VALUE OBJECTS are often passed as parameters in messages between objects. They are frequently transient, created for an operation and then discarded.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;VALUE OBJECTS are used as attributes of ENTITTIES (and other VALUES).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-outline-level: 1; text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;DOMAIN SERVICES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;There are important &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;domain operations&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; that can not find a natural home in an ENTITY or VALUE OBJECT. Some of these are intrinsically activities or actions, not things. Forcing the required domain functionality to be responsibility of ENTITY or VALUE either distorts the definition of a model-based object or adds meaningless artificial objects.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;The name service emphasizes the relationship with other objects. Unlike ENTITIES and VALUE OBJECTS, it is defined purely in terms of what it can do for a client. A SERVICE tends to be named for an activity. A SERVICE should still have defined responsibility, and that responsibility and the interface fulfilling it should be defined as part of the domain model. Operations should come from the &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;UBIQUITOUS LANGUAGE&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; or be introduced into it. Parameters and results should be domain objects.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;A DOMAIN SERVICE has three characteristics:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;1.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; 1.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;The operation relates to a domain concept that is not a natural part of an ENTITY or VALUE OBJECT.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;2.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; 2.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;The interface is defined in terms of other elements of the domain model.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpLast" style="mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;3.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; 3.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;The operation is stateless.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-outline-level: 1; text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;SERVICES IN LAYERS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;Application services&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;: &lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;are the interface used by the outside world. These services could map outside messages to internal operations and processes, communicating with services in the Domain and Infrastructure layers to provide cohesive operations for outside clients.&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;Domain services: &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;Embeds business rules. These use the infrastructure services to do their tasks.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;Infrastructure services: &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;communication with external resources like databases, file systems, web service end points, etc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-outline-level: 1; text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;AGGREGATES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;An AGGREGATE is a set of associated objects that we treat as a unit for the purpose of data changes. Each AGGREGATE has a root and a boundary. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l2 level1 lfo2; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 8pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;The &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;boundary&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; defines what is inside the AGGREATE. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l2 level1 lfo2; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 8pt; line-height: 115%;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;The &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;root&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; is a single, specific ENTITY contained in the AGGREATE. The root is the only member that outside objects are allowed to hold references to, although objects within the boundary may hold references to each other. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 11px; line-height: 12px;"&gt;It is difficult to guarantee the consistency of changes to objects in a model with complex associations. &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;Invariants&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; are consistency rules that must be maintained whenever data changes and will involve relationships between members of the AGGREGATE. The invariants applied within an AGGREAGATE will be enforced with the completion of each transaction.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px; line-height: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;&lt;span style="color: red;"&gt;&lt;b&gt;&lt;i&gt;Rules for implementing AGGREGATES:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;1.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;The root ENTITY has global identity and is ultimately responsible for checking invariants. ENTITIES other than root inside the boundary have local identity, unique only within the AGGREGATE, because no outside object can ever see it out of the context of the root ENTITY.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="margin-left: 18.0pt; mso-add-space: auto; text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo4; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;2.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; 2.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;Nothing outside the AGGREGATE boundary can hold a reference to anything inside, except to the root ENTITY. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="margin-left: 18.0pt; mso-add-space: auto; text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo4; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;3.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; 3.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;The root ENTITY can hand references to internal ENTITIES to other objects, but those objects can use them only transiently, and they may not hold on to the reference. The root may hand a copy of a VALUE OBJECT to another object, and it does not matter what happens to it, because it is a VALUE and no longer will have any association with the AGGREGATE.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="margin-left: 18.0pt; mso-add-space: auto; text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo4; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;4.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; 4.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;Only AGGREGATE roots can be obtained directly with database queries. All other objects must be found by traversal of associations.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="margin-left: 18.0pt; mso-add-space: auto; text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo4; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;5.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; 5.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;Objects within the AGGREGATE can hold references to other AGGREGATE roots.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="margin-left: 18.0pt; mso-add-space: auto; text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo4; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;6.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; 6.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;A delete operation must remove everything within the AGGREGATE boundary at once.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="margin-left: 18.0pt; mso-add-space: auto; text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo4; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;7.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; 7.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;When a change to any object within the AGGREGATE boundary is committed, all invariants&lt;i style="mso-bidi-font-style: normal;"&gt; of the whole AGGREGATE must be satisfied. &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpLast" style="margin-left: 0cm; mso-add-space: auto; text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px; line-height: 12px;"&gt;&lt;b&gt;Example - Bank Customer&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px; line-height: 12px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_0QFX4__VHgo/S0S7Bi4n5RI/AAAAAAAAAaw/LYuZ4MmB8R8/s1600-h/aggregate+diagram.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_0QFX4__VHgo/S0S7Bi4n5RI/AAAAAAAAAaw/LYuZ4MmB8R8/s640/aggregate+diagram.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px; line-height: 12px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px; line-height: 12px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-outline-level: 1; text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;References&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;Eric Evans 2004. &lt;i style="mso-bidi-font-style: normal;"&gt;Domain Driven Design. Tackling Complexity in the Heart of Software. &lt;/i&gt;Addison-Wesley.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="ListParagraphCxSpFirst" style="margin-left: 0cm; mso-add-space: auto; text-align: justify;"&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="font-family: 'Times New Roman';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;b&gt; &lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8148007777591375750-189979639784709672?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/189979639784709672/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2010/01/beyond-technologies-domain-driven.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/189979639784709672'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/189979639784709672'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2010/01/beyond-technologies-domain-driven.html' title='Beyond Technologies: Domain Driven Design - ENTITIES, VALUE OBJECTS, DOMAIN SERVICES AND AGGREGATES'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_0QFX4__VHgo/S0S7Bi4n5RI/AAAAAAAAAaw/LYuZ4MmB8R8/s72-c/aggregate+diagram.JPG' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-6356410114263802541</id><published>2009-12-29T14:13:00.048Z</published><updated>2010-01-06T11:40:21.219Z</updated><title type='text'>Beyond Technologies: Domain Driven Design - Layered architecture</title><content type='html'>&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 13px; font-weight: bold;"&gt;1. Introduction&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;u1:p&gt;&lt;/u1:p&gt;&lt;span style="font-family: 'Courier New'; font-size: 13px;"&gt;In this post I sum up the most important concepts about Domain Driven Design.&lt;/span&gt;&lt;br /&gt;&lt;u1:p&gt;&lt;/u1:p&gt;&lt;span style="font-family: 'Courier New'; font-size: 13px;"&gt;I recommend you when you read this post not to think in technologies. Put away the technical knowledge and think from an upper level, from an architectural level.&lt;/span&gt;&lt;br /&gt;&lt;u1:p&gt;&lt;/u1:p&gt;  &lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: 13px; font-weight: bold;"&gt;2. Domain Driven Design elements&lt;/span&gt;&lt;br /&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;In future posts I will show my understanding about the following concepts:&lt;br style="mso-special-character: line-break;" /&gt; &lt;br style="mso-special-character: line-break;" /&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul style="margin-top: 0cm;" type="square"&gt;&lt;li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;Layered      Architecture&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;Services&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;Entities&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;Value      Objects&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;Aggregates&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;Repositories&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;Factories&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_0QFX4__VHgo/SzoU2ntGMxI/AAAAAAAAAR8/wFMVrnSjSIQ/s1600-h/Navigation+map.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_0QFX4__VHgo/SzoU2ntGMxI/AAAAAAAAAR8/wFMVrnSjSIQ/s640/Navigation+map.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 18.0pt; text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;/span&gt;3. Isolating the domain with a Layered architecture&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;u1:p&gt;&lt;/u1:p&gt;  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;The design and implementation of business logic constitute the&amp;nbsp;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;domain layer&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;. Isolating the domain implementation is a prerequisite for domain-driven design.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_0QFX4__VHgo/SzoU7dtKlUI/AAAAAAAAASE/CgNzPQWYteo/s1600-h/Layered+Architecture.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_0QFX4__VHgo/SzoU7dtKlUI/AAAAAAAAASE/CgNzPQWYteo/s640/Layered+Architecture.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;User interface&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;u1:p&gt;&lt;/u1:p&gt;  &lt;br /&gt;&lt;ul style="margin-top: 0cm;" type="square"&gt;&lt;li class="MsoNormal" style="color: black; mso-list: l3 level1 lfo2; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 10pt;"&gt;It&amp;nbsp;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;show&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span lang="EN-GB" style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;s&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;information to the user&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;u1:p&gt;&lt;/u1:p&gt;&lt;li class="MsoNormal" style="color: black; mso-list: l3 level1 lfo2; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 10pt;"&gt;It&lt;/span&gt;&lt;i&gt;&lt;span lang="EN-GB" style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;interpret&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span lang="EN-GB" style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;s&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;the user´s commands&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;u1:p&gt;&lt;/u1:p&gt;  &lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: 13px;"&gt;Application Layer&lt;/span&gt;&lt;br /&gt;&lt;u1:p&gt;&lt;/u1:p&gt;  &lt;br /&gt;&lt;ul style="margin-top: 0cm;" type="square"&gt;&lt;li class="MsoNormal" style="color: black; mso-list: l2 level1 lfo3; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 10pt;"&gt;It&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;defines the jobs the software is      supposed to do&lt;u1:p&gt;&lt;/u1:p&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: black; mso-list: l2 level1 lfo3; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;The      tasks are meaningful to the business or necessary for interaction with the      application layers of other systems.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;u1:p&gt;&lt;/u1:p&gt;&lt;li class="MsoNormal" style="color: black; mso-list: l2 level1 lfo3; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;This      layer is&amp;nbsp;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;thi&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span lang="EN-GB" style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;n&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt;&lt;span lang="EN-GB" style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 10pt;"&gt;and&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;does&amp;nbsp;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;not contain business rules&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;or know&lt;/span&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 10pt;"&gt;l&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;edge&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;u1:p&gt;&lt;/u1:p&gt;&lt;li class="MsoNormal" style="color: black; mso-list: l2 level1 lfo3; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;It&amp;nbsp;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;coordinates tasks and delegates work&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;to collaborations of domain objects in the next      layer down.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;u1:p&gt;&lt;/u1:p&gt;  &lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: 13px;"&gt;Domain Layer or Model layer&lt;/span&gt;&lt;br /&gt;&lt;u1:p&gt;&lt;/u1:p&gt;  &lt;br /&gt;&lt;ul style="margin-top: 0cm;" type="square"&gt;&lt;li class="MsoNormal" style="color: black; mso-list: l1 level1 lfo4; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;It      represents&amp;nbsp;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;concepts of the business&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;and the&amp;nbsp;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;business rules&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;u1:p&gt;&lt;/u1:p&gt;&lt;li class="MsoNormal" style="color: black; mso-list: l1 level1 lfo4; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;The      state that reflects the business situation is controlled and used here&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;u1:p&gt;&lt;/u1:p&gt;&lt;li class="MsoNormal" style="color: black; mso-list: l1 level1 lfo4; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;This      layer is the&amp;nbsp;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;heart of the business software&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;u1:p&gt;&lt;/u1:p&gt;  &lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: 13px;"&gt;Infrastructure Layer&lt;/span&gt;&lt;br /&gt;&lt;u1:p&gt;&lt;/u1:p&gt;  &lt;br /&gt;&lt;ul style="margin-top: 0cm;" type="square"&gt;&lt;li class="MsoNormal" style="color: black; mso-list: l4 level1 lfo5; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;Provides&amp;nbsp;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;generic technical capabilities&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;that support the higher layers:&amp;nbsp;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;message sending&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;for the application,&amp;nbsp;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;persistence&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;for the domain, drawing      widgets for the UI, and so on.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;u1:p&gt;&lt;/u1:p&gt;&lt;li class="MsoNormal" style="color: black; mso-list: l4 level1 lfo5; tab-stops: list 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;This      infrastructure layer may also support the pattern of interactions between      the four layers through an architectural framework.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;u1:p&gt;&lt;/u1:p&gt;  &lt;br /&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;Martin Fowler&amp;nbsp;says:&amp;nbsp;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;“If the architecture isolates the domain-related code in a way that allows a cohesive domain design loosely coupled to the rest of the system, then that architecture can probably support domain-driven design”&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;div class="MsoNormal"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;br /&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;4. References&lt;/b&gt;&lt;/span&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;Eric Evans 2004.&amp;nbsp;&lt;i&gt;Domain Driven Design. Tackling Complexity in the Heart of Software.&amp;nbsp;&lt;/i&gt;Addison-Wesley.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&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/8148007777591375750-6356410114263802541?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/6356410114263802541/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2009/12/1.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/6356410114263802541'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/6356410114263802541'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2009/12/1.html' title='Beyond Technologies: Domain Driven Design - Layered architecture'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_0QFX4__VHgo/SzoU2ntGMxI/AAAAAAAAAR8/wFMVrnSjSIQ/s72-c/Navigation+map.JPG' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-3276213317044457639</id><published>2009-12-08T14:26:00.000Z</published><updated>2009-12-08T14:26:40.365Z</updated><title type='text'>Locking in JPA 2.0</title><content type='html'>&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;div class="MsoNormal" style="margin-left: 18.0pt; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt; text-align: justify; text-autospace: none; text-indent: -18.0pt;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style="mso-list: Ignore;"&gt;1.&lt;span style="font: 7.0pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;Introduction&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;The JPA specification 2.0 assumes that the databases to which persistence units are mapped will be accessed by the implementation using read-committed isolation (or a vendor equivalent in which long-term read locks are not held).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt; text-align: justify; text-autospace: none; text-indent: -36.0pt;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style="mso-list: Ignore;"&gt;2.&lt;span style="font: 7.0pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;Optimistic Locking&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;Optimistic locking is a technique that is used to insure that updates (merge operation) to the database data corresponding to the state of an entity are made only when no intervening transaction has updated that data since the entity state was read. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;Version Attributes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;The Version field or property is used by the persistence provider to perform optimistic locking. &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;An entity is automatically enabled for optimistic locking if it has a property or field mapped with a Version mapping&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #646464; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;@Entity&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #646464; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;@Table&lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;(name = &lt;/span&gt;&lt;span style="color: #2a00ff; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;"ITEMS"&lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;)&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;class&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt; Item &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;implements&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt; Serializable {&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #646464; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;@Id&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #646464; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;@Column&lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;(name = &lt;/span&gt;&lt;span style="color: #2a00ff; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;"ITEM_ID"&lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;)&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;private&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt; Long &lt;/span&gt;&lt;span style="color: #0000c0; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;itemId&lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;span style="color: #646464; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;@Column&lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;(name = &lt;/span&gt;&lt;span style="color: #2a00ff; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;"ITEM_NAME"&lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;)&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;private&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt; Long &lt;/span&gt;&lt;span style="color: #0000c0; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;itemName&lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #646464; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;@Version&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #646464; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;@Column&lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;(name = &lt;/span&gt;&lt;span style="color: #2a00ff; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;"OPT_LOCK"&lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;)&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;private&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt; Integer &lt;/span&gt;&lt;span style="color: #0000c0; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;version&lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;…&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;}&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;The persistence provider's implementation of the merge operation must examine the version attribute when an entity is being merged and throw an &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;OptimisticLockException&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; if it is discovered that the object being merged is a stale copy of the entity—i.e. that the entity has been updated since the entity became detached.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;The version attribute is updated by the persistence provider runtime when the object is written to the database.&lt;b style="mso-bidi-font-weight: normal;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt;UPDATE&lt;/span&gt;&lt;span style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt; ITEMS &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt;SET&lt;/span&gt;&lt;span style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt; ITEM_NAME &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt;=&lt;/span&gt;&lt;span style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt; &lt;/span&gt;&lt;span style="background: white; color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt;'Name test'&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt;,&lt;/span&gt;&lt;span style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt; OPT_LOCK &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt;=&lt;/span&gt;&lt;span style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt; &lt;/span&gt;&lt;span style="background: white; color: maroon; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt;2&lt;/span&gt;&lt;span style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt; &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt;WHERE&lt;/span&gt;&lt;span style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt; ITEM_ID &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt;=&lt;/span&gt;&lt;span style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt; &lt;/span&gt;&lt;span style="background: white; color: maroon; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt;700&lt;/span&gt;&lt;span style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt; &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt;AND&lt;/span&gt;&lt;span style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt; OPT_LOCK &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt;=&lt;/span&gt;&lt;span style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt; &lt;/span&gt;&lt;span style="background: white; color: maroon; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt; mso-highlight: white;"&gt;1&lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;Optimistic lock modes&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;If transaction calls &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;lock(entity, LockModeType.OPTIMISTIC)&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; on a versioned object, the entity manager must ensure that neither dirty read nor non-repeatable read occurs. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;If transaction calls &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;lock(entity, LockModeType.OPTIMISTIC_FORCE_INCREMENT)&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; on a versioned object, the entity manager must ensure that neither dirty read nor non-repeatable read occur and &lt;span class="apple-style-span"&gt;&lt;span style="color: black;"&gt;force an increment to the version at the end of the transaction, even if the entity is not modified.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;Note: LockModeType.OPTIMISTIC is synonymous with LockModeType.READ and LockModeType. OPTIMISTIC_FORCE_INCREMENT is synonymous with LockModeType.WRITE.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt; text-align: justify; text-autospace: none; text-indent: -36.0pt;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style="mso-list: Ignore;"&gt;3.&lt;span style="font: 7.0pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;Pessimistic Locking&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span class="apple-style-span"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;Pessimistic concurrency locks the database row when data is read and it ensures that transactions do not update the same entity at the same time, which can simplify application code, but it limits concurrent access to the data which can cause bad scalability and may cause deadlocks. Pessimistic locking is better for applications with a higher risk of contention among concurrent transactions.&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;Pessimistic locking guarantees that once a transaction has obtained a pessimistic lock (long-term database locks) on an entity instance:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;• &lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;No other transaction (whether a transaction of an application using the Java Persistence API or any other transaction using the underlying resource) may successfully modify or delete that instance until the transaction holding the lock has ended.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;• &lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;If the pessimistic lock is an exclusive lock (LockModeType.PESSIMISTIC_WRITE or LockModeType.PESSIMISTIC_FORCE_INCREMENT), that same transaction may modify or delete that entity instance.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;A persistence provider may use an underlying database platform's &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;SELECT FOR UPDATE&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; statements to implement pessimistic locking if that construct provides appropriate semantics, or the provider may use an isolation level of &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;repeatable read&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;Pessimistic lock modes&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;These lock modes are used to immediately obtain long-term database locks. Any locks must be obtained immediately and retained until transaction completes (commits or rolls back).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;If transaction calls &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;lock(entity, LockModeType.PESSIMISTIC_READ)&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; or &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;lock(entity, LockModeType.PESSIMISTIC_WRITE) &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;on an object, the entity manager must ensure that dirty read nor non-repeatable read occurs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;If transaction calls &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;lock(entity, LockModeType.PESSIMISTIC_FORCE_INCREMENT)&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; on a versioned object, the entity manager must ensure that dirty read nor non-repeatable read occurs and must also force an update (increment) to the entity's version column. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt; text-align: justify; text-autospace: none; text-indent: -36.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style="mso-list: Ignore;"&gt;4.&lt;span style="font: 7.0pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;API to use&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;There are multiple APIs to specify locking an Entity:&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-indent: -18.0pt;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style="mso-list: Ignore;"&gt;1.&lt;span style="font: 7.0pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;EntityManager methods: lock, find, refresh&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-bidi-font-size: 12.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-indent: -18.0pt;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style="mso-list: Ignore;"&gt;2.&lt;span style="font: 7.0pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;Query methods: setLockMode&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-indent: -18.0pt;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style="mso-list: Ignore;"&gt;3.&lt;span style="font: 7.0pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;NamedQuery annotation: lockMode element&lt;span class="apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8148007777591375750-3276213317044457639?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/3276213317044457639/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2009/12/locking-in-jpa-20.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/3276213317044457639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/3276213317044457639'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2009/12/locking-in-jpa-20.html' title='Locking in JPA 2.0'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-3638563428477047600</id><published>2009-11-26T14:34:00.002Z</published><updated>2009-11-26T15:38:57.088Z</updated><title type='text'>Transaction isolation levels, consenquences and configuration</title><content type='html'>&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;div class="NormalCourierNew" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style="mso-list: Ignore;"&gt;1.&lt;span style="font: 7.0pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;Introduction&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;o:p&gt;&amp;nbsp;In this post I sum up the different isolation levels and how we can configure them in JBoss AS depending on the type of datasource defined for our JEE application.&lt;/o:p&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style="mso-list: Ignore;"&gt;2.&lt;span style="font: 7.0pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;JDBC transaction isolation levels&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;o:p&gt;Transaction isolation levels specify what data is visible to statements within a transaction. These levels directly impact the level of concurrent access by defining what &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;interaction is possible between&lt;/span&gt;&lt;/i&gt; &lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;transactions against the same target data source&lt;/span&gt;&lt;/i&gt;.&lt;/b&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;READ UNCOMMITTED&lt;/b&gt;: allows a row changed by one transaction to be read by another transaction before any changes in that row have been committed (a "dirty read"). If any of the changes are rolled back, the second transaction will have retrieved an invalid row.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;READ COMMITTED&lt;/b&gt;: prohibits a transaction from reading a row with uncommitted changes in it. This is the default level for most of databases.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;REPEATABLE READ&lt;/b&gt;: prohibits a transaction from reading a row with uncommitted changes in it, and it also prohibits the situation where one transaction reads a row, a second transaction alters the row, and the first transaction rereads the row, getting different values the second time (a "non-repeatable read").&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;SERIALIZABLE&lt;/b&gt;: includes the prohibitions in &lt;code&gt;&lt;span style="font-size: 10.0pt;"&gt;TRANSACTION_REPEATABLE_READ&lt;/span&gt;&lt;/code&gt; and further prohibits the situation where one transaction reads all rows that satisfy a &lt;code&gt;&lt;span style="font-size: 10.0pt;"&gt;WHERE&lt;/span&gt;&lt;/code&gt; condition, a second transaction inserts a row that satisfies that &lt;code&gt;&lt;span style="font-size: 10.0pt;"&gt;WHERE&lt;/span&gt;&lt;/code&gt; condition, and the first transaction rereads for the same condition, retrieving the additional "phantom" row in the second read.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;NONE&lt;/b&gt;: transactions are not supported.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="apple-style-span"&gt;Depending on your isolation level we can have three phenomena: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;strong&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-weight: normal;"&gt;Dirty reads&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;1.&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Transaction A inserts a row into a table.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;2.&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Transaction B reads the new row.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;3.&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Transaction A rolls back.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;4.&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Transaction B may have done work to the system based on the row inserted by transaction A, but that row never became a permanent part of the database.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;strong&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-weight: normal;"&gt;Nonrepeatable&lt;/span&gt;&lt;/strong&gt;&lt;span class="apple-converted-space"&gt; &lt;b style="mso-bidi-font-weight: normal;"&gt;reads&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;1.&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Transaction A reads a row.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;2.&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Transaction B changes the row.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;3.&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Transaction A reads the same row a second time and gets the new results.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;strong&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-weight: normal;"&gt;Phantom &lt;/span&gt;&lt;/strong&gt;&lt;span class="apple-converted-space"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;reads &lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;1.&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Transaction A reads all rows that satisfy a WHERE clause on an SQL query.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;2.&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Transaction B inserts an additional row that satisfies the WHERE clause.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;3.&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Transaction A re-evaluates the WHERE condition and picks up the additional row.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; width: 95.0%;"&gt;&lt;tbody&gt;&lt;tr&gt;   &lt;td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="boldbodycopy"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Isolation Level&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="boldbodycopy"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Dirty Read&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="boldbodycopy"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Nonrepeatable Read&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="boldbodycopy"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Phantom Read&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;READ   UNCOMMITTED&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Permitted&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Permitted&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Permitted&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;READ   COMMITTED&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;No   Permitted&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Permitted&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Permitted&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;REPEATABLE   READ&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;No   Permitted&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;No   Permitted&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Permitted&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr&gt;   &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SERIALIZABLE&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;No   Permitted&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;No   Permitted&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top"&gt;   &lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bodycopy"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;No   Permitted&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style="mso-list: Ignore;"&gt;3.&lt;span style="font: 7.0pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;How to set transaction isolation level in JBoss AS 4.2.2&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;o:p&gt;&amp;nbsp;As far as I know we can configure it within &lt;span class="apple-style-span"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="color: red;"&gt;server/my_server/deploy/*-ds.xml &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: windowtext; mso-bidi-font-style: italic; mso-bidi-font-weight: bold;"&gt;(i.e oracle-ds.xml, mysql-ds.xml).&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;There are two types of datasources where we can define it: &lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;local-tx-datasource&lt;/b&gt;: identifies a datasource that uses &lt;span class="apple-style-span"&gt;single phase commit transactions, therefore there is just one resource per JTA transaction (local transaction).&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;xa-tx-datasource&lt;/b&gt;: identifies a datasource that uses &lt;span class="apple-style-span"&gt;two phase commit transactions, therefore there are more than one resource per JTA transaction (global transaction).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="apple-style-span"&gt;Note: Use &lt;/span&gt;xa-tx-datasource when it is really needed. It is expensive in terms of performance.&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="apple-style-span"&gt;The element to set is&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span class="bold"&gt;&lt;b&gt;transaction-isolation&lt;/b&gt;&lt;/span&gt;: specifies the&lt;span class="apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-size: 10.0pt;"&gt;java.sql.Connection&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/tt&gt;&lt;span class="apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;transaction isolation level to use. The constants defined in the Connection interface are the possible element content values and include:&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify; text-indent: 36.0pt;"&gt;TRANSACTION_READ_UNCOMMITTED&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;TRANSACTION_READ_COMMITTED&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify; text-indent: 36.0pt;"&gt;TRANSACTION_REPEATABLE_READ&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify; text-indent: 36.0pt;"&gt;TRANSACTION_SERIALIZABLE&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify; text-indent: 36.0pt;"&gt;TRANSACTION_NONE&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="NormalCourierNew" style="text-align: justify;"&gt;We can find further information in this link&amp;nbsp;&lt;a href="http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Server_Configuration_Guide/4/html/Connectors_on_JBoss-Configuring_JDBC_DataSources.html"&gt;&lt;/a&gt;&lt;a href="http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Server_Configuration_Guide/4/html/Connectors_on_JBoss-Configuring_JDBC_DataSources.html"&gt;JBoss web site&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8148007777591375750-3638563428477047600?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/3638563428477047600/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2009/11/transaction-isolation-levels.html#comment-form' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/3638563428477047600'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/3638563428477047600'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2009/11/transaction-isolation-levels.html' title='Transaction isolation levels, consenquences and configuration'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-1411616948974354201</id><published>2009-11-23T12:23:00.001Z</published><updated>2009-11-23T12:24:05.587Z</updated><title type='text'>Introducing security concepts in JBoss AS</title><content type='html'>&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 11px; font-weight: bold;"&gt;Authentication in JBoss AS&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Authentication &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;is the process by which a system verifies the identity of a user. There are two important concepts:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;Principal&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;: &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;a human user, machine or process that’s trying to prove its identity on another system. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;Credentials&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;: one or more forms of identifications provided by a principal, i.e. passwords, certificates or any other reliable form of identification.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Security data can be kept in different data sources, so JBoss SX has different &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red;"&gt;login modules&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; that can read security information from different locations such as a &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;database&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; or an &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;LDAP server&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_0QFX4__VHgo/Swp9AlizzKI/AAAAAAAAAQM/x_L4UWn1EWs/s1600/Authentication.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_0QFX4__VHgo/Swp9AlizzKI/AAAAAAAAAQM/x_L4UWn1EWs/s640/Authentication.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Authorization&lt;o:p&gt;&amp;nbsp;in JBoss AS&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Authorization &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;is the process of verifying that a principal has sufficient privileges to access an application resource. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Authorization is often achieved by assigning one or more roles to a principal and then associating one or more roles with a component or resource that a principal might want to access. When the principal tries to access the component, the system looks at the roles allowed to access the component and the roles assigned to the principal. If the principal has one of the roles assigned to the component, then he can access the component; otherwise, the principal can’t access the component. This process is called &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;role-based authorization&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Java EE defines declarative, role-based authorization for standard component technologies such as &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;servlet, JSP, and EJB&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. Declarative authorization means that you can assign roles to components via configuration without the need to write any code. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Note: There are certain situations where role-based security doesn’t cut it. This fact becomes evident when the security you want to apply depends on the context of the request that the user sends. Applying security based on information in the request is often called &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red;"&gt;context-based security&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;, or &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red;"&gt;programmatic security&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. For example, you want to allow a bank employee to enter deposits under 10,000 GPB, but anything over 10,000 GPB would require manager’s approval. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;You can implement context-based security in several ways for each of the different component models. For &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;EJBs&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;, you can use &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;JBoss SX security proxies&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; or &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;EJB3 interceptors&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. For &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;web applications&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;, you can use &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;servlet filters, custom valves, or interceptors&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_0QFX4__VHgo/Swp9F79YnaI/AAAAAAAAAQU/ml_bXRe-sUA/s1600/Authorization.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_0QFX4__VHgo/Swp9F79YnaI/AAAAAAAAAQU/ml_bXRe-sUA/s640/Authorization.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Configuring security&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Each Java EE component or resource has a different mechanism for defining security. The definition of what method to use and what should be secured is defined in each component’s standard deployment descriptor. But, the Java EE specification doesn’t specify the underlying security implementation; it doesn’t describe where the security data should be kept, how it should be retrieved, or how it should be validated. Each &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;application server vendor&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; has to create its own security implementation and allow programmers to configure and use it through &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;vendor-specific deployment descriptors&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;st1:place w:st="on"&gt;&lt;st1:city w:st="on"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;JBoss&lt;/span&gt;&lt;/st1:city&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;st1:state w:st="on"&gt;AS&lt;/st1:state&gt;&lt;/span&gt;&lt;/st1:place&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;’s security implementation is called &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;JBoss SX&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;, which builds on top of the &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;Java Authentication and Authorization Service (JAAS)&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; to secure all the Java EE technologies running in the application server. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;When a request comes into &lt;st1:place w:st="on"&gt;&lt;st1:city w:st="on"&gt;JBoss&lt;/st1:city&gt; &lt;st1:state w:st="on"&gt;AS&lt;/st1:state&gt;&lt;/st1:place&gt;, the targeted application component or resource (web application, EJB application, JMS queue/topic, or whatever), it may be—doesn’t need to know where the underlying security data exists or how it’s accessed. The component request is routed to a JBoss SX component called a &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red;"&gt;security domain&lt;/span&gt;&lt;/i&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;,&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; an abstraction used to secure all requests made to a component. The security domain performs any necessary security checks and notifies the component whether the user can proceed or not. The security domain knows how to use one or more login modules to load security data from a data source. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Security domains are configured at the server level and can be used by any component within the server. Security domains are bound into JNDI when the server starts; pointing to the security domain’s JNDI context maps a component to a security domain. You can add or modify existing security domain definitions within the &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;server/my_server/conf/login-config.xml&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Note: When&lt;span style="color: black;"&gt; you define a security domain in the login-config.xml file, JBoss SX doesn’t automatically bind the security domain into JNDI. JBoss SX only binds a security domain into JNDI after you deploy an application that references the security domain.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_0QFX4__VHgo/Swp9NHZPoEI/AAAAAAAAAQc/l0QCeP9r4WE/s1600/JBOSS_SX.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_0QFX4__VHgo/Swp9NHZPoEI/AAAAAAAAAQc/l0QCeP9r4WE/s640/JBOSS_SX.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none; text-indent: -36.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Everything together - Step by Step Example&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Bank’s secure Java EE-enabled website with a secure &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;public-key certificate&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; from a trusted &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;certificate authority &lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;(CA)&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Alvaro accesses the bank website and clicks on a link that should take his to her account summary. This link might be something like https://www.alvarobank.com/accountSumm.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;The page is accessed via a secured protocol (HTTPS), the server sends its secure certificate to Alvaro’s web browser, like all major browsers, has a list of well-known certificate authorities. On receiving the bank’s certificate, her browser turns around and asks the trusted certificate authorities if the certificate belongs to the bank &lt;/span&gt;&lt;span style="color: #333333; font-family: 'Courier New'; font-size: 8pt;"&gt;C&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Assuming that one of the certificate authorities acknowledges the authenticity of the bank’s certificate, Alvaro’s browser tries to forward her to the account summary page he originally requested. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Alvaro can now trust that he’s accessing &lt;i&gt;his &lt;/i&gt;bank and that nobody can intercept her communication with her bank. Also, as long as he accesses the bank over the secure protocol, all her communications are transferred over a secure channel.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;The bank needs to know if it can trust him. The URL for the account summary page is secured with &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;form-based authentication&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;. Users also must be a part of the &lt;i style="mso-bidi-font-style: normal;"&gt;AccountHolder role&lt;/i&gt; before accessing the page. Before Alvaro can access the account summary page, his request is intercepted by the &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;JBoss Web Server web container&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;. The container realizes that the URL that he’s accessing is secured, so it checks with the security framework&lt;/span&gt;&lt;span style="color: #333333; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;to see if Alvaro is already logged in. After realizing that he’s not, a login form is sent back to Alvaro, prompting him for his username and password.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;When Alvaro types in her credentials (user and password) and submits the form, the web container receives the form submission and passes Alvaro’s credentials to the application server’s security framework. The security framework accesses security information from a database, which it queries to determine whether or not Alvaro can access to the resource he’s requesting. First, the security framework should &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;authenticate&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;/span&gt;&lt;/i&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Alvaro, comparing the password she supplies against a known password to see if she should be granted access to the system at all. Then, the security framework should &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;authorize&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;/span&gt;&lt;/i&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Alvaro, determining if his username is associated with a role that can access the resource.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Everything matches up, so the security framework returns control back to the web container. Now that Alvaro’s credentials have been verified, the web container forwards her request to the resource associated with the URL for the account summary.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;The account summary page is implemented as a &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;servlet&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;. In order for the servlet to render Alvaro’s account summary information, it needs to access her account information.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;The servlet makes a call to the getAccountSummary(User u) method on a &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;session EJB&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; called Account, which runs in the EJB container. Because the EJB container runs locally, the servlet automatically propagates the security credentials.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;The EJB method only allows access to users with the AccountHolder role. The EJB server accesses the JBoss SX security framework to determine if Alvaro is authenticated and authorized to access the resources. Again, access to the EJB method succeeds, and Alvaro’s account information loads from the application database. After the account summary loads, control returns to the servlet, which renders the output and sends it back to Alvaro, still over a secure channel.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_0QFX4__VHgo/Swp9RJR4kkI/AAAAAAAAAQk/2_18fstye_I/s1600/Example.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_0QFX4__VHgo/Swp9RJR4kkI/AAAAAAAAAQk/2_18fstye_I/s640/Example.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&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/8148007777591375750-1411616948974354201?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/1411616948974354201/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2009/11/introducting-security-concepts-in-jboss.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/1411616948974354201'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/1411616948974354201'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2009/11/introducting-security-concepts-in-jboss.html' title='Introducing security concepts in JBoss AS'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_0QFX4__VHgo/Swp9AlizzKI/AAAAAAAAAQM/x_L4UWn1EWs/s72-c/Authentication.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-7596673797894689091</id><published>2009-11-15T21:25:00.006Z</published><updated>2009-11-16T00:09:55.533Z</updated><title type='text'>Transfer Obejcts vs Business Objects (JPA entities)  across the tiers</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 11px; font-weight: bold;"&gt;Introduction&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;In this article I try to launch a very common technical discussion about what is the best approach, Transfer objects or Business objects (JPA entities) across the tiers. Once more time, I think that there is no a golden rule. It depends on the use case, the complexity of the application in terms of architecture and frameworks used.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 11px; font-weight: bold;"&gt;Transfer Object across the tiers&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 11px; font-weight: bold;"&gt;Pros&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 11px;"&gt;1. Reduces network traffic in distributed systems. Transfer objects are passed to the client in a single remote call.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;2. Improves client performance by removing any need to assemble data models.&lt;br /&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;3. Decouples business logic from the client and keeps it in the business tier.&lt;br /&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;4. Improves transaction performance by isolating the components that can be updated.&lt;br /&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Cons&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 11px;"&gt;1. Data in transfer objects might get obsolete. The transfer object has a copy of the data which is not automatically updated if the data changes on the server.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;2. The system can be complicated when using concurrent access or transaction management processes.&lt;br /&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;3. Synchronization logic can complicate the system if updatable transfer objects are used.&lt;br /&gt;Object creation overhead on the server side increases.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: 11px; font-weight: bold;"&gt;Business Object across the tiers&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;div style="text-align: justify;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New'; font-size: 11px;"&gt;Pros&lt;/span&gt;&lt;/div&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;div style="text-align: justify;"&gt;1. Good approach in simple presentation tier design.&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;2. Makes easier the development in business and presentation tier because there is no need to assemble data models.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 11px;"&gt;Cons&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 11px;"&gt;1. Couples presentation tier and business tier.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Note: If the business requirements don’t change often I consider that is good point to use them but otherwise it could be a nightmare for each single change to adapt the presentation tier.&lt;br /&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;2. In the case that the user interface requires a complex set of properties:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;2.1. The domain model to pass across tiers can become heavyweight in terms of memory.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;2.2. The development in the presentation tier can be complex because we need to navigate across multiple business objects to get the properties.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;br /&gt;2.3. The development in business tier can become very tedious because we will load a lot of properties in the domain model (properties from BO1 -&amp;gt; properties from BO2 -&amp;gt; properties from BO3 and so on). There are two approaches to have all the properties in presentation tier:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; 2.3.1 In business tier: Eager relationships in JPA entities.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span lang="EN-US" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; 2.3.2&amp;nbsp;In business tier:&amp;nbsp;“Fetch Join” in application services.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Note: Some frameworks keep transaction opened during the render of the user interface. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;In the case the relationships in the JPA entities can be defined as LAZY. We do not have &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New'; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;to be worry about exceptions as&amp;nbsp;&lt;span class="Apple-style-span" style="font-size: 12px; font-weight: bold; white-space: pre;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;org.hibernate.LazyInitializationException &lt;span class="Apple-style-span" style="font-family: 'Courier New'; font-size: 11px; font-weight: normal; white-space: normal;"&gt;in the case of &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New'; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;using Hibernate as JPA provider.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;span style="font-family: 'Times New Roman';"&gt;&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&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/8148007777591375750-7596673797894689091?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/7596673797894689091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2009/11/transfer-obejcts-vs-business-objects.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/7596673797894689091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/7596673797894689091'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2009/11/transfer-obejcts-vs-business-objects.html' title='Transfer Obejcts vs Business Objects (JPA entities)  across the tiers'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-6872208694690666092</id><published>2009-11-04T16:55:00.000Z</published><updated>2009-11-04T16:55:41.278Z</updated><title type='text'>JMS: Message-driven Bean - Part 3</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: 'Courier New'; font-size: 11px; font-weight: bold;"&gt;Introduction&lt;/span&gt;&lt;br /&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;The message-driven bean model develops an &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;Enterprise Bean&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; that is &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;asynchro­nously&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; invoked by the container to handle the processing of incoming messages.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;From the perspective of the client, the existence of a message-driven bean is completely hidden behind the destination or endpoint for which the message-driven bean is the message listener. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_0QFX4__VHgo/SvGqoJRMSJI/AAAAAAAAAPo/Bd_jI459fdo/s1600-h/Simple_model.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_0QFX4__VHgo/SvGqoJRMSJI/AAAAAAAAAPo/Bd_jI459fdo/s320/Simple_model.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 4.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 21.0pt; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Implementing the MessageListener&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;A message-driven bean implements &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;javax.jms.MessageListener&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; interface (JMS Message driven bean). &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;The container uses the listener interface to register the &lt;span style="color: black;"&gt;message-driven bean&lt;/span&gt; with the message provider and to pass incoming messages by invoking implemented message listener methods. There are different ways to define a &lt;span style="color: black;"&gt;message-driven bean&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-autospace: none; text-indent: -18.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;1.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #646464; font-family: 'Courier New'; font-size: 8pt;"&gt;@MessageDriven&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (name=&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"ShippingRequestJMSProcessor"&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;,&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; messageListenerInterface=&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"javax.jms.MessageListener"&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;)&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none; text-indent: 35.4pt;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;class&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; ShippingRequestProcessorMDB {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify; text-indent: 36.0pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;2.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;class&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt; ShippingRequestProcessorMDB &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;implements&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt; MessageListener&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;3.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Deployment descriptor.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;The bean’s message listener method &lt;/span&gt;&lt;b&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;void&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; onMessage(Message message)&lt;/span&gt;&lt;/i&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;is called by the container when a message has arrived for the bean to service. The message lis­tener method contains the business logic that handles the processing of the message.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Note: If the message-driven bean class implements more than one interface other than &lt;i style="mso-bidi-font-style: normal;"&gt;java.io.Serial­izable&lt;/i&gt;, &lt;i style="mso-bidi-font-style: normal;"&gt;java.io.Externalizable&lt;/i&gt;, or any of the interfaces defined by the &lt;i style="mso-bidi-font-style: normal;"&gt;javax.ejb&lt;/i&gt; pack­age, the message listener interface must be specified by the &lt;i style="mso-bidi-font-style: normal;"&gt;messageListenerInterface&lt;/i&gt; element of the &lt;i style="mso-bidi-font-style: normal;"&gt;MessageDriven&lt;/i&gt; annotation or the messaging-type element of the mes­sage-driven deployment descriptor element.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="SP6250197"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;b&gt;Activation Configuration Properties&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="SP6250229" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;The &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;activationConfig&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt; property of the &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;@MessageDriven&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;annotation&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt; allows you to provide messaging system-specific configuration information through an array of &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;ActivationConfigProperty&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt; instances. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-bottom-style: none; border-collapse: collapse; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; width: 621px;"&gt;&lt;tbody&gt;&lt;tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;"&gt;   &lt;td colspan="3" style="background: #BFBFBF; border: solid black 1.0pt; mso-border-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 466.1pt;" valign="top" width="621"&gt;&lt;div align="center" class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-align: center;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;ActivationConfigProperty&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 1;"&gt;   &lt;td style="background: #C4BC96; border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 133.0pt;" valign="top" width="177"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;propertyName&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="background: #C4BC96; border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 138.5pt;" valign="top" width="185"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;propertyValue&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="background: #C4BC96; border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 194.6pt;" valign="top" width="259"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Description&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 2;"&gt;   &lt;td rowspan="2" style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 133.0pt;" valign="top" width="177"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;destinationType&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 138.5pt;" valign="top" width="185"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;javax.jms.Queue&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 194.6pt;" valign="top" width="259"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Tells the   container this JMS MDB is listening to a queue.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 3;"&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 138.5pt;" valign="top" width="185"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;javax.jms.Topic&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 194.6pt;" valign="top" width="259"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Tells the   container this JMS MDB is listening to a topic.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 4;"&gt;   &lt;td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 133.0pt;" valign="top" width="177"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;destinationName&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 138.5pt;" valign="top" width="185"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;jms/ShippingRequestQueue&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 194.6pt;" valign="top" width="259"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Specifies   that we are listening for messages arriving at a destination with the JNDI   name of jms/ShippingRequestQueue.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 5;"&gt;   &lt;td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 133.0pt;" valign="top" width="177"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;connectionfactoryJndiName&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 138.5pt;" valign="top" width="185"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;jms/QueueConnectionFactory&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 194.6pt;" valign="top" width="259"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Specifies   the JNDI name of the connection factory that should be used to create JMS   connections for the MDB.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 6;"&gt;   &lt;td rowspan="2" style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 133.0pt;" valign="top" width="177"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;acknowledgeMode&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 138.5pt;" valign="top" width="185"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;AUTO_KNOWLEDGE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 194.6pt;" valign="top" width="259"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;The session   automatically acknowledges receipt after a message has been received or is   successfully processed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 7;"&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 138.5pt;" valign="top" width="185"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;DUPS_OK_ACKNOWLEDGE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 194.6pt;" valign="top" width="259"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;The session   can lazily acknowledge receipt of the message.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 8;"&gt;   &lt;td rowspan="2" style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 133.0pt;" valign="top" width="177"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;subscriptionDurability&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 138.5pt;" valign="top" width="185"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Durable &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 194.6pt;" valign="top" width="259"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Once a   consumer obtains a durable subscription on a topic, all messages sent to the   topic are guaranteed to be delivered to the consumer.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 9;"&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 138.5pt;" valign="top" width="185"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;NonDurable   (By default)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 194.6pt;" valign="top" width="259"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;In the   pub-sub domain, a message is distributed to all currently subscribed   consumers. In general, this is much like a broadcast message in that anyone   who is not connected to the topic at the time does not receive a copy the   message.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 10; mso-yfti-lastrow: yes;"&gt;   &lt;td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 133.0pt;" valign="top" width="177"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;messageSelector&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 138.5pt;" valign="top" width="185"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;JMSType   = ‘car’ AND color = ‘blue’ and weight &amp;gt; 2500&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 194.6pt;" valign="top" width="259"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Determines   which messages a JMS message-driven bean is to receive. &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt; line-height: 115%;"&gt;Example 1.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #646464; font-family: 'Courier New'; font-size: 8pt;"&gt;@MessageDriven&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; name=&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"ShippingRequestProcessor"&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;,&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; activationConfig = {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #646464; font-family: 'Courier New'; font-size: 8pt;"&gt;@&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;ActivationConfigProperty(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; propertyName=&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"destinationType"&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;,&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; propertyValue=&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"javax.jms.Queue"&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;),&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #646464; font-family: 'Courier New'; font-size: 8pt;"&gt;@&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;ActivationConfigProperty(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; propertyName=&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"connectionFactoryJndiName"&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;,&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; propertyValue=&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"jms/QueueConnectionFactory"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ),&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #646464; font-family: 'Courier New'; font-size: 8pt;"&gt;@&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;ActivationConfigProperty(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; propertyName=&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"destinationName"&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;,&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; propertyValue=&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"jms/ShippingRequestQueue"&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;)&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 4.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 21.0pt; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Using bean lifecycle callbacks&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 4.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 21.0pt; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;The container is responsible for the following:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 4.0pt; margin-left: 36.0pt; margin-right: 0cm; margin-top: 21.0pt; mso-layout-grid-align: none; mso-list: l1 level1 lfo3; tab-stops: list 36.0pt; text-align: justify; text-autospace: none; text-indent: -18.0pt;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;1.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;A MDB instance’s life starts when the container invokes newInstance on the MDB class to create a new instance. Next, the container injects the bean’s MessageDriverContext, if applicable, and performs any other dependency injection as specified by metadata annotations on the bean class or by the deployment descriptor. The container then calls the bean’s PostConstruct lifecycle callback methods, if any.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 4.0pt; margin-left: 36.0pt; margin-right: 0cm; margin-top: 21.0pt; mso-layout-grid-align: none; mso-list: l1 level1 lfo3; tab-stops: list 36.0pt; text-align: justify; text-autospace: none; text-indent: -18.0pt;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;2.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;The MDB instance is now ready to be delivered a message sent to its associated destination or endpoint by any client or a call from the container to the timeout callback method.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 4.0pt; margin-left: 36.0pt; margin-right: 0cm; margin-top: 21.0pt; mso-layout-grid-align: none; mso-list: l1 level1 lfo3; tab-stops: list 36.0pt; text-align: justify; text-autospace: none; text-indent: -18.0pt;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;3.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;When the container no longer needs the instance (happens when the container wants to reduce the number of instances in the method-ready pool), the container invokes the PreDestroy lifecycle callback methods for it, if any. This ends the life of the MDB instance.&lt;br style="mso-special-character: line-break;" /&gt; &lt;br style="mso-special-character: line-break;" /&gt; &lt;u&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_0QFX4__VHgo/SvGq4PQ16AI/AAAAAAAAAPw/RBBmp8KjvfA/s1600-h/lifecycle.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_0QFX4__VHgo/SvGq4PQ16AI/AAAAAAAAAPw/RBBmp8KjvfA/s640/lifecycle.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 4.0pt; margin-left: 36.0pt; margin-right: 0cm; margin-top: 21.0pt; mso-layout-grid-align: none; mso-list: l1 level1 lfo3; tab-stops: list 36.0pt; text-align: justify; text-autospace: none; text-indent: -18.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;The following &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;lifecycle event callbacks&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; are supported for message-driven beans. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 3.0pt; margin-left: 35.4pt; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;•&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;PostConstruct.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 35.4pt; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;•&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;PreDestroy.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;A message driven bean can be registered with the EJB timer service for time-based event notifications. The container invokes the appropriate bean instance &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;timeout callback&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; method when a timer for the bean has expired. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;The AroundInvoke business method interceptor methods are supported for message-driven beans. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 4.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 21.0pt; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Serializing Message-Driven Bean Methods&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;The container serializes calls to each message-driven bean instance. Most containers will support many instances of a message-driven bean executing concurrently; however, each instance sees only a serial­ized sequence of method calls. Therefore, a message-driven bean does not have to be coded as reentrant. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;The container must serialize all the container-invoked callbacks (e.g., lifecycle callback interceptor methods and timeout callback methods), and it must serialize these callbacks with the message listener method calls. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Concurrency of Message Processing&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;A container allows many instances of a message-driven bean class to be executing concurrently, thus allowing for the concurrent processing of a stream of messages. No guarantees are made as to the exact order in which messages are delivered to the instances of the message-driven bean class, although the container should attempt to deliver messages in order when it does not impair the concurrency of mes­sage processing. Message-driven beans should therefore be prepared to handle messages that are out of sequence: for example, the message to cancel a reservation may be delivered before the message to make the reservation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Transaction Context of Message-Driven Bean Methods and acknowledgment&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;If the MDB uses &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;container-managed transaction&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;demarcation&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 36.0pt; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; mso-list: l2 level1 lfo2; tab-stops: list 36.0pt; text-align: justify; text-autospace: none; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 8pt;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;In message listener methods&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 54.0pt; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;REQUIRED&lt;/span&gt;&lt;/i&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;. The message receipt is part of the transac­tion and &lt;span style="font-family: 'Courier New';"&gt;message acknowledgment is handled automatically as a part of the transaction commit&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 35.4pt; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none; text-indent: 18.6pt;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;NOT_SUPPORTED.&lt;/span&gt;&lt;/i&gt;&lt;u&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 36.0pt; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; mso-list: l2 level1 lfo2; tab-stops: list 36.0pt; text-align: justify; text-autospace: none; text-indent: -18.0pt;"&gt;&lt;span style="font-family: Wingdings; font-size: 8pt;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;In timeout callback methods&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 35.4pt; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none; text-indent: 35.4pt;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;REQUIRED.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 35.4pt; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none; text-indent: 35.4pt;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;REQUIRES_NEW.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 35.4pt; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none; text-indent: 35.4pt;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;NOT_SUPPORTED.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;If the MDB uses &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;bean-managed transaction demarcation&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; uses the &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;javax.trans­action.UserTransaction interface&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; to demarcate transactions, the message receipt is not part of the transaction. &lt;span style="font-family: 'Courier New';"&gt;The receipt is acknowledged by the container (AUTO_ACKNOWLEDGE semantics or DUPS_OK_ACKNOWLEDGE).&lt;/span&gt;&lt;u&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Dealing with Exceptions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;A message-driven bean’s message listener method must not throw the java.rmi.RemoteExcep­tion.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Message-driven beans should not, in general, throw RuntimeExceptions. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;A RuntimeException that is not an application exception thrown from any method of the mes­sage-driven bean class (including a message listener method and the callbacks invoked by the container) results in the transition to the &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;“does not exist” state&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;. If a message-driven bean uses bean-managed trans­action demarcation and throws a RuntimeException, the container should not acknowledge the message. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;From the client perspective, the message consumer continues to exist. If the client continues sending messages to the destination or endpoint associated with the bean, the container can delegate the client’s messages to another instance.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;The message listener methods of some messaging types may throw application exceptions. An applica­tion exception is propagated by the container to the resource adapter.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Some Basic Scenarios&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;&lt;o:p&gt;&amp;nbsp;Scenario 1.&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_0QFX4__VHgo/SvGuo9XhfNI/AAAAAAAAAP4/9PdBodYeCMY/s1600-h/noj2eeserver.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_0QFX4__VHgo/SvGuo9XhfNI/AAAAAAAAAP4/9PdBodYeCMY/s640/noj2eeserver.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt;"&gt;&lt;o:p&gt;&amp;nbsp;Scenario 2.&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_0QFX4__VHgo/SvGutQuoF8I/AAAAAAAAAQA/ytnyeUGTwSs/s1600-h/j2eeserver.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_0QFX4__VHgo/SvGutQuoF8I/AAAAAAAAAQA/ytnyeUGTwSs/s400/j2eeserver.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&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/8148007777591375750-6872208694690666092?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/6872208694690666092/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2009/11/jms-message-driven-bean-part-3.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/6872208694690666092'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/6872208694690666092'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2009/11/jms-message-driven-bean-part-3.html' title='JMS: Message-driven Bean - Part 3'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_0QFX4__VHgo/SvGqoJRMSJI/AAAAAAAAAPo/Bd_jI459fdo/s72-c/Simple_model.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-6127169586198959158</id><published>2009-10-26T14:15:00.002Z</published><updated>2009-10-26T16:26:30.978Z</updated><title type='text'>JMS: Reliable and robust applications - Part 2</title><content type='html'>&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;1. Introduction &lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;This post &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;explains how to use features of the JMS API to achieve the level of reliability and performance your application requires. All this content is taken from my summaries based on the specification.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;2.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Basic Reliability Mechanisms&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;2.1 Controlling Message Acknowledgment&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Until a JMS message has been acknowledged, it is not considered to be successfully consumed; this ordinarily takes place in three steps.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;1. The client receives the message.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;2. The client processes the message.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;3. The message is acknowledged. Acknowledgment is initiated either by the JMS provider or by the client, depending on the session acknowledgment mode.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Let’s pay attention in the following: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre&gt;&lt;span style="font-size: 8pt;"&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/jms/QueueSession.html" title="interface in javax.jms"&gt;&lt;span style="text-decoration: none;"&gt;QueueSession&lt;/span&gt;&lt;/a&gt; &lt;b&gt;createQueueSession&lt;/b&gt;(boolean&amp;nbsp;transacted, int&amp;nbsp;acknowledgeMode)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throws &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/jms/JMSException.html" title="class in javax.jms"&gt;&lt;span style="text-decoration: none;"&gt;JMSException&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-size: 8pt;"&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/jms/TopicSession.html" title="interface in javax.jms"&gt;&lt;span style="text-decoration: none;"&gt;TopicSession&lt;/span&gt;&lt;/a&gt; &lt;b&gt;createTopicSession&lt;/b&gt;(boolean&amp;nbsp;transacted, int&amp;nbsp;acknowledgeMode)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throws &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/jms/JMSException.html" title="class in javax.jms"&gt;&lt;span style="text-decoration: none;"&gt;JMSException&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;If the first parameter is true, the session is &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;transacted&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; and the acknowledgment happens automatically when a transaction is committed. If a transaction is rolled back, all consumed messages are redelivered.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;If the first parameter is false, the session is &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;nontransacted &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;and the value in the parameter &lt;code&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;acknowledgeMode&lt;/i&gt;&lt;/code&gt; indicates whether the consumer or the client will acknowledge any messages it receives, ignored if the session is transacted.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;Session.AUTO_ACKNOWLEDGE&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. The session automatically acknowledges a client’s receipt of a message either when the client has successfully returned from a call to receive or when the MessageListener it has called to process the message returns successfully. A synchronous receive in an AUTO_ACKNOWLEDGE session is the exception to the rule that message consumption is a three-stage process. In this case, the receipt and acknowledgment take place in one step, followed by the processing of the message.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;Session.CLIENT_ACKNOWLEDGE&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. A client acknowledges a message by calling the message’s acknowledge method. In this mode, acknowledgment takes place on the session level: Acknowledging a consumed message automatically acknowledges the receipt of all messages that have been consumed by its session. For example, if a message consumer consumes ten messages and then acknowledges the fifth message delivered, all ten messages are acknowledged.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;Session.DUPS_OK_ACKNOWLEDGE&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. This option instructs the session to lazily acknowledge the delivery of messages. This is likely to result in the delivery of some duplicate messages if the JMS provider fails, so it should be used only by consumers that can tolerate duplicate messages. This option can reduce session overhead by minimizing the work the session does to prevent duplicates.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;If messages have been received but not acknowledged when a QueueSession terminates, the JMS provider retains them and redelivers them when a consumer next accesses the queue. The provider also retains unacknowledged messages for a terminated TopicSession with a durable TopicSubscriber. Unacknowledged messages for a nondurable TopicSubscriber are dropped when the session is closed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 18.0pt; mso-layout-grid-align: none; mso-list: l0 level2 lfo1; tab-stops: list 18.0pt; text-align: justify; text-autospace: none; text-indent: -18.0pt;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;2.2&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Specifying Message Persistence&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;The JMS API supports two delivery modes for messages to specify whether messages are lost if the JMS provider fails. These delivery modes are fields of the javax.jms.DeliveryMode interface.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• The &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;PERSISTENT delivery mode&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; (by default), instructs the JMS provider to take extra care to ensure that a message is not lost in transit in case of a JMS provider failure. A message sent with this delivery mode is logged to stable storage when it is sent. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• The &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;NON_PERSISTENT delivery mode&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; does not require the JMS provider to store the message or otherwise guarantee that it is not lost if the provider fails. This mode may improve performance and reduce storage overhead, but you should use it only if your application can afford to miss messages.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;2.3 Setting Message Priority Levels&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;You can use message priority levels (0 lowest to 9 highest, 4 default) to instruct the JMS provider to deliver urgent messages first. You can set the priority level in either of two ways. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;2.4 Allowing Messages to Expire&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;By default, a message never expires. If a message will become obsolete after a certain period, however, you may want to set an expiration time. You can do this in either of two ways.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;2.5 Creating Temporary Destinations&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;The JMS API enables you to create destinations:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;QueueSession.createTemporaryQueue &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red; font-family: 'Courier New'; font-size: 8pt;"&gt;TopicSession.createTemporary&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;They last only for the duration of the connection in which they are created. The only message consumers that can consume from a temporary destination are those created by the same connection that created the destination. Any message producer can send to the temporary destination. If you close the connection that a temporary destination belongs to, the destination is closed and its contents lost.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;You can use temporary destinations to implement a simple request/reply mechanism (see JMSReplyTo, JMSCorrelationID, JMSMessageID). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;3.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Advanced Reliability Mechanisms&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;3.1 Creating Durable Subscriptions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;To make sure that a pub/sub application receives all published messages, use PERSISTENT delivery mode for the publishers. In addition, use durable subscriptions for the subscribers.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;The &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;TopicSession.createSubscriber&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; method creates a nondurable subscriber and can receive only messages that are published while it is active.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_0QFX4__VHgo/SuWt8gQQnYI/AAAAAAAAAPY/ctA9XnDIHSQ/s1600-h/NonDurableSubscription.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_0QFX4__VHgo/SuWt8gQQnYI/AAAAAAAAAPY/ctA9XnDIHSQ/s400/NonDurableSubscription.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;The &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;TopicSession.createDurableSubscriber&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; method creates a durable subscriber. A durable subscription can have only one active subscriber at a time.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_0QFX4__VHgo/SuWuDB0-fwI/AAAAAAAAAPg/IHXZD4OiyS4/s1600-h/DurableSubcription.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_0QFX4__VHgo/SuWuDB0-fwI/AAAAAAAAAPg/IHXZD4OiyS4/s400/DurableSubcription.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;A durable subscriber registers a durable subscription with a unique identity that is retained by the JMS provider. Subsequent subscriber objects with the same identity resume the subscription in the state in which it was left by the previous subscriber. If a durable subscription has no active subscriber, the JMS provider retains the subscription’s messages until they are received by the subscription or until they expire.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;You establish the unique identity of a durable subscriber by setting the following:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• A client ID for the connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• A topic and a subscription name for the subscriber&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;With a durable subscriber, the subscriber can be closed and recreated, but the subscription continues to exist and to hold messages until the application calls the unsubscribe method. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;3.2 Using JMS API Local Transactions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;You can group a series of operations together into an atomic unit of work called a transaction. If any one of the operations fails, the transaction can be rolled back, and the operations can be attempted again from the beginning. If all the operations succeed, the transaction can be committed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;In a JMS client, you can use local transactions to group message sends and receives. The JMS API Session interface provides commit and rollback methods that you can use in a JMS client. A transaction commit means that all produced messages are sent and all consumed messages are acknowledged. A transaction rollback means that all produced messages are destroyed and all consumed messages are recovered and redelivered unless they have expired.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;A transacted session is always involved in a transaction. As soon as the commit or the rollback method is called, one transaction ends and another transaction begins. Closing a transacted session rolls back its transaction in progress, including any pending sends and receives.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_0QFX4__VHgo/SuWt0DjZVII/AAAAAAAAAPQ/dkV0oJkSUYw/s1600-h/Local_Trasactions.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_0QFX4__VHgo/SuWt0DjZVII/AAAAAAAAAPQ/dkV0oJkSUYw/s400/Local_Trasactions.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;In an &lt;st1:city w:st="on"&gt;&lt;st1:place w:st="on"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;Enterprise&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;/st1:city&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt; JavaBeans component&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;, you cannot use the Session.commit and Session.rollback methods. Instead, you use &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;distributed transactions&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;You can combine several sends and receives in a single JMS API local transaction. If you do so, you need to be careful about the order of the operations. You will have no problems if the transaction consists of all sends or all receives or if the receives come before the sends. But if you try to use a request-reply mechanism, whereby you send a message and then try to receive a reply to the sent message in the same transaction, the program will hang, because the send cannot take place until the transaction is committed. Because a message sent during a transaction is not actually sent until the transaction is committed, the transaction cannot contain any receives that depend on that message’s having been sent.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;It is also important to note that &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;the production and the consumption of a message cannot both be part of the same transaction&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. The reason is that the transactions take place between the clients and the JMS provider, which intervenes between the production and the consumption of the message. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Another way of putting this is that the act of producing and/or consuming messages in a session can be transactional, but the act of producing and consuming a specific message across different sessions cannot be transactional.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Because the commit and the rollback methods for local transactions are associated with the session, you cannot combine queue and topic operations in a single transaction.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;You can, however, receive from one queue and send to another queue in the same transaction, assuming that you use the same Queue-Session to create the QueueReceiver and the QueueSender. You can pass a client program’s session to a message listener’s constructor function and use it to create a message producer, so that you can use the same session for receives and sends in asynchronous message consumers.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&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/8148007777591375750-6127169586198959158?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/6127169586198959158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2009/10/reliable-and-robust-jms-applications.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/6127169586198959158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/6127169586198959158'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2009/10/reliable-and-robust-jms-applications.html' title='JMS: Reliable and robust applications - Part 2'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_0QFX4__VHgo/SuWt8gQQnYI/AAAAAAAAAPY/ctA9XnDIHSQ/s72-c/NonDurableSubscription.JPG' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-6088151673171382742</id><published>2009-10-16T16:28:00.007+01:00</published><updated>2009-10-22T18:08:10.428+01:00</updated><title type='text'>JMS: Basic Concepts - Part 1</title><content type='html'>&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Arial;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;1. Introduction&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;b&gt;My intention with this post is to summarize the most important ideas behind of JMS. As always, I am not trying to reinvent the wheel and all the notes are taken from the specification.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;2. What Is the JMS API?&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;The Java Message Service is a Java API that allows applications to create, send, receive, and read messages.&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;The JMS API enables distributed communication that is not only &lt;span style="color: red;"&gt;&lt;b&gt;&lt;i&gt;loosely coupled&lt;/i&gt;&lt;/b&gt;&lt;/span&gt; but also&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• &lt;b&gt;&lt;span style="color: red;"&gt;&lt;i&gt;Asynchronous&lt;/i&gt;&lt;/span&gt;. &lt;/b&gt;A JMS provider can deliver messages to a client as they arrive; a client does not have to request messages in order to receive them.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• &lt;b&gt;&lt;i&gt;&lt;span style="color: red;"&gt;Reliable&lt;/span&gt;&lt;/i&gt;. &lt;/b&gt;The JMS API can ensure that a message is delivered once and only once. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Arial;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;b&gt;3.&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;When Can You Use the JMS API?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;span style="font-weight: normal;"&gt;An enterprise application provider is likely to choose a messaging API over a tightly coupled API, such as Remote Procedure Call (RPC), under the following circumstances.&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• The provider wants the components not to depend on information about other components’ interfaces, so that components can be easily replaced.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• The provider wants the application to run whether or not all components are up and running simultaneously.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• The application business model allows a component to send information to another and to continue to operate without receiving an immediate response.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Arial;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;4.&lt;span style="font-family: 'Times New Roman'; font-size: xx-small;"&gt;&lt;span style="font-size: 8px; font-weight: normal;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;JMS API Architecture&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;span style="font-weight: normal;"&gt;A JMS application is composed of the following parts.&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red;"&gt;JMS provider&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt; &lt;/i&gt;is a messaging system that implements the JMS interfaces and provides administrative and control features. An implementation of the J2EE platform at release 1.3 includes a JMS provider.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red;"&gt;JMS clients&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt; &lt;/i&gt;are the programs or components, written in the Java programming language, that produce and consume messages.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red;"&gt;Messages &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;are the objects that communicate information between JMS clients.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red;"&gt;Administered objects&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt; &lt;/i&gt;are preconfigured JMS objects created by an administrator for the use of clients. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red;"&gt;Native clients&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt; &lt;/i&gt;are programs that use a messaging product’s native client API instead of the JMS API. An application first created before the JMS API became available and subsequently modified is likely to include both JMS and native clients.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_0QFX4__VHgo/StiQlmg4tQI/AAAAAAAAAOg/-onVGrTr2OU/s1600-h/JMS_Architecture.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_0QFX4__VHgo/StiQlmg4tQI/AAAAAAAAAOg/-onVGrTr2OU/s400/JMS_Architecture.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Arial;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;5.&lt;span style="font-family: 'Times New Roman'; font-size: xx-small;"&gt;&lt;span style="font-size: 8px; font-weight: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Messaging Domains&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;Point-to-Point Messaging Domain&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Each message is addressed to a specific &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;queue&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;, and receiving clients extract messages from the queue(s) established to hold their messages.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Queues retain all messages sent to them until the messages are consumed or until the messages expire.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_0QFX4__VHgo/StiREQBuHiI/AAAAAAAAAOw/gTnBztcfmOM/s1600-h/PointToPointMessaging.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_0QFX4__VHgo/StiREQBuHiI/AAAAAAAAAOw/gTnBztcfmOM/s400/PointToPointMessaging.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;PTP messaging has the following characteristics:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• Each message has &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;only one consumer&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• A sender and a receiver of a message have &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;no timing dependencies&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. The receiver can fetch the message whether or not it was running when the client sent the message.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• The receiver acknowledges the successful processing of a message.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Publish/Subscribe Messaging Domain&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Publishers and subscribers are generally anonymous and may dynamically publish or subscribe to the content hierarchy. The system takes care of distributing the messages arriving from a topic’s multiple publishers to its multiple subscribers. Topics retain messages only as long as it takes to distribute them to current subscribers.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_0QFX4__VHgo/StiQ2X81V6I/AAAAAAAAAOo/iMyXKCik3Nk/s1600-h/PublishSubscribe.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_0QFX4__VHgo/StiQ2X81V6I/AAAAAAAAAOo/iMyXKCik3Nk/s400/PublishSubscribe.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Pub/sub messaging has the following characteristics.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• Each message may have &lt;span style="color: red;"&gt;&lt;b&gt;&lt;i&gt;multiple consumers&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• Publishers and subscribers have a &lt;span style="color: red;"&gt;&lt;i&gt;&lt;b&gt;timing dependency&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;. A client that subscribes to a topic can consume only messages published after the client has created a subscription, and the subscriber must continue to be active in order for it to consume messages.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;The JMS API relaxes this timing dependency to some extent by allowing clients to create &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red;"&gt;durable subscriptions&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. Durable subscriptions can receive messages sent while the subscribers are not active. Durable subscriptions provide the flexibility and reliability of queues but still allow clients to send messages to many recipients.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;span style="font-family: Arial;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;6.&amp;nbsp;&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Message Consumption&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Messaging products are inherently asynchronous in that no fundamental timing dependency exists between the production and the consumption of a message. However, the JMS Specification uses this term in a more precise sense. Messages can be consumed in either of two ways:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• &lt;b&gt;Synchronously. &lt;/b&gt;A subscriber or a receiver explicitly fetches the message from the destination by calling the receive method. The receive method can block until a message arrives or can time out if a message does not arrive within a specified time limit.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;• &lt;b&gt;Asynchronously. &lt;/b&gt;A client can register a &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i&gt;&lt;span style="color: red;"&gt;message listener&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt; &lt;/i&gt;with a consumer. A message listener is similar to an event listener. Whenever a message arrives at the destination, the JMS provider delivers the message by calling the listener’s &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;onMessage method&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;, which acts on the contents of the message.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-autospace: none; text-indent: -36.0pt;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;b&gt;7.&lt;/b&gt;&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&lt;b&gt;Main&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;b&gt;&amp;nbsp;elements in JMS application&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Administered Objects&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Two parts of a JMS application—destinations and connection factories—are best maintained administratively rather than programmatically. The technology underlying these objects is likely to be very different from one implementation of the JMS API to another. Therefore, the management of these objects belongs with other administrative tasks that vary from provider to provider.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;JMS clients access these objects through interfaces that are portable, so a client application can run with little or no change on more than one implementation of the JMS API.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Connection Factories&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;A &lt;i&gt;connection factory &lt;/i&gt;is the object a client uses to create a connection with a provider.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;A connection factory encapsulates a set of connection configuration parameters that has been defined by an administrator.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Context ctx = &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; InitialContext();&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) ctx.lookup(&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"QueueConnectionFactory"&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;);&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) ctx.lookup(&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"TopicConnectionFactory"&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;);&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Destinations&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;A &lt;i&gt;destination &lt;/i&gt;is the object a client uses to specify the target of messages it produces&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;and the source of messages it consumes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Topic myTopic = (Topic) ctx.lookup(&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"MyTopic"&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;);&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Queue myQueue = (Queue) ctx.lookup(&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"MyQueue"&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;);&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Connections&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;A &lt;i&gt;connection &lt;/i&gt;encapsulates a virtual connection with a JMS provider. A connection could represent an open TCP/IP socket between a client and a provider service daemon. You use a connection to create one or more sessions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: 'Courier New';"&gt;QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: 'Courier New';"&gt;TopicConnection topicConnection = topicConnectionFactory.createTopicConnection();&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Sessions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;A &lt;i&gt;session &lt;/i&gt;is a single-threaded context for producing and consuming messages. You use sessions to create message producers, message consumers, and messages. Sessions serialize the execution of message listeners.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;A session provides a transactional context with which to group a set of sends and receives into an atomic unit of work.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;TopicSession topicSession = topicConnection.createTopicSession(&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;,&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Session.AUTO_ACKNOWLEDGE);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;QueueSession queueSession = queueConnection.createQueueSession(&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;true&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;, 0);&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Message Producers&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;A &lt;i&gt;message producer &lt;/i&gt;is an object created by a session and is used for sending messages to a destination. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: 'Courier New';"&gt;QueueSender queueSender = queueSession.createSender(myQueue);&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: 'Courier New';"&gt;TopicPublisher topicPublisher = topicSession.createPublisher(myTopic);&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Once you have created a message producer, you can use it to send messages.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: 'Courier New';"&gt;queueSender.send(message);&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: 'Courier New';"&gt;topicPublisher.publish(message);&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Message Consumers&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;A &lt;i&gt;message consumer &lt;/i&gt;is an object created by a session and is used for receiving messages sent to a destination. A message consumer allows a JMS client to register interest in a destination with a JMS provider. The JMS provider manages the delivery of messages from a destination to the registered consumers of the destination.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: 'Courier New';"&gt;QueueReceiver queueReceiver = queueSession.createReceiver(myQueue);&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: 'Courier New';"&gt;TopicSubscriber topicSubscriber = topicSession.createSubscriber(myTopic);&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;You use the TopicSession.createDurableSubscriber method to create a durable topic subscriber. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Message Listeners&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;A &lt;i&gt;message listener &lt;/i&gt;is an object that acts as an asynchronous event handler for messages.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;This object implements the MessageListener interface, which contains one method, onMessage. In the onMessage method, you define the actions to be taken when a message arrives.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;You register the message listener with a specific QueueReceiver or TopicSubscriber by using the setMessageListener method. For example, if you define a class named TopicListener that implements the MessageListener interface, you can register the message listener as follows:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: 'Courier New';"&gt;TopicListener topicListener = new TopicListener();&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: 'Courier New';"&gt;topicSubscriber.setMessageListener(topicListener);&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;A message listener is not specific to a particular destination type. The same listener can obtain messages from either a queue or a topic, depending on whether the listener is set by a QueueReceiver or a TopicSubscriber object. A message listener does, however, usually expect a specific message type and format. Moreover, if it needs to reply to messages, a message listener must either assume a particular destination type or obtain the destination type of the message and create a producer for that destination type.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Your onMessage method should handle all exceptions. It must not throw checked exceptions, and throwing a RuntimeException, though possible, is considered a programming error.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;The session used to create the message consumer serializes the execution of all message listeners registered with the session. At any time, only one of the session’s message listeners is running.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;In the J2EE 1.3 platform, a message-driven bean is a special kind of message listener. For details, see Section 6.2 on page 75.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Exception Handling&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;The root class for exceptions thrown by JMS API methods is JMSException. Catching JMSException provides a generic way of handling all exceptions related to the JMS API. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;8. Examples&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;span style="color: black; font-weight: bold;"&gt;Example 1 - Sending Messages to a Queue&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;/*&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Look up connection factory and queue. If either does&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * not exist, exit.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queueConnectionFactory = (QueueConnectionFactory)&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; jndiContext.lookup(&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"QueueConnectionFactory"&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="ES" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;queue = (Queue) jndiContext.lookup(queueName);&lt;/span&gt;&lt;span lang="ES" style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span lang="ES" style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;} &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (NamingException e) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ......................&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;/*&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Create connection.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Create session from connection; false means session is not transacted.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Create sender and text message.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Send messages, varying text slightly.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Send end-of-messages message.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Finally, close connection.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queueConnection = queueConnectionFactory.createQueueConnection();&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queueSession = &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 72.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;queueConnection.createQueueSession(&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 72.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Session.AUTO_ACKNOWLEDGE);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queueSender = queueSession.createSender(queue);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; message = queueSession.createTextMessage();&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;for&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; i = 0; i &amp;lt; NUM_MSGS; i++) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; message.setText(&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"This is message "&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; + (i + 1));&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queueSender.send(message);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;/*&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;* Send a non-text control message indicating end of&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;* messages.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queueSender.send(queueSession.createMessage());&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (JMSException e) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .............&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; tab-stops: 36.0pt 72.0pt 108.0pt; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;finally&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; {&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (queueConnection != &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queueConnection.close();&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (JMSException e) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .............&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 108.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;}&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Arial;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Example 2 - &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Publishing Messages to a Topic&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;/*&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 10pt;"&gt;* Look up connection factory and topic. If either does&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * not exist, exit.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; topicConnectionFactory = (TopicConnectionFactory)&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; jndiContext.lookup(&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"TopicConnectionFactory"&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; topic = (Topic) jndiContext.lookup(topicName);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (NamingException e) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ............&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;/*&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Create connection.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Create session from connection; false means session is&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * not transacted.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Create publisher and text message.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Send messages, varying text slightly.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Finally, close connection.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; topicConnection =&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; topicConnectionFactory.createTopicConnection();&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; topicSession = &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 72.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;topicConnection.createTopicSession(&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;,&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Session.AUTO_ACKNOWLEDGE);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; topicPublisher = topicSession.createPublisher(topic);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; message = topicSession.createTextMessage();&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;for&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; i = 0; i &amp;lt; NUM_MSGS; i++) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; message.setText(&lt;/span&gt;&lt;span style="color: #2a00ff; font-family: 'Courier New'; font-size: 8pt;"&gt;"This is message "&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; + (i + 1));&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; topicPublisher.publish(message);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (JMSException e) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ............&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;finally&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (topicConnection != &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; topicConnection.close();&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (JMSException e) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ............&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-align: justify; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8148007777591375750-6088151673171382742?l=azajava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azajava.blogspot.com/feeds/6088151673171382742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://azajava.blogspot.com/2009/10/1_16.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/6088151673171382742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8148007777591375750/posts/default/6088151673171382742'/><link rel='alternate' type='text/html' href='http://azajava.blogspot.com/2009/10/1_16.html' title='JMS: Basic Concepts - Part 1'/><author><name>Alvaro Vilaplana Garcia</name><uri>http://www.blogger.com/profile/11553335108218062944</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://3.bp.blogspot.com/_0QFX4__VHgo/SoaT_32jy5I/AAAAAAAAAK8/Ya9axDLsrC4/S220/ALVARO_BLOG.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_0QFX4__VHgo/StiQlmg4tQI/AAAAAAAAAOg/-onVGrTr2OU/s72-c/JMS_Architecture.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8148007777591375750.post-6519412866416085835</id><published>2009-10-06T12:48:00.011+01:00</published><updated>2009-10-06T12:57:41.601+01:00</updated><title type='text'>Exceptions in Java world: agree or not to agree, this is the question</title><content type='html'>&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;1.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Introduction&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;In this article I try to explain generic rules or tips that can be followed to try to create a robust application with decouple layers. This topic is very polemic because everybody has a particular opinion about this and actually there is &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;no a golden rule&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; to follow.&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_0QFX4__VHgo/SssumGDWukI/AAAAAAAAAOQ/cc8HI69NrKM/s1600-h/hierarchy.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_0QFX4__VHgo/SssumGDWukI/AAAAAAAAAOQ/cc8HI69NrKM/s320/hierarchy.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;2.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Exceptions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;The Java programming language provides three kinds of throwables:&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;span style="font-weight: normal;"&gt;2.1&lt;/span&gt;&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Checked exceptions &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 11px;"&gt;Checked exceptions are all subclasses of &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;java.lang.Exception, &lt;/i&gt;&lt;/b&gt;except &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;java.lang.RuntimeException&lt;/i&gt;&lt;/b&gt; and its subclasses.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 54.0pt; mso-list: l0 level3 lfo1; text-align: justify; text-indent: -36.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;span style="font-weight: normal;"&gt;2.1.1&lt;/span&gt;&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Business exceptions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 11px;"&gt;The business exceptions should be used for exceptional conditions and not for ordinary control flow. A well-designed API must not force its client to use exceptions for ordinary control flow.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;The business exceptions are used for conditions from which the caller can reasonably be expected to recover. It is important to mention that the &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;business exceptions are associated with a business semantic&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Avoid unnecessary use of business exceptions. The overuse of checked exceptions can make an API far less pleasant to use. If a method throws one or more checked exceptions, the code that invokes the method must handle the exceptions in one or more catch blocks, or it must declare that it throws the exceptions and let them propagate outward. Either way, it places a nontrivial burden on the programmer.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-size: 11px;"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; transferMoney(AccountDTO accountTo, AccountDTO accountFrom&lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt; , double&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; amount) &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;throws&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; NoSufficientFundsException&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Exception in business meaning:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;NoSufficientFundsException is thrown if you try to transfer money from an account to another account and you have no enough money.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;This checked exception bring business semantics to the caller.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 54.0pt; mso-list: l0 level3 lfo2; text-align: justify; text-indent: -36.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;2.1.2&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;‘Infrastructure’ Checked exceptions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 11px;"&gt;For example, we could consider as ‘infrastructure’ checked exceptions J2SE API checked exceptions, JEE API checked exceptions, Third Party API checked exceptions etc.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;For instance:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 108.0pt; mso-list: l1 level1 lfo1; tab-stops: list 108.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span lang="EN-GB" style="font-family: Wingdings; font-size: 8pt;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;java.io.IOException&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 108.0pt; mso-list: l1 level1 lfo1; tab-stops: list 108.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span lang="EN-GB" style="font-family: Wingdings; font-size: 8pt;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;javax.naming.NamingException&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 108.0pt; mso-list: l1 level1 lfo1; tab-stops: list 108.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span lang="EN-GB" style="font-family: Wingdings; font-size: 8pt;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;java.sql.SQLException.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 108.0pt; mso-list: l1 level1 lfo1; tab-stops: list 108.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span lang="EN-GB" style="font-family: Wingdings; font-size: 8pt;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;javax.mail.MessagingException&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 108.0pt; mso-list: l1 level1 lfo1; tab-stops: list 108.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span lang="EN-GB" style="font-family: Wingdings; font-size: 8pt;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;javax.resource.ResourceException&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 108.0pt; mso-list: l1 level1 lfo1; tab-stops: list 108.0pt; text-align: justify; text-indent: -18.0pt;"&gt;&lt;span lang="EN-GB" style="font-family: Wingdings; font-size: 8pt;"&gt;§&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;javax.ejb.FinderException.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;If an ‘infrastructure’ checked exception is thrown, it can be catch and either a business exception will be thrown up or it will be logged. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Note: The high-level classes should not know the low-level details of implementation. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Example 1.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;// Exception Translation with infrastructure checked exceptions&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;// ...&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (IOException e) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;throw&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; NotFoundResourceException();&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;}&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Example 2.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;// Exception log&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;// ...&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (&lt;u&gt;IOException&lt;/u&gt; &lt;/span&gt;&lt;span style="color: #0000c0; font-family: 'Courier New'; font-size: 8pt;"&gt;e&lt;/span&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;u&gt;e&lt;/u&gt;) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;u&gt;log&lt;/u&gt;.error(&lt;u&gt;e&lt;/u&gt;,”The resource was not found”);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;… &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;// solve the problem somehow.&lt;/span&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;div style="text-indent: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;2.2&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Unchecked exceptions &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 54.0pt; mso-list: l0 level3 lfo1; text-align: justify; text-indent: -36.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;span style="font-weight: normal;"&gt;2.2.1&lt;/span&gt;&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Runtime exceptions &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 11px;"&gt;Runtime exceptions are all subclasses of &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;java.lang.RuntimeException.&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;The runtime exceptions should not be thrown explicitly in developer java code. These exceptions mean precondition violations or &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;bugs&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;. This is simply a failure by the client of an API to adhere to the contract established by the API specification.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 54.0pt; mso-list: l0 level3 lfo1; text-align: justify; text-indent: -36.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;span style="font-weight: normal;"&gt;2.2.2&lt;/span&gt;&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Errors &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 11px;"&gt;All subclasses of &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;java.lang.Error&lt;/i&gt;&lt;/b&gt;.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;There is a strong convention that errors are reserved for use by the JVM to indicate resource deficiencies, invariant failures, or other conditions that make it impossible to continue execution. It is very recommended to extend the error class.&lt;u&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;3.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Advisable Rules&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;span style="font-weight: normal;"&gt;3.1&lt;/span&gt;&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Throw exceptions appropriate to the abstraction.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 11px;"&gt;It is disconcerting when a method throws an exception that has no apparent connection to the task that it performs. This often happens when a method propagates an exception thrown by a lower-level abstraction. This pollutes the API of the higher layer with implementation details. If the implementation of the higher layer changes in a subsequent release, the exceptions that it throws will change too, potentially breaking existing client programs.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;To avoid this problem, higher layers should catch lower-level exceptions and, in their place, throw exceptions that can me explained in terms of the higher-level abstraction. This is known as &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;exception translation&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Example 1.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #3f7f5f;"&gt;// Exception Translation&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;// Use lower-level abstraction to do our bidding&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (LowerLevelException &lt;/span&gt;&lt;i&gt;&lt;span style="color: #0000c0; font-family: 'Courier New'; font-size: 8pt;"&gt;e&lt;/span&gt;&lt;/i&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;throw&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; HigherLevelException(...);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 11px;"&gt;A special form of exception translation called &lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="color: red;"&gt;exception chaining&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; is appropriate in cases where the lower-level exception might be helpful to someone debugging the problem that caused the higher-level exception. The lower-level exception (the cause) is passed to the higher-level exception, which provides an accessor method (Throwable.getCause) to retrieve the lower-level exception:&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Example 2.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #3f7f5f;"&gt;// Exception Chaining&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;// Use lower-level abstraction to do our bidding&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (LowerLevelException cause) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;throw&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; HigherLevelException(cause);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 11px;"&gt;The higher-level exception’s constructor passes the cause to a chaining-aware superclass constructor, so it is ultimately passed to one of Throwable’s chaining-aware constructors, such as Throwable(Throwable):&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Example 3.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;//Exception with chaining-aware constructor&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Class HigherLevelException &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;extends&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; Exception {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HigherLevelException(Throwable cause){&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;super&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;(cause);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Most standard exceptions have chaining-aware constructor. For exceptions that don’t, you can set the cause using &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Throwable’s initCause method.&lt;/span&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;div style="text-indent: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;3.2&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Never declare that a method throws Exception or worse yet, throws Throwable. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;span style="font-weight: normal;"&gt;3.3&lt;/span&gt;&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Include failure-capture information in detail messages. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 11px;"&gt;To capture the failure, the detail message of an exception should contain the values of al parameters and fields that “contributed to the exception”.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Example 1.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;// Including detail message about the exception&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;// Use lower-level abstraction to do our bidding&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (LowerLevelException cause) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;throw&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; HigherLevelException(“This the cause”,cause);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span lang="EN-GB" style="font-family: 'Courier New'; font-size: 8pt;"&gt;Example 2.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 8pt;"&gt;// Including detail message about the exception&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none; text-indent: 36.0pt;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;throw&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; LowerLevelException(“This the cause”);&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;4.&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Case studies – Bank Website&lt;u&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;In this section I show different use cases with different perspective about how the exceptions are focus. We start thinking that we have an application in the way that is represented in the figure.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_0QFX4__VHgo/Sssu59etoKI/AAAAAAAAAOY/sdC0lMFH_Wk/s1600-h/Architecture.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_0QFX4__VHgo/Sssu59etoKI/AAAAAAAAAOY/sdC0lMFH_Wk/s400/Architecture.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; text-align: justify;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;span style="font-weight: normal;"&gt;4.1&lt;/span&gt;&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;Use case – Balance&lt;u&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 11px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 11px; font-weight: bold;"&gt;Client Component&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: 36.0pt; text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;…&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;Double balance = façadeBank.balanceAccount(userDTO); &amp;nbsp; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; …&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;} &lt;/span&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; (RuntimeException e) {&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; log.error(e,”Some message”);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; forward = “error_page”;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;}&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt;…&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="color: #7f0055; font-family: 'Courier New'; font-size: 8pt;"&gt;return&lt;/span&gt;&lt;/b&gt;&lt;span style="color: black; font-family: 'Courier New'; font-size: 8pt;"&gt; forward;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 8pt;"&gt;The RuntimeException can be catch in the client component but it should
