<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" gd:etag="W/&quot;DEYFRHc-eip7ImA9WhdbGEg.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052</id><updated>2011-10-17T05:55:15.952-07:00</updated><category term="Java training" /><category term="MVC" /><category term="Factory Design Pattern" /><category term="Software Engineering" /><category term="Kingston-Upon-Thames" /><category term="SAAJ" /><category term="risk management" /><category term="Public vs private XML schema" /><category term="AJAX" /><category term="UML editor" /><category term="new order" /><category term="SCJP" /><category term="Corba" /><category term="London" /><category term="Joomla1.6" /><category term="upgrade" /><category term="iteration" /><category term="Observer design pattern" /><category term="scrum agile" /><category term="design pattern" /><category term="Decorator design pattern" /><category term="WSDL" /><category term="eXtreme Programming" /><category term="DOM" /><category term="iphone" /><category term="SaaS" /><category term="w3schools" /><category term="function" /><category term="agile development" /><category term="treawurfl" /><category term="Command design pattern" /><category term="XSD editor" /><category term="Publisher-Subscriber pattern" /><category term="Outsourcing" /><category term="London User Group" /><category term="understanding selectors" /><category term="Tom Gilb" /><category term="Mobile development" /><category term="Css" /><category term="XSLT" /><category term="p2p" /><category term="IT-business alignment" /><category term="Java EE" /><category term="cloud computing" /><category term="JAXB tutorial" /><category term="tutorial" /><category term="migration" /><category term="XML" /><category term="development process" /><category term="Java inner class tutorial" /><category term="UDDI" /><category term="web services" /><category term="Java" /><category term="mobile joomla" /><category term="Web service" /><category term="SAX" /><category term="SOAP" /><category term="PHP" /><category term="jquery" /><category term="Netbeans" /><category term="Sun" /><category term="Joomla" /><category term="Singleton design pattern" /><category term="BI" /><category term="XML parsing" /><category term="Satyam" /><category term="Strategy Design Pattern" /><category term="W3C standards" /><category term="estimation" /><title>ITIS Consultants</title><subtitle type="html">Matters pertaining to IT</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>44</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/ItisConsultants" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="itisconsultants" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;CEQFSH8yfSp7ImA9Wx9aF0g.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-5711962554094725315</id><published>2011-03-10T02:04:00.000-08:00</published><updated>2011-03-10T02:18:39.195-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-10T02:18:39.195-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="IT-business alignment" /><category scheme="http://www.blogger.com/atom/ns#" term="BI" /><title>JUMP - Joint Up Means Payback</title><content type="html">Yesterday I attended the joint meeting of British Computer Society and Chartered Institute of Management Accountants at the premises of BCS in London. The agenda was to review what business-IT alignment and business intelligence means from the perspective of these two organisations.&lt;br /&gt;
&lt;br /&gt;
IT is a world with a bewildering array of technologies - Java, .net, c++, sql, ITIL, CMS, databases, Joomla!, XML, CSS, HTML, PHP, TCP/IP, SMTP, HTTP, Unix, Firefox, agile, SCRUM and one can go on. To harness these successfully for business has been the dream for last twenty-five years. In fact, I cannot remember a single year over the last two decades when one or other management consultancy did not emerge with a framework for successfully aligning IT with business. Historically, many organisations have moved their IT personnel into business departments or encouraged their IT people to acquire CIMA/MBA qualification to bridge the chasm between these two worlds. Yet it was sobering to discover that business perceptions remains that these two world are far apart and bridging them is still a burning issue. A framework was presented to bridge this divide by Dr James Bacon based upon system-thinking and Genuine Action Learning. The claim was that joint-up thinking leads to dramatic increase in profitability (JUMP).&lt;br /&gt;
&lt;br /&gt;
Also I remember that in the early 90s the BI systems were called Executive Information Systems (EIS). In the mid-90s I remember dubbing EIS as Everybody's Information System as the technology was becoming ubiquitous and affordable for lower tiers in the organisation. Interestingly CIMA sees this shift now and believes that analytical processing will move from the hands of accountants to become more pervasive. This redefines the role to become more focused on planning and control rather than analysis.&lt;br /&gt;
&lt;br /&gt;
The moral of the story is that we are still grappling with old problems and trying to find better solutions to them.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-5711962554094725315?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/5711962554094725315/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2011/03/jump-joint-up-means-payback.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/5711962554094725315?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/5711962554094725315?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2011/03/jump-joint-up-means-payback.html" title="JUMP - Joint Up Means Payback" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CE8NQ3k_fSp7ImA9Wx9bEEg.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-1621609620244744878</id><published>2011-02-18T10:02:00.000-08:00</published><updated>2011-02-18T10:14:52.745-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-18T10:14:52.745-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mobile joomla" /><category scheme="http://www.blogger.com/atom/ns#" term="treawurfl" /><title>Mobile Joomla and TERAWURFL database</title><content type="html">&amp;nbsp;Mobile Joomla! is a great extension for making your Joomla site ready for mobile viewing but it adds in a 40M worth of tables into Joomla database. This potentially causes difficulty in database backup and recovery. So here are the steps to put all the terawurfl tables in a separate database.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
1) Go into phpmyadmin and copy you Joomla database as terawurfl.&lt;br /&gt;
&lt;br /&gt;
2) Go into information_schema database and run the query&lt;br /&gt;
&lt;br /&gt;
select concat("drop table ",table_name,";") from tables where substr(table_name,1,4) = 'jos_' and&lt;br /&gt;
substr(table_name,1,13) != 'Jos_terawurfl';&lt;br /&gt;
&lt;br /&gt;
Note: I am assuming you are running Joomla database with prefix 'jos_', if not then change the above accordingly&lt;br /&gt;
&lt;br /&gt;
3) Copy all the drop statements into clipboard.&lt;br /&gt;
&lt;br /&gt;
4) Go into terawurl database and run SQL with statements copied from the  clipboard. At this stage you have a database with just the terawurfl  tables.&lt;br /&gt;
&lt;br /&gt;
5) Now go back to information_schema database and run the query&lt;br /&gt;
&lt;br /&gt;
select concat("drop table ",table_name,";") from tables where  substr(table_name,1,13) = 'Jos_terawurfl';&lt;br /&gt;
&lt;br /&gt;
6) Copy the drop statements to clipboard.&lt;br /&gt;
&lt;br /&gt;
7) Now go to your Joomla database and run the SQL with statements copied  from the clipboard. At this stage you have a database with just the  joomla tables.&lt;br /&gt;
&lt;br /&gt;
The above process would have taken out the terawurfl tables and put them in a separate database.&lt;br /&gt;
&lt;br /&gt;
Now go and set database name, user and pass in plugins/mobile/terawurfl.php, They are currently picked up from the configuration.php You probably will just have to change the line to set schema to terarwurfl as the user and password would still be valid as we follow the above procedure.&lt;br /&gt;
&lt;br /&gt;
TeraWurflConfig::DB_SCHEMA = "terawurfl";&lt;br /&gt;
&lt;br /&gt;
Now you can backup your dynamically changing Joomla database more frequently without having the overhead of copying terawurfl tables as well. Also the database recovery time for Joomla tables will be lower too.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-1621609620244744878?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/1621609620244744878/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2011/02/mobile-joomla-and-terawurfl-database.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/1621609620244744878?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/1621609620244744878?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2011/02/mobile-joomla-and-terawurfl-database.html" title="Mobile Joomla and TERAWURFL database" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEcARH47fSp7ImA9Wx9UGUk.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-3043265945563099592</id><published>2011-02-17T03:27:00.000-08:00</published><updated>2011-02-17T03:27:25.005-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-17T03:27:25.005-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Mobile development" /><category scheme="http://www.blogger.com/atom/ns#" term="Joomla" /><category scheme="http://www.blogger.com/atom/ns#" term="iphone" /><title>Mobile Development and Joomla</title><content type="html">Here is to get you going with getting your Joomla site ready for iPhone on your local PC. We start with the assumption that WAMP has already been installed, along with Joomla.&lt;br /&gt;
&lt;br /&gt;
First download the Mobile Joomla extension from &lt;a href="http://www.mobilejoomla.com/"&gt;here&lt;/a&gt;. You have to register but it is free. The extension provides the support for carrying out mobile development.&amp;nbsp; It is a rather big component which adds a number of templates, plugins and module positions. So once you kick-off the install it could take 30-50s to install. Just disable the 'Mobile - Always' plugin as you don't want to your site to be permanently served via mobile. It may be alright in development environment to leave this plugin enabled but in production environment you have to disable it as you are serving different types of clients.&lt;br /&gt;
&lt;br /&gt;
In mobile development you always have two choices. Either you can have a different URL in a subdomain for iPhone (multi-site option) or you can use the same URL and let the mobile plugin decide which template to serve (multi-client option). We will opt for the latter but if you want the multi-site option then you will have to set it up in the Joomla Mobile settings. We can adjust the modules for iPhone or just serve the default before tinkering.&lt;br /&gt;
&lt;br /&gt;
Now establish the ip address of your local PC by running ipconfig. It will be something like 192.168.1.2.&lt;br /&gt;
. &lt;br /&gt;
Go to iphonetester.com. If you were typing localhost/joomla to get into your local website then you will have to type http://192.168.1.2/joomla in the tester URL. Now you have full simulation of your site as viewed by iPhone. You can start playing with module positions and experimenting. Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-3043265945563099592?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/3043265945563099592/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2011/02/mobile-development-and-joomla.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/3043265945563099592?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/3043265945563099592?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2011/02/mobile-development-and-joomla.html" title="Mobile Development and Joomla" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;DkEHRnc_eSp7ImA9Wx9UGEk.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-8039717236455263762</id><published>2011-02-16T00:23:00.000-08:00</published><updated>2011-02-16T00:23:57.941-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-16T00:23:57.941-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="London User Group" /><category scheme="http://www.blogger.com/atom/ns#" term="Joomla" /><title>Exciting meeting of London's Joomla User Group</title><content type="html">I had the pleasure of attending my first-ever Joomla User Group meeting at University College London yesterday. The minor drizzle in the evening did not dampen the enthusiasm of the attendees who were all passionate about Joomla. It turned out to a lively session of two hours where a lot of insights were parted by the members.&lt;br /&gt;
&lt;br /&gt;
We had a presentation on Joomla performance tuning which covered all the aspects from caching, compression, CSS and Javascript minification, MySql tuning and image servers. A suggestion that serving images from a different server speeds up the page download as the HTTP traffic becomes parallelized was particularly good. Also the warning that many image-bloated templates and sub-optimal extensions are the main culprit in reducing performance was welcome.&lt;br /&gt;
&lt;br /&gt;
A lively discussion followed on extensions. The two most memorable ones for me were Alpha Content and Store Locator. The former provided a directory listing of articles in a category in an alphabetic manner and gave A-Z index on top to navigate easily to any content beginning with that letter. The latter gave a Google Map of Excel-loaded interest-points (they could be stores or individuals) to easily zoom in at their location or associated URL. &lt;br /&gt;
&lt;br /&gt;
There were a host of other useful insights and this brief introduction does slight injustice to the meeting. I would suggest that if you are interested in Joomla then make your way to the next meeting on15th of March at 7.00pm.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-8039717236455263762?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/8039717236455263762/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2011/02/exciting-meeting-of-londons-joomla-user.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/8039717236455263762?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/8039717236455263762?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2011/02/exciting-meeting-of-londons-joomla-user.html" title="Exciting meeting of London's Joomla User Group" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DUIASH47eip7ImA9Wx9WGUk.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-2883375740712817949</id><published>2011-01-25T01:18:00.000-08:00</published><updated>2011-01-25T01:25:49.002-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-25T01:25:49.002-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Joomla1.6" /><category scheme="http://www.blogger.com/atom/ns#" term="migration" /><category scheme="http://www.blogger.com/atom/ns#" term="upgrade" /><title>Migrating to Joomla 1.6</title><content type="html">I carried out a quick test to establish the issues in migrating to Joomla1.6 on my local PC. The simple answer is that one shouldn't jump into it if one is not willing to do a considerable amount of work oneself. I used a basic site which used rhuk_milkyway template. Here are the findings:&lt;br /&gt;
&lt;br /&gt;
The JUpgrade actually works quite smoothly if you are converting from Joomla 1.5.22. It successfully creates a new working environment for Joomla1.6 and preserves the 1.5 installation. Basically a new directory is created to hold 1.6 code and the MySql database gets the additional Joomla tables with j16 prefix. In ideal world it should just be required to drop the old tables and directory and point to the new installation. However the life is not that simple.&lt;br /&gt;
&lt;br /&gt;
Firstly, the default templates which Joomla1.6 comes with are not production quality and&amp;nbsp;rhuk_milkyway is not supported. Originally it was envisaged to include this particular template in the production release but the idea was shelved. The net effect is that various menus just disappear as one has to place them in new positions manually. Also the menu items had a value of -1 set in line Link Type Options/Link Image for various menu items. All these had to be manually set which is annoying and cumbersome.&lt;br /&gt;
&lt;br /&gt;
After spending around an hour I had a functional site but it was a crude replica of the 1.5 version. I was not too fussed about extensions at this stage but obviously their availability is a critical decision in choosing to migrate. To get the site fully working I would have been forced to spend a considerable amount of time on CSS. So the bottom line is : "Don't rush in! Access control lists are great but the effort required to migrate is too much at this point in time".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-2883375740712817949?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/2883375740712817949/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2011/01/migrating-to-joomla-16.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/2883375740712817949?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/2883375740712817949?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2011/01/migrating-to-joomla-16.html" title="Migrating to Joomla 1.6" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;C08CQnw6cCp7ImA9Wx9WEU0.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-9011515719765458216</id><published>2011-01-15T06:28:00.000-08:00</published><updated>2011-01-15T06:31:03.218-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-15T06:31:03.218-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="scrum agile" /><category scheme="http://www.blogger.com/atom/ns#" term="Tom Gilb" /><category scheme="http://www.blogger.com/atom/ns#" term="estimation" /><title>Estimating project delay just from the quality of requirement specification</title><content type="html">I was privileged to attend a course by Tom Gilb recently on quality and he produced a wonderful way of estimating project delay from just the quality of its requirement&amp;nbsp;specification. Those who are not&amp;nbsp;familiar with Tom should know that he is the pioneer of&amp;nbsp;iterative development&amp;nbsp;method. His Evo methodology with emphasis on weekly deliverables and feedback was produced in the 60s, a long before Agile and Scrum appeared on the horizon. Also he can be credited with introducing software metrics in the 70s which were&amp;nbsp;incorporated as Capability Maturity Model level IV.&amp;nbsp;People who have grown up in quality movement are familiar with the fact that the quality is something which has to be designed within a process and cannot be gained through mere inspection. So just by checking the number of defects in a random page of the specification we can estimate the probability of project success.&lt;br /&gt;
&lt;br /&gt;
A logical page of around three hundred words is&amp;nbsp;inspected&amp;nbsp;for deviation from the rules like testability,&amp;nbsp;ambiguousness&amp;nbsp;and no-design by 3-5 people. It is no good saying that a quality like usability should be dramatically improved unless we&amp;nbsp;numerically&amp;nbsp;quantify it. We take the figure for the highest number of major defects discovered by a team member, D. We multiply this by a factor of two to establish the discoverable defect density (source: experience). Now any inspection only captures a third of the potential defects (source: Capers Jones) so we multiply the discoverable defect density by a factor to generate potential major defects. Now the likelihood of a major defect turning into a downstream bug is one third. Each of this downstream bugs will cost 10 hours to resolve. This gives the formula for project slippage as:&lt;br /&gt;
&lt;br /&gt;
Hours slippage = D * 2 * 3 * 1/3 * 10 * number of non-comment logical pages in the specification&lt;br /&gt;
&lt;br /&gt;
Now this is pure magic as it has been empirically validated on a number of projects in the field. If you don't believe it then carry out the test on a project on which you have worked in the past and see whether the slippage provided by the formula is not within plus or minus 10% of the actual slippage.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-9011515719765458216?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/9011515719765458216/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2011/01/estimating-project-delay-just-from.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/9011515719765458216?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/9011515719765458216?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2011/01/estimating-project-delay-just-from.html" title="Estimating project delay just from the quality of requirement specification" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;A0MCSHg5eSp7ImA9WxFXFk0.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-5774202246282591991</id><published>2010-05-23T02:54:00.000-07:00</published><updated>2010-05-23T03:11:09.621-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-23T03:11:09.621-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="function" /><category scheme="http://www.blogger.com/atom/ns#" term="PHP" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>PHP essentials for Java programmers</title><content type="html">I recently had to do a project in PHP and being from Java background one notices enumerable similarities. Obviously the whole knowledge about object-oriented programming and the procedural constructs like assignments, statements, conditions, loop etc are totally&amp;nbsp;transferable. However the key difference I noticed was in the function calls. In Java all the arguments are passed by value, even for the objects, ie we pass the copy of the address for the object. But in PHP we are allowed to pass arguments by value or reference. Thus we have a simple function&lt;br /&gt;
&lt;br /&gt;
function writeName($name) { echo $name; }&lt;br /&gt;
&lt;br /&gt;
it passes the $name argument as value. However, by just prefixing $name with an ampersand we pass the argument by reference to give&lt;br /&gt;
&lt;br /&gt;
function writeName(&amp;amp;$name) { echo $name; }&lt;br /&gt;
&lt;br /&gt;
The other clever thing about PHP function is that we can return a value by reference too. Take the example from Joomla! library:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function &amp;amp;getLanguage()&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;static $instance;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;if (!is_object($instance))&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;//get the debug configuration setting&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;$conf =&amp;amp; JFactory::getConfig();&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;$debug = $conf-&amp;gt;getValue('config.debug_lang');&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;$instance = JFactory::_createLanguage();&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;$instance-&amp;gt;setDebug($debug);&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;return $instance;&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
Preceding the getLanguage() function by an ampersand indicates that the function will return a value by reference, thus the return is a pointer to $instance.&lt;br /&gt;
&lt;br /&gt;
The another line which will puzzle Java programmers above is&lt;br /&gt;
&lt;br /&gt;
$conf =&amp;amp; JFactory::getConfig();&lt;br /&gt;
&lt;br /&gt;
=&amp;amp; the syntax simply means that $conf is being assigned reference to the object created by getConfig() method of JFactory class. :: notation indicates that we are invoking a class method rather than an instance method. The normal Java dot notation of object.method() for invoking an instance method is changed in PHP to object-&amp;gt;method()&lt;br /&gt;
&lt;br /&gt;
Armed with the knowledge in this article a Java programmer is ready to do a PHP project. The only other thing to bear in mind is that the class constructor is defined by&amp;nbsp;function __construct(). Obviously one will have to come to grips with various PHP functions but this should be no different from understanding a new Java API.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-5774202246282591991?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/5774202246282591991/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/05/java-and-php.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/5774202246282591991?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/5774202246282591991?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/05/java-and-php.html" title="PHP essentials for Java programmers" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkUMQH47cSp7ImA9WxFREEw.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-8759734669275686798</id><published>2010-04-23T01:11:00.000-07:00</published><updated>2010-04-23T01:11:21.009-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-23T01:11:21.009-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="understanding selectors" /><category scheme="http://www.blogger.com/atom/ns#" term="Css" /><title>Selectors in Cascading Style Sheets</title><content type="html">The&amp;nbsp;indispensable tool&amp;nbsp;&amp;nbsp;in every web developers portfolio is&amp;nbsp;Cascading Style Sheets (CSS). Once HTML has been used to organize the contents, the presentational brilliance stems from using CSS rules. Syntactically the rules have a selector followed by a declaration containing various properties&amp;nbsp;separated&amp;nbsp;by semicolons:&lt;br /&gt;
&lt;br /&gt;
p {color:blue; font-weight:normal;}&lt;br /&gt;
&lt;br /&gt;
This&amp;nbsp;simple&amp;nbsp;tag selector rule colours all the contents of &lt;br /&gt;
tags in the HTML document. Also noted that the property-value combination is defined by separating the property from its value with a colon. &amp;nbsp;Instead of p we could have used any of the html elements like h1, h2 etc. To apply the rule to a group of elements we simply use a selector with comma separated the elements. For example, if we want to override the h3, h4, h5 and h6 header elements default definition of the browser, we can just use group selector:&lt;br /&gt;
&lt;br /&gt;
h3, h4, h5, h6 {color:black; font-size:1.2em;)&lt;br /&gt;
&lt;br /&gt;
The commonest way of formatting content is to use the class selector in conjunction with&amp;nbsp;&amp;lt;div&amp;gt;&amp;nbsp;block element or&amp;nbsp;&amp;lt;span&amp;gt;&amp;nbsp;inline element.&lt;br /&gt;
&lt;br /&gt;
.myClass&amp;nbsp;{color:black; font-size:1.2em;) class selector has a period prefix. Currently it will apply to any tag which has attribute definition of class="myClass". For example, if we have the following in our document:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class="myClass"&amp;gt;...&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;div class="myClass"&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then the .myClass selector will apply the declaration formatting to both these elements. To just restrict the formatting to &lt;br /&gt;
element, we change the selector to p.myClass in our rule.&lt;br /&gt;
&lt;br /&gt;
Along with class, id is another attribute which can be placed on most elements. Indeed, javascript uses id to get the elements. So if we have&amp;nbsp;&amp;lt;p id="myID"&amp;gt;&amp;nbsp;then the hash prefixed selector for this element becomes:&lt;br /&gt;
&lt;br /&gt;
#myID&amp;nbsp;{color:black; font-size:1.2em;)&lt;br /&gt;
&lt;br /&gt;
We also have pseudo-classes and pseudo-elements available as selectors. The anchor pseudo-classes are used to invariably define link&amp;nbsp;interaction&amp;nbsp;with a:link, a:visited, a:hover and a:active selectors. We know that these stages happen with links.&amp;nbsp;Similarly, the first line of a&amp;nbsp;paragraph&amp;nbsp;or a first letter of the paragraph doesn't have a tag but it is easily&amp;nbsp;identifiable&amp;nbsp;pseudo-element so we can have a selectors like:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p:first-letter {color: blue;font-size:1.5em;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
p:first-line {color: blue;font-size:1.5em;}&lt;br /&gt;
&lt;br /&gt;
Similarly there are pseudo-elements after and before for auto-generated content. To prefix a paragraph with a class="intro" with 'Thought of the day!' auto-generated content, we have the selector syntax:&lt;br /&gt;
&lt;br /&gt;
p.intro:before {content: "Thought of the day!" }&lt;br /&gt;
&lt;br /&gt;
or to give the text after the paragraph:&lt;br /&gt;
&lt;br /&gt;
p.intro:after {content: "Thought of the day!" }&lt;br /&gt;
&lt;br /&gt;
To style tags within tags we have descendant selector. For example, to highlight emphasis within a paragraph we may use the selector:&lt;br /&gt;
&lt;br /&gt;
h1 strong { color: red; }&lt;br /&gt;
&lt;br /&gt;
Here sub-element&amp;nbsp;&amp;lt;strong&amp;gt; within element&amp;nbsp;&amp;lt;h1&amp;gt; is coloured red. Similarly if we wanted to select the ordered lists which are direct children of body element the syntax is body&amp;nbsp;&amp;gt;&amp;nbsp;ol for the rule. Note the angle bracket is used for the child selector. Or to get to an adjacent sibling we use the plus ('+') sign instead of the angle bracket.&lt;br /&gt;
&lt;br /&gt;
We can also select on the attributes. These selectors allow us to select element which have a certain property. For example to select all the images with title attribute we will have a selector img[title]. Or to just select text boxes in a form we can have the attribute selector&lt;br /&gt;
&lt;br /&gt;
input[type="text"]&lt;br /&gt;
&lt;br /&gt;
There are some further refinements to these selector but the knowledge is acquired by experimentation. The aspects covered are more than adequate.&lt;br /&gt;
&lt;br /&gt;
For a good source for understanding the selectors visit&amp;nbsp;&lt;a href="http://gallery.theopalgroup.com/selectoracle/"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.amazon.com/CSS-Missing-David-Sawyer-McFarland/dp/0596802447?ie=UTF8&amp;amp;tag=wwwitisconsul-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969" target="_blank"&gt;CSS: The Missing Manual&lt;/a&gt;&lt;img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=wwwitisconsul-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=0596802447" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /&gt;&amp;nbsp;is a very useful resource which you should have in your collection.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-8759734669275686798?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/8759734669275686798/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/04/selectors-in-cascading-style-sheets.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/8759734669275686798?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/8759734669275686798?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/04/selectors-in-cascading-style-sheets.html" title="Selectors in Cascading Style Sheets" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkMERns4eCp7ImA9WxFSE0w.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-8026013740695023601</id><published>2010-04-14T23:53:00.000-07:00</published><updated>2010-04-14T23:53:27.530-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-14T23:53:27.530-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jquery" /><category scheme="http://www.blogger.com/atom/ns#" term="tutorial" /><category scheme="http://www.blogger.com/atom/ns#" term="w3schools" /><title>Delight of w3schools</title><content type="html">Like countless other people I have used the tutorials at &lt;a href="http://www.w3schools.com/"&gt;w3schools&lt;/a&gt;&amp;nbsp;to become familiar with various technologies at different stages in my life. It is impossible to be not familiar with this site for anyone who has taken delight in learning new things. I recall learning about ASP, XPath etc on this site a number of years ago. Indeed a career in IT is impossible without constantly updating ones skill base so a comprehensive training resource is a real boon. The site invariably appears in the top searches whenever 'Ajax tutorial' or 'jquery tutorial' type terms are used in google so cannot escape the radar of any technology&amp;nbsp;aficionado. For last couple of years I had been hearing good things about jquey so decided to take the plunge and become familiar with the framework yesterday. Needless to say that w3schools gave me a couple of hours of real pleasure. There tutorial seem basic but they get to the heart of the matter. Their examples were lucid and their jquery engine for practising is great. So here is a public thanks for being so useful. W3schools, you rock!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-8026013740695023601?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/8026013740695023601/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/04/delight-of-w3schools.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/8026013740695023601?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/8026013740695023601?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/04/delight-of-w3schools.html" title="Delight of w3schools" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;A0MMR388fyp7ImA9WxFSEEQ.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-6864176084339106211</id><published>2010-04-12T12:09:00.000-07:00</published><updated>2010-04-12T12:11:26.177-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-12T12:11:26.177-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Public vs private XML schema" /><title>Industry vocabularies are imperative - don't create your own</title><content type="html">In many respects the advantages and disadvantages of using user-specific XML schema and industry-standard schema are akin to those stemming from using customised bespoke application compared to application packages. One offers absolute control to adapt the software to ones need whilst the other eschews the temptation of reinventing-the-wheel by accepting industry best practice as embodied in state-of-the-art package.&lt;br /&gt;
&lt;br /&gt;
The vocabularies emerging from standards organisations like W3C, ebXML, RosettaNet etc are the cornerstone of e-business. They facilitate interoperability and allow the business processes to extend beyond the enterprise in a seamless fashion. Indeed, without the vocabulary of SOAP, WSDL and UDDI the web services would not be possible. However, the reason Adobe ended up creating eXtensible Metadata Platform (XMP) for adding metadata to resources like application files, content management systems, databases etc was that there was a lack of standardised metadata (Schmelzer et al, 2002, p562). This is the problem with industry-vocabulary that it takes time to evolve and then requires consensus to develop it further so can be slow. &amp;nbsp;But once the vocabulary is agreed then all the trading partners can refer to a tag and know its precise meaning and definition. All the design decisions are in place and we don’t have to go about reinventing the wheel. The software specialists can start providing applications to handle a particular vocabulary with confidence. For example, the existence of XML Schema vocabulary means that many validating parsers have been written. A commercial product like BEA Weblogic conforms to RosettaNet specification for supply chain management to achieve B-to-B integration (Thuraisingham, 2002, p180). &lt;br /&gt;
&lt;br /&gt;
Let us consider the particular example of image tagging. If all the images on the web had metadata tags according to a particular vocabulary then it would be easy to write programs to discover and integrate new images into existing databases. It would also be possible to validate a document against a vocabulary before any information exchange between parties. The Dublin Core metadata elements like subject, description, rights etc enable us to easily document image resources and discover them (Dublin Core Metadata Initiative, 2008). If organisations didn’t deploy these standard metadata elements then any meaningful image search would be a nightmare as the search keyword would not be contextualised.&lt;br /&gt;
&lt;br /&gt;
Always resist the temptation to create your own schema and opt for the one which is publicly available. It pays off in the long run. Although it is straightforward to build up a tight relationship with a trading partner by providing everything he needs by agreeing to an internal vocabulary. We don’t have the burden of mapping our existing internal definitions to the standards. However, as the partners proliferate, the approach becomes a nightmare as customisation may be required for handling each new relationship. The cost of maintaining translations between our internal vocabulary and our partners’ vocabularies would quickly become prohibitive and unsustainable. The internal vocabulary works best when we have total control over the domain and do not need to reach out to the wider world. Tim Bray, the co-creator of XML, &amp;nbsp;provides the sound advice that you shouldn’t really create your own specialist vocabulary unless you really have to.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;References&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
Dublin Core Metadata Initiative (2008) &lt;i&gt;Dublin Core Metadata Element Set, Version 1.1&lt;/i&gt; [online], available from: &amp;nbsp;http://dublincore.org/documents/dces/ &amp;nbsp;(accessed 12 May 2010)&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Schmelzer R., Vandersypen T., Bloomberg J., Siddalingaiah M., Hunting S., Qualls M.D., Houlding D., Darby C and Kennedy D. (2002) &lt;i&gt;XML and Web Servicese Unleashed&lt;/i&gt;, Sams Publishing, USA&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt; &lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Thuraisingham, B. (2002) &lt;i&gt;XML Databases and the Semantic Web&lt;/i&gt;, CRC Press, Florida&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&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/7261548585686045052-6864176084339106211?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/6864176084339106211/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/04/industry-vocabularies-are-imperative.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/6864176084339106211?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/6864176084339106211?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/04/industry-vocabularies-are-imperative.html" title="Industry vocabularies are imperative - don't create your own" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;A08ERXc9eCp7ImA9WxFTEU0.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-2219323328247219996</id><published>2010-04-01T00:59:00.000-07:00</published><updated>2010-04-01T01:16:44.960-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-01T01:16:44.960-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SAX" /><category scheme="http://www.blogger.com/atom/ns#" term="DOM" /><category scheme="http://www.blogger.com/atom/ns#" term="XML parsing" /><category scheme="http://www.blogger.com/atom/ns#" term="XSLT" /><title>Comparison of XML data extraction mechanisms</title><content type="html">We have two distinct methods available for extracting relevant elements from an XML document and present them in a suitable new document, namely the XSL Transformation language (XSLT ) or conventional programming using Java, C++ etc.. &lt;br /&gt;
&lt;br /&gt;
The Extensible Style Sheet (XSL) technologies are standards defined by W3C for handling XML documents for various purposes. Just as we have cascading style sheet (CSS) for declaring the presentation of HTML tags, the XSL technologies have equivalent XSL Formatting Object Language (XSL-FO) for managing presentation of XML documents. However, XSL technologies also have XPath for navigating the nodes of XML documents and XSLT for transforming a document from one vocabulary to another or creating a subset of a document’s elements in a different document. XSLT utilises XPath as a sublanguage, especially for identifying parts of the input XML document which should be processed.  Conceptually we will have our input XML document with full definition of our image metadata, an associated style sheet template with processing declarations and these jointly are processed by XSLT processor to produce a new restricted version of our output XML document with required image elements (Figure 1). The XSLT processor is a piece of software either built into browser, web or application server or a standalone application.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Figure 1. Transformation process of an XML document with XSLT&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_mrFFpG3NgK0/S7RMMvp-zyI/AAAAAAAAACk/10Q4um-cZT8/s1600/xslt.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="316" src="http://3.bp.blogspot.com/_mrFFpG3NgK0/S7RMMvp-zyI/AAAAAAAAACk/10Q4um-cZT8/s400/xslt.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
The XSL stylesheet is a well-formed XML document with the following structure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:template match="”node”"&amp;gt;&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- the node speciation in the match attribute is effectively an XPath expression --&amp;gt;&lt;br /&gt;
&amp;lt;-- use XSLT language elements like &lt;xsl:if&gt; &lt;xsl:loop&gt; &lt;xsl:sort&gt; etc to build logic --&amp;gt;&lt;/xsl:sort&gt;&lt;/xsl:loop&gt;&lt;/xsl:if&gt;&lt;br /&gt;
&lt;xsl:if&gt;&lt;xsl:loop&gt;&lt;xsl:sort&gt;&amp;lt;/xsl:sort&amp;gt;&amp;lt;/xsl:loop&amp;gt;&amp;lt;/xsl:if&amp;gt;&lt;/xsl:sort&gt;&lt;/xsl:loop&gt;&lt;/xsl:if&gt;&lt;br /&gt;
&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
(Note there is version 2.0 available since 2007).&lt;br /&gt;
&lt;br /&gt;
All the instructions within the stylesheet are written in XSLT language. The processing in template interleaves input (XPath pattern matching), output and XSLT instructions. We have many programming constructs like loop, if, sort, for-each, value-of, copy-of etc available in XSLT language. These language elements enable us to process the input XML document in a very flexible manner to produce the desired output. The whole power of XPath is available to reach any node set in the input XML document for processing. Defining the processing instructions in declarative fashion in an XML document is ideally suited to an environment where we are primarily dealing with XML documents. It is straightforward to convert from one vocabulary to another using XSLT. We simply state the required output when a certain input pattern is detected. However, the approach forces traditional developers to acquire new skill set. Also XSLT is not expressive enough to handle complex problems like searching for elements described by another element. Although the existing XSLT processors place the whole XML document in memory so could be memory hungry but declarative instructions offers the possibility of progressive rendering.&lt;br /&gt;
&lt;br /&gt;
The alternative is to build on the existing expertise of developer in a programming language like Java, C++ etc to produce the desired output document (Figure 2).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Figure 2. Transformation process of an XML document with conventional application programming&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_mrFFpG3NgK0/S7RNysXmMMI/AAAAAAAAACs/4Hk6J_yROMM/s1600/x2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_mrFFpG3NgK0/S7RNysXmMMI/AAAAAAAAACs/4Hk6J_yROMM/s320/x2.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
A conventional programmer can readily take an input file, process it in some manner and produce an output. However, an XML document needs to be parsed to extract relevant information. If we could parse it using library routines of some nature then producing the required output document is just a matter of creating a root element and adding relevant elements, attributes and their contents.&lt;br /&gt;
&lt;br /&gt;
This is achieved normally in one of two ways. Either entire document is read into the memory, a Document Object Model is created and library routines are used for parsing the XML document. Or alternatively Simple API for XML (SAX) can be used for parsing the document. DOM approach needs to read the entire document in memory so it is not suitable for very large documents but can change the document in situ. To overcome the memory-intensive nature of DOM, the SAX approach reads the file sequentially and triggers off an event every time a new element is reached or one ended so the programmer can take appropriate action pertaining to that element. Thus the SAX processing hinges on defining event listeners. DOM model has flexibility of being able to access elements randomly but SAX is a sequential approach. DOM is a W3C specification but its API is deemed to be too complex. Also DOM approach requires recursive programming which makes some developers uncomfortable. However once we have acquired expertise in DOM API or SAX then changing parsers becomes easier as newer and better implementations arrive on the scene. Although for relatively small files the DOM approach may be suitable but SAX allows us to handle documents which are&amp;nbsp;bigger than the available computer memory. SAX generally tends to be faster as we are just reading small portion of document at a time. A hybrid approach of XML pull-parsing has evolved lately to combine the efficiency of SAX and simplicity of DOM. It contrasts with ‘push’ nature of SAX as the portion of document is pulled as required. People who are seeking de jure standards would opt for DOM as SAX is open source, free of charge product stemming from the collaborative effort of XML-DEV mailing list. In general, the DOM approach is preferable in a context where we are effectively changing the structure of a rather small document and require total flexibility in navigation.&lt;br /&gt;
&lt;br /&gt;
Nowadays a Java programmer has the best of both worlds and would simply employ Java API for XML Processing (JAXP). Its abstraction layer allows various parsers to be plugged in and the documents to be easily validated, parsed and transformed.&amp;nbsp;&lt;a href="http://www.amazon.com/Java-XML-JAXP-Arthur-Griffith/dp/0471209074?ie=UTF8&amp;amp;tag=wwwitisconsul-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969" target="_blank"&gt;Java, XML, and the JAXP&lt;/a&gt;&lt;img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=wwwitisconsul-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=0471209074" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /&gt;&amp;nbsp;is a good guide.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Reference&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;Rosewell, J. (2009d) ‘Block 2 part 8: Processing XML’, in T320 E-business Technologies: Foundations and Practice, The Open University, Milton Keynes&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-2219323328247219996?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/2219323328247219996/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/04/comparison-of-xml-data-extraction.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/2219323328247219996?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/2219323328247219996?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/04/comparison-of-xml-data-extraction.html" title="Comparison of XML data extraction mechanisms" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_mrFFpG3NgK0/S7RMMvp-zyI/AAAAAAAAACk/10Q4um-cZT8/s72-c/xslt.jpg" height="72" width="72" /><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;DEUDR3gycCp7ImA9WxFTEU0.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-7418974406199395396</id><published>2010-03-31T12:24:00.000-07:00</published><updated>2010-04-01T00:17:56.698-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-01T00:17:56.698-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="new order" /><category scheme="http://www.blogger.com/atom/ns#" term="IT-business alignment" /><title>The brave new world</title><content type="html">The pressure on IT has always been there to deliver. I recall the 80s when the business-IT alignment was on everybody's lips, the 90s when the IT-facilitated business process re-engineering and kaizan were talk of the town and the new economic order was proclaimed by the web-based companies at the turn of the century. IT was always deemed indispensable in these initiatives but adjudged to be slow to meet the business needs. The bursting of the dotcom bubble and the y2k experience tarnished the IT image but did not abet the pressure on IT to facilitate inter-organisational processes in a globalised world. IT's role was still at the heart of 'making it happen'. One assumed that the ERP systems had taken care of all the transactional needs at the operational level and the datawarehouses and business intelligence tools had enamoured the business executives by adding value to strategy formulation. Now comes the &lt;a href="http://bit.ly/d0tNgY"&gt;frightening reminder &lt;/a&gt; that all is not well in the wake of global financial meltdown.&lt;br /&gt;
&lt;br /&gt;
"Capital expenditure priorities are shifted into IT from other high-payback projects" just to perform necessary ERP changes, claims one executive. Whilst another bemoans: "Change to ERP paralyzes the entire organization in moving forward in other areas that can bring more value."&lt;br /&gt;
&lt;br /&gt;
An Accenture partner sees rising tide of operational flexibility on daily basis and proclaims "strategy, as we knew it, is dead." A paradigm shift in IT's execution is expected and demanded in this new world order. Yet the top priority for 2009 was "modernizing key legacy applications" and the SOA, the pre-requisite for flexibility, seemed fatally wounded.&lt;br /&gt;
&lt;br /&gt;
It is a challenge to all the IT professionals to acquire a mindset attuned with business imperatives and successfully deploy disruptive technologies to make a quantum change. The decade ahead of us is full of potential and we must not fail.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-7418974406199395396?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/7418974406199395396/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/brave-new-world.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/7418974406199395396?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/7418974406199395396?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/brave-new-world.html" title="The brave new world" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkUERH0-eyp7ImA9WxBaGUs.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-1773619202075736830</id><published>2010-03-30T04:14:00.000-07:00</published><updated>2010-03-30T08:50:05.353-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-30T08:50:05.353-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SOAP" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="SAAJ" /><title>SOAP with Attachment API for Java (SAAJ) example</title><content type="html">SAAJ is an indispensable tool for manipulating SOAP messages, especially if they have got attachments. We have illustrated all the steps in creating a SwA (SOAP Messages with Attachments) in the short self-explanatory example which can be adapted for all purposes.&lt;br /&gt;
&lt;br /&gt;
package saajexample;&lt;br /&gt;
&lt;br /&gt;
import java.awt.Image;&lt;br /&gt;
import java.awt.Toolkit;&lt;br /&gt;
import javax.xml.soap.*;&lt;br /&gt;
&lt;br /&gt;
public class Main {&lt;br /&gt;
&lt;br /&gt;
public static void main(String[] args) throws Exception {&lt;br /&gt;
// Factory needed to create SOAP message&lt;br /&gt;
MessageFactory msgFactory = MessageFactory.newInstance();&lt;br /&gt;
SOAPMessage message = msgFactory.createMessage();&lt;br /&gt;
// illustrate the story so far by dumping out the message&lt;br /&gt;
message.writeTo(System.out);&lt;br /&gt;
// detach the header from the SOAP Envelope&lt;br /&gt;
message.getSOAPHeader().detachNode();&lt;br /&gt;
System.out.println("");&lt;br /&gt;
message.writeTo(System.out);&lt;br /&gt;
// manipulate the body of the SOAP message&lt;br /&gt;
SOAPBody body = message.getSOAPBody();&lt;br /&gt;
SOAPElement getStockPrice = body.addChildElement(&lt;br /&gt;
"getStockPrice",&lt;br /&gt;
"rt",&lt;br /&gt;
"http://www.rajeev.com/jws/StockQuote");&lt;br /&gt;
System.out.println("");&lt;br /&gt;
message.writeTo(System.out);&lt;br /&gt;
getStockPrice.setEncodingStyle(SOAPConstants.URI_NS_SOAP_ENCODING);&lt;br /&gt;
System.out.println("");&lt;br /&gt;
message.writeTo(System.out);&lt;br /&gt;
SOAPElement code = getStockPrice.addChildElement("stockCode");&lt;br /&gt;
System.out.println("");&lt;br /&gt;
message.writeTo(System.out);&lt;br /&gt;
code.addTextNode("IBM");&lt;br /&gt;
System.out.println("");&lt;br /&gt;
message.writeTo(System.out);&lt;br /&gt;
// attach an image&lt;br /&gt;
Image image = Toolkit.getDefaultToolkit().createImage("raj.jpg");&lt;br /&gt;
AttachmentPart jpegAttach = message.createAttachmentPart();&lt;br /&gt;
// use setDataHandler method below if connecting to FileDataSource object for pdf file&lt;br /&gt;
jpegAttach.setContent(image, "image/jpeg");&lt;br /&gt;
// add the mime type for the image&lt;br /&gt;
jpegAttach.addMimeHeader("Content-Transfer-Encoding", "binary");&lt;br /&gt;
jpegAttach.setContentId("xxx");&lt;br /&gt;
message.addAttachmentPart(jpegAttach);&lt;br /&gt;
System.out.println("");&lt;br /&gt;
//        message.writeTo(System.out); // cannot stream image&lt;br /&gt;
// check attachment created successfully&lt;br /&gt;
System.out.printf("Number of attachments: %d%n", message.countAttachments());&lt;br /&gt;
// remove the attachment and verify&lt;br /&gt;
message.removeAllAttachments();&lt;br /&gt;
System.out.printf("Number of attachments: %d%n", message.countAttachments());&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-1773619202075736830?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/1773619202075736830/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/soap-with-attachment-api-for-java-saaj.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/1773619202075736830?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/1773619202075736830?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/soap-with-attachment-api-for-java-saaj.html" title="SOAP with Attachment API for Java (SAAJ) example" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DUQEQ3s-fip7ImA9WxBaGEs.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-5648449413176249506</id><published>2010-03-29T02:20:00.000-07:00</published><updated>2010-03-29T05:55:02.556-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-29T05:55:02.556-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="JAXB tutorial" /><title>JAXB tutorial</title><content type="html">XML is the lingua franca of the web services world. Unsurprisingly, the ability to process XML documents simply is an essential requirement. To my mind DOM and SAX parsers are the equivalent of assembler programming compared to the high-level programming provided by the Java Architecture for XML Binding, JAXB. It is an essential tool in every Java developer's portfolio. But many tutorials on the web hark back to JAXB1.0 so here is something to get you started.&lt;br /&gt;
&lt;br /&gt;
The JAXB tutorial provided by &lt;a href="http://www.roseindia.net/jaxb/r/jaxb.shtml"&gt;Rose India&lt;/a&gt; is rather dated now. The &lt;a href="http://www.ibm.com/developerworks/webservices/library/ws-tip-jaxwsrpc2.html"&gt;IBM resource&lt;/a&gt; was a fairly good introduction to Java-XML mapping once upon a time but the Sun/Oracle JAXB tutorial is simply amazing. &lt;br /&gt;
&lt;br /&gt;
Rarely a tutorial is written which is as comprehensive as the one provided &lt;a href="https://jaxb.dev.java.net/tutorial/index.html"&gt;here&lt;/a&gt;. All the aspects of mapping XML Schema Language types to Java, marshalling Java-based tree content to XML, unmarshalling from XML-to-Java, ObjectFactory class, XML annotations, the JAXB schema compiler (xjc) et al have been covered very lucidly.&lt;br /&gt;
&lt;br /&gt;
If it still doesn't satisfy your curiosity then the book &lt;a target="_blank"  href="http://www.amazon.com/JAXB-2-0-Wolfgang-Schmiesing/dp/3446407537?ie=UTF8&amp;tag=wwwitisconsul-20&amp;link_code=btl&amp;camp=213689&amp;creative=392969"&gt;JAXB 2.0&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=wwwitisconsul-20&amp;l=btl&amp;camp=213689&amp;creative=392969&amp;o=1&amp;a=3446407537" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important; padding: 0px !important" /&gt; is all you need for all the JAXB requirements but unfortunately it is in German.&lt;br /&gt;
&lt;br /&gt;
Here is a sample code to marshal and unmarshal a simple letter written by me to Helen of Troy.&lt;br /&gt;
&lt;br /&gt;
package raj;&lt;br /&gt;
&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import javax.xml.bind.JAXBContext;&lt;br /&gt;
import javax.xml.bind.Marshaller;&lt;br /&gt;
import javax.xml.bind.Unmarshaller;&lt;br /&gt;
import javax.xml.bind.annotation.XmlAttribute;&lt;br /&gt;
import javax.xml.bind.annotation.XmlRootElement;&lt;br /&gt;
&lt;br /&gt;
@XmlRootElement&lt;br /&gt;
public class Letter {&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
* The sender of the letter.&lt;br /&gt;
*/&lt;br /&gt;
private String sender;&lt;br /&gt;
/**&lt;br /&gt;
* The receiver.&lt;br /&gt;
*/&lt;br /&gt;
private String receiver;&lt;br /&gt;
/**&lt;br /&gt;
* A unique number for the message number sent .&lt;br /&gt;
*/&lt;br /&gt;
private int messageNo;&lt;br /&gt;
/**&lt;br /&gt;
* The missive despatched.&lt;br /&gt;
*/&lt;br /&gt;
private String message;&lt;br /&gt;
&lt;br /&gt;
public Letter() {&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public String getSender() {&lt;br /&gt;
return sender;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void setSender(String sender) {&lt;br /&gt;
this.sender = sender;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public String getReceiver() {&lt;br /&gt;
return receiver;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void setReceiver(String receiver) {&lt;br /&gt;
this.receiver = receiver;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public String getMessage() {&lt;br /&gt;
return message;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void setMessage(String message) {&lt;br /&gt;
this.message = message;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public int getMessageNo() {&lt;br /&gt;
return messageNo;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@XmlAttribute&lt;br /&gt;
public void setMessageNo(int messageNo) {&lt;br /&gt;
this.messageNo = messageNo;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public String toString() {&lt;br /&gt;
return String.format("Letter %s from %s to %s, saying '%s'", messageNo, sender, receiver, message);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[] arg) {&lt;br /&gt;
Letter text = new Letter();&lt;br /&gt;
text.setSender("Rajeev Trikha");&lt;br /&gt;
text.setMessageNo(2010);&lt;br /&gt;
text.setReceiver("Helen of Troy");&lt;br /&gt;
text.setMessage("Welcome to my world of JAXB in 2010!");&lt;br /&gt;
// Create a JAXB context and a marshaller&lt;br /&gt;
try {&lt;br /&gt;
// here just using a class as an argument but normally is a package&lt;br /&gt;
JAXBContext context = JAXBContext.newInstance(Letter.class);&lt;br /&gt;
Marshaller marshaller = context.createMarshaller();&lt;br /&gt;
// Set the output in formatted manner&lt;br /&gt;
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);&lt;br /&gt;
// Make the actual serialization&lt;br /&gt;
&lt;br /&gt;
marshaller.marshal(text, new File("raj.xml"));&lt;br /&gt;
Unmarshaller unmarshaller = context.createUnmarshaller();&lt;br /&gt;
// Get the object&lt;br /&gt;
Letter msg = (Letter) unmarshaller.unmarshal(new File("raj.xml"));&lt;br /&gt;
System.out.println(msg);&lt;br /&gt;
} catch (Exception e) {&lt;br /&gt;
System.out.println("exc");&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The marshalled file raj.xml shows the created XML message which is well indented.&lt;br /&gt;
&lt;br /&gt;
The unmarshalling prints out to the console: &lt;br /&gt;
Letter 2010 from Rajeev Trikha to Helen of Troy, saying 'Welcome to my world of JAXB in 2010!'&lt;br /&gt;
&lt;br /&gt;
If you are using Netbeans then &lt;a href="http://netbeans.org/kb/docs/websvc/jaxb.html"&gt;check out&lt;/a&gt; for understanding how xjc is tied up within the product.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-5648449413176249506?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/5648449413176249506/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/jaxb-tutorial.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/5648449413176249506?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/5648449413176249506?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/jaxb-tutorial.html" title="JAXB tutorial" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DUMNSXs7fSp7ImA9WxBaFUw.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-6428375383225852286</id><published>2010-03-20T02:48:00.000-07:00</published><updated>2010-03-25T04:44:58.505-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-25T04:44:58.505-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Corba" /><category scheme="http://www.blogger.com/atom/ns#" term="web services" /><title>CORBA or web services</title><content type="html">CORBA has the key advantage of being truly object-oriented component architecture and comes with a host of standard services like naming, transactions, printing, events etc which support complex applications in a heterogeneous environment in a platform and language independent manner. For example, there is no equivalent of CORBA Security service in web service environment and only now the suppliers have started addressing these aspects. So the disadvantage of web services over CORBA is that it is reinventing-the-wheel and cannot handle the required amount of complexity in its current state. However the complexity of CORBA, the issues with its specification and the slowness of new development have opened way for web services which are more suited to web-environment with their loose coupling, XML and HTTP usage. The SOAP messages of web services are simple to use and implement. Unsurprisingly, this simplicity has given momentum to web services over CORBA.&lt;br /&gt;
&lt;br /&gt;
&lt;a target="_blank"  href="http://www.amazon.com/Java-Web-Services-Up-Running/dp/059652112X?ie=UTF8&amp;tag=wwwitisconsul-20&amp;link_code=btl&amp;camp=213689&amp;creative=392969"&gt;Java Web Services: Up and Running&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=wwwitisconsul-20&amp;l=btl&amp;camp=213689&amp;creative=392969&amp;o=1&amp;a=059652112X" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important; padding: 0px !important" /&gt; is one of the most up-to-date and practical books on web services.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-6428375383225852286?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/6428375383225852286/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/corba-or-web-services.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/6428375383225852286?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/6428375383225852286?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/corba-or-web-services.html" title="CORBA or web services" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkYCQ3kyeip7ImA9WxBaEEo.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-3219947943642026503</id><published>2010-03-20T02:37:00.000-07:00</published><updated>2010-03-20T02:42:42.792-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-20T02:42:42.792-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SOAP" /><category scheme="http://www.blogger.com/atom/ns#" term="W3C standards" /><category scheme="http://www.blogger.com/atom/ns#" term="XML" /><category scheme="http://www.blogger.com/atom/ns#" term="WSDL" /><category scheme="http://www.blogger.com/atom/ns#" term="UDDI" /><title>W3C standards for web services</title><content type="html">The key W3C standards for web services are SOAP (previously Simple Object Access Protocol), eXtensible Markup Language (XML), Web Services Description Language (WSDL) and, peripherally, Universal Description, Discovery and Integration (UDDI).&lt;br /&gt;&lt;br /&gt;SOAP is protocol which facilitates message-based communication between heterogeneous systems using XML over HTTP (usually) in a defined form. The SOAP message envelop is well-formed, its tags are qualified by a namespace, avoids firewall issues as HTTP port is always open and is part of the body of HTTP request or response.  &lt;br /&gt;&lt;br /&gt;XML has become the de facto standard for exchanging data between systems as it segregates the meaning of data from its presentation in a plain Unicode text file. SOAP, WSDL and UDDI entries use XML. XML Schema Definition (XSD) is W3C standard for constraining documents vocabularies. The XML files are inherently readable, compressible, portable and support internationalisation, which are pre-requisites in a complex heterogeneous environment. To testify to its popularity, the vocabularies with defined elements and attributes exist for various business domains and the language is extensible. It has become the lingua franca of inter-system communication. SOAP protocol and WSDL descriptions use it. XML messages can be sent over HTTP channels, XML parsers exist in abundance and Data Type Definitions (DTD) or XML Schemas of various vocabularies means that irrespective of platform and implementation language a received XML document can be checked for conformance and meaning and facilitates communication.&lt;br /&gt;&lt;br /&gt;WSDL provides platform-independent definition of interfaces of a web service. A WSDL definition describes the location, protocol, service operations, parameters etc in an XML file thus facilitating the segregation of description from the actual implementation. The definition enables one to understand the service and its operations and invoke them.&lt;br /&gt;&lt;br /&gt;The UDDI specification is managed by OASIS but it is so central to web services use that it will be churlish to avoid it. UDDI enables web services to be registered and discovered in standard way. The creators of web services register their services in the registry and the potential customers/users discover them there and use them. The white pages, yellow pages and green pages of UDDI entries are well understood and utilised by all who are interested in services-oriented architecture.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-3219947943642026503?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/3219947943642026503/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/w3c-standards-for-web-services.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/3219947943642026503?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/3219947943642026503?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/w3c-standards-for-web-services.html" title="W3C standards for web services" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DU8AR3Y8eSp7ImA9WxBaFUw.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-3929645651079998509</id><published>2010-03-20T01:20:00.000-07:00</published><updated>2010-03-25T04:50:46.871-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-25T04:50:46.871-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SCJP" /><category scheme="http://www.blogger.com/atom/ns#" term="Java training" /><category scheme="http://www.blogger.com/atom/ns#" term="Kingston-Upon-Thames" /><category scheme="http://www.blogger.com/atom/ns#" term="London" /><title>Java training course to pass SCJP 6 in Kingston-Upon-Thames</title><content type="html">&lt;span class="Apple-style-span"   style="  border-collapse: collapse; font-family:arial, sans-serif;font-size:13px;"&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  border-collapse: collapse; font-family:arial, sans-serif;font-size:13px;"&gt;If you live in the vicinity of Kingston-Upon-Thames or are based in London then here is an excellent opportunity to learn Java for £300. Obviously the intention of the course is to give a thorough grounding in Java but the course is structured around the objectives of SCJP 6. You do not need any prior exposure to programming or Java to do this course.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  border-collapse: collapse; font-family:arial, sans-serif;font-size:13px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;We will use Netbeans IDE  and focus on the objective of SCJP 6. The idea is to make students comfortable with all the relevant classes in JDK 6 and have good foundational knowledge of object orientated concepts like inheritance polymorphism, and encapsulation. &lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  border-collapse: collapse; font-family:arial, sans-serif;font-size:13px;"&gt;The SCJP focuses on modifiers, wrapper classes, autoboxing, flow control, loops, exceptions, APIs, serialization, threads, packaging (JARs), collections, generics, garbage collection, assertions, regular expressions, var-args, covariant returns, static imports, enum, inner classes etc and we will cover all these aspects of Java language over the five days. The IDE hides complexity so we will do some command line compilation and running of programs to give a clear feel for how packages work and the various flags in java and javac&lt;/span&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  border-collapse: collapse; font-family:arial, sans-serif;font-size:13px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  border-collapse: collapse; font-family:arial, sans-serif;font-size:13px;"&gt;What is most important is that we will provide the support till you actually pass the SCJP exam. Note that the Prometric centre examination fees are not covered in the course cost.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  border-collapse: collapse; font-family:arial, sans-serif;font-size:13px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  border-collapse: collapse; font-family:arial, sans-serif;font-size:13px;"&gt;For more information either phone me at 0208 541 0225 or email rajeev108@gmail.com&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;a target="_blank"  href="http://www.amazon.com/SCJP-Certified-Programmer-Java-310-065/dp/0071591060?ie=UTF8&amp;tag=wwwitisconsul-20&amp;link_code=btl&amp;camp=213689&amp;creative=392969"&gt;SCJP Sun Certified Programmer for Java 6 Exam 310-065&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=wwwitisconsul-20&amp;l=btl&amp;camp=213689&amp;creative=392969&amp;o=1&amp;a=0071591060" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important; padding: 0px !important" /&gt; is the recommended book if you really want to come to grip with the language and pass the SCJP.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-3929645651079998509?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/3929645651079998509/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/java-training-course-to-pass-scjp-6-in.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/3929645651079998509?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/3929645651079998509?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/java-training-course-to-pass-scjp-6-in.html" title="Java training course to pass SCJP 6 in Kingston-Upon-Thames" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;Dk4GRXg_eSp7ImA9WxBbF08.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-8782815338861623189</id><published>2010-03-15T23:47:00.000-07:00</published><updated>2010-03-16T00:35:24.641-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-16T00:35:24.641-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="XSD editor" /><category scheme="http://www.blogger.com/atom/ns#" term="Sun" /><category scheme="http://www.blogger.com/atom/ns#" term="UML editor" /><category scheme="http://www.blogger.com/atom/ns#" term="Netbeans" /><title>Return of some useful plugins in Netbeans6.9</title><content type="html">The introduction of Netbeans6.8 was a mixed blessing. Its support for JSF2.0 and ease of development at various-fronts is indeed praiseworthy but the downside was that we lost many useful plugins including visual web tool for JSF development, UML editor, XML schema editor etc. The&lt;a href="http://forums.netbeans.org/topic20097.html"&gt; howls of anguish&lt;/a&gt; were widespread. Sun justified it on the basis of instability of some of the tools and the strategic need to marshal resources on winning fronts. Well, Netbeans6.9 early release have some of these back. It indeed is a good news for champions of these tools but it leaves the question answered on the future direction of these tools in the hands of Oracle. The departure of Sun's CEO Jonathan Schwartz, the chief open source officer Simon Phipps and Java technology evangelist Sang Shin (whose javapassion.com was a useful tool for learning various Java technologies) is indicative of the winds of change. Are these back because of the transitional uncertainties? Whatever the reason, enjoy while they are available.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Many know how to add a new plugin in Netbeans using Tools/Plugins/Available Plugins but fewer are certain of Tools/Plugins/Downloaded/Add Plugins which allows the .nbm (the Netbeans distribution files or Netbeans Modules files) to be incorporated in our 'User Installed Plugins) section. The latter option is the one you need to use if you are downloading a zip file from the Sun's site with the appropriate plugin and want to include it in your environment.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I recall an interview of Leo Apotheker (SAPS's ex-CEO) at Charlie Rose last year where he surmised that SAP may even get in the business of producing hardware devices. The rationale was that the software could easily integrate into remotely monitoring utilities meters and other devices and as BI Accelerator shows that the marriage is inevitable in many cases. Whilst there is feverish speculation on the direction of Java, MySql, OpenOffice etc under the aegis of Oracle, it may well be that it is the hardware/software marriage which underpins the acquisition. But it is hard to remain sanguine about these technologies future under a profit-driven acquisitor like Oracle. The Netbeans tools mentioned above may have gained temporary life while Oracle rationalises their product portfolio. So let us temporarily enjoy their availability whilst there are transitional uncertainties.&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-8782815338861623189?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/8782815338861623189/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/return-of-some-useful-plugins-in.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/8782815338861623189?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/8782815338861623189?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/return-of-some-useful-plugins-in.html" title="Return of some useful plugins in Netbeans6.9" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUQMSH47eyp7ImA9WxBbFko.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-2843909308032779644</id><published>2010-03-15T08:30:00.000-07:00</published><updated>2010-03-15T10:16:29.003-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-15T10:16:29.003-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Web service" /><category scheme="http://www.blogger.com/atom/ns#" term="Netbeans" /><title>Creating and consuming a web service using Netbeans</title><content type="html">&lt;div style="text-align: left;"&gt;Here are the steps for creating a simple service which allows two numbers to be multiplied:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;create a new web application project called MultiplyApp (File/New project/Java Web/Web Application)&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Click on the MultiplyApp node in the project and add a new web service called MultiplyWS (new/Web Service and type MultiplyWS as the Web Service Name and raj as the Package)&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Expand the new created Web Services folder and look at the source of MultiplyWS. The default skeleton code should be showing error on MultiplyWS class as it has no operation as yet.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Right click within the class definition and define the multiply operation with long return type and two int type parameters i and j (insert Code/Add Web Service Operation)&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;img src="http://2.bp.blogspot.com/_mrFFpG3NgK0/S55ZzmyvU2I/AAAAAAAAACE/RQrCv78HlMs/s400/ws.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5448891342286443362" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 300px; " /&gt;&lt;/span&gt; &lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Change the MultiplyWS. java code from return 0; to return i * j;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Right click on the MultiplyApp node and select Deploy to deploy the web service.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Right click on MultiplyWS in Web Service folder and select Test Web Service to see the service behaviour.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Right click on MultiplyApp and select Properties and then choose Run category and change the relative path to /MultiplyWSService?Tester&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;At this stage our service is ready but we need service consumers which can be any Java application, a servlet or a JSP. We cover the steps for the Java application in some detail but the process for creating a JSP or servlet consumer follows the same pattern.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Create a new Java application project called MultiplyClient (File/New Project/Java/Java Application). Leave the Create Main Class box checked while creating.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Right click on the project name MultiplyClient and create new web service client (New/Web Service Client). Select the MultiplyWS service in Project by using Browse.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;img src="http://4.bp.blogspot.com/_mrFFpG3NgK0/S55ihCvDaQI/AAAAAAAAACU/A6J0HoSbdBM/s400/ws2.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5448900918974310658" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 268px; " /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Right click within main method of our Main.java class and select Insert Code/Call Web Service Operation and choose multiply from the available web service references.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Set the values of i and j and add in a code to print exception if you want.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Run the project and verify that the console printed the correct multiplication of i and j variables which we set in the previous step.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;The process for creating the JSP or servlet-based client is the same, barring the fact that when we create a new project we choose File/New Project/Java Web/Web Application. We go through all the steps as above but we add the logic in a new servlet or a JSP and set the relative path in the project/properties/run  accordingly to make these the entry points. Obviously the syntactic changes would be there to reflect that we are dealing with a servlet or a JSP when Insert Code/Call Web Service Operation happens. The only point worth mentioning is that the multiply operation can be dragged from the Web Service References to the appropriate point in the code to auto-generate the appropriate logic for the service call at that point. Thus for JSP we get this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;img src="http://2.bp.blogspot.com/_mrFFpG3NgK0/S55rQdhEVgI/AAAAAAAAACc/VF5rS_XeS0U/s400/ws3.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5448910529710282242" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 288px; " /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Experiment and enjoy! &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;br /&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;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-2843909308032779644?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/2843909308032779644/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/creating-and-consuming-web-service.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/2843909308032779644?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/2843909308032779644?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/creating-and-consuming-web-service.html" title="Creating and consuming a web service using Netbeans" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_mrFFpG3NgK0/S55ZzmyvU2I/AAAAAAAAACE/RQrCv78HlMs/s72-c/ws.JPG" height="72" width="72" /><thr:total>4</thr:total></entry><entry gd:etag="W/&quot;DU8GQ3k_eCp7ImA9WxBbFUg.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-7108612326805234464</id><published>2010-03-14T00:33:00.000-08:00</published><updated>2010-03-14T01:10:22.740-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-14T01:10:22.740-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="Command design pattern" /><title>Command design pattern</title><content type="html">&lt;div&gt;The command pattern basically has client, command, invoker and the receiver. The pattern encapsulates request (command)  as an object. It decouples the client from the receiver. The requests are defined through concrete commands which encapsulate the receiver and implement the command interface containing a single execute() method in it. It uses an invoker with a standardised interface (execute())  to invoke the request on the receiver. The invoker has no knowledge of the receiver. The concrete command it invokes knows about the receiver, the action to invoke on it and the parameters to be passed to it. We are basically issuing requests to objects without knowing anything about the receiver of the object or the method being invoked on it.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We will illustrate it with an example whose UML is in Fig1.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src="http://3.bp.blogspot.com/_mrFFpG3NgK0/S5yilX9fUII/AAAAAAAAAB8/iFPBmxV90ZM/s320/command.jpg" /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The walk through the example is self-explanatory.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;package raj;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;public class TestCommand {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public static void main(String[] arg) {&lt;/div&gt;&lt;div&gt;        // First illustrate the tight coupling of Horse class&lt;/div&gt;&lt;div&gt;        Horse horse = new Horse();&lt;/div&gt;&lt;div&gt;        horse.eat();&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;        /* Obviously we could do this with other classes too&lt;/div&gt;&lt;div&gt;         * but we want to decouple the receiver of the action&lt;/div&gt;&lt;div&gt;         * from the client using action commands invoked by an&lt;/div&gt;&lt;div&gt;         * intermediary, the Invoker.&lt;/div&gt;&lt;div&gt;         */&lt;/div&gt;&lt;div&gt;        // create the command we want to invoke&lt;/div&gt;&lt;div&gt;        Command command = new EatCommand(new Horse());&lt;/div&gt;&lt;div&gt;        // create the invoker&lt;/div&gt;&lt;div&gt;        Invoker invoker = new Invoker();&lt;/div&gt;&lt;div&gt;        // Tell the invoker about the command we want to execute&lt;/div&gt;&lt;div&gt;        invoker.setCommand(command);&lt;/div&gt;&lt;div&gt;        // execute the EatCommand via the invoker&lt;/div&gt;&lt;div&gt;        invoker.execute();&lt;/div&gt;&lt;div&gt;        // change the animal to tiger and execute&lt;/div&gt;&lt;div&gt;        command = new EatCommand(new Tiger());&lt;/div&gt;&lt;div&gt;        invoker.setCommand(command);&lt;/div&gt;&lt;div&gt;        invoker.execute();&lt;/div&gt;&lt;div&gt;        // illustrate how we can do no action&lt;/div&gt;&lt;div&gt;        invoker.setCommand(new NoCommand());&lt;/div&gt;&lt;div&gt;        invoker.execute();&lt;/div&gt;&lt;div&gt;        // create a different type of command on a different class&lt;/div&gt;&lt;div&gt;        // illustrate the action can do multiple things&lt;/div&gt;&lt;div&gt;        invoker.setCommand(new ExamineCommand(new Vet()));&lt;/div&gt;&lt;div&gt;        invoker.execute();&lt;/div&gt;&lt;div&gt;        // pass parameters to command&lt;/div&gt;&lt;div&gt;        invoker.setCommand(new PaperWorkCommand(new Clerk(), "Efficienly"));&lt;/div&gt;&lt;div&gt;        invoker.execute();&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;interface Command {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void execute();&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class Invoker implements Command {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    Command command;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void execute() {&lt;/div&gt;&lt;div&gt;        command.execute();&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void setCommand(Command command) {&lt;/div&gt;&lt;div&gt;        this.command = command;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class NoCommand implements Command {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void execute() {&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class EatCommand implements Command {&lt;/div&gt;&lt;div&gt;    /* the key thing is that the command knows about the receiver&lt;/div&gt;&lt;div&gt;     * (contains Animal in this case)&lt;/div&gt;&lt;div&gt;     * and the type of action to take on it (run eat() method)&lt;/div&gt;&lt;div&gt;     */&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    Animal animal;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    EatCommand(Animal animal) {&lt;/div&gt;&lt;div&gt;        this.animal = animal;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void execute() {&lt;/div&gt;&lt;div&gt;        animal.eat();&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class ExamineCommand implements Command {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    Vet vet;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    ExamineCommand(Vet vet) {&lt;/div&gt;&lt;div&gt;        this.vet = vet;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void execute() {&lt;/div&gt;&lt;div&gt;        vet.openSurgery();&lt;/div&gt;&lt;div&gt;        vet.examine();&lt;/div&gt;&lt;div&gt;        vet.closeSurgery();&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class PaperWorkCommand implements Command {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    Clerk clerk;&lt;/div&gt;&lt;div&gt;    String efficiency;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    PaperWorkCommand(Clerk clerk, String efficiency) {&lt;/div&gt;&lt;div&gt;        this.clerk = clerk;&lt;/div&gt;&lt;div&gt;        this.efficiency = efficiency;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void execute() {&lt;/div&gt;&lt;div&gt;        clerk.pushPaper(efficiency);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class Animal {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void eat() {&lt;/div&gt;&lt;div&gt;        System.out.println("Eating generically");&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class Horse extends Animal {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void eat() {&lt;/div&gt;&lt;div&gt;        System.out.println("Eating grass");&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class Tiger extends Animal {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void eat() {&lt;/div&gt;&lt;div&gt;        System.out.println("Eating meat");&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void attack() {&lt;/div&gt;&lt;div&gt;        System.out.println("Killing a prey");&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class Vet {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void examine() {&lt;/div&gt;&lt;div&gt;        System.out.println("Examine an animal");&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void openSurgery() {&lt;/div&gt;&lt;div&gt;        System.out.println("Surgery opened");&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void closeSurgery() {&lt;/div&gt;&lt;div&gt;        System.out.println("Surgery closed");&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class Clerk {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void pushPaper(String efficiency) {&lt;/div&gt;&lt;div&gt;        System.out.println("Doing paperwork " + efficiency);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Note that &lt;a href="http://itis-consultants.blogspot.com/2010/03/strategy-design-pattern.html"&gt;strategy pattern &lt;/a&gt; had also encapsulated behaviour.&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;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-7108612326805234464?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/7108612326805234464/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/command-design-pattern.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/7108612326805234464?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/7108612326805234464?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/command-design-pattern.html" title="Command design pattern" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_mrFFpG3NgK0/S5yilX9fUII/AAAAAAAAAB8/iFPBmxV90ZM/s72-c/command.jpg" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C0EAQXg8eyp7ImA9WxBbFUw.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-4740786795489801013</id><published>2010-03-13T11:20:00.001-08:00</published><updated>2010-03-13T12:20:40.673-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-13T12:20:40.673-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Publisher-Subscriber pattern" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="Observer design pattern" /><title>Observer design pattern (Publisher-Subscriber)</title><content type="html">The use of observer design pattern is ubiquitous in Java. We just have to consider Swing classes, GUI frameworks, RMI, JavaBeans etc to note its pervasive nature. Whenever a component registers for an action event, it is using the Observer pattern. The straightforward principle is that whenever multiple parties (observers) are interested in the changes of state of an object (subject/observable) then they subscribe for the notification of changes. The observable object monitors its state and on observing relevant change in its state, it notifies all the interested parties through a common update() interface. The subject provides methods for the subscription and un-subscription. Obviously, the subject can either push all the changes to the observers or allow the observers to pull the changes on notification through provides API. The key is that the subject and the observers are loosely coupled, as the subject has no knowledge of the observers.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Our sample program clearly illustrate the principle.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;package raj;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;import java.util.ArrayList;&lt;/div&gt;&lt;div&gt;import java.util.List;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;public class TestObserver {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public static void main(String[] arg) {&lt;/div&gt;&lt;div&gt;        // create the subject we are interested in subscribing&lt;/div&gt;&lt;div&gt;        Subject subject = new Subject();&lt;/div&gt;&lt;div&gt;        // create the subscriber for the subject&lt;/div&gt;&lt;div&gt;        Bar interestedObserver = new Bar();&lt;/div&gt;&lt;div&gt;        // add subscribers&lt;/div&gt;&lt;div&gt;        subject.addObserver(new Foo());&lt;/div&gt;&lt;div&gt;        subject.addObserver(new Bar());&lt;/div&gt;&lt;div&gt;        subject.addObserver(interestedObserver);&lt;/div&gt;&lt;div&gt;        // subject state changes; the observers notified&lt;/div&gt;&lt;div&gt;        subject.stateChange();&lt;/div&gt;&lt;div&gt;        // unsubscribe&lt;/div&gt;&lt;div&gt;        subject.removeObserver(interestedObserver);&lt;/div&gt;&lt;div&gt;        // check the unsubscribed party doesn't get further notification&lt;/div&gt;&lt;div&gt;        subject.stateChange();&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class Subject {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    List&lt;observer&gt; observerList = new ArrayList&lt;observer&gt;();&lt;/observer&gt;&lt;/observer&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void addObserver(Observer o) {&lt;/div&gt;&lt;div&gt;        observerList.add(o);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void removeObserver(Observer o) {&lt;/div&gt;&lt;div&gt;        int index = observerList.indexOf(o);&lt;/div&gt;&lt;div&gt;        if (index &gt;= 0) {&lt;/div&gt;&lt;div&gt;            observerList.remove(index);&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void notifyObservers() {&lt;/div&gt;&lt;div&gt;        for (Observer o : observerList) {&lt;/div&gt;&lt;div&gt;            o.update("change");&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void stateChange() {&lt;/div&gt;&lt;div&gt;        notifyObservers();&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;interface Observer {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void update(String message);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class Foo implements Observer {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void update(String message) {&lt;/div&gt;&lt;div&gt;        System.out.println("Foo: " + message);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class Bar implements Observer {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void update(String message) {&lt;/div&gt;&lt;div&gt;        System.out.println("Bar: " + message);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We have opted for push technique in our example but it could be more appropriate to use pull as it allows the observer more flexibility in responding to the change.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Also it is worth noticing that Java provides its own implementation of Observer and Observable in the java.util package so the above sample could have been codes as:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;import java.util.Observable;&lt;/div&gt;&lt;div&gt;import java.util.Observer;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;public class JavaObserver extends Observable {&lt;/div&gt;&lt;div&gt;  private String message;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;  public String getMessage() {&lt;/div&gt;&lt;div&gt;    return message;&lt;/div&gt;&lt;div&gt;  }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;  public void stateChange(String message) {&lt;/div&gt;&lt;div&gt;    this.message = message;&lt;/div&gt;&lt;div&gt;    setChanged(); // signifies state change&lt;/div&gt;&lt;div&gt;    notifyObservers(message);&lt;/div&gt;&lt;div&gt;// the line below is for 'pull' as we pass the object so getMessage() can be invoked&lt;/div&gt;&lt;div&gt;// notifyObservers(this);&lt;/div&gt;&lt;div&gt;  }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;  public static void main(String[] args) {&lt;/div&gt;&lt;div&gt;    JavaObserver subject = new JavaObserver();&lt;/div&gt;&lt;div&gt;    Baz bar = new Baz();&lt;/div&gt;&lt;div&gt;    Baz baz = new Baz();&lt;/div&gt;&lt;div&gt;    Baz foo = new Baz();&lt;/div&gt;&lt;div&gt;    subject.addObserver(foo);&lt;/div&gt;&lt;div&gt;    subject.addObserver(bar);&lt;/div&gt;&lt;div&gt;    subject.addObserver(baz);&lt;/div&gt;&lt;div&gt;    subject.stateChange("Change!");&lt;/div&gt;&lt;div&gt;  }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class Baz implements Observer {&lt;/div&gt;&lt;div&gt;  public void update(Observable o, Object message) {&lt;/div&gt;&lt;div&gt;    System.out.println("Baz: " + message); // push&lt;/div&gt;&lt;div&gt;// the line below is for 'pull'&lt;/div&gt;&lt;div&gt;//  System.out.println("Baz: " + ((JavaObserver) message).getMessage());&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;  }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The key restriction of the Java built-in functionality is that we have to extend the Observable class so there is no way extending JavaObserver from any other class.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&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;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&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;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-4740786795489801013?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/4740786795489801013/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/observer-design-pattern.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/4740786795489801013?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/4740786795489801013?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/observer-design-pattern.html" title="Observer design pattern (Publisher-Subscriber)" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkIHSHw4eip7ImA9WxBbFEU.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-1599035344839208799</id><published>2010-03-13T05:17:00.000-08:00</published><updated>2010-03-13T05:55:39.232-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-13T05:55:39.232-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVC" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="design pattern" /><title>Model-View-Controller (MVC) pattern</title><content type="html">The MVC architectural pattern is the bedrock of technologies like JavaServer Faces and is fundamental to implementing three-tier architecture. It clearly segregates the model in the business layer, view in the presentation layer and the controller, which handles all the inputs affecting the model. Obviously if the model is totally segregated then it becomes relatively easier to test the domain logic with automated tools. We can illustrate this decoupling of model and view through a simple calculator application which takes two numbers and applies the requested operator to provide the result.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_mrFFpG3NgK0/S5uYTaepLlI/AAAAAAAAAB0/4InaZo_m4ng/s1600-h/calculator.JPG"&gt;&lt;img src="http://4.bp.blogspot.com/_mrFFpG3NgK0/S5uYTaepLlI/AAAAAAAAAB0/4InaZo_m4ng/s320/calculator.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5448115633527533138" style="cursor: pointer; width: 320px; height: 54px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;package mvc;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;import java.awt.event.ActionEvent;&lt;/div&gt;&lt;div&gt;import javax.swing.*;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;public class MvcTest {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    private static void buildUI() {&lt;/div&gt;&lt;div&gt;        MvcModel model = new MvcModel();&lt;/div&gt;&lt;div&gt;        MvcView view = new MvcView();&lt;/div&gt;&lt;div&gt;        MvcControl control = new MvcControl("Result", view, model);&lt;/div&gt;&lt;div&gt;        view.setControl(control);&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;        JFrame frame = new JFrame("Test Calculator");&lt;/div&gt;&lt;div&gt;        frame.getContentPane().add(view.getMainPanel());&lt;/div&gt;&lt;div&gt;        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;/div&gt;&lt;div&gt;        frame.pack();&lt;/div&gt;&lt;div&gt;        frame.setLocationRelativeTo(null);&lt;/div&gt;&lt;div&gt;        frame.setVisible(true);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public static void main(String[] args) {&lt;/div&gt;&lt;div&gt;        java.awt.EventQueue.invokeLater(new Runnable() {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;            public void run() {&lt;/div&gt;&lt;div&gt;                buildUI();&lt;/div&gt;&lt;div&gt;            }&lt;/div&gt;&lt;div&gt;        });&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class MvcView {&lt;/div&gt;&lt;div&gt;    // mainPanel holds all the GUI components&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    private JPanel mainPanel = new JPanel();&lt;/div&gt;&lt;div&gt;    // two input fields and the result textfield&lt;/div&gt;&lt;div&gt;    private JTextField firstOperand = new JTextField(10);&lt;/div&gt;&lt;div&gt;    private JTextField operator = new JTextField(1);&lt;/div&gt;&lt;div&gt;    private JTextField secondOperand = new JTextField(10);&lt;/div&gt;&lt;div&gt;    private JTextField resultField = new JTextField(10);&lt;/div&gt;&lt;div&gt;    private JButton addButton = new JButton();&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public MvcView() {&lt;/div&gt;&lt;div&gt;        resultField.setEditable(false);&lt;/div&gt;&lt;div&gt;        operator.setText("+"); // default to add&lt;/div&gt;&lt;div&gt;        mainPanel.add(firstOperand);&lt;/div&gt;&lt;div&gt;        mainPanel.add(operator);&lt;/div&gt;&lt;div&gt;        mainPanel.add(secondOperand);&lt;/div&gt;&lt;div&gt;        mainPanel.add(new JLabel("="));&lt;/div&gt;&lt;div&gt;        mainPanel.add(resultField);&lt;/div&gt;&lt;div&gt;        mainPanel.add(addButton);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void setControl(MvcControl control) {&lt;/div&gt;&lt;div&gt;        addButton.setAction(control);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public JPanel getMainPanel() {&lt;/div&gt;&lt;div&gt;        return mainPanel;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public String getFirstOperandText() {&lt;/div&gt;&lt;div&gt;        return firstOperand.getText();&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public String getSecondOperandText() {&lt;/div&gt;&lt;div&gt;        return secondOperand.getText();&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public String getOperatorText() {&lt;/div&gt;&lt;div&gt;        return operator.getText();&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void setResultText(String text) {&lt;/div&gt;&lt;div&gt;        resultField.setText(text);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class MvcControl extends AbstractAction {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    private MvcModel model;&lt;/div&gt;&lt;div&gt;    private MvcView view;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public MvcControl(String text, MvcView view, MvcModel model) {&lt;/div&gt;&lt;div&gt;        super(text);&lt;/div&gt;&lt;div&gt;        this.view = view;&lt;/div&gt;&lt;div&gt;        this.model = model;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void actionPerformed(ActionEvent e) {&lt;/div&gt;&lt;div&gt;        view.setResultText(""); // clear the result &lt;/div&gt;&lt;div&gt;        try {&lt;/div&gt;&lt;div&gt;            double op1 = Double.parseDouble(view.getFirstOperandText());&lt;/div&gt;&lt;div&gt;            double op2 = Double.parseDouble(view.getSecondOperandText());&lt;/div&gt;&lt;div&gt;            char operator = view.getOperatorText().charAt(0);&lt;/div&gt;&lt;div&gt;            if (operator == '+'&lt;/div&gt;&lt;div&gt;                    || operator == '-'&lt;/div&gt;&lt;div&gt;                    || operator == '*'&lt;/div&gt;&lt;div&gt;                    || operator == 'x'&lt;/div&gt;&lt;div&gt;                    || operator == 'X'&lt;/div&gt;&lt;div&gt;                    || operator == '/'&lt;/div&gt;&lt;div&gt;                    || operator == '%') {}&lt;/div&gt;&lt;div&gt;            else throw new IllegalArgumentException();&lt;/div&gt;&lt;div&gt;            double result = model.doOperation(op1, op2, operator); // use the model here&lt;/div&gt;&lt;div&gt;            view.setResultText(String.valueOf(result));&lt;/div&gt;&lt;div&gt;        } catch (NumberFormatException nfe) {&lt;/div&gt;&lt;div&gt;            JOptionPane.showMessageDialog(view.getMainPanel(), "Only Numbers Allowed",&lt;/div&gt;&lt;div&gt;                    "Data Error", JOptionPane.ERROR_MESSAGE);&lt;/div&gt;&lt;div&gt;        } catch (IllegalArgumentException nfe) {&lt;/div&gt;&lt;div&gt;            JOptionPane.showMessageDialog(view.getMainPanel(), "The operator must be one of *, /, +, - or %",&lt;/div&gt;&lt;div&gt;                    "Data Error", JOptionPane.ERROR_MESSAGE);&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class MvcModel {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public double doOperation(double op1, double op2, char operator) {&lt;/div&gt;&lt;div&gt;        double result = 0;&lt;/div&gt;&lt;div&gt;        switch (operator) {&lt;/div&gt;&lt;div&gt;            case '+':&lt;/div&gt;&lt;div&gt;                result = op1 + op2;&lt;/div&gt;&lt;div&gt;                break;&lt;/div&gt;&lt;div&gt;            case '-':&lt;/div&gt;&lt;div&gt;                result = op1 - op2;&lt;/div&gt;&lt;div&gt;                break;&lt;/div&gt;&lt;div&gt;            case '*':&lt;/div&gt;&lt;div&gt;            case 'x':&lt;/div&gt;&lt;div&gt;            case 'X':&lt;/div&gt;&lt;div&gt;                result = op1 * op2;&lt;/div&gt;&lt;div&gt;                break;&lt;/div&gt;&lt;div&gt;            case '/':&lt;/div&gt;&lt;div&gt;                result = op1 / op2;&lt;/div&gt;&lt;div&gt;                break;&lt;/div&gt;&lt;div&gt;            case '%':&lt;/div&gt;&lt;div&gt;                result = op1 % op2;&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;        return result;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It is clear in our example that the view (MvcView)  is the user interface which asks for two operands and the mathematical operation to apply on them. Model (MvcModel) is passed these inputs by the controller (MvcController) to get the calculation result. In our design the view has no knowledge of the model and the controller is an observer of the action performed on the 'result' button in the view. The controller uses its knowledge of the view to update the result. Thus a clear segregation of roles has been achieved. Obviously an application can have a number of these MVC triplets.&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;br /&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;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-1599035344839208799?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/1599035344839208799/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/model-view-controller-mvc-pattern.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/1599035344839208799?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/1599035344839208799?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/model-view-controller-mvc-pattern.html" title="Model-View-Controller (MVC) pattern" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_mrFFpG3NgK0/S5uYTaepLlI/AAAAAAAAAB0/4InaZo_m4ng/s72-c/calculator.JPG" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEEFRXgzfSp7ImA9WxBbFEs.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-8438725496316990662</id><published>2010-03-12T03:41:00.000-08:00</published><updated>2010-03-12T22:43:34.685-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-12T22:43:34.685-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Factory Design Pattern" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Factory design pattern</title><content type="html">Let us give ourselves godlike powers and create a factory to produce animals. The basic structure for such a factory would look like:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;package raj;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;/**&lt;/div&gt;&lt;div&gt; * @author Rajeev&lt;/div&gt;&lt;div&gt; */&lt;/div&gt;&lt;div&gt;public class AnimalFactory {&lt;/div&gt;&lt;div&gt;     private String animalType;&lt;/div&gt;&lt;div&gt;     AnimalFactory(String animalType) {&lt;/div&gt;&lt;div&gt;     this.animalType = animalType;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;     public Animal createAnimal() {&lt;/div&gt;&lt;div&gt;         if (animalType.equals("Dog")) return new Dog();&lt;/div&gt;&lt;div&gt;        else if (animalType.equals("Cat")) return new Cat();&lt;/div&gt;&lt;div&gt;        else if (animalType.equals("Donkey")) return new Donkey();&lt;/div&gt;&lt;div&gt;        else if (animalType.equals("Horse")) return new Horse();&lt;/div&gt;&lt;div&gt;        else return new Animal();&lt;/div&gt;&lt;div&gt;     }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;class Animal {public String toString(){return "Animal";}}&lt;/div&gt;&lt;div&gt;class Dog extends Animal {public String toString(){return "Dog";}}&lt;/div&gt;&lt;div&gt;class Cat extends Animal {public String toString(){return "Cat";}}&lt;/div&gt;&lt;div&gt;class Donkey extends Animal {public String toString(){return "Donkey";}}&lt;/div&gt;&lt;div&gt;class Horse extends Animal {public String toString(){return "Horse";}}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;It allows us to create an animal of a type which the factory has been geared to produce. We can test it with:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;package raj;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;/**&lt;/div&gt;&lt;div&gt; * @author Rajeev&lt;/div&gt;&lt;div&gt; */&lt;/div&gt;&lt;div&gt;public class TestFactory {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public static void main(String[] arg) {&lt;/div&gt;&lt;div&gt;        // create factories&lt;/div&gt;&lt;div&gt;        AnimalFactory horseFactory = new AnimalFactory("Horse");&lt;/div&gt;&lt;div&gt;        AnimalFactory dogFactory = new AnimalFactory("Dog");&lt;/div&gt;&lt;div&gt;        AnimalFactory catFactory = new AnimalFactory("Cat");&lt;/div&gt;&lt;div&gt;        AnimalFactory donkeyFactory = new AnimalFactory("Donkey");&lt;/div&gt;&lt;div&gt;        AnimalFactory animalFactory = new AnimalFactory("");&lt;/div&gt;&lt;div&gt;        // create horses&lt;/div&gt;&lt;div&gt;        Animal animal = horseFactory.createAnimal();&lt;/div&gt;&lt;div&gt;        Animal animal2 = horseFactory.createAnimal();&lt;/div&gt;&lt;div&gt;        System.out.printf("We are type %s %s%n",animal,animal2);&lt;/div&gt;&lt;div&gt;        // create dogs&lt;/div&gt;&lt;div&gt;        animal = dogFactory.createAnimal();&lt;/div&gt;&lt;div&gt;        animal2 = dogFactory.createAnimal();&lt;/div&gt;&lt;div&gt;        System.out.printf("We are type %s %s%n",animal,animal2);&lt;/div&gt;&lt;div&gt;        // create cats&lt;/div&gt;&lt;div&gt;        animal = catFactory.createAnimal();&lt;/div&gt;&lt;div&gt;        animal2 = catFactory.createAnimal();&lt;/div&gt;&lt;div&gt;        System.out.printf("We are type %s %s%n",animal,animal2);&lt;/div&gt;&lt;div&gt;        // create donkeys&lt;/div&gt;&lt;div&gt;        animal = donkeyFactory.createAnimal();&lt;/div&gt;&lt;div&gt;        animal2 = donkeyFactory.createAnimal();&lt;/div&gt;&lt;div&gt;        System.out.printf("We are type %s %s%n",animal,animal2);&lt;/div&gt;&lt;div&gt;        // create animals&lt;/div&gt;&lt;div&gt;        animal = animalFactory.createAnimal();&lt;/div&gt;&lt;div&gt;        animal2 = animalFactory.createAnimal();&lt;/div&gt;&lt;div&gt;        System.out.printf("We are type %s %s%n",animal,animal2);&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now if we decide to produce 'sheep' in future or make a species extinct then all we have to do is to alter the Factory class to incorporate this new requirement at one central place. A demigod could be allocated a particular factory type now and he can happily go on churning objects of that particular species. This programming idiom is useful but not the Factory method pattern defined by GoF. Our current UML diagram is shown in Fig 1.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qd4lU2QFI/AAAAAAAAABA/7eKQcuZpO3I/s320/factory.jpg" /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The GoF Factory method design pattern would alter the diagram to Fig 2.&lt;/div&gt;&lt;div&gt;&lt;img src="http://4.bp.blogspot.com/_mrFFpG3NgK0/S5qiW2Kw9rI/AAAAAAAAABI/ems_UZ5vzw8/s320/factory2.jpg" /&gt;&lt;/div&gt;&lt;div&gt;With this variation, the TestFactory client is totally isolated from the realisation of the factory and its products (the concrete Animal). In this approach the client talks to the abstract interfaces which delegate the actual implementation to their subclasses. Our code changes accordingly to make this possible.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;package raj;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;public class TestFactoryFM {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public static void main(String[] arg) {&lt;/div&gt;&lt;div&gt;        // create factory&lt;/div&gt;&lt;div&gt;        AnimalFactoryIF horseFactory = new AnimalFactory("Horse");&lt;/div&gt;&lt;div&gt;        // create horses&lt;/div&gt;&lt;div&gt;        AnimalIF animal = horseFactory.createAnimal();&lt;/div&gt;&lt;div&gt;        AnimalIF animal2 = horseFactory.createAnimal();&lt;/div&gt;&lt;div&gt;        System.out.printf("We are type %s %s%n",animal,animal2);}&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;abstract class AnimalFactoryIF {abstract public AnimalIF createAnimal();}&lt;/div&gt;&lt;div&gt;class AnimalFactory extends AnimalFactoryIF {&lt;/div&gt;&lt;div&gt;     private String animalType;&lt;/div&gt;&lt;div&gt;     AnimalFactory(String animalType) {&lt;/div&gt;&lt;div&gt;     this.animalType = animalType;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;     public AnimalIF createAnimal() {&lt;/div&gt;&lt;div&gt;     if (animalType.equals("Dog")) return new Dog();&lt;/div&gt;&lt;div&gt;     else if (animalType.equals("Cat")) return new Cat();&lt;/div&gt;&lt;div&gt;     else if (animalType.equals("Donkey")) return new Donkey();&lt;/div&gt;&lt;div&gt;     else if (animalType.equals("Horse")) return new Horse();&lt;/div&gt;&lt;div&gt;     else return new Animal();&lt;/div&gt;&lt;div&gt;     }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;abstract class AnimalIF { abstract public String toString();};&lt;/div&gt;&lt;div&gt;class Animal extends AnimalIF {public String toString(){return "Animal";}}&lt;/div&gt;&lt;div&gt;class Dog extends Animal {public String toString(){return "Dog";}}&lt;/div&gt;&lt;div&gt;class Cat extends Animal {public String toString(){return "Cat";}}&lt;/div&gt;&lt;div&gt;class Donkey extends Animal {public String toString(){return "Donkey";}}&lt;/div&gt;&lt;div&gt;class Horse extends Animal {public String toString(){return "Horse";}}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hitherto, in our approach we have one-to-one relationship between the AnimalIF and its subclass and the FactoryIF and its subclass. However, the power of the approach becomes apparent if subclass our FactoryIF with another factory, SpecialFactory, which produces superior quality animals, SpecialAnimal, which are a subclass of the AnimalIF. The client is built to an interface and is totally unaware of the type of animal it is dealing with. Unsurprisingly, the Factory method design is used frequently in frameworks.&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-8438725496316990662?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/8438725496316990662/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/factory-design-pattern.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/8438725496316990662?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/8438725496316990662?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/factory-design-pattern.html" title="Factory design pattern" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qd4lU2QFI/AAAAAAAAABA/7eKQcuZpO3I/s72-c/factory.jpg" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkYGQ349fip7ImA9WxBbE0Q.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-1905049455677482392</id><published>2010-03-12T02:01:00.000-08:00</published><updated>2010-03-12T02:35:22.066-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-12T02:35:22.066-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SCJP" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Compilation failures one should know in Java</title><content type="html">&lt;div&gt;Those of you who are preparing for SCJP are aware that nearly every question has 'compilation will fail' as an option. Here is a short random list of the compilation failures one should watch out for. No list of this nature can be comprehensive but it does include many useful hints.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;while (false) {} // immediate error on the line&lt;/div&gt;&lt;div&gt;while (true) {}; // immediate error on the line following the loop&lt;/div&gt;&lt;div&gt;but  while (true) {break;}&lt;/div&gt;&lt;div&gt;        System.out.println(""); will compile.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;throw new RuntimeException; // the line following is unreachable&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;go(1) when go(short i); // cannot down cast int to short have to say go((short) 1)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;assert (): go(); where void go() // need a string and cannot have void&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;final X f = new X(); and then f=null; // cannot assign anything to reference&lt;/div&gt;&lt;div&gt;final int x=5; then x++ // especially with interface constants&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;importing static from a different package whose access is defined as default&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We can define unused variables. It is not a compilation failure but just like unused imports.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;switch case has a non-compile time literal (ie  it is not defined and initiated final on the same line. It is not good enough to declare it as final on one line and then initialize it on the next).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can't change the return type of overridden method, if return is int in parent then can't return Integer or short in the child. The temptation because of covariant returns is that it may be possible. An overridden method can return the child of a class defined in the parent. However it is a compile error to return parent to a child return type. If expecting Number m() return Integer; is fine, and Integer m() return Integer; is fine but Integer m() return Number; will not compile. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Calling super or instance from static block. Always ensure that an object exists in main before invocation of methods.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Using join, sleep or wait without handling InterruptedException or throwing InterrupedException from run(). The latter breaches the contract of Runnable interface by throwing an unexpected checked exception.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Method with no return type will not compile&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;new myrunnable().start will not compile. Has to be new Thread(myrunnable).start&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class X&lt;t&gt; is not correct nor is class &lt;/t&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;import static with just the class name fails&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There is no such thing as super.super to invoke parent's parent.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You cannot override a static method with a non-static or vice versa.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;try {} System.out.println("Here"); catch () {} will fail. No statements between try and catch.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;parse needs to catch ParseException&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;run() cannot throw InterruptedException // no checked exception can be thrown which interface didn't define&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;for(String s:aa) // declaration has to be within foreach and s should not have been declared before. However it is OK to have s being used in multiple foreach as each has just the local scope.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;assert 1 &gt; 2: go(); // will not compile if from within main or any static block if go() not static&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;inner classes cannot have static members so be wary of their definitions.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;import static java.lang.Integer.MAX_VALUE; then import static java.lang.Short.MAX_VALUE; as MAX_VALUE already defined.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;declaring enum in a method fails&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;void doMore() {throw new IOException) fails becuase checked exception must say doMaore() throws IOException&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If we catch Exception() then compiler won't allow any child of it to follow it. The order matters.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Putting long in switch expression, it can only be int or thing which can convert to in like char, byte, short&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;trying to use uninitialized local variable in a method or trying to prefix them with access modifier. Only valid modifier within method is final. Watch out for private int i = 5 in a method. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;enum outside class can not be marked static, final, abstract, private or protected. Within the class it can be marked static, private or protected but not abstract or final.&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;myenum xx= new myenum(); won't compile. Enums are just initialised.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Trying to cast char into a String. char is a primitive and String is an object so S = c fails.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Instance variables cannot be marked strictfp, native, synchronized, abstract. final and transient are fine.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Not having a proper main() method is a runtime error, not a compiler error!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;char c = -1; is illegal but char c = (char) -1 is OK. Char is unsigned integer literal with max value of 65535;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;byte a = 3; byte b = 2; but byte c = a + b; will not compile as the result is an int. However byte c = 3 +5 is OK as within range and the compiler knows.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;float f = 23.4; will not compile as 23.4 is a double. &lt;/div&gt;&lt;div&gt;A variable defined within the initialisation block is not visible to the program, ie {int j = 1;} j cannot be seen anywhere. Trying to use it later will not compile.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;int i = 5; static {i = 7;} will not work as i is non-static.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can't widen an Integer into a Long. The wrapper classes are different objects.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;if (5 &amp;amp;&amp;amp; 6) will not compile. The expression has to evaluate to boolean&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;if (x=6) is an illegal argument to if. It is just assigning. Can get away with this with boolean otherwise compile fails.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Integer i = new Integer(4); switch (i) is wrong if used as a case expression in switch statement.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;continue statements must be inside a loop; otherwise, you’ll get a compiler error. break statements must be used inside either a loop or switch statement.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Labelled continue and break statements must be inside the loop that has the same label name; otherwise, the code will not compile.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Object test() { return (Double) 2.7;} works  Object test() { return (Float) 2.7;} doesn't works 2.7 boxes to Double&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Short n = new Short((short) 3); without the cast it fails. However it is ok to say Short s = 555; Integer i = 1 etc as long as they are within range.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;More importantly it is fine to compare the incompatible wrapper types like Integer, Short etc with relational operators like greater than or greater than or equal to but not right to use ==. For relational comparisons of greater than, less than etc. it auto unboxes and doesn't complain.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;boolean equals(Object o) {return true;} doesn't compile. hashCode(), toString() too are PUBLIC methods. As they are without public modifier they are improper override.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Watch out for missing semicolon in the definition of anonymous inner class.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The compiler will complain if you try to invoke any method on an anonymous inner class reference that is not in the superclass class definition.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Beware of sticking static in front of run() it will not compile as being improper override.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The public access modifier is the only one that allows code from outside a package to access methods in a package regardless of inheritance. If we are overriding a method in a subclass in a different package then the method must be public.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;While using an interface from a different package, it must be declared public or we will not be able to use it. Just default package will not work.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-1905049455677482392?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/1905049455677482392/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/compilations-warning-one-should-know-in.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/1905049455677482392?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/1905049455677482392?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/compilations-warning-one-should-know-in.html" title="Compilation failures one should know in Java" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;D0UGSXgyfSp7ImA9WxBbE0U.&quot;"><id>tag:blogger.com,1999:blog-7261548585686045052.post-7446472193328058764</id><published>2010-03-12T00:39:00.000-08:00</published><updated>2010-03-12T01:13:48.695-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-12T01:13:48.695-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="Singleton design pattern" /><title>Singleton design pattern</title><content type="html">It is conceptually the simplest design pattern and many argue that it is actually an anti-pattern and continues to exist within computing courses because GoF specified it in their seminal work and it offers easy introduction to the subject of design patterns.  Controversial it may well be but it has a useful purpose when we do genuinely need just one object of a class. Obviously the logger is the primary example.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The design is simple:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;package raj;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;class TestSingleton {&lt;/div&gt;&lt;div&gt;    public static void main(String[] arg) {&lt;/div&gt;&lt;div&gt;        Singleton s = Singleton.getInstance();&lt;/div&gt;&lt;div&gt;        System.out.println(s.toString());&lt;/div&gt;&lt;div&gt;        s.setVal(100);&lt;/div&gt;&lt;div&gt;        Singleton s2 = Singleton.getInstance();&lt;/div&gt;&lt;div&gt;        System.out.println(s2.toString());&lt;/div&gt;&lt;div&gt;        System.out.println(s2.getVal());&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;public class Singleton {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    private static Singleton singletonObj;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    private Singleton() {&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;    private int val = 0;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public int getVal() {&lt;/div&gt;&lt;div&gt;        return val;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void setVal(int val) {&lt;/div&gt;&lt;div&gt;        this.val = val;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public static Singleton getInstance() {&lt;/div&gt;&lt;div&gt;        if (singletonObj == null) {&lt;/div&gt;&lt;div&gt;            singletonObj = new Singleton();&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;        return singletonObj;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It relies on having a private constructor and public static interface to provide the object. We can make this design thread-safe by synchronizing the getInstance() method:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt; public static synchronized Singleton getInstance() {&lt;/div&gt;&lt;div&gt;        if (singletonObj == null) {&lt;/div&gt;&lt;div&gt;            singletonObj = new Singleton();&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;        return singletonObj;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;However, this approach would considerably slow down the access to the object as synchronization can be painfully slow and is only needed during the first create. To over come this we may eschew lazy instantiation of the object and change our Singleton class to the following to let the class loader take the responsibility for instantiation:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;public class Singleton {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    private static Singleton singletonOb = new Singleton();j;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    private Singleton() {&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;    private int val = 0;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public int getVal() {&lt;/div&gt;&lt;div&gt;        return val;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public void setVal(int val) {&lt;/div&gt;&lt;div&gt;        this.val = val;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    public static Singleton getInstance() {&lt;/div&gt;&lt;div&gt;        return singletonObj;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This is great! But if the objected created is a scarce resource and is never used then it obviously is wasteful. A thread-safe compromise solution would be to use double-checked locking:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;public static Singleton getInstance() {&lt;/div&gt;&lt;div&gt;        if (singletonObj == null) {&lt;/div&gt;&lt;div&gt;            synchronized (Singleton.class) {&lt;/div&gt;&lt;div&gt;             if (singletonObj == null) singletonObj = new Singleton();&lt;/div&gt;&lt;div&gt;        }}&lt;/div&gt;&lt;div&gt;        return singletonObj;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now we take the synchronization hit just during the create but there is still a small overhead of an extra conditional check during every access. Also note that we cannot use synchronized(this) as we are locking from within a static context so need the class literal Singleton.class. &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7261548585686045052-7446472193328058764?l=itis-consultants.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://itis-consultants.blogspot.com/feeds/7446472193328058764/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/singleton-design-pattern.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/7446472193328058764?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7261548585686045052/posts/default/7446472193328058764?v=2" /><link rel="alternate" type="text/html" href="http://itis-consultants.blogspot.com/2010/03/singleton-design-pattern.html" title="Singleton design pattern" /><author><name>Rajeev Trikha</name><uri>http://www.blogger.com/profile/07435391398428608212</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="22" height="32" src="http://1.bp.blogspot.com/_mrFFpG3NgK0/S5qm0uiCP8I/AAAAAAAAABU/mvmm4lUWPXY/S220/raj.jpg" /></author><thr:total>0</thr:total></entry></feed>

