<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;DEIFQX48eyp7ImA9WhRRFE4.&quot;"><id>tag:blogger.com,1999:blog-3855656585138701891</id><updated>2011-11-28T04:58:30.073+05:30</updated><title>Drink Eat Sleep Breathe .... Java</title><subtitle type="html">Java blog. My experiences, key learnings and best practices while coding in Java.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://breathing-java.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://breathing-java.blogspot.com/" /><author><name>Amey Bhide</name><uri>http://www.blogger.com/profile/16983821654401130379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://photos1.blogger.com/blogger/4314/722/1600/Amey_1.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/DrinkEatSleepBreatheJava" /><feedburner:info uri="drinkeatsleepbreathejava" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><entry gd:etag="W/&quot;C0EHSH4_cCp7ImA9WxFVEkk.&quot;"><id>tag:blogger.com,1999:blog-3855656585138701891.post-1901549011318811378</id><published>2010-06-11T12:59:00.005+05:30</published><updated>2010-06-11T13:03:59.048+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-06-11T13:03:59.048+05:30</app:edited><title>log4j ... Dynamic Log File Name</title><content type="html">&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;u&gt;Background:&lt;/u&gt;&lt;/strong&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;We developed a Bulk Loader component using core Java api's and used log4j for writing all the developer debugs, info, warn etc messages to a log file. The Bulk Loader, as the name suggests, sent bulk requests to application which enabled Load Testing. The Bulk Loader was developed in such a way that multiple instances could run on the same machine : this enabled controlling the load pushed to the application from various Bulk Loader instances.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;u&gt;Problem scenario:&lt;/u&gt;&lt;/strong&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;During testing, if was found that all the Bulk Loader instances running on one machine, used the same log file for writing their messages to. This made the log file illegible. Messages from different instances were interwoven into a single log file which made debugging a very tough job. A solution was needed for each instance to create and write to its own log file.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Method 1: Modify the java code for setting the correct log file name to the FileAppender&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Get hold of the all Appenders &amp;nbsp;from the Logger object&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Loop through each and find the Appender of interest. This will typically be the FileAppender&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Call the setFile( String fileName ) api&amp;nbsp;for setting desired log file name&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Call the activateOptions&amp;nbsp;for Log4j framework to pick the newly set log file name&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Though most of us would like and prefer to use the above method, there are two stark&amp;nbsp;limitations :&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;There can be multiple File Appenders defined in the log4j.xml. For example, my log4j.xml has two RollingFileAppenders; one with name as Process the other with Audit. In such cases, the logic of setting the log file name dynamically starts getting complex if lot of conditional checks&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If the source code of api responsible for initializing the Logger is not available (&lt;em&gt;this could be due to the fact that you, as a part of Services team, have the ability to invoke an exposed log( String message, int level ) method and initialization and configuration of the&amp;nbsp;Logger is taken care by the Product team&lt;/em&gt;), then you definitely cannot get hold to any of the Appenders and change the log file name.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Method&amp;nbsp;2: Modify the log4j.xml and Use -D switch&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;This&amp;nbsp;method does not require any code changes and hence no need to recompile. This method is only related to configuration of log4j.xml and the start command of java program.&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Open the log4j.xml and introduce a variable in front of the log file name definition. The variable name should be wrapped with special characters as follows: &lt;strong&gt;&lt;span style="color: blue;"&gt;${variable name}&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Following is the snippet from my log4j.xml&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;table width="90%" cellpadding="1" &gt;&lt;tr&gt;&lt;td bgcolor="ORANGE"&gt;&lt;table width="100%" &gt;&lt;tr&gt;&lt;td bgcolor="WHITE"&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;appender name="Process" class="org.apache.log4j.DailyRollingFileAppender"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;param name="File" value="./logs/&lt;strong&gt;&lt;span style="color: blue;"&gt;${log_file_name}_&lt;/span&gt;&lt;/strong&gt;Log.txt"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;appender name="AuditAppender" class="org.apache.log4j.RollingFileAppender"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;param name="File" value="./logs/&lt;span style="color: blue;"&gt;&lt;strong&gt;${log_file_name}&lt;/strong&gt;_&lt;/span&gt;Audit_log.txt"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Modify the start command of java application as below: &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;table width="90%" cellpadding="1" &gt;&lt;tr&gt;&lt;td bgcolor="ORANGE"&gt;&lt;table width="100%" &gt;&lt;tr&gt;&lt;td bgcolor="WHITE"&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;java &lt;strong&gt;&lt;span style="color: blue;"&gt;-Dlog_file_name=Items&lt;/span&gt;&lt;/strong&gt; -cp %CLASSPATH% HelloWorld&lt;/span&gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;This will create two log files by the name Items_Log.txt and Items_Audit.txt in the logs folder&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Hope this post was helpful. Happy Logging !&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3855656585138701891-1901549011318811378?l=breathing-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://breathing-java.blogspot.com/feeds/1901549011318811378/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3855656585138701891&amp;postID=1901549011318811378" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/1901549011318811378?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/1901549011318811378?v=2" /><link rel="alternate" type="text/html" href="http://breathing-java.blogspot.com/2010/06/log4j-dynamic-log-file-name.html" title="log4j ... Dynamic Log File Name" /><author><name>Amey Bhide</name><uri>http://www.blogger.com/profile/16983821654401130379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://photos1.blogger.com/blogger/4314/722/1600/Amey_1.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkIFR34zfCp7ImA9WxFRGUs.&quot;"><id>tag:blogger.com,1999:blog-3855656585138701891.post-5554992321771871123</id><published>2010-04-03T11:40:00.007+05:30</published><updated>2010-05-04T13:38:36.084+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-04T13:38:36.084+05:30</app:edited><title>A Webservice that WORKS !!!</title><content type="html">I faintly recollect the last webservice which I deployed on Tomcat in the year 2005. That was an achievement for me as no one in our team knew how to develop and deploy one. Four years and counting, I was facing the same challenge again. Unfortunately, I lost the reference project from year 2005 and here I was back to square one. &lt;br /&gt;
&lt;div&gt;&lt;/div&gt;Searching on Google indeed returned lot of results; but; I doubt if anybody has been able to get them work. Samples from sun-java tutorials always talk about using ant scripts to compile and prepare the target war files. Seldom do we use Sun's J2EE server in our projects; most of the times the application server used is WebSphere or Weblogic or JBOSS. The next problem is to build the component for successful deployment on Weblogic or JBOSS etc. &lt;br /&gt;
&lt;div&gt;&lt;/div&gt;I am being candid here. I tried a lot and hit many obstacles on the way. After breaking my head during leisure time, I managed to successfully expose and consume a webservice. The following section is my attempt to help folks who are in similar situation. I have tried to explain the following things:&lt;br /&gt;
&lt;br /&gt;
Steps to develop a simple webservice &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Most of the webservices tutorials use simple types while passing and return from the service. Frankly speaking, a webservice accepting an int and returning a String is of no use to anyone of us. We always have complex types i.e. custom objects which are used as request (i.e. input argument to the webservice) and response (i.e. return parameter from the webservice). &lt;/li&gt;
&lt;li&gt;Deployment on JBoss 4.0.5 GA &lt;/li&gt;
&lt;li&gt;Deployment on Weblogic 9.2 &lt;/li&gt;
&lt;li&gt;Test Client Standalone &lt;/li&gt;
&lt;li&gt;Test Client Weblogic &lt;/li&gt;
&lt;li&gt;Important points to remember&lt;/li&gt;
&lt;/ol&gt;Hope you are successful too ! &lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;strong&gt;&lt;u&gt;Software versions&lt;/u&gt;&lt;/strong&gt;: Jboss 4.0.5 GA, Weblogic 9.2, JDK 1.5.0.*, JWSDP 2.0 (very important)&lt;/div&gt;&lt;br /&gt;
&lt;div&gt;&lt;strong&gt;&lt;u&gt;Steps:&lt;/u&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;a href="http://2.bp.blogspot.com/_NsW-kSou9Jw/S7bZ8H3x5yI/AAAAAAAAAWU/MhsR-Y7doFI/s1600/webservices_folders.jpg" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="87" nt="true" src="http://2.bp.blogspot.com/_NsW-kSou9Jw/S7bZ8H3x5yI/AAAAAAAAAWU/MhsR-Y7doFI/s200/webservices_folders.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;1. Create the folder structure&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;The final folder from which the deployment ear/war/jar will be created is as follows:&lt;/div&gt;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
2. 2. Create the remote interface, implementation class and the input &amp;amp; output valueobjects. An important point to be considered is the nomenclature of the implementation class. When using servlets to masquerade the webservice, we are inclined to put the name as XYZServlet. This works fine when deploying the webservice in Weblogic. But Jboss has a problem; if the name of the servlet class has 'Servlet' in it, then that class is ignored during webservice deployment and is treated as a valid Servlet instead. &lt;br /&gt;
&lt;div&gt;&lt;/div&gt;Hence I recommend sticking to the XYZService nomenclature. XYZ will be remote interface a.k.a service end point and XYZService will be the implementation of the service.&lt;br /&gt;
&lt;br /&gt;
Adjust your IDE settings such that the ouput from compilation of the below mentioned java files, results into creation of class files under webapp\web-services\WEB-INF\classes folder&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;Interceptor.java&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;=================&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;package org.jboss.webservices.queuing;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import java.rmi.Remote;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import java.rmi.RemoteException;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import org.jboss.webservices.valueobjects.InterceptorRequest;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import org.jboss.webservices.valueobjects.InterceptorResponse;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;public interface Interceptor extends Remote {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; public InterceptorResponse addToQueue( InterceptorRequest req ) throws RemoteException;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; public String removeFromQueue( int positionNumber ) throws RemoteException;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;InterceptorService.java&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;=======================&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;package org.jboss.webservices.queuing;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import java.rmi.RemoteException;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import org.jboss.webservices.valueobjects.InterceptorRequest;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import org.jboss.webservices.valueobjects.InterceptorResponse;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;public class InterceptorService {&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; public InterceptorResponse addToQueue( InterceptorRequest req ) throws RemoteException {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println( "Interceptor request received is : " + req );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; InterceptorResponse res = new InterceptorResponse();&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; String[] result = new String[ 3 ];&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; result[ 0 ] = "First element";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; result[ 1 ] = "Second element";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; result[ 2 ] = "Third element";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; res.setResult( result );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return res;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; public String removeFromQueue( int positionNumber ) throws RemoteException {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; String retString = "Removed element at position " + positionNumber;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println( retString );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return retString;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;InterceptorRequest.java&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;=======================&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;package org.jboss.webservices.valueobjects;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import java.io.Serializable;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;public class InterceptorRequest implements Serializable {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; private String _soapMsg = null;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; private int _demuxId = -1;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; private long _entryTimeInMillis = 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; private String[] _tcgsUrls = null;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; public String getSoapMsg() {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return _soapMsg;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; public void setSoapMsg(String soapMsg) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this._soapMsg = soapMsg;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; public int getDemuxId() {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return _demuxId;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; public void setDemuxId(int demuxId) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this._demuxId = demuxId;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;and so on ... create getter and setter for each property&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;InterceptorResponse.java&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;========================&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;package org.jboss.webservices.valueobjects;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;import java.io.Serializable;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;public class InterceptorResponse implements Serializable {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; private String[] _result = null;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; public String[] getResult() {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return _result;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; public void setResult(String[] result) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this._result = result;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;3. Masquerade the webservice as a servlet: For this, we will add a web.xml with entries similar to the ones required while defining the servlet. The web.xml will reside at the following location : webapp\web-services\WEB-INF&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;&lt;span style="color: #cc0000;"&gt;web.xml&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;=======&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;&amp;lt;web-app xmlns="http://java.sun.com/xml/ns/j2ee"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;version="2.4"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: #cc0000;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: #cc0000;"&gt;&amp;lt;servlet&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;&amp;lt;servlet-name&amp;gt;InterceptorService&amp;lt;/servlet-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;&amp;lt;servlet-class&amp;gt;org.jboss.webservices.queuing.InterceptorService&amp;lt;/servlet-class&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;&amp;lt;/servlet&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: #cc0000;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: #cc0000;"&gt;&amp;lt;servlet-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;&amp;lt;servlet-name&amp;gt;InterceptorService&amp;lt;/servlet-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;&amp;lt;url-pattern&amp;gt;/Intercept&amp;lt;/url-pattern&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;&amp;lt;/servlet-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #cc0000;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: #cc0000;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: #cc0000;"&gt;&amp;lt;/web-app&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;Important points while developing the web xml:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;The servlet name should match in the servlet and servlet-mapping tag. &lt;/li&gt;
&lt;li&gt;The servlet class holds the fully qualified class name of the service implementation class. &lt;/li&gt;
&lt;li&gt;The url-pattern should be unique and not used anywhere else in the web xml.&lt;/li&gt;
&lt;/ol&gt;4. Build the configuration descriptor for webservice. Place this in a file called as interceptor_config.xml.&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;configuration xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;service name="InterceptorService"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;targetNamespace="http://queuing.webservice.jboss.org/"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;typeNamespace="http://queuing.webservice.jboss.org/types"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;packageName="org.jboss.webservices.queuing"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;interface name="org.jboss.webservices.queuing.Interceptor"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/service&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;Important points while developing the configuration descriptor:&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;The interface name is fully qualified class name of the service endpoint i.e. the remote interface&lt;br /&gt;
As a rule of thumb, I put the target namespace and type namespace in reverse order of the pakcage name of the service endpoint&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;5. Build the service using wscompile.bat file available in the jwsdp2-0\jaxrpc\bin folder. The command is as below: &lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;wscompile -verbose -classpath webapp/web-services/WEB-INF/classes -gen:server -f:rpcliteral -f:unwrap -d webapp/web-services/WEB-INF/classes -nd webapp/web-services/WEB-INF/wsdl -mapping webapp/web-services/WEB-INF/interceptor_mapping.xml interceptor_config.xml &lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;The wscompile command line arguments explanation is : &lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;-verbose : gives the detailed console output of wscompile &lt;br /&gt;
-classpath : represents the folder holding classes from which the webservice needs to be generated &lt;br /&gt;
-d : represents the destination where the service classes need to be generated &lt;br /&gt;
-nd : represents the destination where all the non class need to be generated &lt;br /&gt;
-mapping : represents the destination where the jaxrpc mapping xml needs to be generated.&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;On successful execution of wscompile, you should find Interceptor Stub, TIE, Literal Serializer and Deserializer class files generated in the folder given against the -d operator. You should also have an InterceptorService.wsdl file generated in the wsdl folder under WEB-INF. Given below are the classes generated on my machine along with the wsdl and jaxrpc-mapping file.&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;classes generated by javac&lt;br /&gt;
==========================&lt;br /&gt;
Interceptor.class&lt;br /&gt;
InterceptorService.class&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;classes generated by wscompile&lt;br /&gt;
==========================&lt;br /&gt;
InterceptorService_SerializerRegistry.class&lt;br /&gt;
Interceptor_addToQueue_RequestStruct.class&lt;br /&gt;
Interceptor_addToQueue_RequestStruct_LiteralSerializer.class&lt;br /&gt;
Interceptor_addToQueue_ResponseStruct.class&lt;br /&gt;
Interceptor_addToQueue_ResponseStruct_LiteralSerializer.class&lt;br /&gt;
Interceptor_removeFromQueue_RequestStruct.class&lt;br /&gt;
Interceptor_removeFromQueue_RequestStruct_LiteralSerializer.class&lt;br /&gt;
Interceptor_removeFromQueue_ResponseStruct.class&lt;br /&gt;
Interceptor_removeFromQueue_ResponseStruct_LiteralSerializer.class&lt;br /&gt;
Interceptor_Tie.class&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;&lt;span style="color: red;"&gt;WSDL&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;====&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;definitions name="InterceptorService" targetNamespace="http://queuing.webservice.jboss.org/" xmlns:tns="http://queuing.webservice.jboss.org/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns2="http://queuing.webservice.jboss.org/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;types&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;schema targetNamespace="http://queuing.webservice.jboss.org/types" xmlns:tns="http://queuing.webservice.jboss.org/types" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;complexType name="InterceptorRequest"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;sequence&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;element name="demuxId" type="int"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;element name="entryTimeInMillis" type="long"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;element name="soapMsg" type="string" nillable="true"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;element name="tcgsUrls" type="string" nillable="true" minOccurs="0" maxOccurs="unbounded"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/sequence&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/complexType&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;complexType name="InterceptorResponse"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;sequence&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;element name="result" type="string" nillable="true" minOccurs="0" maxOccurs="unbounded"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/sequence&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/complexType&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/schema&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/types&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;message name="Interceptor_addToQueue"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;part name="InterceptorRequest_1" type="ns2:InterceptorRequest"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/message&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;message name="Interceptor_addToQueueResponse"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;part name="result" type="ns2:InterceptorResponse"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/message&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;message name="Interceptor_removeFromQueue"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;part name="int_1" type="xsd:int"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/message&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;message name="Interceptor_removeFromQueueResponse"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;part name="result" type="xsd:string"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/message&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;portType name="Interceptor"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;operation name="addToQueue" parameterOrder="InterceptorRequest_1"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;input message="tns:Interceptor_addToQueue"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;output message="tns:Interceptor_addToQueueResponse"/&amp;gt;&amp;lt;/operation&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;operation name="removeFromQueue" parameterOrder="int_1"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;input message="tns:Interceptor_removeFromQueue"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;output message="tns:Interceptor_removeFromQueueResponse"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/operation&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/portType&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;binding name="InterceptorBinding" type="tns:Interceptor"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;operation name="addToQueue"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;soap:operation soapAction=""/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;input&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;soap:body use="literal" namespace="http://queuing.webservice.jboss.org/"/&amp;gt;&amp;lt;/input&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;output&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;soap:body use="literal" namespace="http://queuing.webservice.jboss.org/"/&amp;gt;&amp;lt;/output&amp;gt;&amp;lt;/operation&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;operation name="removeFromQueue"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;soap:operation soapAction=""/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;input&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;soap:body use="literal" namespace="http://queuing.webservice.jboss.org/"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/input&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;output&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;soap:body use="literal" namespace="http://queuing.webservice.jboss.org/"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/output&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/operation&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/binding&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;service name="InterceptorService"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;port name="InterceptorPort" binding="tns:InterceptorBinding"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;soap:address location="REPLACE_WITH_ACTUAL_URL"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/port&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/service&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/definitions&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style="color: red;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: red;"&gt;interceptor_mapping.xml i.e. jaxrpc mapping &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;===========================================&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;java-wsdl-mapping xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;package-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;package-type&amp;gt;org.jboss.webservices.queuing&amp;lt;/package-type&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;namespaceURI&amp;gt;http://queuing.webservice.jboss.org/types&amp;lt;/namespaceURI&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/package-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;package-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;package-type&amp;gt;org.jboss.webservices.queuing&amp;lt;/package-type&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;namespaceURI&amp;gt;http://queuing.webservice.jboss.org/&amp;lt;/namespaceURI&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/package-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;java-xml-type-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;java-type&amp;gt;org.jboss.webservices.valueobjects.InterceptorResponse&amp;lt;/java-type&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;root-type-qname xmlns:typeNS="http://queuing.webservice.jboss.org/types"&amp;gt;typeNS:InterceptorResponse&amp;lt;/root-type-qname&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;qname-scope&amp;gt;complexType&amp;lt;/qname-scope&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;variable-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;java-variable-name&amp;gt;result&amp;lt;/java-variable-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;xml-element-name&amp;gt;result&amp;lt;/xml-element-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/variable-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/java-xml-type-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;java-xml-type-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;java-type&amp;gt;org.jboss.webservices.valueobjects.InterceptorRequest&amp;lt;/java-type&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;root-type-qname xmlns:typeNS="http://queuing.webservice.jboss.org/types"&amp;gt;typeNS:InterceptorRequest&amp;lt;/root-type-qname&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;qname-scope&amp;gt;complexType&amp;lt;/qname-scope&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;variable-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;java-variable-name&amp;gt;demuxId&amp;lt;/java-variable-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;xml-element-name&amp;gt;demuxId&amp;lt;/xml-element-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/variable-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;variable-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;java-variable-name&amp;gt;entryTimeInMillis&amp;lt;/java-variable-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;xml-element-name&amp;gt;entryTimeInMillis&amp;lt;/xml-element-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/variable-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;variable-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;java-variable-name&amp;gt;soapMsg&amp;lt;/java-variable-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;xml-element-name&amp;gt;soapMsg&amp;lt;/xml-element-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/variable-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;variable-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;java-variable-name&amp;gt;tcgsUrls&amp;lt;/java-variable-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;xml-element-name&amp;gt;tcgsUrls&amp;lt;/xml-element-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/variable-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/java-xml-type-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;service-interface-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;service-interface&amp;gt;org.jboss.webservices.queuing.InterceptorService&amp;lt;/service-interface&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-service-name xmlns:serviceNS="http://queuing.webservice.jboss.org/"&amp;gt;serviceNS:InterceptorService&amp;lt;/wsdl-service-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;port-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;port-name&amp;gt;InterceptorPort&amp;lt;/port-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;java-port-name&amp;gt;InterceptorPort&amp;lt;/java-port-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/port-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/service-interface-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;service-endpoint-interface-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;service-endpoint-interface&amp;gt;org.jboss.webservices.queuing.Interceptor&amp;lt;/service-endpoint-interface&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-port-type xmlns:portTypeNS="http://queuing.webservice.jboss.org/"&amp;gt;portTypeNS:Interceptor&amp;lt;/wsdl-port-type&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-binding xmlns:bindingNS="http://queuing.webservice.jboss.org/"&amp;gt;bindingNS:InterceptorBinding&amp;lt;/wsdl-binding&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;service-endpoint-method-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;java-method-name&amp;gt;addToQueue&amp;lt;/java-method-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-operation&amp;gt;addToQueue&amp;lt;/wsdl-operation&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;method-param-parts-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;param-position&amp;gt;0&amp;lt;/param-position&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;param-type&amp;gt;org.jboss.webservices.valueobjects.InterceptorRequest&amp;lt;/param-type&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-message-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-message xmlns:wsdlMsgNS="http://queuing.webservice.jboss.org/"&amp;gt;wsdlMsgNS:Interceptor_addToQueue&amp;lt;/wsdl-message&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-message-part-name&amp;gt;InterceptorRequest_1&amp;lt;/wsdl-message-part-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;parameter-mode&amp;gt;IN&amp;lt;/parameter-mode&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/wsdl-message-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/method-param-parts-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-return-value-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;method-return-value&amp;gt;org.jboss.webservices.valueobjects.InterceptorResponse&amp;lt;/method-return-value&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-message xmlns:wsdlMsgNS="http://queuing.webservice.jboss.org/"&amp;gt;wsdlMsgNS:Interceptor_addToQueueResponse&amp;lt;/wsdl-message&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-message-part-name&amp;gt;result&amp;lt;/wsdl-message-part-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/wsdl-return-value-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/service-endpoint-method-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;service-endpoint-method-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;java-method-name&amp;gt;removeFromQueue&amp;lt;/java-method-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-operation&amp;gt;removeFromQueue&amp;lt;/wsdl-operation&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;method-param-parts-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;param-position&amp;gt;0&amp;lt;/param-position&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;param-type&amp;gt;int&amp;lt;/param-type&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-message-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-message xmlns:wsdlMsgNS="http://queuing.webservice.jboss.org/"&amp;gt;wsdlMsgNS:Interceptor_removeFromQueue&amp;lt;/wsdl-message&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-message-part-name&amp;gt;int_1&amp;lt;/wsdl-message-part-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;parameter-mode&amp;gt;IN&amp;lt;/parameter-mode&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/wsdl-message-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/method-param-parts-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-return-value-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;method-return-value&amp;gt;java.lang.String&amp;lt;/method-return-value&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-message xmlns:wsdlMsgNS="http://queuing.webservice.jboss.org/"&amp;gt;wsdlMsgNS:Interceptor_removeFromQueueResponse&amp;lt;/wsdl-message&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-message-part-name&amp;gt;result&amp;lt;/wsdl-message-part-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/wsdl-return-value-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/service-endpoint-method-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/service-endpoint-interface-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/java-wsdl-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;6. Link the webservice and servlet through the webservice.xml. Place the webservices.xml under webapp\web-services\WEB-INF&lt;br /&gt;
webservices.xml&lt;br /&gt;
===============&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;webservices xmlns="http://java.sun.com/xml/ns/j2ee"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd" version="1.1"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;webservice-description&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;webservice-description-name&amp;gt;InterceptorService&amp;lt;/webservice-description-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-file&amp;gt;WEB-INF/wsdl/InterceptorService.wsdl&amp;lt;/wsdl-file&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;jaxrpc-mapping-file&amp;gt;WEB-INF/interceptor_mapping.xml&amp;lt;/jaxrpc-mapping-file&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;port-component&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;port-component-name xmlns:sns="http://queuing.webservice.jboss.org/"&amp;gt;sns:Interceptor&amp;lt;/port-component-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl-port xmlns:sns="http://queuing.webservice.jboss.org/"&amp;gt;sns:InterceptorPort&amp;lt;/wsdl-port&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;service-endpoint-interface&amp;gt;org.jboss.webservices.queuing.Interceptor&amp;lt;/service-endpoint-interface&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;service-impl-bean&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;servlet-link&amp;gt;InterceptorService&amp;lt;/servlet-link&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/service-impl-bean&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/port-component&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/webservice-description&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/webservices&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;Important points:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;The webservice description name and the servlet name should match. &lt;/li&gt;
&lt;li&gt;The wsdl file name along with relative path from WEB-INF folder should be crrect&lt;/li&gt;
&lt;li&gt;The jaxrpc mapping file should point to the interceptor_mapping xml file&lt;/li&gt;
&lt;li&gt;The port component name should match the value of the portType tag's name attribute in the wsdl file&lt;/li&gt;
&lt;li&gt;The wsdl port should match the value of the port tags name attribute in the wsdl file&lt;/li&gt;
&lt;li&gt;The service endpont interface holds the fully qualified name of our remote interface&lt;/li&gt;
&lt;li&gt;The service impl bean holds a link to the servlet name.&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;div&gt;7. The finalstructure of the webapp folder:&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_NsW-kSou9Jw/S7bg1ExzCAI/AAAAAAAAAWc/djKEROpOwQQ/s1600/webservices_folders_final.jpg" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" nt="true" src="http://4.bp.blogspot.com/_NsW-kSou9Jw/S7bg1ExzCAI/AAAAAAAAAWc/djKEROpOwQQ/s320/webservices_folders_final.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;8. Open command prompt. Navigate inside the webapp/web-services folder. Create a war file of all contents in the web-services folder. Command for creating the war file is :&lt;/div&gt;&lt;div&gt;jar -cvf web-services.war *&lt;/div&gt;&lt;div&gt;&lt;/div&gt;This creates a web-services.war file. Copy the web-services war file in the %JBOSS_HOME%\server\default\deploy folder. Start jboss and check the console. You should find the following lines:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Navigate to the %JBOSS_HOME%\server\default\data\wsdl folder. You should see a web-services.war folder in there. Inside this folder, you should find the InterceptorService.wsdl file. This means that the webservice is successfully deployed. In order to consume the webservice, a manual change in the deployed wsdl is necessary. This is shortcoming of JBOSS 4.0.5 GA. Open the InterceptorService.wsdl file and go to the end where the service is defined as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;service name="InterceptorService"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;port name="InterceptorPort" binding="tns:InterceptorBinding"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;soap:address location="http://pni3p103:8080/web-services/Intercept"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/port&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/service&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Change the port number in the URL of the location attribute of the address tag. The port number is defaulted to 8080 by JBOSS. Change this to the appropriate port number which JBOSS is listening too. In my case, I have changed it to 7001. In case the editor flags a "sharing or access violation" while saving the modified wsdl; don't panic. This means that the app server has successfully loaded the wsdl and you need not explicitly change the ports. My Jboss allowed me to change the wsdl most of the times; but I did observe this file being locked by the appserver which did not allow modification to the port number. But I was able to access the wsdl successfully though !&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;lt;service name="InterceptorService"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;lt;port name="InterceptorPort" binding="tns:InterceptorBinding"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;lt;soap:address location="http://pni3p103:7001/web-services/Intercept"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;lt;/port&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;lt;/service&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Try accessing the url by suffixing ?WSDL to it : http://pni3p103:7001/web-services/Intercept?WSDL This should render the wsdl on your internet browser. Your webservice is successfully deployed !&lt;br /&gt;
&lt;br /&gt;
9. Deploy in Weblogic:&lt;br /&gt;
Weblogic gives us ability to deploy the folder instead of packaging it into a war file; we will use this feature. I recommend making a copy of the webapp folder so that weblogic files do not meddle with jboss files. Create a folder Weblogic and copy the webapp folder under this. Start your Weblogic server; remember to shutdown JBoss in case you have both on a single machine. I typically make all the app servers listen to the same port due to which I can have only one instance running at a time. Once the Weblogic server has started, log into the administration console. The url is http://machine-name:port-number/console Login to the application. Click on Lock and Edit button --&amp;gt; click on Deployments --&amp;gt; click on Install button. Browse to the Weblogic\webapps\web-services. Select web-services folder and deploy as an application by clicking Next and selecting all others as defaults. Finally click on the Activate changes green button. Restart Weblogic instance and login to the administration console again.&lt;br /&gt;
&lt;br /&gt;
In the Deployments, you should see web-services application in the Active state. If it is in prepared state, select the web-service application and click on Start --&amp;gt; Start servicing all requests. Click on the plus sign beside the web-service application and it will display the InterceptorService. Now there are couple of additional steps required by Weblogic. Click on the InterceptorService --&amp;gt; Click on the Configuration tab --&amp;gt; Select View Dynamic WSL Enabled and click Save. This will bring up a Deployment Plan Assistance. Select WEB-INF radio button and click Finish. Activate the Changes and restart Weblogic instance. Try to access the URL for the WSDL. If your Jboss and Weblogic listen the same port, the URL will remain same. &lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;a href="http://3.bp.blogspot.com/_NsW-kSou9Jw/S7c1ODfZMjI/AAAAAAAAAWk/99KN_J0JBHg/s1600/webservices_weblogic_screens.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="419" nt="true" src="http://3.bp.blogspot.com/_NsW-kSou9Jw/S7c1ODfZMjI/AAAAAAAAAWk/99KN_J0JBHg/s640/webservices_weblogic_screens.JPG" width="640" /&gt;&lt;/a&gt;10. Test from standalone client&lt;/div&gt;&lt;br /&gt;
Create a separate java project. Create an interceptor_client_config.xml file with the following entries&lt;br /&gt;
intercept_client_config.xml&lt;br /&gt;
===========================&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;configuration&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;wsdl location="http://localhost:7001/web-services/Intercept?WSDL"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;packageName="org.jboss.webservices.queuing"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Build client stubs using the wscompile. The command is:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
wscompile -verbose -d . -gen:client intercept_client_config.xml&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create a WebservicesClient.java. Put the following code in it.&lt;br /&gt;
&lt;span style="color: blue;"&gt;import java.net.URL;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import javax.xml.namespace.QName;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import javax.xml.rpc.Service;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import javax.xml.rpc.ServiceFactory;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import org.jboss.webservices.hello.Hello;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import org.jboss.webservices.hello.SayHello;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import org.jboss.webservices.queuing.Interceptor;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import org.jboss.webservices.queuing.InterceptorRequest;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import org.jboss.webservices.queuing.InterceptorResponse;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;public class WebservicesClient&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; public static void main(String[] args) throws Exception {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; addToQueue();&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; removeFromQueue();&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;private static void removeFromQueue() throws Exception {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;String urlstr = "http://localhost:7001/web-services/Intercept?WSDL";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;System.out.println("Contacting webservice at " + urlstr);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;URL url = new URL(urlstr);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;QName qname = new QName("http://queuing.webservice.jboss.org/", "InterceptorService");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;ServiceFactory factory = ServiceFactory.newInstance();&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Service service = factory.createService(url, qname);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Interceptor intercept = ( Interceptor ) service.getPort( Interceptor.class );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;System.out.println("Interceptor.removeFromQueue( 0 )");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Object o = intercept.removeFromQueue( 0 );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;System.out.println( "Class ::&amp;gt;&amp;gt; " + o.getClass() );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;System.out.println( "output : " + o );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;private static void addToQueue() throws Exception {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;String urlstr = "http://localhost:7001/web-services/Intercept?WSDL";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;System.out.println("Contacting webservice at " + urlstr);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;URL url = new URL(urlstr);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;QName qname = new QName("http://queuing.webservice.jboss.org/", "InterceptorService");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;ServiceFactory factory = ServiceFactory.newInstance();&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Service service = factory.createService(url, qname);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Interceptor intercept = ( Interceptor ) service.getPort( Interceptor.class );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;InterceptorRequest req = new InterceptorRequest();&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;req.setDemuxId( 1 );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;req.setEntryTimeInMillis( 1000L );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;req.setSoapMsg( "ameybhide soap msg" );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;req.setTcgsUrls( new String[] { "a", "m", "e", "y" } );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;System.out.println("Interceptor.addToQueue( " + req + " )");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Object o = intercept.addToQueue( req );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;System.out.println( "Class ::&amp;gt;&amp;gt; " + o.getClass() );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;InterceptorResponse res = ( InterceptorResponse )o;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;System.out.println( "output ::&amp;gt;&amp;gt; [InterceptorResponse]: " );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;if( res.getResult() != null &amp;amp;&amp;amp; res.getResult().length &amp;gt; 0 ) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;System.out.println( "Elements ::&amp;gt;&amp;gt; " );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;for ( int counter = 0; counter &amp;lt; res.getResult().length; counter++ ) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;System.out.println( res.getResult()[ counter ] );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;} else {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;System.out.println( "Empty" );&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
You will need the following jar files on your classpath before you run the above class file&lt;br /&gt;
- the stub classes generated as a result of the wscompile command&lt;br /&gt;
- jwsdp2-0/jaxrpc/lib/jaxrpc-api.jar&lt;br /&gt;
- jwsdp2-0/jaxrpc/lib/jaxrpc-impl.jar&lt;br /&gt;
- jwsdp2-0/jaxrpc/lib/jaxrpc-spi.jar&lt;br /&gt;
- jboss-4.0.5.GA/client/activation.jar&lt;br /&gt;
- jboss-4.0.5.GA/client/mail.jar&lt;br /&gt;
- jboss-4.0.5.GA/client/namespace.jar&lt;br /&gt;
- jwsdp2-0/saaj/lib/saaj-api.jar&lt;br /&gt;
- jwsdp2-0/saaj/lib/saaj-impl.jar&lt;br /&gt;
- jwsdp2-0/fastinfoset/lib/FastInfoset.jar&lt;br /&gt;
- jwsdp2-0/sjsxp/lib/jsr173_api.jar&lt;br /&gt;
&lt;br /&gt;
Run the WebservicesClient. You should see the following output:&lt;br /&gt;
Contacting webservice at http://localhost:7001/web-services/Intercept?WSDL&lt;br /&gt;
Interceptor.addToQueue( org.jboss.webservices.queuing.InterceptorRequest@273686 )&lt;br /&gt;
Class ::&amp;gt;&amp;gt; class org.jboss.webservices.queuing.InterceptorResponse&lt;br /&gt;
output ::&amp;gt;&amp;gt; [InterceptorResponse]: &lt;br /&gt;
&lt;br /&gt;
Elements ::&amp;gt;&amp;gt; &lt;br /&gt;
First element&lt;br /&gt;
Second element&lt;br /&gt;
Third element &lt;br /&gt;
Contacting webservice at http://localhost:7001/web-services/Intercept?WSDL &lt;br /&gt;
Interceptor.removeFromQueue( 0 )&lt;br /&gt;
Class ::&amp;gt;&amp;gt; class java.lang.String&lt;br /&gt;
output : Removed element at position 0 &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
All the Best !!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3855656585138701891-5554992321771871123?l=breathing-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://breathing-java.blogspot.com/feeds/5554992321771871123/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3855656585138701891&amp;postID=5554992321771871123" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/5554992321771871123?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/5554992321771871123?v=2" /><link rel="alternate" type="text/html" href="http://breathing-java.blogspot.com/2010/04/webservice-that-works_03.html" title="A Webservice that WORKS !!!" /><author><name>Amey Bhide</name><uri>http://www.blogger.com/profile/16983821654401130379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://photos1.blogger.com/blogger/4314/722/1600/Amey_1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_NsW-kSou9Jw/S7bZ8H3x5yI/AAAAAAAAAWU/MhsR-Y7doFI/s72-c/webservices_folders.jpg" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkIFQXg7eCp7ImA9WxFTFEg.&quot;"><id>tag:blogger.com,1999:blog-3855656585138701891.post-1902003796844476500</id><published>2010-03-12T13:31:00.000+05:30</published><updated>2010-04-05T13:31:50.600+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-05T13:31:50.600+05:30</app:edited><title>Remote Debugging with Eclipse</title><content type="html">&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;My eyes were glued to the monitor, fingers doing a tap dance on the F6 key periodically using F5 and F8 too. A colleague walked over to my cubicle and asked me what I was doing. After giving him a I-didn't-want-to-be-disturbed look, I told him I was debugging a server side Java code. He was surprized. He knew how to debug a stand alone Java application using Eclipse. It was as simple as running the application through the Debug mode, introducing a breakpoint and changing the perspective of Eclipse to Debug. He was not aware that we could do the same on a code getting executed inside an application server.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Simple ... I told him. The only change required is to setup a Remote Java application in Eclipse and modify the start up scripts of your application sever. Piece of cake ! &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;We use Websphere, Weblogic and JBoss applicaiton servers the most in our projects. I have listed down steps for configuring Eclipse and these application servers for debugging your J2EE components. Hope it saves your time spent in restart, recompile, redeploy of J2EE components. Finding a problem is very easy when you have the power of debugger !&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;u&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Weblogic 9.2:&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Open the startWebLogic.cmd file present in the bin folder withing your user domain.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Search for text -Xrunjdwp in this cmd file. If you find one, stick to modifying it. If you don't find one, then you will need to add the following line:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set JAVA_OPTIONS=%JAVA_OPTIONS% -Xdebug&amp;nbsp;-Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Some advice to set the debug parameters in the DEBUG_OPTS variable. But I prefer sticking to the JAVA_OPTIONS as these are definitely put on the command for launching the weblogic application server.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;The address=1044 tells the&amp;nbsp;application server to connect the debugger over 1044 port. In case the port is in user, change it to some other port like 7002 or 9001&amp;nbsp; whichever is free. &lt;/span&gt;&lt;/li&gt;
&lt;li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;The suspend=n tells the application server to continue with the startup and execution even if no debugger is attached&lt;/span&gt;&lt;/li&gt;
&lt;li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If the value of suspend attribute is changed to y i.e. suspend=y, then the application server's JVM starts in suspended mode and stays suspended till some debugger gets attached to it. &lt;/span&gt;&lt;/li&gt;

&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_NsW-kSou9Jw/S7mPrfHr0vI/AAAAAAAAAWs/yC4wzRIB-DY/s1600/Remote+Debugging_Weblogic.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;img border="0" height="316" nt="true" src="http://4.bp.blogspot.com/_NsW-kSou9Jw/S7mPrfHr0vI/AAAAAAAAAWs/yC4wzRIB-DY/s640/Remote+Debugging_Weblogic.JPG" width="640" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Start Weblogic. You should see the text highlighted in the image&amp;nbsp;above on your console too.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;JBoss 4.0.5 GA :&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/div&gt;&lt;ul&gt;&lt;li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Open the run.bat file present in the bin directory of JBoss installation&lt;/span&gt;&lt;/li&gt;
&lt;li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Look for the following text : &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rem JPDA options. Uncomment and modify as appropriate to enable remote debugging.&lt;/span&gt;&lt;/div&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rem set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%&lt;/span&gt;&lt;/div&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;ul&gt;&lt;li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If you find it, then uncomment the set JAVA_OPTS by removing the rem keyword. &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If you do not find the text, add the following text :&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=y %JAVA_OPTS%&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;The address=1044 tells the application server to connect the debugger over 1044 port. In case the port is in user, change it to some other port like 7002 or 9001 whichever is free.&lt;/span&gt;&lt;/li&gt;
&lt;li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;The suspend=n tells the application server to continue with the startup and execution even if no debugger is attached.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If the value of suspend attribute is changed to y i.e. suspend=y, then the application server's JVM starts in suspended mode and stays suspended till some debugger gets attached to it&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;a href="http://4.bp.blogspot.com/_NsW-kSou9Jw/S7mQIZ8LpTI/AAAAAAAAAW0/j9Ndhqoo-bc/s1600/Remote+Debugging_JBoss.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;img border="0" height="320" nt="true" src="http://4.bp.blogspot.com/_NsW-kSou9Jw/S7mQIZ8LpTI/AAAAAAAAAW0/j9Ndhqoo-bc/s640/Remote+Debugging_JBoss.JPG" width="640" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Start JBoss. You should see the text as shown in the image&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;strong&gt;&lt;u&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Websphere 6.1.0.13:&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Open the admin console of Websphere. This is generally &lt;/span&gt;&lt;a href="https://machine-name:9043/ibm/console"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;https://machine-name:9043/ibm/console&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Login using correct credentials&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;On the left navigation pane, open Servers --&amp;gt; Application Servers. On the right pane, click on your server name that needs to be started up in&amp;nbsp;debug mode.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;This takes&amp;nbsp;you to the Configuration tab. Scroll to the botton to find a section for Additional Properties. Click on the Debugging Services link.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Change the JVM debug port to 1044. &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Append the following text to the JVM debug arguments:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;The address=1044 tells the application server to connect the debugger over 1044 port. In case the port is in user, change it to some other port like 7002 or 9001 whichever is free&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;The suspend=n tells the application server to continue with the startup and execution even if no debugger is attached.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If the value of suspend attribute is changed to y i.e. suspend=y, then the application server's JVM starts in suspended mode and stays suspended till some debugger gets attached to it.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Click on OK button. &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Restart the Websphere instance&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_NsW-kSou9Jw/S7mVmb4F25I/AAAAAAAAAW8/6MV15_CswQI/s1600/Remote+Debugging_Websphere.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;img border="0" height="337" nt="true" src="http://2.bp.blogspot.com/_NsW-kSou9Jw/S7mVmb4F25I/AAAAAAAAAW8/6MV15_CswQI/s640/Remote+Debugging_Websphere.JPG" width="640" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;strong&gt;&lt;u&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Eclipse 3.3.0 :&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Start one of the application server (Weblogic/Websphere/JBOSS)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Launch eclipse. Change to the Debug perspective. Open the Debug Dialog.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Select the Remote Java Application and Click on New Launch configuration (the button on the top left)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Give suitable name for this debug app ( I have given it same as application server name i.e. JBOSS)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Select the project which you want to debug. This could be your EJB, Webservice, Servlet etc&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Give the hostname as the machine name where the application server is running. The port number should match the value of the address attribute set in the start up script off application server (we have provided the address in the above sections)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;a href="http://1.bp.blogspot.com/_NsW-kSou9Jw/S7mYbkMTr0I/AAAAAAAAAXE/Nxw7k9x-hdQ/s1600/Remote+Debugging_Eclipse_1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;img border="0" height="504" nt="true" src="http://1.bp.blogspot.com/_NsW-kSou9Jw/S7mYbkMTr0I/AAAAAAAAAXE/Nxw7k9x-hdQ/s640/Remote+Debugging_Eclipse_1.JPG" width="640" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Click on apply. Then click on Debug. You should see multiple Java threads listed in the Debug perspective.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_NsW-kSou9Jw/S7mYiXyK2hI/AAAAAAAAAXM/VbG9D7q5CnU/s1600/Remote+Debugging_Eclipse_2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;img border="0" nt="true" src="http://3.bp.blogspot.com/_NsW-kSou9Jw/S7mYiXyK2hI/AAAAAAAAAXM/VbG9D7q5CnU/s320/Remote+Debugging_Eclipse_2.JPG" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Now you can insert break points in the project and debug the J2EE components deployed in application server.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Happy debugging !&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3855656585138701891-1902003796844476500?l=breathing-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://breathing-java.blogspot.com/feeds/1902003796844476500/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3855656585138701891&amp;postID=1902003796844476500" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/1902003796844476500?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/1902003796844476500?v=2" /><link rel="alternate" type="text/html" href="http://breathing-java.blogspot.com/2010/04/remote-debugging-with-eclipse.html" title="Remote Debugging with Eclipse" /><author><name>Amey Bhide</name><uri>http://www.blogger.com/profile/16983821654401130379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://photos1.blogger.com/blogger/4314/722/1600/Amey_1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_NsW-kSou9Jw/S7mPrfHr0vI/AAAAAAAAAWs/yC4wzRIB-DY/s72-c/Remote+Debugging_Weblogic.JPG" height="72" width="72" /><thr:total>5</thr:total></entry><entry gd:etag="W/&quot;CkADR30_fyp7ImA9WxdQGE0.&quot;"><id>tag:blogger.com,1999:blog-3855656585138701891.post-3044771878183696564</id><published>2008-06-18T16:41:00.002+05:30</published><updated>2008-06-18T20:22:56.347+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-06-18T20:22:56.347+05:30</app:edited><title>Persistence, Concurrency and RTTI</title><content type="html">&lt;span style="font-family:arial;"&gt;I got a request to write about Java tenets: Persistence, Concurrency and RTTI. My two cents ....&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Persistence:&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;Object persistence (a.k.a Serialization in Java) is ability to read/write state of object on a stream. Persistence is useful/required in situations when object's state needs to be retained/stored across invocation of a program or when an object needs to be synchronized across JVM's. Examples of persistence are:&lt;br /&gt;&lt;/span&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Storing object state to a file - File input and output streams&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Storing object state to a database &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Sending/Receiving/Synchronizing object state across JVM - typically over sockets&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;Quoting -Carting applications generally use Persistence. A Quote object contains items that you wish to purchase from the online portal. Multiple Quote objects taken together make up a Cart object. The 'Save Cart' option actually serializes the entire Cart object into a Blob colum inside a database table. The Cart object can be reloaded from the db at a later instant to view the complete order. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;This brings up two important aspects of Persistence:&lt;/span&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;The entire object state is serialized to the stream (except for transient variables). Object's properties can be primitives or references to other Object's. Thus each such object also needs to be serialized. In a nutshell, serializing an object results into serialization of all objects contained in the current object till nth level.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Reflections api is used to create a object by reading its state from the stream.&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;An object can be serialized only if it implements the marker interface 'Serializable'.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;&lt;u&gt;Concurrency:&lt;br /&gt;&lt;/u&gt;&lt;/strong&gt;Java supports MultiThreading. A Thread object is a lightweight process and multiple Threads execute concurrently in JVM. This brings up a potential problem of data corruption by simultaneous access via multiple Threads or in other words maintaining sanctity of data being accessed/mutated by various Threads. Use of synchronized keyword, wait() and notify() methods help us in solving the aforementioned issues. I will not go deep into implementation details of wait(), notify() and synchronized as these will be addressed in the Multi Threading blog. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;Each object has a monitor associated with it. When a Thread comes across a synchronized method or block during its execution, it obtains the monitor on the object before entering the method or block. Only one Thread can obtain the monitor on an object. Thus in case a second Thread wants to execute another/same synchronized method/block of the same object, then it blocks till the first Thread release the previously obtained monitor.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;&lt;u&gt;&lt;strong&gt;RTTI (R&lt;/strong&gt;un&lt;strong&gt;T&lt;/strong&gt;ime&lt;strong&gt; T&lt;/strong&gt;ype&lt;strong&gt; I&lt;/strong&gt;dentification&lt;strong&gt;):&lt;/strong&gt;&lt;/u&gt;&lt;strong&gt; &lt;/strong&gt;&lt;br /&gt;RTTI helps us in identifying the object type at runtime as there may be a need to check the object type prior to executing a chunk of business logic. Implementing Polymorphism with interfaces to achieve extensibilty introduces use of base class reference when objects communicate with each other by sending messages. For example, consider the following hierarchy: Animal interface has implmentation classes Wild and Tame which are further extended by Lion, Tiger, Elephant, Deer, Snake, Dog, Cat etc&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Arial;"&gt;With appropriate OO design we will introduce api's like getNumberOfLegs in the Animal interface which will be implemented in the concrete derived classes. While passing a list of animals, each of the element in the list will be Animal reference. But what if we wanted to increment a counter for all animals that were Wild? We can add an isWild() api to Animal class and implement it in Wild and Tame classes. This will get automatically inherited into all the subclasses. The basic purpose of introducing Wild and Tame subclasses gets defeated because within Tame, we are implementing isWild() which returns false. Not a good design.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Arial;"&gt;Instead, while iterating over the Animal list, we can use the instanceof operator, which is Java api for RTTI. We can check if the current element is an instance of Wild and then conditionally increment the counter. Having said this, use of instanceof operator is very heavy and affects the performance. A code having number of if .. else if .. else if ... statements involving instanceof operator suggests bad design.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Arial;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3855656585138701891-3044771878183696564?l=breathing-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://breathing-java.blogspot.com/feeds/3044771878183696564/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3855656585138701891&amp;postID=3044771878183696564" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/3044771878183696564?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/3044771878183696564?v=2" /><link rel="alternate" type="text/html" href="http://breathing-java.blogspot.com/2008/06/persistence-concurrency-and-rtti.html" title="Persistence, Concurrency and RTTI" /><author><name>Amey Bhide</name><uri>http://www.blogger.com/profile/16983821654401130379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://photos1.blogger.com/blogger/4314/722/1600/Amey_1.jpg" /></author><thr:total>4</thr:total></entry><entry gd:etag="W/&quot;DkUFQHw-fyp7ImA9WxdQF0w.&quot;"><id>tag:blogger.com,1999:blog-3855656585138701891.post-2549185073740841861</id><published>2008-06-17T17:45:00.005+05:30</published><updated>2008-06-17T20:20:11.257+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-06-17T20:20:11.257+05:30</app:edited><title>Parameter Passing</title><content type="html">Objects communicate with each other by sending messages. Sending a message basically means invoking one of the methods from the published contract of other object. Most of the methods will involve passing arguments back and forth between objects.&lt;br /&gt;&lt;br /&gt;A method, in C/C++ or Java, can have only one return type, but the signature of method can have a number of arguments in it. For example, the following method declaration is valid:&lt;br /&gt;&lt;pre id="Classes"&gt;&lt;br /&gt;&lt;a name="3"&gt;&lt;/a&gt;  &lt;span id="Public"&gt;public&lt;/span&gt; String getName( List myList, &lt;span id="Int"&gt;int&lt;/span&gt; count ) {&lt;br /&gt;&lt;a name="4"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="5"&gt;&lt;/a&gt;    ...&lt;br /&gt;&lt;a name="5"&gt;&lt;/a&gt;    ...&lt;br /&gt;&lt;a name="6"&gt;&lt;/a&gt;  }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The above declaration says that the getName method accepts two parameters and returns a String. There is no syntactically legal construct that allows us to return two String objects.&lt;br /&gt;&lt;br /&gt;C/C++ developers use a typical coding practice. The return from a method will always be an int. A return of zero indicates successful execution of the method whereas a non-zero return value indicates some error in method execution. This error code is then passed to another api to get the complete error report. A value that needs to be returned from the method is accepted as input argument itself which is subsequently modified in the method. A typical C/C++ api signature is as follows which clearly mentions input and output parameters.&lt;br /&gt;&lt;pre id="Classes"&gt;&lt;br /&gt;/**&lt;br /&gt; *   This function will return all the views,&lt;br /&gt; *   for a given Item.&lt;br /&gt; */&lt;br /&gt;extern C_API int ITEM_list_all_view_revs(&lt;br /&gt;    &lt;br /&gt;    obj_o    item,    /** &lt; (I) Tag of the item */     &lt;br /&gt;    int*     count,   /** &lt; (O) Number of views attached to the above Item */&lt;br /&gt;    obj_o**  views    /**&lt; (OF) count objects of views for the Item */     ); &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This is where we have to be careful while passing arguments to ITEM_list_all_view_revs api. The obj_o is an input which will be read by the method to list the views. This will be pass by value. The int* count and obj_o** views will be mutated by the method. These have to be pass by reference.&lt;br /&gt;&lt;br /&gt;Is it the same when we invoke methods in Java? Yes and No. Yes, we can pass arguments to methods and mutate the same in side the method body. No, there is no such thing as passing by reference in Java. All parameters/arguments in Java are always pass by value. Surprized?&lt;br /&gt;&lt;br /&gt;Java does not have the concept of pointers. In case of primitives, the memory location at which the variable is defined holds the value of the variable. For example, writing int i = 5 creates a variable i at say memory location 100 which holds value 5. In case of objects, the object is created on the heap and its memory location address is stored as a value at the memory location where the reference to the object is created. For example, writing List myList = new ArrayList() creates an object of type ArrayList on the heap at say memory location 1000. A reference myList is created at a different memory location say 200 and the value stored at this memory location is 1000.&lt;br /&gt;&lt;br /&gt;Suppose we were to call the above declared java method, the code fragment would be somthing like:&lt;br /&gt;&lt;br /&gt;&lt;pre id="Classes"&gt;&lt;br /&gt;&lt;a name="10"&gt;&lt;/a&gt;    List myList = &lt;span id="New"&gt;new&lt;/span&gt; ArrayList();&lt;br /&gt;&lt;a name="11"&gt;&lt;/a&gt;    &lt;span id="Int"&gt;int&lt;/span&gt; count = &lt;span id="IntegerLiteral"&gt;5&lt;/span&gt;;&lt;br /&gt;&lt;a name="12"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="13"&gt;&lt;/a&gt;    ParameterPassing pp = &lt;span id="New"&gt;new&lt;/span&gt; ParameterPassing();&lt;br /&gt;&lt;a name="14"&gt;&lt;/a&gt;    pp.getName( myList, count );&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Essentially what is getting passed is the value at the memory location of variables myList and count. myList is a reference to object and hence holds the address of the object created on heap whereas count is a primitive and directly holds the value. Thus in the getName method if we were to call the myList.add("xyz") method, then it will go and modify the object state on the heap. But if we do count++ within the getName method then the value is modified withing the method scope but not persisted back to the memory location where it originated from.&lt;br /&gt;&lt;br /&gt;The crux of paramter passing in Java is as follows:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Parameters/Arguments are always &lt;strong&gt;&lt;em&gt;passed by value&lt;/em&gt;&lt;/strong&gt; &lt;/li&gt;&lt;li&gt;Objects are always &lt;strong&gt;&lt;em&gt;mutated by reference&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;Another implementation detail to be kept in mind is that method invocation results into creation of local variables of the parameters passed to the method. Thus passing myList to getName method creates a local variable/reference to the ArrayList object created on the heap. Suppose in the method, we assign a different reference to the myList variable, myList = new ArrayList(), then this is valid only in the current method scope. This is because the locally created myList reference now points to a new object created on the heap.&lt;br /&gt;&lt;br /&gt;A small program to explain the above concept:&lt;br /&gt;&lt;pre id="Classes"&gt;&lt;br /&gt;&lt;a name="1"&gt;&lt;/a&gt;&lt;span id="Import"&gt;import&lt;/span&gt; java.util.*;&lt;br /&gt;&lt;a name="2"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="3"&gt;&lt;/a&gt;&lt;span id="Public"&gt;public&lt;/span&gt; &lt;span id="Class"&gt;class&lt;/span&gt; ParameterPassing {&lt;br /&gt;&lt;a name="4"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="5"&gt;&lt;/a&gt;  &lt;span id="Public"&gt;public&lt;/span&gt; String getName( List myList, &lt;span id="Int"&gt;int&lt;/span&gt; count ) {&lt;br /&gt;&lt;a name="6"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="7"&gt;&lt;/a&gt;    myList.add(&lt;span id="StringLiteral"&gt;"XYZ"&lt;/span&gt;);&lt;br /&gt;&lt;a name="8"&gt;&lt;/a&gt;    count++;&lt;br /&gt;&lt;a name="9"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="10"&gt;&lt;/a&gt;    System.out.println(myList.get(&lt;span id="IntegerLiteral"&gt;0&lt;/span&gt;));&lt;br /&gt;&lt;a name="11"&gt;&lt;/a&gt;    System.out.println(count);&lt;br /&gt;&lt;a name="12"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="13"&gt;&lt;/a&gt;    myList = &lt;span id="New"&gt;new&lt;/span&gt; ArrayList();&lt;br /&gt;&lt;a name="14"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="15"&gt;&lt;/a&gt;    &lt;span id="Return"&gt;return&lt;/span&gt; &lt;span id="StringLiteral"&gt;""&lt;/span&gt;;&lt;br /&gt;&lt;a name="16"&gt;&lt;/a&gt;  }&lt;br /&gt;&lt;a name="17"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="18"&gt;&lt;/a&gt;  &lt;span id="Public"&gt;public&lt;/span&gt; &lt;span id="Static"&gt;static&lt;/span&gt; &lt;span id="Void"&gt;void&lt;/span&gt; main( String args[]) {&lt;br /&gt;&lt;a name="19"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="20"&gt;&lt;/a&gt;    List myList = &lt;span id="New"&gt;new&lt;/span&gt; ArrayList();&lt;br /&gt;&lt;a name="21"&gt;&lt;/a&gt;    &lt;span id="Int"&gt;int&lt;/span&gt; count = &lt;span id="IntegerLiteral"&gt;5&lt;/span&gt;;&lt;br /&gt;&lt;a name="22"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="23"&gt;&lt;/a&gt;    ParameterPassing pp = &lt;span id="New"&gt;new&lt;/span&gt; ParameterPassing();&lt;br /&gt;&lt;a name="24"&gt;&lt;/a&gt;    pp.getName( myList, count );&lt;br /&gt;&lt;a name="25"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="26"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="27"&gt;&lt;/a&gt;    System.out.println(myList.get(&lt;span id="IntegerLiteral"&gt;0&lt;/span&gt;));&lt;br /&gt;&lt;a name="28"&gt;&lt;/a&gt;    System.out.println(count);&lt;br /&gt;&lt;a name="29"&gt;&lt;/a&gt;  }&lt;br /&gt;&lt;a name="30"&gt;&lt;/a&gt;}&lt;/pre&gt;&lt;br /&gt;Following is the output:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;XYZ&lt;br /&gt;6&lt;br /&gt;XYZ&lt;br /&gt;5&lt;/span&gt;&lt;br /&gt;The count in the main method holds the old value 5 because the count++ in getName method actually increments the local variable. Similarly myList = new ArrayList() points the local reference to the new object created on the heap.&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3855656585138701891-2549185073740841861?l=breathing-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://breathing-java.blogspot.com/feeds/2549185073740841861/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3855656585138701891&amp;postID=2549185073740841861" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/2549185073740841861?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/2549185073740841861?v=2" /><link rel="alternate" type="text/html" href="http://breathing-java.blogspot.com/2008/06/parameter-passing.html" title="Parameter Passing" /><author><name>Amey Bhide</name><uri>http://www.blogger.com/profile/16983821654401130379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://photos1.blogger.com/blogger/4314/722/1600/Amey_1.jpg" /></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;C04MQ3w5cCp7ImA9WxdQFkU.&quot;"><id>tag:blogger.com,1999:blog-3855656585138701891.post-3798565117770782588</id><published>2008-06-16T12:46:00.007+05:30</published><updated>2008-06-17T11:23:02.228+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-06-17T11:23:02.228+05:30</app:edited><title>OOPs ! I defined it again ....</title><content type="html">&lt;span style="font-family:arial;"&gt;All the interviews that I have given and conducted till date always had (and will continue to have) the usual suspect : 'Define concepts/principles of Object Oriented Programming". Most of the interviewers arrive at a fair enough conclusion about the interviewee depending upon his explanation on the aforementioned question. Before I dive into crisp definitions of each of the concept, I want to point out three important entities often misunderstood or misquoted or misconceived while reading books.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="font-family:arial;"&gt;C&amp;amp;C (common and crap) answers:&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;"An Object is an instance of a class ..... Class is from which objects are created/derived". Practically i.e. looking from coding point of view it is a correct definition, but unfortunately doesn't explain much about the exact use of object and class. To put it in layman terms "X equals Y and Y equals X". When one gets to designing an application, this definition will not help.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;"An interface is Java's solution to support multiple inheritance". Agreed, but that is &lt;strong&gt;&lt;em&gt;use&lt;/em&gt;&lt;/strong&gt; of interface and not the definition.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;C&amp;amp;C answers again &lt;/strong&gt;(this time crisp and correct) &lt;strong&gt;:&lt;/strong&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;u&gt;Object:&lt;/u&gt; An object is an entity that has the following four characteristics, viz: &lt;strong&gt;&lt;em&gt;Identity, State, Behaviour and Properties&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;u&gt;Class:&lt;/u&gt; A class provides an Identity to the object and models the state, behaviour and properties of the object. A class defines a &lt;strong&gt;&lt;em&gt;skeleton&lt;/em&gt;&lt;/strong&gt; for objects and acts as a &lt;strong&gt;&lt;em&gt;blueprint&lt;/em&gt;&lt;/strong&gt; from which object can be created.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;u&gt;Interface:&lt;/u&gt; Interface is a &lt;strong&gt;&lt;em&gt;contract between a class and the outside world&lt;/em&gt;&lt;/strong&gt;. The behaviour of an object i.e. the methods form the object's interface to outside world. By implementing an interface, a class promises to provide the behaviour published by the Interface. Interfaces help in extensibility.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;&lt;u&gt;The four Object Oriented Principles:&lt;/u&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;u&gt;Inheritance:&lt;/u&gt; Mechanism to structure and organize our software. Provides an ability to a sub-calss to inherit the properties, state and behaviour of the base class. Inheritance enables us to define a more general class and derive specialized classes from it. This helps in better data analysis.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;u&gt;Encapsulation:&lt;/u&gt; Separating object's interface from its implementation. Hiding object data and allowing modification of object data by publishing method. Controlling the access to data and methods that manipulate the data using access modifiers.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;u&gt;Polymorphism:&lt;/u&gt; The ability of a reference of a base class to denote an object of its own class or any of its subclasses at runtime. This is a definition that many of you might be reading for the first time. The common definitions being "one name many forms" or "method overloading and overriding". But on deeper introspection, the above is possible when a reference of a base class can denote different objects at runtime. The only exeception being &lt;strong&gt;&lt;em&gt;method overloading&lt;/em&gt;&lt;/strong&gt; as this is compile time polymorphism i.e. which method will be executed can be determined at compile time itself.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;u&gt;Abstraction:&lt;/u&gt; Simplifying complexities by seggregating/breaking them into smaller units and modelling a structure/heirarchy chain by abstracting common behaviour into classes.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;All the OOP principals work hand-in-hand. It is very difficult to write a code that just implements the Abstraction principal and so forth.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;I hope you have a better perspective of the principles now. I will write more in the blogs-to-come. Till then ... happy digestion.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Arial;"&gt;  &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3855656585138701891-3798565117770782588?l=breathing-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://breathing-java.blogspot.com/feeds/3798565117770782588/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3855656585138701891&amp;postID=3798565117770782588" title="14 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/3798565117770782588?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/3798565117770782588?v=2" /><link rel="alternate" type="text/html" href="http://breathing-java.blogspot.com/2008/06/oops-i-defined-it-again.html" title="OOPs ! I defined it again ...." /><author><name>Amey Bhide</name><uri>http://www.blogger.com/profile/16983821654401130379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://photos1.blogger.com/blogger/4314/722/1600/Amey_1.jpg" /></author><thr:total>14</thr:total></entry><entry gd:etag="W/&quot;DkAHRXozeyp7ImA9WxdQFk8.&quot;"><id>tag:blogger.com,1999:blog-3855656585138701891.post-5672684885603043040</id><published>2008-06-13T14:46:00.012+05:30</published><updated>2008-06-16T19:28:54.483+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-06-16T19:28:54.483+05:30</app:edited><title>Hello Primitives</title><content type="html">&lt;span style="font-family:arial;"&gt;Java is not 100% object oriented because of two main constraints:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;int, float, char etc are primitives and not objects&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Multiple inheritance not supported.&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;Java has an answer/solution to the above mentioned constraints. Wrapper classes are provided which allow us to create an object even when dealing with simple numbers. Thus instead of using int, we can create an object of type Integer or a Float object instead of float primitive. Java's answer to multiple inheritance is Interfaces; a class can implement more than one interfaces.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;Even with these solutions/workarounds, the main reason behind Java not being purely object oriented is that we can still write a Java program with the use of primitives. This introduces use of an entity that is not an object, which violates the principle of object oriented program. Java allows the use of primitives for &lt;strong&gt;&lt;em&gt;performance&lt;/em&gt;&lt;/strong&gt; reasons. If it weren't for primitives, our mundane loops would have caused a catastrophe. A simple program to illustrate the Power of Primitives:&lt;/span&gt;&lt;br /&gt;&lt;pre id="Classes"&gt;&lt;br /&gt;&lt;a name="1"&gt;&lt;/a&gt;&lt;span id="Import"&gt;import&lt;/span&gt; java.util.Calendar;&lt;br /&gt;&lt;a name="2"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="3"&gt;&lt;/a&gt;&lt;span id="Public"&gt;public&lt;/span&gt; &lt;span id="Class"&gt;class&lt;/span&gt; HelloPrimitives {&lt;br /&gt;&lt;a name="4"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="5"&gt;&lt;/a&gt;  &lt;span id="Public"&gt;public&lt;/span&gt; &lt;span id="Static"&gt;static&lt;/span&gt; &lt;span id="Void"&gt;void&lt;/span&gt; main(String args[]) {&lt;br /&gt;&lt;a name="6"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="7"&gt;&lt;/a&gt;    &lt;span id="SingleLineComment"&gt;//Nested loops using primitives&lt;br /&gt;&lt;a name="8"&gt;&lt;/a&gt;&lt;/span&gt;    &lt;span id="Long"&gt;long&lt;/span&gt; lTimeInMillis = Calendar.getInstance().getTimeInMillis();&lt;br /&gt;&lt;a name="9"&gt;&lt;/a&gt;    &lt;span id="Int"&gt;int&lt;/span&gt; i = &lt;span id="IntegerLiteral"&gt;0&lt;/span&gt;;&lt;br /&gt;&lt;a name="10"&gt;&lt;/a&gt;    &lt;span id="Int"&gt;int&lt;/span&gt; j = &lt;span id="IntegerLiteral"&gt;0&lt;/span&gt;;&lt;br /&gt;&lt;a name="11"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="12"&gt;&lt;/a&gt;    &lt;span id="For"&gt;for&lt;/span&gt;( &lt;span id="Int"&gt;int&lt;/span&gt; counter = &lt;span id="IntegerLiteral"&gt;0&lt;/span&gt;; counter &amp;lt; &lt;span id="IntegerLiteral"&gt;1000&lt;/span&gt;; counter++ ) {&lt;br /&gt;&lt;a name="13"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="14"&gt;&lt;/a&gt;      &lt;span id="For"&gt;for&lt;/span&gt;( &lt;span id="Int"&gt;int&lt;/span&gt; innerCounter = &lt;span id="IntegerLiteral"&gt;0&lt;/span&gt;; innerCounter &amp;lt; &lt;span id="IntegerLiteral"&gt;3000&lt;/span&gt;; innerCounter++ ) {&lt;br /&gt;&lt;a name="15"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="16"&gt;&lt;/a&gt;        j = innerCounter;&lt;br /&gt;&lt;a name="17"&gt;&lt;/a&gt;      }&lt;br /&gt;&lt;a name="18"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="19"&gt;&lt;/a&gt;      i = counter;&lt;br /&gt;&lt;a name="20"&gt;&lt;/a&gt;    }&lt;br /&gt;&lt;a name="21"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="22"&gt;&lt;/a&gt;    lTimeInMillis = Calendar.getInstance().getTimeInMillis() - lTimeInMillis;&lt;br /&gt;&lt;a name="23"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="24"&gt;&lt;/a&gt;    &lt;span id="SingleLineComment"&gt;//Nested loops using wrapper classes&lt;br /&gt;&lt;a name="25"&gt;&lt;/a&gt;&lt;/span&gt;    Long oTimeInMillis = &lt;span id="New"&gt;new&lt;/span&gt; Long( Calendar.getInstance().getTimeInMillis( ) );&lt;br /&gt;&lt;a name="26"&gt;&lt;/a&gt;    Integer objI = &lt;span id="Null"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;a name="27"&gt;&lt;/a&gt;    Integer objJ = &lt;span id="Null"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;a name="28"&gt;&lt;/a&gt;    Integer objCounter = &lt;span id="New"&gt;new&lt;/span&gt; Integer( &lt;span id="IntegerLiteral"&gt;0&lt;/span&gt; );&lt;br /&gt;&lt;a name="29"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="30"&gt;&lt;/a&gt;    &lt;span id="For"&gt;for&lt;/span&gt;( ; objCounter.intValue() &amp;lt; &lt;span id="IntegerLiteral"&gt;1000&lt;/span&gt;; ) {&lt;br /&gt;&lt;a name="31"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="32"&gt;&lt;/a&gt;      Integer integerInnerCounter = &lt;span id="New"&gt;new&lt;/span&gt; Integer( &lt;span id="IntegerLiteral"&gt;0&lt;/span&gt; );&lt;br /&gt;&lt;a name="33"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="34"&gt;&lt;/a&gt;      &lt;span id="For"&gt;for&lt;/span&gt;( ; objInnerCounter.intValue() &amp;lt; &lt;span id="IntegerLiteral"&gt;3000&lt;/span&gt;; ) {&lt;br /&gt;&lt;a name="35"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="36"&gt;&lt;/a&gt;        objJ = &lt;span id="New"&gt;new&lt;/span&gt; Integer( objInnerCounter.intValue() );&lt;br /&gt;&lt;a name="37"&gt;&lt;/a&gt;        objInnerCounter = &lt;span id="New"&gt;new&lt;/span&gt; Integer( objInnerCounter.intValue() + &lt;span id="IntegerLiteral"&gt;1&lt;/span&gt; );&lt;br /&gt;&lt;a name="38"&gt;&lt;/a&gt;      }&lt;br /&gt;&lt;a name="39"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="40"&gt;&lt;/a&gt;      objI = &lt;span id="New"&gt;new&lt;/span&gt; Integer( objCounter.intValue() );&lt;br /&gt;&lt;a name="41"&gt;&lt;/a&gt;      objCounter = &lt;span id="New"&gt;new&lt;/span&gt; Integer( objCounter.intValue() + &lt;span id="IntegerLiteral"&gt;1&lt;/span&gt; );&lt;br /&gt;&lt;a name="42"&gt;&lt;/a&gt;    }&lt;br /&gt;&lt;a name="43"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="44"&gt;&lt;/a&gt;    oTimeInMillis = &lt;span id="New"&gt;new&lt;/span&gt; Long( Calendar.getInstance().getTimeInMillis() - oTimeInMillis.longValue() );&lt;br /&gt;&lt;a name="45"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="46"&gt;&lt;/a&gt;    System.out.println( &lt;span id="StringLiteral"&gt;"Time taken by primitives = "&lt;/span&gt; + lTimeInMillis );&lt;br /&gt;&lt;a name="47"&gt;&lt;/a&gt;    System.out.println( &lt;span id="StringLiteral"&gt;"Time taken by wrapper classes = "&lt;/span&gt; + oTimeInMillis.longValue() );&lt;br /&gt;&lt;a name="48"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="49"&gt;&lt;/a&gt;  }&lt;br /&gt;&lt;a name="50"&gt;&lt;/a&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;The following output is observed on my machine (numbers are machine specific):&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;D:\amey\blogs\java\progs\hello_primitives&gt;java HelloPrimitives&lt;br /&gt;Time taken by primitives = 15&lt;br /&gt;Time taken by wrapper classes = 1219&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It can be seen that use of primitives improves the performance significantly. Stark reasons for this are&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;ol&gt;&lt;li&gt;Memory allocation for a primitive and object is very different. For primitive datatype, the value is directly stored at the memory address of the reference. Whereas objects are created on heap, and the memory location of the reference holds the memory location of the object on the heap.&lt;/li&gt;&lt;li&gt;The values can be directly accessed in case of primitives while for objects, we need to invoke a method using the dot ',' operator. This calls for pushing the current method on the stack and popping it back at later instance which is time consuming.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;One more tip for increasing performance is controlling number of times a primitive or object gets created. In the above program, we are creating &lt;em&gt;innerCounter&lt;/em&gt; and &lt;em&gt;objInnerCounter &lt;/em&gt;within the inner loop. Try initializing them just once above the outermost for loop and see the difference in timings.&lt;/span&gt;&lt;/p&gt;&lt;span style="font-family:arial;"&gt;Also increase the inner loop to 30,000.&lt;/span&gt;&lt;br /&gt;&lt;pre id="Classes"&gt;&lt;br /&gt;&lt;a name="11"&gt;&lt;/a&gt;    &lt;span id="Int"&gt;int&lt;/span&gt; innerCounter = &lt;span id="IntegerLiteral"&gt;0&lt;/span&gt;; &lt;span id="SingleLineComment"&gt;//initialize only once&lt;br /&gt;&lt;a name="12"&gt;&lt;/a&gt;&lt;/span&gt;    &lt;span id="For"&gt;for&lt;/span&gt;( &lt;span id="Int"&gt;int&lt;/span&gt; counter = &lt;span id="IntegerLiteral"&gt;0&lt;/span&gt;; counter &amp;lt; &lt;span id="IntegerLiteral"&gt;1000&lt;/span&gt;; counter++ ) {&lt;br /&gt;&lt;a name="34"&gt;&lt;/a&gt;      &lt;span id="For"&gt;for&lt;/span&gt;( ; innerCounter &amp;lt; &lt;span id="IntegerLiteral"&gt;30000&lt;/span&gt;; ) {&lt;br /&gt;&lt;a name="14"&gt;&lt;/a&gt;    .....&lt;br /&gt;&lt;a name="27"&gt;&lt;/a&gt;    .....&lt;br /&gt;&lt;a name="49"&gt;&lt;/a&gt;  }&lt;br /&gt;&lt;br /&gt;&lt;a name="13"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="14"&gt;&lt;/a&gt;    .....&lt;br /&gt;&lt;a name="27"&gt;&lt;/a&gt;    .....&lt;br /&gt;&lt;a name="28"&gt;&lt;/a&gt;    Integer objCounter = &lt;span id="New"&gt;new&lt;/span&gt; Integer( &lt;span id="IntegerLiteral"&gt;0&lt;/span&gt; );&lt;br /&gt;&lt;a name="29"&gt;&lt;/a&gt;    Integer objInnerCounter = &lt;span id="New"&gt;new&lt;/span&gt; Integer( &lt;span id="IntegerLiteral"&gt;0&lt;/span&gt; ); &lt;span id="SingleLineComment"&gt;//initialize only once&lt;br /&gt;&lt;a name="30"&gt;&lt;/a&gt;&lt;/span&gt;    &lt;span id="For"&gt;for&lt;/span&gt;( ; objCounter.intValue() &amp;lt; &lt;span id="IntegerLiteral"&gt;1000&lt;/span&gt;; ) {&lt;br /&gt;&lt;a name="31"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="32"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="33"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="34"&gt;&lt;/a&gt;      &lt;span id="For"&gt;for&lt;/span&gt;( ; objInnerCounter.intValue() &amp;lt; &lt;span id="IntegerLiteral"&gt;30000&lt;/span&gt;; ) {&lt;br /&gt;&lt;a name="14"&gt;&lt;/a&gt;    .....&lt;br /&gt;&lt;a name="27"&gt;&lt;/a&gt;    .....&lt;br /&gt;&lt;a name="49"&gt;&lt;/a&gt;  }&lt;br /&gt;&lt;a name="50"&gt;&lt;/a&gt;}&lt;/pre&gt;&lt;span style="font-family:arial;"&gt;The output on my machine is:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;D:\amey\blogs\java\progs\hello_primitives&gt;java HelloPrimitives&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Time taken by primitives = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Time taken by wrapper classes = 16&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Wow !&lt;br /&gt;&lt;br /&gt;Cheers,&lt;br /&gt;Amey&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3855656585138701891-5672684885603043040?l=breathing-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://breathing-java.blogspot.com/feeds/5672684885603043040/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3855656585138701891&amp;postID=5672684885603043040" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/5672684885603043040?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/5672684885603043040?v=2" /><link rel="alternate" type="text/html" href="http://breathing-java.blogspot.com/2008/06/hello-primitives.html" title="Hello Primitives" /><author><name>Amey Bhide</name><uri>http://www.blogger.com/profile/16983821654401130379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://photos1.blogger.com/blogger/4314/722/1600/Amey_1.jpg" /></author><thr:total>3</thr:total></entry><entry gd:etag="W/&quot;A0YBRX04cSp7ImA9WxFVEk4.&quot;"><id>tag:blogger.com,1999:blog-3855656585138701891.post-2290775278074040869</id><published>2008-06-11T17:03:00.021+05:30</published><updated>2010-06-11T12:22:34.339+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-06-11T12:22:34.339+05:30</app:edited><title>Hello World</title><content type="html">&lt;span style="font-family: arial;"&gt;The first ever program written by a newbie is HelloWorld, be it C, C++, Java or any other programming language. Gives a sense of satisfaction to see the output on the screen. But few get there in the first shot. As for me, it took me god damm five freaking hours to understand what was going wrong.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: arial;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: arial;"&gt;Most of the times, the first ever HelloWorld program is copied by us till the last 'white character'. Seldom any chance of making any mistakes there. The first problem that hits us is:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table width="90%" cellpadding="1" &gt;&lt;tr&gt;&lt;td bgcolor="ORANGE"&gt;&lt;table width="100%" &gt;&lt;tr&gt;&lt;td bgcolor="WHITE"&gt;&lt;br /&gt;
C:\&amp;gt;javac HelloWorld.java&lt;br /&gt;
'javac' is not recognized as an internal or external command,operable program or batch file.C:\&amp;gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;br /&gt;
&lt;span style="font-family: arial;"&gt;javac.exe is a file that gets installed on our machine as a part of jdk installation. This executable is required for generating the byte code i.e. essentially the .class file from our .java files. javac.exe is present in the &lt;java_home&gt;/bin folder. This bin folder should be available in the 'Path' variable for the command prompt to locate javac.exe.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial;"&gt;Copy the path till &lt;java_home&gt;/bin and set it into the 'Path' variable withing the command prompt and then try the 'javac' command. Don't forget to append %PATH% at the end otherwise you will end up messing up the existing path variables in the current window. Sample from my environment:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table width="90%" cellpadding="1" &gt;&lt;tr&gt;&lt;td bgcolor="ORANGE"&gt;&lt;table width="100%" &gt;&lt;tr&gt;&lt;td bgcolor="WHITE"&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: courier new; font-size: 85%;"&gt;C:\&amp;gt;set PATH=D:\apps\JDK_1.5.0.11\bin;%PATH%&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;C:\&amp;gt;javac&lt;br /&gt;
Usage: javac &lt;options&gt;&lt;source&gt;where possible options include: &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-g Generate all debugging info &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-g:none Generate no debugging info &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-g:{lines,vars,source} Generate only some debugging info &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-nowarn Generate no warnings &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-verbose Output messages about what the compiler is doing &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-deprecation Output source locations where deprecated APIs are used &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-classpath &lt;path&gt;Specify where to find user class files &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-cp &lt;path&gt;Specify where to find user class files &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-sourcepath &lt;path&gt;Specify where to find input source files &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-bootclasspath &lt;path&gt;Override location of bootstrap class files &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-extdirs &lt;dirs&gt;Override location of installed extensions &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-endorseddirs &lt;dirs&gt;Override location of endorsed standards path &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-d &lt;directory&gt;Specify where to place generated class files &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-encoding &lt;encoding&gt;Specify character encoding used by source files &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-source &lt;release&gt;Provide source compatibility with specified release &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-target &lt;release&gt;Generate class files for specific VM version &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-version Version information &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-help Print a synopsis of standard options &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-X Print a synopsis of nonstandard options &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;-J&lt;flag&gt; Pass &lt;flag&gt;directly to the runtime system&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: courier new; font-size: 85%;"&gt;C:\&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;br /&gt;
&lt;span style="font-family: arial;"&gt;Similar problems are observed with the 'jar' command. jar.exe is an executable which helps us in creating java archive (jar), web archive (war) and enterprise archive (ear) files. In case jar -uvf xyz.jar com/* command gives you an error, the solution is same as above.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: arial;"&gt;Many a times I have resources asking me that even if &lt;jre_home&gt;/bin is in the classpath, we get 'javac not recognised command ....' error. JRE is abbreviation for &lt;strong&gt;&lt;u&gt;J&lt;/u&gt;&lt;/strong&gt;ava &lt;strong&gt;&lt;u&gt;R&lt;/u&gt;&lt;/strong&gt;untime &lt;strong&gt;&lt;u&gt;E&lt;/u&gt;&lt;/strong&gt;nvironment. The bin folder under jre holds set of executables and binaries required by JVM (&lt;strong&gt;&lt;u&gt;J&lt;/u&gt;&lt;/strong&gt;ava &lt;strong&gt;&lt;u&gt;V&lt;/u&gt;&lt;/strong&gt;irtual &lt;strong&gt;&lt;u&gt;M&lt;/u&gt;&lt;/strong&gt;achine). Thus development time executables, like javac, jar, javadoc, rmic to name a few, will not be present in this bin folder. Runtime executables like java, rmiregistry etc will be available in jre/bin.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial;"&gt;Hope this blog serves as a good appetizer.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial;"&gt;Cheers, &lt;/span&gt;&lt;span style="font-family: Arial;"&gt;Amey&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3855656585138701891-2290775278074040869?l=breathing-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://breathing-java.blogspot.com/feeds/2290775278074040869/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3855656585138701891&amp;postID=2290775278074040869" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/2290775278074040869?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/2290775278074040869?v=2" /><link rel="alternate" type="text/html" href="http://breathing-java.blogspot.com/2008/06/hello-world.html" title="Hello World" /><author><name>Amey Bhide</name><uri>http://www.blogger.com/profile/16983821654401130379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://photos1.blogger.com/blogger/4314/722/1600/Amey_1.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C0IERno5eCp7ImA9WxdQEEQ.&quot;"><id>tag:blogger.com,1999:blog-3855656585138701891.post-5299232534682360885</id><published>2008-06-10T10:15:00.000+05:30</published><updated>2008-06-10T15:21:47.420+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-06-10T15:21:47.420+05:30</app:edited><title>Java Programmers aren't BORN !!!</title><content type="html">&lt;span style="font-family:arial;"&gt;In most of the interviews, which I have conducted till date, the candidates frequently ask me: “How can I become a good Java programmer?” or “How can I improve my Java skills” or “How did you learn Java”. I thought of sharing some of my methodologies, which might prove useful to some of you.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;There is really no short cut to mastering Java, so in this column I will try to talk about the pedagogy. Let us picture for a moment, that a fan is asking Sachin Tendulkar a similar question about cricket:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Fan: "Good morning Sachin, my son would like to start a career in cricket. What advice can you give him?"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Sachin: "Is he playing in Ranjhi?"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Fan: "Oh no, he does not play cricket, but he follows it religiously on television. He has all the statistics on his finger tips"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Sachin: "Oooooh. What other sports does he play?"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Fan: "He plays soccer …… on his computer, you heard about Fifa98/99 …2004. Other than that, we once played table tennis together."&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;The point I am trying to make here is, you cannot learn Java just by reading fat books by international authors. You need to dirty your hands by writing programs, go through the pain of writing and compiling programs without IDEs and code assist.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;&lt;u&gt;Where and how does it all start?&lt;/u&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Becoming a programmer starts early in life. You would have been at a great advantage if you were good in mathematics and physics. Here I am not looking for the tools that you learn doing maths, but rather the interest in "thinking" subjects. There are two types of java programmers; ones who know the legal constructs by heart and others who can think in Java.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Then the next step is to want to program for relaxation. Yes, you heard me right. It is not always necessary that the code you write will be used in the project that one is working on. You can code utility methods for some one working on a different project or just practice what you learnt, but all of this apart from the regular deliverables, chat, orkut and mailers. When I embarked on my programming career, all I did during free time was to download code samples from the Internet and study the behavior. It really did not make any sense at first, but as I read through tutorials and code samples, things started correlating.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;I believe that being a programmer is not a job; it is a life. In order to learn it, you need to eat, breathe and sleep Java. There should be very few waking moments where you are not thinking about Java.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Let's say, for example, that your official work hours are 9:00am to 6:00pm. It is what happens after those hours that will determine your future as a programmer, i.e. what are you doing between 6:00pm and 9:00am. Before you set off for work, you could be programming in Java. And what about the time from 6:00pm (when you get home) until 23:59:59? If we take into account a few responsibilities, you have an additional 1.5 hours in the morning, and 3 hours in the evening.I am not making this up. If you want to be a good Java programmer, you need to have the dedication to further your own knowledge "after hours". Instead of orkut, surf for Java concepts, Object orientation, Design Patterns, etc.The key is the drive behind what you do. If your motivation to be a Java programmer is just to do a job, and to thereby earn a salary, you will never be good. Becoming an excellent Java programmer is neither difficult nor too easy. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Follow these steps:&lt;/span&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Read Java Complete Reference thrice. The first time for legal constructs and sample codes, the second time for understanding the concepts and the third for understanding how to use the concepts programmatically.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Program for pleasure, not for money. Spend at least few hours of your own time per day on learning more about programming in Java.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Never stop learning. The half-life of our IT knowledge is 18 months. We cannot afford to stand still; otherwise we will be obsolete in a very short period of time.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Don't read books - STUDY them. When I read a new Java book, I open it next to my workstation and then I type in the code as I progress. This is a bit slower, but you learn faster.&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;There are very few people who have the potential to become good programmers. It is a tiny percentage of the programmers on the apex of the pyramid that can do it. Our goal is to reach the apex. These are some thoughts on how to become an excellent Java programmer. They are tough jobs to do, and by no means complete, but are meant to get you thinking.&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3855656585138701891-5299232534682360885?l=breathing-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://breathing-java.blogspot.com/feeds/5299232534682360885/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3855656585138701891&amp;postID=5299232534682360885" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/5299232534682360885?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/5299232534682360885?v=2" /><link rel="alternate" type="text/html" href="http://breathing-java.blogspot.com/2008/06/java-programmers-arent-born.html" title="Java Programmers aren't BORN !!!" /><author><name>Amey Bhide</name><uri>http://www.blogger.com/profile/16983821654401130379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://photos1.blogger.com/blogger/4314/722/1600/Amey_1.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CE4CRXgzfSp7ImA9WxdQF00.&quot;"><id>tag:blogger.com,1999:blog-3855656585138701891.post-8829468481195296826</id><published>2008-06-08T14:51:00.004+05:30</published><updated>2008-06-17T17:12:44.685+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-06-17T17:12:44.685+05:30</app:edited><title>My First Address To Freshers</title><content type="html">&lt;p&gt;&lt;span style="font-family:arial;"&gt;Hello Everyone,&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;I would have personally liked to address you before the training kicks off, but as I had to fly to Japan, I have requested Mr. K to do the honors.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;I underwent a corporate training for Java and J2EE back in 2004 when I was associated with a different employer. That’s when I met Mr. J, who was the trainer. For four days we talked at length from OOP concepts to Reflections and that was indeed an enlightening experience.I was on the interview panel and I found some common misunderstanding of concepts amongst the candidates that I interviewed. That is the reason I why I to take this opportunity to share some of my experiences specifically with Mr. J and generally with “How to make the most from the training session”. These are some of my cheat sheets and it is not an obligation for you all to follow these steps in case our views differ.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;Concepts: The most important and fundamental key to be good developer is to have your concepts clear. This training course is not similar to the commercial ones available in the markets where they teach you the syntactically legal constructs of writing Java/C++ programs. We have tailored the course contents to put more emphasis on topics that we feel should be discussed at length. Ask as many questions that arise in your mind and follow a simple principal “No question is stupid, no question is pathetic”. Once the concepts are clear, writing code will be very simple.I would like to emphasize that you all put enough efforts to get the OOP concepts crystal clear by the time you all finish with the training. This was one thing in common that I found most of you lacked.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;Implementation: The exercises given during the training need to be essentially carried out individually rather than in groups. Try to relate what you are typing. Don’t feel shy to ask Mr. J when you get confused over what really has to be done. I bet Mr. J will never spoon feed any of you; so try to give your best shot. Remember, once you get on with the projects, you will be all alone. I feel this is the best time when you all can start cranking up your debugging skills, imagination as to how the code might be working internally and so on. Try to squeeze as much information from Mr. J as possible. This includes best implementation practices, code reuse, how to decide the best fit java classes for a particular functionality when we need to make a choice from couple of types available at hand etc.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;Post training: It will be good if you all can read some more literature after every session. Google.com is one unlimited source of information and “Complete Reference by Herbert Schields” is another ready reference. Read this book in parallel to the training and get your doubts cleared if you find a discrepancy between what is written and what was taught. It often happens that the wording in the book misleads us to believe in something that is actually not true. Be careful.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;Mr. J: He is a well read and a no nonsense guy. I bet you won’t feel sleepy or bored during any of his lectures as he makes the discourses humorous enough. Try to understand the similarities and differences when he compares two technologies or the implementations in different technologies. Make ample notes from his presentations, specifically the definitions or different terms, java tenets, java constraints and so forth. They have proved very helpful to me in the long run. Take his assignments seriously as the feedback he provides on the implementation is genuine enough, it will train your mind while coding and also improve writing good performance code in the first shot. Trust me, you will be able to make a lot of use of these assignments when you come aboard on live projects. If time permits try to go the extra mile to implement additional features that might be discussed in the class.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:arial;"&gt;Last but not the least. We are all here to help you out in case you are stuck with some implementation and Pankaj is not around. But don’t just get someone to fix the code and leave, try and understand the logic behind fix. The bottom line to successful coding is having the right logic in place as after that its only the semantics that have to be followed.&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3855656585138701891-8829468481195296826?l=breathing-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://breathing-java.blogspot.com/feeds/8829468481195296826/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3855656585138701891&amp;postID=8829468481195296826" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/8829468481195296826?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3855656585138701891/posts/default/8829468481195296826?v=2" /><link rel="alternate" type="text/html" href="http://breathing-java.blogspot.com/2008/06/my-first-ever-address-to-freshers.html" title="My First Address To Freshers" /><author><name>Amey Bhide</name><uri>http://www.blogger.com/profile/16983821654401130379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://photos1.blogger.com/blogger/4314/722/1600/Amey_1.jpg" /></author><thr:total>0</thr:total></entry></feed>

