<?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; Java</title>
	<atom:link href="http://javablog.franksalinas.net/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://javablog.franksalinas.net</link>
	<description>Java Enterprise Development &#38; Technology</description>
	<lastBuildDate>Sat, 26 Feb 2011 20:59:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Java&#8217;s Future Exist in the Enterprise</title>
		<link>http://javablog.franksalinas.net/2011/01/28/javas-future-exist-in-the-enterprise/</link>
		<comments>http://javablog.franksalinas.net/2011/01/28/javas-future-exist-in-the-enterprise/#comments</comments>
		<pubDate>Fri, 28 Jan 2011 15:40:32 +0000</pubDate>
		<dc:creator>Frank Salinas</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[Assembler]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[COBAL]]></category>

		<guid isPermaLink="false">http://javablog.franksalinas.net/?p=1001</guid>
		<description><![CDATA[This comes as no surprise to me as in my opinion the primary strength of Java lies with it&#8217;s enterprise abilities. Forrester&#8217;s authors say that its report, &#8220;The Future of Java,&#8221; is not a Java obituary. Java is still dominant in the enterprise but no programming language has retained a central position through multiple platform [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>This comes as no surprise to me as in my opinion the primary strength of Java lies with it&#8217;s enterprise abilities.</p>
<blockquote><p>Forrester&#8217;s authors say that its report, &#8220;The Future of Java,&#8221; is not a Java obituary. Java is still dominant in the enterprise but no programming language has retained a central position through multiple platform changes. Java will evolve just as Assembler, C and COBOL did. More so, the core message here is for application developers and how applications are distributed.</p>
<p>&#8230;</p>
<p>Oracle controls the future of Java but its road map has been accepted and that means no major disruptions for enterprise customers. But it&#8217;s clear that Java is no longer the center for technology innovation. The innovation is now on the platforms and with Ruby and open environments such as HTML 5.</p></blockquote>
<p>via <a href="http://www.readwriteweb.com/enterprise/2011/01/why-the-future-of-java-is-with.php">Why The Future of Java is with Large Customers, not Innovative, Young Developers</a>.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://javablog.franksalinas.net/2011/01/28/javas-future-exist-in-the-enterprise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is Java Losing Appeal?</title>
		<link>http://javablog.franksalinas.net/2010/10/18/is-java-losing-appeal/</link>
		<comments>http://javablog.franksalinas.net/2010/10/18/is-java-losing-appeal/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 04:58:40 +0000</pubDate>
		<dc:creator>Frank Salinas</dc:creator>
				<category><![CDATA[Career]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[JRuby]]></category>
		<category><![CDATA[JVM]]></category>
		<category><![CDATA[Jython]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://javablog.franksalinas.net/?p=927</guid>
		<description><![CDATA[Is Java on it's way to being phased out by newer JVM languages?
No related posts.]]></description>
			<content:encoded><![CDATA[<blockquote><p>My theory goes like this: Good java developers are hard to find because fewer and fewer of them are being created. New developers are not choosing java to “cut their teeth” on. And I suspect that coming from whatever they are coming from, java doesn’t look appealing.</p></blockquote>
<p>via <a href="http://goodgroovy.wordpress.com/2010/10/14/i-think-i-figured-out-why-good-java-developers-are-so-hard-to-find/">I think I figured out why good Java developers are so hard to find « I love groovy</a>.</p>
<p>The excerpt above came from a <a href="http://goodgroovy.wordpress.com/2010/10/14/i-think-i-figured-out-why-good-java-developers-are-so-hard-to-find/" target="_blank">blog post</a> I read this morning. It made me ask the question: Is Java on it&#8217;s way to being phased out by newer JVM languages? <span id="more-927"></span>Judging by some of the comments to this article at least a few believe so. But which JVM language has the potential to replace it? I found this article: <a href="http://www.jroller.com/scolebourne/entry/the_next_big_jvm_language1">The Next Big JVM Language </a>which evaluates a few contenders.</p>
<p>Java is not sexy to the next generation of developers. The language is considered old, bloated, overly complex and has more than a few legacy quirks which fuel many language debates. Scala, Jython/Python, JRuby/Ruby and Groovy all seem to be popular alternatives.</p>
<blockquote cite="#commentbody-71"><p><strong><a href="#comment-71">headpower</a> :</strong></p>
<p>I’m a 15 year old person studying to become a developer (mostly in my free time), and I can tell you that Java is not something I would ever consider. I consider myself to “know” Python and [Objective-]C, but, Java isn’t even on my radar. I know some people my age who would use Java, but to me it just seems outdated and bloated to most of us, I think.</p>
<p>Since I guess I’m the “next generation”, it doesn’t seem that your situation is going to get any better…</p></blockquote>
<p>According to these sources:  <a href="http://www.numberof.net/number-of-java-developers/" target="_blank">http://www.numberof.net/number-of-java-developers/</a> and<a href="http://jaxenter.com/how-many-java-developers-are-there-10462.html" target="_blank"> http://jaxenter.com/how-many-java-developers-are-there-10462.html</a> there are 9,007,346 Java developers world-wide. That&#8217;s a very large and active user base. While it seems that Java may not be the choice of the next-generation of developers it is still the primary language for over 9 million developers.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://javablog.franksalinas.net/2010/10/18/is-java-losing-appeal/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<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[Java]]></category>
		<category><![CDATA[JEE]]></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>
<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>Best Practices: Avoid Returning Null</title>
		<link>http://javablog.franksalinas.net/2010/06/09/avoid-returning-null/</link>
		<comments>http://javablog.franksalinas.net/2010/06/09/avoid-returning-null/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 03:36:59 +0000</pubDate>
		<dc:creator>Frank Salinas</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Null]]></category>
		<category><![CDATA[NullPointerException]]></category>
		<category><![CDATA[RuntimeException]]></category>

		<guid isPermaLink="false">http://javablog.franksalinas.net/?p=836</guid>
		<description><![CDATA[A few simple tips to avoid generating NullPointerException in your code.
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I recall the first oddity that struck me about Java programming is that it seems common practice to test returned objects for <code>null</code>. I find it frustrating and inefficient to scatter if conditions throughout my code just to see if I have a valid object instance returned. <span id="more-836"></span></p>
<p>Receiving null is confusing. When you make a function call and the result is null what does it mean? Was the data not found? Was there an exception in the function that was silently swallowed resulting in the return of a null object? You&#8217;re not really sure if null is an expected return value. If no exception is thrown then you just kind of assume that null is a valid return value. However, you can&#8217;t really do anything with the returned null object so what do you do now?</p>
<p>Here are a couple of alternatives to returning null:</p>
<h2>Use the Empty Collection Methods</h2>
<p>If you are working with returning collection objects from your function you should return an empty collection rather than a null object. This is very easy to do with the Collections class. There are three static methods available:</p>
<ul>
<li>Collections.emptyList()</li>
<li>Collections.emptySet()</li>
<li>Collections.emptyMap()</li>
</ul>
<p>An empty List is easily instantiated for return as shown here:</p>
<pre class="brush:java; smart-tabs:true; wrap-lines:false">   List&lt;String&gt; myList = Collections.emptyList();</pre>
<p>Returning an empty List eliminates the required check for null by the function caller. Now instead of having code which looks like this:</p>
<pre class="brush:java; smart-tabs:true; wrap-lines:false">   List&lt;String&gt; names = getNames();
   if(names != null) {
      for(String name : names) {
         System.out.println(name);
      }
   }</pre>
<p>You can simply write the following without worrying about a NullPointerException:</p>
<pre class="brush:java; smart-tabs:true; wrap-lines:false">   List&lt;String&gt; names = getNames();
   for(String name : names) {
      System.out.println(name);
   }</pre>
<p>This second example is much cleaner, easier to read and understand. Returning empty Collections is much safer as well since it avoids the potential run time exception: NullPointerException.</p>
<p>An unchecked exception represent defects in the program (bugs) - often invalid arguments passed to a non-private method. To quote from <em>The Java Programming Language</em>, by Gosling, Arnold, and Holmes : &#8220;Unchecked runtime exceptions represent conditions that, generally speaking, reflect errors in your program&#8217;s logic and cannot be reasonably recovered from at run time.&#8221; <a href="#citation">[1]</a></p>
<p>Certainly an empty collection is not a bug! So lets just return an empty collection rather than a null reference. In addition, testing for an empty collection is a lot more intuitive than testing for null.</p>
<pre class="brush:java; smart-tabs:true; wrap-lines:false">   List&lt;String&gt; names = getNames();
   if(names.isEmpty()) {
      //throw an Exception
      //or do something else
      //or do nothing at all

   }</pre>
<h2>Throw an Exception</h2>
<p>It&#8217;s perfectly acceptable to throw a custom checked exception alerting the calling client that the requested object cannot be populated or retrieved. This approach is much more revealing and forces the calling client to handle the potential problem. It also eliminates the need to check the returned object for null.</p>
<p>A checked exception is guaranteed to be handled so you gain more control over your program. A RuntimeException may or may not be handled by the caller and will bubble up until either it is caught or reaches the top of the caller chain.</p>
<h2>Conclusion</h2>
<p>Nulls are useful under certain conditions when null values are expected. However, for the above conditions with collections and data retrieval I feel it has been abused. Use the empty collection and avoid returning null objects whenever possible. It will make code cleaner, easier to read and debug.</p>
<hr />
<h4 id="citation">Citations:</h4>
<p>1. &#8220;checked versus uncheck exceptions&#8221; J<span style="text-decoration: underline;">avaPractices.com</span>. 2010 Hirondelle Systems. 6 June 2010 &lt;<a href="http://www.javapractices.com/topic/TopicAction.do?Id=129" target="_blank">http://www.javapractices.com/topic/TopicAction.do?Id=129</a>&gt;</p>
<hr />
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://javablog.franksalinas.net/2010/06/09/avoid-returning-null/feed/</wfw:commentRss>
		<slash:comments>5</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[Java]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[JEE]]></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[A short tutorial on getting started with Java Web Services (JWS) using the JAX-WS API. Sample code is provided along with step-by-step instructions.
Related posts:<ol>
<li><a href='http://javablog.franksalinas.net/2008/10/29/web-services-on-jboss/' rel='bookmark' title='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='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>
<p>Related posts:<ol>
<li><a href='http://javablog.franksalinas.net/2008/10/29/web-services-on-jboss/' rel='bookmark' title='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='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>Java tip: How to read files quickly &#124; Nadeau Software</title>
		<link>http://javablog.franksalinas.net/2009/11/25/java-tip-how-to-read-files-quickly-nadeau-software/</link>
		<comments>http://javablog.franksalinas.net/2009/11/25/java-tip-how-to-read-files-quickly-nadeau-software/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 20:10:06 +0000</pubDate>
		<dc:creator>Frank Salinas</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[BufferedInputStream]]></category>
		<category><![CDATA[FileChannel]]></category>
		<category><![CDATA[FileInputStream]]></category>
		<category><![CDATA[I/O]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://javablog.franksalinas.net/2009/11/25/java-tip-how-to-read-files-quickly-nadeau-software/</guid>
		<description><![CDATA[Here’s a good article comparing the performance of various File I/O implementations.&#160; I was particularly interested in the performance difference between the BufferedInputStream and the FileChannel. Java tip: How to read files quickly &#124; Nadeau Software No related posts.
No related posts.]]></description>
			<content:encoded><![CDATA[<p>Here’s a good article comparing the performance of various File I/O implementations.&#160; I was particularly interested in the performance difference between the BufferedInputStream and the FileChannel. </p>
<p><a href="http://nadeausoftware.com/articles/2008/02/java_tip_how_read_files_quickly#BufferedInputStreamwithbytearrayreads" title="Java tip: How to read files quickly | Nadeau Software">Java tip: How to read files quickly | Nadeau Software</a></p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://javablog.franksalinas.net/2009/11/25/java-tip-how-to-read-files-quickly-nadeau-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use final</title>
		<link>http://javablog.franksalinas.net/2009/10/27/use-final-judiciously/</link>
		<comments>http://javablog.franksalinas.net/2009/10/27/use-final-judiciously/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 04:19:07 +0000</pubDate>
		<dc:creator>Frank Salinas</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Final]]></category>

		<guid isPermaLink="false">http://javablog.franksalinas.net/?p=574</guid>
		<description><![CDATA[The final keyword is one that I find is under utilized. Use final in your projects as a means of defensive programming. If you are unfamiliar with this keyword here is a great article on its usage. Renaud Waldura&#8217;s The Final Word On the final Keyword . No related posts.
No related posts.]]></description>
			<content:encoded><![CDATA[<p>The final keyword is one that I find is under utilized. Use final in your projects as a means of defensive programming. If you are unfamiliar with this keyword here is a great article on its usage.</p>
<p><a href="http://renaud.waldura.com/doc/java/final-keyword.shtml">Renaud Waldura&#8217;s The Final Word On the final Keyword </a>.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://javablog.franksalinas.net/2009/10/27/use-final-judiciously/feed/</wfw:commentRss>
		<slash:comments>2</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[Java]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[JEE]]></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='Java Web Services: Getting Started'>Java Web Services: Getting Started</a> <small>A short tutorial on getting started with Java Web Services...</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>
<p>Related posts:<ol>
<li><a href='http://javablog.franksalinas.net/2010/03/09/java-web-services-getting-started/' rel='bookmark' title='Java Web Services: Getting Started'>Java Web Services: Getting Started</a> <small>A short tutorial on getting started with Java Web Services...</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>
		<item>
		<title>Enforce Data Integrity With Check Constraints</title>
		<link>http://javablog.franksalinas.net/2008/11/23/enforce-data-integrity-with-check-constraints/</link>
		<comments>http://javablog.franksalinas.net/2008/11/23/enforce-data-integrity-with-check-constraints/#comments</comments>
		<pubDate>Sun, 23 Nov 2008 17:25:39 +0000</pubDate>
		<dc:creator>Frank Salinas</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[Programming 101]]></category>

		<guid isPermaLink="false">http://javablog.franksalinas.net/?p=175</guid>
		<description><![CDATA[A short rant about using check constraints in your database.
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I came across some code the other day that simply horrified me. I was looking at a table that had a field name which implied it stored a boolean value (e.g. IS_LAUGHABLE). The field type is defined as a char(1), allows NULL values and defined no default value. Looking at the data in the column I found a combination of the following values: T, F, Y, and N.<span id="more-175"></span></p>
<p>I didn&#8217;t know what to do. I wanted to insert a new row but could not decide which value is correct to denote for boolean true or false? Then I thought how would the code handle these values? The above value combinations make it impossible to use the ternary operator to retrieve the desired boolean value such as:</p>
<pre class="brush:java; smart-tabs:true; wrap-lines:false">
boolean isLaughable =
    resultSet.getString("is_laughable").equals("Y")?true:false);</pre>
<p>Then I found that someone had gone through the trouble of creating a utility method to convert the various character values to the desired boolean output of true or false. The method looked something like this:</p>
<pre class="brush:java; smart-tabs:true; wrap-lines:false" >static public boolean getBooleanFromString(String attr)
{
  if ( attr == null ) {
		return false ;
  }
  boolean val = false;

  if ("true".equalsIgnoreCase(attr)
         || "t".equalsIgnoreCase(attr)
         || "y".equalsIgnoreCase(attr)
         || "yes".equalsIgnoreCase(attr))
  {
		val = true;
  }

  return val;
}</pre>
<p>I couldn&#8217;t believe it! Instead of cleansing the data they just applied a Band-Aid to get around the issue. This is not the proper way to store this type of data. Possible values for this field can only be one of two values; true or false. Physically what characters represent those values is up to the developer. However since it represents a boolean value it should not allow more than two values to be inserted nor should it allow NULL values.</p>
<p>The proper action to take here is to clean up the data and add a check constraint to the table to restrict the data stored in this field. This can be done with two simple ALTER statements:</p>
<pre class="brush:sql; smart-tabs:true wrap-lines:false">ALTER TABLE jokes
ADD IS_LAUGHABLE char(1) DEFAULT 'N' NOT NULL; 

ALTER TABLE jokes
ADD CONSTRAINT jokes_is_laughable_ck
CHECK (IS_LAUGHABLE IN('Y','N'));</pre>
<p>Adding check constraints to your database will greatly increase data integrity, reduce data related bugs and make programming easier since you know exactly what values to expect from the database. Any situation where you have a finite list of values such as boolean values, or state (e.g. Error, Success, Processing, etc) are good candidates for value check constraints. Use good judgment and leverage check constraints to your advantage.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://javablog.franksalinas.net/2008/11/23/enforce-data-integrity-with-check-constraints/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java vs. .NET: Job Market and Salary Survey</title>
		<link>http://javablog.franksalinas.net/2008/11/22/java-vs-net-job-market-and-salary-survey/</link>
		<comments>http://javablog.franksalinas.net/2008/11/22/java-vs-net-job-market-and-salary-survey/#comments</comments>
		<pubDate>Sun, 23 Nov 2008 03:27:15 +0000</pubDate>
		<dc:creator>Frank Salinas</dc:creator>
				<category><![CDATA[Career]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Salary]]></category>

		<guid isPermaLink="false">http://javablog.franksalinas.net/?p=102</guid>
		<description><![CDATA[A salary comparison between J2EE and .NET Architect/Lead and Developer roles in the San Francisco Bay Area.
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I was recently contacted about a technology job search engine named OdinJobs.com. I took a look a the site and found that they have some great tools for job market analysis and salary surveys. Here I compared salaries and job market trends between J2EE and .NET Architect/Lead and Developer roles in the San Francisco Bay Area.<br />
<span id="more-102"></span></p>
<h2>Median Salary</h2>
<p>As you can see from the data below the median salary between the two technologies is comparable with .NET having a slightly higher median salary for Architect/Lead roles and Java/J2EE having a higher median salary for Developer roles.</p>
<table style="font-size:80%" border="0">
<tbody>
<tr>
<td colspan="2"><img src="http://www.odinjobs.com/Odin/mediansalary?id=6362&amp;q=.NET vs J2EE" alt="" /></td>
</tr>
<tr>
<td align="left">Generated By: <img src="http://www.odinjobs.com/favicon.ico" alt="" />OdinJobs &#8211; <a href="http://www.odinjobs.com">IT Jobs and Technology Job Search Engine</a></td>
</tr>
</tbody>
</table>
<table style="font-size:80%" border="0">
<tbody>
<tr>
<td colspan="2"><img src="http://www.odinjobs.com/Odin/mediansalary?id=6365&amp;q=.NET vs J2EE" alt="" /></td>
</tr>
<tr>
<td align="left">Generated By: <img src="http://www.odinjobs.com/favicon.ico" alt="" />OdinJobs &#8211; <a href="http://www.odinjobs.com">IT Jobs and Technology Job Search Engine</a></td>
</tr>
</tbody>
</table>
<h2>Job Trends</h2>
<p>The job trends charts shows that there is a higher demand for J2EE Architect/Lead roles than for .NET. There also appears to have been a spike in job listings for J2EE Architect/Lead roles in recent months while job trends for Developer roles are comparable between the two technologies. Both charts show an increase in job listings in 2008 over 2007.</p>
<table style="font-size:80%" border="0">
<tbody>
<tr>
<td colspan="2"><img src="http://www.odinjobs.com/Odin/jobstrendline?id=6362&amp;q=.NET vs J2EE" alt="" /></td>
</tr>
<tr>
<td align="left">Generated By: <img src="http://www.odinjobs.com/favicon.ico" alt="" />OdinJobs &#8211; <a href="http://www.odinjobs.com">IT Jobs and Technology Job Search Engine</a></td>
</tr>
</tbody>
</table>
<table style="font-size:80%" border="0">
<tbody>
<tr>
<td colspan="2"><img src="http://www.odinjobs.com/Odin/jobstrendline?id=6365&amp;q=.NET vs J2EE" alt="" /></td>
</tr>
<tr>
<td align="left">Generated By: <img src="http://www.odinjobs.com/favicon.ico" alt="" />OdinJobs &#8211; <a href="http://www.odinjobs.com">IT Jobs and Technology Job Search Engine</a></td>
</tr>
</tbody>
</table>
<h2>Salary Histogram</h2>
<p>The salary histograms show that the salary range for Architect/Lead roles is between $80k and $120k, and $70k and $100k for Developer roles depending on experience. Both histograms show outlying salary data around the $150k range which I suspect represents Director level positions.</p>
<table style="font-size:80%" border="0">
<tbody>
<tr>
<td colspan="2"><img src="http://www.odinjobs.com/Odin/salaryhistogram?id=6362&amp;q=.NET vs J2EE" alt="" /></td>
</tr>
<tr>
<td align="left">Generated By: <img src="http://www.odinjobs.com/favicon.ico" alt="" />OdinJobs &#8211; <a href="http://www.odinjobs.com">IT Jobs and Technology Job Search Engine</a></td>
</tr>
</tbody>
</table>
<table style="font-size:80%" border="0">
<tbody>
<tr>
<td colspan="2"><img src="http://www.odinjobs.com/Odin/salaryhistogram?id=6365&amp;q=.NET vs J2EE" alt="" /></td>
</tr>
<tr>
<td align="left">Generated By: <img src="http://www.odinjobs.com/favicon.ico" alt="" />OdinJobs &#8211; <a href="http://www.odinjobs.com">IT Jobs and Technology Job Search Engine</a></td>
</tr>
</tbody>
</table>
<h2>Conclusion</h2>
<p>The job market seems solid for both technologies and salaries are comparable. Java/J2EE seems to have a slight advantage in demand and salary but it is evident that you can make a great career specializing in Java or .NET with plenty of room for career advancement. The <a href="http://www.odinjobs.com/">OdinJobs</a> web site provides additional functionality to compare job market trends and salary in different locations as well as specific job roles and company types. It&#8217;s interesting to see which industries specific technologies are in demand.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://javablog.franksalinas.net/2008/11/22/java-vs-net-job-market-and-salary-survey/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: javablog.franksalinas.net @ 2012-02-04 16:55:45 -->
