<?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>Java tutorial for beginners, Java projects and Java sample programs, J2EE Projects, Java web application development, application servers and Java Frameworks</title>
	<atom:link href="http://www.deknight.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.deknight.com</link>
	<description>Java ORM frameworks like Hibernate and iBatis, Persistent frameworks and EJB Java WebService development tutorial, Programming in Hadoop, Hbase and Cassandra. Learn Java Quickly- Advanced Java,JSP,JSF,JSTL,Servlets,JDBC,EJB,Web Services,Spring MVC,Spring Validator framework, Spring Dependency injection, Spring IoC or Inversion of Control and Java build tools like ANT, Maven etc.</description>
	<lastBuildDate>Fri, 04 May 2012 22:08:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>SQL Tuning &#8211; SQL Optimization &#8211; Query Optimization</title>
		<link>http://www.deknight.com/sql/sql-tuning-sql-optimization-query-optimization.html</link>
		<comments>http://www.deknight.com/sql/sql-tuning-sql-optimization-query-optimization.html#comments</comments>
		<pubDate>Fri, 04 May 2012 21:29:23 +0000</pubDate>
		<dc:creator>jaisonpjohn</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Query Optimization]]></category>
		<category><![CDATA[SQL Optimization]]></category>
		<category><![CDATA[SQL Tuning]]></category>

		<guid isPermaLink="false">http://www.deknight.com/?p=111</guid>
		<description><![CDATA[&#160; SQL Tuning has a critical role in code performance. If you take SQL Tuning light, it will definitely screw up your entire code performance no matter whatever optimization you have done on your Java middle layer and front end.  Of course, its important that you should design your application in such a way that it will do your desired [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-5264876235537030";
/* 336x280, created 12/5/09 */
google_ad_slot = "1618689741";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
SQL Tuning has a critical role in code performance. If you take SQL Tuning light, it will definitely screw up your entire code performance no matter whatever optimization you have done on your Java middle layer and front end.  Of course, its important that you should design your application in such a way that it will do your desired task with the minimal database hit. But, here we are talking about how your SQL query can be optimized so that it will take the minimum time to do your database operations (SELECT, CREATE, INSERT etc). Believe me, SQL Tuning is gonna make a BIG difference in your application&#8217;s overall performance.</p>
<h3>Try to avoid &#8220;SELECT * FROM&#8221;</h3>
<p>Use the actual column names to be selected in the SELECT statement instead of &#8220;SELECT * FROM&#8221;. The SQL Query becomes considerably faster if you use the actual column names in SELECT statement. Let me say, this is one among the basic lessons in SQL Tuning school (Even newbies to SQL Tuning should be aware of this).</p>
<p>For example:</p>
<p>Write the Query as</p>
<pre class="brush: sql; gutter: true">SELECT id, first_name, last_name, age, subject FROM student_details;</pre>
<p>Instead of:</p>
<pre class="brush: sql; gutter: true">SELECT * FROM student_details;</pre>
<h3>Avoid using &#8220;HAVING&#8221; in place of &#8220;WHERE&#8221;</h3>
<p>&#8220;HAVING&#8221; clause is used to filter the rows after all the rows are selected. It is just like a filter, do not use it as an alternative to &#8220;WHERE&#8221;</p>
<p>For example:</p>
<p>Write the Query as</p>
<pre class="brush: sql; gutter: true">SELECT subject, count(subject)
FROM student_details
WHERE subject != &#039;Science&#039;</pre>
<p>Instead of:</p>
<pre class="brush: sql; gutter: true">SELECT subject, count(subject)
FROM student_details
HAVING subject != &#039;Science&#039;;</pre>
<p>Keep in mind that you have to use &#8220;HAVING&#8221; clause in some particular cases, no other go. Example: If the HAVING clause is applied to aggregate functions, it cannot be replaced by WHERE. I mean to say, just for the sake of SQL Tuning you cannot replace every &#8220;HAVING&#8221; with &#8220;WHERE&#8221;.</p>
<h3>Minimize number of subqueries</h3>
<p>Sometimes you may have more than one subqueries in your main query. Try to minimize the number of subquery-block in your query.</p>
<p>For example:</p>
<p>Write the query as</p>
<pre class="brush: sql; gutter: true">SELECT name
FROM employee
WHERE (salary, age ) = (SELECT MAX (salary), MAX (age)
FROM employee_details)
AND dept = &#039;Electronics&#039;;</pre>
<p>Instead of:</p>
<pre class="brush: sql; gutter: true">SELECT name
FROM employee
WHERE salary = (SELECT MAX(salary) FROM employee_details)
AND age = (SELECT MAX(age) FROM employee_details)
AND emp_dept = &#039;Electronics&#039;;</pre>
<h3>Use operators EXISTS and IN appropriately</h3>
<ul>
<li>Usually IN has the slowest performance.</li>
<li>IN is efficient when most of the filter criteria is in the sub-query.</li>
<li>EXISTS is efficient when most of the filter criteria is in the main query.</li>
</ul>
<p>For example:</p>
<p>Write the query as</p>
<pre class="brush: sql; gutter: true">SELECT name, department_id
FROM department,
WHERE NOT EXISTS
(SELECT department_id
FROM employee
WHERE department.department_id=employee.department_id)</pre>
<p>Instead of:</p>
<pre class="brush: sql; gutter: true">SELECT name, department_id
FROM department
WHERE department_id NOT IN
(SELECT department_id FROM employee)</pre>
<h3>Use &#8220;GROUP BY&#8221; instead of &#8220;DISTINCT&#8221;</h3>
<p>This is another basic lesson in SQL Tuning. Avoid using &#8220;DISTINCT&#8221; when you can use GROUP BY</p>
<p>For example:</p>
<p>Write the query as</p>
<pre class="brush: sql; gutter: true">select col1 from table1 group by col1;</pre>
<p>Instead of:</p>
<pre class="brush: sql; gutter: true">select distinct col1 from table1;</pre>
<h3>Use UNION ALL instead of UNION</h3>
<p>UNION requires a sort operation to eliminate any rows that are duplicated across the two row sets. UNION ALL returns all rows, even if they are duplicated. If duplicated rows are not important, or if you are sure there won&#8217;t be any duplicate rows, using UNION ALL can avoid potentially expensive sorts, merges, and filtering operations.</p>
<p>For example:</p>
<p>Write the query as</p>
<pre class="brush: sql; gutter: true">SELECT acct_num, balance_amt
FROM debit_transactions
WHERE tran_date = `31-DEC-99&#039;
UNION ALL
SELECT acct_num, balance_amt
FROM credit_transactions
WHERE tran_date = `31-DEC-99&#039;;</pre>
<p>Instead of:</p>
<pre class="brush: sql; gutter: true">SELECT acct_num, balance_amt
FROM debit_transactions
WHERE tran_date = `31-DEC-99&#039;
UNION
SELECT acct_num, balance_amt
FROM credit_transactions
WHERE tran_date = `31-DEC-99&#039;;</pre>
<h3>Avoid unnecessary use of Aggregate Functions</h3>
<p>While considering SQL optimization, Aggregate Functions are costly, use it only if its necessary</p>
<p>For example:</p>
<p>Write the query as</p>
<pre class="brush: sql; gutter: true">SELECT id, first_name, age
FROM student_details
WHERE first_name LIKE &#039;Chan%&#039;;</pre>
<p>Instead of:</p>
<pre class="brush: sql; gutter: true">SELECT id, first_name, age
FROM student_details
WHERE SUBSTR(first_name,1,3) = &#039;Cha&#039;;</pre>
<h3>Make use of available Operators</h3>
<p>If operators are avilable for your desired task, use it instead of writing it on your own.</p>
<p>For example:</p>
<p>Write the query as</p>
<pre class="brush: sql; gutter: true">SELECT product_id, product_name
FROM product
WHERE unit_price BETWEEN MAX(unit_price) and MIN(unit_price);</pre>
<p>Instead of:</p>
<pre class="brush: sql; gutter: true">SELECT product_id, product_name
FROM product
WHERE unit_price &gt;= MAX(unit_price)
and unit_price &lt;= MIN(unit_price);</pre>
<p><strong>Please note:</strong> BETWEEN operates behaves differently in different databases. For some databases BETWEEN operator will return all the value between lower and upper limit, for some databases it will return values including the upper and lower limit, for some others it will return values including either one of the limits.</p>
<h3>Avoid Unnecessary Operations</h3>
<p>This optimization is non specific to SQL tuning, its applicable in all sort of programming language.</p>
<p>For example:</p>
<p>Write the query as</p>
<pre class="brush: sql; gutter: true">SELECT id, name, salary
FROM employee
WHERE salary &lt; 25000;</pre>
<p>Instead of:</p>
<pre class="brush: sql; gutter: true">SELECT id, name, salary
FROM employee
WHERE salary + 10000 &lt; 35000;</pre>
<h3>Join tables wisely</h3>
<p>This is another basic lesson in SQL Tuning, the order in which tables are joined really matters alot in SQL tuning.</p>
<p>The order in which tables are joined normally affects the number of rows processed by that JOIN operation and hence proper ordering of tables in a JOIN operation may result in the processing of fewer rows, which will in turn improve the performance. The key to decide the proper order is to have the most restrictive filtering condition in the early phases of a multiple table JOIN.</p>
<p>For example, in case we are using a master table and a details table then it&#8217;s better to connect to the master table first. Connecting to the details table first may result in more number of rows getting joined. This is a very effective SQL Tuning lesson which you may come across multiple times if you are dealing with complex queries with multiple JOINs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deknight.com/sql/sql-tuning-sql-optimization-query-optimization.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Method Overloading Function Overloading in Java</title>
		<link>http://www.deknight.com/java/method-overloading-function-overloading-in-java.html</link>
		<comments>http://www.deknight.com/java/method-overloading-function-overloading-in-java.html#comments</comments>
		<pubDate>Thu, 26 Apr 2012 22:54:13 +0000</pubDate>
		<dc:creator>jaisonpjohn</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.deknight.com/?p=104</guid>
		<description><![CDATA[Method Overloading in Java &#8211; We can say it as the example of OOP concept &#8220;Polymorphism&#8221; Two or more methods in a Java class can have the same name, provided their argument lists are different, this feature is known as Method Overloading. Method Overloading in Java is Static Polymorphism Overloaded methods invocation will be resolved during [...]]]></description>
			<content:encoded><![CDATA[<p><br/><br />
<strong>Method Overloading in Java</strong> &#8211; We can say it as the example of OOP concept &#8220;<strong>Polymorphism</strong>&#8221;</p>
<p>Two or more methods in a Java class can have the same name, provided their argument lists are different, this feature is known as Method Overloading.</p>
<p><strong>Method Overloading in Java is Static Polymorphism</strong></p>
<p>Overloaded methods invocation will be resolved during compile time. In other words, while compiling, when the overloaded methods are invoked JVM will choose the appropriate method based on the arguments used for invocation. For example, if the print method is invoked with an int argument, the JVM will choose the overloaded print method that accepts an int parameter.</p>
<p>For a valid method overloading, argument list could differ in any of this</p>
<ul>
<li>Data type of parameters</li>
<li>Number of parameters</li>
<li>Sequence of parameters (Consider only the datatype of each parameter)</li>
</ul>
<p><strong>Java Method overloading Example (difference in Data type of parameters)</strong></p>
<pre class="brush: java; gutter: true">void print(int i){
    System.out.println(i);
}
void print(double d){
    System.out.println(d);
}
void print(char c){
    System.out.println(c);
}</pre>
<p><strong>Java Method overloading Example (difference in Number of parameters)</strong></p>
<pre class="brush: java; gutter: true">void print(int i){
    System.out.println(i);
}
void print(int i,int j){
    System.out.println(i+j);
}</pre>
<p><strong>Java Method overloading Example (difference in Sequence of parameters)</strong></p>
<pre class="brush: java; gutter: true">void print(int i,String j){
    System.out.println(j+i);
}
void print(String j,int i){
    System.out.println(j+i+j);
}</pre>
<p>If there is a difference in Sequence of datatype of parameters it&#8217;s a valid method overloading, otherwise its not. The following example is not a valid method overloading, it will throw compilation error.</p>
<pre class="brush: java; gutter: true">void print(int i,String j){
    System.out.println(j+i);
}
void print(int j,String i){
    System.out.println(j+i);
}</pre>
<p><strong>Methods differing only in return type</strong></p>
<p>Methods differing only in return type will <strong>NOT</strong> be treated as overloaded methods, it will result in compilation error. For Example, the below given methods will give compilation error.</p>
<pre class="brush: java; gutter: true">void print(int i){
    System.out.println(i);
}
int print(int i)){
    System.out.println(i);
    return i;
}</pre>
<p><strong>Constructor Overloading</strong></p>
<p>Just like other methods, constructors also can be overloaded.</p>
<pre class="brush: java; gutter: true">public class Student{
    public Student(){
        mark = 100;
    }
    public Student(int rollNo, double mark){
        this.rollNo = rollNo;
        this.mark = mark;
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.deknight.com/java/method-overloading-function-overloading-in-java.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enhanced For Loop in Java 5.0</title>
		<link>http://www.deknight.com/java/enhanced-for-loop-in-java-5-0.html</link>
		<comments>http://www.deknight.com/java/enhanced-for-loop-in-java-5-0.html#comments</comments>
		<pubDate>Thu, 26 Apr 2012 22:17:49 +0000</pubDate>
		<dc:creator>jaisonpjohn</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[Enhanced For Loop]]></category>

		<guid isPermaLink="false">http://www.deknight.com/?p=97</guid>
		<description><![CDATA[What is enhanced For loops in Java? The Java enhanced For loop is a new feature which was introduced in Java 5.0/J2SE 5.0 as a simpler way to iterate through the elements (all elements) of an array or a Collection (like ArrayList). If you are using the enhanced For loop, you don&#8217;t need to use Iterator or [...]]]></description>
			<content:encoded><![CDATA[<p><strong>What is enhanced For loops in Java?</strong></p>
<p>The Java enhanced For loop is a new feature which was introduced in Java 5.0/J2SE 5.0 as a simpler way to iterate through the elements (all elements) of an array or a Collection (like ArrayList). If you are using the enhanced For loop, you don&#8217;t need to use Iterator or calculate end conditions of For loop using incrementing/decrementing loop counter. Thus, enhanced for loop replaces the traditional ways of accessing elements in a collection.</p>
<p>The enhanced For loop is really a useful feature. The enhanced for loop is very simple structure which allows the programmer to simplify code by writing the For loops that iterates through all elements in an array or a collection without explicitly writing the code to iterate through each element. It&#8217;s not necessary that every programmer should switch to this all new enhanced for loops. As the old coding style didn&#8217;t become invalid with the new for loop syntax, you can stick to the traditional ways to iterate through the collections if you prefer. Let&#8217;s go through some examples.</p>
<p><strong>When to use Enhanced For Loop.</strong></p>
<p>Enhanced for loops may be simple but inflexible. You don&#8217;t have access to LoopIndex. Prefer Enhanced For Loop only</p>
<ol>
<li>If you have to iterate through all the elements.</li>
<li>If you don&#8217;t need to know the loop index of the current element</li>
<li>If you need to iterate through the Collection/Array in first-to-last order.(In other words, if the order doesn&#8217;t matter to you)</li>
</ol>
<p>In all other cases, the &#8220;standard&#8221; For loop should be preferred.</p>
<h3>Enhanced For Loop in Array Iteration</h3>
<p>With the new enhanced for loop, array iteration code will change something like the following:</p>
<p><strong>Traditional For Loop (before Java 5.0)</strong></p>
<pre class="brush: java; gutter: true">for (int i=0; i &lt; arrayOfElements.length; i++) {
    System.out.println(&quot;Element: &quot; + arrayOfElements[i]);
}</pre>
<p><strong>Enhanced For Loop (Java 5.0+)</strong></p>
<pre class="brush: java; gutter: true">for (String element : arrayOfElements) {
    System.out.println(&quot;Element: &quot; + element);
}</pre>
<h3>Enhanced For Loop in ArrayList Iteration</h3>
<p>With the new enhanced For loop, ArrayList iteration code will change something like the following:</p>
<p><strong>Traditional For Loop (before Java 5.0)</strong></p>
<pre class="brush: java; gutter: true">ArrayList&lt;String&gt; listOfString = new ArrayList&lt;String&gt;();
listOfString.add(&quot;Cpp&quot;);
listOfString.add(&quot;Java&quot;);
listOfString.add(&quot;Python&quot;);
listOfString.add(&quot;LISP&quot;);
for (int i=0; i&lt;listOfString.size();i++){
	System.out.println(listOfString.get(i));
}</pre>
<p><strong>Traditional For Loop with Iterator(before Java 5.0)</strong></p>
<pre class="brush: java; gutter: true">ArrayList&lt;String&gt; listOfString = new ArrayList&lt;String&gt;();
listOfString.add(&quot;Cpp&quot;);
listOfString.add(&quot;Java&quot;);
listOfString.add(&quot;Python&quot;);
listOfString.add(&quot;LISP&quot;);
Iterator&lt;String&gt; iterator =listOfString.iterator();
for (;iterator.hasNext();){
	System.out.println(iterator.next());
}</pre>
<p><strong>Enhanced For Loop (Java 5.0+)</strong></p>
<pre class="brush: java; gutter: true">ArrayList&lt;String&gt; listOfString = new ArrayList&lt;String&gt;();
listOfString.add(&quot;Cpp&quot;);
listOfString.add(&quot;Java&quot;);
listOfString.add(&quot;Python&quot;);
listOfString.add(&quot;LISP&quot;);
for (String element : listOfString){
	System.out.println(element);
}</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deknight.com/java/enhanced-for-loop-in-java-5-0.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to read properties file in Java</title>
		<link>http://www.deknight.com/java/how-to-read-properties-file-in-java.html</link>
		<comments>http://www.deknight.com/java/how-to-read-properties-file-in-java.html#comments</comments>
		<pubDate>Thu, 29 Mar 2012 05:36:19 +0000</pubDate>
		<dc:creator>jaisonpjohn</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring Interview questions]]></category>
		<category><![CDATA[Spring3.0]]></category>

		<guid isPermaLink="false">http://www.deknight.com/?p=85</guid>
		<description><![CDATA[How to read properties file in Java? Its pretty simple and there are numerous way to do that. In this article I will tell you how to read properties file in conventional Java techniques and in Spring framework technique. To read properties file in Java and get the fields from it, use the following technique. Here, [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-5264876235537030";
/* 336x280, created 12/5/09 */
google_ad_slot = "1618689741";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
How to read properties file in Java? Its pretty simple and there are numerous way to do that. In this article I will tell you how to read properties file in conventional Java techniques and in Spring framework technique.</p>
<p>To read properties file in Java and get the fields from it, use the following technique. Here, we read the properties file as a stream and loads to the Properties class and use the getProperty() method to get the value from the properties. This is conventional java technique to read properties file and get the data, you can use this method to read properties file irrespective of whether you are using any java framework or not.</p>
<pre class="brush: java; gutter: true">public Properties getBankConfigProps() {

		// Reading properties file to set Default values
		Properties bankConfig = new Properties();
		try {
			bankConfig.load(BankUtility.class.getClassLoader().getResourceAsStream(&quot;conf/configuration.properties&quot;));
		} catch (IOException e) {
			System.out.println(&quot;Exception in getBankConfigProps: &quot;+e);
		}
		return bankConfig;
	}

	public String getClubIdFromProps()
	{
		/* Reading properties file in Java */
		Properties bankConfig;
		bankConfig = getBankConfigProps();
		String strClubId = bankConfig.getProperty(&quot;clubId&quot;);
		System.out.println(&quot;club id is &quot;+strClubId);
		return strClubId;
	}</pre>
<p>And of course you should have conf/configuration.properties</p>
<pre class="brush: java; gutter: true">clubId=northclub
someotherfields1=someothervalues1
someotherfields2=someothervalues2</pre>
<p>But, if you are using spring dependancy injection/ Inversion of control(IOC) framework in your project, then there are much better ways to load properties file in to your java application. You can inject the properties directly to your class with spring&#8217;s dependency injection.</p>
<p><strong>How to read properties file in Spring versions prior to spring 3.0</strong></p>
<p>This is a really cool feature from Spring framework, you dont need to read from properties file on your own, instead spring will inject the values for you wherever you want. You just need to add a class variable to which the value should get injected(expirationOffset and expirationOffsetString)and a setter method. See the below example, spring will handle the data type also. You can declare the variable(to which you need the value to get injected from properties file) as String or int, spring will do the rest for you, you dont need to typecast it. Here, in this example its trying to load values from properties file to expirationOffset and expirationOffsetString. So your Java class will look something like this.</p>
<p><strong>BankServiceImpl.java</strong></p>
<pre class="brush: java; gutter: true">public class BankServiceImpl implements BankService {
	private int expirationOffset;
	private String expirationOffsetString;

	public void setExpirationOffset(int expirationOffset) {
		this.expirationOffset = expirationOffset;
	}

	public void setExpirationOffsetString(String expirationOffsetString) {
		this.expirationOffsetString = expirationOffsetString;
	}</pre>
<p>And our <strong>ApplicationContext.xml</strong> will look something like this</p>
<pre class="brush: xml; gutter: true">&lt;!DOCTYPE beans PUBLIC
    &quot;-//SPRING//DTD BEAN//EN&quot; &quot;http://www.springframework.org/dtd/spring-beans.dtd&quot;&gt;
&lt;beans&gt;
	&lt;bean id=&quot;propertyConfigurer&quot;
		class=&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;&gt;
		&lt;property name=&quot;location&quot;&gt;
			&lt;value&gt;file:conf/configuration.properties&lt;/value&gt;
		&lt;/property&gt;
	&lt;/bean&gt;
	&lt;bean id=&quot;bankService&quot; class=&quot;com.blah.blah.BankServiceImpl&quot;&gt;
		&lt;property name=&quot;bankDAO&quot;&gt;
			&lt;ref bean=&quot;bankDAO&quot; /&gt;
		&lt;/property&gt;
		&lt;property name=&quot;expirationOffset&quot;&gt;
			&lt;value&gt;${xprnOffset}&lt;/value&gt;
		&lt;/property&gt;
		&lt;property name=&quot;expirationOffsetString&quot;&gt;
			&lt;value&gt;${xprnOffsetProp}&lt;/value&gt;
		&lt;/property&gt;
	&lt;/bean&gt;
&lt;/beans&gt;</pre>
<p>&lt;property name=&#8221;expirationOffsetString&#8221;&gt;&lt;value&gt;${xprnOffsetProp}&lt;/value&gt;&lt;/property&gt; using this configurations you are saying spring framework that you need to get value of xprnOffsetProp from properties file get injected to the member variable expirationOffsetString.<br />
&lt;property name=&#8221;expirationOffset&#8221;&gt;&lt;value&gt;${xprnOffset}&lt;/value&gt;&lt;/property&gt;using this configurations you are saying spring framework that you need to get value of xprnOffset from properties file get injected to the member variable expirationOffset.</p>
<p>And your properties file will look something like this</p>
<p><strong>conf/configuration.properties</strong></p>
<pre class="brush: java; gutter: true">xprnOffset= 7
xprnOffsetProp= Hello
someotherfields1=someothervalues1
someotherfields2=someothervalues2</pre>
<p>So when you run this application, while instantiating BankServiceImpl class, spring framework will inject expirationOffset and expirationOffsetString for you.</p>
<p><strong>How to read properties file in Spring versions 3.0 +</strong></p>
<p>In spring 3.0+ versions, its more easy, you don&#8217;t need to do all this setter method circus, instead you can use autowiring and annotations and all new Spring Expression Language (SpEL). you dont need to define the bean configurations, instead &lt;context:component-scan base-package=&#8221;com.blah.blah&#8221;/&gt; will take care of that.</p>
<p>So your <strong>ApplicationContext.xml</strong></p>
<pre class="brush: xml; gutter: true">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
    xsi:schemaLocation=&quot;
    http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context.xsd&quot;&gt;

    &lt;context:annotation-config/&gt;
    &lt;context:component-scan base-package=&quot;com.blah.blah&quot;/&gt;
    &lt;context:property-placeholder location=&quot;conf/config.properties&quot;/&gt;
&lt;/beans&gt;</pre>
<p>and in the java class where you intend to get the value injected by annotations, add this</p>
<pre class="brush: java; gutter: true">private @Value(&quot;${xprnOffset}&quot;) int expirationOffset;
private @Value(&quot;${xprnOffsetProp}&quot;) int expirationOffsetString;</pre>
<p>use the same <strong>conf/configuration.properties</strong></p>
<pre class="brush: java; gutter: true">xprnOffset= 7
xprnOffsetProp= Hello
someotherfields1=someothervalues1
someotherfields2=someothervalues2</pre>
<p>your member variable expirationOffset will get injected with the value 7.<br />
your member variable expirationOffsetString will get injected with the value &#8220;Hello&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deknight.com/java/how-to-read-properties-file-in-java.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring Interview Questions</title>
		<link>http://www.deknight.com/java/spring-interview-questions-top10.html</link>
		<comments>http://www.deknight.com/java/spring-interview-questions-top10.html#comments</comments>
		<pubDate>Sat, 17 Mar 2012 06:58:39 +0000</pubDate>
		<dc:creator>jaisonpjohn</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[java interview Questions]]></category>
		<category><![CDATA[Spring Interview questions]]></category>

		<guid isPermaLink="false">http://www.deknight.com/?p=74</guid>
		<description><![CDATA[Spring Interview Questions Spring Interview Questions Index What is Spring framework ? What is Dependency Injection/Inversion Of Control(IOC) in Spring framework ? What are the different types of Inversion of Control or dependency injection ? What are the different types of Spring dependency injection ? What are the advantages or Pros of IOC (Dependency Injection) [...]]]></description>
			<content:encoded><![CDATA[<h3>Spring Interview Questions</h3>
<p><strong>Spring Interview Questions Index</strong></p>
<p><a href="#What-is-spring-framework">What is Spring framework ?</a><br />
<a href="#What-is-dependency-injection">What is Dependency Injection/Inversion Of Control(IOC) in Spring framework ?</a><br />
<a href="#different-types-of-inversion-of-control-dependency-injection">What are the different types of Inversion of Control or dependency injection ?</a><br />
<a href="#different-types-of-spring-dependency-injection">What are the different types of Spring dependency injection ?</a><br />
<a href="#advantages-of-dependency-injection">What are the advantages or Pros of IOC (Dependency Injection) ?</a><br />
<a href="#benefits-of-spring-framework">What are the pros or benefits of Spring framework ?</a><br />
<a href="#different-modules-of-spring-framework">What are the various modules in Spring?</a><script type="text/javascript"><!--
google_ad_client = "ca-pub-5264876235537030";
/* 336x280, created 12/5/09 */
google_ad_slot = "1618689741";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</p>
<p>1. <a name="What-is-spring-framework"></a>What is Spring framework ?</p>
<p>Spring framework is an open source Java application framework created to ease developers effort by addressing the enterprise application development complexity. The beauty of Spring framework is it&#8217;s layered architecture which allows the programmer to be selective about which all spring components he wants. And Spring also provides a cohesive framework for Java Enterprise application development. Spring framework comprises of several modules that provide different services such as Spring IOC(dependency injection)framework, Spring MVC, Spring data access framework, Spring validator framework etc. In fact, it&#8217;s a common practice in Software industry to use struts MVC together with spring IOC framework, so whenever you mention about Spring framework you can be more specific like spring IOC framework or Spring MVC framework.<br />
2. <a name="What-is-dependency-injection"></a>What is Dependency Injection/Inversion Of Control(IOC) in Spring framework ?</p>
<p>You can expect this question, this one among the common Spring Interview Questions.</p>
<p>The basic concept of the Dependency Injection or Inversion of Control is that, programmer do not need to create the objects, instead just describe how it should be created. No need to directly connect your components and services together in program, instead just describe which services are needed by which components in a configuration file/xml file. The Spring IOC container is then responsible for binding it all up.</p>
<p>In other words, while applying Inversion Of Control, at the time of object creation, objects are given their dependencies by some external entity that coordinates each object in the system. That means, dependencies are injected into objects at the time of their creation. So, Inversion of Control means an inversion of responsibility with regard to how an object obtains references to collaborating objects.<br />
3. <a name="different-types-of-inversion-of-control-dependency-injection"></a>What are the different types of Inversion of Control or dependency injection ?</p>
<p>There are three different types of Inversion of Control or dependency injection:</p>
<ul>
<li><strong>Setter Injection</strong>: Dependencies are injected through JavaBeans properties (ex: setter/Getter methods in bean objects).</li>
<li><strong>Constructor Injection</strong>: Dependencies are assigned as constructor parameters.</li>
<li><strong>Interface Injection</strong>: Injection is done through an interface.</li>
</ul>
<p>Constructor and Setter Injection are the two dependency injection method which Spring supports.<br />
4. <a name="different-types-of-spring-dependency-injection"></a>What are the different types of Spring dependency injection ?</p>
<p>As I said earlier, its Setter Injection and Constructor Injection</p>
<ul>
<li><strong>Setter Injection:</strong> Dependencies are provided through JavaBeans properties (ex: setter/Getter methods in bean objects).</li>
<li><strong>Constructor Injection:</strong> Dependencies are assigned as constructor parameters.</li>
</ul>
<p>5. <a name="advantages-of-dependency-injection"></a>What are the advantages or Pros of IOC (Dependency Injection) ?</p>
<p>Advantages of Dependency Injection/Inversion of Control are as follows:</p>
<ul>
<li>Dependency Injection minimizes the amount of code in any application. Dependency is handled by the framework itself</li>
<li>Dependency Injection makes developers life easier. With Inversion of Control containers developers do not need to think about how services are created and how to get references to the ones he needs.</li>
<li>Easily scalable applications. It&#8217;s very easy to add additional services by adding a new constructor or a getter/setter method with a minimal configuration. With Spring Framework 3.0, its even easier as &lt;context:component-scan base-package=&#8221;com.blah.blah&#8221;/&gt; will do everything for you, you don&#8217;t need to add getter and setter method and beans for each dependency injection, just autowire the services wherever it needed.&lt;Read how spring 3.0 made a developers life easier&gt;</li>
<li>Dependency Injection makes your application more test-friendly by not demanding any JNDI lookup mechanisms or singletons in your test cases. IOC containers make testing and switching implementations easy by allowing you to inject your own objects into the object under test.</li>
<li>Comparing to other options like factory design pattern the IOC container is injecting the dependency into requesting piece of code where as the factory design pattern is more intrusive and components or services need to be requested explicitly.</li>
<li>IOC containers support eager instantiation and lazy loading of services.</li>
<li>IOC Containers provide support for instantiation of cyclical dependencies, managed objects, life cycles management and dependency resolution between managed objects etc.</li>
</ul>
<p>6. <a name="benefits-of-spring-framework"></a>What are the pros or benefits of Spring framework ?</p>
<p>This is one among the common Spring Interview Questions</p>
<p>The pros of Spring framework are as follows:</p>
<ul>
<li>Spring is an open source framework and free to download.</li>
<li>Spring has layered architecture. You can select the feature you wants, as I said before you can have Struts MVC and Springs IOC container in one application itself. Eventhough spring has MVC framework if you want you can opt out.</li>
<li>Spring Enables Plain Old Java Object (POJO) Programming. POJO programming enables continuous integration and testability.</li>
<li>Dependency Injection is really cool stuff, spring 3.0 onwards the introduction of component-scan/autowiring and Spring Expression Language makes it even spicier.</li>
<li>spring is lightweight.</li>
</ul>
<p>7. <a name="different-modules-of-spring-framework"></a>What are the various modules in Spring?</p>
<p>Spring comprises of seven different modules. They are as follows</p>
<p><strong>Inversion of Control container/ The core container</strong><br />
The core container/IoC container handles the configuration of application components and lifecycle management of Java objects. It is responsible for the Dependency Injection. Inversion of Control container provides the essential functionality of the Spring framework. A primary component of the core container is the BeanFactory, an implementation of the Factory pattern. The BeanFactory applies the IOC pattern to separate an application’s actual application code and configuration and dependency specification.</p>
<p><strong>Spring context</strong><br />
The Spring context is a configuration file that provides context information to the Spring framework. The Spring context includes enterprise services such as JNDI, EJB, e-mail, internalization, validation, and scheduling functionality.</p>
<p><strong>Spring AOP -Aspect oriented programming</strong><br />
The Spring AOP module integrates aspect-oriented programming functionality directly into the Spring framework through its configuration management feature. Spring AOP enables implementation of cross-cutting routines. As a result you can easily enable aspect oriented programming in any object managed by the Spring framework. The Spring AOP module provides transaction management services for objects in any Spring-based application. With Spring AOP you can incorporate declarative transaction management into your applications without relying on EJB components.</p>
<p><strong>Spring DAO -Data access</strong><br />
The Spring JDBC DAO abstraction layer offers an exception hierarchy for managing the exception handling and error messages thrown by different database vendors. The exception hierarchy simplifies error handling and greatly reduces the amount of exception code you need to write, such as opening and closing connections. Spring DAO’s JDBC-oriented exceptions comply to its generic DAO exception hierarchy.Spring DAO is working with relational database management systems on the Java platform using JDBC and object-relational mapping tools and with NoSQL databases</p>
<p><strong>Spring ORM</strong><br />
The Spring framework plugs into several ORM frameworks to provide its Object Relational tool, including JDO, Hibernate, and iBatis SQL Maps. All of these comply to Spring’s generic transaction and DAO exception hierarchies.</p>
<p><strong>Spring Web module</strong><br />
The Web context module builds on top of the application context module, providing contexts for Web-based applications. As a result, the Spring framework supports integration with Jakarta Struts. The Web module also eases the tasks of handling multi-part requests and binding request parameters to domain objects.</p>
<p><strong>Spring MVC framework</strong><br />
The Model-View-Controller (MVC) framework is a full-featured MVC implementation for building Web applications. The MVC framework is highly configurable via strategy interfaces and accommodates numerous view technologies including JSP, Velocity, Tiles, iText, and POI.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deknight.com/java/spring-interview-questions-top10.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to read properties file in spring using autowiring annotations</title>
		<link>http://www.deknight.com/java/spring/how-to-read-properties-file-in-spring-using-autowiring-annotations.html</link>
		<comments>http://www.deknight.com/java/spring/how-to-read-properties-file-in-spring-using-autowiring-annotations.html#comments</comments>
		<pubDate>Tue, 13 Mar 2012 04:56:48 +0000</pubDate>
		<dc:creator>jaisonpjohn</dc:creator>
				<category><![CDATA[Spring]]></category>
		<category><![CDATA[Annotations]]></category>
		<category><![CDATA[Autowire]]></category>
		<category><![CDATA[Spring3.0]]></category>

		<guid isPermaLink="false">http://www.deknight.com/?p=66</guid>
		<description><![CDATA[To read properties file in spring using autowiring annotations or in other words &#8220;properties injection into a bean via Annotations&#8221;, you need to make some tweaks in your application-context.xml and in your java class Keep 3 things in mind before doing properties injection into a bean via Annotations. Injection of values using component-scan will not work on Spring versions prior [...]]]></description>
			<content:encoded><![CDATA[<p>To read properties file in spring using autowiring annotations or in other words &#8220;properties injection into a bean via Annotations&#8221;, you need to make some tweaks in your application-context.xml and in your java class</p>
<p>Keep 3 things in mind before doing properties injection into a bean via Annotations.</p>
<ol>
<li>Injection of values using component-scan will not work on Spring versions prior to 3.0</li>
<li>If you are using previous versions of spring framework (older than Spring 3.0), you could have either bundle up your value types in a reference type and inject the reference type or define the bean explicitly. Before Spring 3.0 framework, there was no option to inject values using component-scan (or in other words autowiring).</li>
<li>Once Spring 3.0 is launched you can inject property value into Spring bean using the all new Spring Expression Language (SpEL).</li>
</ol>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-5264876235537030";
/* 336x280, created 12/5/09 */
google_ad_slot = "1618689741";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<strong>ApplicationContext.xml</strong></p>
<pre class="brush: java; gutter: true">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
	xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
	xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
	xsi:schemaLocation=&quot;
	http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context.xsd&quot;&gt;

	&lt;context:annotation-config/&gt;
	&lt;context:component-scan base-package=&quot;com.blah.blah&quot;/&gt;
	&lt;context:property-placeholder location=&quot;conf/config.properties&quot;/&gt;
&lt;/beans&gt;</pre>
<p>and config.properties</p>
<pre class="brush: java; gutter: true">expirationOffset = 7
someotherValues=45
someothervalue=33</pre>
<p>and in the java class where you intend to get the value injected by autowiring, add this</p>
<pre class="brush: java; gutter: true">private @Value(&quot;${expirationOffset}&quot;) int exprnOffset;</pre>
<p>your member variable exprnOffset will get injected with the value 7.</p>
<p>&nbsp;</p>
<p><strong>Another Approach to Inject values in Spring</strong></p>
<p>Instead of &lt;context:property-placeholder location=&#8221;conf/config.properties&#8221;/&gt; you can use the old conventional bean definition</p>
<p>&lt;bean id=&#8221;config&#8221; class=&#8221;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&#8221;&gt;<br />
&lt;property name=&#8221;location&#8221;&gt;&lt;value&gt;file:conf/config.properties&lt;/value&gt;&lt;/property&gt;<br />
&lt;/bean&gt;</p>
<p>If you want to do it this way, your  applicationContext.xml will look like this</p>
<pre class="brush: java; gutter: true">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
	xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
	xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
	xsi:schemaLocation=&quot;
	http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context.xsd&quot;&gt;

	&lt;context:annotation-config/&gt;

	&lt;context:component-scan base-package=&quot;com.blah.blah&quot;/&gt;
	&lt;bean id=&quot;config&quot; class=&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;&gt;
    	&lt;property name=&quot;location&quot;&gt;&lt;value&gt;file:conf/config.properties&lt;/value&gt;&lt;/property&gt;
	&lt;/bean&gt;

&lt;/beans&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.deknight.com/java/spring/how-to-read-properties-file-in-spring-using-autowiring-annotations.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to generate unique alphanumeric code in java</title>
		<link>http://www.deknight.com/java/how-to-generate-unique-alphanumeric-code-in-java.html</link>
		<comments>http://www.deknight.com/java/how-to-generate-unique-alphanumeric-code-in-java.html#comments</comments>
		<pubDate>Sat, 10 Mar 2012 22:02:49 +0000</pubDate>
		<dc:creator>jaisonpjohn</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[generate alphanumeric code]]></category>

		<guid isPermaLink="false">http://www.deknight.com/?p=53</guid>
		<description><![CDATA[This is how you can generate unique alphanumeric code in java. This code will make sure that you are getting unique alphanumeric code, provided you are not supposed to call this method in the same milli second. That means, in this alphanumeric code generation technique, to ensure the uniqueness, instead of random numbers, we are using system time-stamp upto the precision [...]]]></description>
			<content:encoded><![CDATA[<p>This is how you can generate unique alphanumeric code in java. This code will make sure that you are getting unique alphanumeric code, provided you are not supposed to call this method in the same milli second. That means, in this alphanumeric code generation technique, to ensure the uniqueness, instead of random numbers, we are using system time-stamp upto the precision of milli seconds. So, if you are invoking the  generateAuthCode() method with in a millisecond, the generated code can be repeated. To avoid this you can think about calling wait/sleep for some milliseconds.</p>
<p>This java code will generate 8 or 9 digit alphanumeric code which contains only capital letters. Here, we are basically converting a base10(decimal) literal to base36 literal(alphanumeric). If your system is able to distinguish between capital letters and small letters, you can go for base62(26 Capital letters+26 Small letters+10 integers) conversion instead which will make your unique alphanumeric code even shorter.</p>
<pre class="brush: java; gutter: true">	//Java code to generate 8 or 9 digit alphanumeric code
	private String generateAuthCode() {
		System.out.println(&quot;Entering generateAuthCode()&quot;);
		//getting the current time in milliseconds
		Date date=new Date();
		long decimalNumber=date.getTime();
		System.out.println(&quot;current time in milliseconds: &quot;+decimalNumber);

		//To convert time stamp to alphanumeric code.
		//We need to convert base10(decimal) to base36
		String strBaseDigits = &quot;0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;;
		String strTempVal = &quot;&quot;;
        int mod = 0;
        // String concat is costly, instead we could have use stringbuffer or stringbuilder
        //but here it wont make much difference.
        while(decimalNumber!= 0){
            mod=(int) (decimalNumber % 36);
            strTempVal=strBaseDigits.substring(mod,mod+1)+strTempVal;
            decimalNumber=decimalNumber/36;
        }
        System.out.println(&quot;alphanumeric code generated from TimeStamp : &quot;+strTempVal);
        return strTempVal;

}</pre>
<p>If your system is having any restrictions such that it needs 8 Digit unique Alphanumeric code, you can trim the leading edge so that the generated code will be matching your requirement of 8 Digits, provided your alphanumeric code can get repeated in some decades.</p>
<p>To trim the generated alphanumeric code you can use the following approach.</p>
<pre class="brush: java; gutter: true">			String strAuthCode=generateAuthCode();
			//Generated alphanumeric code can be longer than 8 digit, if thats the case we will trim the leading edge.
			//So that it will take decades to repeat the same alphanumeric code
			while(strAuthCode.length()&gt;8){
				log.info(&quot;Generated alphanumeric code is long. Trimming it to 8 digits&quot;);
				strAuthCode=strAuthCode.substring(1);
			}
			System.out.println(&quot;AuthCode : &quot;+strAuthCode);</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deknight.com/java/how-to-generate-unique-alphanumeric-code-in-java.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JEE architecture- What is Java Enterprise edition architecture ?</title>
		<link>http://www.deknight.com/java/jee-architecture-java-enterprise-edition-architecture.html</link>
		<comments>http://www.deknight.com/java/jee-architecture-java-enterprise-edition-architecture.html#comments</comments>
		<pubDate>Sun, 01 Jan 2012 16:39:29 +0000</pubDate>
		<dc:creator>jaisonpjohn</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[JEE architecture]]></category>

		<guid isPermaLink="false">http://www.deknight.com/?p=39</guid>
		<description><![CDATA[     JEE (Java Enterprise Edition) follows the distributed multi-tiered application approach which means the entire application may not reside at a single location, but distributed. And the applications is divided into various tiers. J2ee application is composed of various components which can be created by the different developers and then assembled together. These components can [...]]]></description>
			<content:encoded><![CDATA[<p><strong>     JEE </strong>(Java Enterprise Edition) follows the distributed multi-tiered application approach which means the entire application may not reside at a single location, but distributed. And the applications is divided into various tiers. J2ee application is composed of various components which can be created by the different developers and then assembled together. These components can be installed on different machines across various tiers. And the distribution of application components across the solely different tiers depends upon the functionality it performs.</p>
<p><strong>JEE Architecture </strong><strong>Diagram</strong></p>
<p>J2EE application tiers are as follows</p>
<ul>
<li>Client Tier (Web Browser or any other kinds of clients)</li>
<li>Web tier</li>
<li>Business Tier</li>
<li>Enterprise Information tier (Database or sometimes XMLs or flatfiles)</li>
</ul>
<p><strong>Various JEE Components</strong></p>
<p>Components are self contained piece of software that are reusable across applications and are configurable external to the source code.<br />
J2EE components are of three types : client component, web component and business component. The client components interact with the user, the web components interact with the web browsers using the HTTP protocol, and the business components interact with the application server and execute the business logic.</p>
<div><strong>Client component of JEE architecture</strong></div>
<p>Client components is of two types : web client and application client.</p>
<ul>
<li>A web client, generally a browser, sends a request to the server and renders the webpage sent back by the server. However, it may not perform any complex tasks such as querying a database or performing any complicated business tasks and hence is also referred to as thin client. The complex tasks are performed on the server. For displaying web pages with applets, the web clients may require Java plug-ins and security policy files for executing the applets.</li>
<li>An application client is a standalone application that doesn’t run in browsers. It can access components in the business tier directly. Note that web clients that require access to a servlet running in the Web tier can open an HTTP connection with the servlet.</li>
</ul>
<div><strong>Web component of JEE architecture</strong></div>
<p>Web components for java are Servlets and JavaServer Pages (JSP). A servlet receives HTTP requests from the client, processes them, and returns the output. It can also generate dynamic responses. Similar to servlets, JSP also create dynamic web pages. JSP pages are converted into servlets and executed within a servlet container. They are used to display the results processed by a servlet.</p>
<div><strong>Business component of JEE architecture</strong></div>
<p>Business components implement the business logic or the functional process logic that defines the business rules and constraints. For example business process such as withdrawing amount from the bank. Business components are of three types : session beans, entity beans, and message-driven beans. Session beans represent a session with a client. Being a transient object, they lose their data on completion of the session. On the other hand, entity beans are persistent objects and so retain data even after the session. They represent a row of data in a database table. Message-driven beans are for receiving the receiving Java Message Service (JMS) messages asynchronously.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deknight.com/java/jee-architecture-java-enterprise-edition-architecture.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Garbage Collection or Memory DeAllocation in Java</title>
		<link>http://www.deknight.com/java/garbage-collection-memory-deallocation-in-java.html</link>
		<comments>http://www.deknight.com/java/garbage-collection-memory-deallocation-in-java.html#comments</comments>
		<pubDate>Fri, 09 Dec 2011 09:32:30 +0000</pubDate>
		<dc:creator>jaisonpjohn</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[garbage collection]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.deknight.com/?p=26</guid>
		<description><![CDATA[In Java, an object which is no longer referred by any reference variable will automatically be removed from the memory, this process is known as Garbage Collection. Garbage Collection is automatically done by Java Virtual Machine (JVM), the automatic Garbage Collection of Java de-allocates the dynamic memory when this memory is no more used by the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.deknight.com/wp-content/uploads/2011/12/Garbage-Collection-Memory-DeAllocation-in-Java.png"><img class="alignleft size-full wp-image-36" title="Garbage Collection Memory DeAllocation in Java" src="http://www.deknight.com/wp-content/uploads/2011/12/Garbage-Collection-Memory-DeAllocation-in-Java.png" alt="Garbage Collection Memory DeAllocation in Java" width="340" height="367" /></a></p>
<p>In Java, an object which is no longer referred by any reference variable will automatically be removed from the memory, this process is known as Garbage Collection. Garbage Collection is automatically done by Java Virtual Machine (JVM), the automatic Garbage Collection of Java de-allocates the dynamic memory when this memory is no more used by the program. Thus the Garabage collection feature of Java relieves the programmer from the overhead of memory de-allocation.(A major difficulty in dynamic memory allocation in C/C++ was that the programmer is responsible for de-allocating the dynamic memory at the right time. Even though experienced programmers can do this very well, beginners and average programmers often miss the statements for de-allocation which leads to memory-leak in many systems.)</p>
<p><strong>How Garbage collection in Java works</strong></p>
<p>If a reference variable is declared within a function, the reference is invalidated soon as the function call ends. Or programmer can explicitly set the reference variable to null to indicate that the referred object is no longer in use. And then Garbage collector will claim the memory allotted for that.</p>
<p><strong>Please note:</strong> Primitive data types are not objects and they cannot be assigned null.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deknight.com/java/garbage-collection-memory-deallocation-in-java.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What are JEE containers?</title>
		<link>http://www.deknight.com/java/java-jee-containers-what-are-jee-containers.html</link>
		<comments>http://www.deknight.com/java/java-jee-containers-what-are-jee-containers.html#comments</comments>
		<pubDate>Sat, 15 Oct 2011 19:12:15 +0000</pubDate>
		<dc:creator>jaisonpjohn</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JEE]]></category>

		<guid isPermaLink="false">http://www.deknight.com/?p=20</guid>
		<description><![CDATA[There are different kind of JEE containers. Take a look at the following JEE containers. Application client container Application client container is the one which is responsible for managing the application client components. Both application client and its container resides at the client machine and are executed on the client end. Example of application container is [...]]]></description>
			<content:encoded><![CDATA[<p>There are different kind of JEE containers. Take a look at the following JEE containers.</p>
<p><strong>Application client container</strong><br />
Application client container is the one which is responsible for managing the application client components. Both application client and its container resides at the client machine and are executed on the client end. Example of application container is JVM.</p>
<p><strong>Applet container</strong><br />
Applet container is the container to manage the execution of applets. Examples of an applet container include Web browser and applet viewer.</p>
<p><strong>Enterprise JavaBeans (EJB) container</strong><br />
Enterprise JavaBeans (EJB) container is used to manage the execution of EJB component of the J2EE application. Both the EJBs and its container run on the J2EE server. J2EE server provides the EJB container, and an example of J2EE server is WebLogic.</p>
<p><strong>Web container</strong><br />
Web container is used to manage the execution of the Servlets and the JSP. Both the Web components and its container run on the J2EE server. An example of a web container is Tomcat.</p>
<div><strong>Responsibilities of JEE containers</strong></div>
<ul>
<li>Life cycle Management- Creating and deleting components</li>
<li>Persistence- Saving information in the components</li>
<li>Naming- Recording the name of a server component and locating it for the client.</li>
<li>Deployment- Placing components in the server</li>
<li>Messaging- Exchanging information between components.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.deknight.com/java/java-jee-containers-what-are-jee-containers.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

