tag:blogger.com,1999:blog-57155598671507295672024-03-14T03:10:14.366+05:30Java 2 Enterprise EditionThis blog is for Java lovers specially oriented towards J2EE based development. Here I intend to discuss in detail concepts, design patterns and architectural best practices in great details.Rahul Choudharyhttp://www.blogger.com/profile/17198358035512759000noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-5715559867150729567.post-63475746019357633682009-08-16T02:04:00.001+05:302009-08-16T02:05:40.110+05:30Innovate with Google Maps and Google DocsHave you seen IT companies websites recently? They doesn't seems like they themselves are aware of the true potential of Web 2.0. Here are few tips and trick to use when (re)designing your company website.<br />
<br />
Company's Contact Us web page / Locate Us pages are simple static content with address. Hard to visualize and outdated, doesn't reflect company's diversity, even when the office addresses runs to the bottom of the page. You should, at that point, think back and check whether the website represents company's brand.<br />
<br />
Here is an example to spruce up the company's contact information. Company website is the first point of entry for a customer where he would like to visualize about company's capabilities to do certain things. What is far more amazing is that you doesn't need to be a Javascript or web designer guru to do this.<br />
<br />
<br />
<iframe frameborder="0" height="320" id="I1" scrolling="no" src="http://9tm49u91btpu7le36r63p2sj07eqiv5p.spreadsheets.gmodules.com/gadgets/ifr?up__table_query_url=https%3A%2F%2Fspreadsheets.google.com%2Ftq%3Frange%3DA1%253AB11%26headers%3D1%26key%3Dt8VdMVH5hQRVlQBqAs1EM9Q%26gid%3D0&up_title=CTE+Locations&up_show_tooltip=1&up_enable_wheel=1&up_map_type=hybrid&up__table_query_refresh_interval=300&url=http%3A%2F%2Fwww.google.com%2Fig%2Fmodules%2Fmap.xml&mid=1&nocache=1&synd=spreadsheets" style="border: 1px solid #cccccc;" width="450"></iframe><br />
<br />
Doing this was so simple in Google docs, that all I needed to do was to enter my fake company's address in one column and contact information in another (Okay, I cheated I used little bit of HTML to make contact information look good). Than I selected the range and told Google spreadsheet to insert a Google Map gadget. Once I am done customizing the gadget I asked for publishing URL and whoof!! I got this beautiful looking Google Map representing my company's location. I could have done far more innovation had I have been used Google Maps API.<br />
<br />
The possibilities are unlimited but you have to open your mind towards them.Rahul Choudharyhttp://www.blogger.com/profile/17198358035512759000noreply@blogger.com2tag:blogger.com,1999:blog-5715559867150729567.post-18893146480524210702009-08-04T00:29:00.000+05:302009-08-04T00:29:24.278+05:30Grails - A RAD framework<span style="font-family: Georgia, 'Times New Roman', serif;">During my quest to learn a new framework I stumbled upon Grails. I have heard about it very often but actually never dared to dive into it thinking that it might be yet another scripting framework like Ruby. But I was wrong and I must admit that I was mesmerized by what I saw (read it as "with What I achieved") in Grails. On the <a href="http://www.grails.org/">homepage of grails</a> it says "the search is over", its a bold statement to make, but quite frankly it will make you feel like it when you start discovering its power. </span><br />
<a href="http://3.bp.blogspot.com/_QUAGXITsdmM/SnczZ-YSCRI/AAAAAAAAFVU/XenKSlpsxLs/s1600-h/top_brandingv2.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://3.bp.blogspot.com/_QUAGXITsdmM/SnczZ-YSCRI/AAAAAAAAFVU/XenKSlpsxLs/s200/top_brandingv2.jpg" /></a><span style="font-family: Georgia;"><br />
</span><br />
<span style="font-family: Georgia;">It is actually what Java should have been if it would have been written in 21st Century. The ease with which it helps you handle MVC architecture is great but what is amazing is the ease with which it handles CRUD operations and performs things with "convention over configuration" approach.</span><br />
<span style="font-family: Georgia;"><br />
</span><br />
<span style="font-family: Georgia;">Long back I was wondering when a programming language be written which can understand plain simple English and performs the tasks. Grails does it and does it pretty good, no wonder it has developed so many followers. I mean who would not want to get away from reinventing the wheel all the time and just concentrate on building some lean mean applications.</span><br />
<span style="font-family: Georgia;"><br />
</span><br />
<span style="font-family: Georgia;">The Grails community is also shaping up pretty well with so many plugins supported each day, I can only assume that this is the next generation framework. Do check back after some time as I will be publishing my first hand experience on Grails very soon.</span>Rahul Choudharyhttp://www.blogger.com/profile/17198358035512759000noreply@blogger.com1San Diego, CA, USA32.718834 -117.16384132.429983 -117.63076000000001 33.007685 -116.696922tag:blogger.com,1999:blog-5715559867150729567.post-42638834314896607312009-06-26T01:39:00.004+05:302009-06-26T01:46:33.726+05:30CSS: Using every declaration just once<div>While surfing for best practices on Internet, I found this article on Google code site. It was an interesting article which was mostly directed towards web developer, but since j2ee deveoper also do some sort of web deveopment, I thought it will be a good idea to share with you guys.</div><div><br /></div><div>Author: Jens Meiert, Google Webmaster</div><div>Recommended experience: Working knowledge of CSS</div><div>Original Site: <a href="http://code.google.com/speed/articles/optimizing-css.html">http://code.google.com/speed/articles/optimizing-css.html</a></div><div><br /></div><div>A logical way to make your website faster is to make the client code you send to the browser smaller. When looking to optimize your CSS files, one of the most powerful measures you can employ is to use <b>every declaration just once</b>.</div><div><br /></div><div>Using every declaration just once means making strict use of<b> selector grouping</b>.</div><div><br /></div><div>For example, you can combine these rules:</div><div><br /></div><div><span class="Apple-style-span" style="font-family:'courier new';">h1 { color: black; }</span></div><div><span class="Apple-style-span" style="font-family:'courier new';">p { color: black; }</span></div><div><br /></div><div>into a single rule:</div><div><br /></div><div><span class="Apple-style-span" style="font-family:'courier new';">h1, p { color: black; }</span></div><div><br /></div><div>While this simple example appears almost obvious, things get more interesting and harder to quantify when talking about complex style sheets. In our experience, using every declaration just once can reduce the <b>CSS file size by 20-40%</b> on average.</div><div><br /></div><div>Let's have a look at another example:</div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" >h1, h2, h3 { font-weight: normal; }</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" >a strong { font-weight: normal !important; }</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" >strong { font-style: italic; font-weight: normal; }</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" >#nav { font-style: italic; }</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" >.note { font-style: italic; }</span></span></div><div><br /></div><div>Applying the "any declaration just once" rule here results in:</div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" >h1, h2, h3, strong { font-weight: normal; }</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" >a strong { font-weight: normal !important; }</span></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" >strong, #nav, .note { font-style: italic; }</span></span></div><div><br /></div><div>Note that the !important declaration makes a difference here. There are some things to keep in mind when applying this method:</div><div><br /></div><div><b>First</b>, overly long selectors can render this method useless. Repeating selectors like <b>html body table tbody tr td p span.example</b> in order to have unique declarations doesn't save much file size. In fact, since "using every declaration just once" might mean a higher number of selectors, this could even result in a bigger style sheet. Using more compact selectors would help, and would enhance the readability of your stylesheet.</div><div><br /></div><div><b>Second</b>, be aware of CSS regulations. When a user agent can't parse the selector, it must ignore the declaration block as well. If you run into trouble with this, just bend the "declaration just once" rule - and use it more than once.</div><div><br /></div><div><b>Third</b>, and most importantly, keep the cascade in mind. No matter if you're sorting your style sheets in a certain way or are very relaxed about the order in which rules appear in your style sheets, using every declaration once will make you change the order of the rules in one way or another. This order, however, can be decisive for a browser to decide which rule to apply. The easiest solution if you're running into any issues with this is to make an exception as well and use the declaration in question more than once.</div><div><br /></div><div>Alas, this is not always trivial to implement-this may change the cascading order and require a different workflow.</div><div><br /></div><div><b>Workflow</b></div><div>"Using every declaration just once" requires more attention when maintaining stylesheets. You will benefit from finding a way to track changed and added declarations to get them in line again. This is not hard when using a more or less reasonable editor (showing line changes, for example), but needs to be incorporated into the workflow.</div><div><br /></div><div>One way, for instance, is to mark rules you edited or added by indenting them. Once you're done updating your stylesheet, you can check for the indented rules to see if there are any new duplicate declarations, which you could then move to make sure each one of them is only used once.</div>Rahul Choudharyhttp://www.blogger.com/profile/17198358035512759000noreply@blogger.com0tag:blogger.com,1999:blog-5715559867150729567.post-66495082904844140252009-06-21T21:44:00.003+05:302009-06-21T21:50:58.358+05:30Unit Test Helper<div>Working on JUnit is fun and great but always remember a golden rule "Never change a good design just to make it accessable/runnable by JUnit". Let me elaborate on this statement to tell you what exactly I meant. In our code we write data access layer, which creates connections and execute sql.</div><div><br /></div><div>Specially in Web Application, connections are often managed inside container and are accessed by our code using JNDI. This is one of the industry best practices. Problem is how to test that code outside the Container. How to make that code JUnit accessible.</div><div><br /></div><div>Normally we might make some changes in our code in order to make JUnit run outside container, DON'T. With the above statement I meant these kind of changes specially. But the question is what is the solution for this situation. Should you leave that code untested? No, you can still test that code. And I am not going to talk about any new testing methodology either. You can test the same code with simple JUnit.</div><div><br /></div><div>This is made possible a small helper jar called JRUnitTestHelper from <a href="http://www.javaranch.com">Java Ranch</a>. This junit utility helps create JNDI based datasources and connections at the run time to assist junit test the code efficiently.</div><div><br /></div><div>Using this jar is very very simple, put this jar in your classpath while running your junit test and call these two lines</div><div><br /></div><div>if(JNDIUnitTestHelper.notInitialized()){</div><div> JNDIUnitTestHelper.init("jndi_unit_test_helper.properties");</div><div> }</div><div><br /></div><div>And of course please mention your connection details like IP, port, username etc in this "jndi_unit_test_helper.properties" properties file. Please feel free to shoot me emails if you have any questions. </div><div><br /></div><div><a href="http://faq.javaranch.com/codebarn/jrunittesthelper.zip">The jar for this program can be downloaded from JavaRanch</a>.</div>Rahul Choudharyhttp://www.blogger.com/profile/17198358035512759000noreply@blogger.com0tag:blogger.com,1999:blog-5715559867150729567.post-78391003029284826762009-06-17T21:08:00.004+05:302009-06-17T21:18:47.605+05:30Google MapsGoogle Maps is an interesting feature which most of us have used in some way or other. Either to find the way to a friend's new house or to locate a Pizza joint near our house. It helps and it sure do but what is interesting is to learn how to use this in our Applications to make them more user centric with all other Web 2.0 concepts.<div><br /></div><div>Let me start with giving you some examples, you go to a Bank's website and click on Locate an ATM link. It takes you to a page where you select a state from a drop down (Eeeaaakkhhhh!!!). The selection than loads another drop down below it with the city information (Double Eeeaaakkkkhh!!). You than select your city and the page is refreshed with 50 entries and their address. Now its your job to figure out which one is the nearest one and in most cases you doesn't even know your neighborhood else you would not had to use this service. Now as a Web developer how can you make this easy and interesting for the user. How about using Google Maps for this? Nope I am not kidding you can integrate Google Maps with your application (For FREE!!). Check out <a href="http://code.google.com/apis/maps/">Google Maps API</a> it have very interesting example and usage.</div><div><br /></div><div>To see a live usage you can goto my other blog <a href="http://varunsmritiudhyaan.blogspot.com">Varun Smriti Udhyaan</a>. It is a very flexible api completely usable using javascript technology and allows you to be very creative in finding the usage. Check out the examples and demo provided on Google Maps API page.</div><div><br /></div><div>Be Creative...</div><div><br /></div>Rahul Choudharyhttp://www.blogger.com/profile/17198358035512759000noreply@blogger.com0tag:blogger.com,1999:blog-5715559867150729567.post-52444265400941320962009-04-02T00:16:00.005+05:302009-04-02T02:11:30.533+05:30Custom Error PagesNope you are wrong, I am not talking about errorPage="true" attribute in this blog. I am talking about few error messages which are sent by the server to the browser like 404. How often you have seen this page.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_QUAGXITsdmM/SdPCmijh3NI/AAAAAAAAD_0/eq7dBZFYqbU/s1600-h/404+Error.JPG"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 71px;" src="http://1.bp.blogspot.com/_QUAGXITsdmM/SdPCmijh3NI/AAAAAAAAD_0/eq7dBZFYqbU/s320/404+Error.JPG" alt="" id="BLOGGER_PHOTO_ID_5319809552221330642" border="0" /></a>Now this is not a good way to treat your site visitors. The main problem with this kind of errors is that than the visitors can drift away from your site. So displaying a custom error message with features like navigation to similar pages or asking them to report a broken link is far better. You can do that pretty easily using the below mentioned solution.<br /><br /><strong>Implement custom error pages</strong> to hide raw exception messages. To do this, simply add something like the following to your web.xml: <br /><br /><error-page><br /> <error-code>404</error-code><br /> <location>/error/404.html</location><br /></error-page><br /><br /><br /><br /><br />Now you are free to write your own custom messages in the 404.html file<br /><br />Here is something which is out of scope for this article but you may find interesting. Here are reference to some of the best 404 pages on the web. <a href="http://www.smashingmagazine.com/2007/08/17/404-error-pages-reloaded/">Best 404 Pages</a>Rahul Choudharyhttp://www.blogger.com/profile/17198358035512759000noreply@blogger.com0tag:blogger.com,1999:blog-5715559867150729567.post-29239641814521067982009-02-09T16:08:00.002+05:302009-02-09T16:16:34.720+05:30Add bubbles to YUI<a href="http://developer.yahoo.com/yui"><span class="blsp-spelling-error" id="SPELLING_ERROR_0">YUI</span></a> has been a great tool to create fast <span class="blsp-spelling-error" id="SPELLING_ERROR_1">RUI</span> web applications. <span class="blsp-spelling-corrected" id="SPELLING_ERROR_2">Intermediates</span>, who are already using it, are complaining about important missing pieces. And experts are comparing it with other such libraries like <a href="http://www.dojotoolkit.org/"><span class="blsp-spelling-error" id="SPELLING_ERROR_3">DOJO</span></a>, <a href="http://script.aculo.us/">Script.Aculo.Us</a> etc.<div><br /></div><div>Few of the most important features which are missing in <span class="blsp-spelling-error" id="SPELLING_ERROR_4">YUI</span> are expandable/<span class="blsp-spelling-corrected" id="SPELLING_ERROR_5">collapsible</span> panel. <span class="blsp-spelling-corrected" id="SPELLING_ERROR_6">Accordion</span> Menu etc. There exists a library which spices up few things for <span class="blsp-spelling-error" id="SPELLING_ERROR_7">YUI</span> named <a href="http://www.bubbling-library.com">bubbling library</a>. It does not provide solutions to all <span class="blsp-spelling-error" id="SPELLING_ERROR_8">YUI</span> problems but it does provides some interesting widgets which can be plugged with existing <span class="blsp-spelling-error" id="SPELLING_ERROR_9">YUI</span> controls to provide some respite for the developers. </div><div><br /></div><div>The current version of bubbling library available is 2.0 which supports <span class="blsp-spelling-error" id="SPELLING_ERROR_10">YUI</span> 1.6.0 build. Earlier version can be used with <span class="blsp-spelling-error" id="SPELLING_ERROR_11">YUI</span> 1.5.2 build as well.</div><div><br /></div><div>Site has got great documentation and the download size is really sleek with only 206 KB. Whether you choose to use it or not but I will recommend one visit to the example section of the site.</div><div><br /></div><div>Cheers<br /><div><br /></div><div><br /></div></div>Rahul Choudharyhttp://www.blogger.com/profile/17198358035512759000noreply@blogger.com0tag:blogger.com,1999:blog-5715559867150729567.post-91514728454613091122008-06-02T16:06:00.004+05:302008-06-03T09:45:15.851+05:30Cobertura - Test Coverage ToolMany a times we wonder that why a software failed even when we have got everything insured with unit tests. Or some times the situation are when we are not exactly sure why the software is not working the way we want it too even though all the tests are passed. If you have gone through similar situations and looking for an answer, this is it.<br /><br /><br />Cobertura is a versatile Java unit test coverage (This blog is about J2EE right) tool. It is a profilic tool that calculates line by line coverage and branch coverage along side other useful metrics like McCabe Complexity Number etc. But the most important idea is that you can see whether your tests are executing your code at each line or not. This becomes very important at the time when you are debugging the unknown error or securing your code for future moderation sensitivity. In any case nothing better than a FREE TOOL. Yes you heard me right its Free. You can download the same from here <a href="http://cobertura.sourceforge.net/">http://cobertura.sourceforge.net/</a>. If you find any dificullty in installing the same for your project, feel free to write to me.<br /><br /><br />If you are an advance user and already knows about cobertura than there are chances that you probably might also knows about Clover (Paid Tool Not Good ) <a href="http://www.atlassian.com/software/clover">http://www.atlassian.com/software/clover</a>. Price is very high but the dashboard they provide is execellent.<br /><br /><br />So don't be disappointed if you cannot purchase the same, as in the near future I will be updating my own xsl sheet which can generate similar report for you without fuss. And yes that will be absolutely FREE, you can donate some bugs for my beer if you wish. But that xsl is free no questions asked :)<br /><br /><br />By the way, this is what Cobertura reports looks like this:<br /><p><br /><img id="BLOGGER_PHOTO_ID_5207266031340578914" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_QUAGXITsdmM/SEPs3cEDaGI/AAAAAAAABiM/CQMeY5TnNjk/s400/cobertura.JPG" border="0" />While my xsl will process the output and provide a report like this:</p><p><br /><img id="BLOGGER_PHOTO_ID_5207266035635546226" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_QUAGXITsdmM/SEPs3sEDaHI/AAAAAAAABiU/Q-eDI3SdI9Q/s400/cobertura-report.jpg" border="0" /></p>Rahul Choudharyhttp://www.blogger.com/profile/17198358035512759000noreply@blogger.com0tag:blogger.com,1999:blog-5715559867150729567.post-2638694821442285412008-05-24T16:48:00.003+05:302008-05-24T16:55:06.226+05:30JMX<span style="font-family:trebuchet ms;"><strong><span style="font-size:130%;">UNDERSTANDING JMX TECHNOLOGY</span></strong></span><br /><span style="font-family:trebuchet ms;"></span><br /><span style="font-family:trebuchet ms;">Java Management Extensions (JMX) technology offers programmers the ability to add monitoring and management to their Java applications. In effect, these APIs allow you to locally or remotely manage anything Java-enabled, from web servers to network devices to web phones. JMX technology is defined by two closely related specifications developed through the Java Community Process (JCP): Java Specification Request (JSR) 3: Java Management Extensions (JMX) Specification and JSR 160: Java Management Extensions (JMX) Remote API 1.0. This tech tip introduces you to the JMX architecture, and shows you how to create a simple Managed Bean. </span><br /><span style="font-family:trebuchet ms;"></span><br /><span style="font-family:trebuchet ms;">With JMX technology, an application, device, or service on one machine (called a resource), can be controlled remotely through the use of one or more custom JavaBean objects known as Managed Beans (MBeans). These MBeans are then registered in a core-managed object server (an MBean server). The MBean server acts as a management agent to any remote managers that want to access the resource. </span><br /><span style="font-family:trebuchet ms;"></span><br /><span style="font-family:trebuchet ms;"><strong>The JMX Environment</strong></span><br /><span style="font-family:trebuchet ms;"></span><br /><span style="font-family:trebuchet ms;">The JMX specification defines an architecture in three distinct tiers. The first two levels shown are the instrumentation and agent tiers, which are defined by JSR 3: </span><br /><span style="font-family:trebuchet ms;"><strong></strong></span><br /><span style="font-family:trebuchet ms;"><strong>Instrumentation Tier:</strong> Resources, such as applications, devices, or services, are instrumented using Java objects called Managed Beans (MBeans). MBeans expose their management interfaces, composed of attributes and operations, through a JMX agent for remote management and monitoring.</span><br /><span style="font-family:trebuchet ms;"></span><br /><span style="font-family:trebuchet ms;"><strong>Agent Tier:</strong> The main component of a JMX agent is the MBean server. This is a core managed object server in which MBeans are registered. A JMX agent also includes a set of services for handling MBeans. JMX agents directly control resources and make them available for management. The remote management level, the third tier, is partly defined by JSR 160:</span><br /><span style="font-family:trebuchet ms;"></span><br /><span style="font-family:trebuchet ms;"><strong>Remote Management Tier:</strong> This tier defines protocol adaptors and connectors that make a JMX agent accessible from remote management applications outside the agent's Java Virtual Machine (JVM)*. (Note that JSR 160 defines connectors only.) Connectors are used when the remote client is JMX-aware, and sees the same JMX API as a local client would. Adaptors are used when the remote client is using a generic management protocol such as Simple Network Management Protocol (SNMP) or Common Information Model and Web Based Enterprise Management (CIM/WBEM). </span><br /><span style="font-family:trebuchet ms;"></span><br /><span style="font-family:trebuchet ms;">There are generally three types of developers who use JMX, although one person might exercise all three roles:A developer that writes MBeans to manage resources. Here, JMX technology defines the interfaces exposed for management. </span><br /><span style="font-family:trebuchet ms;"></span><br /><span style="font-family:trebuchet ms;">The developer is responsible for the "glue" between the MBean and the resource itself.A developer that creates and deploys the agent. This person typically performs a number of tasks, including:Creating an MBean server, or using the one supplied by the platform.Registering the MBeans that represent the resources using MBean naming conventions.Configuring the connectors and protocol adaptors supplied by the platform (RMI and SNMP), or adding custom connectors or adaptors if the resources are to be accessed remotely. </span><br /><span style="font-family:trebuchet ms;"></span><br /><span style="font-family:trebuchet ms;">A developer that writes the remote manager. This person chooses the connector or protocol adaptors to interact with the JMX agent, and builds views of the resources managed remotely through the exposed MBeans. There are four types of MBeans, as defined by the JMX specification:Standard MBeans: Standard MBeans are management interfaces that are described by their method names. The methods are then exposed through introspection of the interface. Standard MBeans are the most common type of MBean. Most developers do not need to create any other MBean types.</span><br /><span style="font-family:trebuchet ms;"></span><br /><span style="font-family:trebuchet ms;"><strong>Dynamic MBeans:</strong> A dynamic MBean implements its management interface programmatically with the javax.management. DynamicMBean interface, instead of through introspection of method names. To do this, it relies on informational classes that represent the attributes and operations exposed for management. Dynamic MBeans are often used when the management interface of an MBean is not known at compile time -- for example, if it is determined by parsing an XML file.</span><br /><span style="font-family:trebuchet ms;"></span><br /><span style="font-family:trebuchet ms;"><strong>Model MBeans:</strong> A model MBean is a generic, configurable MBean that applications can use to instrument any resource dynamically. Essentially, it is a dynamic MBean that has been implemented so that its management interface and its actual resource can be set programmatically. This enables any manager connected to a Java dynamic management agent to instantiate and configure a model MBean dynamically.</span><br /><span style="font-family:trebuchet ms;"></span><br /><span style="font-family:trebuchet ms;"><strong>Open MBean:</strong> Open MBeans are dynamic MBeans, with specific constraints on their data types, that allow management applications and their human administrators to understand and use new managed objects as they are discovered at runtime. Open MBeans provide a flexible means of instrumenting resources that need to be open to a wide range of applications compliant with the Java Management Extensions (JMX) specification. </span><br /><span style="font-family:trebuchet ms;"></span><br /><span style="font-family:trebuchet ms;">The typical process used in creating a JMX-compliant management interface involves at least two steps. The first step is to create an MBean interface, as well as an agent to register that MBean with the MBean server. The next step is to manage the MBean using a remote management application. The JMX specification defines a standard set of connectors that allow you to access JMX agents from remote management applications. </span><br /><span style="font-family:trebuchet ms;"></span><br /><span style="font-family:trebuchet ms;">This is useful because JMX connectors using different protocols provide the same management interface. This enables a management application to manage resources transparently, regardless of the communication protocol used. JMX agents can also be used by systems or applications that are not compliant with the JMX specification, but which support JMX agents. </span>Rahul Choudharyhttp://www.blogger.com/profile/17198358035512759000noreply@blogger.com0tag:blogger.com,1999:blog-5715559867150729567.post-51023257737355665622008-05-23T12:09:00.002+05:302008-05-23T12:19:28.763+05:30XML Timing Language<span style="font-family:trebuchet ms;"><span style="font-size:180%;"><strong>Introduction to XML Timing Language - XTL</strong></span><br /></span><br /><span style="font-family:trebuchet ms;">The XML Timing Language (Timesheets) is at present submitted to the W3C org for discussion by the Helsenki University of Technology. This XML Timing Language is used for introducing the timings to the XML document elements.<br /></span><br /><span style="font-family:trebuchet ms;">Hence XML Timing Language is a separate part of the XML document that specifies the timings for the different elements in the document. The XML Timing Language uses a subset of the Timing and Synchronization module of SMIL 2.0.<br /></span><br /><span style="font-family:trebuchet ms;">To explain further about the XML Timing Language, think of a webpage that uses Cascading Style Sheets to present the content of a web page. In this way all the contents of the pages are presented all the time. Suppose you want to present only part of the page at an instant and then after a few seconds the other part should be presented, then you can use XML Timing Language to achieve this.<br /></span><br /><span style="font-family:trebuchet ms;">Just like a slide show you can present contents of the page in different times using the XML Timing Language and the style of presentation is taken care of by the CSS. Hence you should be clear that the XML Timing Language (Timesheets) specify the visibility of the given elements in a document at a moment.<br /></span><br /><span style="font-family:trebuchet ms;">Timesheets are separate sections of the XML documents. An XML document can have any number of Timesheet elements. It is the container which has other item element which may refer to the media elements. The media elements are divided into static and dynamic elements.<br /></span><br /><span style="font-family:trebuchet ms;">The static elements are those that contain static images and text and the dynamic media elements are those that contain video and audio. When a static media element is included in the document you have to specify the duration of the element otherwise the element would be displayed indefinitely. In the case of dynamic media elements you need not specify the duration since it will automatically stop when the content of the video or audio is over.<br />The timing language elements have attributes like begin and dur. The begin attribute gives the relative starting time of the element with respect to its activation. If you do not specify any attribute value for the begin attribute, it defaults to “0s” which means 0 seconds. The dur attribute gives the duration of the element relative to the start time of the element. For static elements the duration will be indefinite unless the parent element deactivates it.<br />The dynamic elements will have the duration as that of the content itself. There is another attribute called the repeat attribute. This gives the repeat count for the element. If the repeat count is positive the element is activated again. You should note that the repeat attribute has some meaning only when it is related to the dynamic content. There is no meaning in repeating the static content. “Indefinite” is also a value for the repeat attribute. This value indicates that the element will be repeated until it is stopped by the parent element.<br /></span><br /><span style="font-family:trebuchet ms;">The following code gives an example of how the XML Timing Language (Timesheet) is used in a web page.</span><br /><br /><blockquote><br /><html xmlns=<a href="http://www.w3.org/1999/xhtml">"http://www.w3.org/1999/xhtml"</a> xmlns:time=<a href="http://www.your-domain.org/2005/timesheet">"http://www.your-domain.org/2005/timesheet"</a>><br /><head><style type="text/css">...</style><br /><time:timesheet><time:par><time:item select="#img1" begin="2s"/><time:item select="#img2" begin="7s"/><time:item select="#img3" begin="12s"/><time:item select="#img4" begin="17s"/></time:par></time:timesheet></head><br /><body><div id="content"><p id="title">My Album</p><p id="img1"><img src="image1.jpg" id="image1"/></p><p id="img2"><img src="image2.jpg" id="image2"/></p><p id="img3<img src="image3.jpg" id="image3"/></p><p id="img4"><img src="image4.jpg" id="image4"/></p></div></body></html><br /></blockquote><br />The above code displays the first image and each successive image is displayed for 5 seconds.<br /><br />The <span style="font-family:trebuchet ms;">tag’s id is chosen to set the duration for the images. The begin attribute is set for 7 seconds, 12 seconds and 17 seconds for the successive images so that the images are displayed for 5 seconds each one by one automatically. With this simple example one can easily understand the power of the Timesheet in a web page. For other elements and attributes and for some simple examples please refer to the XML Timing Language documentation available at “</span><a href="http://www.w3.org/Submission/xml-timing/"><span style="font-family:trebuchet ms;">http://www.w3.org/Submission/xml-timing/”</span></a><br /><br /><br /><span style="font-family:verdana;"><?xml:namespace prefix = time /><time:item begin="2s" select="#img1"><time:item begin="7s" select="#img2"><time:item begin="12s" select="#img3"><time:item begin="17s" select="#img4"></time:item></time:item></time:item></time:item></span>Rahul Choudharyhttp://www.blogger.com/profile/17198358035512759000noreply@blogger.com0tag:blogger.com,1999:blog-5715559867150729567.post-28208700517219890582008-05-15T10:09:00.005+05:302008-05-15T13:59:02.234+05:30Watij - Web Application Testing in Java<span class="blsp-spelling-error" id="SPELLING_ERROR_0">WATIJ</span> stands for <strong><em>'Web Application Testing in Java'</em></strong>. J2<span class="blsp-spelling-error" id="SPELLING_ERROR_1">EE</span> deals with creating Web Applications, and like in most cases project teams cannot afford dedicated testers due to "<em>resource limitations</em>", "<em>schedule limitation</em>", "<em>management limitations</em>" and for many other unique explanations and reasons. In some cases where they even do hire manual testers, the job of the tester becomes tedious since most of the team nowadays follows Iterative development model like <a href="http://agileplusplus.blogspot.com/">AGILE</a>, Spiral etc. And thus they need to repeat testing for same set of functionality with every release to ensure that '<strong>new</strong>' has not <span class="blsp-spelling-corrected" id="SPELLING_ERROR_2">broken</span> '<strong>previous</strong>'. And thus with every release the burden on the poor fellow only keeps on getting tougher. Like many other web application, one very important but common feature is Authentication & Authorization. Authentication stands for identifying the users while Authorization refers to validating user's rights within the system. For all these functionalities the tester has to check every time with every release whether they are intact or not. <strong>THIS CAN BE AUTOMATED</strong> and thus bringing hours of testing effort to be reduced to minutes of self automated runs.<br /><br />Now, I know that you know that it can be automated using costly tools like <span class="blsp-spelling-error" id="SPELLING_ERROR_3"><strong>QTP</strong></span> etc. But what I am telling you is that it can be done free of <span class="blsp-spelling-error" id="SPELLING_ERROR_4">cost</span> using a <a href="http://en.wikipedia.org/wiki/OpenSource">Open Source</a> tool name as <a href="http://www.watij.com/"><span class="blsp-spelling-error" id="SPELLING_ERROR_5">WATIJ</span></a>. <span class="blsp-spelling-error" id="SPELLING_ERROR_6">Watij</span> is built over <span class="blsp-spelling-error" id="SPELLING_ERROR_7">JUnit</span> and thus provides similar interfaces to write the tests. But writing tests are very very simple, when I say simple it means so simple that even my QC and <span class="blsp-spelling-error" id="SPELLING_ERROR_8">QA</span> who <span class="blsp-spelling-corrected" id="SPELLING_ERROR_9">doesn't</span> had previous experience on Java where able to write hundreds of tests. The (<a href="http://www.watij.com/">wiki</a>) site provides easy tutorials to start with and I am sure you will love it when you start using it.<br /><br />But there is a catch, as there are few limitations to the tool at the moment.<br /><br />1. Currently it only works with IE<br />2. It <span class="blsp-spelling-corrected" id="SPELLING_ERROR_10">doesn't</span> works with Applet (<span class="blsp-spelling-error" id="SPELLING_ERROR_11">Huh</span>, like any body is using it nowadays).<br /><br />I tried it with AJAX and it gave good <span class="blsp-spelling-corrected" id="SPELLING_ERROR_12">response</span> on many <span class="blsp-spelling-corrected" id="SPELLING_ERROR_13">occasions</span> but not sure if it can support advance javascript functionalities like "Drag and Drop" etc. But with all the features it has, mind you it is worth trying.Rahul Choudharyhttp://www.blogger.com/profile/17198358035512759000noreply@blogger.com7tag:blogger.com,1999:blog-5715559867150729567.post-48578678705478163882008-05-10T11:53:00.008+05:302008-05-11T19:55:05.843+05:30There exists NO Alternative 4 Unit Testing<span style="font-family:trebuchet ms;">There exists no alternative known for Unit Testing, although there exists '<span style="font-size:180%;"><strong>∞</strong></span>' number of tools which can help you in doing it. Since this blog is oriented towards J2EE, I will talk about JUnit. A tool that has revolutionize the way code is developed (Are you wondering why I didn't said "revolutionize Testing"? Its because its not helpful for tester, it is more helpful for developers). It truly is, it helps developers to eliminate bugs in initial stages. Sach ("Really"), It has been proved over and over again. People, Thinkers, Great mind have always stressed on <a href="http://4.bp.blogspot.com/_QUAGXITsdmM/SCbrueb29nI/AAAAAAAABd0/mhCRYxvKKVY/s1600-h/No-Bugs.jpg"><img id="BLOGGER_PHOTO_ID_5199102003522238066" style="FLOAT: right; MARGIN: 0px 0px 10px 10px; CURSOR: hand" alt="" src="http://4.bp.blogspot.com/_QUAGXITsdmM/SCbrueb29nI/AAAAAAAABd0/mhCRYxvKKVY/s400/No-Bugs.jpg" border="0" /></a>its usage but we never listened. Let me try to put up the same in another way which may persuade you to think otherwise.<a href="http://3.bp.blogspot.com/_QUAGXITsdmM/SCboCOb29mI/AAAAAAAABds/UzlGbVuBmW8/s1600-h/No-Bugs.jpg"></a></span><br /><br /><span style="font-family:Trebuchet MS;">Lets say, you are building a house (Please start thinking about your dream house which you might have wanted to build or have build already). Now lets start with a land, you will have to buy a land somewhere. Everybody have some choices, specific opinions, lets say some people want their home to be situated in a good colony, some might want it to be far away from city rush. What ever is your choice, tell me would you evaluate the prospect land before buying or after buying? What will happen if you find out after completing your house that the land is not fulfilling your all choices? Either you redo the cycle again (which I am sure most of us here cannot afford to do) or stay with a compromise. </span><br /><br /><blockquote><br /><span style="font-family:Trebuchet MS;">Lesson 1: Please start testing each unit unit of code before you complete your software. DONOT put off testing until completion, as either it will leave you with a compromise or will require you to do the whole cycle again. You choose, for me choice is simple. :)</span><br /></blockquote><br /><br /><span style="font-family:Trebuchet MS;">Now, why unit testing is better. I am sure you will be very familiar with the term unit. You use it quite often in your daily life, its a measurement terminology. For e.g. you buy milk 1 litre/day. Litre is your unit to measure the milk quantity. What is the unit for software? Milk quantity can be measured in terms of Litre, Kilo Litre, may be in ounce or kg. There can be many unit to measure the same product. Same way in software you can use NCSS (Non Commenting Source Code) as your unit or function as your unit. In case of JUnit normally function is treated as one unit and test can be written to test each functions. </span><br /><br /><br /><span style="font-family:Trebuchet MS;">Now, lets say you have assigned construction of your house to a vendor (may be due to time shortage). Will you make visits to your house frequently or let the constructor build the complete house and than you will go for inspection. The answer is pretty straight forward, frequent visits will allow you to check the progress made which will result in better control on the construction. That means you can check each "unit" added daily and thus perform better quality control. Same way, if in software construction as well, it will be far easy to write tests for each unit and test it seperately instead of testing software as a bundle (whole).</span>Rahul Choudharyhttp://www.blogger.com/profile/17198358035512759000noreply@blogger.com0