<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Frank&#039;s Java Development Blog &#187; JEE</title>
	<atom:link href="http://javablog.franksalinas.net/category/jee/feed/" rel="self" type="application/rss+xml" />
	<link>http://javablog.franksalinas.net</link>
	<description>Java Enterprise Development &#38; Technology</description>
	<lastBuildDate>Sat, 24 Jul 2010 17:06:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>JavaOne and Oracle Develop 2010</title>
		<link>http://javablog.franksalinas.net/2010/07/15/oracle-openworld-2010-registration/</link>
		<comments>http://javablog.franksalinas.net/2010/07/15/oracle-openworld-2010-registration/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 16:53:27 +0000</pubDate>
		<dc:creator>Frank Salinas</dc:creator>
				<category><![CDATA[JEE]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Training]]></category>

		<guid isPermaLink="false">http://javablog.franksalinas.net/?p=912</guid>
		<description><![CDATA[Tomorrow is the last day for early-bird registration discounts. JavaOne and Oracle Develop 2010 No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Tomorrow is the last day for early-bird registration discounts.</p>
<p><a title="JavaOne and Oracle Develop 2010" href="http://www.oracle.com/us/javaonedevelop/index.html">JavaOne and Oracle Develop 2010</a></p>

<div style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"></div>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://javablog.franksalinas.net/2010/07/15/oracle-openworld-2010-registration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Poll: Which MVC Framework Do You Use?</title>
		<link>http://javablog.franksalinas.net/2010/04/30/poll-which-mvc-framework-do-you-use/</link>
		<comments>http://javablog.franksalinas.net/2010/04/30/poll-which-mvc-framework-do-you-use/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 17:14:38 +0000</pubDate>
		<dc:creator>Frank Salinas</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Struts]]></category>
		<category><![CDATA[Struts 2]]></category>

		<guid isPermaLink="false">http://javablog.franksalinas.net/?p=815</guid>
		<description><![CDATA[At work we&#8217;re looking into swapping out Struts with a different MVC framework. I&#8217;m curious as to which frameworks are most in use today. Please complete the poll below and feel free to post comments/recommendations on the subject. Share the link and spread the word, the more data received the better! No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>At work we&#8217;re looking into swapping out Struts with a different MVC framework. I&#8217;m curious as to which frameworks are most in use today. Please complete the poll below and feel free to post comments/recommendations on the subject. Share the link and spread the word, the more data received the better!<br />
<span id="more-815"></span></p>
<p><center><script type='text/javascript' language='javascript' charset='utf-8' src='http://s3.polldaddy.com/p/3133860.js'></script><noscript> <a href='http://answers.polldaddy.com/poll/3133860/'>View Poll</a></noscript></center></p>

<div style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"></div>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://javablog.franksalinas.net/2010/04/30/poll-which-mvc-framework-do-you-use/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Java Web Services: Getting Started</title>
		<link>http://javablog.franksalinas.net/2010/03/09/java-web-services-getting-started/</link>
		<comments>http://javablog.franksalinas.net/2010/03/09/java-web-services-getting-started/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 04:49:22 +0000</pubDate>
		<dc:creator>Frank Salinas</dc:creator>
				<category><![CDATA[JBoss]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[EJB]]></category>
		<category><![CDATA[JAX-RPC]]></category>
		<category><![CDATA[JAX-WS]]></category>
		<category><![CDATA[POJO]]></category>
		<category><![CDATA[Servlet]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[WSDL]]></category>

		<guid isPermaLink="false">http://javablog.franksalinas.net/?p=640</guid>
		<description><![CDATA[When it came time for me to tackle my first web service implementation I ran into a lot of problems. Here I will write a series of articles to address the questions and problems I encountered in hopes of helping you get started in developing web services faster than I did. The following example will show [...]


Related posts:<ol><li><a href='http://javablog.franksalinas.net/2008/10/29/web-services-on-jboss/' rel='bookmark' title='Permanent Link: Web Services on JBoss'>Web Services on JBoss</a> <small>I&#8217;ve been working on a project which requires developing some...</small></li>
<li><a href='http://javablog.franksalinas.net/2009/03/01/the-ejb-specification-concurrency-and-batch-processing/' rel='bookmark' title='Permanent Link: The EJB Specification, Concurrency, and Batch Processing'>The EJB Specification, Concurrency, and Batch Processing</a> <small>The EJB specification does not leave much room for implementing...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>When it came time for me to tackle my first web service implementation I ran into a lot of problems. Here I will write a series of articles to address the questions and problems I encountered in hopes of helping you get started in developing web services faster than I did. The following example will show you how to create a web service using JAX-WS and packaged as a servlet.<span id="more-640"></span></p>
<h4>A Simple Service</h4>
<p>To start out you <span style="text-decoration: underline;">should</span> create an interface defining your business methods. I will keep the implementation extremely simple so we can focus on the details of web services. Here&#8217;s our interface named <code>SimpleServiceWS</code></p>
<pre class="brush:java; smart-tabs:true; wrap-lines:false">public interface SimpleServiceWS {

	public String simpleMethod();

}</pre>
<p>The next step is to create a plain java class (POJO) which implements this interface. I&#8217;ll name it <code>SimpleServiceImpl</code></p>
<pre class="brush:java; smart-tabs:true; wrap-lines:false">public class SimpleServiceImpl implements SimpleServiceWS {

	public String simpleMethod() {
		return "Simple response";
	}

}</pre>
<p><em><span style="color: #808080;"><span style="color: #000000;">Please note that it is not required to create and implement an interface and almost every web service example I found did not do so. I feel it is good practice and consistent with Java programming practices to program against interfaces.</span></span></em></p>
<p>What we have so far is just a plain Java class (POJO) that returns a simple string. Now we have to decorate our class with some annotations to make it behave as a web services.</p>
<pre class="brush:java; smart-tabs:true; wrap-lines:false">import javax.jws.WebService;

@WebService(
		serviceName="SimpleService",
		portName="SimpleServicePort",
		endpointInterface="net.franksalinas.javablog.SimpleServiceWS")
public class SimpleServiceImpl implements SimpleServiceWS {

	public String simpleMethod() {
		return "Simple response";
	}

}</pre>
<p>I added the <code>@WebService</code> annotation and supplied some values to the annotation attributes. You can simply add the <code>@WebService</code> annotation without specifying any of the attributes and they will pick up default values based on the class and package names. However, there is one exception. If you choose to define and implement an interface you must do two things:</p>
<ol>
<li>You must decorate the interface with the <code>@WebService</code> annotation.</li>
<li>You must also supply the <code>endpointInterface</code> annotation attribute with the fully qualified name of the interface in the implementation class.</li>
</ol>
<pre class="brush:java; smart-tabs:true; wrap-lines:false">import javax.jws.WebService;

@WebService()
public interface SimpleServiceWS {

	public String simpleMethod();

}</pre>
<p>As far as code goes this is all there is to it. The remaing steps describe how to package and deploy these objects.</p>
<h4>Package and Deploy</h4>
<p>As I mentioned above we will package and deploy these classes as a servlet implementation. I am most familiar with JBoss so that is the application server I will use but any servlet container should work fine.</p>
<p>Create a new xml file named <code>web.xml</code> and define the servlet mappings for the <code>SimpleServiceImpl</code> class as shown here.</p>
<pre class="brush:xml; smart-tabs:true; wrap-lines:false">&lt;?xml version="&gt;&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE web-app PUBLIC
	"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
	"http://java.sun.com/dtd/web-app_2_3.dtd"&gt;
&lt;web-app&gt;
	&lt;servlet&gt;
		&lt;servlet-name&gt;SimpleServiceWS&lt;/servlet-name&gt;
		&lt;servlet-class&gt;net.franksalinas.javablog.SimpleServiceImpl&lt;/servlet-class&gt;
	&lt;/servlet&gt;

	&lt;servlet-mapping&gt;
		&lt;servlet-name&gt;SimpleServiceWS&lt;/servlet-name&gt;
		&lt;url-pattern&gt;/SimpleService&lt;/url-pattern&gt;
	&lt;/servlet-mapping&gt;
&lt;/web-app&gt;</pre>
<p>Now create a <code>WEB-INF</code> directory and place this file there. Compile your Java files and place them in a folder named <code>classes</code>. Create a folder named <code>dist</code>. Copy the <code>WEB-INF</code> and <code>classes</code> directory to this new folder. Now create a JAR file named <code>SimpleService.war</code> containing the contents of <code>dist</code> directory. (Visit <a title="Sun WAR File Format (Wikipedia)" href="http://en.wikipedia.org/wiki/Sun_WAR_(file_format)" target="_blank">http://en.wikipedia.org/wiki/Sun_WAR_(file_format)</a> for more info on the WAR file structure.)</p>
<p>You should now have a WAR file with the following structure:</p>
<pre class="brush:xml; smart-tabs:true; wrap-lines:false">META-INF/
META-INF/MANIFEST.MF
WEB-INF/
WEB-INF/web.xml
classes/
classes/net/
classes/net/franksalinas/
classes/net/franksalinas/javablog/
classes/net/franksalinas/javablog/SimpleServiceImpl.class
classes/net/franksalinas/javablog/SimpleServiceWS.class</pre>
<p>Now you can copy this <code>SimpleService.war</code> file to your application server&#8217;s deployment directory <em>(&lt;jboss_home&gt;/server/default/deploy</em>) and start the server. Your web service will be deployed. On JBoss you can see the deployment and access the WSDL for the service at url http://127.0.0.1:8080/SimpleService/SimpleService?wsdl</p>
<p>That&#8217;s all there is to it!</p>
<p><em>Note that we did not implement the <code>javax.servlet.http.HttpServlet</code> interface in the service class. It is not required but may be considered good practice to do so depdending on your implementation.</em></p>
<h4>Summary</h4>
<p>In this example we created a simple web service using JAX-WS and packaged and deployed the implementation as a servlet configuration. We learned that web services are nothing more than plain old Java objects (POJOs) that are decorated with a few simple annotations and that servlet configurations do not require the web service class to implement the <code>javax.servlet.http.HttpServlet</code> interface. We covered packaging the code as a WAR file and deploying on the JBoss application server.</p>
<p>This is a very simple example and there&#8217;s a lot more material to cover. I hope you found this posting informative and helpful. You can download all the source code for this example here: <a href="http://javablog.franksalinas.net/wp-content/uploads/2010/02/SimpleService.zip">SimpleService.zip</a>.</p>
<p><a title="Sun WAR File Format (Wikipedia)" href="http://en.wikipedia.org/wiki/Sun_WAR_(file_format)" target="_blank"></a></p>

<div style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"></div>

<p>Related posts:<ol><li><a href='http://javablog.franksalinas.net/2008/10/29/web-services-on-jboss/' rel='bookmark' title='Permanent Link: Web Services on JBoss'>Web Services on JBoss</a> <small>I&#8217;ve been working on a project which requires developing some...</small></li>
<li><a href='http://javablog.franksalinas.net/2009/03/01/the-ejb-specification-concurrency-and-batch-processing/' rel='bookmark' title='Permanent Link: The EJB Specification, Concurrency, and Batch Processing'>The EJB Specification, Concurrency, and Batch Processing</a> <small>The EJB specification does not leave much room for implementing...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://javablog.franksalinas.net/2010/03/09/java-web-services-getting-started/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The EJB Specification, Concurrency, and Batch Processing</title>
		<link>http://javablog.franksalinas.net/2009/03/01/the-ejb-specification-concurrency-and-batch-processing/</link>
		<comments>http://javablog.franksalinas.net/2009/03/01/the-ejb-specification-concurrency-and-batch-processing/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 19:54:51 +0000</pubDate>
		<dc:creator>Frank Salinas</dc:creator>
				<category><![CDATA[JBoss]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Batch Processing]]></category>
		<category><![CDATA[Concurrency]]></category>
		<category><![CDATA[EJB]]></category>
		<category><![CDATA[JMS]]></category>
		<category><![CDATA[Specifications]]></category>
		<category><![CDATA[ThreadPoolExecutor]]></category>
		<category><![CDATA[Threads]]></category>

		<guid isPermaLink="false">http://javablog.franksalinas.net/?p=211</guid>
		<description><![CDATA[The EJB specification does not leave much room for implementing concurrent processing within the EJB container. This poses a problem to developers who need to implement solutions for processing long running batch processes as part of the business logic of an application. The EJB specification states the following: The enterprise bean must not attempt to [...]


Related posts:<ol><li><a href='http://javablog.franksalinas.net/2010/03/09/java-web-services-getting-started/' rel='bookmark' title='Permanent Link: Java Web Services: Getting Started'>Java Web Services: Getting Started</a> <small>When it came time for me to tackle my first...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The EJB specification does not leave much room for implementing concurrent processing within the EJB container. This poses a problem to developers who need to implement solutions for processing long running batch processes as part of the business logic of an application. The EJB specification states the following:</p>
<blockquote><p>The enterprise bean must not attempt to manage threads. The enterprise bean must not attempt to start, stop, suspend, or resume a thread, or to change a thread’s priority or name. The enterprise bean must not attempt to manage thread groups.</p>
<p><em>These functions are reserved for the EJB container. Allowing the enterprise bean to manage threads would decrease the container’s ability to properly manage the runtime environment.</em></p></blockquote>
<p><span id="more-211"></span>Researching this topic I found that while the specification states the restrictions, the EJB containers do not actually enforce the rule. I was able to test an implementation using a ThreadPoolExecutor in JBoss with no problems. Most implementations addressing long running batch processing solutions specify developing applications outside the EJB container. While the design respects the EJB programming restrictions it is not always a feasible solution for developers. Currently, I am confronted with business requirements to process a large set of files within the process flow of a business method.  The process flow would be to select files based on some criteria, specify what to do with the file collection, and submit the task asynchronously as a background process through JMS to a message-driven bean (MDB) for processing. When the job is done, update the database with the new file paths and notify the user of successful completion. There are several underlying issues:</p>
<ol>
<li>The user submits a request to process a very large set of files. The time to process this request may take hours to complete and will most-likely exceed the default configured transaction time-out of the message-driven bean at which point a TransactionTimeOut Exception is thrown and the operation halts. This can be overcome to a certain extent by increasing the transaction timeout period in the application server settings.</li>
<li>The single large task executes in a sequential manner, and does not take advantage of all available CPU&#8217;s on a multi-processor machine.</li>
<li>It would be more efficient and reduce execution time if the task could be broken up into smaller tasks (or batches) and executed in parallel, or distributed across a group of servers which can process each sub-task individually.</li>
</ol>
<p>The design concepts are relatively simple but the implementation details are complex due to the programming restrictions in the EJB specification. This screams concurrency! The most commonly suggested solution for concurrency is to use JMS. One solution I found is to break up the task, create multiple JMS messages that reply to an acknowledgment queue. Then set the Session Bean to listen to that ack queue using a message filter to collect the results of each sub-task. This is a good solution but a bit more complex to implement than bending the rules and using a ThreadPoolExecutor. I think the real issue with managing threads within the EJB container is the topic of <a href="http://www.oreillynet.com/cs/user/view/cs_msg/17107" target="_blank">reentrancy</a>. In my case, I am calling a remote service so there is no chance of that.</p>
<p>There are many factors to consider when implementing a batch processing framework for your application. There is no one size fits all solution. You really have to evaluate all the options, weigh the pros and cons of each, and decide on your own which approach works best in your environment. Here is a list of articles I found very helpful in making that decision:</p>
<ul>
<li><a title="High Performance Batch Processing" href="http://java.sys-con.com/node/415321" target="_blank">High Performance Batch Processing with Java Enterprise Edition</a></li>
<li><a href="http://www.javaworld.com/javaworld/jw-07-2003/jw-0718-mdb.html?page=1" target="_blank">Add Concurrent Processing with Message Driven Beans</a></li>
<li><a href="http://www.devx.com/Java/Article/20184/0/page/1" target="_blank">JMS Enables Concurrent Processing in EJB</a></li>
<li><a href="http://www.devx.com/java/article/20791" target="_blank">High Volume Transaction Processing in J2EE</a></li>
</ul>

<div style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"></div>

<p>Related posts:<ol><li><a href='http://javablog.franksalinas.net/2010/03/09/java-web-services-getting-started/' rel='bookmark' title='Permanent Link: Java Web Services: Getting Started'>Java Web Services: Getting Started</a> <small>When it came time for me to tackle my first...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://javablog.franksalinas.net/2009/03/01/the-ejb-specification-concurrency-and-batch-processing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)

Served from: javablog.franksalinas.net @ 2010-09-06 08:48:43 -->