<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-13911304</id><updated>2011-07-07T13:03:10.708-07:00</updated><title type='text'>Common knowledge in Java</title><subtitle type='html'>A few notes, observations that I would like to document about Java. This may be common,trivial knowledge, but I just want it to be in one place.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-13911304.post-112135548707676809</id><published>2005-07-14T08:25:00.000-07:00</published><updated>2005-07-19T14:50:46.786-07:00</updated><title type='text'>apache.commons.net ParserInitializationException</title><content type='html'>&lt;div style="text-align: left;"&gt;&lt;span style="font-size:85%;"&gt;We use the jakarta/apache (don't know what they call it these days) commons net jar as our ftp client and this seems to be failing with a TANDEM ftp box.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  Looks like &lt;a href="http://www.opensubscriber.com/message/commons-dev@jakarta.apache.org/1695230.html"&gt;someone else&lt;/a&gt; was running into the same error at about the same time.&lt;br /&gt;This is the error I was running into:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(102, 51, 51); font-weight: bold;font-family:courier new;" &gt;org.apache.commons.net.ftp.parser.ParserInitializationException:&lt;br /&gt;Error initializing parser at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.&lt;br /&gt;createFileEntryParser(DefaultFTPFileEntryParserFactory.java:115) at org.apache.commons.net.ftp.FTPClient.&lt;br /&gt;initiateListParsing(FTPClient.java:2306) at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2055) at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2106) at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2146)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;After taking a look at the commons code, here's what I figured out, the TANDEM box was returning&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;an empty string on a FTP SYST command. Our good people at commons don't handle a null, assuming&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;the FTPClient.getSystemName() always returns something. So here's my hack to get around it.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt; &lt;span style="color: rgb(102, 102, 0); font-weight: bold;font-family:courier new;" &gt;  if(null == ftpClient.getSystemName()) {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt; &lt;span style="color: rgb(102, 102, 0); font-weight: bold;font-family:courier new;" &gt;     //use parserKey,pathName method signature&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt; &lt;span style="color: rgb(102, 102, 0); font-weight: bold;font-family:courier new;" &gt;     ftpFileArray = ftpClient.listFiles("UNIX",(String)null);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt; &lt;span style="color: rgb(102, 102, 0); font-weight: bold;font-family:courier new;" &gt;  } else {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt; &lt;span style="color: rgb(102, 102, 0); font-weight: bold;font-family:courier new;" &gt;     ftpFileArray = ftpClient.listFiles();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt; &lt;span style="color: rgb(102, 102, 0); font-weight: bold;font-family:courier new;" &gt;  }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13911304-112135548707676809?l=javasmitten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/112135548707676809/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13911304&amp;postID=112135548707676809' title='42 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/112135548707676809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/112135548707676809'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/2005/07/apachecommonsnet-parserinitializatione.html' title='apache.commons.net ParserInitializationException'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><thr:total>42</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13911304.post-112014296740810391</id><published>2005-06-30T07:35:00.000-07:00</published><updated>2005-06-30T07:49:27.413-07:00</updated><title type='text'>MySQL: access denied for user: (Using password: YES)</title><content type='html'>More experimenting with struts. So I got ambitious, downloaded MySQL and tried to wire a database into my simple struts app. Setting up MySQL was a breeze, although it was my first time, except that some time was wasted googling for user account creation etc.&lt;br /&gt;So, I set up a datasource in Tomcat, which could be looked up by JNDI. I added this in server.xml.&lt;br /&gt;But was getting errors with Context.lookup, indicating there was no &lt;span style="color: rgb(0, 0, 153);"&gt;"java:comp/env/jdbc"&lt;/span&gt; in the Context. Realized I forgot to add the resource-ref in my web descriptor.&lt;br /&gt;This done, I was getting a different error.&lt;br /&gt;&lt;span style="color: rgb(102, 51, 51); font-weight: bold;"&gt;Access denied for user 'blah': (Using password: YES).&lt;/span&gt;&lt;br /&gt;What the ..., I didn't set the password as YES, what the heck was going on?&lt;br /&gt;So googled again &lt;span style="color: rgb(153, 153, 0);"&gt;(one of these days, when someone asks me what tools, IDE I use for development, I will be sure to add 'Google' in there, in fact this should come integrated with the IDE, any Exception or Error message should be linked to Google search)&lt;/span&gt;, anyway I digress.&lt;br /&gt;So this seems to be a common problem. I tweak the user account a bit in MySQL,  apparently the host shouldn't be set as '%', you are better off setting it to 'localhost'. I also deleted the default user account '', which is an empty string. So either of these fixed it for me and I am on my way.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13911304-112014296740810391?l=javasmitten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/112014296740810391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13911304&amp;postID=112014296740810391' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/112014296740810391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/112014296740810391'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/2005/06/mysql-access-denied-for-user-using.html' title='MySQL: access denied for user: (Using password: YES)'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13911304.post-112007193072117019</id><published>2005-06-29T12:02:00.000-07:00</published><updated>2005-06-29T12:05:30.726-07:00</updated><title type='text'>Gripe about the parameter attribute in Struts action config</title><content type='html'>My gripe about this generic attribute called 'parameter' in the struts action config.&lt;br /&gt;So I have something like:&lt;br /&gt;      &lt;span style="color: rgb(204, 102, 0);font-size:85%;" &gt;&lt;span style="font-family: courier new;"&gt; &amp;lt;action         path="/logonProcess"&lt;/span&gt;&lt;br /&gt; &lt;span style="font-family: courier new;"&gt;         type="naive.actions.LogonAction"&lt;/span&gt;&lt;br /&gt; &lt;span style="font-family: courier new;"&gt;         name="logonForm"&lt;/span&gt;&lt;br /&gt; &lt;span style="font-family: courier new;"&gt;         parameter="/pages/Logon.jsp"&lt;/span&gt;&lt;br /&gt; &lt;span style="font-family: courier new;"&gt;         validate="true"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Now someone pray tell me what this 'parameter' is supposed to do.&lt;br /&gt;I looked up on the Apache site and it says:&lt;br /&gt; "action general purpose configuration parameter".&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Alright, but what is that supposed to mean. Well it means different things to different action type classes, if it is a ForwardAction it can be the url you want the action to be forwarded to. For DispatchAction it is the key to the different method values. Someone ought to document this, instead of making you run in circles, dammit. But that is what they say about struts, very little documentation. What do I know, anyway.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13911304-112007193072117019?l=javasmitten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/112007193072117019/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13911304&amp;postID=112007193072117019' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/112007193072117019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/112007193072117019'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/2005/06/gripe-about-parameter-attribute-in.html' title='Gripe about the parameter attribute in Struts action config'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13911304.post-112007165454224105</id><published>2005-06-29T11:50:00.000-07:00</published><updated>2005-06-29T12:00:54.556-07:00</updated><title type='text'>Struts action, parameter attribute</title><content type='html'>My gripe about this generic attribute called 'parameter' in the struts action config.&lt;br /&gt;So I have something like:&lt;br /&gt;       &lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new; color: rgb(204, 102, 0);"&gt; &lt;action&lt;/span&gt;&lt;br /&gt; &lt;span style="font-family: courier new; color: rgb(204, 102, 0);"&gt;            path="/logonProcess"&lt;/span&gt;&lt;br /&gt; &lt;span style="font-family: courier new; color: rgb(204, 102, 0);"&gt;            type="naive.actions.LogonAction"&lt;/span&gt;&lt;br /&gt; &lt;span style="font-family: courier new; color: rgb(204, 102, 0);"&gt;            name="logonForm"&lt;/span&gt;&lt;br /&gt; &lt;span style="font-family: courier new; color: rgb(204, 102, 0);"&gt;            &lt;span style="font-weight: bold;"&gt;parameter="/pages/Logon.jsp"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="font-family: courier new; color: rgb(204, 102, 0);"&gt;            validate="true"&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: georgia;"&gt;Now someone pray tell me what this 'paramter' is supposed to do.&lt;br /&gt;I looked up on the Apache site and it says:&lt;/span&gt;&lt;br /&gt; &lt;span style="font-family: georgia;"&gt;"action general purpose configuration parameter".&lt;/span&gt;&lt;br /&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;div style="text-align: justify;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new; color: rgb(204, 102, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: georgia;"&gt;Alright, but what is that supposed to mean. Well it means different things to different action type classes, if it is a ForwardAction it can be the url you want the action to be forwarded to. For DispatchAction it is the key to the different method values. Someone ought to document this, instead of making you run in circles, dammit. But that is what they say about struts, very little documentation. What do I know, anyway.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new; color: rgb(204, 102, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13911304-112007165454224105?l=javasmitten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/112007165454224105/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13911304&amp;postID=112007165454224105' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/112007165454224105'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/112007165454224105'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/2005/06/struts-action-parameter-attribute.html' title='Struts action, parameter attribute'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13911304.post-111991591679154460</id><published>2005-06-27T16:20:00.000-07:00</published><updated>2005-06-27T16:49:27.690-07:00</updated><title type='text'>Playing with Struts Day 1</title><content type='html'>&lt;span style="font-size:85%;"&gt;Ok, so finally after looking at much examples, I thought I had a basic idea and this was too trivial to actually go about trying. But today out of sheer boredem, I exported the struts-blank.war into Tomcat and got hacking at it. So here goes my tryst with struts:&lt;br /&gt;&lt;/span&gt; &lt;ul&gt;   &lt;li&gt;&lt;span style="font-size:85%;"&gt;2:15 PM Ok then, I edit struts-config.xml: create a simple logonForm extending DynActionForm, add action logon, map the action to logonForm and a LogonAction class, that I will code in a bit.&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-size:85%;"&gt;2:30 PM I create the jsps using the tags.&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-size:85%;"&gt;2:40 I get interrupted, they want me to do some work actually.&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-size:85%;"&gt;3:30 PM Ok where was I? Right the jsps; I write a simple action class: LogonAction, in which I check the username and password against hard-coded values and if they match, forward the page to success, if not forward to failure.&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-size:85%;"&gt;3:35 PM I am all compiled and ready to go, I fire up Tomcat and go to the logon page.&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-size:85%;"&gt;3:40PM  Hurrah! I can actually see the logon page, I hit submit, the page goes to logon.do, but empty page.&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-size:85%;"&gt;3:45 PM I think there might be something wrong in the Action class, so I comment the very cryptic username, password checking logic and just forward the page to success. I fire up Tomcat again.&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-size:85%;"&gt;Fast Forward: a few iterations, debugs, logs and System.out.println later:&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-size:85%;"&gt;4:30 PM Still no luck, also anything I log or write to sysout does not show up in the logs, so probably the action calss is not even getting invoked.&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-size:85%;"&gt;4:45 PM I tear out my hair, google for "struts action empty page", there is something about previous Action API requiring you to implement perform and current ones needing you to implement execute.&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-size:85%;"&gt;5:00 PM So, sure enough I am impelmenting perform, I just change this to execute and try again, Hallelujah!, I am strutting away to glory.&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt; &lt;span style="font-size:85%;"&gt;Moral of the story when in "Action",  "execute", do not "perform".&lt;br /&gt;So much for struts.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13911304-111991591679154460?l=javasmitten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/111991591679154460/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13911304&amp;postID=111991591679154460' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111991591679154460'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111991591679154460'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/2005/06/playing-with-struts-day-1.html' title='Playing with Struts Day 1'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13911304.post-111962617010751231</id><published>2005-06-24T08:08:00.000-07:00</published><updated>2005-07-19T21:07:22.536-07:00</updated><title type='text'>Inversion of control/Dependency Injection</title><content type='html'>A very interesting way of looking at Inversion of Control by Craig Walls in his Spring in Action Book:&lt;br /&gt;"You can think of IoC as JNDI in reverse— instead of an object looking up dependencies from a container, the container gives the dependencies to the object at instantiation without waiting&lt;br /&gt;to be asked."&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.martinfowler.com/articles/injection.html"&gt;Article&lt;/a&gt; by Martin Fowler.&lt;br /&gt;&lt;br /&gt;This is from an &lt;a href="http://javaboutique.internet.com/tutorials/spring_frame/"&gt;article&lt;/a&gt; on Spring Framework by Benoy Jose, for quick reference.&lt;br /&gt;&lt;-- Start Snippet --&gt;&lt;br /&gt;There are three types of Dependency Injections.&lt;br /&gt;&lt;ul&gt;   &lt;li&gt;Type 1 IOC also called Interface Injection In Type 1 IOC the injection is done though an interface. The interface will define the injection method and the implementation class has to implement this interface and provide concrete implementation for the injection method. Pico Container uses this.&lt;/li&gt;   &lt;li&gt;Type 2 IOC also called Setter Injection In Type 2 IOC the injection is done via a setter method. Type 2 IOC uses setter methods to get the dependent classes it needs. Spring uses this.&lt;/li&gt;   &lt;li&gt;Type 3 IOC also called Constructor Injection. In Type 3 IOC implementing class defines a constructor to get all its dependents. The dependent classes are defined in the constructor arguments. Avalon uses this.&lt;/li&gt; &lt;/ul&gt; &lt;-- End Snippet --&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13911304-111962617010751231?l=javasmitten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/111962617010751231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13911304&amp;postID=111962617010751231' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111962617010751231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111962617010751231'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/2005/06/inversion-of-controldependency.html' title='Inversion of control/Dependency Injection'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13911304.post-111958545384800679</id><published>2005-06-23T20:49:00.000-07:00</published><updated>2005-06-23T20:57:33.853-07:00</updated><title type='text'>Byte Streams Character Streams</title><content type='html'>I can't believe I how people have programmed in Java, myself included, without really understanding how Byte Streams are different from Character Streams. There is an excellent article &lt;a href="http://java.sun.com/developer/technicalArticles/Streams/ProgIOStreams/"&gt;here&lt;/a&gt;&lt;br /&gt;Some pointers:&lt;br /&gt;&lt;ul&gt;   &lt;li&gt;&lt;span style="font-size:100%;"&gt;If you see &lt;code&gt;Reader&lt;/code&gt; or &lt;code&gt;Writer&lt;/code&gt; think character stream and if you see &lt;code&gt;InputStream&lt;/code&gt; and &lt;code&gt;OutputStream &lt;span style="font-family: georgia;"&gt;think bytes.&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: georgia;"&gt;Thumb rule: use byte stream for binary data and character stream for everything else.&lt;br /&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13911304-111958545384800679?l=javasmitten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/111958545384800679/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13911304&amp;postID=111958545384800679' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111958545384800679'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111958545384800679'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/2005/06/byte-streams-character-streams.html' title='Byte Streams Character Streams'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13911304.post-111958388124860084</id><published>2005-06-23T20:20:00.000-07:00</published><updated>2005-06-23T20:36:19.750-07:00</updated><title type='text'>EJB, again, best practices, patterns</title><content type='html'>&lt;span style="font-weight: bold;"&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;Session Facade&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;Consider two Entity Beans and a client for ex: Employee and Paycheck. So you find the Employee, create a new Paycheck, populate some of the employee details or based on some values in Employee, you set some values on Paycheck. So you have all this business logic noise all over the client and the overhead of managing the entity beans. Enter Session Facade: You have a Session bean, that has a single method called managePaycheck, all the client has to do is call this method and all the noise moves to the Session bean.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Value Object/Data Transfer Object&lt;br /&gt;&lt;/span&gt;Value objects are used to transfer bulk data between tiers. So if you have a remote object (entity bean) and you are calling a multitude of get methods on that object. It makes sense to create a single ValueObject containing all the data needed. So now you are just calling getValueObject on that Entity bean (provided ofcourse the entity bean populates all the fields in the ValueObject first).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Use of dirty flags in the EntityBean&lt;br /&gt;&lt;/span&gt;Use dirty flags in ejbStore, basically init this as false in ejbLoad and set it to true in the setter. In ejbStore check this flag and only go ahead if it is true.&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;More to come...&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13911304-111958388124860084?l=javasmitten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/111958388124860084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13911304&amp;postID=111958388124860084' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111958388124860084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111958388124860084'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/2005/06/ejb-again-best-practices-patterns.html' title='EJB, again, best practices, patterns'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13911304.post-111958145637544757</id><published>2005-06-23T19:36:00.000-07:00</published><updated>2005-06-23T19:50:56.380-07:00</updated><title type='text'>EJB in two minutes: a refresher</title><content type='html'>&lt;ul&gt;   &lt;li&gt;More detail &lt;a href="http://members.tripod.com/gsraj/ejb/chapter/"&gt;here&lt;/a&gt;&lt;br /&gt;  &lt;/li&gt;   &lt;li&gt;You have your EJB server, container, EJBs and clients.&lt;/li&gt;   &lt;li&gt;Entity Beans (think persistence), Session Beans (stateful/stateless), Mesage Driven Beans (needs no interface)&lt;/li&gt; &lt;/ul&gt; EJBs have: &lt;ul&gt;   &lt;li&gt;Home Interface: provides  methods for locating, creating, and removing instances of EJB classes, home object is implementation&lt;/li&gt;   &lt;li&gt;Remote Interface: is the client facing interface, it has all the business methods.&lt;/li&gt;   &lt;li&gt;Enterprise Java Bean: Is in the container result of deploying home and remote interface.&lt;/li&gt;   &lt;li&gt;Create home interface by extending EJBHome&lt;/li&gt;   &lt;li&gt;Create Remote interface by extending EJBObject&lt;/li&gt;   &lt;li&gt;Define primary key object.&lt;/li&gt;   &lt;li&gt;Create your Entity Bean implementing EntityBean&lt;/li&gt; &lt;/ul&gt; Typical lifecycle: &lt;ul&gt;   &lt;li&gt;Locate home object, create or find remote object from home object, apply business methods on remote object&lt;br /&gt;  &lt;/li&gt; &lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13911304-111958145637544757?l=javasmitten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/111958145637544757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13911304&amp;postID=111958145637544757' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111958145637544757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111958145637544757'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/2005/06/ejb-in-two-minutes-refresher.html' title='EJB in two minutes: a refresher'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13911304.post-111957663882058872</id><published>2005-06-23T18:19:00.000-07:00</published><updated>2005-06-23T18:30:38.823-07:00</updated><title type='text'>What do you look for in Performance</title><content type='html'>&lt;ul&gt;   &lt;li&gt;When selecting rows from database, is filtering being done by SQL or by java.&lt;/li&gt;   &lt;li&gt;Referencing and de-referencing objects,  especially in recursion.&lt;/li&gt;   &lt;li&gt;File processing, are you buffering your reads or reading the entire file into a glob of String.&lt;/li&gt;   &lt;li&gt;Cache read-only data.&lt;/li&gt;   &lt;li&gt;See where the code is spending more amount of time&lt;/li&gt;   &lt;li&gt;More to come...&lt;br /&gt;  &lt;/li&gt; &lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13911304-111957663882058872?l=javasmitten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/111957663882058872/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13911304&amp;postID=111957663882058872' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111957663882058872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111957663882058872'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/2005/06/what-do-you-look-for-in-performance.html' title='What do you look for in Performance'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13911304.post-111957572490362526</id><published>2005-06-23T18:08:00.000-07:00</published><updated>2005-06-23T18:15:24.906-07:00</updated><title type='text'>What do you look for in Code reviews?</title><content type='html'>We do a lot of this unconsciously during code reviews, but when asked we turn a blank face.&lt;br /&gt;&lt;ul&gt;   &lt;li&gt;First the usual suspects, is the code doing what is functionally required, business logic, especially if the team member is new&lt;/li&gt;   &lt;li&gt;See that there are no hard-codes, standards are being followed.&lt;/li&gt;   &lt;li&gt;Is there chance to make something configurable, like lookups. See that these are being read from properties files or the database, that way any new additions don't need a code release.&lt;/li&gt;   &lt;li&gt;Are connections, jndi lookups being cached.&lt;/li&gt;   &lt;li&gt;Code re-use, both classes and methods.&lt;/li&gt;   &lt;li&gt;Kludge.&lt;/li&gt;   &lt;li&gt;Performance considerations, StringBuffer vs String and so on.&lt;br /&gt;  &lt;/li&gt; &lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13911304-111957572490362526?l=javasmitten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/111957572490362526/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13911304&amp;postID=111957572490362526' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111957572490362526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111957572490362526'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/2005/06/what-do-you-look-for-in-code-reviews.html' title='What do you look for in Code reviews?'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13911304.post-111957522922853803</id><published>2005-06-23T18:02:00.000-07:00</published><updated>2005-06-23T18:07:09.230-07:00</updated><title type='text'>Pass by value vs. Pass by reference</title><content type='html'>Always pass by value, if you ever say pass by reference, you will be rejected for sure. (in the interview that is)&lt;br /&gt;You don't believe me, this&lt;a href="http://javadude.com/articles/passbyvalue.htm"&gt; guy&lt;/a&gt; explains it far more better than I ever can.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13911304-111957522922853803?l=javasmitten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/111957522922853803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13911304&amp;postID=111957522922853803' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111957522922853803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111957522922853803'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/2005/06/pass-by-value-vs-pass-by-reference.html' title='Pass by value vs. Pass by reference'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13911304.post-111957480574816261</id><published>2005-06-23T17:56:00.000-07:00</published><updated>2005-06-23T18:00:05.750-07:00</updated><title type='text'>Checked vs. Unchecked Exceptions</title><content type='html'>&lt;ul&gt;   &lt;li&gt;&lt;span style="font-size:85%;"&gt;Checked exceptions are checked at compile time (not exactly checked, but the compiler knows will occur since they are declared as being thrown during compile time), so the compiler will crib if you don't handle them.&lt;br /&gt;    &lt;/span&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-size:85%;"&gt;Unchecked exceptions only occur at runtime, mostly extend RuntimeException, these can't be checked, usually occur due to program errors, such as NullPointerException&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-size:85%;"&gt;There have been holy wars waged over this topic.&lt;br /&gt;    &lt;/span&gt;&lt;/li&gt; &lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13911304-111957480574816261?l=javasmitten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/111957480574816261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13911304&amp;postID=111957480574816261' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111957480574816261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111957480574816261'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/2005/06/checked-vs-unchecked-exceptions.html' title='Checked vs. Unchecked Exceptions'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13911304.post-111957440105826670</id><published>2005-06-23T17:49:00.000-07:00</published><updated>2005-06-23T17:53:21.063-07:00</updated><title type='text'>Difference between Abstract and Interface</title><content type='html'>&lt;ul&gt;   &lt;li&gt;Interface only provides the contract, does not add default behaviour, whereas abstract classes provide default behaviour (not necessarily, only if you want to, but that is the point)&lt;br /&gt;  &lt;/li&gt;   &lt;li&gt;You can implement as many interfaces as you may want, but only extend from one abstract class&lt;/li&gt;   &lt;li&gt;You cannot have private, protected variables in an Interface.&lt;br /&gt;  &lt;/li&gt; &lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13911304-111957440105826670?l=javasmitten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javasmitten.blogspot.com/feeds/111957440105826670/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13911304&amp;postID=111957440105826670' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111957440105826670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13911304/posts/default/111957440105826670'/><link rel='alternate' type='text/html' href='http://javasmitten.blogspot.com/2005/06/difference-between-abstract-and.html' title='Difference between Abstract and Interface'/><author><name>Java Foo</name><uri>http://www.blogger.com/profile/14104080800348407575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/260/6654/640/jfoo2.jpg'/></author><thr:total>0</thr:total></entry></feed>
