<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.rifidi.net/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.rifidi.net/index.php?action=history&amp;feed=atom&amp;title=Northwind_TagLocationService</id>
		<title>Northwind TagLocationService - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.rifidi.net/index.php?action=history&amp;feed=atom&amp;title=Northwind_TagLocationService"/>
		<link rel="alternate" type="text/html" href="https://wiki.rifidi.net/index.php?title=Northwind_TagLocationService&amp;action=history"/>
		<updated>2026-04-26T08:27:48Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.1</generator>

	<entry>
		<id>https://wiki.rifidi.net/index.php?title=Northwind_TagLocationService&amp;diff=2787&amp;oldid=prev</id>
		<title>Gustavo.cabral: /* Write a JMS Listener */</title>
		<link rel="alternate" type="text/html" href="https://wiki.rifidi.net/index.php?title=Northwind_TagLocationService&amp;diff=2787&amp;oldid=prev"/>
				<updated>2010-06-03T17:14:34Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Write a JMS Listener&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 17:14, 3 June 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 237:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 237:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Write a JMS Listener===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Write a JMS Listener===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Create a new class called &amp;lt;tt&amp;gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;MessageReceiever&lt;/del&gt;&amp;lt;/tt&amp;gt; in the &amp;lt;tt&amp;gt;com.northwind.rfid.shipping.war&amp;lt;/tt&amp;gt; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;pacakge&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Create a new class called &amp;lt;tt&amp;gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;MessageReceiver&lt;/ins&gt;&amp;lt;/tt&amp;gt; in the &amp;lt;tt&amp;gt;com.northwind.rfid.shipping.war&amp;lt;/tt&amp;gt; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;package&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;package com.northwind.rfid.shipping.war;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;package com.northwind.rfid.shipping.war;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Gustavo.cabral</name></author>	</entry>

	<entry>
		<id>https://wiki.rifidi.net/index.php?title=Northwind_TagLocationService&amp;diff=2624&amp;oldid=prev</id>
		<title>Kyle at 22:38, 24 November 2009</title>
		<link rel="alternate" type="text/html" href="https://wiki.rifidi.net/index.php?title=Northwind_TagLocationService&amp;diff=2624&amp;oldid=prev"/>
				<updated>2009-11-24T22:38:51Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 22:38, 24 November 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Write at TagLocation Service&lt;/del&gt;==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;This is Step 8 in the [[Northwind Tutorial|Northwind Application Tutorial]]&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Previous Step: [[Northwind Hello World Servlet | Step 7: Write a Hello World Servlet]]&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Next Step: [[Northwind Display Events using JSP: Step 9: Display events in a JSP]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;=What you will learn=&lt;/ins&gt;==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;* How to use a service to manage events&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;* How to receive and process events over JMS&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Now that we have all the MVC plumbing working, we need to hook up the RFID application with the web application.&amp;#160; We will do this by creating a service that the controller can use to find out the list of tags at each stage.&amp;#160; Then we will write a JMS listener who will update the service with the latest information.&amp;#160; Finally we will inject the service into the contoller.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Now that we have all the MVC plumbing working, we need to hook up the RFID application with the web application.&amp;#160; We will do this by creating a service that the controller can use to find out the list of tags at each stage.&amp;#160; Then we will write a JMS listener who will update the service with the latest information.&amp;#160; Finally we will inject the service into the contoller.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Write a Service Interface===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Write a Service Interface===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kyle</name></author>	</entry>

	<entry>
		<id>https://wiki.rifidi.net/index.php?title=Northwind_TagLocationService&amp;diff=2594&amp;oldid=prev</id>
		<title>Kyle: New page: ==Write at TagLocation Service== Now that we have all the MVC plumbing working, we need to hook up the RFID application with the web application.  We will do this by creating a service tha...</title>
		<link rel="alternate" type="text/html" href="https://wiki.rifidi.net/index.php?title=Northwind_TagLocationService&amp;diff=2594&amp;oldid=prev"/>
				<updated>2009-11-24T19:22:07Z</updated>
		
		<summary type="html">&lt;p&gt;New page: ==Write at TagLocation Service== Now that we have all the MVC plumbing working, we need to hook up the RFID application with the web application.  We will do this by creating a service tha...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Write at TagLocation Service==&lt;br /&gt;
Now that we have all the MVC plumbing working, we need to hook up the RFID application with the web application.  We will do this by creating a service that the controller can use to find out the list of tags at each stage.  Then we will write a JMS listener who will update the service with the latest information.  Finally we will inject the service into the contoller.&lt;br /&gt;
===Write a Service Interface===&lt;br /&gt;
* Create a new package called &amp;lt;tt&amp;gt;com.northwind.rfid.shipping.war.service&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Create a new Interface called &amp;lt;tt&amp;gt;TagLocationService&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package com.northwind.rfid.shipping.war.service;&lt;br /&gt;
&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import com.northwind.rfid.shipping.notifications.AlertNotification;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * This service provides the current list of tags at the Dock Door and the Weigh&lt;br /&gt;
 * Station, as well as all the alerts that have happened so far&lt;br /&gt;
 * &lt;br /&gt;
 * @author Kyle Neumeier - kyle@pramari.com&lt;br /&gt;
 * &lt;br /&gt;
 */&lt;br /&gt;
public interface TagLocationService {&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get a list of all packages at the dock door&lt;br /&gt;
	 * &lt;br /&gt;
	 * @return&lt;br /&gt;
	 */&lt;br /&gt;
	List&amp;lt;String&amp;gt; getDockDoorItems();&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get a list of all packages at the Weigh Station&lt;br /&gt;
	 * &lt;br /&gt;
	 * @return&lt;br /&gt;
	 */&lt;br /&gt;
	List&amp;lt;String&amp;gt; getWeighStationItems();&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get a list of all the alerts&lt;br /&gt;
	 * &lt;br /&gt;
	 * @return&lt;br /&gt;
	 */&lt;br /&gt;
	List&amp;lt;AlertNotification&amp;gt; getAlerts();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Write a Manager Interface===&lt;br /&gt;
The &amp;lt;tt&amp;gt;TagLocationService&amp;lt;/tt&amp;gt; interface allows a component to consume information.  We also need the ability to add data to the service as it arrives.  As such, let's create a second interface with the required methods.&lt;br /&gt;
* Create a new package called &amp;lt;tt&amp;gt;com.northwind.rfid.shipping.war.service.impl&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Create a new Interface called &amp;lt;tt&amp;gt;TagLocationServiceManager&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package com.northwind.rfid.shipping.war.service.impl;&lt;br /&gt;
&lt;br /&gt;
import com.northwind.rfid.shipping.notifications.AlertNotification;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * The manager of the TagLocationService. It allows a component to add data.&lt;br /&gt;
 * &lt;br /&gt;
 * @author Kyle Neumeier - kyle@pramari.com&lt;br /&gt;
 * &lt;br /&gt;
 */&lt;br /&gt;
public interface TagLocationServiceManager {&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Called when a new package has arrived at the dockdoor&lt;br /&gt;
	 * &lt;br /&gt;
	 * @param item&lt;br /&gt;
	 */&lt;br /&gt;
	void PackageArrivedAtDockDoor(String item);&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Called when a package departs from the dock door&lt;br /&gt;
	 * &lt;br /&gt;
	 * @param item&lt;br /&gt;
	 */&lt;br /&gt;
	void PackageDepartedFromDockDoor(String item);&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Called when an item arrives at the weigh station&lt;br /&gt;
	 * &lt;br /&gt;
	 * @param item&lt;br /&gt;
	 */&lt;br /&gt;
	void PackageArrivedAtWeighStation(String item);&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Called when an item departs from the weigh station&lt;br /&gt;
	 * &lt;br /&gt;
	 * @param item&lt;br /&gt;
	 */&lt;br /&gt;
	void PackageDepartedFromWeighStation(String item);&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Called when a new alert happens&lt;br /&gt;
	 * &lt;br /&gt;
	 * @param notification&lt;br /&gt;
	 */&lt;br /&gt;
	void Alert(AlertNotification notification);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Implement the Service===&lt;br /&gt;
Create a class called &amp;lt;tt&amp;gt;TagLocationServiceImpl&amp;lt;/tt&amp;gt; in the &amp;lt;tt&amp;gt;com.northwind.rfid.shipping.war.service.impl&amp;lt;/tt&amp;gt; package.&lt;br /&gt;
There are a few considerations to take into account:&lt;br /&gt;
# The class needs to be thread-safe, since multiple threads might access the class.  In our case, there are two: The JMS thread will call the manager methods, while the servlet thread will call the service methods.  In order to prevent any race conditions, I wrapped the three data structures in synchronized collections.  I also made sure to copy the collections before I returned them.&lt;br /&gt;
# We probably want to preserve the ordering that tags were inserted into the lists, however we don't want to store one tag more than once in each data structure.  Therefore, I used a LinkedHashSet.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package com.northwind.rfid.shipping.war.service.impl;&lt;br /&gt;
&lt;br /&gt;
import java.util.Collections;&lt;br /&gt;
import java.util.LinkedHashSet;&lt;br /&gt;
import java.util.LinkedList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
&lt;br /&gt;
import com.northwind.rfid.shipping.notifications.AlertNotification;&lt;br /&gt;
import com.northwind.rfid.shipping.war.service.TagLocationService;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Thread-safe implementation of TagLocationService and TagLocationServiceManager&lt;br /&gt;
 * interfaces.&lt;br /&gt;
 * &lt;br /&gt;
 * @author Kyle Neumeier - kyle@pramari.com&lt;br /&gt;
 * &lt;br /&gt;
 */&lt;br /&gt;
public class TagLocationServiceImpl implements TagLocationService,&lt;br /&gt;
		TagLocationServiceManager {&lt;br /&gt;
&lt;br /&gt;
	/** All the items that can be seen at dock door */&lt;br /&gt;
	private final Set&amp;lt;String&amp;gt; dockDoor = Collections&lt;br /&gt;
			.synchronizedSet(new LinkedHashSet&amp;lt;String&amp;gt;());&lt;br /&gt;
	/** All the items that can be seen at the weigh station */&lt;br /&gt;
	private final Set&amp;lt;String&amp;gt; weighstation = Collections&lt;br /&gt;
			.synchronizedSet(new LinkedHashSet&amp;lt;String&amp;gt;());&lt;br /&gt;
	/** All the alerts that have been created */&lt;br /&gt;
	private final List&amp;lt;AlertNotification&amp;gt; alerts = Collections&lt;br /&gt;
			.synchronizedList(new LinkedList&amp;lt;AlertNotification&amp;gt;());&lt;br /&gt;
&lt;br /&gt;
	/*&lt;br /&gt;
	 * (non-Javadoc)&lt;br /&gt;
	 * &lt;br /&gt;
	 * @see&lt;br /&gt;
	 * com.northwind.rfid.shipping.war.service.TagLocationService#getAlerts()&lt;br /&gt;
	 */&lt;br /&gt;
	@Override&lt;br /&gt;
	public List&amp;lt;AlertNotification&amp;gt; getAlerts() {&lt;br /&gt;
		return new LinkedList&amp;lt;AlertNotification&amp;gt;(alerts);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/*&lt;br /&gt;
	 * (non-Javadoc)&lt;br /&gt;
	 * &lt;br /&gt;
	 * @see&lt;br /&gt;
	 * com.northwind.rfid.shipping.war.service.TagLocationService#getDockDoorItems&lt;br /&gt;
	 * ()&lt;br /&gt;
	 */&lt;br /&gt;
	@Override&lt;br /&gt;
	public List&amp;lt;String&amp;gt; getDockDoorItems() {&lt;br /&gt;
		return new LinkedList&amp;lt;String&amp;gt;(dockDoor);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/*&lt;br /&gt;
	 * (non-Javadoc)&lt;br /&gt;
	 * &lt;br /&gt;
	 * @seecom.northwind.rfid.shipping.war.service.TagLocationService#&lt;br /&gt;
	 * getWeighStationItems()&lt;br /&gt;
	 */&lt;br /&gt;
	@Override&lt;br /&gt;
	public List&amp;lt;String&amp;gt; getWeighStationItems() {&lt;br /&gt;
		return new LinkedList&amp;lt;String&amp;gt;(weighstation);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/*&lt;br /&gt;
	 * (non-Javadoc)&lt;br /&gt;
	 * &lt;br /&gt;
	 * @see&lt;br /&gt;
	 * com.northwind.rfid.shipping.war.service.impl.TagLocationServiceManager&lt;br /&gt;
	 * #Alert(com.northwind.rfid.shipping.notifications.AlertNotification)&lt;br /&gt;
	 */&lt;br /&gt;
	@Override&lt;br /&gt;
	public void Alert(AlertNotification notification) {&lt;br /&gt;
		this.alerts.add(notification);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/*&lt;br /&gt;
	 * (non-Javadoc)&lt;br /&gt;
	 * &lt;br /&gt;
	 * @see&lt;br /&gt;
	 * com.northwind.rfid.shipping.war.service.impl.TagLocationServiceManager&lt;br /&gt;
	 * #PackageArrivedAtDockDoor(java.lang.String)&lt;br /&gt;
	 */&lt;br /&gt;
	@Override&lt;br /&gt;
	public void PackageArrivedAtDockDoor(String item) {&lt;br /&gt;
		this.dockDoor.add(item);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/*&lt;br /&gt;
	 * (non-Javadoc)&lt;br /&gt;
	 * &lt;br /&gt;
	 * @see&lt;br /&gt;
	 * com.northwind.rfid.shipping.war.service.impl.TagLocationServiceManager&lt;br /&gt;
	 * #PackageArrivedAtWeighStation(java.lang.String)&lt;br /&gt;
	 */&lt;br /&gt;
	@Override&lt;br /&gt;
	public void PackageArrivedAtWeighStation(String item) {&lt;br /&gt;
		this.weighstation.add(item);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/*&lt;br /&gt;
	 * (non-Javadoc)&lt;br /&gt;
	 * &lt;br /&gt;
	 * @see&lt;br /&gt;
	 * com.northwind.rfid.shipping.war.service.impl.TagLocationServiceManager&lt;br /&gt;
	 * #PackageDepartedFromDockDoor(java.lang.String)&lt;br /&gt;
	 */&lt;br /&gt;
	@Override&lt;br /&gt;
	public void PackageDepartedFromDockDoor(String item) {&lt;br /&gt;
		this.dockDoor.remove(item);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/*&lt;br /&gt;
	 * (non-Javadoc)&lt;br /&gt;
	 * &lt;br /&gt;
	 * @see&lt;br /&gt;
	 * com.northwind.rfid.shipping.war.service.impl.TagLocationServiceManager&lt;br /&gt;
	 * #PackageDepartedFromWeighStation(java.lang.String)&lt;br /&gt;
	 */&lt;br /&gt;
	@Override&lt;br /&gt;
	public void PackageDepartedFromWeighStation(String item) {&lt;br /&gt;
		this.weighstation.remove(item);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Write a JMS Listener===&lt;br /&gt;
Create a new class called &amp;lt;tt&amp;gt;MessageReceiever&amp;lt;/tt&amp;gt; in the &amp;lt;tt&amp;gt;com.northwind.rfid.shipping.war&amp;lt;/tt&amp;gt; pacakge.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package com.northwind.rfid.shipping.war;&lt;br /&gt;
&lt;br /&gt;
import java.io.ByteArrayInputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.ObjectInputStream;&lt;br /&gt;
&lt;br /&gt;
import javax.jms.BytesMessage;&lt;br /&gt;
import javax.jms.JMSException;&lt;br /&gt;
import javax.jms.Message;&lt;br /&gt;
import javax.jms.MessageListener;&lt;br /&gt;
&lt;br /&gt;
import com.northwind.rfid.shipping.notifications.AlertNotification;&lt;br /&gt;
import com.northwind.rfid.shipping.notifications.EZone;&lt;br /&gt;
import com.northwind.rfid.shipping.notifications.ItemArrivalNotification;&lt;br /&gt;
import com.northwind.rfid.shipping.notifications.ItemDepartureNotification;&lt;br /&gt;
import com.northwind.rfid.shipping.war.service.impl.TagLocationServiceManager;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * The class that implements the logic of receiving a notification from JMS&lt;br /&gt;
 * using the TagLocationServiceManager to update the TagLocationService&lt;br /&gt;
 * &lt;br /&gt;
 * @author Kyle Neumeier - kyle@pramari.com&lt;br /&gt;
 * &lt;br /&gt;
 */&lt;br /&gt;
public class MessageReceiver implements MessageListener {&lt;br /&gt;
&lt;br /&gt;
	/** The TagLocationServiceManager to use */&lt;br /&gt;
	private volatile TagLocationServiceManager TLSManager;&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Called by spring&lt;br /&gt;
	 * &lt;br /&gt;
	 * @param TLSManager&lt;br /&gt;
	 *            The TagLocationServiceManager&lt;br /&gt;
	 */&lt;br /&gt;
	public void setTLSManager(TagLocationServiceManager TLSManager) {&lt;br /&gt;
		this.TLSManager = TLSManager;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/*&lt;br /&gt;
	 * (non-Javadoc)&lt;br /&gt;
	 * &lt;br /&gt;
	 * @see javax.jms.MessageListener#onMessage(javax.jms.Message)&lt;br /&gt;
	 */&lt;br /&gt;
	@Override&lt;br /&gt;
	public void onMessage(Message arg0) {&lt;br /&gt;
		if (arg0 instanceof BytesMessage) {&lt;br /&gt;
			try {&lt;br /&gt;
				// deserialize the message&lt;br /&gt;
				Object message = deserialize((BytesMessage) arg0);&lt;br /&gt;
				if (message instanceof ItemArrivalNotification) {&lt;br /&gt;
					// If the message is an ItemArrival&lt;br /&gt;
					ItemArrivalNotification notification = (ItemArrivalNotification) message;&lt;br /&gt;
					if (notification.getZone() == EZone.DOCK_DOOR) {&lt;br /&gt;
						// If it arrived at the dock door&lt;br /&gt;
						TLSManager.PackageArrivedAtDockDoor(notification&lt;br /&gt;
								.getTag_Id());&lt;br /&gt;
					} else {&lt;br /&gt;
						// otherwise it arrived at the weigh station&lt;br /&gt;
						TLSManager.PackageArrivedAtWeighStation(notification&lt;br /&gt;
								.getTag_Id());&lt;br /&gt;
					}&lt;br /&gt;
				} else if (message instanceof ItemDepartureNotification) {&lt;br /&gt;
					// if the message is an Item Departure&lt;br /&gt;
					ItemDepartureNotification notification = (ItemDepartureNotification) message;&lt;br /&gt;
					if (notification.getZone() == EZone.DOCK_DOOR) {&lt;br /&gt;
						// If it departed from the dock door&lt;br /&gt;
						TLSManager.PackageDepartedFromDockDoor(notification&lt;br /&gt;
								.getTag_Id());&lt;br /&gt;
					} else {&lt;br /&gt;
						// otherwise it departed from the weigh station&lt;br /&gt;
						TLSManager.PackageDepartedFromWeighStation(notification&lt;br /&gt;
								.getTag_Id());&lt;br /&gt;
					}&lt;br /&gt;
				} else if (message instanceof AlertNotification) {&lt;br /&gt;
					// if the message is an alert&lt;br /&gt;
					TLSManager.Alert((AlertNotification) message);&lt;br /&gt;
				} else {&lt;br /&gt;
					System.out.println(&amp;quot;Notification type not recognized&amp;quot;);&lt;br /&gt;
				}&lt;br /&gt;
			} catch (JMSException e) {&lt;br /&gt;
				e.printStackTrace();&lt;br /&gt;
			} catch (IOException e) {&lt;br /&gt;
				e.printStackTrace();&lt;br /&gt;
			} catch (ClassNotFoundException e) {&lt;br /&gt;
				e.printStackTrace();&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/***&lt;br /&gt;
	 * A private helper method that deserializes the incoming JMS notifications&lt;br /&gt;
	 * &lt;br /&gt;
	 * @param message&lt;br /&gt;
	 *            The message to deserialize&lt;br /&gt;
	 * @return&lt;br /&gt;
	 * @throws JMSException&lt;br /&gt;
	 * @throws IOException&lt;br /&gt;
	 * @throws ClassNotFoundException&lt;br /&gt;
	 */&lt;br /&gt;
	private Object deserialize(BytesMessage message) throws JMSException,&lt;br /&gt;
			IOException, ClassNotFoundException {&lt;br /&gt;
		int length = (int) message.getBodyLength();&lt;br /&gt;
		byte[] bytes = new byte[length];&lt;br /&gt;
		message.readBytes(bytes);&lt;br /&gt;
		ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(&lt;br /&gt;
				bytes));&lt;br /&gt;
		return in.readObject();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kyle</name></author>	</entry>

	</feed>