<?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>Tallan&#039;s Technology Blog &#187; Java</title>
	<atom:link href="http://blog.tallan.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tallan.com</link>
	<description>Tallan&#039;s Top Technologists Share Their Thoughts on Today&#039;s Technology Challenges</description>
	<lastBuildDate>Fri, 03 Feb 2012 17:23:33 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Java EE 6 Overview</title>
		<link>http://blog.tallan.com/2011/02/01/java-ee-6-overview/</link>
		<comments>http://blog.tallan.com/2011/02/01/java-ee-6-overview/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 00:26:59 +0000</pubDate>
		<dc:creator>Dylan Barrett</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=975</guid>
		<description><![CDATA[Introduction
For the past year or so I have been working on a web development project using Java.  Like many Java projects, the project I was working on used 3rd party frameworks like Spring and Hibernate rather than utilizing the official Java EE stack.  Many developers have turned to these frameworks because the official Java EE [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>For the past year or so I have been working on a web development project using Java.  Like many Java projects, the project I was working on used 3rd party frameworks like Spring and Hibernate rather than utilizing the official Java EE stack.  Many developers have turned to these frameworks because the official Java EE stack had been notoriously cumbersome and difficult to use.  That is starting to change.  Java EE 5 started moving Java EE in a new direction.  Inspired by the ideologies of the 3rd party frameworks, the JCP, the standards community that works on the Java specification, began to make radical changes to the core of Java EE.  These changes have continued in the latest iteration, Java EE 6.</p>
<p>Interested in comparing Java EE 6 to my experiences with Spring and Hibernate, I picked up a book on the topic and began playing around with some code.  It was easy to see the influence of Spring and Hibernate in components such as JPA, Java EE&#8217;s ORM solution; a dependency injection component; and a focus on using POJOs.  The purpose of this article will be to give a brief overview of the core Java EE 6 technologies.</p>
<h2>Java Persistence API</h2>
<p>The Java Persistence API (JPA) is Java EE&#8217;s ORM solution.  It is meant to be a replacement for EJB Entity Beans, which have been deprecated in Java EE 6.  If you are familiar with Hibernate, then you will feel right at home with JPA.  In fact, many Hibernate developers played a role in the design and development of JPA.  For those of you unfamiliar with Object-Relational Mapping (ORM); it is a technique used to map your programs domain objects to the tables of your database.  ORMs usually make it very easy to perform CRUD operations on your data as well provide you with methods to query the underlying database using your object model rather than a standard SQL query.  ORMs commonly abstract away the underlying database and present a clean, cross-database API for accessing data.  JPA, like the latest versions of Hibernate, allow two methods of mapping your classes to the database: XML and annotations.  Following the trends of the day, use of annotations is encouraged over XML, but both are fully supported.  Using JPA is easy.  You only have to create a single, simple XML file containing database connection information, place the appropriate JPA annotations on your, and then you are ready to go!</p>
<h2>Enterprise JavaBeans</h2>
<p>Enterprise JavaBeans (EJB) is Java EE&#8217;s business layer solution.  The EJBs are where you will place most of your business logic.  The EJB engine will take care of many cross cutting concerns such as transactions and security for you.  EJB was heavily frowned upon in previous versions for being very heavy-weight and complicated.  Starting with version 3, EJB received a complete makeover.  It is now much more lightweight.  You can work almost entirely with POJOs and no longer need to inherit from EJB classes.  Like the rest of Java EE 6, EJB uses convention over configuration so the very little configuration you do have to do can be done using simple annotations.  There are two main types of EJB: Session Beans and Message Driven Beans.</p>
<p>Session Beans themselves can be classified into three types: Stateless, Stateful, and Singleton.  Stateless session beans are great for functionality that does not need to maintain state.  For example, a bean that simply queries the database to received the latest news updates can be stateless.  Because state does not need to be maintained, stateless beans can be kept in a pool and reused for multiple requests.  Stateful Beans are good for situations where you need to maintain state, such as keeping track of a customers shopping cart.  Stateful beans stay alive for the duration of the session.  Finally, Singleton Beans can be used for logic that you want to have available globally.  Only a single copy of Singleton bean is created and it is shared by all requests.</p>
<p>Message Driven Beans (MDB) are used to receive messages from Java Message Service (JMS).  An MDB can subscribe to messaging queues and can act on messages that appear in the queue.</p>
<h2>JavaServer Faces</h2>
<p>JavaServer Faces (JSF) is Java EE&#8217;s presentation technology.  It is similar to ASP.NET Web Forms in that it uses controls, called components in JSF, that emit HTML code.  Unlike ASP.NET Web Forms, however, JSF is an MVC framework.  Previous versions of JSF used JSPs as the view engine.  In Java EE 6, Facelets are the default view engine.  Unlike JSPs, Facelets are valid XML files that work a lot better with the JSF component model.  The model can be accessed through something called a managed bean.  A managed bean is a simple POJO that is annotated as a managed bean.  The properties of the managed bean can be used directly in the facelet and can be bound to the components.</p>
<h2>Other Changes</h2>
<p>The latest version of Java EE also provides dependency injection functionality.  This makes your application more loosely coupled and also helps make unit testing easier.  As mentioned earlier, Java EE 6 favors the use of annotations over XML configuration.  The people who complained of &#8220;XML Hell&#8221; in previous versions of Java EE can breathe a sigh of relief.  Convention over configuration has also taken a hold in the Java EE world.  Instead of having developers create a ton of configuration, Java EE will default to using reasonable defaults and allow for configuration when you wish to override the defaults.  This combined with the use of annotations over XML allows you to hit the ground running with Java EE faster than ever before!</p>
<h2>Conclusion</h2>
<p>Overall, I feel that Java EE 6 is a huge step in the right direction.  I think JPA is great and very comparable to Hibernate.  EJB has been improved a lot and is now much easier to use.  As far as JSF goes, I prefer to use a framework like Spring MVC with JSPs as the view engine.  I think that the JSP view engine is very powerful and I like working close to the HTML rather than abstracting it away.  Others may definitely enjoy the power of JSF though.  I feel that dependency injection in Java EE is a little lacking compared to what is available in Spring.  I would say that if you are working on an existing project using Spring or another third party framework, you probably shouldn&#8217;t bother changing over to Java EE 6.  However, if you are starting out on a new project, I would take a look at Java EE 6.  It is powerful and much easier to use now, having learned a lot from frameworks like Spring and Hibernate.</p>
<h3>Want to learn more?</h3>
<p>I recommend the book <a href="http://www.amazon.com/Beginning-GlassFish-Experts-Voice-Technology/dp/143022889X/ref=sr_1_1?ie=UTF8&amp;qid=1296519896&amp;sr=8-1">Beginning Java EE 6 Platform with Glassfish 3</a> by Antonio Goncalves.  It is well written and gives a great overview of development with Java EE 6.</p>
<p>-Dylan</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2011/02/01/java-ee-6-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Unstandard Tag Library: Using Constants Within JSPs</title>
		<link>http://blog.tallan.com/2010/07/01/the-unstandard-tag-library-using-constants-within-jsps/</link>
		<comments>http://blog.tallan.com/2010/07/01/the-unstandard-tag-library-using-constants-within-jsps/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 14:18:20 +0000</pubDate>
		<dc:creator>Dylan Barrett</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JSP]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=536</guid>
		<description><![CDATA[Introduction
The Unstandard Tag Library is a JSP tag library that was developed as part of the Jakarta Project.  Its purpose is to provide a collection       of useful tags that people have been requesting for JSTL.  The library serves as a place to keep all of these tags [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>The Unstandard Tag Library is a JSP tag library that was developed as part of the Jakarta Project.  Its purpose is to provide a collection       of useful tags that people have been requesting for JSTL.  The library serves as a place to keep all of these tags until they are officially added to       the Standard Tag Library.  This article focuses on the use of one of the tags contained within the library, the useConstants tag.</p>
<h2>The Problem</h2>
<p>While working on a project for a client, I realized that they were using a Java class with constants to define strings used within the application.       The idea was to use the constants everywhere in the application where the strings were needed so they could easily be maintained in one location without       having to search through the whole application when making a change.  This makes sense, and is a common best practice.  I was working on a JSP page that       needed to use the constants from the class.  It is now considered bad practice to use Java Scriptlets in your JSP page.  It is much better to use the       Expression Language (EL) in combination with JSTL and other custom tags.  Trying to keep to this rule I quickly ran into a problem.  The EL does not allow       and easy way to access constants from a Java class.  That is where the Unstandard Tag Library&#8217;s useConstants tag comes in handy.</p>
<h2>How To Use It</h2>
<p>Once you have added the library to your project it is very simple to use.  Let&#8217;s assume we have a java class containing constants such as the one below:</p>
<pre class="brush: java;">
package com.tallan.unstandard;  

public class MyConstants {    

  public static final String MY_CONSTANT_1 = 'Hello World';
  public static final String MY_CONSTANT_2 = 'Goodbye World';  

}
</pre>
<p>Let&#8217;s also assume that we added the tag library to our page as follows:</p>
<pre class="brush: xml;">
&lt;%@ taglib uri=&quot;http://jakarta.apache.org/taglibs/unstandard-1.0&quot;
           prefix=&quot;un&quot;%&gt;
</pre>
<p>We can then utilize the useConstants tag as follows:</p>
<pre class="brush: xml;">
&lt;un:useConstants var=&quot;Constants&quot;
                 className=&quot;com.tallan.unstandard.MyConstants&quot; /&gt;
</pre>
<p>After we run this line of code, an object called Constants will be available for use on the page.  We can use it with the EL and access the constants as       properties of the object.  For example:</p>
<pre class="brush: xml;">
&lt;p&gt;${Constants.MY_CONSTANT_1}&lt;/p&gt;
</pre>
<p>This solves our problem of using constants from a Java class within a JSP page without relying on scriptlets.</p>
<h2>Where To Get It</h2>
<p>You may be thinking &#8220;This is great, but where can I find this library?&#8221;  Unfortunately the Jakarta project has stopped development of the library and no       longer makes it obvious where you can get the code.  If you look around on the Jakarta site you will find that they allow you to get the project out of       source control and build it with Maven, but this is a little bit of a hassle.  If you want an easier way to get the library just go       <a href="http://people.apache.org/builds/jakarta-taglibs-sandbox/nightly/projects/unstandard/jakarta-taglibs-sandbox-unstandard-20060829.zip">here</a>.       This site contains old binaries of the library and they should work just fine.</p>
<h2>Conclusion</h2>
<p>The Unstandard Tag Library contains many useful tags that can help in the development of our JSP pages.  While it is no longer being actively developed, it can still       be a very useful tool.  We covered how to access constants from a Java class using the library&#8217;s useConstants tag.</p>
<h3>Want to Learn More?</h3>
<p>If you want to learn more about the tags available in the Unstandard Tag Library and how to use them, then head over to the documentation page for the library       located <a href="http://jakarta.apache.org/taglibs/sandbox/doc/unstandard-doc/index.html">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2010/07/01/the-unstandard-tag-library-using-constants-within-jsps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java could be a pain to C# developers (Pass by Reference)</title>
		<link>http://blog.tallan.com/2009/03/06/java-could-be-a-pain-to-c-developers-pass-by-reference/</link>
		<comments>http://blog.tallan.com/2009/03/06/java-could-be-a-pain-to-c-developers-pass-by-reference/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 20:18:04 +0000</pubDate>
		<dc:creator>seung</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[How To Guide]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Pass by Reference in Java]]></category>

		<guid isPermaLink="false">http://blogs.tallan.com/dotnetreflections/?p=108</guid>
		<description><![CDATA[In C++ and C#, developers have freedom to modify variables by directly having  access to memory location.
In C++,
#include &#60;stdio.h&#62;
void swapnum(int &#38;i, int &#38;j)
{
     int temp = i;
     i = j;
     j =  temp;
} 

int main(void)
{
     int a [...]]]></description>
			<content:encoded><![CDATA[<p>In C++ and C#, developers have freedom to modify variables by directly having  access to memory location.</p>
<p>In C++,</p>
<pre>#include &lt;stdio.h&gt;
void swapnum(int &amp;i, int &amp;j)
{
     int temp = i;
     i = j;
     j =  temp;
} 

int main(void)
{
     int a = 10;
     int b = 20;
     swapnum(a, b);
     printf("A is %d and B is %d\n", a, b);
     return  0;
}</pre>
<p>In C#,</p>
<pre>int a = 1;
modify(ref a); //now a=2
void modify(ref int a)
{
     a = 2;
}</pre>
<p>In Java, however, there&#8217;s no such thing as pass by reference. Even the  so-called pointers (created by &#8216;new&#8217; operator) are passed by copy of the  reference.</p>
<p>Thus, if you do the following,</p>
<pre>String a = "a";
modify(a); //a doesn't change, since a is being passed as  a copy of the pointer a.
void modify(String a)
{
     a = "b"
     //this a  is a different pointer, thus does not affect the real 'a' pointer outside of the  method.
}</pre>
<p>As you can see, there&#8217;s no direct way of modifying the variable. This has  become a problem for me in many cases, since from time to time, it is necessary  to have direct access to the variables.</p>
<p>The answer is by using a wrapper.</p>
<p>Here&#8217;s an example.</p>
<pre>String a = "a";
System.out.println(a); // 'a' gets printed
String[]  array = new String[]{a}; //add a copy of the pointer variable a to String  array
modify(array);
System.out.println(array[0]);

void modify(String[] array)
{
     array[0] = "b";
}</pre>
<p>This is not the most elegant way of doing it, but you get the idea.  <img src='http://blog.tallan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>One thing to remember is that String[] array contains a copy of pointer &#8216;a&#8217;.  When you assign, or add, items to any collections such as array, you&#8217;re passing  a copy of a pointer. So the variable &#8216;a&#8217; in the example above still is pointing  to the value &#8216;a&#8217;, whereas array[0] points to &#8216;b&#8217;. In order to finalize the  pointer modification, you need to assign</p>
<pre>a = array[0].</pre>
<p>So, the basic idea is this: In Java, when you pass variables around, whether  they are pointers or primitive values, you&#8217;re always dealing with a copy of the  variables, not the variables themselves. If you understand the basic idea of  it, you can take advantage of the true &#8220;Pass by Reference&#8221;.</p>
<p>I hope this sort of &#8216;trick/hack&#8217; can be of help to you all. <img src='http://blog.tallan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>-Seung Kim (SK)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2009/03/06/java-could-be-a-pain-to-c-developers-pass-by-reference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

