<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Girish Gaurav&#039;s Blog</title>
	<atom:link href="http://girishgaurav.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://girishgaurav.wordpress.com</link>
	<description>View life as a continuous learning experience.</description>
	<lastBuildDate>Tue, 10 Aug 2010 09:30:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='girishgaurav.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Girish Gaurav&#039;s Blog</title>
		<link>http://girishgaurav.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://girishgaurav.wordpress.com/osd.xml" title="Girish Gaurav&#039;s Blog" />
	<atom:link rel='hub' href='http://girishgaurav.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Download/Attach source-code/java-docs with maven dependencies</title>
		<link>http://girishgaurav.wordpress.com/2010/07/16/downloadattach-source-codejava-docs-with-maven-dependencies/</link>
		<comments>http://girishgaurav.wordpress.com/2010/07/16/downloadattach-source-codejava-docs-with-maven-dependencies/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 11:34:08 +0000</pubDate>
		<dc:creator>Girish Gaurav Agarwal</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[dependency]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javadocs]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[pom]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[source code jars]]></category>

		<guid isPermaLink="false">http://girishgaurav.wordpress.com/?p=110</guid>
		<description><![CDATA[I am using Maven in my projects from last couple of years, and the automatically downloading the Jars from repository feature of maven is really helpful for developers. But If you are using Eclipse and want to read/analyse Source Code or Java Doc of API then you need the jar file that contains the Source [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=girishgaurav.wordpress.com&amp;blog=14192500&amp;post=110&amp;subd=girishgaurav&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am using Maven in my projects from last couple of years, and the automatically downloading the Jars from repository feature of maven is really helpful for developers. But If you are using Eclipse and want to read/analyse Source Code or Java Doc of API then you need the jar file that contains the Source code and java doc of the API, but unfortunately maven does not download and attach the source code and java doc of the APIs automatically.</p>
<p>Maven provides some different ways to download and attach that source code and Java Doc:</p>
<ul>
<li><em>Using maven eclipse plugin</em></li>
<li><em>Using maven dependency plugin</em></li>
</ul>
<p><strong>Note:</strong> <em>The sources and javadocs of the libraries </em><em>must</em><em> exist in the repository so that the plugin can download it and attach it.</em></p>
<p><strong>1. Maven eclipse plugin:</strong></p>
<p style="padding-left:30px;">Maven dependencies that are deployed with the source and javadocs can be downloaded and attached to the Eclipse library by using maven-eclipse-plugin. It can be done by:</p>
<ul>
<li>passing command-line argument to the maven-eclipse-plugin, or</li>
<li>by declaring in the pom.xml</li>
</ul>
<p style="padding-left:30px;"><strong>1.1 passing command-line argument to maven-eclipse-plugin:</strong></p>
<p style="padding-left:60px;">This example shows that how to do this by passing command line argument to the maven-eclipse-plugin:</p>
<p style="padding-left:60px;"><em>mvn eclipse:eclipse </em><em><strong>-DdownloadSources=true -DdownloadJavadocs=true</strong></em></p>
<p style="padding-left:30px;"><strong>1.2 declaring in the pom.xml</strong></p>
<p style="padding-left:60px;">This sample pom shows that how to declare downloadSources and downloadJavadocs configuration in pom.xml</p>
<p style="padding-left:60px;">&lt;project&gt;</p>
<p style="padding-left:90px;">&#8230;</p>
<p style="padding-left:90px;">&lt;build&gt;</p>
<p style="padding-left:120px;">&lt;plugins&gt;</p>
<p style="padding-left:150px;">&lt;plugin&gt;</p>
<p style="padding-left:180px;">&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;</p>
<p style="padding-left:180px;">&lt;artifactId&gt;maven-eclipse-plugin&lt;/artifactId&gt;</p>
<p style="padding-left:180px;"><em><strong>&lt;configuration&gt;</strong></em></p>
<p style="padding-left:210px;"><em><strong>&lt;downloadSources&gt;true&lt;/downloadSources&gt;</strong></em></p>
<p style="padding-left:210px;"><em><strong>&lt;downloadJavadocs&gt;true&lt;/downloadJavadocs&gt;</strong></em></p>
<p style="padding-left:180px;"><em><strong>&lt;/configuration&gt;</strong></em></p>
<p style="padding-left:150px;">&lt;/plugin&gt;</p>
<p style="padding-left:120px;">&lt;/plgins&gt;</p>
<p style="padding-left:90px;">&lt;/build&gt;</p>
<p style="padding-left:90px;">&#8230;</p>
<p style="padding-left:60px;">&lt;/project&gt;</p>
<p><strong>2. Maven dependency plugin:</strong></p>
<p style="padding-left:30px;">maven-dependency-plugin provides a goal named <strong>sources </strong>that resolves the project source dependencies from the repository.</p>
<p style="padding-left:30px;"><strong>usage:</strong></p>
<p style="padding-left:60px;"><strong>mvn dependency:sources</strong></p>
<p style="padding-left:30px;">This is useful when you want the source attachments downloaded to your local repository and you don&#8217;t want to use the eclipse plugin to do this since the eclipse plugin creates/overwrites the eclipse files.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/girishgaurav.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/girishgaurav.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/girishgaurav.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/girishgaurav.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/girishgaurav.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/girishgaurav.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/girishgaurav.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/girishgaurav.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/girishgaurav.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/girishgaurav.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/girishgaurav.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/girishgaurav.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/girishgaurav.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/girishgaurav.wordpress.com/110/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=girishgaurav.wordpress.com&amp;blog=14192500&amp;post=110&amp;subd=girishgaurav&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://girishgaurav.wordpress.com/2010/07/16/downloadattach-source-codejava-docs-with-maven-dependencies/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4d7fd057b8dd68f39ad0f33914557914?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">girishgaurav</media:title>
		</media:content>
	</item>
		<item>
		<title>Configuring multiple Tomcat application servers with Apache HTTP server/ Load Balancing with Apache Web Server</title>
		<link>http://girishgaurav.wordpress.com/2010/07/09/configuring-multiple-tomcat-application-servers-with-apache-http-server/</link>
		<comments>http://girishgaurav.wordpress.com/2010/07/09/configuring-multiple-tomcat-application-servers-with-apache-http-server/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 09:40:24 +0000</pubDate>
		<dc:creator>Girish Gaurav Agarwal</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Load balancing]]></category>
		<category><![CDATA[mod_jk]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://girishgaurav.wordpress.com/?p=84</guid>
		<description><![CDATA[In this article, I am going to explain how we can configure multiple Tomcat instances with single Apache Web Server. There are many solutions posted on the web, but it is the simplest and easiest way to do this. Prerequisite: Apache HTTP Server 2.x Tomcat 6.x mod_jk.so module for Apache Web server Any text editor, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=girishgaurav.wordpress.com&amp;blog=14192500&amp;post=84&amp;subd=girishgaurav&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this article, I am going to explain how we can configure multiple Tomcat instances with single Apache Web Server.</p>
<p>There are many solutions posted on the web, but it is the simplest and easiest way to do this.</p>
<p><strong>Prerequisite:</strong></p>
<ul>
<li>Apache HTTP Server 2.x</li>
<li>Tomcat 6.x</li>
<li>mod_jk.so module for Apache Web server</li>
<li>Any text editor, i.e. Notepad, gedit, etc.</li>
</ul>
<p>if you do not have Apache HTTP server goto <a href="http://httpd.apache.org/">http://httpd.apache.org/</a> and download the appropriate version and install on your machine.</p>
<p>if you do not have Apache Tomcat Server goto <a href="http://tomcat.apache.org/">http://tomcat.apache.org/</a> and download the appropriate version and install on your machine.</p>
<p>if you do not have mod_jk.so module, goto <a href="http://tomcat.apache.org/download-connectors.cgi">http://tomcat.apache.org/download-connectors.cgi</a> and download the appropriate connector for Apache Web Server.</p>
<p><strong>Step 1: Configure Tomcat</strong></p>
<p>If you having one machine per Tomcat, you don&#8217;t need to do this. but if you don&#8217;t have, you have to configure each tomcat instance for different port to run successfully.</p>
<p>To configure Tomcat&#8217;s port, goto <strong><em>conf</em></strong> directory of any tomcat instance you have and open the<strong> </strong><em><strong>server.xml</strong></em><strong> </strong>file in the text editor.</p>
<p>search these lines in the <em>server.xml</em> and make the value of <strong><em>port</em></strong> property unique for each instance of tomcat.</p>
<p style="padding-left:30px;"><em>&lt;Server </em><strong><em>port=&#8221;8005&#8243;</em></strong><em> shutdown=&#8221;SHUTDOWN&#8221;&gt;</em></p>
<p style="padding-left:30px;">&lt;Connector port=&#8221;8080&#8243; protocol=&#8221;HTTP/1.1&#8243; connectionTimeout=&#8221;20000&#8243; redirectPort=&#8221;8443&#8243; /&gt;</p>
<p style="padding-left:30px;"><em>&lt;Connector </em><strong><em>port=&#8221;8009&#8243;</em></strong><em> protocol=&#8221;AJP/1.3&#8243; redirectPort=&#8221;8443&#8243; /&gt;</em></p>
<p><strong>Step 2: Creating configuration file of Tomcat instances for Apache Web Server</strong></p>
<p>now open text editor and create a file called <strong><em>workers.properties</em></strong> and enter the information of all tomcat instances you have. and save it  under the conf directory of Apache.</p>
<p>A sample <strong><em>worker.properties</em></strong> is given:</p>
<p style="padding-left:30px;"># <em>lists the workers by name</em></p>
<p style="padding-left:30px;">worker.list=tomcat1, tomcat2, loadbalancer</p>
<p style="padding-left:30px;"># <em>Tomcat1 configuration</em></p>
<p style="padding-left:30px;">worker.<em>tomcat1</em>.port=8009 //AJP1.3 Connector&#8217;s port</p>
<p style="padding-left:30px;">worker.<em>tomcat1</em>.host=localhost //IP of machine where tomcat1 is running</p>
<p style="padding-left:30px;">worker.<em>tomcat1</em>.type=ajp13 //AJP Connector type.</p>
<p style="padding-left:30px;">worker.<em>tomcat1</em>.lbfactor=100 //Load Balancing factor</p>
<p style="padding-left:30px;"># <em>Tomcat2 configuration</em></p>
<div style="padding-left:30px;">
<p>worker.<em>tomcat2</em>.port=8119 //AJP1.3 Connector&#8217;s port</p>
</div>
<div style="padding-left:30px;">
<p>worker.<em>tomcat2</em>.host=localhost //IP of machine where tomcat1 is running</p>
<p>worker.<em>tomcat2</em>.type=ajp13 //AJP Connector type.</p>
<p>worker.<em>tomcat2</em>.lbfactor=100 //Load Balancing factor</p>
<p>#<em>Load Balance worker configuration</em></p>
<p>worker.loadbalancer.type=lb</p>
<p><em><span style="font-style:normal;">worker.loadbalancer.balanced_workers=tomcat1,tomcat2</span></em></p>
</div>
<p><strong>Step 3: Configure JK module</strong></p>
<p>Copy the downloaded JK module file (mod_jk.so) to the modules directory of Apache Web Server. now goto conf directory of Apache Server, and open the <strong><em>httpd.conf </em></strong>file in the text editor.</p>
<p>and add these lines to the end of httpd.conf</p>
<p style="padding-left:30px;">LoadModule jk_module modules/mod_jk.so</p>
<p style="padding-left:30px;">JkWorkersFile conf/workers.properties</p>
<p style="padding-left:30px;">JkLogFile logs/mod_jk.log</p>
<p style="padding-left:30px;">JkLogLevel info</p>
<p>now you have done all the configuration, now you need to configure the JK Module to redirect the requests to specific tomcats. It can be done by the following:</p>
<p style="padding-left:30px;">To redirect specific request to specific Tomcat add this line to <em>httpd.conf:</em></p>
<p style="padding-left:30px;"><em>JkMount /abc/* tomcat1</em></p>
<p style="padding-left:30px;">or</p>
<p style="padding-left:30px;"><em>JkMount /*.do tomcat2</em></p>
<p style="padding-left:30px;">Or, if you want to configure requests to be served by any of the tomcat then add this:</p>
<p style="padding-left:30px;"><em>JkMount /*.jsp loadbalancer</em></p>
<p style="padding-left:30px;">if any of the tomcat is stopped then all the request will be served by other tomcat and if both the tomcat are running then the requests are redirected to tomcat servers according to the <em>lbfactor </em>specified in the workers.properties.</p>
<p>Now start all the Tomcat Servers and Apache Server, and its done.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/girishgaurav.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/girishgaurav.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/girishgaurav.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/girishgaurav.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/girishgaurav.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/girishgaurav.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/girishgaurav.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/girishgaurav.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/girishgaurav.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/girishgaurav.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/girishgaurav.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/girishgaurav.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/girishgaurav.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/girishgaurav.wordpress.com/84/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=girishgaurav.wordpress.com&amp;blog=14192500&amp;post=84&amp;subd=girishgaurav&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://girishgaurav.wordpress.com/2010/07/09/configuring-multiple-tomcat-application-servers-with-apache-http-server/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4d7fd057b8dd68f39ad0f33914557914?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">girishgaurav</media:title>
		</media:content>
	</item>
		<item>
		<title>Accessing Private Members of a Java class using Reflection</title>
		<link>http://girishgaurav.wordpress.com/2010/06/21/accessing-private-members-of-a-java-class-using-reflection/</link>
		<comments>http://girishgaurav.wordpress.com/2010/06/21/accessing-private-members-of-a-java-class-using-reflection/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 10:44:49 +0000</pubDate>
		<dc:creator>Girish Gaurav Agarwal</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Reflection]]></category>
		<category><![CDATA[reflection API]]></category>

		<guid isPermaLink="false">http://girishgaurav.wordpress.com/?p=21</guid>
		<description><![CDATA[Somebody asked me that, &#8220;Can we access private members of a Java Class?&#8220; Then I got the idea to write this article, because Java Reflection API provides a feature to access private members of a Java Class. java.lang.reflect package provides the AccessibleObject class that is parent class of Constructor, Method, and Field class. Using the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=girishgaurav.wordpress.com&amp;blog=14192500&amp;post=21&amp;subd=girishgaurav&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Somebody asked me that, &#8220;<em>Can we access private members of a Java Class?</em>&#8220;</p>
<p>Then I got the idea to write this article, because <strong>Java Reflection API</strong> provides a feature to access private members of a Java Class.</p>
<p><strong><em>java.lang.reflect </em></strong>package provides the <strong>AccessibleObject </strong>class that is parent class of Constructor, Method, and Field class. Using the AccessibleObject class, we can change the access control flags of a Reflection Object (<em>Reflection </em>is a feature in the Java programming language. It allows an executing Java program to examine or &#8220;introspect&#8221; upon itself, and manipulate internal properties of the program. For example, it&#8217;s possible for a Java class to obtain the names of all its members and display them.), and the <em>setAccessible(boolean)</em> method is used to change the access control flag of an Object.</p>
<p><strong>package</strong> test;</p>
<p>/**</p>
<p>* <strong>@author</strong> girish.gaurav</p>
<p>*</p>
<p>*/</p>
<p><strong>class</strong> DemoClass {</p>
<p style="padding-left:30px;"><strong>private</strong> <strong>int</strong> privateInt = 10;</p>
<p style="padding-left:30px;"><strong>private</strong> String privateString = &#8220;temp String&#8221;;</p>
<p style="padding-left:30px;"><strong>private</strong> <strong>long</strong> privateLong = 1234567890L;</p>
<p style="padding-left:30px;"><strong>private</strong> <strong>void</strong> resetFields(<strong>int</strong> i, String s, <strong>long</strong> l) {</p>
<p style="padding-left:60px;">privateInt = i;</p>
<p style="padding-left:60px;">privateString = s;</p>
<p style="padding-left:60px;">privateLong = l;</p>
<p style="padding-left:30px;">}</p>
<p style="padding-left:30px;"><strong>public</strong> <strong>void</strong> display() {</p>
<p style="padding-left:60px;">System.<em>out</em>.println(&#8220;Int = &#8221; + privateInt);</p>
<p style="padding-left:60px;">System.<em>out</em>.println(&#8220;String = &#8221; + privateString);</p>
<p style="padding-left:60px;">System.<em>out</em>.println(&#8220;Long = &#8221; + privateLong);</p>
<p style="padding-left:30px;">}</p>
<p>}</p>
<p><strong>class</strong> Test {</p>
<p style="padding-left:30px;">/**</p>
<p style="padding-left:30px;">* <strong>@param</strong> args</p>
<p style="padding-left:30px;">*/</p>
<p style="padding-left:30px;"><strong>public</strong> <strong>static</strong> <strong>void</strong> main(String[] args) {</p>
<p style="padding-left:60px;">DemoClass obj = <strong>new</strong> DemoClass();</p>
<p style="padding-left:60px;">obj.display();</p>
<p style="padding-left:60px;">Class clazz = obj.getClass();</p>
<p style="padding-left:60px;"><strong>try</strong> {</p>
<p style="padding-left:90px;">Field intField = clazz.getDeclaredField(&#8220;privateInt&#8221;);</p>
<p style="padding-left:90px;">Field strField = clazz.getDeclaredField(&#8220;privateString&#8221;);</p>
<p style="padding-left:90px;">Field longField = clazz.getDeclaredField(&#8220;privateLong&#8221;);</p>
<p style="padding-left:90px;">intField.setAccessible(<strong>true</strong>);</p>
<p style="padding-left:90px;">strField.setAccessible(<strong>true</strong>);</p>
<p style="padding-left:90px;">longField.setAccessible(<strong>true</strong>);</p>
<p style="padding-left:90px;">System.<em>out</em>.println(&#8220;value of privateInt field is : &#8220; + intField.get(obj));</p>
<p style="padding-left:90px;">System.<em>out</em>.println(&#8220;value of privateString field is : &#8220; + strField.get(obj));</p>
<p style="padding-left:90px;">System.<em>out</em>.println(&#8220;value of privateLong field is : &#8220; + longField.get(obj));</p>
<p style="padding-left:90px;">intField.set(obj, 100);</p>
<p style="padding-left:90px;">strField.set(obj, &#8220;this is new string&#8221;);</p>
<p style="padding-left:90px;">longField.set(obj, 55555L);</p>
<p style="padding-left:90px;">obj.display();</p>
<p style="padding-left:60px;">} <strong>catch</strong> (SecurityException e) {</p>
<p style="padding-left:90px;">e.printStackTrace();</p>
<p style="padding-left:60px;">} <strong>catch</strong> (NoSuchFieldException e) {</p>
<p style="padding-left:90px;">e.printStackTrace();</p>
<p style="padding-left:60px;">} <strong>catch</strong> (IllegalArgumentException e) {</p>
<p style="padding-left:90px;">e.printStackTrace();</p>
<p style="padding-left:60px;">} <strong>catch</strong> (IllegalAccessException e) {</p>
<p style="padding-left:90px;">e.printStackTrace();</p>
<p style="padding-left:60px;">}</p>
<p style="padding-left:60px;"><strong>try</strong> {</p>
<p style="padding-left:90px;">Method method = clazz.getDeclaredMethod(&#8220;resetFields&#8221;, <strong>int</strong>.<strong>class</strong>, String.<strong>class</strong>, <strong>long</strong>.<strong>class</strong>);</p>
<p style="padding-left:90px;">method.setAccessible(<strong>true</strong>);</p>
<p style="padding-left:90px;">method.invoke(obj, 25, &#8220;new String from resetField method.&#8221;, 987654321L);</p>
<p style="padding-left:90px;">obj.display();</p>
<p style="padding-left:60px;">} <strong>catch</strong> (SecurityException e) {</p>
<p style="padding-left:90px;">e.printStackTrace();</p>
<p style="padding-left:60px;">} <strong>catch</strong> (NoSuchMethodException e) {</p>
<p style="padding-left:90px;">e.printStackTrace();</p>
<p style="padding-left:60px;">} <strong>catch</strong> (IllegalArgumentException e) {</p>
<p style="padding-left:90px;">e.printStackTrace();</p>
<p style="padding-left:60px;">} <strong>catch</strong> (IllegalAccessException e) {</p>
<p style="padding-left:90px;">e.printStackTrace();</p>
<p style="padding-left:60px;">} <strong>catch</strong> (InvocationTargetException e) {</p>
<p style="padding-left:90px;">e.printStackTrace();</p>
<p style="padding-left:60px;">}</p>
<p style="padding-left:30px;">}</p>
<p>}</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/girishgaurav.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/girishgaurav.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/girishgaurav.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/girishgaurav.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/girishgaurav.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/girishgaurav.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/girishgaurav.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/girishgaurav.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/girishgaurav.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/girishgaurav.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/girishgaurav.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/girishgaurav.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/girishgaurav.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/girishgaurav.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=girishgaurav.wordpress.com&amp;blog=14192500&amp;post=21&amp;subd=girishgaurav&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://girishgaurav.wordpress.com/2010/06/21/accessing-private-members-of-a-java-class-using-reflection/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4d7fd057b8dd68f39ad0f33914557914?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">girishgaurav</media:title>
		</media:content>
	</item>
		<item>
		<title>Introduction to Nonblocking Sockets</title>
		<link>http://girishgaurav.wordpress.com/2010/06/14/introduction_to_nonblocking_sockets/</link>
		<comments>http://girishgaurav.wordpress.com/2010/06/14/introduction_to_nonblocking_sockets/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 10:06:39 +0000</pubDate>
		<dc:creator>Girish Gaurav Agarwal</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Channels and Selectors]]></category>
		<category><![CDATA[J2SE]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[NIO]]></category>
		<category><![CDATA[non-blocking sockets]]></category>
		<category><![CDATA[Sockets]]></category>

		<guid isPermaLink="false">http://girishgaurav.wordpress.com/?p=5</guid>
		<description><![CDATA[Here, I am going to explain what non-blocking sockets are, how it works, and where it can be useful, everything in details. Preface: Non-blocking sockets are introduced in Java 2 Standard Edition 1.4. It allows network communication between applications without blocking processes using the sockets. A nonblocking socket allows input/output operation on a channel without [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=girishgaurav.wordpress.com&amp;blog=14192500&amp;post=5&amp;subd=girishgaurav&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here, I am going to explain what non-blocking sockets are, how it works, and where it can be useful, everything in details.</p>
<p><strong>Preface:</strong></p>
<p><!-- 		@page { margin: 2cm } 		P { margin-bottom: 0.21cm } -->Non-blocking sockets are introduced in Java 2 Standard Edition 1.4. It allows network communication between applications without blocking processes using the sockets.</p>
<p>A nonblocking socket allows input/output operation on a channel without  blocking the processes using it. I&#8217;m talking about asynchronous  high-performance read/write operations that, as you will see, turn  upside-down the techniques for designing and developing socked-based  applications.</p>
<p>Java developers who already working or worked on sockets might ask that, &#8220;Why we use a new technology to work on Sockets while we already have an old one that working fine? Or whats wrong with the traditional (Java 1.3.x) socket programming? and What are the advantage with new non-blocking socket API?&#8221;</p>
<p>Suppose we are going to implement a server application that accepts huge number of client connections and as well as, we want the server that can be able to process multiple requests simultaneously. If we use older socket programming to achieve this requirement we have two ways:</p>
<p>1. Implement a multithread server that manually handles a thread for each connection.<br />
2. By using an external third-party module.</p>
<p>Both the given solution can work fine, but if we adopt first solution then the whole thread-management solution will be developed by the programmer and all the concurrency related issues will also be considered by the programmer. and the second solution may cost money. And by using Non-blocking sockets, you can implement a nonblocking server without directly managing threads or resorting to external modules.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/girishgaurav.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/girishgaurav.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/girishgaurav.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/girishgaurav.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/girishgaurav.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/girishgaurav.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/girishgaurav.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/girishgaurav.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/girishgaurav.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/girishgaurav.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/girishgaurav.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/girishgaurav.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/girishgaurav.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/girishgaurav.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=girishgaurav.wordpress.com&amp;blog=14192500&amp;post=5&amp;subd=girishgaurav&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://girishgaurav.wordpress.com/2010/06/14/introduction_to_nonblocking_sockets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4d7fd057b8dd68f39ad0f33914557914?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">girishgaurav</media:title>
		</media:content>
	</item>
	</channel>
</rss>
