<?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-6980756524418707775</id><updated>2011-12-15T08:42:01.440-08:00</updated><category term='Blackberry Development'/><category term='WebServices'/><category term='IntelliJ Idea'/><category term='Quality Control'/><category term='MySQL'/><category term='Performance'/><category term='Force.com'/><category term='Hibernate'/><category term='ActiveMQ'/><category term='Technical Architecture'/><category term='Tech Fun'/><category term='Parsing'/><category term='Spring Validation'/><category term='Log4j'/><category term='RMI'/><category term='Testing'/><category term='Tomcat'/><category term='Spring MVC'/><category term='JMock'/><category term='PostgreSQL'/><category term='General'/><category term='EHCache'/><category term='Maven'/><category term='Technology Management'/><category term='JAXB'/><category term='JMS'/><category term='Spring Cache'/><category term='SSL'/><category term='JUnit'/><category term='Spring'/><category term='Multithreading'/><category term='Product Ideas'/><category term='Serialization'/><category term='Quartz'/><title type='text'>Technologies Ahoy</title><subtitle type='html'>Living technology</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>56</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-4715202476025408226</id><published>2011-12-15T08:42:00.000-08:00</published><updated>2011-12-15T08:42:01.446-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technical Architecture'/><title type='text'>Basic Patterns Catalogue</title><content type='html'>&lt;div style="font-family:verdana;font-size:12px;"&gt;Summarising key patterns used in development for reference.&lt;br /&gt;&lt;br /&gt;A &lt;b&gt;Pattern&lt;/b&gt; is a solution to a problem in a context.&lt;br /&gt;&lt;br /&gt;An &lt;b&gt;Anti-Pattern&lt;/b&gt; tells you how to go from problem to a bad situation.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Observer Pattern&lt;/b&gt; defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Adapter Pattern&lt;/b&gt; converts the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.&lt;br /&gt;&lt;br /&gt;Use &lt;b&gt;Bridge Pattern&lt;/b&gt; to vary not only your implementation, but also your abstraction.&lt;br /&gt;&lt;br /&gt;Use &lt;b&gt;Builder Pattern&lt;/b&gt; to encapsulate the construction of a product and allow it to be constructed in steps. It encapsulates the way a complex object is created. &lt;br /&gt;&lt;br /&gt;Use &lt;b&gt;Chain of Responsibility Pattern&lt;/b&gt; when you want to give more than one object a chance to handle a request.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Composite Pattern&lt;/b&gt; allows you to compose objects into tree structures to represent part-whole hierarchies. It lets clients treat individual objects and composition of objects uniformly.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Command Pattern&lt;/b&gt; encapsulates the request as an object, thereby letting you parameterise other objects with different requests, queue or log requests, and support undoable operations.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Decorator Pattern&lt;/b&gt; attaches additional responsibilities to an object dynamically. It provides a flexible alternative to subclassing for extending functionality.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Facade Pattern&lt;/b&gt; provides a unified interface to a set of interfaces in a subsystem. It defines a higher level interface that makes the subsystem easier to use.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Factory Method Pattern&lt;/b&gt; defines an interface for creating an object, but lets subclasses decide which classes to instantiate. Factory Method lets a class defer instantiation to subclasses.&lt;br /&gt;&lt;br /&gt;Use the &lt;b&gt;Flyweight Pattern&lt;/b&gt; when one instance of a class can be used to provide many “virtual instances”.&lt;br /&gt;&lt;br /&gt;Use &lt;b&gt;Interpreter Pattern&lt;/b&gt; to build an interpreter for a simple language. &lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Iterator Pattern&lt;/b&gt; provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;&lt;br /&gt;Use the &lt;b&gt;Mediator Pattern&lt;/b&gt; to centralise complex communications and controls between related objects. It can become overly complex without proper design.&lt;br /&gt;&lt;br /&gt;Use the &lt;b&gt;Memento Pattern&lt;/b&gt; when you need to be able to return an object to one of its previous states, e.g. if your user requests an “undo”.&lt;br /&gt;&lt;br /&gt;Use the &lt;b&gt;Prototype Pattern&lt;/b&gt; when creating an instance of a given class is either expensive or complicated.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Proxy Pattern&lt;/b&gt; provides a surrogate or placeholder for another object to control access to it.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Singleton Pattern&lt;/b&gt; ensures a class has only one instance, and provides a global point of access to it.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;State Pattern&lt;/b&gt; allows an object to alter its behaviour when its internal state changes. The object will appear to change its class.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Strategy Pattern&lt;/b&gt; defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Template Method Pattern&lt;/b&gt; defines the skeleton of an algorithm in a method, deferring some steps to subclasses. It lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure.&lt;br /&gt;&lt;br /&gt;Use the &lt;b&gt;Visitor Pattern&lt;/b&gt; when you want to add capabilities to a composite of objects and encapsulation is not important.&lt;br /&gt;&lt;br /&gt;Please refer &lt;a href='http://c2.com/ppr/' target='_blank'&gt;http://c2.com/ppr/&lt;/a&gt; for more on patterns.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-4715202476025408226?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/4715202476025408226/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=4715202476025408226' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/4715202476025408226'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/4715202476025408226'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2011/12/basic-patterns-catalogue.html' title='Basic Patterns Catalogue'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-4302543782943565779</id><published>2011-12-13T13:35:00.000-08:00</published><updated>2011-12-13T13:36:03.241-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Force.com'/><title type='text'>Force.com: What Gives?</title><content type='html'>&lt;div style="font-family:verdana;font-size:12px;"&gt;When Salesforce.com came up with Force.com, briefly I did nurture the illusion that they wanted to make the new platform for the web. Too bad it turned out to be a marketing gimmick to tap into a wider creative potential. Brilliant strategic move, but not what I had hoped it would become.&lt;br /&gt;&lt;br /&gt;Force.com licenses are now paid and Salesforce is coming up with a financial software. Too bad its Chatter and related ideas didn't amount to much eventually. Nevertheless, as a company it has a good future. I only rue that it could have really worked on making Force a platform for the web. That, however, would have needed a paradigm shift in business strategy. So, in a way, the company has come back to its roots; not letting itself being deluded by grandiose ideas about social networking. &lt;br /&gt;&lt;br /&gt;Paying for Force.com is like being sold Java and then being expected to pay for it (thank God that didn't happen!): doesn't feel good. Business, however, is not about feeling good: it is about profit. Perhaps that's why Oracle bought Sun while Salesforce continues its growth saga. On behalf of people who support open-source, I can only say: RIP, Force.com (hopefully)!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-4302543782943565779?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/4302543782943565779/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=4302543782943565779' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/4302543782943565779'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/4302543782943565779'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2011/12/forcecom-what-gives.html' title='Force.com: What Gives?'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-3636190906480540637</id><published>2011-11-29T05:53:00.000-08:00</published><updated>2011-11-29T05:53:54.311-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technical Architecture'/><title type='text'>10 Design Principles</title><content type='html'>&lt;div style="font-family:verdana;font-size:12px;"&gt;Was going through my older notes, brushing up some technical bits. My first book for design patterns was &lt;a href='http://www.amazon.co.uk/Design-patterns-elements-reusable-object-oriented/dp/0201633612/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1322573821&amp;sr=1-1' target='_blank'&gt;the original book by the Gang of Four&lt;/a&gt;. However, the book that helped me understand Design Patterns the best was &lt;a href='http://www.amazon.co.uk/Head-First-Design-Patterns-Freeman/dp/0596007124/ref=sr_1_2?s=books&amp;ie=UTF8&amp;qid=1322573821&amp;sr=1-2' target='_blank'&gt;Head First Design Patterns&lt;/a&gt;. Following are the key design principles summarised in the book:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Identify the aspects of the application that vary and separate them from what stays the same: use encapsulation.&lt;/li&gt;&lt;li&gt;Program to an interface, not an implementation&lt;/li&gt;&lt;li&gt;Favour composition over inheritance&lt;/li&gt;&lt;li&gt;Strive for loosely coupled designs between objects that interact&lt;/li&gt;&lt;li&gt;While inheritance is powerful, it does not always lead to the most flexible or maintainable designs&lt;/li&gt;&lt;li&gt;Code should be closed to change but open to extension&lt;/li&gt;&lt;li&gt;Principle of least knowledge: talk only to your immediate friends. Only invoke methods that belong to:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;The object itself&lt;/li&gt;&lt;li&gt;Objects passed in a parameter to the method&lt;/li&gt;&lt;li&gt;Any object that the method creates or instantiates&lt;/li&gt;&lt;li&gt;Any components of the object&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Depend upon abstractions. Do not depend upon concrete classes&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Avoid variables that hold reference to a concrete class (use Factory)&lt;/li&gt;&lt;li&gt;Avoid deriving class from concrete classes&lt;/li&gt;&lt;li&gt;Avoid overriding any of the implemented methods of a base class&lt;/li&gt;&lt;li&gt;You can ignore these guidelines if the class is highly unlikely to change&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Hollywood principle: don’t call us, we’ll call you. Low level components can hook into the system, but high level components determine when they are needed.&lt;/li&gt;&lt;li&gt;A class should have only one reason to change&lt;/li&gt;&lt;/ol&gt;I have put this blog for my own reference, but hope it helps somebody else as well. To learn more, you will have to refer Head First. In next few posts I will summarise key design patterns as described in the book.&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/6980756524418707775-3636190906480540637?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/3636190906480540637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=3636190906480540637' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3636190906480540637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3636190906480540637'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2011/11/design-principles.html' title='10 Design Principles'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-2555487145389620621</id><published>2010-09-18T05:32:00.000-07:00</published><updated>2010-09-18T05:32:01.807-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='General'/><title type='text'>Fewer Posts</title><content type='html'>&lt;div style="font-famiy:verdana;font-size:12px"&gt;Since I am starting my MBA from this September, this blog will see fewer posts. Nevertheless, I will log my technical learnings in general as I come across them! So, don't think I am gone, just hibernating :).&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-2555487145389620621?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/2555487145389620621/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=2555487145389620621' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/2555487145389620621'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/2555487145389620621'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2010/09/fewer-posts.html' title='Fewer Posts'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-3663177183791641149</id><published>2010-05-19T02:45:00.000-07:00</published><updated>2010-05-19T02:46:34.295-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Blackberry Development'/><category scheme='http://www.blogger.com/atom/ns#' term='IntelliJ Idea'/><title type='text'>Debugging Tests For Blackberry Development in IntelliJ Idea</title><content type='html'>&lt;div style="font-family:verdana;font-size:12px;"&gt;Thanks to Andrew's persistent and genius effort, the team now has a way to debug the tests in IntelliJ Idea for BlackBerry development. This still does not debug UI code in simulator, but is still a huge jump forward to help the team with super-effective unit testing. The build file has been updated to reflect the changes. Besides using this build file and the structure mentioned in the previous post, you need to follow these steps:&lt;br /&gt;&lt;br /&gt;1. Lets assume your main application project is called SampleApp. This should appear in your Idea project as a single module. Create another module for your project and name it "testing" (say)&lt;br /&gt;&lt;br /&gt;2. This will create a "testing" folder on your hard disk. Create an empty folder under the module and name it "src". In the project module settings set this to be source folder for the module&lt;br /&gt;&lt;br /&gt;3. Using the ant build file, first build and test your SampleApp. This will create a "tests.jar" in the "test_build" folder and a "SampleApp.jar" in the application folder &lt;br /&gt;&lt;br /&gt;4. Now, for the testing module open the module settings and go to the "Dependencies" pane. Add the SampleApp as Module Dependency. After this add the SampleApp.jar and test.jar. Finally, add all the dependency jars that we added for SampleApp and all the jars in the lib folder of the installed Ant. Use J2ME SDK as the module JDK&lt;br /&gt;&lt;br /&gt;5. Now, open Run-&gt;Edit Configurations. Add a new configuration to "Application" and name it "ant run". Set the following parameters:&lt;br /&gt;&lt;br /&gt;Main class: org.apache.tools.ant.launch.Launcher&lt;br /&gt;&lt;br /&gt;Program parameters: -buildfile bb_build.xml -Dbasedir=C:\development\code\SampleApp test&lt;br /&gt;(the base directory of your project with the ant build file in it)&lt;br /&gt;&lt;br /&gt;Working Directory : C:\development\code\SampleApp&lt;br /&gt;(has your build file)&lt;br /&gt;&lt;br /&gt;Environment Variables: -Dant.home=C:\development\ant_installation&lt;br /&gt;&lt;br /&gt;Use classpath and JDK of module: testing&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Voila! You are ready to debug your tests! Put a break-point in your tests in SampleApp module and debug the testing module using this configuration.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-3663177183791641149?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/3663177183791641149/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=3663177183791641149' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3663177183791641149'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3663177183791641149'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2010/05/debugging-tests-for-blackberry.html' title='Debugging Tests For Blackberry Development in IntelliJ Idea'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-3428925684864818476</id><published>2010-05-17T04:38:00.000-07:00</published><updated>2010-05-19T02:45:34.032-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Blackberry Development'/><category scheme='http://www.blogger.com/atom/ns#' term='IntelliJ Idea'/><title type='text'>Ant Script for Blackberry Development in IntelliJ Idea</title><content type='html'>&lt;div style="font-family:verdana;font-size:12px"&gt;To say that developing Blackberry J2ME applications is a nightmare is an understatement, especially is you wish to setup a comprehensive build and test environment for the team. It is possible to do things in bits and pieces, but having a single integrated development environment handle it all gracefully looks like a distant dream, forcing us to move to Ant and use its build scripts to get a build environment that is not only independent of the IDE but can also be used in continuous builds. Many thanks to &lt;a href="http://uk.linkedin.com/pub/andrew-langmead/1/7a6/a00" target="_blank"&gt;Andrew&lt;/a&gt; for helping us to get this far. I have compiled the steps needed to set up the Ant environment in IntelliJ Idea.&lt;br /&gt;&lt;br /&gt;1. Install &lt;a href="http://java.sun.com/javame/sdk/" target="_blank"&gt;Sun's Java ME SDK&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;2. Install &lt;a href="http://ant.apache.org/" target="_blank"&gt;Ant&lt;/a&gt; such as its path does NOT have a blank space in its installation path name&lt;br /&gt;&lt;br /&gt;3. Install the relevant version of RIM JDE and emulator &lt;br /&gt;&lt;br /&gt;4. Create an ordinary Java project. Change SDK to ME in project settings (Project Settings-&gt;General, you can bring up the dialog from File-&gt;Settings)&lt;br /&gt;&lt;br /&gt;5. Check the folder in which the project has been created. Create the following sub-folders inside it: application, bin, lib, src, test, test_build, test_results. Within "test_build" create a "classes" folder&lt;br /&gt;&lt;br /&gt;6. Even though you could link jar files from anywhere in the system, it may be a good idea to put following jars for following projects at one place in the lib directory:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://bb-ant-tools.sourceforge.net/" target="_blank"&gt;Blackberry Ant Tools&lt;/a&gt;&lt;br /&gt;&lt;a href="http://hammingweight.com/modules/jmunit/" target="_blank"&gt;JMUnit and Hammock&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.jdom.org/" target="_blank"&gt;JDOM&lt;/a&gt;&lt;br /&gt;&lt;a href="http://j2meunit.sourceforge.net/" target="_blank"&gt;J2MEUnit&lt;/a&gt; &lt;br /&gt;&lt;a href="http://www.microemu.org/" target="_blank"&gt;Microemulator&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Additionally, to make your life easier while coding, copy the net_rim_api.jar from the lib folder of the installed RIM JDE&lt;br /&gt;&lt;br /&gt;7. In project setting (Project Settings-&gt;Modules), set "src" as the source folder and "test" as the test folder. In dependencies, add jars for RIM, JMunit, Hammock and J2MEUnit.&lt;br /&gt;&lt;br /&gt;8. Expand the "Ant Build" panel and open properties dialog. Under execution, use custom ant and point to the intallation that does not have any blank spaces in its path. Under Additional Classpath, add all the jars that we had put in step 6. Be sure to have the ant tasks for JMUnit and Blackberry Ant Tools.&lt;br /&gt;&lt;br /&gt;9. You are all ready to start coding under your "src" folder and write tests under your "test" folder. Now we need a build file that can enable you to actually build and test your code. For that, make a "build.xml" file, which will be your ant script, and place under the root folder. &lt;a href="http://docs.google.com/View?id=ddhf5h22_154rtj9f5hc" target="_blank"&gt;Use this script provided for you&lt;/a&gt;. Don't forget to adjust the paths as per your installations. With some luck, this should bring up 8 tasks on your pane: build, build_and_deploy, build_deploy_and_launch_simulator, launch_simulator, test, test_compile. Note that the build task will not launch test task in the current script, but you could change it if you please.&lt;br /&gt;&lt;br /&gt;These tasks will accrue you the following benefits:&lt;br /&gt;&lt;br /&gt;1. You can write your blackberry development code in Idea&lt;br /&gt;2. You have an ant script that can be used to make contunuous builds and tests. The test also generates reports that are stored under the test_results folder. &lt;br /&gt;&lt;br /&gt;My team has still not found a satisfactory answer to debugging, but current set-up helps us to develop using a more effective tool and get our automated build systems to run effectively for the wretched J2ME. Moreover, this Ant script can be run from any IDE (with similar configuration for the ant used). It is still not 100% perfect, but we are getting there: constantly thinking about testability, logging and sustainability of build environment. I will keep updating the build file so as it gets more comprehensive.&lt;br /&gt;&lt;br /&gt;PS: We were able to build and test using Ant and Netbeans, but the build/deploy part was tightly coupled with Netbeans, which was not encouraging for automated build tasks.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-3428925684864818476?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/3428925684864818476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=3428925684864818476' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3428925684864818476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3428925684864818476'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2010/05/ant-script-for-blackberry-development.html' title='Ant Script for Blackberry Development in IntelliJ Idea'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-2062223408496174077</id><published>2010-04-14T07:13:00.000-07:00</published><updated>2010-04-14T07:13:50.188-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tech Fun'/><title type='text'>An Ode To Testing</title><content type='html'>&lt;div style="font-family:verdana;font-size:12px"&gt;Even though I am all for quality, testing can get torturous at times. So here is a fun take on the perils of testing by yours truly :)&lt;br /&gt;&lt;br /&gt;"O Horrible testing, in ways so many of thee&lt;br /&gt;You take pleasure in tormenting me&lt;br /&gt;&lt;br /&gt;Test cases are many, JUnit is one&lt;br /&gt;And these useless stubs under the sun&lt;br /&gt;Trying to focus my eyes water&lt;br /&gt;As my head starts feeling hotter&lt;br /&gt;And I yawn and I fall&lt;br /&gt;Horribly sleepy one and all&lt;br /&gt;In search of quality I seek thee&lt;br /&gt;But a JMocking venomous smirk is all I see&lt;br /&gt;Murderously as you try to JRun me &lt;br /&gt;Yes, you take pleasure in tormenting me"&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-2062223408496174077?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/2062223408496174077/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=2062223408496174077' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/2062223408496174077'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/2062223408496174077'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2010/04/ode-to-testing.html' title='An Ode To Testing'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-329103071496333094</id><published>2010-04-13T14:06:00.000-07:00</published><updated>2010-04-13T14:06:04.422-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Testing'/><category scheme='http://www.blogger.com/atom/ns#' term='Technology Management'/><category scheme='http://www.blogger.com/atom/ns#' term='Quality Control'/><title type='text'>Thinking Quality: Basic Thumb Rules</title><content type='html'>&lt;div style="font-size:12px;font-family:verdana"&gt;Quality of code is often a critical issue in a development team. Ensuring the quality can get complicated for a variety of reasons, so let us explore the possible ways to ensure code quality.&lt;br /&gt;&lt;br /&gt;First, it is important to get the programmer to think how he can keep improving the quality of his code. Bugs are inevitable, but that is no excuse for shabby programming. However, it is difficult to get most developers to take this seriously without antagonizing them. Nevertheless, making unit testing integral to development can check many if not all bugs. People can also be encouraged to develop a customized check-list for themselves to help them avoid common mistakes. Having a "company-wide" check-list may prove to be both counter-productive and bureaucratic.&lt;br /&gt;&lt;br /&gt;Second, code reviews can be useful. However, it can cause antagonism within the team and people may be reluctant to criticize each other. Moreover, it can be done effectively only by senior and more experienced people in the team. Anonymous, time-bound reviews is one potential answer to use this tool.&lt;br /&gt;&lt;br /&gt;Third, using Agile and related development technologies will help the manager to leverage the full experience of the team, get them closer to the requirements and avoid many bugs related with misunderstanding specifications.&lt;br /&gt;&lt;br /&gt;Finally, the productivity of the team is the function of morale. Morale for different people can mean different things. The best way, however, to build it is by having a clear vision for the company and being able to percolate it meaningfully in every aspect of work. Further, focus on the strengths and interests of each team member instead of focussing on their weaknesses.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-329103071496333094?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/329103071496333094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=329103071496333094' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/329103071496333094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/329103071496333094'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2010/04/thinking-quality-basic-thumb-rules.html' title='Thinking Quality: Basic Thumb Rules'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-8030514292253535972</id><published>2010-02-04T05:49:00.000-08:00</published><updated>2010-02-04T05:57:58.180-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Blackberry Development'/><title type='text'>Nested Table Component for Blackberry</title><content type='html'>&lt;p style="font-family:verdana;font-size:14px"&gt;Based on our last Simple Table component, I have put together a Nested Table as well. The main features are:&lt;br /&gt;&lt;br /&gt;-Each row can be rendered like an irregular table&lt;br /&gt;-Each row is backed by an object&lt;br /&gt;-Possibility to add a popup to row click&lt;br /&gt;&lt;br /&gt;These classes demonstrate how to use the component:&lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_134dttqrqcz' target='_blank'&gt;SampleApplication.java&lt;/a&gt;&lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_135cvtz29fj' target='_blank'&gt;SampleRowBackingBean.java&lt;/a&gt; &lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_136fm7f3phr' target='_blank'&gt;SampleBean.java&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;You would need the following classes to make this work:&lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_137g48nvvcn' target='_blank'&gt;BNestedTable.java&lt;/a&gt;&lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_138546nvngj' target='_blank'&gt;BMultiRowBackingBean.java&lt;/a&gt; &lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_139rv2qrhcg' target='_blank'&gt;BGenericTableCallback.java&lt;/a&gt; &lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_140xnfghgdf' target='_blank'&gt;BAbstractRowRenderer&lt;/a&gt; &lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_141fj9d6xdk' target='_blank'&gt;BNestedRowRenderer.java&lt;/a&gt;&lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_142gpqgt7hc' target='_blank'&gt;BSimplePopupScreen.java&lt;/a&gt;  &lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_143cg5dh3hk' target='_blank'&gt;FieldCreatorUtility.java&lt;/a&gt;&lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_144fqnkrnc6 ' target='_blank'&gt;UiProperties.java&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;Possible improvements:&lt;br /&gt;-implementing varying row heights&lt;br /&gt;-implement table header, table footer and column header&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-8030514292253535972?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/8030514292253535972/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=8030514292253535972' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/8030514292253535972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/8030514292253535972'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2010/02/nested-table-component-for-blackberry.html' title='Nested Table Component for Blackberry'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-1055761032500154648</id><published>2010-02-03T08:37:00.001-08:00</published><updated>2010-02-05T01:58:30.863-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Blackberry Development'/><title type='text'>A Simple Table Component for Blackberry</title><content type='html'>&lt;p style="font-family:verdana;font-size:14px;"&gt;Just worked on making a J2ME based prototype for a Blackberry (JDE 4.7+). The documentation, the website and the API are horrible, to say the least. We are using the Eclipse Plugin for development. One of the prime difficulties we faced was the absence of a well-defined table component. "ListField" is horribly designed and the example that is given in their documentation does needs serious improvement. Moreover, to make a flexible component that renders a list of messages (like the SMS message list) with each composite row selectable as a whole, no example could really help. So, I have made two components that you can improve upon and use as you please.&lt;/p&gt;&lt;p style="font-family:verdana;font-size:14px;"&gt;The first one, that is given in this post, is a simple table. It takes a 2-D array of fields and converts it into a visual table. It simply improves upon ListField. You would need the following three classes:&lt;/p&gt;&lt;span style="font-family:verdana;font-size:14px;"&gt;&lt;a href="http://docs.google.com/View?id=ddhf5h22_131dn3383cr" target="_blank"&gt;BSimpleTable.java&lt;/a&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/View?id=ddhf5h22_132ck8d8xdh" target="_blank"&gt;BSimpleTableCallback.java&lt;/a&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/View?id=ddhf5h22_133crhtrnpv" target="_blank"&gt;BSimpleRowRenderer.java&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style="font-family:verdana;font-size:14px;"&gt;Then in you code, use a similar code snippet to make and add a table (here we use it to create the title of the screen):&lt;/p&gt;&lt;pre style="font-family:courier;font-size:14px;background-color:#EEEEEE;border:solid 1px black"&gt;Field[][] titleContent = new Field[1][];&lt;br /&gt;titleContent[0] = new Field[3];&lt;br /&gt;titleContent[0][0] = new LabelField("S.No.",&lt;br /&gt;  DrawStyle.ELLIPSIS);&lt;br /&gt;titleContent[0][1] = new LabelField("Message",&lt;br /&gt;  DrawStyle.ELLIPSIS);&lt;br /&gt;titleContent[0][2] = new LabelField("Time",&lt;br /&gt;  DrawStyle.ELLIPSIS);&lt;br /&gt;int[] widthPercent = {10,63,27};&lt;br /&gt;int[] paddings = { 5, 0, 0 };&lt;br /&gt;setTitle(new BSimpleTable(titleContent,&lt;br /&gt;  widthPercent, paddings, &lt;br /&gt;  Field.NON_FOCUSABLE));&lt;br /&gt;&lt;/pre&gt;&lt;p style="font-family:verdana;font-size:14px;"&gt;If you don't want to sign the application, hard code the total screen width instead of using Display.getWidth()&lt;br /&gt;&lt;br /&gt;Also, see: &lt;a href="http://docs.blackberry.com/en/developers/subcategories/?userType=21&amp;amp;category=Development+Guides&amp;amp;subCategory=&amp;amp;url=/developers/subcategories/&amp;amp;versionId=174" target="_blank"&gt;Version Specific Developmnet Guides (3.6 to 5.0 beta)&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-1055761032500154648?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/1055761032500154648/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=1055761032500154648' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/1055761032500154648'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/1055761032500154648'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2010/02/simple-table-component-for-blackberry.html' title='A Simple Table Component for Blackberry'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-889362269566738156</id><published>2009-12-16T07:46:00.000-08:00</published><updated>2009-12-16T13:56:23.040-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technology Management'/><title type='text'>Marketing Triumphs Technology?</title><content type='html'>&lt;div&gt;I have heard quite a few business leaders implying that marketing always triumphs technology. I do not dispute the importance of marketing. Nevertheless, working in technology business myself, I have no doubts that in the long-run technology is as important as marketing. Putting one above the other is to disparage one at the cost of other. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It is possible to use logic to exhalt any department. For example, the Business Development department can as easily assert that it is the sales force that gets in the money and is truly in touch with the truths at the ground level, unlike marketing managers that make a sweet sounding theoretical plans in their ivory towers. Technology, Marketing and Sales have their own place in the company structure. Comparing one with the other is absurd, unwarranted and potentially destructive.  &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Many technology guys are more interested in developing and creating. Innovation cannot come to them easily unless they are given a chance to interact with customers and involved with the business side of things. Barricading engineers &amp;amp; scientists in laboratories and complaining about lack of innovation is ironic, to say the least. Without customer interaction innovation is difficult to achieve. Marketing itself can be highly destructive if it operates in isolation from the customer. Sales without customer focus will kill the product eventually. Some people talk of innovation as if it is a commodity or a God given gift. My experience tells me that innovation is a result of closeness to customer and willingness to experiment. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Innovation may not be about wearing white coats, but it is not about wearing a tie and a suit (with a marketing hat) either. Innovation is an attitude born out of a company's culture and its people. Period.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-889362269566738156?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/889362269566738156/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=889362269566738156' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/889362269566738156'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/889362269566738156'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/12/marketing-triumphs-technology.html' title='Marketing Triumphs Technology?'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-4788656898825911484</id><published>2009-09-10T02:51:00.000-07:00</published><updated>2009-09-10T02:52:51.106-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technology Management'/><title type='text'>Speeding Up Technology: Thinking People</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Verdana; font-size: 13px; "&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;In the previous two articles I have talked about the need for a vision with an ambition and the need to cultivate leaders. I have talked about the importance of policy. It, however, strikes me that who will make policy? Policy is the product created by people. So we have read about the importance of hiring the right people. But who will hire the right people? Only somebody who believes in it as a concept and is willing to implement it in practice. Moreover, it does not end here and the company needs to be ready with at least ambition-vision + cultivate leadership mindset so as it can make full use of the right people and retain them. Bottom-up changes are generally painful and often viewed with suspicion by almost everybody at top. Top-down changes without getting people involved are viewed similarly by people who are not party to it. The next pre-requisite, then, is a lot of communication and flexibility within the limits of the clearly defined vision/ policy.  &lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;The organization is defined by its people. Nevertheless, people cannot operate in a vacuum. Having a leader that nurtures such people and inculcates a sense of pride and ownership in them without duping them is a rarity, and can be a supremely powerful force in the growth of a company. &lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;What has to be remembered, though, is that no policy, no vision can be immutable. If there is one certainty in this universe, it is change. More so in the technical world. The playing field can change completely in few years at best and few months at worse, such is the speed of change. The only defence can be having the right people and cultivating in them a spirit of learning and leadership. I would call it a "nursery" of leaders, hiring brilliant people and preparing them to rise&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-4788656898825911484?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/4788656898825911484/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=4788656898825911484' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/4788656898825911484'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/4788656898825911484'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/09/speeding-up-technology-thinking-people.html' title='Speeding Up Technology: Thinking People'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-6144575180427999690</id><published>2009-09-01T06:00:00.000-07:00</published><updated>2009-09-01T06:01:16.669-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technology Management'/><title type='text'>Speeding Up Technology: Cultivating Leaders</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Verdana; font-size: 13px; "&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Most people understand leadership as power and/or authority and there is a lot of talk about the "strength" and "vision" of a leader. However, it is easy to mistake bullying &amp;amp; stubbornness for strength and demagogy &amp;amp; rhetoric for vision. The difference is too subtle and short-term results too similar to cause any alarm.&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;The generally accepted way to make a new product at greatest speed is to place some brilliant developers under an able Senior Manager or Product Architect. Now, it can take two directions from this basic set up. One way is that the manager just focuses on the current product and executes the project in the style of "Command and Conquer" by making things simpler for his team and spelling out clear instructions to execute the project. If the team struggles, he dives right in and leads from the front ensuring the correct course for the ship. All sailors learn a lot by seeing the able captain in action and there is tremendous growth. He can encourage his sailors to learn and grow.&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;All is happy in the world till the point, till one of the sailor learns enough to attempt to captain the ship, perhaps a smaller ship. The captain may view it as abject desertion or, worse, covert mutiny. Or he may provide the testing ground for the willing sailor as he knows that the company will eventually have many ships and he cannot steer all of them alone. In this context, the vision and growth strategy of company assumes paramount importance. If there is no growth potential, it will definitely be either desertion or mutiny (with accompanying unpleasantness). Else the business will gain another leader and grow. &lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;This also makes further demand on the captain to actively recognize, cultivate and have an outlet for promising young sailors. Else he should hire sailors who do not harbour such ambitions and are happy sticking their nose only to their immediate work. Since no company can provide an unlimited supply of opportunities, one has to be ready to let go of talented people if they cannot neither find optimum use of the same nor think of ways to cultivate them further.&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;A company trusts only the best to build the nuts and bolts of their product. If it cannot make a strategy to retain them, it is a shame. This can not only lead to loss of talent but can also disrupt progress of the product due to loss of expertise and problems associated with hiring. Hence, it is in the best interest of the project to give a thought about this before starting. Here, as I said, the vision and policy of a company may be the ultimate deciding factor. At least in the initial life of a company, an entrepreneurial team that generates more entrepreneurial teams can be a powerhouse of growth and innovation. That it will affect speed positively over the long run is but one of the many side-effects of a well-thought and flexible company policy.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-6144575180427999690?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/6144575180427999690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=6144575180427999690' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/6144575180427999690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/6144575180427999690'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/09/speeding-up-technology-cultivating.html' title='Speeding Up Technology: Cultivating Leaders'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-1941447428437647348</id><published>2009-08-17T07:28:00.000-07:00</published><updated>2009-08-17T07:31:41.586-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technology Management'/><title type='text'>Speeding Up Technology: Ambition with Vision</title><content type='html'>&lt;span class="Apple-style-span"   style="  ;font-family:Verdana;font-size:13px;"&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Till this point we talked only about technology and its impact on the project without taking into account the manager, the leadership and the company. These elements bring in the human element and its pitfalls to the job. For this one reason, I feel behaviour sciences need to be explored more not only wrt economics but practically all domains of management. My articles do not claim to be any authority but reflect my point of view developed by working, reading and observing.&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;In our first article we talked that f&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;rom managerial point of view, the main stumbling blocks can be:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;ul style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;li style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;poor choice of technology&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;poor choice of development methodology&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;lack of focus on long-term vision with complete focus on speed&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;We shall explore them. But even before that, a lot depends on the company vision and the corresponding leadership policy. &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Company vision defines the existence of a corporation. Why does the corporation exist in the first place? How ambitious and flexible is it towards growth? I have seen a lot of family and privately owned businesses stagnating as their sole purpose is to earn money for its owners, as a stable source of income or to do some limited good work in its sphere. There are yet others that come up due to the Government's policy changes and new legislation or those that manage to entrench themselves in a monopolistic niche. One thing strikingly common is that many of these ventures aim to neither be the "best" nor have a long term growth plan. There is no vision to the ambition. In Jim Collins words, these are companies who have figured out a way to be good but have not thought of being great by choice or chance. In cases when they do, some truly amazing companies or professions result from that. &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;The problems, to name a few, that arise from company's lack of vision for its growth are as follows:&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;ul style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;li style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;A small company does not have any use for too many leaders. This would generally translate into a senior rung of management with a big vacuum beneath. This can blow in the company's face in time&lt;/span&gt;&lt;/li&gt;&lt;li style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Lack of growth will ultimately frustrate ambitious &amp;amp; able executives and employees alike, who may ultimately leave for better avenues. This is especially true for the Sales force&lt;/span&gt;&lt;/li&gt;&lt;li style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;A "family" atmosphere and nepotism can take roots more easily in a family run enterprise, seriously affecting the company's long-term future&lt;/span&gt;&lt;/li&gt;&lt;li style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Ultimately competition will come calling, and if they are growth oriented, it will prove disastrous for the parent company&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Having said that, there are some advantages to be had by working for a small company in its setting up phase:&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;ul style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;li style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;it will give you the opportunity to interact with and witness all aspects of business. This may prove critical in your growth as a leader who has a strong general awareness&lt;/span&gt;&lt;/li&gt;&lt;li style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;you get to see the whole product development lifecycle very closely, again adding to your leadership potential&lt;/span&gt;&lt;/li&gt;&lt;li style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;if (a big if) you can affect the company to make the leap and it succeeds, the dividends are yours to have&lt;/span&gt;&lt;/li&gt;&lt;li style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;in the initial growth phase learning is very profound and comprehensive due to the chaos associated with starting a venture, these things may be hard to learn in any big company and will serve you well when you want to do something on your own&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Summarizing, in general limiting of vision ultimately reduces the company's efficiency and affects its supply of leaders. This is true at least for the technology industry where change is too rapid for comfort of the conservative. Ambition with vision can be the currency of speed. If your employees know that they are not a "cog in the wheel" but are actually contributing to something important that will affect at least their lives positively, it will help to speed up work and check attrition. A good work-life balance, an understanding manager, "just" compensations and good employees facilities can be the icing on the cake, but it is not the cake that can satiate the hunger. I feel that nothing can replace the electric, palpitating combination of vision and ambition.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-1941447428437647348?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/1941447428437647348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=1941447428437647348' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/1941447428437647348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/1941447428437647348'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/08/speeding-up-technology-ambition-with.html' title='Speeding Up Technology: Ambition with Vision'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-3971366052396185771</id><published>2009-08-12T03:05:00.000-07:00</published><updated>2009-08-12T03:08:23.676-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technology Management'/><title type='text'>Speeding Up Technology: Testing</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Verdana; font-size: 13px; "&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Nothing can replace good development, and a good unit testing is a part of good development. I will not go as far as recommending hardcore test-driven development, but robust unit testing never hurts.&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Pre-JUnit, having a "main" method in every Java class to be tested was the way I went about testing. In came web applications and testing this way suddenly felt difficult. Then a combination of JUnit, JMock and Spring enabled me to test my code more meaningfully. For multi-threaded systems where even debugging into the running code is virtually impossible and Unit testing can help only so much, intelligent use of logging can help a lot to both verify functionality and spot potential bugs. &lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Change is our constant friend, and unit tests enable your team to keep track of their key assumptions and all the parts of the code affected by any change in the code. Barring this, the team will inevitably waste time due to avoidable, simple bugs. This makes more sense as a company cannot be sure about who will change the code in future. Documentation, code-comments and well-written code can help a new developer to understand many things, but none of them can replace well-thought unit tests that capture the essential purpose, assumptions and functionality of the class in a very practical way. It also helps the developer to think about his code more deliberately and deeply. Overall, this adds to efficiency gains in terms of product development speed and code quality.&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-3971366052396185771?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/3971366052396185771/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=3971366052396185771' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3971366052396185771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3971366052396185771'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/08/speeding-up-technology-testing.html' title='Speeding Up Technology: Testing'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-740665272923879011</id><published>2009-08-10T03:19:00.000-07:00</published><updated>2009-08-10T03:20:11.111-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technology Management'/><title type='text'>Speeding Up Technology: Choosing the Right IDE</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Verdana; font-size: 13px; "&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;People who were born with 'Eclipse' in their hand may not be able to appreciate the woes of a programmer trying to be productive with 'Edit Plus' or 'vim'. Many managers grossly under-estimate the productivity gains that can be had by using the right IDE. Not only that, development productivity for many current technologies can be improved significantly if their IDEs see significant improvement. &lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;If you do not mind spending, go ahead and buy 'Idea'. If you are broke, 'Net Beans' would make a very good choice. I know a lot of people would be screaming 'Eclipse' by this point of time. 'Eclipse' is, no doubt, the IDE with greatest potential. But if you are developing a web application, want to get up-to-speed asap and integrated with most of the needed Java and J2EE technologies for the project(Maven, Subversion, Database, Servers, Messaging etc.) in no time, I would recommend 'Net Beans'. If you value super customization over speed, 'Eclipse' is your baby. Eclipse can also serve as a fabulous starting point for anybody who wants to develop an IDE.&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;The tricky bit will come into play if you wish to develop a rich internet application. This would certainly need either JavaScript or Flex. Personally, I feel that there is no IDE that effectively addresses this problem of building a super-efficient dashboard on top of a Java based backend. In this case I would recommend using Eclipse because the Flex IDE is built on top of Eclipse. You may even use Net Beans and Eclipse in conjunction while you take time to configure Eclipse to do the complete bidding.&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-740665272923879011?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/740665272923879011/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=740665272923879011' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/740665272923879011'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/740665272923879011'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/08/speeding-up-technology-choosing-right.html' title='Speeding Up Technology: Choosing the Right IDE'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-2840283751511042682</id><published>2009-08-06T06:04:00.000-07:00</published><updated>2009-08-06T06:06:42.243-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technology Management'/><title type='text'>Speeding Up Technology: Reinventing The Wheel</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Verdana; font-size: 13px; "&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Re-usability is the holy-grail of any large-scale production industry. IT is no different. This re-usability primarily manifests itself on the technical front in form of programming paradigms, reusable components and frameworks. &lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;b&gt;Programming Paradigms&lt;/b&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Programming paradigms include computing concepts like algorithms, data structures, object oriented programming, aspect oriented programming, design pattern et al. These are fundamentals that enable programmers to 'reuse' experience. It is surprising how many developers are unaware about these things. If the team has any member who completely lacks this knowledge, training or replacement is in order as these are probably the basic pre-requisites for hiring.&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;b&gt;Reusable Components&lt;/b&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Reusable components can be taken from open-source communities, licensed from third party or developed in-house. In open source, Google and Apache Foundation are perhaps the biggest and most reliable contributors. There are also a lot of third party development houses that may have developed the needed components and can save the company a lot of time. It is always a good idea to not only be aware about these initiatives but to actively track them. Joining organizations like Association for Computing Machinery and attending technology seminars can help in keeping you aware and agile. Buying a library, using an open-source library or building on a tried and tested library are acceptable, and even desirable, ways of speeding up development. &lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Developing reusable components in-house, however, is a more tricky business. Each company, knowingly or unknowingly, does try to build upon what it knows. It is a good start but can never be enough. What is really needed is an active initiative to consciously try to build components, if not frameworks, at each step. A forum to share best practices and components across the company can multiply the benefits and speed up development significantly. In fact, bigger the company, more the benefits. The only point to be kept in mind is that this initiative should neither detract nor confuse the main objective of building the product. The danger of "initiative" turning into another bureaucratic process is an equally scary scenario.&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;b&gt;Frameworks&lt;/b&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;The final component is using frameworks. We have seen Ruby-on-Rails, Struts, Spring et al assuming significant importance. Most of them are practical implementation of programming paradigms and demonstrate the effectiveness (and weaknesses) of the underlying paradigms. Hence, frameworks are at one higher level of abstraction than either the programming paradigms or the components. This means that efficiency gains can be significantly higher if the framework is chosen correctly. In my experience, Spring makes an excellent choice for complex, multi-tiered web applications.  &lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;In our next article we talk about IDEs. &lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-2840283751511042682?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/2840283751511042682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=2840283751511042682' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/2840283751511042682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/2840283751511042682'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/08/speeding-up-technology-reinventing.html' title='Speeding Up Technology: Reinventing The Wheel'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-3387738952872295703</id><published>2009-08-04T03:49:00.000-07:00</published><updated>2009-08-06T06:04:44.175-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technology Management'/><title type='text'>Speeding Up Technology Projects</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;Speeding up technology projects can be done in various ways. I feel that there can be two fundamental stumbling blocks: technological and managerial. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;Technologically, I assume that the team has hired reasonably bright developers with a decent, if not perfect, understanding of programming basics. After that,the potential bottle-necks can be:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;reinventing the wheel: programmers spend way too much time doing stuff that is already done by somebody &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;IDE: a good IDE can significantly speed up the speed of development&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;poor testing&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;From managerial point of view, the main stumbling blocks can be:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;poor choice of technology&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;poor choice of development methodology&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;lack of focus on long-term vision with complete focus on speed&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;These may be self-evident to most of you who have had some experience in IT. Nevertheless, each point is much more complicated than it appears and merits some discussion.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;These issues can come to haunt a team at any point due to the extremely dynamic nature of information technology. To be ever-vigilant is the only answer. What makes it especially challenging is the fact that many problems can persist themselves without making themselves evident for a long time; and by that time the rot has set in with a vengeance and changes are pretty hard to implement. In a series of articles I shall have a closer look at these issues in perspective of my experience and observations and chronicle the same. Please feel free to give your feedback and views wrt same. &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/6980756524418707775-3387738952872295703?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/3387738952872295703/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=3387738952872295703' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3387738952872295703'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3387738952872295703'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/08/speeding-up-technology-projects-1.html' title='Speeding Up Technology Projects'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-5939915079286267626</id><published>2009-07-14T03:14:00.000-07:00</published><updated>2009-07-16T07:15:47.736-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SSL'/><category scheme='http://www.blogger.com/atom/ns#' term='Tomcat'/><title type='text'>Specifying SSL Certificate and Keystore Location &amp; Password</title><content type='html'>&lt;div style="font-family:verdana;font-size:12pt;"&gt;A small reminder about how to configure the location and password for your keystore with Tomcat. By default Tomcat will look for your keystore (with the file name .keystore) in the home directory with the default password. It is possible to change the filename, password, and the location that Tomcat looks for the keystore by configuring the SSL Connector in "server.xml" (in conf folder in tomcat). "keystoreFile" is the parameter specifying key location and "keyPass" would specify the corresponding password. the finished config may look something like:&lt;/div&gt;&lt;pre style="font-family:courier;border:1px solid black;background-color:#CCCCCC;font-size:10pt;"&gt;&amp;lt;Connector port="8443" &lt;br /&gt;    protocol="HTTP/1.1" SSLEnabled="true"&lt;br /&gt;    maxThreads="150" scheme="https" secure="true"&lt;br /&gt;    clientAuth="false" sslProtocol="TLS" &lt;br /&gt;    keystoreFile="/home/user_name/my_domain.key" &lt;br /&gt;    keypass="my_keystore_password"/&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;div style="font-family:verdana;font-size:12pt;"&gt;This, however, will not help you if you are using an SSL socket. This is just for making an https connection. If you want to control only keystore and truststore name and password for your socket, you need to give the system properties the values by either specifying the same in vm parameters or setting it in the code:&lt;br /&gt;&lt;br /&gt;Using VM parameters:&lt;/div&gt;&lt;pre style="font-family:courier;border:1px solid black;background-color:#CCCCCC;font-size:10pt;"&gt;-Djavax.net.ssl.keyStore=keystore.jks &lt;br /&gt;-Djavax.net.ssl.keyStorePassword=abc123 &lt;br /&gt;-Djavax.net.ssl.trustStore=truststore.jks &lt;br /&gt;-Djavax.net.ssl.trustStorePassword=abc123&lt;/pre&gt;&lt;br /&gt;&lt;div style="font-family:verdana;font-size:12pt;"&gt;In Code:&lt;/div&gt;&lt;pre style="font-family:courier;border:1px solid black;background-color:#CCCCCC;font-size:10pt;"&gt;Properties properties = System.getProperties();&lt;br /&gt;properties.put("javax.net.ssl.keyStore", keyStoreName);&lt;br /&gt;properties.put("javax.net.ssl.keyStorePassword", keyStorePassword);&lt;br /&gt;properties.put("javax.net.ssl.trustStore", trustStoreName);&lt;br /&gt;properties.put("javax.net.ssl.trustStorePassword", trustStorePassword);&lt;/pre&gt;&lt;br /&gt;&lt;div style="font-family:verdana;font-size:12pt;"&gt;For a better understanding of SSL Sockets, please refer to the &lt;a href="http://java.sun.com/j2se/1.5.0/docs/guide/security/jsse/JSSERefGuide.html" target="_blank"&gt;JSSE Reference Guide&lt;/a&gt;. Nevertheless, this is not the end of your woes if you want to control the location as well. This would make sense if you wished to package your application with some default stores so as it can potentially work right out of the box. Here is a piece of code that can help you to do exactly that: &lt;a href='http://docs.google.com/View?id=ddhf5h22_110dz55x664' target='_blank'&gt;Managing store locations&lt;/a&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-5939915079286267626?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/5939915079286267626/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=5939915079286267626' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/5939915079286267626'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/5939915079286267626'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/07/specifying-ssl-certificate-and-keystore.html' title='Specifying SSL Certificate and Keystore Location &amp; Password'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-3224463729772588388</id><published>2009-07-10T06:23:00.000-07:00</published><updated>2009-07-10T06:24:30.632-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Product Ideas'/><title type='text'>Brainstorming Basics</title><content type='html'>&lt;div&gt;A question asked is if this idea is unique. Yes and no is the answer. No, as a information systems are being built in one form or another. Yes, as there is no &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_0"&gt;comprehensive&lt;/span&gt; information management and analysis system. For example, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;Joomla&lt;/span&gt; is unique as it gives a completely different perspective on building and managing website. Similarly, the project that I am proposing is unique in its vision and application.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Is it even possible to make information systems generalist when people use them so differently? Indeed, this problem is challenging. &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_2"&gt;Nevertheless&lt;/span&gt;, in my experience, it is not only possible but is also desirable.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Am I not worried that somebody might steal my idea? Not really. In fact, if somebody can build such a system I may use it to make more &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_3"&gt;applications&lt;/span&gt;. On the other hand, since this application that I intend to build may end up as open-source, it may have some appeal eventually.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The first step is to start defining the key modules. Let us brainstorm the objects that we can see in the system&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Data Handler: A data handler that reads data in a &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_4"&gt;standardized&lt;/span&gt; format and then stores, updates or deletes it as need be&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Information: The central class that would act as a controller or central point of directing a particular information set&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;Webpage&lt;/span&gt;: A simple html page that we wish to use display various data &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_6"&gt;interpretation&lt;/span&gt; elements&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Report: A static report&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Graph: Tools to generate static graphs on data set&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Tables: Tools to generate smart tables on data set&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Filters: Filters for graph or table data&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Dashboard: Tools to generate a group of one or more dynamic graphs, smart tables and filters&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Rules: Conditional treatment of incoming data&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Alert: A &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_7"&gt;notification&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;broadcasted&lt;/span&gt; based on some rules defined on data&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Logger: Logger that takes care of information logging&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Support: A &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;UI&lt;/span&gt; to dynamically manage the information system and see the system state visually&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Each word in this list is inevitably linked to many more. As I work on it (time permitting) one definition a time, let us see where we reach. To reach the skeleton stage, we will define minimal (and final) goals for each list as we reach them.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-3224463729772588388?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/3224463729772588388/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=3224463729772588388' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3224463729772588388'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3224463729772588388'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/07/brainstorming-basics.html' title='Brainstorming Basics'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-4574010044207972202</id><published>2009-07-09T08:32:00.001-07:00</published><updated>2009-07-09T08:33:48.881-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Product Ideas'/><title type='text'>A Need For Generic Information Systems</title><content type='html'>Information systems are critical to any business. But what do I mean by information systems? I broadly define them as software entities that read data and perform some useful function on the same.  These useful functions can include:&lt;br /&gt;&lt;br /&gt;- Data visualization (reports &amp;amp; graphs)&lt;br /&gt;- Aid manual data analysis and model making (with rich data dashboards)&lt;br /&gt;- Generate event based alerts for stakeholders (email, sms, automated call, fax)&lt;br /&gt;- Rule-based data analysis&lt;br /&gt;&lt;br /&gt;Further, these systems can be either at real-time or passive.&lt;br /&gt;&lt;br /&gt;The umpteen number of permutations mean infinite possibilities. Nevertheless, it is fair to assume that such systems should have some common governing principles as they perform a fairly similar job. The current market has a plethora of information system software that are sector specific and address a small subset according to needs of its users. Yet I have not seen an information engine that addresses all these concerns in a way that is generic and powerful enough. There are a lot of pieces that address some part of the puzzle, but what we are missing is something that takes into account the whole picture.&lt;br /&gt;&lt;br /&gt;Such a project will be complex in scope and diverse in application. A modular approach that does not force user to take what he does not need is warranted. It should save the development cost for such systems for a wide array of sectors.&lt;br /&gt;&lt;br /&gt;I would propose (naturally) a java based solution using mix of spring, maven, Apache libraries, Flex, OpenMQ, Quartz and PostGres. Making it work efficiently for real-time systems and the scale of the project are two immediate challenges that I see. Making it open-source and charging for elite training/support is the way to go; unless somebody has a better idea :D. In coming days, I will try to put down the basic pegs to work towards. Ta till then!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-4574010044207972202?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/4574010044207972202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=4574010044207972202' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/4574010044207972202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/4574010044207972202'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/07/need-for-generic-information-systems.html' title='A Need For Generic Information Systems'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-1800230197933341827</id><published>2009-07-06T06:51:00.000-07:00</published><updated>2009-07-06T07:03:00.997-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Parsing'/><title type='text'>Writing DOM to XML File on Disk</title><content type='html'>&lt;div style="font-family:verdana;font-size:10;"&gt;Just wrote a small program to write a DOM to an XML on the disk using Xerces. The sample class can be seen &lt;a href="http://docs.google.com/View?id=ddhf5h22_109hp8dhzg6" target="_blank"&gt;here&lt;/a&gt;. If you are using maven, don't forget to add xerces dependencies: &lt;pre style="font-family:courier;font-size:10pt;border:solid black 1px;background-color:#DDDDDD"&gt;        &amp;lt;dependency&amp;gt;&lt;br /&gt;            &amp;lt;groupId&amp;gt;xerces&amp;lt;/groupId&amp;gt;&lt;br /&gt;            &amp;lt;artifactId&amp;gt;xmlParserAPIs&amp;lt;/artifactId&amp;gt;&lt;br /&gt;            &amp;lt;version&amp;gt;2.6.2&amp;lt;/version&amp;gt;&lt;br /&gt;        &amp;lt;/dependency&amp;gt;&lt;br /&gt;        &amp;lt;dependency&amp;gt;&lt;br /&gt;            &amp;lt;groupId&amp;gt;apache-xerces&amp;lt;/groupId&amp;gt;&lt;br /&gt;            &amp;lt;artifactId&amp;gt;xercesImpl&amp;lt;/artifactId&amp;gt;&lt;br /&gt;            &amp;lt;version&amp;gt;2.9.1&amp;lt;/version&amp;gt;&lt;br /&gt;        &amp;lt;/dependency&amp;gt;&lt;/pre&gt;&lt;br /&gt;For more details, refer &lt;a href="http://www.cafeconleche.org/books/xmljava/chapters/ch13.html" target="_blank"&gt;Processing XML with Java by Elliotte Rusty Harold&lt;/a&gt;&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/6980756524418707775-1800230197933341827?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/1800230197933341827/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=1800230197933341827' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/1800230197933341827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/1800230197933341827'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/07/writing-dom-to-xml-file-on-disk.html' title='Writing DOM to XML File on Disk'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-6899787302543655255</id><published>2009-06-16T03:50:00.001-07:00</published><updated>2009-06-17T03:15:32.050-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Maven'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><category scheme='http://www.blogger.com/atom/ns#' term='JUnit'/><title type='text'>Testing Database Code Using JUnit</title><content type='html'>&lt;div style='font-family:verdana;font-size;19px'&gt;This post outlines the basic setup that you may need to use HSQL in JUnit, Spring, Maven environment to test database code when you are using JdbcTemplate directly instead of Hibernate.&lt;br /&gt;&lt;br /&gt;Step 1: Include the maven dependencies in your pom:&lt;br /&gt;&lt;pre style='font-family:courier;font-size:15px;background-color:#DDDDDD;border:1px black solid'&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;    &amp;lt;groupId&amp;gt;hsqldb&amp;lt;/groupId&amp;gt;&lt;br /&gt;    &amp;lt;artifactId&amp;gt;hsqldb&amp;lt;/artifactId&amp;gt;&lt;br /&gt;    &amp;lt;version&amp;gt;1.8.0.7&amp;lt;/version&amp;gt;&lt;br /&gt;    &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;&lt;br /&gt;&amp;lt;/dependency&amp;gt;&lt;br /&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;    &amp;lt;groupId&amp;gt;commons-collections&amp;lt;/groupId&amp;gt;&lt;br /&gt;    &amp;lt;artifactId&amp;gt;commons-collections&amp;lt;/artifactId&amp;gt;&lt;br /&gt;    &amp;lt;version&amp;gt;3.2&amp;lt;/version&amp;gt;&lt;br /&gt;&amp;lt;/dependency&amp;gt;&lt;br /&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;    &amp;lt;groupId&amp;gt;commons-dbcp&amp;lt;/groupId&amp;gt;&lt;br /&gt;    &amp;lt;artifactId&amp;gt;commons-dbcp&amp;lt;/artifactId&amp;gt;&lt;br /&gt;    &amp;lt;version&amp;gt;1.2.2&amp;lt;/version&amp;gt;&lt;br /&gt;&amp;lt;/dependency&amp;gt;&lt;/pre&gt;Step 2: Setup bean config that will be used by our test (save as database.xml and put it in the resources folder):&lt;br /&gt;&lt;pre style='font-family:courier;font-size:15px;background-color:#DDDDDD;border:1px black solid'&gt;&amp;lt;bean id="dataSource"&lt;br /&gt;        class="org.apache.commons.dbcp.BasicDataSource"&amp;gt;&lt;br /&gt;    &amp;lt;property name="driverClassName" &lt;br /&gt;        value="org.hsqldb.jdbcDriver"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="url" &lt;br /&gt;        value="jdbc:hsqldb:mem:aname"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="username" value="sa"/&amp;gt;&lt;br /&gt;    &amp;lt;property name="password" value=""/&amp;gt;&lt;br /&gt;    &amp;lt;property name="defaultAutoCommit" value="false"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;lt;bean id="jdbcTemplate" &lt;br /&gt;        class="org.springframework.jdbc.core.JdbcTemplate"&amp;gt;&lt;br /&gt;    &amp;lt;property name="dataSource" ref="dataSource"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;/pre&gt;Step 3: Write the &lt;a href='http://docs.google.com/View?id=ddhf5h22_106xbdjb9gj' target='_blank'&gt;test case(s)&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You may find the &lt;a href='http://hsqldb.org/web/hsqlDocsFrame.html' target='_blank'&gt;HSQL documentation&lt;/a&gt; (supported data types in chapter 9) and &lt;a href='http://static.springframework.org/spring/docs/2.5.6/api/org/springframework/jdbc/core/JdbcTemplate.html' target='_blank'&gt;the api doc on JdbcTemplate&lt;/a&gt; useful as well.&lt;br /&gt;&lt;br /&gt;Of course things will not be that simple due to one simple reason: HSQL will most probably not support all the data types used by your DB (e.g. "bytea" , an array of bytes, is supported by PostGreSQL DB but not by HSQL). But it definitely a headstart and a good way to test your DB.&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/6980756524418707775-6899787302543655255?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/6899787302543655255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=6899787302543655255' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/6899787302543655255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/6899787302543655255'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/06/testing-database-code-using-junit.html' title='Testing Database Code Using JUnit'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-5308952172749575530</id><published>2009-06-10T02:40:00.000-07:00</published><updated>2009-06-10T02:53:00.761-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Cutting Corners</title><content type='html'>&lt;div style='font-family:verdana;font-size:10'&gt;When you are making systems that need to be very fast, every small bit helps. Some tips (thanks to Andrew) to fine tune performance:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;If you know that a value will not change in its lifetime, mark it as final (even those inside a method call). This will ensure that compiler accesses them faster. eg:&lt;br /&gt;&lt;pre style="font-family:courier;font-size:15px;background-color:#eeeeee;border:solid 1px black;"&gt;final int someValueToRefer;&lt;br /&gt;&lt;br /&gt;public void aMethod(final Object obj, final int funcValToRefer){&lt;br /&gt;    final int aMethodValueThatWontChange = 1234;&lt;br /&gt;}&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Use message queues between systems you want to truly decouple. This makes sure that one part doesn't hold the other to ransom&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Use System.currentTimeMillis() if all you need is current time instead of new Date()&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Save dates in DB as long values instead of date objects&lt;/li&gt;&lt;br /&gt;&lt;li&gt;When using a cache, save minimal information (saving a unique ID instead of the whole object, for example)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Use connection pooling: for databases, thread pools, messaging queues&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Use synchronization blocks instead of full method synchronization&lt;/li&gt;&lt;br /&gt;&lt;li&gt;When there is too much information to process, it may be desirable to first "group" similar chunks and process them in batches (for example, when you are sending stock alerts to you star trading team, you may want to group all the alerts by the time they are expected to go off)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;When there is a boolean to return, one can generally avoid creating one explicitly. eg:&lt;br /&gt;&lt;pre style="font-family:courier;font-size:15px;background-color:#eeeeee;border:solid 1px black;"&gt;boolean wasFound = false;&lt;br /&gt;&lt;br /&gt;for(MyObject currObj:objectList){&lt;br /&gt;     if(currObj.getProperty().equals(valueLookingFor)){&lt;br /&gt;        wasFound=true;&lt;br /&gt;        break;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return wasFound;&lt;/pre&gt;can be replaced by:&lt;br /&gt;&lt;pre style="font-family:courier;font-size:15px;background-color:#eeeeee;border:solid 1px black;"&gt;for(MyObject currObj:objectList){&lt;br /&gt;     if(currObj.getProperty().equals(valueLookingFor)){&lt;br /&gt;        return true;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return false;&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Similarly, when we have a function that finds something and returns it, when you find it in a loop return right there instead of bothering to assign it to some var and break. eg:&lt;br /&gt;&lt;pre style="font-family:courier;font-size:15px;background-color:#eeeeee;border:solid 1px black;"&gt;MyObject retVal= null;&lt;br /&gt;&lt;br /&gt;for(MyObject currObj:objectList){&lt;br /&gt;     if(currObj.getProperty().equals(valueLookingFor)){&lt;br /&gt;        retVal=currObj;&lt;br /&gt;        break;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return retVal;&lt;/pre&gt;can be replaced by:&lt;br /&gt;&lt;pre style="font-family:courier;font-size:15px;background-color:#eeeeee;border:solid 1px black;"&gt;for(MyObject currObj:objectList){&lt;br /&gt;     if(currObj.getProperty().equals(valueLookingFor)){&lt;br /&gt;        return currObj;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return null;&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-5308952172749575530?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/5308952172749575530/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=5308952172749575530' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/5308952172749575530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/5308952172749575530'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/06/cutting-corners.html' title='Cutting Corners'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-5115922104850407859</id><published>2009-05-29T05:36:00.000-07:00</published><updated>2009-05-29T05:55:24.076-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='EHCache'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>A Simple Cache That Works</title><content type='html'>&lt;span style="font-family:verdana;font-size:10;"&gt;In our last post we saw how to make a custom multiple write-single read class. In this post we see how to use basic caching to help us process information selectively. Caching is a complex thing, ie if you go to finer details. However, we needed something simple that we can log the way we want to (and know for sure that it works). I started with some complicated AOP that caches method results to only find using a basic cache to be more efficient. &lt;br /&gt;&lt;br /&gt;There are three basic steps to using cache in the spring environment:&lt;br /&gt;&lt;br /&gt;1. Configure the ehcache.xml and put it in your resources folder&lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_98gtw7h6fh' target='_blank'&gt;EHCache Config&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;2. Put the required spring configuration, injecting the cache in the required bean&lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_99gcpxdj5f' target='_blank'&gt;Spring Cache Config&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;3. Use the cache in the bean as you deem fit:&lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_96dp77f8fh' target='_blank'&gt;The multiple write, single read bean that uses caching&lt;/a&gt;&lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_97cx3s9bgz' target='_blank'&gt;A helper bean that stores data being passed around&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;And, of course, you would need the ehcache and spring cache dependencies if you are using maven:&lt;br /&gt;&lt;pre style="font-family:courier;font-size:15px;background-color:#eeeeee;border:solid 1px black;"&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;    &amp;lt;groupId&amp;gt;net.sf.ehcache&amp;lt;/groupId&amp;gt;&lt;br /&gt;    &amp;lt;artifactId&amp;gt;ehcache&amp;lt;/artifactId&amp;gt;&lt;br /&gt;    &amp;lt;version&amp;gt;1.5.0&amp;lt;/version&amp;gt;&lt;br /&gt;    &amp;lt;scope&amp;gt;compile&amp;lt;/scope&amp;gt;&lt;br /&gt;&amp;lt;/dependency&amp;gt;&lt;br /&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;    &amp;lt;groupId&amp;gt;spring-cache&amp;lt;/groupId&amp;gt;&lt;br /&gt;    &amp;lt;artifactId&amp;gt;spring-cache&amp;lt;/artifactId&amp;gt;&lt;br /&gt;    &amp;lt;version&amp;gt;2.4.1&amp;lt;/version&amp;gt;&lt;br /&gt;&amp;lt;/dependency&amp;gt;&lt;br /&gt;&lt;/pre&gt;&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/6980756524418707775-5115922104850407859?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/5115922104850407859/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=5115922104850407859' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/5115922104850407859'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/5115922104850407859'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/05/simple-cache-that-works.html' title='A Simple Cache That Works'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-3575226722744169924</id><published>2009-05-28T09:30:00.000-07:00</published><updated>2009-05-28T09:34:00.110-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Multithreading'/><title type='text'>Multiple Write and Single Read Mechanism</title><content type='html'>&lt;span style="font-family:verdana;font-size:10;"&gt;&lt;br /&gt;Just imagine: you are a successful financial company with a big entourage of traders slogging it out throughout the day. They make money for you and you would want to build a system that works as hard to help them. Sheer muscle may get you some where, but sooner or later you are going into big problems associated with building a distributed system that handles a huge-huge volume of data. It can be a hard to tame, resource hungry beast. &lt;br /&gt;&lt;br /&gt;Lets say you want it to process the data supplied in a known format and send alerts/emails to all the concerned traders (some rule based events). You also want it to be accessible over the web to your team sitting in different corners of the country. On top of it, the speed is of paramount importance. &lt;br /&gt;&lt;br /&gt;My team has solved a similar problem and it has been one hell of a experience. Don't know from where I should try to collate my experience. In each article I will summarize a problem we faced and the solutions that we opted for.&lt;br /&gt;&lt;br /&gt;We were facing a nasty problem with our messaging system. Our system had three queues where messages were posted to and read from. Each of the queue had multiple consumers and the posting was done using a pooled connection factory (ActiveMQ). The problem was that after some time the consumers would refuse to pick any fresh messages from the queue, as if they were stuck forever. We suspected it to be an ActiveMQ bug, but at the end it turned out to be a problem with our threading and caching. Our threads were getting dead-locked blocking the ports from which a consumer could read anything. We were also trying to cache the whole method call instead of the results. Got it rectified and learnt a few more things about the threaded systems and caching. In the process learned quite a few things from my manager and colleagues. Thanks to Andrew and Ben. &lt;br /&gt;&lt;br /&gt;First, we wanted to use a ReadWriteLock mechanism in which a number of threads write to a list for a particular amount of time after which another thread processes all the data written. When the data is being read, no thread can write to the common pool and the reader should allow any thread that was already writing to complete before attempting to read. We opted to use nuts-and-bolts multi-threading instead of delving deeper into java's lock mechanisms.  Here is a generic class that can do that for you:    &lt;br /&gt;&lt;br /&gt;&lt;a href='http://docs.google.com/View?id=ddhf5h22_95fr7t5xfs' target='blank'&gt;MultiWriteSingleRead.java&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In the next post we will explore using a cache on the same class so as we process information selectively.&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/6980756524418707775-3575226722744169924?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/3575226722744169924/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=3575226722744169924' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3575226722744169924'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3575226722744169924'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/05/multiple-write-and-single-read.html' title='Multiple Write and Single Read Mechanism'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-7633099993645756995</id><published>2009-04-03T03:19:00.000-07:00</published><updated>2009-04-03T03:27:01.634-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Quartz'/><title type='text'>The Return of the Persistent Quartz Job</title><content type='html'>Finally I managed to understand the persistent job and make it work reliably: for your stateful job and the trigger volatility should NOT be true. Even setting durability to true can cause problems as it would persist orphan jobs that we may not need. If the intention is to just prevent loss of jobs during system re-starts, it is enough to set requests recovery to true. That's it. Simple is beautiful :).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-7633099993645756995?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/7633099993645756995/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=7633099993645756995' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/7633099993645756995'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/7633099993645756995'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/04/return-of-persistent-quartz-job.html' title='The Return of the Persistent Quartz Job'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-3680493987898760998</id><published>2009-04-02T03:44:00.000-07:00</published><updated>2009-06-17T03:17:52.236-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spring Cache'/><category scheme='http://www.blogger.com/atom/ns#' term='EHCache'/><category scheme='http://www.blogger.com/atom/ns#' term='Maven'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>Caching Method Invocation Results</title><content type='html'>&lt;p style='font-style:verdana;font-size:12;'&gt;Worked on setting up a cache for a method invocation fetching results from a webservice using Spring Cache AOP and EHCache in a Spring-Maven environment.Long live sourceforge! The &lt;a href='http://www.onthoo.com/spring-aop-cache/apidocs/index.html?org/springframework/aop/interceptor/cache/EHCacheInterceptor.html' target='_blank'&gt;spring cache java doc&lt;/a&gt; is pretty helpful and &lt;a href='http://opensource.atlassian.com/confluence/spring/display/DISC/AOP+Cache' target='_blank'&gt;this article&lt;/a&gt; by &lt;a href='http://www.onthoo.com/blog/programming/2004/09/spring-aop-cache.html' target='_blank'&gt;Pieter Coucke&lt;/a&gt; expands on what you read in the java doc. You can also have a look at &lt;a href='http://docs.google.com/Doc?id=ddhf5h22_86c6mdmjc5' target='_blank'&gt;my complete configuration&lt;/a&gt; (which works) and is based on the article and the java doc.&lt;p&gt;&lt;p&gt;And if you are using Maven, you would need to add dependencies for &lt;a href='http://ehcache.sourceforge.net/' target='_blank'&gt;ehcache&lt;/a&gt; and &lt;a href='http://sourceforge.net/projects/spring-cache/' target='_blank'&gt;spring cache&lt;/a&gt;. &lt;/p&gt;&lt;pre style="font-style:courier;font-size:10;background-color:#DDDDDD;color:black;border:solid black 1px;padding-left:5px;"&gt;&lt;br /&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;    &amp;lt;groupId&amp;gt;net.sf.ehcache&amp;lt;/groupId&amp;gt;&lt;br /&gt;    &amp;lt;artifactId&amp;gt;ehcache&amp;lt;/artifactId&amp;gt;&lt;br /&gt;    &amp;lt;version&amp;gt;1.5.0&amp;lt;/version&amp;gt;&lt;br /&gt;&amp;lt;/dependency&amp;gt;&lt;br /&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;    &amp;lt;groupId&amp;gt;spring-cache&amp;lt;/groupId&amp;gt;&lt;br /&gt;    &amp;lt;artifactId&amp;gt;spring-cache&amp;lt;/artifactId&amp;gt;&lt;br /&gt;    &amp;lt;version&amp;gt;2.4.1&amp;lt;/version&amp;gt;&lt;br /&gt;&amp;lt;/dependency&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-3680493987898760998?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/3680493987898760998/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=3680493987898760998' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3680493987898760998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/3680493987898760998'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/04/caching-method-invocation-results.html' title='Caching Method Invocation Results'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-284489690922915047</id><published>2009-04-01T06:35:00.000-07:00</published><updated>2009-04-02T00:14:42.841-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ActiveMQ'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>Another Way of Starting ActiveMQ Broker in Spring</title><content type='html'>&lt;p style="font-family:Verdana;font-size:12px;"&gt;I had posted a &lt;a href="http://javaandjava.blogspot.com/2008/10/running-activemq-broker-in-spring.html" target="_blank"&gt;blog about running an ActiveMQ broker in Spring&lt;/a&gt;. Recently, I  found an alternative way to start an ActiveMQ message broker in spring environment by injecting a bean based on &lt;span style="font-family:courier;font-size:10;"&gt;org.apache.activemq.xbean.XBeanBrokerService&lt;/span&gt;:&lt;/p&gt;&lt;pre style="font-family:courier;font-size:10;border:solid black 1px;background-color:#CCCCCC;color:black;"&gt;&lt;br /&gt;&amp;lt;bean id="broker" class="org.apache.activemq.xbean.XBeanBrokerService"&amp;gt;&lt;br /&gt;   &amp;lt;property name="useJmx" value="true"/&amp;gt;&lt;br /&gt;   &amp;lt;!-- this tells it to create a filesystem store --&amp;gt;&lt;br /&gt;   &amp;lt;property name="persistent" value="true"/&amp;gt;&lt;br /&gt;   &amp;lt;property name="brokerName" value="mySpringBroker"/&amp;gt;&lt;br /&gt;   &amp;lt;!--the queues/topics that this broker starts with--&amp;gt;&lt;br /&gt;   &amp;lt;property name="destinations"&amp;gt;&lt;br /&gt;       &amp;lt;list&amp;gt;&lt;br /&gt;           &amp;lt;ref bean="destination1"/&amp;gt;&lt;br /&gt;           &amp;lt;ref bean="destination2"/&amp;gt;&lt;br /&gt;       &amp;lt;/list&amp;gt;&lt;br /&gt;   &amp;lt;/property&amp;gt;&lt;br /&gt;   &amp;lt;property name="transportConnectors"&amp;gt;&lt;br /&gt;       &amp;lt;list&amp;gt;&lt;br /&gt;          &amp;lt;!-- an in vm connector which is nice and fast --&amp;gt;&lt;br /&gt;          &amp;lt;bean class="org.apache.activemq.broker.TransportConnector"&amp;gt;&lt;br /&gt;             &amp;lt;property name="uri" value="vm://localhost"/&amp;gt;&lt;br /&gt;          &amp;lt;/bean&amp;gt;&lt;br /&gt;          &amp;lt;!-- a connection for external clients specifying the IP of machine deploying the broker, something like tcp://10.10.10.10:61636. Here read from a properties file but can be hard-coded as well--&amp;gt;&lt;br /&gt;          &amp;lt;bean class="org.apache.activemq.broker.TransportConnector"&amp;gt;&lt;br /&gt;             &amp;lt;property name="uri" value="${broker.transportExternalConnectorUri}"/&amp;gt;&lt;br /&gt;          &amp;lt;/bean&amp;gt;&lt;br /&gt;       &amp;lt;/list&amp;gt;&lt;br /&gt;   &amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="destination1" class="org.apache.activemq.command.ActiveMQQueue"&amp;gt;&lt;br /&gt;    &amp;lt;constructor-arg value="com.saveenkumar.myQueue1"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="destination2" class="org.apache.activemq.command.ActiveMQQueue"&amp;gt;&lt;br /&gt;    &amp;lt;constructor-arg value="com.saveenkumar.myQueue2"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-family:Verdana;font-size:12px;"&gt;In fact,the package &lt;a href='http://activemq.apache.org/maven/activemq-core/apidocs/index.html?org/apache/activemq/xbean/' style='font-family:courier;font-size:10;'&gt;org.apache.activemq.xbean&lt;/a&gt; provides various options (beans) to start the broker in a spring environment.  &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-284489690922915047?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/284489690922915047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=284489690922915047' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/284489690922915047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/284489690922915047'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/04/another-way-of-starting-activemq-broker.html' title='Another Way of Starting ActiveMQ Broker in Spring'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-2331632450003982674</id><published>2009-04-01T05:26:00.000-07:00</published><updated>2009-04-01T05:53:23.014-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Quartz'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>The Wierd Persistent Quartz Job</title><content type='html'>&lt;span class="Apple-style-span"   style="  ;font-family:Verdana;font-size:13px;"&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;I recently faced a problem with getting quartz to persist the jobs in case of a scheduler shut down. Penning down how it got solved (with &lt;a href="http://blog.benshort.co.uk/"&gt;Ben&lt;/a&gt;'s help). &lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_84fmjptg7z"&gt;My initial scheduler config looked like this&lt;/a&gt;.&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Also, when I configured my stateful job, I set volatility and request recovery to true besides putting in job class, name and group. Sadly, the job never-ever persisted when the system re-started. &lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Miraculously, &lt;a href="http://docs.google.com/Doc?id=ddhf5h22_85gn5h7pwz"&gt;this started working fine when config was replaced by this configuration&lt;/a&gt; (only scheduler config is different).&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Plus when I configured the stateful job, I set durability to true and always put in job class, name and group. Of course you can add what you want to the data map (as long as it is Serializable). &lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;What I don't understand is that even when I have not set either volatility or request recovery to true, how setting only durability to true takes care of persisting the Job between shutdowns and startups. Whatever it takes to make it work... Quirky but may be helpful to you if you face a similar problem. Cheers.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-2331632450003982674?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/2331632450003982674/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=2331632450003982674' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/2331632450003982674'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/2331632450003982674'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/04/wierd-persistent-quartz-job.html' title='The Wierd Persistent Quartz Job'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-6565671174731525217</id><published>2009-02-27T04:45:00.000-08:00</published><updated>2009-02-27T05:04:07.276-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate'/><title type='text'>Database Connection Pooling in Hibernate</title><content type='html'>&lt;div style="font-family:Verdana;font-size:12;"&gt;I was looking for a way to control connection pooling in Hibernate inside a Spring environment. God bless Apache foundation for their amazing code helps, as I found the answers in &lt;a href="http://commons.apache.org/dbcp/"&gt;DBCP&lt;/a&gt;. Which-ever hibernate session factory you use, use the following data source bean in your configuration xml to control connection pooling:&lt;br /&gt;&lt;pre style="border:1px solid black;background-color:#EEEEEE;font-family:courier;font-size:10;"&gt;&lt;br /&gt;    &amp;lt;bean id="internalDataSource" class="org.apache.commons.dbcp.BasicDataSource"&amp;gt;&lt;br /&gt;        &amp;lt;property name="driverClassName" value="org.postgresql.Driver"/&amp;gt;&lt;br /&gt;        &amp;lt;property name="url" value="jdbc:postgresql://127.0.0.1/myDatabase"/&amp;gt;&lt;br /&gt;        &amp;lt;property name="username" value="root"/&amp;gt;&lt;br /&gt;        &amp;lt;property name="password" value="abc123"/&amp;gt;&lt;br /&gt;        &amp;lt;property name="maxIdle" value="5"/&amp;gt;&lt;br /&gt;        &amp;lt;property name="maxActive" value="25"/&amp;gt;&lt;br /&gt;        &amp;lt;property name="minIdle" value="5"/&amp;gt;&lt;br /&gt;        &amp;lt;property name="initialSize" value="5"/&amp;gt;&lt;br /&gt;    &amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;For all options and details, &lt;a href="http://commons.apache.org/dbcp/apidocs/org/apache/commons/dbcp/BasicDataSource.html"&gt;refer the API for BasicDataSource&lt;/a&gt;. And, if you are a maven user, don't forget to include the dependency:&lt;br /&gt;&lt;pre style="border:1px solid black;background-color:#EEEEEE;font-family:courier;font-size:10;"&gt;&lt;br /&gt;        &amp;lt;dependency&amp;gt;&lt;br /&gt;            &amp;lt;groupId&amp;gt;commons-dbcp&amp;lt;/groupId&amp;gt;&lt;br /&gt;            &amp;lt;artifactId&amp;gt;commons-dbcp&amp;lt;/artifactId&amp;gt;&lt;br /&gt;            &amp;lt;version&amp;gt;1.2.2&amp;lt;/version&amp;gt;&lt;br /&gt;        &amp;lt;/dependency&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&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/6980756524418707775-6565671174731525217?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/6565671174731525217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=6565671174731525217' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/6565671174731525217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/6565671174731525217'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/02/database-connection-pooling-in.html' title='Database Connection Pooling in Hibernate'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-998803120781048907</id><published>2009-02-25T04:11:00.000-08:00</published><updated>2009-02-25T04:13:04.659-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='General'/><title type='text'>Which IDE?</title><content type='html'>&lt;div&gt;IDEs can be critical to productivity. As a developer, which is the one that I prefer?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There are three IDEs that I have used for development:  Idea, Eclipse and NetBeans.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Idea costs money, but it is worth it. Developing enterprise applications with it is easier than with other IDEs. Nevertheless it is not cheap and other IDEs are fast catching up with it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Eclipse is too much customizable for its own good, making the "setting up of eclipse" so as it works with a plethora of commonly used enterprise technologies almost an art. Hence the learning curve can be sharp. If you are in a hurry to get the project running and don't have much experience with Eclipse , I would not recommend Eclipse. Eclipse is a good (and free) IDE and can be a developer's joy. Nevertheless it can be a pain for somebody new to it and not willing to spend so much effort customizing it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I would have completely ruled out NetBeans before its version 6. In the past I saw it as a good Java GUI builder and thats it. But the recent release is impressive. It takes into account a lot of problems that are commonly faced using disparate technologies in enterprise development. It is configurable but comes with a lot of intelligent defaults that can get you up-to-speed pretty quickly. Still not as good as Idea, but is a good contender if you are not willing to spend. &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-998803120781048907?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/998803120781048907/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=998803120781048907' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/998803120781048907'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/998803120781048907'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/02/which-ide.html' title='Which IDE?'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-2401659723918167894</id><published>2009-01-15T03:21:00.000-08:00</published><updated>2009-01-23T04:01:27.672-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Parsing'/><title type='text'>Parsing CSV File</title><content type='html'>&lt;span class="Apple-style-span" style=";font-family:Verdana;font-size:100%;"  &gt;&lt;div style="margin-top: 0px; margin-bottom: 0px;"&gt;I just wanted to read a simple CSV file in the resources folder and parse it in my spring application. A simple class to do the same. csvFileName is a string property injected at runtime.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_58dvdx47cm"&gt;CSV Reader&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Errata: My good friend and colleague &lt;a href="http://blog.benshort.co.uk/"&gt;Ben&lt;/a&gt; has rightly pointed out availability of generic csv parsers that can make life easier. I am exploring &lt;a href="http://sourceforge.net/projects/javacsv/"&gt;Java CSV&lt;/a&gt; and &lt;a href="http://flatpack.sourceforge.net/"&gt;Flatpack&lt;/a&gt; as suggested by &lt;a href="http://blog.benshort.co.uk/"&gt;Ben&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javacsv.sourceforge.net/"&gt;Java CSV API&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.csvreader.com/java_csv_samples.php"&gt;Java CSV Sample&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-2401659723918167894?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/2401659723918167894/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=2401659723918167894' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/2401659723918167894'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/2401659723918167894'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2009/01/parsing-csv-file.html' title='Parsing CSV File'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-1601844178019840879</id><published>2008-12-15T08:38:00.000-08:00</published><updated>2008-12-16T03:59:12.436-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Log4j'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>Using Log4J in Spring: Effective Logging</title><content type='html'>&lt;span class="Apple-style-span"   style="  ;font-family:Verdana;font-size:13px;"&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Spring supports logging in its usual plug and use format. To use Apache's log4j in a Spring-Maven environments:&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;ol style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;li style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Add the log4j dependency to the pom&lt;/span&gt;&lt;/li&gt;&lt;li style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;In web.xml of the application define spring listener for log4j and its config location&lt;/span&gt;&lt;/li&gt;&lt;li style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;In the config location put in the appropriate properties file defining your loggers&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_56gqgv47gz"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Log4J Config&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;The log4j.properties at the above link is fully commented to help you(and me) understand how to use a properties file to split your logs at a finer level.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;I have realized that in order to utilize the full power of log4j it is important to understand and use log4j.properties. This can help you to isolate logs from different part of of your application- something that can be really handy when you are trying to pin-point the source of trouble in a large system. The bigger and more distributed your system becomes, more important and useful logging appears.&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;As usual, I have focussed only on the practical aspects. For knowing more about log4j, see:&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://logging.apache.org/log4j/"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Log4J Website @ Apache&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://en.wikipedia.org/wiki/Log4J"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Log4J on Wiki&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://logging.apache.org/log4j/1.2/apidocs/index.html"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Log4J API &lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-1601844178019840879?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/1601844178019840879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=1601844178019840879' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/1601844178019840879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/1601844178019840879'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/12/using-log4j-in-spring-effective-logging.html' title='Using Log4J in Spring: Effective Logging'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-1719609919320454492</id><published>2008-12-09T04:55:00.000-08:00</published><updated>2008-12-10T08:28:22.955-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='PostgreSQL'/><title type='text'>PostgreSQL Vs MySQL</title><content type='html'>&lt;span class="Apple-style-span"   style="  ;font-family:Verdana;font-size:13px;"&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;My team decided to use PostgreSQL instead of MySQL. This got me interested in finding out why. Found these articles that helped me understand:&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;a href="http://www.wikivs.com/wiki/MySQL_vs_PostgreSQL"&gt;WikiVs on MySQL vs PostgreSQL&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style="font-size:16px;"&gt;(a recent comparison, subtly votes in favor of PostgreSQL)&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:48px;"&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style=" ;font-size:16px;"&gt;&lt;a href="http://www-css.fnal.gov/dsg/external/freeware/pgsql-vs-mysql.html"&gt;Comparison by Fermilab&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style=" ;font-size:16px;"&gt;(this is the most concise comparison but is a little old, very nicely tabulated)&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style="font-size:16px;"&gt;&lt;a href="http://www.databasejournal.com/features/postgresql/article.php/3288951/PostgreSQL-vs-MySQL-Which-is-better.htm"&gt;Comparison by Ian Gilfillan&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style="font-size:16px;"&gt;(a very old comparison to give some prespective)&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style="font-size:16px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;In a nutshell, both are equally good in the current scenario; though before the 8th release of PostgreSQL,  MySQL held a distinct advantage. Currently PostgreSQL offers a wider range of features and on the whole MySQL is a bit faster. However with every release MySQL is inching towards more features and PostGreSQL towards more speed. MySQL is currently more widespread, perhaps because it is older and is preferred by the widespread PHP community. Another difference is the licensing. Both are open-source but MySQL is under GNU while PostgreSQL is under BSD.  &lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-1719609919320454492?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/1719609919320454492/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=1719609919320454492' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/1719609919320454492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/1719609919320454492'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/12/postgresql-vs-mysql.html' title='PostgreSQL Vs MySQL'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-5301506762124596861</id><published>2008-12-08T02:24:00.000-08:00</published><updated>2008-12-08T03:23:27.736-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JAXB'/><category scheme='http://www.blogger.com/atom/ns#' term='WebServices'/><category scheme='http://www.blogger.com/atom/ns#' term='Maven'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>Using JAXB in a Spring-Maven Environment for WebServices</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Verdana; font-size: 13px; "&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;In a Spring application you can consume a webservice using &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;JaxRpcPortProxyFactorybean &lt;/span&gt;or &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;XFireClientFactoryBean &lt;/span&gt;(in conjunction with XFire). However, there is another way which can prove to be extremely useful and convenient if you are using Spring and Maven: by using Spring and Maven in conjunction with JAXB. As usual, I will focus on using JAXB and not about JAXB. To learn more about JAXB see:&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://java.sun.com/developer/technicalArticles/WebServices/jaxb/"&gt;JAXB Reference at Sun&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;In this article we will cover&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;1. Setting up JAXB in Spring environment to generate stubs for the webservice&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;2. Using it in an external project or the same project.&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;As per the default maven build structure, you need to make a package called "wsdl" under src/main and place a copy of wsdl of the webservice you wish to use. Then configure your pom file with the right dependencies:&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_534k5nxjgp"&gt;POM config for JAXB&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Two things that you should notice in the pom besides JAXB dependencies are the build plugins &lt;span style="font-family: 'Courier New'; "&gt;maven-source-plugin &lt;span style="font-family: Verdana; "&gt;and &lt;span style="font-family: 'Courier New'; "&gt;maven-jaxb2-plugin&lt;span style="font-family: Verdana; "&gt;. They will generate stubs for your webservice in the "target" directory under "generated-sources" when you compile the project/ generate resources using maven. After that your webservice should be ready to used. Almost :D.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;The generated source will contain stubs that correspond to exposed functions, responses and the various objects used. The name of the stubs will correspond to name in wsdl. In the same project you can use it by importing stubs from the package specified in &lt;span style="font-family: 'Courier New'; "&gt;&lt;generatepackage&gt;com.saveenkumar.myApp.someWebService.types&lt;/generatepackage&gt;. &lt;span style="font-family: Verdana; "&gt; For an external project, you just need to import the project as a dependency.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Let us now see how to use these stubs. You will be able to use the webservice in your Spring app with the help of &lt;span style="font-family: 'Courier New'; "&gt;org.springframework.ws.client.core.WebServiceTemplate&lt;span style="font-family: Verdana; "&gt;. You can see the bean config that you can use to inject it here:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_54c5h5xddj"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;WebServiceTemplate&lt;/span&gt; config as a spring bean&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(85, 26, 139); font-size: 12px; text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Note that the "&lt;span style="font-family: 'Courier New'; "&gt;contextPaths&lt;/span&gt;" property of the JAXB marshaller is same as the &lt;span style="font-family: 'Courier New'; "&gt;&lt;generatepackage&gt; &lt;/span&gt;property above. If you want to dig still deeper, have a look about using &lt;span style="font-family: 'Courier New'; "&gt;WebServiceTemplate  &lt;/span&gt;at:&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://static.springframework.org/spring-ws/sites/1.5/reference/html/client.html"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;WebServiceTemplate&lt;/span&gt; Reference&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;and&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;a href="http://static.springsource.org/spring-ws/sites/1.5/apidocs/org/springframework/ws/client/core/WebServiceTemplate.html"&gt;WebServiceTemplate &lt;/a&gt;&lt;/span&gt;&lt;a href="http://static.springsource.org/spring-ws/sites/1.5/apidocs/org/springframework/ws/client/core/WebServiceTemplate.html"&gt;API&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;It may be a good idea to hide the &lt;span style="font-family: 'Courier New'; "&gt;WebServiceTemplate&lt;span style="font-family: Verdana; "&gt; behind a nice interface to abstract away the user from the generated JAXB classes.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;The generated classes will always have a class called "ObjectFactory". There will also be objects corresponding to every operation, every response and every object used in these transactions. Let us say our webservice exposes the following operations:&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family: 'Courier New'; "&gt;List&lt;stockinfo&gt; getAllStockInfo();&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family: 'Courier New'; "&gt;List&lt;stockinfo&gt; getStocksByVolatilityRange(float low, float high);&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family: 'Courier New'; "&gt;StockInfo getStockInfo(String ticker);&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;May generate following objects:&lt;br /&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family: 'Courier New'; "&gt;ObjectFactory&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family: 'Courier New'; "&gt;ArrayOfStockInfo&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family: 'Courier New'; "&gt;StockInfo&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family: 'Courier New'; "&gt;GetAllStockInfo&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family: 'Courier New'; "&gt;GetAllStockInfoResponse&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family: 'Courier New'; "&gt;GetStockInfo&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family: 'Courier New'; "&gt;GetStockInfoResponse&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family: 'Courier New'; "&gt;GetStocksByVolatilityRange&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span style="font-family: 'Courier New'; "&gt;GetStocksByVolatilityRangeResponse&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Let us say we want to use &lt;span style="font-family: 'Courier New'; "&gt;GetStockInfo&lt;/span&gt;. The code would look something like:&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_55g98dcvvs"&gt;Sample JAXB Usage&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;I would also recommend using &lt;a href="http://www.soapui.org/"&gt;SoapUI&lt;/a&gt; to test your webservices. &lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-5301506762124596861?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/5301506762124596861/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=5301506762124596861' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/5301506762124596861'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/5301506762124596861'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/12/using-jaxb-in-spring-maven-environment.html' title='Using JAXB in a Spring-Maven Environment for WebServices'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-8820185855885058396</id><published>2008-12-02T02:17:00.001-08:00</published><updated>2008-12-02T02:27:54.396-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>@Resource and @Autowired</title><content type='html'>&lt;span class="Apple-style-span"   style="  ;font-family:Verdana;font-size:13px;"&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;In September I wrote &lt;a href="http://javaandjava.blogspot.com/2008/09/using-autowiring-for-testing-rmi.html"&gt;an article&lt;/a&gt; on using &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;@Autowired &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;for testing RMI services in Spring. Recently when trying to test a webservice consumer, I ran into trouble with &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;@Autowired&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;. Instead using &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;@Resource&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; (&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;javax.annotation.Resourc&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;e in Java 1.6) seemed to work fine. Digging I found this article in Spring forum:&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(85, 26, 139); text-decoration: underline;"&gt;&lt;a href="http://forum.springframework.org/showthread.php?t=48563"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Spring Forum Article on &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;@Resource&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; and &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;@Autowired&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;which pointed to this in spring reference:&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(85, 26, 139); text-decoration: underline;"&gt;&lt;a href="http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-autowired-annotation"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Spring Reference to Using &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;@Autowired&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Seems the two are pretty similar. Using &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;@Qualifier&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="  ;font-family:Verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; (&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;org.springframework.beans.factory.annotation.Qualifier&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="  ;font-family:Verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;) with &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;@Autowired&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="  ;font-family:Verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; solved the problem and in the end I could use either. &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/6980756524418707775-8820185855885058396?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/8820185855885058396/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=8820185855885058396' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/8820185855885058396'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/8820185855885058396'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/12/resource-and-autowired.html' title='@Resource and @Autowired'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-4804297124400460453</id><published>2008-11-24T08:16:00.000-08:00</published><updated>2008-11-24T08:19:43.794-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Serialization'/><title type='text'>Serialization</title><content type='html'>Serialization is not just about implementing the &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;java.io.Serializabl&lt;/span&gt;e interface, I learned. Thanks to this article pointed by my colleague, &lt;a href="http://blog.benshort.co.uk/"&gt;Ben&lt;/a&gt;. Hope it helps you too.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.javapractices.com/topic/TopicAction.do?Id=45"&gt;Click here to see the article&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-4804297124400460453?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/4804297124400460453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=4804297124400460453' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/4804297124400460453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/4804297124400460453'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/11/serialization.html' title='Serialization'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-4206224567306654449</id><published>2008-11-24T07:56:00.001-08:00</published><updated>2008-11-24T08:13:58.181-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate'/><title type='text'>Retreiving Stored Objects Using Hibernate</title><content type='html'>This one is relatively simple. &lt;div&gt;&lt;ol&gt;&lt;li&gt;Use &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;org.springframework.orm.hibernate3.support.HibernateDaoSupport&lt;/span&gt; to manage data (add or retrieve)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Refer to the official hibernate documentation to see how you can use &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Criteria &lt;/span&gt;to narrow your result set by clicking &lt;a href="http://hibernate.org/hib_docs/v3/reference/en/html/querycriteria.html"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;use&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt; getSession()&lt;/span&gt; from &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;HibernateDaoSupport &lt;/span&gt;to get the hibernate session and fire away using what you learned in step 2&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-4206224567306654449?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/4206224567306654449/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=4206224567306654449' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/4206224567306654449'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/4206224567306654449'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/11/retreiving-stored-objects-using.html' title='Retreiving Stored Objects Using Hibernate'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-8056658712803123812</id><published>2008-10-30T07:21:00.000-07:00</published><updated>2008-10-30T07:53:55.874-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Maven'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate'/><title type='text'>Persisting A List of Custom Objects Using Hibernate in a Spring Env.</title><content type='html'>&lt;span class="Apple-style-span"   style="  ;font-family:Verdana;font-size:13px;"&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;The prospect of persisting an object using hibernate into a database and then reading it back did not seem challenging with good old hibernate taking care of most things. &lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Piece of cake? Not quite actually as I discovered while trying to do it for a List of custom objects. Let us see what were the challenges and how I found the solutions. Let us assume I wish to persist an object that contains the current situation of all stocks trading in the market. Our simplistic object has an id and a list of stocks: &lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_37gw9z2wfk"&gt;StockInfoHolder POJO&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;The list of stocks is made of a custom object:&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_38dp8cdqfz"&gt;StockInfo POJO&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;And since we refuse to live without spring, we need some bean config:&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_39c3v8rkhp"&gt;Spring Bean Config&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;With spring so near how can we forget maven and the pom dependencies:&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_40g5vbsrfm"&gt;POM Dependencies&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Phew! Sometimes I forget how much these XML config make our lives easier (?).  Now, had it been my own custom object, I would have used @Embedded. But what do I do with a java collection. I was tempted to mark it with @Lob and it compiled fine. But when I actually tried to persist it, it gave me one big, fat ClassCastException: java.util.ArrayList cannot be cast to java.sql.Blob. OK, so objects don't turn into byte arrays overnight and that attempt was dumb and desperate. &lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Then what? Referring "Java Persistence with Hibernate" (Bauer and King,2006) and &lt;a href="http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/#entity-hibspec-identifier"&gt;official hibernate docs&lt;/a&gt; helped my to make my classes look like this:&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_41g8kc48hg"&gt;Hibernate Ready StockInfoHolder&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_42dswcw7cz"&gt;Hibernate Ready StockInfo&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;&lt;div style="margin-top: 0px; margin-bottom: 0px; "&gt;Now this works like a charm: at least the part about starting your app, seeing your tables created perfectly and storing your objects at the right place with some class like:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_43gh79gpds"&gt;HibernateDao&lt;/a&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In our next post we will see how we read this information back and use it if I face any difficulty with it as well!&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-8056658712803123812?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/8056658712803123812/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=8056658712803123812' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/8056658712803123812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/8056658712803123812'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/10/persisting-list-of-custom-objects-using.html' title='Persisting A List of Custom Objects Using Hibernate in a Spring Env.'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-1147855548277741431</id><published>2008-10-08T02:24:00.000-07:00</published><updated>2008-10-08T02:30:59.650-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JMS'/><category scheme='http://www.blogger.com/atom/ns#' term='ActiveMQ'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>ActiveMQ Message Consumer in Spring</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;In the last blog we saw how to configure an ActiveMQ broker to run in a Spring environment. In this blog we will see how to configure a message consumer. Again, I am not trying to explain how consumers work but just sharing code and config to make it work in Spring :p&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Since we have the luxury of Spring , we will use a message listener container provided by the framework: &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;SimpleMessageListenerContainer&lt;/span&gt;&lt;/span&gt; (&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;org.springframework.jms.listener.SimpleMessageListenerContainer&lt;/span&gt;&lt;/span&gt; ). My needs were simple and non-transactional so this container suffices&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;The basic reason is the desire to be message driven i.e. I want my app to take some actions as and when it receives messages. The container bean definition should look like:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &amp;lt;bean id="jmsContainer" class="org.springframework.jms.listener.SimpleMessageListenerContainer"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        &amp;lt;property name="autoStartup" value="true"/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        &amp;lt;property name="connectionFactory" ref="myConnectionFactory"/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        &amp;lt;property name="destination" ref="myDestination"/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        &amp;lt;property name="messageListener" ref="myMessageListener"/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        &amp;lt;property name="acceptMessagesWhileStopping" value="true"/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &amp;lt;/bean&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;This config makes the container start when the bean gets loaded and makes sure no messages are lost even if it is down. Further we need to specify the connection factory to use to connect to broker, the destination at broker from which we wish to hear and the message listener that ultimately handles the message. The config for these three will look like:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &amp;lt;bean id="myDestination" class="org.apache.activemq.command.ActiveMQQueue"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        &amp;lt;constructor-arg value="myPackage.myQueue"/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &amp;lt;/bean&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &amp;lt;bean id="myConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        &amp;lt;property name="brokerURL" value="tcp://localhost:61636"/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   &amp;lt;/bean&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;lt;bean id="myMessageListener" class="myPackage.MyMessageListener"&amp;gt;       &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &amp;lt;property name="appName" value="My Application"/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;lt;/bean&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Destination takes the name for destination in order to identify it at broker. the producer would refer it by the same name. JNDI can be used for more sophisticated look-ups which we may see some other time. Connection factory just needs url for a running broker. Message Listener is just our custom bean to handle messages. &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;MyMessageListene&lt;/span&gt;&lt;/span&gt;r would look like:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;package myPackage;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;import javax.jms.*;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public class MyMessageListener implements MessageListener {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    private String appName;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    public void setAppName(String appName){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        this.appName = appName;    &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    public void onMessage(Message message) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        //do your stuff&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Finally, don't forget the POM dependencies included in last blog if you are using Maven. You should be good to go.&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/6980756524418707775-1147855548277741431?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/1147855548277741431/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=1147855548277741431' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/1147855548277741431'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/1147855548277741431'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/10/activemq-message-consumer-in-spring.html' title='ActiveMQ Message Consumer in Spring'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-8574384038252292477</id><published>2008-10-07T07:09:00.000-07:00</published><updated>2008-10-07T07:27:35.016-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JMS'/><category scheme='http://www.blogger.com/atom/ns#' term='ActiveMQ'/><category scheme='http://www.blogger.com/atom/ns#' term='Maven'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>Running ActiveMQ Broker in Spring</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:verdana;"&gt;ActiveMQ can run as an independent JMS server. This may be desirable if we want to run it independently of our spring application. However it is also possible that we may want to deploy a message broker within a spring environment. This may be simply because we need to do some unit testing or because our webapp is too small to break across several machines. Whatever be the reason. Let us make a note of basic steps to do it:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;1. Put in your activemq.xml under the WEB-INF folder. Your ActiveMQ distribution(5.1.0 at time of this article) has this config file under the "conf" folder. We will not discuss configuring it here. &lt;a href="http://activemq.apache.org/xml-configuration.html"&gt;Go here to read about configuring&lt;/a&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;2. The lib folder of the distribution has all possible jars that JMS may ever need in its lifetime. If you are not using Maven, you may need to copy the jars to your classpath. If you are using Maven, these dependencies should generally suffice for basic use.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;        &amp;lt;dependency&amp;gt;&lt;br /&gt;           &amp;lt;groupId&amp;gt;org.springframework&amp;lt;/groupId&amp;gt;&lt;br /&gt;           &amp;lt;artifactId&amp;gt;spring-jms&amp;lt;/artifactId&amp;gt;&lt;br /&gt;           &amp;lt;version&amp;gt;2.5.5&amp;lt;/version&amp;gt;&lt;br /&gt;       &amp;lt;/dependency&amp;gt;&lt;br /&gt;&lt;br /&gt;       &amp;lt;dependency&amp;gt;&lt;br /&gt;           &amp;lt;groupId&amp;gt;org.apache.derby&amp;lt;/groupId&amp;gt;&lt;br /&gt;           &amp;lt;artifactId&amp;gt;derby&amp;lt;/artifactId&amp;gt;&lt;br /&gt;           &amp;lt;version&amp;gt;10.3.1.4&amp;lt;/version&amp;gt;&lt;br /&gt;       &amp;lt;/dependency&amp;gt;&lt;br /&gt;&lt;br /&gt;       &amp;lt;dependency&amp;gt;&lt;br /&gt;           &amp;lt;groupId&amp;gt;org.apache.activemq&amp;lt;/groupId&amp;gt;&lt;br /&gt;           &amp;lt;artifactId&amp;gt;activemq-all&amp;lt;/artifactId&amp;gt;&lt;br /&gt;           &amp;lt;version&amp;gt;5.1.0&amp;lt;/version&amp;gt;&lt;br /&gt;       &amp;lt;/dependency&amp;gt;&lt;br /&gt;&lt;br /&gt;       &amp;lt;dependency&amp;gt;&lt;br /&gt;           &amp;lt;groupId&amp;gt;org.apache.activemq&amp;lt;/groupId&amp;gt;&lt;br /&gt;           &amp;lt;artifactId&amp;gt;activemq-web&amp;lt;/artifactId&amp;gt;&lt;br /&gt;           &amp;lt;version&amp;gt;5.1.0&amp;lt;/version&amp;gt;&lt;br /&gt;       &amp;lt;/dependency&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;a style="font-family: verdana;" href="http://activemq.apache.org/maven2-activemq-broker-plugin.html"&gt;Go here if you wish to simply run ActiveMQ using Maven&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: verdana;"&gt;3. Put this bean definition in your spring conf:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&amp;lt;bean id="broker" class="org.apache.activemq.xbean.BrokerFactoryBean"&amp;gt;&lt;br /&gt;   &amp;lt;property name="config" value="/WEB-INF/activemq.xml"/&amp;gt;&lt;br /&gt;   &amp;lt;property name="start" value="true"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: verdana;"&gt;You should be good to go. Bringing up your Spring application will start the broker at &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;tcp://localhost:61636&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/6980756524418707775-8574384038252292477?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/8574384038252292477/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=8574384038252292477' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/8574384038252292477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/8574384038252292477'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/10/running-activemq-broker-in-spring.html' title='Running ActiveMQ Broker in Spring'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-7394359162294304993</id><published>2008-10-03T06:17:00.000-07:00</published><updated>2009-04-01T05:58:15.731-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JMS'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>Understanding JMS with a Spring Perspective</title><content type='html'>Making some notes from the &lt;a href="http://java.sun.com/products/jms/tutorial/1_3_1-fcs/doc/jms_tutorialTOC.html"&gt;official &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;JMS&lt;/span&gt; tutorial&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Why Messaging? &lt;/b&gt;&lt;br /&gt;Messaging enables distributed communication that is loosely coupled. Messaging is used for communication between software applications or software components.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What is NOT Messaging?&lt;/b&gt;&lt;br /&gt;Messaging is different from &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;RMI&lt;/span&gt;, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;RPC&lt;/span&gt; or email&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What is &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;JMS&lt;/span&gt;?&lt;/b&gt;&lt;br /&gt;The Java Message Service is a Java &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;API&lt;/span&gt; to help you with your messaging needs&lt;br /&gt;&lt;br /&gt;&lt;b&gt;When to use &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;JMS&lt;/span&gt;/ Messaging?&lt;/b&gt;&lt;br /&gt;Use &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;JMS&lt;/span&gt; if&lt;br /&gt;&lt;ul&gt;&lt;li&gt;you do not want to depend on any information about other components’ interfaces( so they are easily replaceable)&lt;/li&gt;&lt;li&gt;you want your app to run whether or not all components are up and running simultaneously&lt;/li&gt;&lt;li&gt;you want an app design that allows a component to send information to another and to continue to operate without receiving an immediate response&lt;/li&gt;&lt;li&gt;you want a guaranteed delivery, not necessarily immediately&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;b&gt;What is the support for &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;JMS&lt;/span&gt; in J2&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;EE&lt;/span&gt;?&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Message driven beans support &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;JMS&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;JMS&lt;/span&gt; messages can participate in distributed transactions&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;b&gt;Where can I get an open-source implementation for &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;JMS&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;API&lt;/span&gt;?&lt;/b&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;ActiveMQ&lt;/span&gt; from Apache is a great open source implementation. You can see others at&lt;a href="http://java-source.net/open-source/jms"&gt; java-source.net&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What is a Messaging Domain?&lt;/b&gt;&lt;br /&gt;Messaging domain denotes the style of messaging. There are basically two types of messaging domains: Point-to-Point(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;PTP&lt;/span&gt;) and Publish/Subscribe(pub/sub)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How is &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;PTP&lt;/span&gt; different for pub/sub?&lt;/b&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;PTP&lt;/span&gt; style of messaging has following features:&lt;br /&gt;• Each message has only one consumer.&lt;br /&gt;• A sender and a receiver of a message have no timing dependencies. The receiver can fetch the message whether or not it was running when the client sent the message.&lt;br /&gt;• The receiver acknowledges the successful processing of a message.&lt;br /&gt;&lt;br /&gt;Use &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;PTP&lt;/span&gt; messaging when every message you send must be processed successfully&lt;br /&gt;by one consumer.&lt;br /&gt;&lt;br /&gt;pub/sub is characterized by:&lt;br /&gt;• Each message may have multiple consumers&lt;br /&gt;• Publishers and subscribers have a timing dependency. A client that subscribes to a topic can consume only messages published after the client has created a subscription, and the subscriber must continue to be active in order for it to consume messages.&lt;br /&gt;&lt;br /&gt;Use pub/sub messaging when each message can be processed by zero, one, or many consumers.&lt;br /&gt;&lt;b&gt;&lt;br /&gt;What does &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;JMS&lt;/span&gt; support out of these two?&lt;/b&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;JMS&lt;/span&gt; supports both. In fact it even provides something called durable subscriptions which allow you to combine flexibility and reliability of queues of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;PTP&lt;/span&gt; with the ability to allow clients to send messages to many recipients of pub/sub&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Using &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;JMS&lt;/span&gt; will the messages be consumed asynchronously or synchronously?&lt;/b&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;JMS&lt;/span&gt; supports both. However the biggest advantages of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;JMS&lt;/span&gt; arise out of asynchronous communication&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What are the main parts of a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;JMS&lt;/span&gt; application?&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;Administred&lt;/span&gt; Objects (connection factories, destinations)&lt;/li&gt;&lt;li&gt;Connections&lt;/li&gt;&lt;li&gt;Sessions&lt;/li&gt;&lt;li&gt;Message producers&lt;/li&gt;&lt;li&gt;Message consumers&lt;/li&gt;&lt;li&gt;Messages&lt;/li&gt;&lt;/ul&gt; A connection factory is used to create a connection. A connection is used to create a session. A session can create a producer, consumer or a message. Producer send messages to a destination while consumers receive messages from the destination.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Does Spring support &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;JMS&lt;/span&gt;?&lt;/b&gt;&lt;br /&gt;Absolutely. You can read it &lt;a href="http://static.springframework.org/spring/docs/2.0.x/reference/jms.html"&gt;here&lt;/a&gt;. If you are using ActiveMQ, you may want to see &lt;a href="http://activemq.apache.org/spring-support.html"&gt;this&lt;/a&gt; too.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Why should I use spring to manage interactions with &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_27"&gt;JMS&lt;/span&gt;?&lt;/b&gt;&lt;br /&gt;For pretty much the same reason you would use spring to manage your database, cache etc. etc. : it makes your life easier. Seriously. Helps you cut down the "&lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_28"&gt;boiler&lt;/span&gt;-plate" code and gives you more specific exceptions besides the regular dependency injection benefits.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-7394359162294304993?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/7394359162294304993/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=7394359162294304993' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/7394359162294304993'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/7394359162294304993'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/10/using-jms.html' title='Understanding JMS with a Spring Perspective'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-7813629238826019539</id><published>2008-10-01T01:55:00.000-07:00</published><updated>2008-10-01T02:15:19.623-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Quartz'/><category scheme='http://www.blogger.com/atom/ns#' term='Maven'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>Setting up Quartz in a Spring-MySQL Environment</title><content type='html'>&lt;div  style="font-family:verdana;"&gt;&lt;span style="font-size:100%;"&gt;If you are using a persistent &lt;span style="font-family:courier new;"&gt;JobStore &lt;/span&gt;in Quartz, you will have to back your spring application with a DB. MySQL can be pretty convenient for local unit testing. Besides the regular spring DataSource config, you need a few more things here and there. I did not find any comprehensive  "todo" checklist for MySQL online. So summing up what worked for me.&lt;/span&gt;&lt;/div&gt;&lt;div  style="font-family:verdana;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div  style="font-family:verdana;"&gt;&lt;span style="font-size:100%;"&gt;Using &lt;span style="font-family:courier new;"&gt;SchedularFactoryBean &lt;/span&gt;you can specify a MySQL &lt;span style="font-family:courier new;"&gt;DataSource &lt;/span&gt;and fine-tune it using quartz properties. You can see this in a config file I had published &lt;span&gt;earlier&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_28g2289ddd"&gt;XML Config&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Besides this, you need to have the following dependencies for sure in your pom if you are using Maven:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_33hfqsjxgp"&gt;POM dependencies&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you are not using maven, the corresponding jars should be in the classpath.&lt;br /&gt;&lt;br /&gt;Finally, don't forget to run the SQL script to create tables in your database provided by quartz:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.opensymphony.com/quartz/wikidocs/TutorialLesson9.html"&gt;Creating DB Tables for Quartz&lt;/a&gt;&lt;br /&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/6980756524418707775-7813629238826019539?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/7813629238826019539/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=7813629238826019539' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/7813629238826019539'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/7813629238826019539'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/10/setting-up-quartz-in-spring-mysql.html' title='Setting up Quartz in a Spring-MySQL Environment'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-2509335993356800604</id><published>2008-09-24T05:09:00.000-07:00</published><updated>2008-09-24T07:28:04.809-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Quartz'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>The Mysterious Ways of SchedulerFactoryBean</title><content type='html'>&lt;span class="Apple-style-span"   style="font-family:Verdana;font-size:13;"&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;Using Spring framework and Quartz, I wanted to make some dynamic Jobs and triggers. After banging my head and some accidents I finally understood how to use it. The API docs say:&lt;/div&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;"For dynamic registration of jobs at runtime, use a bean reference to this &lt;span class="Apple-style-span"  style="font-family:'Courier New';"&gt;SchedulerFactoryBean &lt;/span&gt;to get direct access to the Quartz Scheduler (&lt;code&gt;&lt;span class="Apple-style-span"  style="font-family:'Courier New';"&gt;org.quartz.Schedule&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt;r&lt;/span&gt;&lt;/code&gt;). This allows you to create new jobs and triggers, and also to control and monitor the entire Scheduler." &lt;/div&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;What the hell that means, I couldn't figure. Hunting for some examples on the web didn't help either. In one of my posts I have given a link to fine tune &lt;span class="Apple-style-span"  style="font-family:'Courier New';"&gt;SchedulerFactoryBean &lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt;for static jobs. Picking from there, let us assume you have a Stocks Alert Manager to which you wish to give a spring managed scheduler using your very own &lt;span class="Apple-style-span"   style="font-family:'Courier New';font-size:16;"&gt;&lt;span class="Apple-style-span"  style="font-size:13;"&gt;SchedulerFactoryBean &lt;/span&gt;&lt;span class="Apple-style-span"   style="font-family:Verdana;font-size:13;"&gt;. Let us assume your &lt;span class="Apple-style-span"  style="font-family:'Courier New';"&gt;stockAlertsManager&lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt; looks like this:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_27cnfz4rgp"&gt;A Sample StocksAlertManager&lt;/a&gt;&lt;/div&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;&lt;span class="Apple-style-span"  style="font-family:'Courier New';"&gt;&lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt;&lt;span class="Apple-style-span"   style="font-family:'Courier New';font-size:16;"&gt;&lt;span class="Apple-style-span"   style="font-family:Verdana;font-size:13;"&gt;Then your bean config should look something like this:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_28g2289ddd"&gt;Bean Config to use SchedulerFactoryBean dynamically&lt;/a&gt;&lt;/div&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;&lt;br /&gt;If you have not noticed, the scheduler property of &lt;span class="Apple-style-span"  style="font-family:'Courier New';"&gt;StockAlertsManager&lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt; is of type &lt;span class="Apple-style-span"  style="font-family:'Courier New';"&gt;org.quartz.impl.StdScheduler&lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt; but in the bean config I have set it to the reference of our all-powerful &lt;span class="Apple-style-span"  style="font-family:'Courier New';"&gt;SchedulerFactoryBean&lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt;. Despite of the mismatch in types your spring application will not complain and initialize the scheduler property nicely. Even when &lt;span class="Apple-style-span"  style="font-family:'Courier New';"&gt;SchedulerFactoryBean &lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt;does not in any way extend &lt;span class="Apple-style-span"  style="font-family:'Courier New';"&gt;StdScheduler&lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt; or implement &lt;span class="Apple-style-span"  style="font-family:'Courier New';"&gt;Scheduler&lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt; . Wierd, counter-intuitive but works. Re-visiting the API doc:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;"For dynamic registration of jobs at runtime, use a bean reference to this &lt;span class="Apple-style-span"  style="font-family:'Courier New';"&gt;SchedulerFactoryBean &lt;/span&gt;to get direct access to the Quartz Scheduler (&lt;code&gt;&lt;span class="Apple-style-span"  style="font-family:'Courier New';"&gt;org.quartz.Schedule&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt;r&lt;/span&gt;&lt;/code&gt;). This allows you to create new jobs and triggers, and also to control and monitor the entire Scheduler." &lt;/div&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;Well, they literally meant it! Who would have thought?!&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-2509335993356800604?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/2509335993356800604/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=2509335993356800604' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/2509335993356800604'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/2509335993356800604'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/09/mysterious-ways-of-schedulerfactorybean.html' title='The Mysterious Ways of SchedulerFactoryBean'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-1388019356990701714</id><published>2008-09-23T08:10:00.000-07:00</published><updated>2008-09-23T08:17:25.228-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='RMI'/><category scheme='http://www.blogger.com/atom/ns#' term='Maven'/><category scheme='http://www.blogger.com/atom/ns#' term='JMock'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><category scheme='http://www.blogger.com/atom/ns#' term='JUnit'/><title type='text'>Using Autowiring for Testing RMI Services in Spring</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:verdana;"&gt;Scehduling can be a common requirement in many applications. However testing such an application that used RMI with JUnit and JMock in a Spring-Maven environment turned out to be a little tricky for me. Thanks to the help of a colleague (thanks Mudassir!) and some head banging, I was able to find a way: Autowiring.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Generally my basic JUnit test cases have the following features:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;1. The whole class annotated by @RunWith(JMock.class) - org.junit.runner.RunWith;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;2. A set up method (the init method) annotated with @Before - org.junit.Before&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;3. The test cases annotated @Test - org.junit.Test&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;4. JUnit4Mockery used to mock relevant interfaces - org.jmock.integration.junit4.JUnit4Mockery&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;5. The usual expectatons and assertions &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;6. Spring adds punch with ability to mock request, response, sessions - org.springframework.mock.web.*&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_23tvcp8rhp"&gt;&lt;span style="font-family:verdana;"&gt; A Simple Test Case&lt;/span&gt;&lt;/a&gt;&lt;a style="font-family: verdana;" id="publishedDocumentUrl" class="tabcontent" target="_blank" href="http://docs.google.com/Doc?id=ddhf5h22_23tvcp8rhp"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Works fine for most things. Now picture this: you are developing application that needs to check stock prices every five minutes and send alerts to registered users if need be. Lets say there are three modules being developed for it: the user interface using which a user may register for an alert for stock price, the scheduler that keeps track of these alerts and the workflow engine that takes care of the alerts once fired. A classic MVC approach so far. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;The controller accepts alerts from user interface and schedules Jobs that forward all information to the workflow. Let us assume these three modules are being developed by three different teams sitting in three corners of the world (ok, may be three corners of the office or just three different/independent machines/servers).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Now, when you are making the controller, you are essentially dependent on view for input and on the model for feedback (if any) for your input. We can provide access to our controller using any RMI strategy. For our example, we consider Spring's HttpInvoker. We intend to write a a test case to test the controller module.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; Our controller has a remote service running in a spring environment. If it had been a simple servlet listening to ordinary post/get requests, writing a test case with MockHttpRequest would be a piece of cake. However when it is an RMI service, what mock up to use? An answer can be a test class looking something like this:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?id=ddhf5h22_24g4q9xhg9"&gt;A Test Case For RMI Service&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;The answer lies in using SpringJUnit4ClassRunner and then auto-wiring the HttpInvokerService. ContextConfiguration points to the locations for the config xml. In the current case you should put it in "myPackage. If you are using Maven, the resources folder would be the right place to put it. The config file may look like:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="font-family: verdana;" href="http://docs.google.com/Doc?id=ddhf5h22_25p88q83c4"&gt;Autowiring Config&lt;/a&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; If you are using Maven, don't forget to add the following dependencies:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="font-family: verdana;" href="http://docs.google.com/Doc?id=ddhf5h22_26grzpbdd4"&gt;Maven Dependencies&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;A few tweaks may be needed to suit your case but this should give you a general idea about using autowiring for your test cases in JUnit, JMock, Spring, Maven environment.&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/6980756524418707775-1388019356990701714?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/1388019356990701714/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=1388019356990701714' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/1388019356990701714'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/1388019356990701714'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/09/using-autowiring-for-testing-rmi.html' title='Using Autowiring for Testing RMI Services in Spring'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-15823327015890185</id><published>2008-09-12T03:50:00.000-07:00</published><updated>2008-09-25T03:27:11.386-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Maven'/><title type='text'>Maven Blues</title><content type='html'>Was facing a strange problem where Maven (version 2) would say something like "&lt;em&gt;&lt;/em&gt;&lt;em&gt;generics are not supported in -source 1.3&lt;/em&gt;" for Java 5 features. Adding the following the Plugins element in the pom helped:&lt;br /&gt;&lt;pre&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;plugins&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;plugin&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;artifactId&amp;gt;maven-compiler-plugin&amp;lt;/artifactId&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;version&amp;gt;2.0.2&amp;lt;/version&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;source&amp;gt;1.5&amp;lt;/source&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;target&amp;gt;1.5&amp;lt;/target&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;/plugin&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;plugins&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-15823327015890185?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/15823327015890185/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=15823327015890185' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/15823327015890185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/15823327015890185'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/09/maven-blues.html' title='Maven Blues'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-6031551351617918442</id><published>2008-09-03T09:00:00.001-07:00</published><updated>2008-09-12T02:56:45.026-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Quartz'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>Quartz and Spring</title><content type='html'>For scheduling purposes one can use Quartz with Spring. The basic usage can be learnt by going through the &lt;a href="http://www.opensymphony.com/quartz/wikidocs/Tutorial.html"&gt;quartz tutorial&lt;/a&gt; and &lt;a href="http://static.springframework.org/spring/docs/1.2.x/reference/scheduling.html"&gt;spring documentation on scheduling&lt;/a&gt; .&lt;br /&gt;&lt;br /&gt;However when it came to using advanced usage like configuring job stores, I had a little difficulty finding stuff. &lt;a href="http://forum.springframework.org/archive/index.php/t-10000.html"&gt;A particular entry in the spring forum&lt;/a&gt; was really useful. These three resources were able to take care of my reasonably complex needs for scheduling. Hope they are of some use to you too.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-6031551351617918442?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/6031551351617918442/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=6031551351617918442' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/6031551351617918442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/6031551351617918442'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/09/quartz-and-spring.html' title='Quartz and Spring'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-8768203201881207230</id><published>2008-08-28T06:12:00.000-07:00</published><updated>2008-08-28T06:16:12.728-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Maven'/><title type='text'>Splitting a Project into Modules in Maven</title><content type='html'>&lt;span style="font-family: verdana;"&gt;The beauty of Maven and Idea is the ease with which they allow you to manage, build and test your applications. Let us suppose we have a project that we wish to build in modules. For sake of simplicity we assume that the project has two basic modules: a webapp module and a core module.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;Make a folder on the system for your project. In the folder make two folders by name "core" and "webapp". Also put a pom.xml which should look like:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="font-family: verdana;" href="http://docs.google.com/Doc?id=ddhf5h22_193sbgpmdn"&gt;parent pom&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;Notable things are the modules node and that the packaging is pom.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;In the "core" folder make a folder "src" and put a pom.xml something like:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="font-family: verdana;" href="http://docs.google.com/Doc?id=ddhf5h22_20ch8qc7fp"&gt;core pom&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;Main things to note about the pom is that packaging is "jar". ID are same as those in the parent pom. In "src" folder make two folders "main" and "test". Put a folder named "java" in each of them.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;In the "webapp" folder create same directory structure as "core". The pom.xml here would look like:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="font-family: verdana;" href="http://docs.google.com/Doc?id=ddhf5h22_21gxm8zsdc"&gt;webapp pom&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;Make the directory structure webapp -&gt; src -&gt; main -&gt; webapp -&gt; WEB-INF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;in WEB-INF put in a web.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;xml&lt;/span&gt; file&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;You are good to go now. Now all you need to do is &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;mvn&lt;/span&gt; idea:idea or &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;mvn&lt;/span&gt; eclipse:eclipse (depending on what you are using) while being in the main folder to create the project with its modules.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-8768203201881207230?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/8768203201881207230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=8768203201881207230' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/8768203201881207230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/8768203201881207230'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/08/splitting-project-into-modules-in-maven.html' title='Splitting a Project into Modules in Maven'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-5986213850275427425</id><published>2008-08-06T09:02:00.000-07:00</published><updated>2008-08-06T09:15:34.143-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spring Validation'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring MVC'/><title type='text'>Alternative to Using Valang Custom Functions</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;Valang provides a rich set of validation tools and is pretty simple. However in some cases you want more. The most obvious case that we encounter is validating if a date is in future or past wrt the current time on server. I know we can parse and input date to a date object readily using initBinder function of a SimpleFormController. But to compare it with the current date using pure varlang is something I could not find.&lt;br /&gt;&lt;br /&gt;Luckily valang has an ability to use custom function. However I found it cumbersome to make one separate class for each function I may need. It would make more sense to allow users to group functions in one class to build a custom library of functions. Not to mention I could not find a proper working example of a custom function. So till I get my hands on one and this implementation improves, I have a simple work around.&lt;br /&gt;&lt;br /&gt;Step 1: Define valang validations in the config file&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;bean id="webMessageFormValidator" &lt;br /&gt;class="myPackage.validators.FormBeanValidator"&amp;gt;&lt;br /&gt;   &amp;lt;property name="valang"&amp;gt;&lt;br /&gt;     &amp;lt;value&amp;gt;&lt;br /&gt;     &amp;lt;![CDATA[&lt;br /&gt;       {to:? IS NOT BLANK:'Please enter email addresses &lt;br /&gt;          for recepients.'}&lt;br /&gt;       {subject:? IS NOT BLANK:'Mail can not be blank.'}          &lt;br /&gt;       {from:(length(?)&amp;gt; 0):'Please specify at least one &lt;br /&gt;            address.'}&lt;br /&gt;     ]]&amp;gt;&lt;br /&gt;     &amp;lt;/value&amp;gt;&lt;br /&gt;   &amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;Step 2: Define the validator as follows&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;&lt;br /&gt;package mypackage.validators;&lt;br /&gt;&lt;br /&gt;import org.springframework.validation.Errors;&lt;br /&gt;import org.springmodules.validation.valang.ValangValidator;&lt;br /&gt;import mypackage.FormBean;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class FormBeanValidator extends ValangValidator {&lt;br /&gt;&lt;br /&gt;    public void validate(Object object, Errors errors) {&lt;br /&gt;&lt;br /&gt;        FormBean form = (FormBean) object;&lt;br /&gt;&lt;br /&gt;        //perform all validations and raise error flag&lt;br /&gt;        //if you find an error&lt;br /&gt;        if(isFutureTime(form.myDate()){&lt;br /&gt;            errors.rejectValue("myDate", "error.futureDate"&lt;br /&gt;            ,"Time cannot be in the future.");&lt;br /&gt;        }&lt;br /&gt;       &lt;br /&gt;        //dont forget call to super so as the validations &lt;br /&gt;        //defined in XML take place&lt;br /&gt;        super.validate(object, errors);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    private boolean isFutureTime(Date formDate, &lt;br /&gt;                          int hours, int minutes){&lt;br /&gt;        //check if time is in future&lt;br /&gt;        return false;&lt;br /&gt;  }&lt;br /&gt;  &lt;/pre&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-5986213850275427425?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/5986213850275427425/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=5986213850275427425' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/5986213850275427425'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/5986213850275427425'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/08/alternative-to-using-valang-custom.html' title='Alternative to Using Valang Custom Functions'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-8320341107426449909</id><published>2008-07-22T07:22:00.000-07:00</published><updated>2008-07-22T08:41:04.290-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spring MVC'/><title type='text'>Problem Statement and Source Files</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;Theory without examples can be hard to grasp and less useful. So just making a small problem and corresponding files. Lets see&lt;br /&gt;Problem statement: Given an online reporting application. There is a form that posts certain parameters and displays reports accordingly. Let us say that  there are two basic  parameters:  report type and date range. Report type may be word, pdf, text. Date range consists of a from and a to time. Further user has an option to specify current time as the to time. Our form bean would look something like this:&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;package myPackage;&lt;br /&gt;&lt;br /&gt;public class MyFormBean{&lt;br /&gt; private String reportType;&lt;br /&gt; //date in format dd/MM/yyyy HH:mm&lt;br /&gt; privateDate fromDate;&lt;br /&gt; private Date toDate;&lt;br /&gt; private boolean useCurrentTime=true;&lt;br /&gt;&lt;br /&gt; //.......&lt;br /&gt; //public getters and setters for fields&lt;br /&gt; //.......&lt;br /&gt;}   &lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Reports are denoted by a simple interface:&lt;/span&gt;&lt;span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;     &lt;pre&gt;package myPackage;&lt;br /&gt;&lt;br /&gt;public interface Report{&lt;br /&gt; String getFileUrl();&lt;br /&gt; String getType();&lt;br /&gt; Date getCreationTime();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;Reports are fetched using this interface:&lt;/span&gt; &lt;span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;package myPackage;&lt;br /&gt;&lt;br /&gt;public interface DataBaseUtil{&lt;br /&gt;  List&amp;lt;Report&amp;gt; getReports(MyFormBean myFormBean);&lt;br /&gt;}        &lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;which may have some implementation like:&lt;/span&gt;&lt;span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;package myPackage;&lt;br /&gt;&lt;br /&gt;public class DataBaseUtilImpl{&lt;br /&gt;  private static DataBaseUtilImpl singleInst = new DataBaseUtilImpl();&lt;br /&gt;  private DataBaseUtilImpl(){}&lt;br /&gt;&lt;br /&gt;  public static DataBaseUtilImpl getInstance(){ return singleInst ; }&lt;br /&gt;&lt;br /&gt;  public List&amp;lt;Report&amp;gt; getReports(MyFormBean myFormBean){&lt;br /&gt;            //process command object to get a list of reports&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;         &lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;The controller will be injected something like this in the config file:&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;br /&gt; &lt;span style="font-family:courier new;"&gt;&lt;br /&gt;     &lt;pre&gt; &amp;lt;bean id="reportFormController" class="myPackage.ReportFormController"&amp;gt;&lt;br /&gt;     &amp;lt;property name "dataBaseUtil" ref="DataBaseUtilBean"/&amp;gt;&lt;br /&gt;     &amp;lt;property name="formView" value="reportInput"/&amp;gt;&lt;br /&gt;     &amp;lt;property name="bindOnNewForm" value="true"/&amp;gt;&lt;br /&gt;     &amp;lt;property name="successView" value="reportOutput"/&amp;gt;&lt;br /&gt;     &amp;lt;property name="validator" ref="myValidator"/&amp;gt;&lt;br /&gt;     &amp;lt;property name="commandName" value="reportFormBean"/&amp;gt;&lt;br /&gt;     &amp;lt;property name="commandClass" value="myPackage.MyFormBean"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;     &lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;The actual form controller will look something like:&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;package myPackage;&lt;br /&gt;&lt;br /&gt;import org.springframework.web.servlet.mvc.SimpleFormController;&lt;br /&gt;import org.springframework.web.servlet.ModelAndView;&lt;br /&gt;import org.springframework.web.bind.ServletRequestDataBinder;&lt;br /&gt;import org.springframework.beans.propertyeditors.CustomDateEditor;&lt;br /&gt;import javax.servlet.http.HttpServletRequest;&lt;br /&gt;import javax.servlet.http.HttpServletResponse;&lt;br /&gt;import java.util.*;&lt;br /&gt;import java.text.*;&lt;br /&gt;&lt;br /&gt;public class ReportFormController extends SimpleFormController {&lt;br /&gt; private DataBaseUtil dataBaseUtil;&lt;br /&gt;&lt;br /&gt; public void setDataBaseUtil(DataBaseUtil dbUtil){&lt;br /&gt;     this.dataBaseUtil = dbUtil;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public DataBaseUtil getDataBaseUtil(){&lt;br /&gt;     return this.dataBaseUtil;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; /*Override so as string inputs in the form bind directly to date in command object*/&lt;br /&gt;  @Override&lt;br /&gt; protected void initBinder(HttpServletRequest request, ServletRequestDataBinder dataBinder) throws Exception{&lt;br /&gt;     DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm");&lt;br /&gt;     df.setLenient(false);&lt;br /&gt;     dataBinder.registerCustomEditor(Date.class,new CustomDateEditor(df,false));&lt;br /&gt;     super.initBinder(request,dataBinder);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; @Override&lt;br /&gt; protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response,Object command, BindException bindException)throws Exception{&lt;br /&gt;     //handle submit request&lt;br /&gt;     ReportFormBean repFormBean = (ReportFormBean ) command;&lt;br /&gt;&lt;br /&gt;     List&amp;lt;Report&amp;gt; reps ;&lt;br /&gt;&lt;br /&gt;     if(dataBaseUtil != null)&lt;br /&gt;         reps = dataBaseUtil.getReports(repFormBean);&lt;br /&gt;     else&lt;br /&gt;         reps = new ArrayList&amp;lt;Report&amp;gt;();&lt;br /&gt;&lt;br /&gt;     ModelAndView mv = showForm(request, response, bindException);&lt;br /&gt;&lt;br /&gt;     mvmodel.put("REPORTS", reps);&lt;br /&gt;&lt;br /&gt;     return mv;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;         &lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;From next post we will start exploring some practical problems using these files as our base.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-8320341107426449909?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/8320341107426449909/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=8320341107426449909' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/8320341107426449909'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/8320341107426449909'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/07/problem-statement-and-source-files.html' title='Problem Statement and Source Files'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-5436170932751121825</id><published>2008-07-14T02:34:00.000-07:00</published><updated>2008-07-14T02:39:41.545-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JMock'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='JUnit'/><title type='text'>Testing a SimpleFormController</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:verdana;"&gt;Testing a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;SimpleFormController&lt;/span&gt; using &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;JUnit&lt;/span&gt; and &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;JMock&lt;/span&gt; was a small challenge I came across. After hitting a number of hurdles I managed to write tests that were meaningful and worked. Following points noted for people on similar quest :):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ol  id="r.:y1" style="font-family:verdana;"&gt;&lt;li id="r.:y2"&gt;&lt;span style="font-size:100%;"&gt;Keep handy &lt;a href="http://www.jmock.org/cheat-sheet.html"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;JMock&lt;/span&gt; Cheat Sheet&lt;/a&gt; , especially the Methods and Expectations part&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li id="p9700"&gt;&lt;span style="font-size:100%;"&gt;Use &lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;MockHttpServletResponse&lt;/span&gt;&lt;/span&gt;,  &lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;MockHttpServletRequest&lt;/span&gt;&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;MockHttpSession&lt;/span&gt;&lt;/span&gt; in the package &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new;"&gt;org.springframework.mock.web &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;to mock web response, request and session respectively.&lt;/span&gt;&lt;/li&gt;&lt;li id="k729"&gt;&lt;span style="font-size:100%;"&gt;Remember you can construct post requests and get requests with your &lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;MockHttpServletRequest&lt;/span&gt;&lt;/span&gt; using: &lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;MockHttpServletRequest&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;mockRequest&lt;/span&gt; = new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;MockHttpServletRequest&lt;/span&gt;("POST","&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;myUrl&lt;/span&gt;");&lt;/span&gt;  and &lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;MockHttpServletRequest&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;mockRequest&lt;/span&gt; = new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;MockHttpServletRequest&lt;/span&gt;("GET","&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;myUrl&lt;/span&gt;");&lt;/span&gt; &lt;/span&gt;&lt;/li&gt;&lt;li id="nta."&gt;&lt;span style="font-size:100%;"&gt;Finally use &lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;ModelAndView&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;modelAndView&lt;/span&gt; = &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;myController&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;handleRequest&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;mockRequest&lt;/span&gt;, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;mockResponse&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;   &lt;/li&gt;&lt;li id="kcp90"&gt;&lt;span style="font-size:100%;"&gt;Use &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;JUnit&lt;/span&gt; asserts to verify &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;ModelAndView&lt;/span&gt; as per your expectations&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; Generally your controller will follow this path: receive request-process-return &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;ModelAndView&lt;/span&gt; to render. Processing may involve using the command object and passing values to the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;backend&lt;/span&gt; for processing. In your controller tests do NOT attempt to check &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;backend&lt;/span&gt;- just mock it. Focus on checking the controller. A combination of expectations and asserts is your best bet to do the testing thoroughly. Let us explore a small example based on these principles in our next post.&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/6980756524418707775-5436170932751121825?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/5436170932751121825/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=5436170932751121825' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/5436170932751121825'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/5436170932751121825'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/07/testing-simpleformcontroller.html' title='Testing a SimpleFormController'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-6261913628236324632</id><published>2008-07-03T06:13:00.000-07:00</published><updated>2008-07-03T06:14:25.713-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spring MVC'/><title type='text'>Conditional Form Binding</title><content type='html'>Form binding is a useful feature in Spring. However I needed to turn on or off form binding depending on certain conditions. Golden question, how to do it...&lt;br /&gt;&lt;br /&gt;1. In the controller constructor (or in XML config for DI) call &lt;span style="font-family: Courier New;"&gt;setBindOnNewForm(true);&lt;/span&gt;&lt;br /&gt;2. Do NOT call/set &lt;span style="font-family: Courier New;"&gt;setSessionForm(true);&lt;/span&gt;&lt;br /&gt;3. Override suppressBinding and return true or false according to your condition. true will suppress form binding.&lt;br /&gt;&lt;br /&gt;&lt;span id="y8gk" style="font-family: Courier New;"&gt;@Override&lt;/span&gt;&lt;br /&gt;&lt;span id="y8gk0" style="font-family: Courier New;"&gt;protected boolean suppressBinding(HttpServletRequest request){&lt;/span&gt;&lt;br /&gt;&lt;span id="y8gk1" style="font-family: Courier New;"&gt;    boolean myCondition = false;&lt;/span&gt;&lt;br /&gt;&lt;span id="y8gk3" style="font-family: Courier New;"&gt;    //some checks on myCondition depending on request params&lt;/span&gt;&lt;br /&gt;&lt;span id="y8gk5" style="font-family: Courier New;"&gt;    return myCondition ;&lt;/span&gt;&lt;br /&gt;&lt;span id="y8gk6" style="font-family: Courier New;"&gt;}&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-6261913628236324632?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/6261913628236324632/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=6261913628236324632' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/6261913628236324632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/6261913628236324632'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/07/conditional-form-binding.html' title='Conditional Form Binding'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-5078200035494521640</id><published>2008-07-01T07:33:00.000-07:00</published><updated>2008-07-01T07:35:24.337-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spring MVC'/><title type='text'>Date Binding on SimpleFormController using initBinder</title><content type='html'>If you wish to bind an input date field in your web form directly to a Date property in your command object, you will need to override the initBinder method of the SimpleFormController. Following maps a date in dd/MM/yyyy format on the front-end to backend and vice-versa. &lt;br /&gt; &lt;br /&gt; &lt;span id="k1b51" style="font-family: Courier New;"&gt;@Override&lt;/span&gt;&lt;br /&gt; &lt;span id="k1b53" style="font-family: Courier New;"&gt;protected void initBinder(HttpServletRequest request, ServletRequestDataBinder dataBinder) throws Exception{&lt;/span&gt;&lt;br /&gt; &lt;span id="k1b55" style="font-family: Courier New;"&gt;        DateFormat df = new SimpleDateFormat("dd/MM/yyyy");&lt;/span&gt;&lt;br /&gt; &lt;span id="k1b57" style="font-family: Courier New;"&gt;        df.setLenient(false);&lt;/span&gt;&lt;br /&gt; &lt;span id="k1b59" style="font-family: Courier New;"&gt;        dataBinder.registerCustomEditor(Date.class,new CustomDateEditor(df,false));&lt;/span&gt;&lt;br /&gt; &lt;span id="k1b511" style="font-family: Courier New;"&gt;        super.initBinder(request,dataBinder);&lt;/span&gt;&lt;br /&gt; &lt;span id="k1b513" style="font-family: Courier New;"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; Your valang validators can help you put some crisp checks on date if need be. Remember dd/mm/yyyy and dd/MM/yyyy are NOT same.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-5078200035494521640?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/5078200035494521640/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=5078200035494521640' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/5078200035494521640'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/5078200035494521640'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/07/date-binding-on-simpleformcontroller.html' title='Date Binding on SimpleFormController using initBinder'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-6024957585118699235</id><published>2008-06-26T07:46:00.000-07:00</published><updated>2008-06-26T07:48:01.284-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spring MVC'/><title type='text'>SimpleFormController and Validation</title><content type='html'>While making your spring application you may come across the need to use a SimpleFormController. If so, there may be questions and confusions. The spring javadoc has some good documentation. Try this cheat sheet too if you are short on time or wish to revise your SimpleFormController knowledge:&lt;br /&gt;  &lt;br /&gt;&lt;a href="http://longgoldenears.blogspot.com/2007/07/simpleformcontroller-workflow-lifecycle.html"&gt;SimpleFormController Cheat Sheet&lt;/a&gt;&lt;br /&gt; &lt;br /&gt; After you get the controller running, you may want to validate your form. Besides using Validator class in the spring framework you may want to explore some configurable validation options. Check springmodules validation:&lt;br /&gt; &lt;br /&gt;&lt;a href="https://springmodules.dev.java.net/docs/reference/0.5/html/validation.html"&gt;Spring Modules Validation&lt;/a&gt;&lt;br /&gt; &lt;br /&gt; This gives you pointers on using Jakarta Commons and valang. I found valang much-much better than using either commons or the spring Validator class for server side validations. For client side validation I still need to make this thing work correctly as my jsp code generates the form on fly using tags. And tags and valang client side thingy dont gel well together. Will post a solution if I find one :).&lt;br /&gt; &lt;br /&gt; And remember that expressions given for valang bean are like assertions. So the following check to make sure that a particular field should NOT be null is WRONG&lt;br /&gt; &lt;br /&gt;&lt;span style="font-family: courier new;"&gt; { myParam : myParam IS NULL : 'This param should not be null.' }&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; This, in effect says that your param SHOULD be null. So, the correct rule will be:&lt;br /&gt; &lt;br /&gt;&lt;span style="font-family: courier new;"&gt; { myParam : myParam IS NOT NULL : 'This param should not be null.' }&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; Your expressions should evaluate to true in order to avoid error. Remember that and you will be happy. Valang allows pretty complex and rigorous test conditions not possible with jakarata commons. Not easily. It is simpler, sweeter and downright good.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6980756524418707775-6024957585118699235?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/6024957585118699235/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=6024957585118699235' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/6024957585118699235'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/6024957585118699235'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/06/simpleformcontroller-and-validation.html' title='SimpleFormController and Validation'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6980756524418707775.post-8599362738118346712</id><published>2008-02-09T02:54:00.000-08:00</published><updated>2008-06-19T08:40:53.955-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>The Beginning</title><content type='html'>&lt;div&gt;There are a million people writing on Java. Why write more? Mainly to chronicle my learnings for personal and public use.&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;br /&gt;&lt;div&gt;Java is vast. And when I say Java, I include J2EE, designing applications using Java and following things related to it. So where to begin? I will be mainly writing on multi-threading, spring, hibernate, junit, jmock and design patterns. It is not really meant to be a tutorial (not yet). Just sharing my learning and chronicling the same over time.&lt;br /&gt;&lt;br /&gt;I will begin with spring.&lt;br /&gt;&lt;br /&gt;The best place to start learning is the spring website at: &lt;a href="http://www.springframework.org/documentation"&gt;http://www.springframework.org/documentation&lt;/a&gt; . I absolutely adore this light-weight, non-intrusive, well-designed framework. The reasons I will leave you to discover for converting you to a spring believer is not my intention. The framework consists of several modules which can be used independently. Again, I am not listing them but will mention as I write about them. This should not affect any article as various spring modules can be used independently.&lt;br /&gt;&lt;br /&gt;I  also refer  Spring in Action by Craig Wells with Ryan Breidenbach. Lets see where we end up!&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/6980756524418707775-8599362738118346712?l=javaandjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaandjava.blogspot.com/feeds/8599362738118346712/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6980756524418707775&amp;postID=8599362738118346712' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/8599362738118346712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6980756524418707775/posts/default/8599362738118346712'/><link rel='alternate' type='text/html' href='http://javaandjava.blogspot.com/2008/02/beginning.html' title='The Beginning'/><author><name>Saveen</name><uri>http://www.blogger.com/profile/07011802722179976668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://2.bp.blogspot.com/_I81aeOWZCnM/TJHqIETuQLI/AAAAAAAAAMI/6tP-FtAXk-A/S220/017.JPG'/></author><thr:total>0</thr:total></entry></feed>
