<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Masoud Kalali&#039;s Blog</title>
	<atom:link href="http://kalali.me/feed/" rel="self" type="application/rss+xml" />
	<link>http://kalali.me</link>
	<description>My thoughts on software engineering and beyond...</description>
	<lastBuildDate>Thu, 26 Apr 2012 20:10:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>From NetBeans to IntelliJ IDEA, Week 1</title>
		<link>http://kalali.me/from-netbeans-to-intellij-idea-week-1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=from-netbeans-to-intellij-idea-week-1</link>
		<comments>http://kalali.me/from-netbeans-to-intellij-idea-week-1/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 10:31:39 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[IntelliJ IDEA]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[IDE]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=1259</guid>
		<description><![CDATA[I have been using NetBeans for a long time now; Because it is easy to use, easy to understand and explain to others, it has impressive Java EE support, etc. I was working on Java EE projects or projects  involving NetBeans RCP applications with 40-50 modules (1m loc or so) which are considered small applications. [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using NetBeans for a long time now; Because it is easy to use, easy to understand and explain to others, it has impressive Java EE support, etc. I was working on Java EE projects or projects  involving NetBeans RCP applications with 40-50 modules (1m loc or so) which are considered small applications. I didn&#8217;t need to have all modules opened or even when I needed NetBeans handled it pretty well. After joining GlassFish team things started to change a little. GlassFish codebase was new to me and the number of maven modules in GlassFish project was way larger than what I could easily open in NetBeans IDE to be able to navigate around in the code, to find the usages of a method, or to locate all of the implementing classes of a particular interface, etc.</p>
<p>I opened a RFE in NetBeans bug-tracking system but till that RFE got addressed I needed to work and thus I decided to give IntelliJ a try and see how it fares with GlassFish codebase and how easy it will be for me to adopt it as the IDE of choice for my day to day work on GlassFish.</p>
<p>First days impressions (Positive):</p>
<ul>
<li>Can import the entire GlassFish codebase and start using it, no delay in code assisting popup and amazingly no lag after the initial scanning and indexing of the entire codebase.</li>
<li>Find usage works almost perfectly, sometimes it says that the class/es are outside of the codebase which might be my fault when importing the project</li>
<li>Code completion assistant is fast, when I say fast I mean really fast.</li>
<li>I like the fact that I can choose between different available LAFs. [The CDE/Motif LAF is still part of the JRE which denotes the overzealousness of keeping the backward compatibility of the platform?]</li>
<li>I like the &#8220;Store Current Layout as Default&#8221; feature which let me store a layout and use it when the layout get too messed-up.</li>
<li>I like the &#8220;Autoscroll to source&#8221; and &#8220;Autoscroll from source&#8221; though I&#8217;d rather have the action to do it manually when the mentioned options are disabled and I want to locate a class in the project view</li>
</ul>
<p>First days impression (Not positive ones): Some of what I am missing might be available somewhere in the IDE but I haven&#8217;t find them yet&#8230;.</p>
<ul>
<li>I was not able to switch between different profiles for the module, for example IDE, release, etc. Maybe it is somewhere but I have not found it yet.</li>
<li>I think the color schema is hard to read because some of the used colors are low contrast, for example the comments, annotations, are hard to read and required some adjustment to be easier to read.</li>
<li>I opened some views that I cannot close, IDETalk, commander, Ant Build&#8230; they are all on auto-hide in the vertical bar in the left side without any close button or close action in the context (right click) menu to remove the tab from the side bar. Same goes for view tabs appearing in the bottom bar and left bar. But the good thing is we can rearrange them for better accessibility.</li>
</ul>
<ul>
<li>I think the local history feature in NetBeans has a better UI and usability than IDEA. In NetBeans the local history is shown in the same tab as the code and not in an extra window same goes for  diff window, etc.</li>
</ul>
<div></div>
<div>

<a href='http://kalali.me/wp-content/uploads/2012/04/netbeans.png' class="fancyboxgroup" rel="gallery-1259" title='Well integrated view for diff/ local history in NetBeans'><img width="150" height="150" src="http://kalali.me/wp-content/uploads/2012/04/netbeans-150x150.png" class="attachment-thumbnail" alt="Well integrated view for diff/ local history in NetBeans" title="Well integrated view for diff/ local history in NetBeans" /></a>
<a href='http://kalali.me/wp-content/uploads/2012/04/intelliJ.png' class="fancyboxgroup" rel="gallery-1259" title='No so well integrated view showing diff in intellij'><img width="150" height="150" src="http://kalali.me/wp-content/uploads/2012/04/intelliJ-150x150.png" class="attachment-thumbnail" alt="No so well integrated view showing diff in intellij" title="No so well integrated view showing diff in intellij" /></a>
<a href='http://kalali.me/wp-content/uploads/2012/04/Screen-Shot-2012-04-12-at-12.13.28-PM1.png' class="fancyboxgroup" rel="gallery-1259" title='Tabs cannot be closed in the slidebar...'><img width="150" height="51" src="http://kalali.me/wp-content/uploads/2012/04/Screen-Shot-2012-04-12-at-12.13.28-PM1-150x51.png" class="attachment-thumbnail" alt="Tabs cannot be closed in the slidebar..." title="Tabs cannot be closed in the slidebar..." /></a>

</div>
<ul>
<li>The code formatter works better in NetBeans (SHIFT+CTRL+F) compared to IntelliJ (CMD+ALT+L). I like the NetBeans hotkey better as it has something from Formatting in the hotkey. (I tried couple of unindented unglized code snippet in both).</li>
<li>The Favorites view does not allow me to add a file system directory to a favorites list which limits the favorites view usage to project members (classes, packages, modules) &#8230;</li>
</ul>
<p>I will post another blog entry after I used IntelliJ for another two weeks to give you a more in depth comparison of how they work for Mavan projects (my comparison will be mostly on Editors and Project/ navigation and refactoring features. Nothing on other languages support, Java EE, JavaFx, application server support, etc.)</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/from-netbeans-to-intellij-idea-week-1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using GlassFish domain templates to easily create several customized domains</title>
		<link>http://kalali.me/using-glassfish-domain-templates-to-easily-create-several-customized-domains/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-glassfish-domain-templates-to-easily-create-several-customized-domains</link>
		<comments>http://kalali.me/using-glassfish-domain-templates-to-easily-create-several-customized-domains/#comments</comments>
		<pubDate>Fri, 06 Apr 2012 11:35:26 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Domain Templates]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=1240</guid>
		<description><![CDATA[It might have happened to you to require some customization the GlassFish behavior after you create the domain in order to make the domain fit the  basic requirements that you have in your organization or for your development purpose. Some of the files that we usually manipulate to customize GlassFish includes logging.properties, keystore.jks, cacert.jks, default-web.xml, server.policy and domain.xml. These [...]]]></description>
			<content:encoded><![CDATA[<p>It might have happened to you to require some customization the GlassFish behavior after you create the domain in order to make the domain fit the  basic requirements that you have in your organization or for your development purpose. Some of the files that we usually manipulate to customize GlassFish includes <em>logging.properties, keystore.jks, cacert.jks, default-web.xml, server.policy </em>and<em> domain.xml</em>. These files can be customized through different <em>asadmin</em> commands, or JDK commands like keytool, policytool or manually using a text editor after you created the domain in the config directory of the domain itself.  But repeating the steps for multiple domains is a laborious task which can be prevented by changing the template files that GlassFish domains are created using them. The templates are located atAnd we can simply open them and edit the properties to make them more fit to our needs.</p>
<p style="text-align: center;"><a href="http://kalali.me/wp-content/uploads/2012/04/domain_templates1.png" class="fancyboxgroup" rel="gallery-1240" title="domain_templates_directory"><img class="aligncenter  wp-image-1250" title="domain_templates_directory" src="http://kalali.me/wp-content/uploads/2012/04/domain_templates1.png" alt="" width="450" height="150" /></a></p>
<p>The benefit of modifying the templates rather than copy pasting the config directory of one domain to another is the domain specific behaviors like port numbers which have placeholders in the <em>domain.xml</em> to be filled by <em>asadmin</em> command. An example of a placeholder is <em>%%%JMS_PROVIDER_PORT%%%</em> which will be replaced by JMS provider port by <em>asadmin</em> command.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/using-glassfish-domain-templates-to-easily-create-several-customized-domains/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>My last blog in 2011: My 2012 wishes and predictions&#8230;</title>
		<link>http://kalali.me/my-last-blog-in-2011-my-2012-wishes-and-predictions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=my-last-blog-in-2011-my-2012-wishes-and-predictions</link>
		<comments>http://kalali.me/my-last-blog-in-2011-my-2012-wishes-and-predictions/#comments</comments>
		<pubDate>Sat, 31 Dec 2011 00:48:11 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Afghanistan]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=1216</guid>
		<description><![CDATA[I almost stopped blogging during 2011 because of lots of complications I was dealing with but this entry is something I couldn&#8217;t just pass over. Hopefully I will resume blogging during 2012 as actively as I was doing during late 2009 and early 2010. My predictions for 2012 in technology realm specially when focused on Java [...]]]></description>
			<content:encoded><![CDATA[<p>I almost stopped blogging during 2011 because of lots of complications I was dealing with but this entry is something I couldn&#8217;t just pass over. Hopefully I will resume blogging during 2012 as actively as I was doing during late 2009 and early 2010.</p>
<p>My predictions for 2012 in technology realm specially when focused on Java is as follow:</p>
<ul>
<li>Oracle will push Java forward like never before.</li>
<li>Java ecosystem will thrive with JavaFX getting open sourced and new big names joining JCP.</li>
<li>We will see the best Java release for Mac os, Java SE 7.</li>
<li>IBM will push the idea of how cool Rational set of IDEs are and how good Websphere is and people will believe it until the are caught with no way to return.</li>
<li>RIM will probably stop development of it&#8217;s own operating system and instead develop a powerpack for Android&#8230;</li>
<li>Google Chrome will eat other browsers marketshare as fast as <em>browserly</em> possible.</li>
<li>Some of the new cool boys in the JVM town that are claiming to be the next Java will vanish/start vanishing without any trace <img src='http://kalali.me/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </li>
<li>GlassFish will get more marketshare and more people will benefit from it&#8217;s modular and extensible architecture.</li>
<li>Google will market a revolutionary Android tablet that will change the concept.</li>
</ul>
<p>What I wish for during 2012</p>
<ul>
<li>No more war and instead of that some peace and quiet time around the globe.</li>
<li>No disasters like what we had in 2011 and instead some ground breaking scientific discoveries in medicine, energy and space travel.</li>
<li>No economy breakdown anywhere in the world.</li>
<li>A cell phone thinner than Motorola DROID RAZR <img src='http://kalali.me/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </li>
<li>Google to provide a good cloud storage for end users so I could stop using combination of DrobBox, Google and SkyDrive.</li>
</ul>
<p>Other predictions for 2012 which I truly like to be proven wrong for them.</p>
<ul>
<li>Iranian government will not go away and will not change to a sane governing body.</li>
<li>Pakistan army and ISI will continue supporting /training and harboring  Al Qaeda and Taliban and continue destabilizing Afghanistan southern and central provinces.</li>
<li>Iranian government will continue meddling in other countries affair specially in Afghanistan and Arab countries.</li>
<li>Syrian dictatorship will remain intact by support of Iranian government and the region will stay unstable as it is now.</li>
</ul>
<h3 style="text-align: center;">I wish everyone a happy new year with lots of joys and success.</h3>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/my-last-blog-in-2011-my-2012-wishes-and-predictions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My thoughts on JSR 351, Java Identity API</title>
		<link>http://kalali.me/some-thought-on-jsr-351-java-identity-api/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=some-thought-on-jsr-351-java-identity-api</link>
		<comments>http://kalali.me/some-thought-on-jsr-351-java-identity-api/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 17:24:14 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[identity]]></category>
		<category><![CDATA[jsr-351]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=1168</guid>
		<description><![CDATA[Identity, something that we hear more often these days with the whole web 2.0 and social services and more and more web based public services growing around us. The identity notion is an integral part of a security system in distributed services. Developing effective software system require an effective security and access control system which [...]]]></description>
			<content:encoded><![CDATA[<p>Identity, something that we hear more often these days with the whole web 2.0 and social services and more and more web based public services growing around us. The identity notion is an integral part of a security system in distributed services. Developing effective software system require an effective security and access control system which java provides, not exactly in the way that it should be in 2011 but it does provide what is the bare bone necessity to develop applications and frameworks on top of it and  benefit from its presence. The identity API is going to ease the interaction between the identity providers and those who consume the identity and trust the identity providers in addition to governing and managing the identity attributes.</p>
<p>I was studying the JSR details and it seems to be covering everything required for the identity attributes governance and the required API for both ends of the usage including the client API the governing/producing API. The identity producing and consuming is not new and there are fair number of public identity producers like facebook, twitter, etc. and also products that system integrators can use  like OpenAM as an open source product or gorilla Commercial software products like ORACLE identity management  or IBM tivoli identity management software, etc.</p>
<p>In a very simple set of words, the <a href="http://www.jcp.org/en/jsr/detail?id=351">JSR 351</a>: The Java Identity API will be as successful as it is going to be adopted. No adoption and it will endup dying some dark corner&#8230;  Design a simple and elegant API and try to ship it with some free and easy to use service implementations and it may get some momentum, otherwise it will be a goner and people will stick with what they have. I like the new features that it is going to introduce in the decision making or authorization part but we should see how well it will be adopted by identity providers to develop the services that provides the interaction point between the JSR interface and their repositories.  Pushing it as JSR wont really do that much without a wide adoption in the community. Look at how many implementation of the JSR 115 and JSR 196 exits to be plugged into application servers supporting the contract and you will get what I am referring to by community adoption.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/some-thought-on-jsr-351-java-identity-api/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>An analysis on the monthly increase of NetBeans IDE active users count</title>
		<link>http://kalali.me/nbusers-analysis/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nbusers-analysis</link>
		<comments>http://kalali.me/nbusers-analysis/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 16:07:11 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Reporting]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=1152</guid>
		<description><![CDATA[In this article I will go through number of NetBeans IDE active users count from Jan 2004 to June 2011]]></description>
			<content:encoded><![CDATA[<p>Few weeks ago I was talking to <a href="http://cz.linkedin.com/in/jirikovalsky">Jiří Kovalský </a> about NetBeans and its <a href="http://netbeans.org/community/news/show/1530.html">1,000,000 active users</a> and I asked him to check whether it is possible to have the number of active users by month or not and today he got back to me with a nice chart showing number of active users for each month since Jan 2004. Jiri is  <a href="http://netbeans.org">NetBeans</a> community manager and also he is the first person in the NetBeans team I get acquaintance long ago during <a href="http://wiki.netbeans.org/NetCAT">NetCat</a>50.</p>
<p>Here I attached the chart and then I will do an short analysis of what the chart can represent.</p>
<p style="text-align: center;"><a href="http://dl.dropbox.com/u/334201/jn-blog-files/active_users.png" class="fancyboxgroup" rel="gallery-1152" title="Number of NetBeans Active users per month"><img class="aligncenter size-full wp-image-1153" title="Number of NetBeans Active users per month" src="http://dl.dropbox.com/u/334201/jn-blog-files/active_users.png" alt="Number of NetBeans Active users per month" width="831" height="252" /></a></p>
<p>Now a brief overview of the chart:</p>
<ul>
<li>NetBeans team started to count the active users in Jan 04</li>
<li>During summer and new year eve there is a decline in the number of active users each year and as overall number of users growth, this decline can be seen more clearly.</li>
<li>Number of active users is increasing continuously.</li>
</ul>
<p>Now I want to merge the above chart with another table which is <a href="http://netbeans.org/community/releases/roadmap.html">different NetBeans versions release dates</a>.</p>
<p style="text-align: center;"><a href="http://dl.dropbox.com/u/334201/jn-blog-files/release_map.png" class="fancyboxgroup" rel="gallery-1152" title="NetBeans versions release dates"><img class="aligncenter size-large wp-image-1154" title="NetBeans versions release dates" src="http://dl.dropbox.com/u/334201/jn-blog-files/release_map.png" alt="NetBeans versions release dates" width="600" height="200" /></a></p>
<ul>
<li>The last line in the bar is for June 2011, The July numbers are not calculated yet.</li>
<li>It took NetBeans two years, until Jan 2006, to get 200,000 active users at the beginning but the growth in number of active users was accelerating from the beginning as chart suggests.</li>
<li>In its next 3 years, from Jan 2006 to Jan 2009 number of users increased by 400,000 to a total of 600,000 active users which means the user growth accelerated quite well. This is the post NetBeans 5 ear when each version&#8217;s  changelog had quite a large number  number of bug fixes, performance improvements and new features.</li>
<li>The biggest increase in the number of users in duration of one year can be seen between June 2010 and June 2011 with about 200,000 users. This is the second year that ORACLE was in charge of Sun and its products.</li>
<li>It looks like that after NetBeans 6.9 the number of active users is increasing faster than before and the reason is clearly the stability and performance improvement in addition to tons of new features in the core and support for PHP and C++.</li>
</ul>
<p>As a long time user of NetBeans IDE I should say that NetBeans has come a long long way to become the IDE that we use in our daily jobs nowadays. The number of features introduced in the IDE and the number of bug fixes is enormous. You can find and try NetBeans 4 or 5 and compare it to NetBeans 7 to understand the huge distance between these two.</p>
<p>NetBeans seen several shifts in its direction specially during netbeans 6 time when More languages were being supported in IDE and diverse set of SOA and XML development features were being included in the IDE. Then Again another shift happened and all those features and language supported were dropped and NetBeans team put more effort into the core to make the core more stable and feature rich which as you can see in the chart has payed off pretty well.</p>
<p>The 1,000,000 active users number is not just a number, it shows that a vast, versatile and living community is behind NetBeans IDE as users, contributors, and the core development team. Long live the good community and the good IDE.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/nbusers-analysis/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A walkthrough for the fork/join framework introduced in Java SE 7</title>
		<link>http://kalali.me/a-walk-through-the-forkjoin-api-introduced-in-java-se-7/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-walk-through-the-forkjoin-api-introduced-in-java-se-7</link>
		<comments>http://kalali.me/a-walk-through-the-forkjoin-api-introduced-in-java-se-7/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 17:01:15 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[fork/join]]></category>
		<category><![CDATA[parallel]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=1107</guid>
		<description><![CDATA[This is a tutorial showing what the fork/join framework is and how you can use it to implement some of your parallel programming solutions...]]></description>
			<content:encoded><![CDATA[<p>Java SE 7 brought some neat features on the table for Java developers, one of these features is the <a href="http://download.oracle.com/javase/tutorial/essential/concurrency/forkjoin.html">fork/join framework</a> or basically the new parallel programming framework we can use to easily to implement our divide and conquer solutions. The point is that a solution to a problem should be devised with the following characteristics to use the fork/join framework effectively:</p>
<ul>
<li>The problem domain whether it is a file, list, etc to be processed or a computation should be dividable to smaller subtasks.</li>
<li>Processing chunks should be possible without requiring the result of other chunks.</li>
</ul>
<p>To summarize it, solving or processing the problem domain should require no self-feedback to make it possible to use the framework. For example if you want to process a list and processing each element in the list require the result of processing previous element then it is impossible to use any parallel computing for doing that job. If you want to apply some FFT over a sound stream which require feedback for processing each pulse from the previous pulses it is not possible to speedup the processing using the fork/join framework, etc.</p>
<p>Well, before we start learning the fork/join framework we better know what it is and what it is not:  What fork/join framework is:</p>
<ul>
<li>A parallel programming framework for Java</li>
<li>Part of Java SE 7</li>
<li>Suitable for implementing parallel processing solutions, mostly data intensive with small or no shared resources between the workers who process the data chunks.</li>
<li>Suitable when no synchronization is required between the workers</li>
</ul>
<p>What fork/join framework is not:</p>
<ul>
<li>It is not a magic that turns your code to run fast on machines with multiple processors, you need to think and implement your solutions in a parallel manner.</li>
<li>It is not hard and obscure like other frameworks, MPI for example. Using the framework is way easier than anything I used before.</li>
</ul>
<p>If you want to learn the mechanics behind the fork/join framework you can read the original article written by Doug Le which explains the motive and the design. The article is available at <a href="http://gee.cs.oswego.edu/dl/papers/fj.pdf">http://gee.cs.oswego.edu/dl/papers/fj.pdf</a>. If you want to see how we can use the framework then continue on reading this article.</p>
<p>First let&#8217;s see what are the important classes that one need to know in order to implement a divide and conquer solution using fork/join framework and then we will start using those classes.</p>
<ul>
<li>The <a href="http://download.oracle.com/javase/7/docs/api/java/util/concurrent/ForkJoinPool.html">ForkJoinPool</a>: This is the workers pool where you can post your <a href="http://download.oracle.com/javase/7/docs/api/java/util/concurrent/ForkJoinTask.html">ForkJoinTask</a> to be executed. The default parallelism level is the number of processors available to the runtime.</li>
<li>The <a href="http://download.oracle.com/javase/7/docs/api/java/util/concurrent/RecursiveTask.html">RecursiveTask&lt;V&gt;</a>: This is a task, subclass of the <a href="http://download.oracle.com/javase/7/docs/api/java/util/concurrent/ForkJoinTask.html">ForkJoinTask</a> which can return some value of type V. For example processing a list of DTOs and returning the result of process.</li>
<li>The <a href="http://download.oracle.com/javase/7/docs/api/java/util/concurrent/RecursiveAction.html">RecursiveAction</a>: Another subclass of the <a href="http://download.oracle.com/javase/7/docs/api/java/util/concurrent/ForkJoinTask.html">ForkJoinTask</a> without any return value, for example processing an array&#8230;</li>
</ul>
<p>
I looked at this new API mainly for data pipelining in which I need to process a pretty huge list of object and turn it to another format to keep the processing result of one library consumable for the next one in the data flow and I am happy with the result pretty easy and straight forward.
</p>
<p>
Following is an small sample showing how to process a list of Row objects and convert them a list of Entity Objects. In my case it was something similar with processing Row objects and turning them to OData OEntity objects.
</p>
<p><br/></p>
<pre class="brush: java; title: ; notranslate">
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.RecursiveTask;

/**
 *
 * @author Masoud Kalali &lt;mkalali&gt;
 */
class RowConverter extends RecursiveTask&lt;List&lt;Entity&gt;&gt; {

    //if more than 5000 we will use the parallel processing
    static final int SINGLE_TREAD_TOP = 5000;
    int begin;
    int end;
    List&lt;Row&gt; rows;

    public RowConverter(int begin, int end, List&lt;Row&gt; rows) {
        this.begin = begin;
        this.end = end;
        this.rows = rows;
    }

    @Override
    protected List&lt;Entity&gt; compute() {

        if (end - begin &lt;= SINGLE_TREAD_TOP) {
            //actual processing happens here
            List&lt;Entity&gt; preparedEntities = new ArrayList&lt;Entity&gt;(end - begin);
            System.out.println(&quot;  beging: &quot; + begin + &quot; end: &quot; + end);
            for (int i = begin; i &lt; end; ++i) {
                preparedEntities.add(convertRow(rows.get(i)));
            }
            return preparedEntities;
        } else {
            //here we do the dividing the work and combining the results
            // specifies the number of chunks you want to break the data to
            int divider = 5000;
            // one can calculate the divider based on the list size and the number of processor available
            // using the http://download.oracle.com/javase/7/docs/api/java/lang/Runtime.html#availableProcessors()
            // decrease the divider number and examine the changes.

            RowConverter curLeft = new RowConverter(begin, divider, rows);
            RowConverter curRight = new RowConverter(divider, end, rows);
            curLeft.fork();
            List&lt;Entity&gt; leftReslt = curRight.compute();
            List&lt;Entity&gt; rightRes = curLeft.join();
            leftReslt.addAll(rightRes);
            return leftReslt;
        }
    }

    //dummy converted method converting one DTO to another
    private Entity convertRow(Row row) {

        return new Entity(row.getId());
    }
}

// the driver class which own the pool
public class Fjf {

    public static void main(String[] args) {

        List&lt;Row&gt; rawData = initDummyList(10000);
        ForkJoinPool pool = new ForkJoinPool();
        System.out.println(&quot;number of worker threads: &quot; + pool.getParallelism());

        List&lt;Entity&gt; res = pool.invoke(new RowConverter(0, rawData.size(), rawData));

        // add a breakpoint here and examine the pool object.
        //check how the stealCount, which shows number of subtasks taken on by available workers,
        //changes when you use an smaller divider and thus produce more tasks
        System.out.println(&quot;processed list: &quot; + res.size());

    }

    /**
     * creates a dummy list of rows
     *
     * @param size number of rows int he list
     * @return the list of @see Row objects
     */
    private static List&lt;Row&gt; initDummyList(int size) {

        List&lt;Row&gt; rows = new ArrayList&lt;Row&gt;(size);

        for (int i = 0; i &lt; size; i++) {
            rows.add(new Row(i));
        }
        return rows;
    }
}

//dummy classes which should be converted from one form to another
class Row {

    int id;

    public Row(int id) {
        this.id = id;
    }

    public int getId() {
        return id;
    }
}

class Entity {

    int id;

    public Entity(int id) {
        this.id = id;
    }

    public int getId() {
        return id;
    }
}
</pre>
<p>Just copy and paste the code into your IDE and try running and examining it to get deeper understanding of how the framework can be used. post any comment and possible questions that you may have here and I will try to help you own with them.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/a-walk-through-the-forkjoin-api-introduced-in-java-se-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How REST interface covers for the absence of JMX/AMX administration and management interface in GlassFish 3.1</title>
		<link>http://kalali.me/how-rest-interface-covers-for-the-absence-of-jmxamx-administration-and-management-interface-in-glassfish-3-1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-rest-interface-covers-for-the-absence-of-jmxamx-administration-and-management-interface-in-glassfish-3-1</link>
		<comments>http://kalali.me/how-rest-interface-covers-for-the-absence-of-jmxamx-administration-and-management-interface-in-glassfish-3-1/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 13:16:33 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[GlassFish 3.1]]></category>
		<category><![CDATA[JMX. REST]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=1047</guid>
		<description><![CDATA[In this article I explain how GlassFish 3.1 provides REST administration instead of AMX/JMX administration and management interface available in GlassFish 3.0]]></description>
			<content:encoded><![CDATA[<p>For sometime I wanted to write this entry and explain what happened to GlassFish JMX/AMX management and administration interface but being busy with other stuff prevented me from doing so. This article here can be an upgrade to my other article about <a href="http://kalali.me/manage-administrate-and-monitor-glassfish-v3-from-java-code-using-amx-jmx/">GlassFish 3.0 JMX administration interface</a> which I wrote while ago.  Long story short, in GlassFish 3.1 the AMX/JMX is no longer available and instead we can use the <a href="http://wiki.glassfish.java.net/attach/V3FunctionalSpecs/HTTPInterfaceForAdministartion.html">REST interface</a> to change the server settings and perform all administration/management and monitoring activities we need. There are fair number of articles and blog entries all over the web about the RESTful interface which I included them at the end of this blog. Firs of all the rest interface is available trough the administration console application meaning that we can access the interface using a URL similar to: <a href="http://localhost:4848/management/domain/">http://localhost:4848/management/domain/</a> The administration console and the rest interface  are running on a separate virtual server and therefore a separate HTTP Listener and if required transport configuration.  What I will explain here will be the following items:</p>
<ul>
<li>How to use Apache HttpClient to perform administration tasks using GlassFish REST interface</li>
<li>How to find the request parameters for different commands.</li>
<li>GlassFish administration, authentication and transport security</li>
</ul>
<h3>How to use Apache HttpClient to interact with GlassFish administration and management application</h3>
<p>Now back to the RESTful interface, this is a HTTP based interaction channel with the GlassFish administration infrastructure which basically allows us to do almost anything possible to do using asadmin trhough HTTP in a RESTful manner. We can use basically any programming language capable to writing on a socket to interact with the RESTFul interface. Here we will use <a title="Apche HTTPClient" href="http://hc.apache.org/httpcomponents-client-ga/index.html">Apache HTTPClient</a> to take care of sending the commands to GlassFish RESTFul console.  When using GlassFish REST management we can use any of the POST/GET and DELETE methods to perform the following tasks:</p>
<ul>
<li>POST: create and partially update a resource</li>
<li>GET: get information like details of a connection pool</li>
<li>DELETE: to delete a resource</li>
</ul>
<p>Following sample code shows how to use the  to perform some basic operations including updating a resource, getting some resources list, creating a resource and finally deleting it.</p>
<pre class="brush: java; title: ; notranslate">
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.util.logging.Logger;

import org.apache.http.HttpEntity;
import org.apache.http.HttpException;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;

/**
 *
 * @author Masoud Kalali
 */
public class AdminGlassFish {

    //change the ports to your own settng
    private static final String ADMINISTRATION_URL = &quot;http://localhost:4848/management&quot;;
    private static final String MONITORING_URL = &quot;http://localhost:4848/monitoring&quot;;
    private static final String CONTENT_TYPE_JSON = &quot;application/json&quot;;
    private static final String CONTENT_TYPE_XML = &quot;application/xml&quot;;
    private static final String ACCEPT_ALL = &quot;text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&quot;;
    private static final Logger LOG = Logger.getLogger(AdminGlassFish.class.getName());

    public static void main(String args[]) throws IOException, HttpException, URISyntaxException {

        //just chaning the indent level for the JSON and XML output to make them readable, for humans...
        String prettyFormatRestInterfaceOutput = &quot;{&quot;indentLevel&quot;:2}&quot;;
        String response = postInformation(&quot;/domain/configs/config/server-config/_set-rest-admin-config&quot;, prettyFormatRestInterfaceOutput);
        LOG.info(response);
        //getting list of all JDBC resources
        String jdbcResources = getInformation(&quot;/domain/resources/list-jdbc-resources&quot;);
        LOG.info(jdbcResources);

//        creating  a JDBC resource on top of the default pool
        String createJDBCResource = &quot;{&quot;id&quot;:&quot;jdbc/Made-By-Rest&quot;,&quot;poolName&quot;:&quot;DerbyPool&quot;}&quot;;
        String resourceCreationResponse = postInformation(&quot;/domain/resources/jdbc-resource&quot;, createJDBCResource);
        LOG.info(resourceCreationResponse);

//        deleting a JDBC resource
        String deletionReponse = deleteResource(&quot;/domain/resources/jdbc-resource/jdbc%2FMade-By-Rest&quot;);
        LOG.info(deletionReponse);

    }

    //using HTTP get
    public static String getInformation(String resourcePath) throws IOException, AuthenticationException {
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpGet httpG = new HttpGet(ADMINISTRATION_URL + resourcePath);
        httpG.setHeader(&quot;Accept&quot;, CONTENT_TYPE_XML);
        HttpResponse response = httpClient.execute(httpG);
        HttpEntity entity = response.getEntity();
        InputStream instream = entity.getContent();
        return isToString(instream);
    }

    //using HTTP post for creating and partially updating resources
    public static String postInformation(String resourcePath, String content) throws IOException {
        HttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(ADMINISTRATION_URL + resourcePath);
        StringEntity entity = new StringEntity(content);

        //setting the content type
        entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, CONTENT_TYPE_JSON));
        httpPost.addHeader(&quot;Accept&quot;,ACCEPT_ALL);
        httpPost.setEntity(entity);
        HttpResponse response = httpClient.execute(httpPost);

        return response.toString();
    }

    //using HTTP delete to delete a resource
    public static String deleteResource(String resourcePath) throws IOException {
        HttpClient httpClient = new DefaultHttpClient();
        HttpDelete httpDelete = new HttpDelete(ADMINISTRATION_URL + resourcePath);
        httpDelete.addHeader(&quot;Accept&quot;,
                ACCEPT_ALL);
        HttpResponse response = httpClient.execute(httpDelete);
        return response.toString();

    }

//converting the get output stream to something printable
    private static String isToString(InputStream in) throws IOException {
        StringBuilder sb = new StringBuilder();
        BufferedReader br = new BufferedReader(new InputStreamReader(in), 1024);
        for (String line = br.readLine(); line != null; line = br.readLine()) {
            sb.append(line);
        }
        in.close();
        return sb.toString();
    }
}
</pre>
<p>You may ask how could one know what are the required attributes names, there are several ways to do it:</p>
<ul>
<li>Look at the reference documents&#8230;</li>
<li>View the source code of the html page representing that kind of resource, for example for the JDBC resource it is like http://localhost:4848/management/domain/resources/jdbc-resource which if you open it in the browser you will see an html page and viewing its source will give you the names of different attributes. I think the label for the attributes is also the same as the attributes themselves.</li>
</ul>
<p style="text-align: center;"><a href="http://dl.dropbox.com/u/334201/jn-blog-files/html_form.png" class="fancyboxgroup" rel="gallery-1047" title="Using the HTML representation"><img class="aligncenter size-medium wp-image-1076" title="Using the HTML representation" src="http://dl.dropbox.com/u/334201/jn-blog-files/html_form.png" alt="" width="500" height="170" /></a></p>
<ul>
<li>Submit the above page and monitor the request using your browser plugin, for example in case of chrome and for the JDBC resource it is like the following picture</li>
</ul>
<p style="text-align: center;"><a href="http://dl.dropbox.com/u/334201/jn-blog-files/http_request.png" class="fancyboxgroup" rel="gallery-1047" title="Using Chrome Development tools"><img class="aligncenter size-medium wp-image-1077" title="Using Chrome Development tools" src="http://dl.dropbox.com/u/334201/jn-blog-files/http_request.png" alt="" /></a></p>
<h3>GlassFish administration, authentication and transport security</h3>
<p>By default when we install GlassFish or we create a domain the domain administration console is not protected by authentication nor it is protected by HTTPS so whatever we send to the application server from through this channel will be readable by someone sniffing around. Therefore you may need to enable authentication using the following command:</p>
<pre>./asadmin change-admin-password</pre>
<p>You may ask now that we enabled the authenticaiton for the admin console, how we can use it by our sample code, the answer is quite simple,  Just set the credentials for the request object and you are done. Something like:</p>
<pre class="brush: java; title: ; notranslate">
UsernamePasswordCredentials cred = new UsernamePasswordCredentials(&quot;admin&quot;, &quot;admin&quot;);
httpget.addHeader(new BasicScheme().authenticate(cred, httpget));
</pre>
<p>Make sure that you are using correct username and passwords as well as correct request object. In this case the request object is httpGet</p>
<p>Now about the HTTPs to have have encryption during the transport we need to enable the SSL for the admin HTTP listener. following steps show how to use the RESTFul interface through a browser to enable HTTPS for the admin console. When using the browser, GlassFish admin console shows basic HML forms for different resources.</p>
<ol>
<li>Open the <a title="http://localhost:4848/management/domain/configs/config/server-config/network-config/protocols/protocol/admin-listener" href="http://localhost:4848/management/domain/configs/config/server-config/network-config/protocols/protocol/admin-listener">http://localhost:4848/management/domain/configs/config/server-config/network-config/protocols/protocol/admin-listener</a> in the browser</li>
<li>Select true for security-enabled option element</li>
<li>Click Update to save the settings.</li>
<li>Restart server using <a title="http://localhost:4848/management/domain/restart" href="http://localhost:4848/management/domain/restart">http://localhost:4848/management/domain/restart</a></li>
</ol>
<p>The above steps have the same effect as</p>
<pre>./asadmin enable-secure-admin</pre>
<p>This will enable the SSL layer for the admin-listener but it will use the default, self singed certificate. Here I explained how to <a href="http://kalali.me/how-to-prepare-for-and-install-godaddy-ssl-certificate-into-glassfish-v3/">install a GoDaddy digital certificate into GlassFish</a> application server to be sure that none can listen during the transport of command parameters and on the other hand the certificate is valid instead of being self signed.  And here I explained <a href="http://kalali.me/glassfish-v3-and-ejbca-3-x-a-fair-couple-for-mutual-ssl-authentication/">how one can use the EJBCA to setup and use an small inter-corporate certificate authority with GlassFish</a>, though the manual is a little old but it will give you enough understanding to use the newer version of EJBCA.</p>
<p>If you are asking about how our small sample application can work with this dummy self signed certificate of GlassFish you need to wait till next time that I will explain how to bypass the invalid certificate installed on our test server.</p>
<p>In the next part of this series I will cover more details on the monitoring part as well as discussing  how to bypass the self signed Digital certificate during the development&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/how-rest-interface-covers-for-the-absence-of-jmxamx-administration-and-management-interface-in-glassfish-3-1/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Updating Web application&#8217;s Spring Context from Beans definitions partially stored in the database&#8230;</title>
		<link>http://kalali.me/updating-web-applications-spring-applicationcontext-from-beans-definition-stored-in-the-db/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=updating-web-applications-spring-applicationcontext-from-beans-definition-stored-in-the-db</link>
		<comments>http://kalali.me/updating-web-applications-spring-applicationcontext-from-beans-definition-stored-in-the-db/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 06:19:22 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Spring framework]]></category>
		<category><![CDATA[ApplicationListener]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=983</guid>
		<description><![CDATA[Updating Web application's Spring Context from Beans definitions partially stored in the database. The definitions stored in the database are the security provider beans and related configurations which we will load right after the context is initialized.]]></description>
			<content:encoded><![CDATA[<p>As you know spring security providers can get complex as  you may need several beans like, implementations of UserDetailsService, SaltSource, PasswordEncoder, the JDBC setup and so on. I was working on an spring based application which needed to load the security configuration from the database because the system administrator was able to select the security configuration from several pre-defined templates like LDAP, JDBC, File Based, etc. change some attributes like LDAP address or file location, etc. to fit the template in the environment and then apply the new configuration to be used by the application.</p>
<p>I was to port some parts of the application to the web and 3 tier architecture and so I had to have the authentication configured for the web application from the database and current implementations of the required beans for the security providers configurations.</p>
<p>It is plain and simple, load all of the context configuration by adding them to the web.xml and let the spring filter use them to initialize the context or extend XmlWebApplicationContext or its siblings and return the configuration file addresses by overriding the getConfigLocations method. This works perfectly when everything is in plain XML file and you have access to everything&#8230; It wont work when some of context configuration files are stored in the database and the only means of accessing the database is the spring context and that needs to be initialized before you could access the database through it.</p>
<p>What I needed to do was putting together a basic authentication in front of the web application while using the ProviderManager which its configuration is stored in the database.  Without the ProviderManager you cannot have the security filters and thus no security will be applied over the context.</p>
<p>The first part, creating the security configuration and specifying the URL patterns which are needed to be protected is straight forward. The filters use the ProviderManager which is not there and thus the context initialization will fail. To solve this I used the following workaround which might help someone else as well. In all of our templates the ProviderManager bean name was the same so I could simply devise the following solution. Create a temporary basic security provider definition file with the following beans:</p>
<ul>
<li>A basic UserDetailsService bean based on InMemoryDaoImpl</li>
<li>An AuthenticationProvider on top of the above UserDetailsService</li>
<li>A ProviderManager which uses the above AuthenticationProvider.</li>
</ul>
<p>The complete file look like this:</p>
<pre class="brush: xml; title: ; notranslate">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd&quot;
    default-lazy-init=&quot;true&quot;&gt;

    &lt;bean id=&quot;tmpUserDetailsService&quot;
          class=&quot;org.springframework.security.core.userdetails.memory.InMemoryDaoImpl&quot;&gt;
        &lt;property name=&quot;userMap&quot;&gt;
            &lt;value&gt;
            &lt;/value&gt;
        &lt;/property&gt;
    &lt;/bean&gt;

    &lt;bean id=&quot;tmpAuthenticationProvider&quot;
          class=&quot;org.springframework.security.authentication.dao.DaoAuthenticationProvider&quot;&gt;
        &lt;property name=&quot;userDetailsService&quot; ref=&quot;tmpUserDetailsService&quot;/&gt;
    &lt;/bean&gt;

    &lt;bean id=&quot;authenticationManager&quot;
        class=&quot;org.springframework.security.authentication.ProviderManager&quot;&gt;
        &lt;property name=&quot;providers&quot;&gt;
            &lt;list&gt;
                &lt;ref local=&quot;tmpAuthenticationProvider&quot;/&gt;
            &lt;/list&gt;
        &lt;/property&gt;
    &lt;/bean&gt;
&lt;/beans&gt;
</pre>
<address>Using this file, the spring context will get initialized and thus no <strong>NoSuchBeanDefinitionException</strong> will be thrown at your face for the least.  You may say, ok why you are not loading the entire security definitions and configurations after the context is initialized so you wont need to have the temporary security provider, the answer to this question is that having no security applied right after the context initialization is finished is a security risk because at the brief moment before the context get updated with the security definitions, people can access the entire system without any authentication or access control. Let&#8217;s say that brief moment is negliable but a bigger factor here is the possible failure of loading the definitions after the context is initialized means that the application will remain without any security restriction if we do not lock down the application with the temporary provider.</address>
<p>Now that spring context can get initialized you can hook into spring context initialization by a listener and load the security provider from the database into the context to override the temporary beans with the actual one stored in the database.</p>
<p>Too hook into spring context initialization process you need to follow the below steps:</p>
<li>Implement your ApplicationListener, following snippet shows how:</li>
<pre class="brush: java; title: ; notranslate">
public class SpringContextEventListener implements ApplicationListener {

    private XmlWebApplicationContext context;

    public void onApplicationEvent(ApplicationEvent e) {

        if (e instanceof ContextRefreshedEvent) {
            context = (XmlWebApplicationContext) ((ContextRefreshedEvent) e).getApplicationContext();
            loadSecurityConfigForServer();
        }
    }

    private void loadSecurityConfigForServer() {

        AutowireCapableBeanFactory factory = context.getAutowireCapableBeanFactory();
        BeanDefinitionRegistry registry = (BeanDefinitionRegistry) factory;
        String securityConfig = loadSecurityConfigFromDatabase();
        XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(registry);
        xmlReader.loadBeanDefinitions(new ByteArrayResource(securityConfig.getBytes()));
    }

    private String loadSecurityConfigFromDatabase() {
        //use the context and load the configuration from the database
    }
}
}
</pre>
<li>Now that you have a listener which listen for ApplicationContext event and load your security configuration  you can hook this listener to you context because by its own it wont do anything <img src='http://kalali.me/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
<p>To add the listener to your application context, just add something similar to the following snippet to one of the context configuration files and you will be done.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;bean id=&quot;applicationListener&quot; class=&quot;your.package.SpringContextEventListener&quot;/&gt;
</pre>
<p><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;">This is all you needed to do in order to get the context updated after web application starts without imposing any security hole on the application for lack of security definitions right after the application startup.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/updating-web-applications-spring-applicationcontext-from-beans-definition-stored-in-the-db/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GlassFish inspired wallpapers for your desktops&#8230;</title>
		<link>http://kalali.me/glassfish-inspired-wallpapers-for-your-desktops/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=glassfish-inspired-wallpapers-for-your-desktops</link>
		<comments>http://kalali.me/glassfish-inspired-wallpapers-for-your-desktops/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 15:37:56 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Logo]]></category>
		<category><![CDATA[Wallpaper]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=1019</guid>
		<description><![CDATA[GlassFish inspired wallpapers for your desktops.]]></description>
			<content:encoded><![CDATA[<p>Well, I saw <a href="http://blog.eisele.net/2011/07/some-free-fun-stuff-glassfish.html">Markus</a> did some nice wallpapers for GlassFish and I tried to mimic him and do some wallpapers. I should say that he is the man of many talents and my wallpapers are, well, screaming far behind his. The main background, the texture, is coming from  <a href="http://www.flickr.com/photos/imageabstraction/4228890623/in/photostream/">ImageAbstraction</a> and are available under  <a href="http://creativecommons.org/licenses/by-nc/2.0/deed.en">(CC BY-NC 2.0)</a>. The GlassFish logo is available at <a href="http://glassfish.java.net/glassfish_buttons/glassfish_logo.png" class="fancyboxgroup" rel="gallery-1019">GlassFish.org</a></p>
<p>The images themselves are included in the following album in 3 sizes, <a href="https://picasaweb.google.com/kalali/GlassFishWallpapers#5628858137496058578">1440*900</a>, <a href="https://picasaweb.google.com/kalali/GlassFishWallpapers#5628858136923582482">1680*1050</a> and <a href="https://picasaweb.google.com/kalali/GlassFishWallpapers#5628858140363021090">1600*1200</a>.<br />
<center></p>
<p><embed type="application/x-shockwave-flash" src="https://picasaweb.google.com/s/c/bin/slideshow.swf" width="400" height="267" flashvars="host=picasaweb.google.com&#038;noautoplay=1&#038;hl=en_GB&#038;feat=flashalbum&#038;RGB=0x000000&#038;feed=https%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fkalali%2Falbumid%2F5628858046510080449%3Falt%3Drss%26kind%3Dphoto%26hl%3Den_GB" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></p>
<p></center></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/glassfish-inspired-wallpapers-for-your-desktops/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Proposed features and functionalities of JavaTM Message Service 2.0, JSR-343</title>
		<link>http://kalali.me/part-02-jsr-343/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=part-02-jsr-343</link>
		<comments>http://kalali.me/part-02-jsr-343/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 06:52:36 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE 7]]></category>
		<category><![CDATA[JMS 2.0]]></category>
		<category><![CDATA[JSR-343]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=966</guid>
		<description><![CDATA[Proposed features and functionalities of JavaTM Message Service 2.0, JSR-343]]></description>
			<content:encoded><![CDATA[<p>This is the second entry on the <a href="http://kalali.me/tag/jsr-343/">series</a> of articles I will write on JMS 2.0. You can find the first entry <a title="Brief overview of JSR 343: JavaTM Message Service 2.0" href="http://kalali.me/jms2-jsr/">here</a>. In this article I will iterate over the suggested features which <strong>might be included</strong> in the JMS 2.0 based on the final decisions by the expert group.</p>
<p>I classified the features into some meaningful categoriz which are as follow:</p>
<h2>The API ease of use</h2>
<p>The first set that I am going to cover is around the ease of use of the API which despite being elegant is a little hard to start with specially for new developers whom look for the asynchronous communication solutions in Java EE platform. The features and changes proposed for this part are as follow:</p>
<ul>
<li>As usual the backward compatibility is a trend which the EG is going to adhere. Any application working with JMS 1.1 will continue to work with JMS 2.</li>
<li>The API wont get harder to use despite the additional features which are going to be included in the next version.</li>
<li>Using JMS from Java SE will be possible with JMS 2.0 as it is with JMS 1.1</li>
<li>API is going to get simpler by using more annotations and integration of the JMS API with the CDI</li>
<li>Using the MDBs is  going to get simpler and MDBs is going to see a revamp as did other EJB types in previous versions of Java EE.</li>
<li>The API should make less use of unchecked exceptions</li>
</ul>
<h2>Changes interesting to vendors</h2>
<p>These are a set of proposed changes to make it easier for the JMS vendors and application server vendors to implement the JMS interface to their JMS brokers as well as integrating the broker into different application servers.</p>
<ul>
<li>An standard interface will be defined to make it possible for any any compliant application server to integrate with any of compliant JMS implementation. It is more likely to happen through the JCA adapter and making it mandatory.</li>
<li>&#8220;Clarify how the JMS provider should interact with Transaction Managers. In particular, the responsibilities of the JMS Provider, the TM and the App Server during recovery need to be clearly defined.&#8221;</li>
<li>Clarifying the relation between JMS provider and other Java EE services and APIs specially the transaction manager. It will be more about documentation rather than implementations.</li>
</ul>
<h2>Other enhancements and changes</h2>
<ul>
<li>Defining the transport security at the API level for sake of more portability.</li>
<li>Message compression for faster transport&#8230;</li>
<li>Timed messages which will be delivered by the provider to the consumer on schedule specified for the message.</li>
<li>Asynchronous send with call back enabled acknowledge in order not to block the client until server sends back the acknowledge.</li>
<li>supporting message consumption from the same session by multiple threads</li>
<li>Deprecate JMS 1.0 Queue and Topic specific interfaces in favor of JMS 1.1 unified interfaces</li>
<li>Ability to send objects directly, without need to wrap in a javax.jms.Message</li>
<li>Standardise the &#8220;connection string&#8221; to define server IPs, timeouts, etc, as in ActiveMQ, OpenMQ, etc.</li>
<li>Standardizing the interaction between Clint and the provider in clustered environment to make the applications more portable from one farm of JMS providers to another.</li>
</ul>
<p>I am member of the JMS 2.0 expert group but this post or any other post in my personal blog does not reflect the expert group opinion or the opinion of my employer on the subject unless you could not see this paragraph at the end of the post <img src="http://kalali.me/wp-includes/images/smilies/icon_smile.gif" alt=":-)" /> . The EG is not going to be held responsible to provide any of these features in the JMS 2.0 as the spec is still open and nothing is finalised. It is just to give you a overview of what is being discussed in the EG. To find more information about the JMS 2.0, take a look at the JCP page for the spec at  <a href="http://www.jcp.org/en/jsr/detail?id=343">http://www.jcp.org/en/jsr/detail?id=343</a> or its homepage at Java.net at <a href="http://java.net/projects/jms-spec/pages/Home">http://java.net/projects/jms-spec/pages/Home</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/part-02-jsr-343/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Some best practices on Spring framework context configuration files naming</title>
		<link>http://kalali.me/best-practices-on-spring-configuration-files/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=best-practices-on-spring-configuration-files</link>
		<comments>http://kalali.me/best-practices-on-spring-configuration-files/#comments</comments>
		<pubDate>Tue, 17 May 2011 11:32:38 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[context]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://kalali.me/best-practices-on-spring-configuration-files/</guid>
		<description><![CDATA[A summarized list of best practices about how to use spring context configuration files in a proper and clear maner.]]></description>
			<content:encoded><![CDATA[<p><!-- p.p1 {margin: 0.0px 0.0px 16.0px 0.0px; line-height: 20.0px; font: 16.0px 'Lucida Grande'} li.li2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px 'Lucida Grande'} span.s1 {text-decoration: underline ; color: #013266} ul.ul1 {list-style-type: disc} -->Like many other developers you may required to work on a pre-existing spring based codebase developed by a team of developers in the past couple of years where few of them really know why there are handful of spring configuration file scattered here and there and each one of them has a mixture of different configuration elements like security, aop, data sources and service definitions without a proper naming of the configuration files. That is a pain in the neck and headache to follow and further refactor/refine. Here I list some of the best practices around spring context configuration files which might help ease the reading and understanding the files:</p>
<ol>
<li>Use unified and proper naming schema like <em>applicationContexte-[server|client |shared]&lt;Configuration Domain&gt;-&lt;Configuration | Beans&gt;-&lt;Additional Clarifier&gt;.xml </em>which may seem to be long but believe me it will save someone or yourself fair deal of time later on. The explanation of the naming schema is as follow:
<ul>
<li>If your if the codebase is to run both client and server, some modules shared and some exclusive for each tier, use server and client to distinguish them.</li>
<li>The configuration domain can be any of: security, data-access, aop, resources, etc.</li>
<li>Use configuration when the file purpose is configure a set of services using some existing base beans</li>
<li>Use beans when you are defining the base beans which will be used to put together the services for the whole system</li>
</ul>
</li>
<li>Do not reference any of these files directly in the source code but rather use one single utility class responsible for returning references to different groups of the configuration files used in different places. Make sure that the methods returning these references uses proper <del>signature</del> return type like an String[] even if you have just one file for an specific domain or group of configuration files. Spring provides the possibility of <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-factory-xml-import">composing a configuration file from multiple other files</a> but I prefer using the code as it gives us more flexibility.</li>
<li>Leave a one paragraph comment describing the purpose of the the document rather than leaving it as it is and hope that whoever is going to read it will understand the purpose by looking at the content or at the name because you don&#8217;t know when someone will look at the code and how s/he will interpret the content. Do not leave room for next to come people to guess where to put the new bean definitions, etc but rather specify it by leaving some comments if not documentation about the configuration file.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/best-practices-on-spring-configuration-files/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Brief overview of JSR 343: JavaTM Message Service 2.0</title>
		<link>http://kalali.me/jms2-jsr/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jms2-jsr</link>
		<comments>http://kalali.me/jms2-jsr/#comments</comments>
		<pubDate>Tue, 17 May 2011 10:45:04 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[JMS]]></category>
		<category><![CDATA[JSR-343]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=933</guid>
		<description><![CDATA[This is a brief overview of the JSR 343 which is the the new specification for the JMS 2.0 API.]]></description>
			<content:encoded><![CDATA[<p>Well, as many of us already know Oracle submitted the JSR for Java EE 7 which is sort of an umbrella JSR for many update in already existing specifications, new versions of some JSRs and some completely new JSRs which will be part of the grand <a href="http://jcp.org/en/jsr/detail?id=342">Java EE 7 &#8211; JSR 342</a>.</p>
<p>One of these JSRs is the <a href="http://jcp.org/en/jsr/summary?id=343">JSR 343</a> which introduces a new version of JMS into the platform as an evolution of its previous version, JSR-914, and will unify the JMS usage with what added to the platform in the past 8 years.</p>
<p>The following represent some very simple usecases of JMS in the enterprise while complex multiphase transactional usecases are not unusual when MDBs and XA data sources are involved.</p>
<ul>
<li><img class="alignright" title="JMS API architecture" src="http://download.oracle.com/javaee/5/tutorial/doc/figures/jms-programmingModel.gif" alt="" width="262" height="202" />JMS itself is for asynchronous communication and widely used to communicate some execution instructions from one node or point to another or a set of other points. For example long running queries can be queued using a JMS queue to get processed by another point in the system while the query client is not blocked for the query result.</li>
</ul>
<ul>
<li>Or it can be used to communicate a common set of instructions to many interested parties which may or may not be around the communication happens, durable subscriptions and persisted topics. For example when clients need to get an ordered set of update messages to update a localcache when they get online after some times. Each client will get its own copy of messages it should receive when getting online.</li>
</ul>
<p>JMS API provides enough functionalities to realize most of our design out of the specification and the minor features and functionalities not included in the JSR while required by some designs are covered by the vendor specific pack of enhancement and tweaks provided in the broker level and through the vendor specific API.</p>
<p>You may ask if the current JMS API provides all we need, why a new JSR should be put on the table, the answer mainly relies on the theme for Java EE 7 which is making Java EE more cloud friendly and sort of cloud enabled by nature rather than by product.</p>
<p>The details of JMS 2.0 spec goals are listed at the JSR <a title="homepage" href="http://www.jcp.org/en/jsr/detail?id=343">homepage</a> but a brief list can be seen as follow:</p>
<ul>
<li>Community requested features and enhancements.</li>
<li>Make the JSR more cloud friendly based on how Java EE 7 will define &#8220;to be cloud friendly&#8221;</li>
<li>Cleanup of some ambiguity in the relation of JMS with other Java EE specs.</li>
<li>Make the API easier to use, more annotations and more generics will be involved for the least of the things or maybe reducing number of boxes and lines in the aove figure  could help many to start with the API faster.</li>
<li>Make necessary changes to benefit from the JSR-299 or Contexts and Dependency Injection to easier and more unified use of API.</li>
</ul>
<p>In the follow up posts I will iterate over each one of these bullet points in more details.</p>
<p>I am member of the JMS 2.0 expert group but this post or any other post in my personal blog does not reflect the expert group opinion or the opinion of my employer on the subject unless you could not see this paragraph at the end of the post <img src='http://kalali.me/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/jms2-jsr/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Writing Solaris Service Management Facility (SMF) service manifest</title>
		<link>http://kalali.me/authoring-solaris-service-management-facility-smf-service-manifest/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=authoring-solaris-service-management-facility-smf-service-manifest</link>
		<comments>http://kalali.me/authoring-solaris-service-management-facility-smf-service-manifest/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 06:31:22 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[OpenSolaris]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[manifest]]></category>
		<category><![CDATA[Service authoring]]></category>
		<category><![CDATA[SMF]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=916</guid>
		<description><![CDATA[This article explains how to turn a custom service to a daemon managed by Solaris Service Management Facility (SMF) to take advantage its service management facilities]]></description>
			<content:encoded><![CDATA[<p>SMF services are basically daemons staying in background and waiting for the requests which they should server, when the request come the daemon wake ups, serve the request and then wait for the next request to come.</p>
<p>The services are building using software development platforms and languages but they have one common aspect which we are going to discuss here. The service manifests which describe the service for the SMF and let the SMF manage and understand the service life cycle.</p>
<p>To write a service manifest we should be familiar with XML and the service manifest schema located at /usr/share/lib/xml/dtd/service_bundle.dtd.1.  This file specifies what elements can be used for describing a service for the SMF.</p>
<p>Next thing we need is a text editor and preferable an XML aware text editor. The Gnome gedit can do the task for us.</p>
<p>The service manifest file composed of 6 important elements which are listed below:</p>
<div id="_mcePaste">
<ul>
<li><span style="font-size: 11.6667px;">The service declaration:  specifies the service name, type and instantiation model</span></li>
<li><span style="font-size: 11.6667px;">Zero or more dependency declaration elements: Specifies the service dependencies</span></li>
<li><span style="font-size: 11.6667px;">Lifecycle methods: Specifies the start, stop and refresh methods</span></li>
<li><span style="font-size: 11.6667px;">Property groups: Which property groups the service description has.</span></li>
<li><span style="font-size: 11.6667px;">Stability element: how stable the service interface is considering version changes</span></li>
<li><span style="font-size: 11.6667px;">Template element: more human readable information for the service.</span></li>
</ul>
</div>
<p>To describe a service, first thing we need to do is identifying the service itself. Following snippet shows how we can declare a service named jws.</p>
<pre>&lt;service name='network/jws’ type='service' version='1'&gt;
&lt;single_instance/&gt;</pre>
<p>The first line specifies the service name, version and its type. The service name attribute forms the FMRI of the service which for this instance will be svc:/network/jws. In the second line we are telling SMF that it should only instantiate one instance of this service which will be svc:/network/jws:default. We can use the create_default_instance element to manipulate automatic creation of the default instance.</p>
<p>All of the elements which we are going to mention in the following sections of this article are immediate child elements of the service element which itself is a child element of the service_bundle element.</p>
<p>The next important element is dependency declaration element. We can have one or more of this element in our service manifest.</p>
<pre>&lt;dependency name='net-physica' grouping='require_all ' restart_on='none' type='service'&gt;
&lt;service_fmri value='svc:/network/physical'/&gt;
&lt;/dependency&gt;</pre>
<p>Here we are telling that our service depends on the svc:/network/physical service and this service needs to be online before our service can start. Some of the values for the grouping attribute are as follow:</p>
<div id="_mcePaste">
<ul>
<li><span style="font-size: 11.6667px;">The require_all which represent that all services marked with this grouping must be online before our service came online</span></li>
<li><span style="font-size: 11.6667px;">The require_any which represents that any of the services in this grouping suffice and our service can become online if one of them is online</span></li>
<li><span style="font-size: 11.6667px;">The optional_all presence of the services marked with this grouping is optional for our service. Our service works with or without them.</span></li>
<li><span style="font-size: 11.6667px;">The exclude_all:  specifies the services which may have conflict with our service and we cannot become online in presence of them</span></li>
</ul>
</div>
<p>The next important elements are specifying how the SMF should start, stop and refresh the service. For these tasks we use three exec_method elements as follow:</p>
<pre>&lt;exec_method name='start' type='method' exec='/opt/jws/runner start' timeout_seconds='60'&gt;
&lt;/exec_method&gt;</pre>
<p>This is the start method, SMF will invoke what the exec attribute specifies when it want to start the service.</p>
<pre>&lt;exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'&gt;
&lt;/exec_method&gt;</pre>
<p>The SMF will terminate the process it started for the service using a kill signal. By default it uses the SIGTERM but we can specify our own signal. For example we can use &#8216;kill -9&#8242; or &#8216;kill -HUP&#8217; or any other signal we find appropriate for our service termination.</p>
<pre>&lt;exec_method name='refresh' type='method' exec='/opt/jws/runner reload_cof' timeout_seconds='60'&gt;
&lt;/exec_method&gt;</pre>
<p>The final method which we should describe is the refresh method in which we should reload the service configuration without disturbing its function.</p>
<p>The start and stop methods description are required to be present in the manifest in order to import it into the SMF repository but the refresh method description and implementation is optional.</p>
<p>The timeout_seconds=&#8217;60&#8242; specifies that the SMF should wait for 60 seconds before aborting the method execution and retrying it over. We can use longer timeout when we know that the execution of the method take longer or lower timeout when we know that our service starts sooner.</p>
<p>The property group elements specify which property groups the SMF should associate with the service.  We can use as many of the SMF built-in property groups or define our own property groups.</p>
<pre>&lt;property_group name='startd' type='framework'&gt;
&lt;propval name='ignore_error' type='astring' value='core,signal'/&gt;
&lt;/property_group&gt;</pre>
<p>The above snippet shows how we can define using a framework built-in property group. The built-in property groups and their properties have meaning for the SMF framework and change its way of dealing with our service.  For example the above snippet says that the SMF should ignore core dump termination of suppresses of this service via a kill signal from another application.</p>
<p>Next important element is the stability element which specifies whether the property names, service name, its dependencies and other service attributes may or may not change for the next release. For example the following snippet specifies that the service attributes may change in the next release.</p>
<pre>&lt;stability value='Unstable'/&gt;</pre>
<p>Finally we have the template element which contains descriptive information about the service, for example we can have something like the following element which describes our service for human users.</p>
<pre>&lt;template&gt;
&lt;common_name&gt;
&lt;loctext xml:lang=’Java'&gt;Java Network Server &lt;/loctext&gt;
&lt;/common_name&gt;
&lt;documentation&gt;
&lt;manpage title='JWS' section='1M' manpath='/usr/share/man'/&gt;
&lt;/documentation&gt;
&lt;/template&gt;</pre>
<p>The entire element is self describing except for the man page element which specifies where the man utility command should look for the man pages for the jws service.</p>
<div id="_mcePaste">All of these elements should be saved into an XML file with the following structure:</div>
<pre>&lt;?xml version='1.0'?&gt;
&lt;!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'&gt;
&lt;service_bundle ...&gt;
&lt;service ...&gt;
&lt;single_instance .../&gt;
&lt;dependency ... /&gt;
&lt;exec_method... /&gt;
&lt;property_group .../&gt;
&lt;stability .../&gt;
&lt;template ...&gt;
&lt;/service&gt;
&lt;/service_bundle&gt;</pre>
<p>This is a raw representation of what the service manifest bare bone cal look like. The syntax is not accurate and the attributes and child elements are omitted to make it easier to scan by the eyes.</p>
<p>The service_bundle, service, and  start and stop method elements are mandatory while other elements are optional.</p>
<p>Now we should install the service into the SMF repository and then administrate it. For installing the service we can use the following command.</p>
<pre># svccfg import /path/to/manifest.xml</pre>
<p><span style="font-size: 11.6667px;">When we import the service manifest into the service repository, SMF will scan the service profiles and check whether this service is required to be enabled either directly or because of a dependent service or not. If required, the SMF will use the start method specified in the manifest to start the service. But before starting it, SMF will check its dependencies and start any required service recursively if they are not already online.</span></p>
<p>Reviewing the XML schema located at /usr/share/lib/xml/dtd/service_bundle.dtd.1 and the staying tuned for my next few entries is recommended for grasping a better understanding of the whole SMF and Solaris Services administration/management.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/authoring-solaris-service-management-facility-smf-service-manifest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solaris fault administration using fmadm command</title>
		<link>http://kalali.me/solaris-fault-administration-using-fmadm-command/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=solaris-fault-administration-using-fmadm-command</link>
		<comments>http://kalali.me/solaris-fault-administration-using-fmadm-command/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 23:48:16 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[OpenSolaris]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[Fault Administration]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=910</guid>
		<description><![CDATA[In this article we will study how we can use the fmadm command to get the list of faulty components along with the detailed information about the fault. Before starting this article we should have a command console open and then we can proceed with using the fmadm command. The most basic form of using fmadm [...]]]></description>
			<content:encoded><![CDATA[<p>In this article we will study how we can use the fmadm command to get the list of faulty components along with the detailed information about the fault.</p>
<p>Before starting this article we should have a command console open and then we can proceed with using the fmadm command. <span style="font-size: 11.6667px;">The most basic form of using fmadm command is using its faulty subcommand as follow</span></p>
<pre># fmadm faulty</pre>
<p>When we have no error in the system, this command will not show anything and exit normally but with a faulty component  the output will be different, for example in the following sample we have  a faulty ZFS pool because some of its underlying devices are missing.</p>
<div id="_mcePaste"><img class="aligncenter" title="fmadm command output" src="http://dl.dropbox.com/u/334201/jn-blog-files/3180_07_01.png" alt="" width="659" height="356" /></div>
<div id="_mcePaste">Starting from top we have:</div>
<div>
<ul>
<li><span style="font-size: 11.6667px;"> <span style="font-size: 11.6667px;">Identification record: This record consisting of  the timestamp, a unique event ID, a message Id letting us know which knowledge repository article we can refer to for learning more about the problem and troubleshooting and finally the fault severity which can be Minor or Major.</span></span></li>
<li><span style="font-size: 11.6667px;">Fault Class: This field allows us to know what is the device hierarchy causing this fault</span></li>
<li><span style="font-size: 11.6667px;">Affects: tells us which component of our system is affected and how. In this instance some devices are missing and therefore the fault manager takes the Zpool out of service.</span></li>
<li><span style="font-size: 11.6667px;">Problem in: shows more details about the problem root. In this case the device id.</span></li>
<li><span style="font-size: 11.6667px;">Description: this field refer us to the a knowledge base article discussing this type of faults</span></li>
<li><span style="font-size: 11.6667px;">Response:  Shows what action(s) were executed by fault manager to repair the problem.</span></li>
<li><span style="font-size: 11.6667px;">Impact: describe the effect of the fault on the overall system stability and the component itself</span></li>
<li><span style="font-size: 11.6667px;">Action: a quick tip on the next step administrator should follow to shoot the problem. This step is fully described in the knowledge base article we were referred in the description field.</span></li>
</ul>
</div>
<p>Following figure shows the output for proceeding with the suggested action.</p>
<div id="_mcePaste"><img class="aligncenter" title="fmadm taking action" src="http://dl.dropbox.com/u/334201/jn-blog-files/3180_07_02.png" alt="" width="620" height="262" /></div>
<p>As we can see the same article we were referred to, is mentioned here again. We can see that two of the three devices have failed and fpool had no replica for each of those failed device to replace them automatically.</p>
<p>If we had a mirrored pool and one of the three devices were out of service, the system could automatically take corrective actions and replace continue working in a degraded status until we replace the faulty device.</p>
<p>The fault management framework is a plug-able framework consisting of diagnosis engines and subsystem agents. Agents and diagnosis engine contains the logic for assessing the problem, performing corrective actions if possible and filing the relevant fault record into the fault database.</p>
<p>To see a list of agents and engines plugged into the fault management framework we can use config subcommand of the fmadm command. Following figure shows the output for this command.</p>
<div id="_mcePaste"><img class="aligncenter" title="fmadm configuration" src="http://dl.dropbox.com/u/334201/jn-blog-files/3180_07_03.png" alt="" width="555" height="244" /></div>
<p>As we can see in the figure, there are two engines deployed with OpenSolaris, eft and the zfs-diagnosis. The eft, standing for Eversholt Fault Diagnosis Language, is responsible for assessing and analyzing hardware faults while the zfs-diagnosis is a ZFS specific engine which analyzes and diagnoses ZFS problems.</p>
<div id="_mcePaste"><span style="font-size: 11.6667px;">The  fmadm is a powerful utility we which can perform much more than what we discussed.  Here we can see few other tasks we can perform using the fmadm.</span></div>
<div><span style="font-size: 11.6667px;">We can use the repaired subcommand of the fmadm utility to notify the FMD about a fault being repaired so it changes the component status and allows it to get enabled and utilized.</span></div>
<p>For example to notify the FMD about repairing the missing underlying device of the ZFS pool we can use the following command.</p>
<pre># fmadm repaired  zfs://pool=fpool/vdev=7f8fb1c77433c183</pre>
<p>We can rotate the log files created by the FMD when we want to keep a log file in a specific status or when we want to have a fresh log using the rotate subcommand as shown below.</p>
<pre># fmadm rotate errlog | fltlog</pre>
<p>The fltlog and errlog are two log files residing in the /var/fm/fmd/ directory storing all event information regarding faults and the errors causing them.</p>
<p>To learn more about fmadm command we can use the man pages and the short help provided with the distribution. Following commands shows how we can invoke the man pages and the short help message.</p>
<pre># man fmadm</pre>
<pre># fmadm --help</pre>
<div id="_mcePaste">A good starting resource is the FM wiki page which is located at <a href="http://wikis.sun.com/display/OpenSolarisInfo/Fault+Management">http://wikis.sun.com/display/OpenSolarisInfo/Fault+Management</a></div>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/solaris-fault-administration-using-fmadm-command/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Monitoring ZFS pools performance using zpool iostat</title>
		<link>http://kalali.me/monitoring-zfs-pools-performance-using-zpool-iostat/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=monitoring-zfs-pools-performance-using-zpool-iostat</link>
		<comments>http://kalali.me/monitoring-zfs-pools-performance-using-zpool-iostat/#comments</comments>
		<pubDate>Thu, 30 Dec 2010 20:04:50 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[OpenSolaris]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[monitor]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[zfs]]></category>
		<category><![CDATA[zpool]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=908</guid>
		<description><![CDATA[In this article you can learn how to monitor ZFS pool performance attributes using command line tools in Solaris.]]></description>
			<content:encoded><![CDATA[<p>Performance, performance, performance; this is what we hear in all software development and management sessions. ZFS provides few utility commands to monitor one or more pools&#8217; performance.</p>
<p>You should remember that we used fsstat command to monitor the UFS performance metrics. We can use iostat subcommand of the zpool command to monitor the performance metrics of ZFS pools.</p>
<p>The iostat subcommand provides some options and arguments which we can see in its syntax shown below:</p>
<pre>iostat [-v] [pool] ... [interval [count]]</pre>
<p>The -v option will show detailed performance metrics about the pools it monitor including the underlying devices.  We can pass as many pools as we want to monitor or we can omit passing a pool name so the command shows performance metrics of all commands.  The interval and count specifies how many times we want the sampling to happen what is the interval between each subsequent sampling.</p>
<p>For example we can use the following command to view detailed performance metrics of fpool for 100 times in 5 seconds interval we can use the following command.</p>
<pre># zpool iostat -v fpool 5 100</pre>
<div id="_mcePaste">The output for this command is shown in the following figure.</div>
<div id="_mcePaste"><img class="aligncenter" title="Monitor ZFS pool performance" src="http://dl.dropbox.com/u/334201/jn-blog-files/3180_02_24.png" alt="" width="431" height="341" /></div>
<p>The first row shows the entire pool capacity stats including how much space were used upon the sampling and how much was available. The second row shows how many reads and writes operations performed during the interval time and finally the last column shows the band width used for reading from this pools and writing into the pool.</p>
<div id="_mcePaste">The zpool iostat retrieve some of its information from the read-only attributes of the requested pools and the system metadata and calculate some other outputs by collecting sample information on each interval.</div>
<div id="_mcePaste"></div>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/monitoring-zfs-pools-performance-using-zpool-iostat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My slides for Java EE Security session at JavaForum meeting 69</title>
		<link>http://kalali.me/my-slides-for-java-ee-security-session-at-javaforum-meeting-69/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=my-slides-for-java-ee-security-session-at-javaforum-meeting-69</link>
		<comments>http://kalali.me/my-slides-for-java-ee-security-session-at-javaforum-meeting-69/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 08:41:06 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Authorization]]></category>
		<category><![CDATA[JSR-115]]></category>
		<category><![CDATA[JSR-196]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=883</guid>
		<description><![CDATA[On the 7th of december I presented the &#8220;Security in Java EE platform: what is included, what is missing&#8221; session in the JavaForum meeting. Although I arrived somehow late and left  right after the last presentation which was done by Chet Hendrickson but I can say that the athmospher was really friendly and enjoyable. I [...]]]></description>
			<content:encoded><![CDATA[<p>On the 7th of december I presented the &#8220;<a href="http://dl.dropbox.com/u/334201/jn-blog-files/Security%20in%20Java%20EE%20platform%3A%20what%20is%20included%2C%20what%20is%20missing.ppt">Security in Java EE platform: what is included, what is missing</a>&#8221; session in the <a href="http://www.javaforum.se/jf/archive.jsp#m69">JavaForum meeting</a>.</p>
<p>Although I arrived somehow late and left  right after the last presentation which was done by Chet Hendrickson but I can say that the athmospher was really friendly and enjoyable. I enjoyed the HTML 5 session and more than that I enjoyed the session presented by Chet, his way of presenting the session was different and pretty fun.</p>
<p>Following album contains some photos from the session.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="267" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="flashvars" value="host=picasaweb.google.com&amp;hl=en_GB&amp;feat=flashalbum&amp;RGB=0x000000&amp;feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fkalali%2Falbumid%2F5548350600348226449%3Falt%3Drss%26kind%3Dphoto%26hl%3Den_GB" /><param name="src" value="http://picasaweb.google.com/s/c/bin/slideshow.swf" /><embed type="application/x-shockwave-flash" width="400" height="267" src="http://picasaweb.google.com/s/c/bin/slideshow.swf" flashvars="host=picasaweb.google.com&amp;hl=en_GB&amp;feat=flashalbum&amp;RGB=0x000000&amp;feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fkalali%2Falbumid%2F5548350600348226449%3Falt%3Drss%26kind%3Dphoto%26hl%3Den_GB"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/my-slides-for-java-ee-security-session-at-javaforum-meeting-69/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Managing Logical network interfaces in Solaris</title>
		<link>http://kalali.me/managing-logical-network-interfaces-in-solaris/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=managing-logical-network-interfaces-in-solaris</link>
		<comments>http://kalali.me/managing-logical-network-interfaces-in-solaris/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 22:56:25 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[Logical network interface]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[Solaris]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=842</guid>
		<description><![CDATA[In this article you will see detailed explanation about Logical NetWork interfaces in Solaris OS. Creating, deleting and logical interface configuration are explained here.]]></description>
			<content:encoded><![CDATA[<p>Like other operating system we can assign multiple IP address to a network interface. This secondary address are called logical interfaces and we can use them to make one machine with one single network interface own multiple IP addresses for different purposes. We may need to assign multiple IP address to an interface to make it available to both internal and external networks or for testing purposes.</p>
<p>We should have one network interface configured in our system in order to create additional logical interfaces.</p>
<p>We are going to add a logical interface to e1000g1 interface with a 10.0.2.24 as its static IP address. Before doing so let’s see what network interface we have using the ifconfig command.</p>
<div id="_mcePaste"><a href="http://kalali.me/wp-content/uploads/2010/11/3180_04_121.png" class="fancyboxgroup" rel="gallery-842" title="3180_04_12"><img class="size-full wp-image-845 aligncenter" title="3180_04_12" src="http://kalali.me/wp-content/uploads/2010/11/3180_04_121.png" alt="" width="646" height="102" /></a></div>
<p>Now to add the logical interface we only need to execute the following command:</p>
<pre># ifconfig e1000g1 addif 10.0.2.24/24 up</pre>
<div id="_mcePaste">Invoking this command performs the following tasks:</div>
<div id="_mcePaste">
<ul>
<li><span style="font-size: 13.3333px;">Create a logical interface named e1000g1:1. The naming schema for logical interfaces conforms with interface_name:logical_interface_number which the number element can be from 1 to 4096.</span></li>
<li><span style="font-size: 13.3333px;">Assign 10.0.2.24/24 as its IP address, net mask and broadcast address.</span></li>
</ul>
</div>
<p>Now if we invoke ifconfing -a command the output should contain the logical interface status as well. The following figure shows a fragment of ifconfig -a command.</p>
<div id="_mcePaste"><a href="http://kalali.me/wp-content/uploads/2010/11/3180_04_131.png" class="fancyboxgroup" rel="gallery-842" title="3180_04_13"><img class="size-full wp-image-846 alignnone" title="3180_04_13" src="http://kalali.me/wp-content/uploads/2010/11/3180_04_131.png" alt="" width="687" height="145" /></a></div>
<p><span style="font-size: 13.3333px;">Operating system does not retain this configuration over a system reboot and to make the configuration persistent we need to make some changes in the interface configuration file. For example to make the configuration we applied in this recipe persistent the content of /etc/opensolaris.e1000g1 should something similar to the following snippet.</span></p>
<pre>10.0.2.23/24
<span style="font-size: 11.6667px;">addif 10.0.2.24/24</span></pre>
<p>The first line as we discussed in recipe 3 of this chapter assign the given address to this interface and the second like adds the logical interface with the given address to this interface. <span style="font-size: 11.6667px;">To remove a logical interface we can simply un-plumb it using the ifconfig command as shown below.</span></p>
<pre># ifconfig e1000g1:1 unplumb</pre>
<p>When we create a logical interface, OpenSolaris register that interface in the network and any packet received by the interface will be delivered to the same stack that handles the underlying physical interface.</p>
<p>Like other operating system we can assign multiple IP address to a network interface. This secondary address are called logical interfaces and we can use them to make one machine with one single network interface own multiple IP addresses for different purposes. We may need to assign multiple IP address to an interface to make it available to both internal and external networks or for testing purposes.</p>
<p>We should have one network interface configured in our system in order to create additional logical interfaces.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/managing-logical-network-interfaces-in-solaris/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring Solaris Link Aggregation (Ethernet bonding)</title>
		<link>http://kalali.me/configuring-solaris-link-aggregation-ethernet-bonding/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=configuring-solaris-link-aggregation-ethernet-bonding</link>
		<comments>http://kalali.me/configuring-solaris-link-aggregation-ethernet-bonding/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 09:55:48 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Network administration]]></category>
		<category><![CDATA[OpenSolaris]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[Ethernet bonding]]></category>
		<category><![CDATA[Link Aggregation]]></category>
		<category><![CDATA[network]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=868</guid>
		<description><![CDATA[This article shows detailed steps to Configure Solaris Link Aggregation (Ethernet bonding).]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: 13.3333px;">Link aggregation or commonly known Ethernet bonding allows us to enhance the network availability and performance by combining multiple network interfaces together and form an aggregation of those interfaces which act as a single network interface with greatly enhanced availability and performance.</span></p>
<div id="_mcePaste">When we aggregate two or more network interfaces, we are forming a new network interface on top of those physical interfaces combined in the link layer.</div>
<div id="_mcePaste">We need to have at least two network interfaces in our machine to create a link aggregation. The interfaces must be unplumb-ed in order for us to use them in a link aggregation. Following command shows how to unplumb a network interface.</div>
<pre># ifconfig e1000g1 down unplumb</pre>
<div id="_mcePaste">We should disable the NWAM because link aggregation and NWAM cannot co-exist.</div>
<pre># svcadm disable network/physical:nwam</pre>
<div id="_mcePaste">The interfaces we want to use in a link aggregation must not be part of virtual interface; otherwise it will not be possible to create the aggregation. To ensure that an interface is not part of a virtual interface checks the output for the following command.</div>
<pre># dladm show-link</pre>
<div id="_mcePaste">Following figure shows that my e1000g0 has a virtual interface on top of it so it cannot be used in an aggregation.</div>
<div><a href="http://kalali.me/wp-content/uploads/2010/11/3180_04_141.png" class="fancyboxgroup" rel="gallery-868" title="3180_04_14"><img class="aligncenter size-full wp-image-871" title="3180_04_14" src="http://kalali.me/wp-content/uploads/2010/11/3180_04_141.png" alt="" width="408" height="137" /></a></div>
<div id="_mcePaste">To delete the virtual interface we can use the dladm command as follow</div>
<pre># dladm delete-vlan vlan0</pre>
<div id="_mcePaste">The link aggregation as the name suggests works in the link layer and therefore we will use dladm command to make the necessary configurations.  We use create-aggr subcommand of dladm command with the following syntax to create aggregation links.</div>
<pre>dladm  create-aggr [-l interface_name]*  aggregation_name</pre>
<div id="_mcePaste">In this syntax we should have at least two occurrence of -l interface_name option followed by the aggregation name.</div>
<div id="_mcePaste">Assuming that we have e1000g0 and e1000g1 in our disposal following commands configure an aggregation link on top of them.</div>
<pre># dladm create-aggr -l e1000g0 -l e1000g1 aggr0</pre>
<div id="_mcePaste">Now that the aggregation is created we can configure its IP allocation in the same way that we configure a physical or virtual network interface. Following command plumb the aggr0 interface, assign a static IP address to it and bring the interface up.</div>
<pre># ifconfig aggr0 plumb 10.0.2.25/24 up</pre>
<div id="_mcePaste">Now we can use ifconfig command to see status of our new aggregated interface.</div>
<pre># ifconfig aggr0</pre>
<div id="_mcePaste">The result of the above command should be similar to the following figure.</div>
<div id="_mcePaste"><a href="http://kalali.me/wp-content/uploads/2010/11/3180_04_151.png" class="fancyboxgroup" rel="gallery-868" title="3180_04_15"><img class="size-full wp-image-870 aligncenter" title="3180_04_15" src="http://kalali.me/wp-content/uploads/2010/11/3180_04_151.png" alt="" width="610" height="103" /></a></div>
<div id="_mcePaste">To get a list of all available network interfaces either virtual or physical we can use the dladm command as follow</div>
<pre># dladm show-link</pre>
<div id="_mcePaste">And to get a list of aggregated interfaces we can use another subcommand of dladm as follow.</div>
<pre># dladm show-aggr</pre>
<div id="_mcePaste">The output for previous dladm commands is shown in the following figure.</div>
<div><a href="http://kalali.me/wp-content/uploads/2010/11/3180_04_161.png" class="fancyboxgroup" rel="gallery-868" title="3180_04_16"><img class="size-full wp-image-869 aligncenter" title="3180_04_16" src="http://kalali.me/wp-content/uploads/2010/11/3180_04_161.png" alt="" width="639" height="189" /></a></div>
<div id="_mcePaste">We can change an aggregation link underlying interfaces by adding an interface to the aggregation or removing one from the aggregation using add-aggr and remove-aggr subcommands of dladm command.  For example:</div>
<pre># dladm add-aggr -l e1000g2 aggr0
<span style="font-size: 11.6667px;"># dladm remove-aggr -l e1000g1 aggr0</span></pre>
<div id="_mcePaste">The aggregation we created will survive the reboot but our ifconfig configuration will not survive a reboot unless we persist it using the interface configuration files.</div>
<div id="_mcePaste">To make the aggregation IP configuration persistent we just need to add create /etc/hostname.aggr0 file with the following content:</div>
<pre>10.0.2.25/24</pre>
<div id="_mcePaste">The interface configuration files are discussed in recipe 2 and 3 of this chapter in great details. Reviewing them is recommended.</div>
<div id="_mcePaste">To delete an aggregation we can use delete-aggr subcommand of dladm command. For example to delete aggr0 we can use the following commands.</div>
<pre># ifconfig aggr0 down unplumb
<span style="font-size: 11.6667px;"># dladm delete-aggr aggr0</span></pre>
<div id="_mcePaste">As you can see before we could delete the aggregation we should bring down its interface and unplumb it.</div>
<div id="_mcePaste">In recipe 11 we discussed IPMP which allows us to have high availability by grouping network interfaces and when required automatically failing over the IP address of any failed interface to a healthy one. In this recipe we saw how we can join a group of interfaces together to have a better performance. By grouping a set of aggregations we can have the high availability that IPMP offers along with the performance boost that link aggregation offers.</div>
<div id="_mcePaste">The link aggregation works in layer 2 meaning that the aggregation groups the interfaces in layer 2 of network where network packets are dealt with. In this layer the network layer’s packets are extracted or created with the designated IP address of the aggregation and then are delivered to the lower, higher layer.</div>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/configuring-solaris-link-aggregation-ethernet-bonding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring DHCP server in Solaris</title>
		<link>http://kalali.me/configuring-dhcp-server-in-solaris/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=configuring-dhcp-server-in-solaris</link>
		<comments>http://kalali.me/configuring-dhcp-server-in-solaris/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 12:40:51 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network administration]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[DHCP server]]></category>
		<category><![CDATA[network]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=836</guid>
		<description><![CDATA[This article explains how to configure DHCP server in Solaris Operating System]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste">A Dynamic Host Configuration Protocol (DHCP) server leases IP address to clients connected to the network and has DHCP client enabled on their network interface.</div>
<div id="_mcePaste">Before we can setup a start the DHCP server we need to install DHCP configuration packages. Detail information about installing packages in provided in recipe of chapter 1. But to save the time we can use the following command to install the packages.</div>
<pre># pkg install SUNWdhcs</pre>
<div id="_mcePaste">After installing these packages we can continue with the next step.</div>
<div id="_mcePaste">How to do it&#8230;</div>
<div id="_mcePaste">First thing to setup the DHCP server is creating the storage and initial settings for the DHCP server. Following command does the trick for us.</div>
<pre># dhcpconfig -D -r SUNWfiles -p /fpool/dhcp_fs -a 10.0.2.254 -d domain.nme -h files -l 86400</pre>
<div id="_mcePaste">In the above command we used several parameters and options, each one of these options are explained below.</div>
<div id="_mcePaste">
<ul>
<li><span style="font-size: 13.3333px;">The -D specifies that we are setting up a new instance of the DHCP service.</span></li>
<li><span style="font-size: 13.3333px;">The -r SUNWfiles specifies the storage type. Here we are using plain-text storage while SUNWbinfiles and SUNWnisplus are available as well.</span></li>
<li><span style="font-size: 13.3333px;">The -p /fpool/dhcp_fs specifies the absolute path to where the configuration files should be stored.</span></li>
<li><span style="font-size: 13.3333px;">The -a 10.0.2.15 specifies the DNS server to use on the LAN. We can multiple comma separated addresses for DNS servers.</span></li>
<li><span style="font-size: 13.3333px;">The -d domain.nme specifies the network domain name.</span></li>
<li><span style="font-size: 13.3333px;">The -h files specifies where the host information should be stored. Other values are nisplus and dns.</span></li>
<li><span style="font-size: 13.3333px;">The -l 86400 specifies the lease time in seconds.</span></li>
</ul>
</div>
<div id="_mcePaste">Now that the initial configuration is created we should proceed to the next step and create a network.</div>
<pre># dhcpconfig -N 10.0.2.0 -m 255.255.255.0  -t 10.0.2.1</pre>
<div id="_mcePaste">Parameters we used in the above command are explained below.</div>
<div id="_mcePaste">
<ul>
<li><span style="font-size: 13.3333px;">The -N 10.0.2.0 specifies the network address.</span></li>
<li><span style="font-size: 13.3333px;">The -m 255.255.255.0 specifies the network mask to use for the network</span></li>
<li><span style="font-size: 13.3333px;">The -t 10.0.2.1 specifies the default gateway</span></li>
</ul>
</div>
<div id="_mcePaste">All configurations that we created are stored in DHCP server configuration files. We can manage the configurations using the dhtadm command. For example to view all of the current DHCP server configuration assemblies we can use the following command.</div>
<pre># dhtadm -P</pre>
<div id="_mcePaste">This command’s output is similar to the following figure.</div>
<div id="_mcePaste"><a href="http://kalali.me/wp-content/uploads/2010/11/3180_04_071.png" class="fancyboxgroup" rel="gallery-881" title="DHCP Configuration - Solaris"><img class="size-full wp-image-837 aligncenter" title="DHCP Configuration - Solaris" src="http://kalali.me/wp-content/uploads/2010/11/3180_04_071.png" alt="" width="792" height="150" /></a></div>
<div id="_mcePaste">Each command we invoked previously is stored as a macro with a unique name in the DHCP configuration storage. Later on we will use these macros in subsequent commands.</div>
<div id="_mcePaste">Now we need to create a network of addresses to lease. Following command adds the addresses we want to lease.</div>
<pre># pntadm -C 10.0.2.0</pre>
<div id="_mcePaste">If we need to reserve an address for a specific host or a specific interface in a host we should add the required configuration to the system to ensure that our host or interface receives the designated IP address. For example:</div>
<pre># pntadm -A 10.0.2.22 -f MANUAL -i 01001BFC92BC10 -m 10.0.2.0 -y 10.0.2.0</pre>
<div id="_mcePaste">In the above command we have:</div>
<div id="_mcePaste">
<ul>
<li><span style="font-size: 13.3333px;">The -A 10.0.2.22 adds the IP address 10.0.2.22.</span></li>
<li><span style="font-size: 13.3333px;">The -f MANUAL sets the flag MANUAL in order to only assign this IP address to the MAC address specified.</span></li>
<li><span style="font-size: 13.3333px;">The -i 01001BFC92BC10 sets the MAC address for the host this entry assigned  to it.</span></li>
<li><span style="font-size: 13.3333px;">The -m 10.0.2.0 specifies that this host is going to use the 192.168.0.0 macro.</span></li>
<li><span style="font-size: 13.3333px;">The –y asks the command to verify that the macro entered actually exists.</span></li>
<li><span style="font-size: 13.3333px;">The 10.0.2.0 Specifies the network the address is assigned to.</span></li>
</ul>
</div>
<div id="_mcePaste">Finally we should restart the DHCP server in order for all the changes to take effect. Following command restarts the corresponding service.</div>
<pre>#  svcadm restart dhcp-server</pre>
<div id="_mcePaste">When we setup the DHCP service, we store the related configuration in the storage of our choice. When we start the service, it reads the configuration from the storage and wait dormant until it receives a request for leasing an IP address. The service checks the configuration and if an IP was available for lease, it leases the IP to the client.</div>
<div id="_mcePaste">Prior to leasing the IP, DHCP service checks all leasing conditions like leasing a specific IP address to a client to ensure that it leases the right address to a client, etc.</div>
<div id="_mcePaste">We can use the DHCP Manager GUI application to configure a DHCP server. The DHCP manager can migrate the DHCP storage from one format to another. To install the DHCP manager package we can use the following command.</div>
<pre># pkg install SUNWdhcm</pre>
<div id="_mcePaste">Now we can invoke the DHCP manager using the following command which opens the DHCP Manager welcome page shown in the following figure.</div>
<pre><span style="font-size: 13.3333px;"># dhcpmgr</span></pre>
<div><a href="http://kalali.me/wp-content/uploads/2010/11/3180_04_081.png" class="fancyboxgroup" rel="gallery-881" title="DHCP Manager GUI - Solaris"><img class="size-full wp-image-838 alignnone" title="DHCP Manager GUI - Solaris" src="http://kalali.me/wp-content/uploads/2010/11/3180_04_081.png" alt="" width="386" height="214" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/configuring-dhcp-server-in-solaris/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GlassFish security book contest: Here are the lucky winners</title>
		<link>http://kalali.me/gsbclw/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gsbclw</link>
		<comments>http://kalali.me/gsbclw/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 14:18:09 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[GlassFish Security]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[book security]]></category>
		<category><![CDATA[contest]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=801</guid>
		<description><![CDATA[Here you will find the winners of GlassFish security book contest I posted two weeks ago in my weblog.]]></description>
			<content:encoded><![CDATA[<p>Thank you all who accepted the challenge and took the <strong><a href="http://kalali.me/win-your-copy-of-glassfish-security-book-by-taking-a-simple-5-questions-quiz/">quiz</a>. </strong> Now it is time to see who are the luckier ones winning the prizes which are copies of <a href="https://www.packtpub.com/glassfish-security-with-java-ee/book">GlassFish Security book</a>. To give you an statistic about the quiz participants,</p>
<div id="attachment_415" class="wp-caption alignright" style="width: 135px"><a href="https://www.packtpub.com/glassfish-security-with-java-ee/book?mid=180510gq2lyz&amp;utm_source=java.net&amp;utm_medium=affiliate&amp;utm_content=blog&amp;utm_campaign=mdb_003525"><img class="size-full wp-image-415" title="GlassFish Security Book" src="http://kalali.me/wp-content/uploads/2010/07/9386_MockupCover.png" alt="" width="125" height="152" /></a><p class="wp-caption-text">GlassFish Security Book</p></div>
<p>I had 156 participants. though some of them, maybe 20 &#8211; 30 are quiz result submitted more than once by some of the participants.</p>
<p>Before we jump to the list of winners, I should explain the questions which I posted in the quiz.  The questions I selected for the quiz are mostly based on <a href="https://www.packtpub.com/sites/default/files/9386-chapter-3-dsigning-and-developing%20%20.pdf">chapter 3</a> of the book which is available for free in packt website.</p>
<p>So the questions, the answers and the explanation about each question are as follow.</p>
<hr /><strong>1. Which one of the following statements is correct?</strong></p>
<address>A. We can specify which security realm we want our web module to use in the sun-web.xml.</address>
<address>B. We can specify which security realm we want our web module to use in the web.xml.</address>
<address>C. We can use sun-application.xml to specify which security realm we want our enterprise application to use</address>
<address><strong><span style="color: #993300;">D. B and C are correct.</span></strong></address>
<p>We can use both the web.xml and sun-application.xml to specify the security realm. In the web.xml we use the login-conf element as shown below:</p>
<p><span style="font-family: Arial, Helvetica, sans-serif; line-height: normal; font-size: 10px; color: #111111;"> </span></p>
<pre>&lt;login-config&gt;
  &lt;auth-method&gt;BASIC&lt;/auth-method&gt;
  &lt;realm-name&gt;LDAP_Realm&lt;/realm-name&gt;
&lt;/login-config&gt;</pre>
<p>And in the sun-application.xml we can specify the application wide security realm as shown in the following snippet.</p>
<p><span style="font-family: Arial, Helvetica, FreeSans, Luxi-sans, 'Nimbus Sans L', sans-serif; line-height: normal; font-size: 10px; color: #333333; -webkit-border-horizontal-spacing: 10px; -webkit-border-vertical-spacing: 10px;"> </span></p>
<pre>&lt;sun-application&gt;
    &lt;realm&gt;<span style="color: #000000; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; font-size: 11.6667px;">LDAP_Realm</span><span style="font-size: 11.6667px;">&lt;/realm&gt;</span>
&lt;/sun-application&gt;</pre>
<p><span style="color: #000000; font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; font-size: 13.3333px; line-height: 22px;">The realm is an immediate child of the sun-application element.</span></p>
<hr /><strong>2. Which one of the following statements shows new security features included in Java EE 6?</strong></p>
<p><span style="color: #000000; font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; font-size: 13.3333px; line-height: 22px;"><em>A. The programmatic login and logout methods in logout in HttpServletRequest interface.<br />
</em><em>B. Inclusion of @ServletSecurity Annotation to annotate a Servlet and enforce security.<br />
</em><em>C. Inclusion of the authenticate method in the HttpServletRequest interface.<br />
</em><em><strong><span style="color: #993300;">D. All of the above.</span></strong></em></span></p>
<p><strong><span style="font-weight: normal;">Yes, all of this new features are included in Java EE 6 to enhance the security APIs and ease their use.</span></strong></p>
<hr /><strong>3. Where we should place the login-config element?</strong></p>
<address><strong><span style="color: #993300;">A. In web.xml</span></strong><br />
<span style="font-size: 13.3333px;">B. In sun-web.xml<br />
</span><span style="font-size: 13.3333px;">C. In sun-application.xml<br />
</span><span style="font-size: 13.3333px;"><span style="color: #000000;">D. In A and C</span></span></address>
<address><span style="font-size: 13.3333px;"><span style="color: #000000;"><br />
</span></span></address>
<div><span style="font-weight: normal;">The login-conf element goes to web.xml to specify the security realm and the authentication method. To see an snippet about this look at the explanation of the first question</span></div>
<div><span style="font-weight: normal;"><br />
</span></div>
<address>
<hr />
<address></address>
<address><em><strong>4. What are j_username and j_password when it come to Java EE security?</strong></em></address>
<address><em><strong><br />
</strong></em></address>
<div><span style="color: #ff0000;"><strong><span style="color: #993300;">A. These are two per-defined filed names which we must use in FORM authentication to pass the username and the password to the container.</span></strong></span></div>
<div><span style="font-weight: normal;">B. These are two per-defined filed names which we must use in BASIC authentication type to pass the username and the password to the container.</span></div>
<div><span style="font-weight: normal;">C. Both of A and B are correct.</span></div>
<div><span style="font-weight: normal;">D. None of the above items.</span></div>
<p><span style="font-style: normal;"><span style="font-weight: normal;">To see some snippet about how we can have FORM authentication, you can take a look at the GlassFish security book </span></span><span style="font-style: normal; font-size: 13.3333px;"><span style="font-weight: normal;"> </span><a href="https://www.packtpub.com/sites/default/files/9386-chapter-3-dsigning-and-developing%20%20.pdf"><span style="font-weight: normal;">chapter 3</span></a><span style="font-weight: normal;"> which is freely available.</span></span></p>
<hr />
<address></address>
<address><strong>5. When we talk about security, which of the following sequences is more accurate?</strong></address>
<address><strong><br />
</strong></address>
<address><span style="color: #ff0000;"><strong><span style="color: #993300;">A. Identification, Authentication, Authorization </span></strong></span><br />
<span style="font-size: 13.3333px;"><span style="font-weight: normal;">B. Authentication, Authorization, Identification<br />
</span> </span><span style="font-size: 13.3333px;"><span style="font-weight: normal;">C. Authentication, Identification, Authorization<br />
</span> </span><span style="font-size: 13.3333px;"><span style="font-weight: normal;">D. Authorization, Authentication, Identification</span></span></address>
<address><span style="font-size: 13.3333px;"><span style="font-weight: normal;"><br />
</span></span></address>
<address></address>
<address><span style="font-size: 13.3333px;"><span style="font-style: normal;"><span style="font-weight: normal;">‌Before we try to authenticate a credential we should receive a credential showing who the requester is claiming to be. After we received the credentials, we should check the credentials validity and finally after we find that the credentials are valid we can check the access level of the provided credentials.</span></span></span></address>
<hr />
<address style="text-align: center;"><span style="font-size: 13.3333px;"><span style="font-style: normal;"><strong><span style="color: #993300;"><br />
And now the winners</span></strong></span></span></address>
<address style="text-align: center;"><span style="font-size: 13.3333px;"><span style="font-style: normal;">The paper copy goes to: <strong><a href="http://twitter.com/brunofsantunes">Bruno Antunes</a></strong></span></span></address>
<address style="text-align: center;"><span style="font-style: normal;">First ebook copy goes to: <strong><a href="http://myopendraft.blogspot.com/">Alireza Haghighatkhah</a></strong></span></address>
<address style="text-align: center;"><span style="font-style: normal;">Second ebook copy goes to: <strong><a href="http://twitter.com/dwuysan">Deny Wuysan</a></strong></span></address>
<address style="text-align: center;"><span style="font-style: normal;"><br />
</span></address>
<address style="text-align: center;"></address>
<address style="text-align: left;"><span style="font-style: normal;">I have not received replys from some of the participants about their country of residence so I put them into the second list. I will contact the winners to coordinate the distribution of the copies with them.</span></address>
<address style="text-align: left;"><span style="font-style: normal;"><br />
</span></address>
<address style="text-align: left;"><span style="font-style: normal;">I am looking for a way to have more contest about GlassFish security book in the coming month. Specially small 2 question quiz which the winner will receive a e-book copy of the title.</span></address>
<address style="text-align: left;"><span style="font-style: normal;"><br />
</span></address>
</p></address>
<p><strong> </strong></p>
<p style="font-weight: bold;"><span style="font-family: Arial, Helvetica, FreeSans, Luxi-sans, 'Nimbus Sans L', sans-serif; line-height: normal; font-size: 10px; color: #333333; -webkit-border-horizontal-spacing: 10px; -webkit-border-vertical-spacing: 10px;"> </span></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/gsbclw/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Try your chance for winning a copy of GlassFish Security book by taking a 5 questions quiz.</title>
		<link>http://kalali.me/win-your-copy-of-glassfish-security-book-by-taking-a-simple-5-questions-quiz/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=win-your-copy-of-glassfish-security-book-by-taking-a-simple-5-questions-quiz</link>
		<comments>http://kalali.me/win-your-copy-of-glassfish-security-book-by-taking-a-simple-5-questions-quiz/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 11:49:32 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Book Review]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Book]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[GlassFish v3]]></category>
		<category><![CDATA[quiz]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=760</guid>
		<description><![CDATA[Win your copy of GlassFish Security book by taking a simple 5 questions quiz. You simply answer 5 questions and then you will be included in the draw for 2 e-book copy and one paper copy of GlassFish security book.]]></description>
			<content:encoded><![CDATA[<p>It is something like 5 months since Packt has published my book, <a title="GlassFish Security" href="https://www.packtpub.com/glassfish-security-with-java-ee/book">GlassFish Security</a>, which covers Java EE security and GlassFish application server security in great details by including OpenSSO and OpenDS into the mix.</p>
<div id="attachment_415" class="wp-caption alignleft" style="width: 135px"><a href="https://www.packtpub.com/glassfish-security-with-java-ee/book"><img class="size-full wp-image-415 " title="GlassFish Security Book" src="http://kalali.me/wp-content/uploads/2010/07/9386_MockupCover.png" alt="" width="125" height="152" /></a><p class="wp-caption-text">Buy GlassFish Security Book</p></div>
<p>The book received around <a href="http://kalali.me/glassfish-security-book/"><strong>10 reviews</strong></a> and all of these reviews unanimously agree that the book content is very useful and the book is something that every Java EE developer or GlassFish administrator may like to have in the shelve.</p>
<p>Now that a chapter of the book, <strong><a href="https://www.packtpub.com/sites/default/files/9386-chapter-3-dsigning-and-developing%20%20.pdf">chapter 3</a></strong>, is available for free in the Packt website, I thought I can form a simple contest in my weblog by including some questions from that chapter and give away some copies of the book to <strong>3</strong> lucky winners who answered all 5 questions correctly.</p>
<p>We will give away 1 paper copy to someone in USA or Europe and two e-books to any lucky winner either in those two continent or not.</p>
<p>It wont take more than 2-3 minutes to answer the questions and you will get the chance to receive a copy of the book when I draw the winners on October 10th.</p>
<p>And now the fun part, below you can find the 5 question quiz which can bring you a copy of GlassFish security book. <span style="color: #ff6600;">Just note that we will only use the first result for each email address and consequent entries will be ignored<strong>.</strong></span></p>
<h3><span style="color: #003366;"><strong><span style="color: #993366;"><span style="font-weight: normal;">&#8220;It seems that the quiz software I am using is not compatible with FireFox, please go with Google Chrome or Apple Safari</span>&#8220;</span></strong></span></h3>
<p><span style="color: #ff6600;"><strong><br />
</strong></span></p>
<p><strong>[wp-simple-survey]</strong></p>
<p><span style="color: #ff6600;"><span style="color: #000000;">Make sure that you press the calculate result button when you are entering your name and email address so your information get stored into the database for the draw.</span></span></p>
<p><span style="color: #ff6600;"><strong><span style="color: #000000;"><span style="color: #ff0000;">The contest is over and winners along with answers to these questions are announce at: </span><a href="http://kalali.me/gsbclw/"><span style="color: #000080;">http://kalali.me/gsbclw/</span></a></span></strong></span></p>
<p><strong><br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/win-your-copy-of-glassfish-security-book-by-taking-a-simple-5-questions-quiz/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>JavaZone 2010, a very brief report.</title>
		<link>http://kalali.me/javazone-2010-a-very-brief-report/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=javazone-2010-a-very-brief-report</link>
		<comments>http://kalali.me/javazone-2010-a-very-brief-report/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 07:05:25 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[JavaZone]]></category>
		<category><![CDATA[JavaZone 2010]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[NIO.2]]></category>
		<category><![CDATA[slides]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=747</guid>
		<description><![CDATA[A brief review and report about JavaZone 2010 and copy of my JavaZone presentation.]]></description>
			<content:encoded><![CDATA[<p>Yesterday the two days <a href="http://jz10.java.no/">JavaZone 2010</a> conference finished, the conference was as good as I expected it to be. The sessions were selected very carefully to cover all sort of interest from architecture and NoSQL to security and core java APIs.</p>
<p>A fair portion of the participants, both in speakers group and in the audiences group were loyal participants which at least attended one of the previous conferences in past 10 years. I was one of those who participated for the first time, so I can not compare this year&#8217;s event with the previous one but those who have seen the previous events agreed that the quality of each year&#8217;s conference is better than previous year, and for this year the quality increases is way more than previous ones.</p>
<p>For few instances I heard people complaining about why more speakers are using English or small number of elementary level sessions (tutorials perhaps) but I believe no one found another reason  for a complain.</p>
<p>The <a href="http://jz10.java.no/journey.html">JourneyZone</a> is what I am looking forward to experience in the next two days. It is the first time in the 10 years history of JavaZone that the program committee is organizing this event for the JZ participants. I am going to check out of the hotel and go for the JourneyZone.</p>
<p>Following album includes few photos from my session, thanks to <a href="http://blogs.sun.com/alexismp/">Alexis</a> for taking the photos.  The slides is available <a href="http://kalali.me/downloads/NIO.2_final.pdf"><strong>here</strong></a><strong> </strong>I know that all videos for the sessions will be available at some point in time, but I do not know when it will become available, maybe in few days maybe in few months.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="267" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="flashvars" value="host=picasaweb.google.com&amp;hl=en_GB&amp;feat=flashalbum&amp;RGB=0x000000&amp;feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fkalali%2Falbumid%2F5514932374929781985%3Falt%3Drss%26kind%3Dphoto%26hl%3Den_GB" /><param name="src" value="http://picasaweb.google.com/s/c/bin/slideshow.swf" /><embed type="application/x-shockwave-flash" width="400" height="267" src="http://picasaweb.google.com/s/c/bin/slideshow.swf" flashvars="host=picasaweb.google.com&amp;hl=en_GB&amp;feat=flashalbum&amp;RGB=0x000000&amp;feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fkalali%2Falbumid%2F5514932374929781985%3Falt%3Drss%26kind%3Dphoto%26hl%3Den_GB"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/javazone-2010-a-very-brief-report/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introducing NIO.2 (JSR 203) Part 6: Filtering directory content and walking over a file tree</title>
		<link>http://kalali.me/introducing-nio-2-jsr-203-part-6-filtering-directory-content-and-walking-over-a-file-tree/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-nio-2-jsr-203-part-6-filtering-directory-content-and-walking-over-a-file-tree</link>
		<comments>http://kalali.me/introducing-nio-2-jsr-203-part-6-filtering-directory-content-and-walking-over-a-file-tree/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 08:54:47 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[File System Tree]]></category>
		<category><![CDATA[JSR-203]]></category>
		<category><![CDATA[NIO.2]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=734</guid>
		<description><![CDATA[In this article we discuss how to walk over a directory tree and visit all of its content down to a specific level. We also discuss how to filter content of a directory based on the file attributes to find the files we need in a directory.]]></description>
			<content:encoded><![CDATA[<p>In this part we will look at how the directory tree walker and the directory stream reader works. These two features are another couple of long requested features which was not included in the core java before Java 7.</p>
<p><span>First, lets see what directory stream reader is, this API allows us to filter content of a directory on the file system and extract the file names that matches our filter criteria. The feature works for very large folders with thousands of files.</span></p>
<p><span>For filtration we can use </span><a href="http://download.java.net/jdk7/docs/api/java/nio/file/PathMatcher.html"><span><span>PathMatcher</span></span></a><span> expression matching the file name or we can filter the directory content based on the different file attributes. for example based on the file permissions or the file size.</span></p>
<p><span>Following sample code shows how to use the <span>DirectoryStream</span> along with filtering. For using the <span>PathMatcher</span> expression we can just use another overload of the <span>newDirectoryStream</span> method which accepts the <span>PathMatcher</span> expression instead of the filter. </span></p>
<pre><span>public class DirectoryStream2 {

    public static void main(String <span>args</span>[]) throws <span>IOException</span> {
	//Getting default file system and getting a path
        <span>FileSystem</span> <span>fs</span> = <span>FileSystems</span>.<span>getDefault</span>();
        Path p = <span>fs</span>.<span>getPath</span>("/<span>usr</span>/bin");

	//creating a directory streamer filter
        <span>DirectoryStream</span>.Filter
 filter = new <span>DirectoryStream</span>.Filter
() {

            public <span>boolean</span> accept(Path file) throws <span>IOException</span> {
                long size = Attributes.<span>readBasicFileAttributes</span>(file).size();
                String perm = <span>PosixFilePermissions</span>.toString(Attributes.<span>readPosixFileAttributes</span>(file).permissions());
                if (size &gt; 8192L &amp;&amp; perm.<span>equalsIgnoreCase</span>("<span>rwxr</span>-<span>xr</span>-x")) {
                    return true;
                }
                return false;
            }
        };
	// creating a directory streamer with the newly developed filter
        <span>DirectoryStream</span>
 <span>ds</span> = p.<span>newDirectoryStream</span>(filter);
        Iterator
 it = <span>ds</span>.iterator();
        while (it.<span>hasNext</span>()) {

            Path pp = it.next();

            System.out.<span>println</span>(pp.<span>getName</span>());
        }
    }
}
</span></pre>
<p><span>The above code is self explaining and I will not explain it any further than the in-line comments.</span></p>
<p>Next subject of this entry is directory tree walking or basically file visitor API. This API allows us to walk over a file system tree and execute any operation we need over the files we found. The good news is that we can scan down to any depth we require using the provided API.</p>
<p><span>With the directory tree walking API, the Java core allows us to register a vaster class with the directory tree walking API and then for each entry the API come across, either a file or a folder, it calls our visitor metho<span>ds</span>. So the first thing we need is a visitor to register it with the tree walker. Following snippet shows a simple visitor which only prints the file type using the Files.<span>probeContentType</span>() method.</span></p>
<pre><span>class visit exten<span>ds</span> <span>SimpleFileVisitor</span>
 {

    @Override
    public <span>FileVisitResult</span> <span>visitFile</span>(Path file, <span>BasicFileAttributes</span> <span>attrs</span>) {
        try {
            System.out.<span>println</span>(Files.<span>probeContentType</span>(file));

        } catch (<span>IOException</span> ex) {
            Logger.<span>getLogger</span>(visit.class.<span>getName</span>()).log(Level.SEVERE, null, ex);
        }
        return super.<span>visitFile</span>(file, <span>attrs</span>);
    }

    @Override
    public <span>FileVisitResult</span> <span>postVisitDirectory</span>(Path <span>dir</span>, <span>IOException</span> <span>exc</span>) {
        return super.<span>postVisitDirectory</span>(<span>dir</span>, <span>exc</span>);
    }

    @Override
    public <span>FileVisitResult</span> <span>preVisitDirectory</span>(Path <span>dir</span>) {
        return super.<span>preVisitDirectory</span>(<span>dir</span>);
    }

    @Override
    public <span>FileVisitResult</span> <span>preVisitDirectoryFailed</span>(Path <span>dir</span>, <span>IOException</span> <span>exc</span>) {
        return super.<span>preVisitDirectoryFailed</span>(<span>dir</span>, <span>exc</span>);
    }

    @Override
    public <span>FileVisitResult</span> <span>visitFileFailed</span>(Path file, <span>IOException</span> <span>exc</span>) {
        return super.<span>visitFileFailed</span>(file, <span>exc</span>);
    }
}
</span></pre>
<p><span>As you can see we extended the <span>SimpleFileVisitor</span> and we have visitor metho<span>ds</span> for all possible cases.</span></p>
<p><span>Now that we have the visitor class, the rest of the code is straight forward. following sample shows how to walk over<em> /home/</em><span><em>masoud</em></span><em> </em>directory down to two levels.</span></p>
<pre><span>public class <span>FileVisitor</span> {

    public static void main(String <span>args</span>[]) {

        <span>FileSystem</span> <span>fs</span> = <span>FileSystems</span>.<span>getDefault</span>();
        Path p = <span>fs</span>.<span>getPath</span>("/home/<span>masoud</span>");
        visit v = new visit();
        Files.<span>walkFileTree</span>(p, <span>EnumSet</span>.<span>allOf</span>(<span>FileVisitOption</span>.class), 2, v);

    }
}
</span></pre>
<p>You can grab the latest version of Java 7 aka Dolphin from <a title="Here" href="http://dlc.sun.com.edgesuite.net/jdk7/binaries/index.html">here</a> and from the same page you can grab the latest JavaDoc which is generated from the same source code that is used to generate the binary bits. Other entries of this series are under the <a href="http://kalali.me/tag/nio-2/">NIO.2</a> tag of my weblog.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/introducing-nio-2-jsr-203-part-6-filtering-directory-content-and-walking-over-a-file-tree/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaZone 2010 sessions I am going to attend</title>
		<link>http://kalali.me/javazone-2010-sessions-i-will-attend/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=javazone-2010-sessions-i-will-attend</link>
		<comments>http://kalali.me/javazone-2010-sessions-i-will-attend/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 10:45:42 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Enterprise Architecture]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[JavaZone]]></category>
		<category><![CDATA[JavaZone 2010]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Modularity]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[Good Sessions]]></category>
		<category><![CDATA[presentations]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=491</guid>
		<description><![CDATA[This is a list of JavaZone 2010 sessions I am planning to attend. Selecting this list was really hard as all of the presentations are exceptionally good.]]></description>
			<content:encoded><![CDATA[<p>I will be attending JavaZone 2010 both as an speaker presenting NIO.2 and as an atendee sitting and learning new technologies other speakers kindly share. After looking at the <a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions">list of sessions</a>, here is the sessions I decided to attend. It is really hard to decided on which speaker and subject to choose. All speakers are known engineers and developers and selected subjects are exceptionally good.</p>
<p>I may change few of this items as JZ2010 staff updates the agenda but majority of the sessions will be what I have already selected. See you at JZ2010 and the JourneyZone afterward the conference itself.</p>
<h2>8th of September:</h2>
<ol>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/Emergent%20Design" target="_blank">Emergent Design</a> — Neal Ford</li>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/JRuby:%20Now%20With%20More%20J!" target="_blank">JRuby: Now With More J!</a> — Nick Sieger</li>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/Howto:%20Implement%20Collaborative%20Filtering%20with%20Map%2FReduce">Howto: Implement Collaborative Filtering with Map/Reduce &#8211; Ole-Martin Mørk </a></li>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/Building%20a%20scalable%20search%20engine%20with%20Apache%20Solr,%20Hibernate%20Shards%20and%20MySQL">Building a scalable search engine with Apache Solr, Hibernate Shards and MySQL &#8211; Aleksander Stensby, Jaran Nilsen</a></li>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/The%20not%20so%20dark%20art%20of%20Performance%20Tuning" target="_blank">The not so dark art of Performance Tuning</a> — Dan Hardiker, Kirk Pepperdine</li>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/Creating%20modular%20applications%20with%20Apache%20Aries%20and%20OSGi" target="_blank">Creating modular applications with Apache Aries and OSGi</a> — Alasdair Nottingham</li>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/Java%207%20NIO.2:%20The%20I%2FO%20API%20for%20Future" target="_blank">Java 7 NIO.2: The I/O API for Future</a> — Masoud Kalali -&gt; <span style="color: #ff0000;"><strong>I am Speaking here</strong></span></li>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/The%20evolution%20of%20data%20grids,%20from%20local%20caching%20to%20distributed%20computing">The evolution of data grids, from local caching to distributed computing &#8211; Bjørn Vidar Bøe</a></li>
</ol>
<h2>9th of September:</h2>
<ol>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/NOSQL%20with%20Java">NOSQL with Java — Aslak Hellesøy</a></li>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/CouchDB%20and%20the%20web">CouchDB and the web — Knut O. Hellan</a></li>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/Decision%20Making%20in%20Software%20Teams" target="_blank">Decision Making in Software Teams</a> — Tim Berglund</li>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/A%20Practical%20Introduction%20to%20Apache%20Buildr" target="_blank">A Practical Introduction to Apache Buildr</a> — Alex Boisvert</li>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/Architecture%20Determines%20Performance">Architecture Determines Performance — Randy Stafford</a></li>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/Surviving%20Java%20Maintenance%20-%20A%20mini%20field%20manual">Surviving Java Maintenance &#8211; A mini field manual — Mårten Haglind</a></li>
<li><a href="http://javazone.no/incogito10/events/JavaZone%202010/sessions/Using%20the%20latest%20Java%20Persistence%20API%202.0%20features" target="_blank">Using the latest Java Persistence API 2.0 features</a> — Arun Gupta</li>
</ol>
<p><a href="          &gt;&lt;/a&gt;&lt;br /&gt;  &lt;a href="></a></p>
<div class="wp-caption alignnone" style="width: 236px"><a title="JavaZone website" href="http://jz10.java.no/"><img title="JavaZone 2010, Oslo" src="http://jz10.java.no/style/gfx/logo.png" alt="JavaZone 2010, Oslo" width="226" height="46" /></a><p class="wp-caption-text">JavaZone 2010, JavaZone logo</p></div>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/javazone-2010-sessions-i-will-attend/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introducing NIO.2 (JSR 203) Part 5: Watch Service and Change Notification</title>
		<link>http://kalali.me/introducing-nio-2-jsr-203-part-5-watch-service-and-change-notification/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-nio-2-jsr-203-part-5-watch-service-and-change-notification</link>
		<comments>http://kalali.me/introducing-nio-2-jsr-203-part-5-watch-service-and-change-notification/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 20:40:12 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Change Notification]]></category>
		<category><![CDATA[dolphin]]></category>
		<category><![CDATA[Java 7]]></category>
		<category><![CDATA[NIO.2]]></category>
		<category><![CDATA[Watch Service]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=698</guid>
		<description><![CDATA[In this entry we will look at one of the most waited functionalities of NIO.2. The watch and notification service which allows us to monitor changes in file system. We can monitor deletion, creation, modification and so on.]]></description>
			<content:encoded><![CDATA[<p>For long time Java developers used in-house developed solutions to monitor the file system for changes. Some developed general purpose libraries to ease the task of others who deal with the same requirement.  Commercial and  free/ open source libraries like <a href="http://jnotify.sourceforge.net/">http://jnotify.sourceforge.net/</a>, <a href="http://jpathwatch.wordpress.com/">http://jpathwatch.wordpress.com/</a> and  <a href="http://www.teamdev.com/jxfilewatcher">http://www.teamdev.com/jxfilewatcher</a> among others. Java 7 comes with NIO.2 or JSR 203 which provides native file system watch service.</p>
<p>The  watch service provided in Java 7  uses the underlying file system functionalities to watch the file system for changes, so if we are running on Windows, MacOS or Linux&#8230; we are sure that the watch service is not imposing polling overhead on our application because the underlying OS and file system provides the required functionalities to allow Java to register for receiving notification on file system changes. If the underlying file system does not provide the watch-ability, which I doubt it for any mainstream file system,  Java will fall back to some rudimentary polling mechanism to keep the code working but the performance will degrade.</p>
<p>From the mentioned libraries the <a href="http://jpathwatch.wordpress.com/">jpathwatch</a> API is the same as the Java 7 APIs to make it easier to migrate an IO based application from older version of Java to Java 7 when its time arrives.</p>
<div id="_mcePaste">The whole story starts with WatchService which we register our interest in watching a path using it. The WatchService itself is an interface with several implementatins for different file system and operating systems.</div>
<div id="_mcePaste">We have four class to work with when we are developing a system with file system watch capability.</div>
<div id="_mcePaste">
<ol>
<li>A <strong>Watchable</strong>: A watchable is an object of a class implementing the Watchable interface. In our case this is the Path class which is the one of the central classes in the NIO.2</li>
<li>A <strong>set of event types</strong>: We use it to specify which types of events we are interested in. For example whether we want to receive creation, deletion, &#8230; events. In our case we will use StandardWatchEventKind which implements the WatchEvent.Kind&lt;T&gt;.</li>
<li>An <strong>event modifier</strong>: An event modifier that qualifies how a Watchable is registered with a WatchService. In our case we will deal with nothing specific up to now as there is no implementation of this interface included in the JDK distribution.</li>
<li>The <strong>Wacher</strong>: This is the watcher who watch some watchable. In our case the watcher watches the File System for changes. The abstract class is java.nio.file.WatchService but we will be using the FileSystem object to create a watcher for the File System.</li>
</ol>
</div>
<p>Now that we know the basics, let&#8217;s see how a complete sample will look like and then we will break down the sample into different parts and discuss them one by one.</p>
<pre>import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.StandardWatchEventKind;
import java.nio.file.WatchEvent;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public class WatchSer {
    public static void main(String args[]) throws InterruptedException {
        try {
            FileSystem fs = FileSystems.getDefault();
            WatchService ws = null;
            try {
                ws = fs.newWatchService();
            } catch (IOException ex) {
                Logger.getLogger(WatchSer.class.getName()).log(Level.SEVERE, null, ex);
            }
            Path path = fs.getPath("/home/masoud/Pictures");
            path.register(ws, StandardWatchEventKind.ENTRY_CREATE, StandardWatchEventKind.ENTRY_MODIFY, StandardWatchEventKind.OVERFLOW, StandardWatchEventKind.ENTRY_DELETE);

            WatchKey k = ws.take();

            List&gt; events = k.pollEvents();
            for (WatchEvent object : events) {
                if (object.kind() == StandardWatchEventKind.ENTRY_MODIFY) {
                    System.out.println("Modify: " + object.context().toString());
                }
                if (object.kind() == StandardWatchEventKind.ENTRY_DELETE) {
                    System.out.println("Delete: " + object.context().toString());
                }
                if (object.kind() == StandardWatchEventKind.ENTRY_CREATE) {
                    System.out.println("Created: " + object.context().toString());
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(WatchSer.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}</pre>
<p>At the beginning of the code we create a FileSystem object and then create a WatchService for the file system underneath the FileSystem object we created previously.</p>
<pre>            FileSystem fs = FileSystems.getDefault();
            WatchService ws = null;
            try {
                ws = fs.newWatchService();
            } catch (IOException ex) {
                Logger.getLogger(WatchSer.class.getName()).log(Level.SEVERE, null, ex);
            }</pre>
<p>At the next step we create a Path object which basically is our watchable, what we want to watch, and then register it with the WatchService object we created in the previous step.</p>
<pre>  Path path = fs.getPath("/home/masoud/Pictures");
   path.register(ws, StandardWatchEventKind.ENTRY_CREATE, StandardWatchEventKind.ENTRY_MODIFY, StandardWatchEventKind.OVERFLOW, StandardWatchEventKind.ENTRY_DELETE);</pre>
<p>Next we get a key which represents the registration of a watchable with a watch service.<br />
This WatchKey object represents our access door to events propagated by the WatchService object.</p>
<p>After getting the key, we can poll for the events arrived at the key. An File system event may get represented by multiple WatchService events. For example a rename is represented by deletion and creation events.</p>
<pre> WatchKey key = ws.take();
 List&gt; events = key.pollEvents();</pre>
<p>Now that we have the list of events we can iterate over the events list and see whether we are intrested in the event or not.</p>
<pre>for (WatchEvent object : events) {
                if (object.kind() == StandardWatchEventKind.ENTRY_MODIFY) {
                    System.out.println("Modify: " + path.toRealPath(true)+"/"+ object.context().toString());

                }
                if (object.kind() == StandardWatchEventKind.ENTRY_DELETE) {
                    System.out.println("Delete: " +  path.toRealPath(true)+"/"+ object.context().toString());
                }
                if (object.kind() == StandardWatchEventKind.ENTRY_CREATE) {
                    System.out.println("Created: " +  path.toRealPath(true)+"/"+ object.context().toString());
                }
            }</pre>
<p>In our sample code we are running the watch service in the application thread while we can use multiple threads to handle the events. One reason that the WatchService is not implemented using the Listener is the urge for using multiple threads to deal with the events in cases where there are thousands of events or event processing take longer than application threshold.<br />
You can grab the latest version of Java 7 aka Dolphin from <a title="Here" href="http://dlc.sun.com.edgesuite.net/jdk7/binaries/index.html">here</a> and from the same page you can grab the latest JavaDoc which is generated from the same source code that is used to generate the binary bits. Other entries of this series are under the <a href="http://kalali.me/tag/nio-2/">NIO.2</a> tag of my weblog.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/introducing-nio-2-jsr-203-part-5-watch-service-and-change-notification/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>I will be speaking at JavaZone 2010 about NIO.2</title>
		<link>http://kalali.me/i-will-be-speaking-at-javazone-2010-about-nio-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=i-will-be-speaking-at-javazone-2010-about-nio-2</link>
		<comments>http://kalali.me/i-will-be-speaking-at-javazone-2010-about-nio-2/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 20:38:08 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[JavaZone]]></category>
		<category><![CDATA[JavaZone 2010]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[2010]]></category>
		<category><![CDATA[NIO.2]]></category>
		<category><![CDATA[Presentation]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=613</guid>
		<description><![CDATA[My abstract for presenting at JavaZone 2010 about NIO.2 has been accepted and I will be speaking on 8th of September in saloon 1 from 10:15 to 11:15]]></description>
			<content:encoded><![CDATA[<p>Well, my abstract for a session in <a title="JavaZone 2010 website" href="http://jz10.java.no/">JavaZone 2010</a> accepted and I will be <a title="NIO.2 session, by Masoud Kalali" href="http://javazone.no/incogito10/events/JavaZone%202010/sessions#0b0ef118-730e-4d81-9717-c7f16ad7025a">speaking about NIO.2</a>, you may call it new new IO, more new IO or technically <a title="JSR-203" href="http://jcp.org/en/jsr/detail?id=203">JSR-203</a>,on 8th of September in saloon 1. I will be the second speaker in the first day of the conference so the timing will be something like 10:15 to 11:15. The session will be in English and I will give the audience an overview of IO features in Java 7 and its differences improvements over old IO framework. I estimated that  I will be speaking for 55 minutes to present something around 35 slides which I have prepared their sketch.</p>
<div class="wp-caption alignnone" style="width: 236px"><a title="JavaZone website" href="http://jz10.java.no/"><img title="JavaZone 2010, Oslo" src="http://jz10.java.no/style/gfx/logo.png" alt="JavaZone 2010, Oslo" width="226" height="46" /></a><p class="wp-caption-text">JavaZone 2010, JavaZone logo</p></div>
<p>Majority of the slides will discuss the file system capabilities included in the NIO.2, some slides will cover the differences between I/O with Java 7 and I/O in older releases. Some slides will discuss Asynchronous I/O, and other cool features of NIO.2. Almost all slides come with a sample code showing the concept in action. I will try to include more about my presentation and slides while I am completing the sketch and the first draft.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/i-will-be-speaking-at-javazone-2010-about-nio-2/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>OpenSolaris Governing Board effort on turning some lights on OpenSolaris future</title>
		<link>http://kalali.me/opensolaris-governing-board-effort-on-turning-some-lights-on-opensolaris-future/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=opensolaris-governing-board-effort-on-turning-some-lights-on-opensolaris-future</link>
		<comments>http://kalali.me/opensolaris-governing-board-effort-on-turning-some-lights-on-opensolaris-future/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 21:33:36 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[OpenSolaris]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[future]]></category>
		<category><![CDATA[OGB]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=587</guid>
		<description><![CDATA[Analyzing OpenSolaris community status and the OGB message to Oracle about stepping down from being OGB.]]></description>
			<content:encoded><![CDATA[<p>Well, After sometime that Oracle decided to keep complete silence, either on analog radio or via digital mediums, OGB (OpenSolaris Governing Board) which is a body of some experienced community member governing the community took action and called on Oracle publicly to decide about what it is going to do about the project.</p>
<p>Long story short, because of Oracle silence about what is going on behind the curtains community members turned restless of not knowing what will happen next which the piece of software they deployed into some of their customers server rooms. Some are looking to know when they can install the promised upgrade on the customer machines to reduce the disk space usage while other are ballistic not knowing whether they should go with OpenSolaris installations or they should turn to *BSD or Linux variants and give up on OpenSolaris.</p>
<p>These concerns raised many times in the mailing list to the point where &#8220;OpenSolaris is dead/ is dying&#8221; messages surpass all other technical discussions and Some of thees messages  seemed inappropriate enough for the Oracle staff to threaten that they are prepared to take action  up to &#8220;moderation and/or deactivation&#8221; of the list.</p>
<p>Jim Grisanzio: <strong>warning about mail on this list &#8211; </strong><em>[Tue Jun 29 16:43:47 UTC 2010]</em>@ <a href="http://mail.opensolaris.org/pipermail/opensolaris-discuss/2010-June/057703.html">http://mail.opensolaris.org/pipermail/opensolaris-discuss/2010-June/057703.html</a></p>
<blockquote><p>Recently there has been mail on this list that violates the website  Terms of Use. Individuals are being warned. However, if this trend  continues the Website Team is prepared to take action up to and  including moderation and/or deactivation of the  list. Please do not respond to hostile posts because that only escalates  the situation.</p></blockquote>
<p>Many more messages posted to the list with different comments and analysis of situation with Solaris/ OpenSolaris product and project.  These comments lead to another warning from Oracle staff:</p>
<p>Alan Burlison<strong>: </strong><strong>Yet another warning about behaviour on this list &#8211; </strong>[<em>Thu Jul 15 14:41:16 UTC 2010</em>]@<a href="http://mail.opensolaris.org/pipermail/opensolaris-discuss/2010-July/058383.html">http://mail.opensolaris.org/pipermail/opensolaris-discuss/2010-July/058383.html</a></p>
<blockquote><p>Despite repeated warnings, some people are continuing to badmouth each other on this list.  As explained previously, this is not acceptable. We&#8217;ve been warning people who have overstepped the mark, from this point on we won&#8217;t be doing that, we&#8217;ll just be immediately closing accounts and unsubscribing people from all of the opensolaris.org  lists.</p>
<p>If that proves ineffective we will consider other measures such as putting the list into moderation or shutting it down entirely.<br />
Be quite clear, this unacceptable behaviour must stop, and now.</p>
<p>Apologies to the vast majority of the list members who clearly aren&#8217;t the cause of the problem.</p></blockquote>
<p>The Oracle silence take long enough and the &#8220;OpenSolaris is dead/ going to die&#8230;&#8221; threads number and messages grow big enough to the point where OGB decided to weigh in and take action, but OGB has almost no control over anything these days and the only thing that they decided to do is calling on Oracle publicly and letting Oracle staff know that they are going to step down and resign from being the OGB if they have no power, official knowledge about what is the faith of the software that they are governing. @ <a href="http://wiki.genunix.org:8080/wiki/index.php/2010_07_12_OGB_Agenda">http://wiki.genunix.org:8080/wiki/index.php/2010_07_12_OGB_Agenda</a></p>
<blockquote><p>The OGB is keen to promote the uptake and open development of OpenSolaris and to work on behalf of the community with Oracle, as such the OGB needs Oracle to appoint a liaison by August 16, 2010, who has the authority to talk about the future of OpenSolaris and its interaction with the OpenSolaris community. Otherwise the OGB will take action at the August 23 meeting to trigger the clause in the OGB charter that will return control of the community to Oracle.</p></blockquote>
<p>Now that OGB decided to publicly call on Oracle as a body of members elected by the community, Oracle need to send some response back. But what can be the response from Oracle? I think one of the following will happen:</p>
<ul>
<li>Oracle will appoint a liaison and take part in the governance board, restructure it and assure community about the what is going on.</li>
<li>Oracle will act like nothing happened and no message like that has even been published but come forth with some resolutions at a later time after the ultimatum ended.</li>
<li>Oracle will come forth with some tanks and carrier class ships filled with Stark industries Iron Men and close down the project axing everyone posted harsh comments <img src='http://kalali.me/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </li>
</ul>
<p>I believe the first alternative is what will happen despite some of the community members believe on some version of the last alternative and demolish of OpenSolaris.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/opensolaris-governing-board-effort-on-turning-some-lights-on-opensolaris-future/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing NIO.2 (JSR 203) Part 4: Changing File System Attributes and Permissions</title>
		<link>http://kalali.me/introducing-nio-2-jsr-203-part-4-changing-file-system-attributes-and-permissions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-nio-2-jsr-203-part-4-changing-file-system-attributes-and-permissions</link>
		<comments>http://kalali.me/introducing-nio-2-jsr-203-part-4-changing-file-system-attributes-and-permissions/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 19:55:53 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[file system]]></category>
		<category><![CDATA[NIO.2]]></category>
		<category><![CDATA[Permissions]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=516</guid>
		<description><![CDATA[In this  entry you will learn how to use nio.2 to change the files and directories attributes and permissions using nio.2 included in Java 7.]]></description>
			<content:encoded><![CDATA[<p>This is the 4th installment of my entries covering NIO.2. In this entry I will discuss more about what we can do with attributes and permissions.  The NIO.2 lets us write the permissions and attributes of a file in addition to reading them. For example we can change the rwx permissions using the Attributes utility class and  PosixFilePermission.</p>
<p>You can execute the following sample code with almost no changes, the only thing you need to change is the path to our sample file and then you are ready to see how it works.</p>
<pre>import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.util.*;

public class Perm2 {

    public static void main(String args[]) throws IOException {
        FileSystem fs = FileSystems.getDefault();
        Path p = fs.getPath("/home/masoud/dl");

        // Reading attributes using attributes views.
        // here we read both basic and posix attributes of a file
        Map att = (Map) p.readAttributes("posix:*, basic:*", LinkOption.NOFOLLOW_LINKS);
        // printing the attributes to output
        Set en = att.keySet();
        for (Iterator it = en.iterator(); it.hasNext();) {
            String string = it.next();
            System.out.println(string + ": " + att.get(string));
        }
        System.out.println("-------------Attributes printing finished----------");

        // definind a new permission set for our file
        Set
 st2 = PosixFilePermissions.fromString("rwxrwxrwx");
        // Setting the attribute using Attributes utility class
        Attributes.setPosixFilePermissions(p, st2);

        // looking up and creating a principal for the given user. If use does
        // not exists it will throws a UserPrincipalNotFoundException
        UserPrincipal up = fs.getUserPrincipalLookupService().lookupPrincipalByName("masoud");

        // Setting the owner to the owner we just looked up.
        // We should have enough permisison to change the owner otherwise it will
        // throw a FileSystemException: /home/masoud/a: Operation not permitted sort of thing
        Attributes.setOwner(p, up);

        //another way to read and write the owner value for a file is using FileOwnerAttributeView
        FileOwnerAttributeView fo = p.getFileAttributeView(FileOwnerAttributeView.class, LinkOption.NOFOLLOW_LINKS);
        fo.setOwner(up);

        //Now that we have changed the permissions lets see the permissions again:
        att = (Map) p.readAttributes("posix:permissions", LinkOption.NOFOLLOW_LINKS);
        System.out.println("New Permissions:" + ": " + att.get("permissions"));
    }
}</pre>
<p>Let&#8217;s see what we have done starting from top: at the beginning we have just initialized the FileSystem object and got a file reference to <em>/home/masoud/dl</em>. Then we read all of this files basic and posix attributes using the attributes view notation. The following sample code shows this step</p>
<pre> FileSystem fs = FileSystems.getDefault();
        Path p = fs.getPath("/home/masoud/dl");

        // Reading attributes using attributes views.
        // here we read both basic and posix attributes of a file
        Map att = (Map) p.readAttributes("posix:*, basic:*", LinkOption.NOFOLLOW_LINKS);
        // printing the attributes to output
        Set en = att.keySet();
        for (Iterator it = en.iterator(); it.hasNext();) {
            String string = it.next();
            System.out.println(string + ": " + att.get(string));
        }
System.out.println("-------------Attributes printing finished----------");</pre>
<p>Next step we have use the PosixPermissions class to create a permission set using the OS permissions presentation and then applied these permissions on our file</p>
<pre> // definind a new permission set for our file
        Set
 st2 = PosixFilePermissions.fromString("rwxrwxrwx");
        // Setting the attribute using Attributes utility class
        Attributes.setPosixFilePermissions(p, st2);</pre>
<p>In the next step we created a user principal for a user named <em>masoud</em> and changed the ownership of our file to this user. We have done this using both available methods.</p>
<pre>// looking up and creating a principal for the given user. If use does
        // not exists it will throws a UserPrincipalNotFoundException
        UserPrincipal up = fs.getUserPrincipalLookupService().lookupPrincipalByName("masoud");

        // Setting the owner to the owner we just looked up.
        // We should have enough permisison to change the owner otherwise it will
        // throw a FileSystemException: /home/masoud/a: Operation not permitted sort of thing
        Attributes.setOwner(p, up);

        //another way to read and write the owner value for a file is using FileOwnerAttributeView
        FileOwnerAttributeView fo = p.getFileAttributeView(FileOwnerAttributeView.class, LinkOption.NOFOLLOW_LINKS);
        fo.setOwner(up);</pre>
<p>Finally we read the file permissions to see what has changed after we applied this new permissions on our file. using the following snippet.</p>
<pre> //Now that we have changed the permissions lets see the permissions again:
        att = (Map) p.readAttributes("posix:permissions", LinkOption.NOFOLLOW_LINKS);
        System.out.println("New Permissions:" + ": " + att.get("permissions"));</pre>
<p>The output of running the above sample code is shown below:</p>
<pre>lastModifiedTime: 2010-07-06T23:15:32Z
fileKey: (dev=805,ino=1922268)
isDirectory: false
lastAccessTime: 2010-07-11T14:15:46Z
isOther: false
isSymbolicLink: false
owner: masoud
permissions: [OTHERS_READ, OWNER_WRITE, GROUP_WRITE, OWNER_READ, GROUP_READ, OTHERS_EXECUTE, OWNER_EXECUTE, GROUP_EXECUTE, OTHERS_WRITE]
isRegularFile: true
creationTime: null
group: dip
size: 219
-------------Attributes printing finished----------
Permissions:: [OTHERS_READ, OWNER_WRITE, GROUP_WRITE, OWNER_READ, GROUP_READ, OTHERS_EXECUTE, OWNER_EXECUTE, GROUP_EXECUTE, OTHERS_WRITE]</pre>
<p>You may ask what is the attribute view notation and what is meaning of that <em>posix:permissions</em> or <em>posix:*</em>. The first one means that we want to retrieve the permissions property of the file while the second one means that we want to retrieve all attributes of the file which can be seen using the posix view.</p>
<p>Now you are asking where you can found list of this attributes view notations, then you question is very right. The following links shows what attributes are available to read using each one of those views. Each attribute is one of the properties included in the interface.</p>
<ul>
<li>BasicFileAttributes: <a href="http://download.oracle.com/docs/cd/E17409_01/javase/7/docs/api/java/nio/file/attribute/BasicFileAttributes.html">http://download.oracle.com/docs/cd/E17409_01/javase/7/docs/api/java/nio/file/attribute/BasicFileAttributes.html</a></li>
<li>PosixFileAttributes: <a href="http://download.oracle.com/docs/cd/E17409_01/javase/7/docs/api/java/nio/file/attribute/PosixFileAttributes.html">http://download.oracle.com/docs/cd/E17409_01/javase/7/docs/api/java/nio/file/attribute/PosixFileAttributes.html</a></li>
</ul>
<p>Sure we have other views, you can find them in the JavaDocs linked above.</p>
<p>Next entry will be the last entry covering File System functionalities of the NIO.2 including the watch and change notification service and the ACL list. After that we will look at new features included for IO developers. You can find other entries of this series under the <a href="http://kalali.me/tag/nio-2/">NIO.2</a> tag of my weblog.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/introducing-nio-2-jsr-203-part-4-changing-file-system-attributes-and-permissions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My weblog is now migrated to its new location, kalali.me</title>
		<link>http://kalali.me/my-weblog-is-now-migrated-to-its-new-location-kalali-me/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=my-weblog-is-now-migrated-to-its-new-location-kalali-me</link>
		<comments>http://kalali.me/my-weblog-is-now-migrated-to-its-new-location-kalali-me/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 19:50:41 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[java.net]]></category>
		<category><![CDATA[migration]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=545</guid>
		<description><![CDATA[I have been blogging for the past 4 years in my java.net blog which is now 301 redirected to its new home at kalali.me. In mid 2006 I joined Netcat 50, NetBeans quality asurance team for netbeans 5.0 release, and it was the starting point for me to get involved with Java community in more [...]]]></description>
			<content:encoded><![CDATA[<p>I have been blogging for the past 4 years in my <a href="http://www.java.net/blog/66740">java.net blog</a> which is now 301 redirected to its new home at <a href="http://kalali.me">kalali.me</a>. In mid 2006 I joined Netcat 50, NetBeans quality asurance team for netbeans 5.0 release, and it was the starting point for me to get involved with Java community in more open way and lead to filing a request to get a weblog at <a href="http://Java.net">Java.net</a>.</p>
<p>The main reason and motive behid starting the blog was sharing my experience about NetBeans platform and java development but in years the blog grown up to a point where I post 6 chapters of my unpublished GlassFish book there and post many other long articles discussing Java EE and other topics including security and software architecture among others.</p>
<p>In the past 4 years, I post 74 blog entries and  my weblog served around 200,000 page views and 160,000 visits. Majority of visitors were using Linux and Firefox according to my, now deleted by mistake, google analytics data. The biggest referal site was <a href="http://Java.net">Java.net</a> itself where my weblog get promoted to the first page and google was the main search engine leading readers to my weblog.</p>
<p>What I will always remember from my Java.net blog is friends I found through the blog and the friendly community and staff behind Java.net and its infrastructure which were and are working around the clock to keep Java.net a professional environment for everyone involved and uses Java.net. Even when I was leaving Java.net they did not stop taking care of my request and kindly applied 301 redirects to all my current blog entries to redirect them to their new location, which in my opinion show how professional they act and think.</p>
<p>But the reason behind moving to my personal domain from the exceptional java.net hosting and community is the flexibility I need to keep all my content in the sam place instead of keeping some content on java.net blog and some other content on my personal website.</p>
<p>In the next few weeks I will include more pages to my new website including a page for my GlassFish security book to have a better communication channel with my readers and a new page for the book I am authoring now. My new website will include my photoblog as anothe part. I am not a professional photographer and I will look for comments and advices from friends and readers whom are more experienced on photography compared to what I know and experienced.</p>
<p><strong><span style="color: red;">If  you are a reader of my weblog then you can follow me using the new domain and the new </span></strong><span style="color: red;"><a href="http://kalali.me/feed/"><strong>feed url</strong></a><strong>. The new domain will serve readers and visitors in a more interactive and easy to find way.</strong></span><strong></strong></p>
<p style="text-align: center;"><strong>Long live <a href="http://Java.net">Java.net</a></strong><strong> and its professional team.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/my-weblog-is-now-migrated-to-its-new-location-kalali-me/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Introducing NIO.2 (JSR 203) Part 3: File System Attributes and Permissions support in NIO.2</title>
		<link>http://kalali.me/introducing-nio-2-jsr-203-part-3-file-system-attributes-and-permissions-support-in-nio-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-nio-2-jsr-203-part-3-file-system-attributes-and-permissions-support-in-nio-2</link>
		<comments>http://kalali.me/introducing-nio-2-jsr-203-part-3-file-system-attributes-and-permissions-support-in-nio-2/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 14:58:16 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Attributes]]></category>
		<category><![CDATA[JSR-203]]></category>
		<category><![CDATA[NIO.2]]></category>
		<category><![CDATA[Permissions]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=380</guid>
		<description><![CDATA[In two previous entries I covered Introducing NIO.2 (JSR 203) Part 1: What are new features? and Introducing NIO.2 (JSR 203) Part 2: The Basics In this entry I will discuss Attributes introduced in NIO.2. Using attributes we can read platform specific attributes of an element in the file system. For example to hide a [...]]]></description>
			<content:encoded><![CDATA[<p>In two previous entries I covered<a href="http://weblogs.java.net/blog/kalali/archive/2010/05/19/introducing-nio2-jsr-203-part-1-what-are-new-features"> Introducing NIO.2 (JSR 203) Part 1: What are new features?</a> and <a href="http://www.java.net/blog/kalali/archive/2010/06/01/introducing-nio2-jsr-203-part-1-basics">Introducing NIO.2 (JSR 203) Part 2: The Basics </a> In this entry I will discuss Attributes introduced in NIO.2. Using attributes we can read platform specific attributes of an element in the file system. For example to hide a file system in DOS file system or to check the last access date of a file in a UNIX machine.</p>
<p>Using NIO.2 we can check which attributes are supported in the platform we are running on and then we can decide how to deal with the available attributes. Following sample code shows how we can detect the available attributes and then how to manipulate them.</p>
<pre>  FileSystem fs = FileSystems.getDefault();
  Path p = fs.getPath("/home/masoud/netbeans-6.9-ml-linux.sh");
 //checking available attributes:
  Set&lt;String&gt; supportedViews = fs.supportedFileAttributeViews();
 //We always have at least one member in the set, the basic view.
  BasicFileAttributes ba = p.getFileAttributeView(BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS).readAttributes();
 //Printing some basic attributes
   System.out.println(p.toString() + " last access:  " + ba.lastAccessTime());
   System.out.println(p.toString() + " last modified " + ba.lastModifiedTime());
        // As I know I am in NIX machine I access the unix attributes.
        // If I didnt I should have iterate over the set to determine which
        // attributes are supported
        if (supportedViews.contains("unix")) {
            PosixFileAttributes pat = Attributes.readPosixFileAttributes(p, LinkOption.NOFOLLOW_LINKS);
            System.out.println(pat.group().getName());
            System.out.println(pat.owner().getName());
        }</pre>
<p>I placed plethora of comments on the code so reading and understanding it get easier.</p>
<p>In the next snippet we will see how we can read permissions of file system element. The first step in checking permissions is using the checkAccess method as shown below. the method throw an exception if the permission is not present or it will execute with no exception if the permission is present.</p>
<pre> FileSystem fs = FileSystems.getDefault();
 Path p = fs.getPath("/home/masoud/netbeans-6.9-ml-linux.sh");
    try {
            // A method to check the access permissin
            p.checkAccess(AccessMode.EXECUTE);
        } catch (IOException ex) {
            Logger.getLogger(perm.class.getName()).log(Level.SEVERE, null, ex);
        }

        // Extracting all permissions of a file and iterating over them.
        //I know that I am dealing with NIX fs so I go directly with that attributes
        // otherwise we should check which attributes are supported and then we can
        // use them.

        PosixFileAttributes patts = Attributes.readPosixFileAttributes(p, LinkOption.NOFOLLOW_LINKS);
        Set&lt;PosixFilePermission&gt; st = patts.permissions();
        for (Iterator&lt;PosixFilePermission&gt; it = st.iterator(); it.hasNext();) {
            System.out.println(it.next().toString());
        }

        // Using PosixFilePermissions to convert permissions to different representations
        System.out.println(PosixFilePermissions.toString(st));</pre>
<p>As you can see in the code we can use the helper class to convert the permission set to a simpl OS represeted permission of the element. for example the set can be translated to rwx&#8212;&#8212;  if the file has owner read, write and execute permissions attached to it. The helper calss can convert the os represenation of the permission to the permissions set for later use in other nio classess or methods. In the next entry I will conver more on permissions and security by tackling the Access Control List (ACL) support in the nio.2</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/introducing-nio-2-jsr-203-part-3-file-system-attributes-and-permissions-support-in-nio-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing NIO.2 (JSR 203) Part 2: The Basics</title>
		<link>http://kalali.me/introducing-nio-2-jsr-203-part-2-the-basics/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-nio-2-jsr-203-part-2-the-basics</link>
		<comments>http://kalali.me/introducing-nio-2-jsr-203-part-2-the-basics/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 04:16:35 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[FileStore]]></category>
		<category><![CDATA[FileSystem]]></category>
		<category><![CDATA[JSR-203]]></category>
		<category><![CDATA[NIO.2]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=378</guid>
		<description><![CDATA[In this part we will discuss the basic classes that we will work with them to have file system operations like copying a file, dealing with symbolic links, deleting a file, and so on. I will write a separate entry to introduce classes which are new to Java 7 for dealing with streams and file [...]]]></description>
			<content:encoded><![CDATA[<p>In this part we will discuss the basic classes that we will work with them to have file system operations like copying a file, dealing with symbolic links, deleting a file, and so on. I will write a separate entry to introduce classes which are new to Java 7 for dealing with streams and file contents, watching service and directory tree walking. If you want to know what are new features in Java SE 7 for dealing with IO take a look at   <a href="http://kalali.me/blog/kalali/archive/2010/05/19/introducing-nio2-jsr-203-part-1-what-are-new-features">Introducing NIO.2 (JSR 203) Part 1: What are new features?</a></p>
<p>Before NIO.2, dealing with file system was mainly done using the File class and no other base class was available. In NIO.2 it there are some new classes at our disposal to take advantage of their existence to do our job.</p>
<p><a href="http://openjdk.java.net/projects/nio/javadoc/java/nio/file/FileSystems.html">FileSystems</a>: Everything starts with this factory class. We use this class to get an instance of the FileSystem we want to work on. The nio.2 provides a SPI to developed support for new file systems. For example an in-memory file system, a ZIP file system and so on. Following two methods are most important methods in FileSystems class.</p>
<p style="-qt-block-indent: 1;">
<ol>
<li>The getDefault() returns the default file system available to the JVM. Usually the operating system default files system.</li>
<li>The getFileSystem(URI uri) returns a file system from the set of available file system providers that match the given uir schema.</li>
</ol>
<p><a href="http://openjdk.java.net/projects/nio/javadoc/java/nio/file/Path.html">Path</a>: This is the abstract class which provides us with all File system functionalities we may need to perform over a file, a directory or a link.</p>
<p><a href="http://openjdk.java.net/projects/nio/javadoc/java/nio/file/FileStore.html">FileStore</a>: This class represents the underplaying storage. For example /dev/sda2 in *NIX machines and I think c: in windows machines. We can access the storage attributes using  <a href="http://openjdk.java.net/projects/nio/javadoc/java/nio/file/attribute/FileStoreSpaceAttributes.html ">FileStoreSpaceAttributes</a> object. Available space, empty space and so on.</p>
<p>Following two sample codes shows how to copy a file and then how to copy it.</p>
<pre>public class Main {

    public static void main(String[] args) {

        try {
            Path sampleFile = FileSystems.getDefault().getPath("/home/masoud/sample.txt");
            sampleFile.deleteIfExists();
            sampleFile.createFile(); // create an empty file
            sampleFile.copyTo(FileSystems.getDefault().getPath("/home/masoud/sample2.txt"), StandardCopyOption.COPY_ATTRIBUTES.REPLACE_EXISTING);
            // Creating a link
            Path dir = FileSystems.getDefault().getPath("/home/masoud/dir");
            dir.deleteIfExists();
            dir.createSymbolicLink(sampleFile);
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }</pre>
<p>And the next sample shows how we can use the FileStore class. In this sample we get the underlying store for a file and examined its attributes. We can an iterator over all available storages using FileSystem.getFileStores() method and examine all of them in a loop.</p>
<pre> public class Main {

    public static void main(String[] args) throws IOException {
        long aMegabyte = 1024 * 1024;
        FileSystem fs = FileSystems.getDefault();
        Path sampleFile = fs.getPath("/home/masoud/sample.txt");
        FileStore fstore = sampleFile.getFileStore();
        FileStoreSpaceAttributes attrs = Attributes.readFileStoreSpaceAttributes(fstore);
        long total = attrs.totalSpace() / aMegabyte;
        long used = (attrs.totalSpace() - attrs.unallocatedSpace()) / aMegabyte;
        long avail = attrs.usableSpace() / aMegabyte;
        System.out.format("%-20s %12s %12s %12s%n", "Device", "Total Space(MiB)", "Used(MiB)", "Availabile(MiB)");
        System.out.format("%-20s %12d %12d %12d%n", fstore, total, used, avail);

            }</pre>
<p>In next entry I will discuss how we can manage file attributes along with discussing the security features of the nio.2 file system.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/introducing-nio-2-jsr-203-part-2-the-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing OpenESB from development to administration and management.</title>
		<link>http://kalali.me/introducing-openesb-from-development-to-administration-and-management/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-openesb-from-development-to-administration-and-management</link>
		<comments>http://kalali.me/introducing-openesb-from-development-to-administration-and-management/#comments</comments>
		<pubDate>Mon, 24 May 2010 08:31:18 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[BPEL]]></category>
		<category><![CDATA[OpenESB]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[WSDL]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=376</guid>
		<description><![CDATA[OpenESB project initiated by Sun Microsystems to develop and deliver a high performance, and feature rich implementation of Java Business Integration (JBI) under an open source friendly license. Basic task of JBI implementations is connecting different type of resources and applications together in a standard and none intrusive way. Basic building blocks of an ESB [...]]]></description>
			<content:encoded><![CDATA[<p >OpenESB project initiated by Sun Microsystems to develop and deliver a high performance, and feature rich implementation of Java Business Integration (JBI) under an open source friendly license. Basic task of JBI implementations is connecting different type of resources and applications together in a standard and none intrusive way. Basic building blocks of an ESB includes the Bus which is a message driven engine and transition path which deliver the required message to designated binding components. These components are the second main set of artifacts which an ESB has. The main tasks of binding components is receiving the Bus standard format messages and deliver them to other software in a format that the particular software can use. The third set of artifacts is Service engines which can relates the Bus to other types of containers like Java EE containers, transform the messages before they enter the Bus, perform routing related activities over the Bus messages.</p>
<p >The Main concept behind the JBI was around for quite some times but in recent years several factors helped with this concept to further evolve. First the increasing integration problems, second the SOA acceptance level between companies and finally introduction of JSR-208 specification by JCP which provides a common interfacing mechanism for JBI artifacts.</p>
<p >The increasing problem is nothing but the urge for integrating different software which is running in different department of the same enterprise or different partners across enterprises. An ESB implementation can be a non intrusive enabler product for integrating different software running in different department or enterprises without or with very small amount of changes in the software itself.</p>
<p >The concept which helped ESB to become very well known and popular is the Service Oriented Architecture (SOA) in which an ESB can play the enabler role because of its modularity and loose coupling nature.</p>
<p><strong><em>1 Introducing OpenESB</em></strong></p>
<p >OpenESB project located at <a href="http://open-esb.dev.java.net/">http://open-esb.dev.java.net</a> initiated in 2005 when Sun Microsystems released a portion of its ESB products under CDDL license. Sun Microsystems, the user community and some other third party companies are working together on OpenESB project. However, the main man power and financial support comes from Sun Microsystems. </p>
<p >The project goal is development and delivery of a high performance, feature rich and modular JBI compliant ESB (the runtime) and all required development phase tools which accelerates and facilitate developing applications based on OpenESB capabilities and features. </p>
<p >The runtime components use GlassFish application server’s components like Metro web services stack, CLI and administration console infrastructure, and so on. OpenESB uses NetBeans IDE as the foundation for providing development and design time artifacts for its it runtime components. Design time functionalities are provided in a modular manner on top of NetBeans modularity system.</p>
<p><strong><em>1.1 Introducing JBI</em></strong></p>
<p >The JBI defines a specification for assembling integration components to create integration solutions that enable different software (external system) to actively integrate on providing a solution based on separate capabilities which every one of that software can provide on itself. These integration components are plugged into a JBI environment and can provide or consume services messages which lead in providing or consuming a service through the shared communication channel. The shared communication channel can route messages between different components and it also can transform the messages in a pre-defined or rule based way. In addition to transformation, different other base services are provided by the JBI environment. We call the environment the Service Bus or Enterprise Service Bus.</p>
<p >Based on the JBI specification and architecture a component is the main part of a JBI implementation which users or developers should understand. These components can acts as consumer or producers. When a component acts as consumer it receives a message from the service bus in a normalized and standard format. Then the component delivers the message to the external system in a format that the external system understands. When a component acts as a consumer to the service bus, it receives the message in a format provided by external system and converts it to normalized XML before sending it into the service bus. We call these components as binding components because they bind a external system to the service bus.</p>
<p><strong>The JBI environment</strong></p>
<p >JBI defines two types of components which JBI developers can develop and plug into a JBI container. However these two types are standardized and certainly each vendor has many internal and none standard interfaces, components, and a specific component model for its internal system. These Two types of components which can be plugged into a JBI environment include:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li> </li>
<p  style=" -qt-block-indent:1;">Service engines provide logic in the environment, such as transformation, scripting language support, ETL and CEP support, or BPEL and so on.</p>
<li> </li>
</ul>
<p  style=" -qt-block-indent:1;">Binding components are adapters which can connect an external system to the service bus. For example a JMS binding component can connect a JMS message broker to the service bus, a mail server component can bind an emailing system to the bus to make it possible for other binding components to send email or receive emails through the bus.</p>
<p >Figure 1 shows the overall architecture of OpenESB from the specification point of view. The architecture may differ from implementation to implementation.</p>
<p><img src="http://dl.dropbox.com/u/334201/jn-blog-files/figure17.1.png" /></p>
<p>Figure 1 The OpenESB architectural diagram from JBI perspective</p>
<p >The most important fact in the JBI environment in message delivery and content delivery usually introduces requirements like transaction support, naming support, and so on. The internal square illustrates the OpenESB overall environment while the external boxes represent systems external to the OpenESB runtime. Message format inside the square is XML while the format between the binding components and external system is external system oriented. Every component either Service engine or Binding component register the service that they provide by WSDL descriptor.</p>
<p><strong><em>1.2 OpenESB versions and editions</em></strong></p>
<p >OpenESB like GlassFish has several concurrent versions which are either in active development mode, stable or in maintenance mode. OpenESB version one is in maintenance mode and the only updates are possible bug fixes, no new feature will be added to this version.</p>
<p >OpenESB version 2 is the current active version which is under development. OpenESB version 3 named project Fuji is under active design and development. Through the project Fuji Sun Microsystems will develop the next version of OpenESB which is fully based on a modular system similar to GlassFish version 3.</p>
<p >Like OpenSSO and GlassFish which have which have commercially packaged version supported by Sun Microsystems, there is a commercially packaged and supported package for OpenESB named GlassFish ESB. The only different between OpenESB and GlassFish ESB is that GlassFish ESB is a package which contains stable components of the OpenESB along with Sun Microsystems support behind it. </p>
<p >If you are looking for latest bug fixes, latest new features and components you should go with OpenESB, if you want a stable version then you should go with GlassFish ESB. Both versions are free and you can use them commercially without paying any license fee. The difference is that Sun provides commercial level support for GlassFish ESB packages.</p>
<p >All versions of OpenESB including GlassFish ESB, Project Fuji, and OpenESB development builds are available at <a href="http://open-esb.dev.java.net/Downloads.html">http://open-esb.dev.java.net/Downloads.html</a>.</p>
<p><strong><em>1.3 OpenESB Architecture</em></strong></p>
<p >OpenESB version 2 closely follows the specification and has no extendibility or pluggibility beyond the JBI proposed components. OpenESB JBI container is tightly integrated with GlassFish application server to provide the overall running ESB. The integration between GlassFish application server and OpenESB results in integrated administration console in all 3 major administration channel including JMX and AMX, CLI and web based administration console. </p>
<p >The most important part of an ESB is the message broker and its Web services stack. OpenESB uses Metro Web service stack which is proven enough to be used by some other vendors as their web services stack and OpenMQ as the message broker. OpenMQ can be considered one of the top level message broking systems in term of performance and capabilities.</p>
<p><strong><em>1.4 OpenESB supported standards and features</em></strong></p>
<p >When it come to list an ESB features and supported protocols and format we can list them under five different categories including: The over all performance, the reliability and scalability of the system, available service engines, available binding components and finally administration and management channel effectiveness. </p>
<p >Certainly there are other factors which can not deeply discuss here, factors like: vendor support level, quality of available components and service engines. Providing benchmarks which shows how good the product works and so on. But, to some extent, we can discuss five primary attributes briefly.</p>
<p><strong>performance</strong></p>
<p >The most important part of an ESB is the messaging system; OpenESB uses OpenMQ as the underlying messaging system. In different benchmarks and uses cases OpenMQ proved to perform very well.</p>
<p >The other important component which affects an ESB performance is Web services stack which is used to develop the underlying WSDL-SOAP communication. The Metro framework which forms the underlying Web services stack of OpenESB is very well featured with an outstanding performance. IBM uses some part of Metro in their JDK, BEA uses Metro stack for its WebLogic application server and so on. </p>
<p><strong>Available service engines</strong></p>
<p >Functional feature of an ESB are directly depended on the functionality of its service engines and binding components. OpenESB has a very rich set of Service engines which are either developed directory by Sun Microsystems or one of OpenESB project partners. Table 1 shows the list of most important service engines along with a description of each service engine.</p>
<p >Table 1 Important service engines available through project OpenESB</p>
<table border="0" width="518" cellspacing="0" cellpadding="7">
<tr>
<td width="113">
<p align="left"></p>
<p align="left"><strong>Service Engine</strong> </p>
</td>
<td width="377">
<p align="left"></p>
<p align="left"><strong>Description</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">BPEL SE</p>
</td>
<td>
<p align="left"></p>
<p align="left">A WS-BPEL 2.0 compliant engine that provides business process orchestration capabilities.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">IEP SE</p>
</td>
<td>
<p align="left"></p>
<p align="left">An engine for Complex Event Processing (CEP) and Event Stream Processing (ESP)</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Java EE SE</p>
</td>
<td>
<p align="left"></p>
<p align="left">Makes the whole EE environment available as a JBI component so that EJBs can communicate with other JBI components through the NMR and vice versa.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">WLM SE</p>
</td>
<td>
<p align="left"></p>
<p align="left">The Worklist Manager is a JBI based engine providing task management and human intervention in a business process.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Data Integrator / ETL SE</p>
</td>
<td>
<p align="left"></p>
<p align="left">Performs extract &#8211; transform &#8211; load to build DataWarehouses, or can be used for Data Migration.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Data mashup</p>
</td>
<td>
<p align="left"></p>
<p align="left">Provides a single view of data from heterogeneous sources, including static web pages and tabular data exposed as web services. Provides options to join/aggregate/clean data, and generate a response in a WebRowSet schema.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">XSLT SE </p>
</td>
<td>
<p align="left"></p>
<p align="left">An engine for applying XSLT transformations with basic orchestration capabilities.</p>
</td>
</tr>
</table>
<p >All of these service engines have the runtime and design time components included. Some of them are not commercially stable enough to be included in GlassFish ESB and in case of requirement we should download and install them manually. The nightly builds are available at <a href="http://download.java.net/jbi/binaries/installers/single-component/v2/nightly/">http://download.java.net/jbi/binaries/installers/single-component/v2/nightly/</a>.</p>
<p >We will discuss BPEL SE in more details in subsequent sections.</p>
<p><strong>Available binding components</strong></p>
<p >Binding components provide the functionalities required to connect an external system to the service bus. We have two expressions about binding components; a binding component acts as consumer or provider. For example an email component which acts as consumer sends a message which receives through the service bus to an email address. And when it injects the incoming emails into the bus it is acting as a provider.</p>
<p >Table 2 lists important binding components available through the OpenESB components project. These components are either developed by Sun Microsystems or one of its partners. Each binding component has a runtime and a design time part. The runtime part should be deployed into OpenESB while the design time part is a NetBeans module which we should install.</p>
<p >Table 2 Important binding components available through project OpenESB</p>
<table border="0" width="518" cellspacing="0" cellpadding="7">
<tr>
<td width="101">
<p align="left"></p>
<p align="left"><strong>Component </strong> </p>
</td>
<td width="389">
<p align="left"></p>
<p align="left"><strong>Description</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">eMail BC </p>
</td>
<td>
<p align="left"></p>
<p align="left">A Binding Component for sending and receiving emails</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Database BC </p>
</td>
<td>
<p align="left"></p>
<p align="left">Reads messages from and writes messages to a database over JDBC</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">HTTP BC </p>
</td>
<td>
<p align="left"></p>
<p align="left">A JBI component for sending and receiving messages over HTTP</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">JMS BC </p>
</td>
<td>
<p align="left"></p>
<p align="left">Receives messages from and sends messages to a remote service through JMS</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">LDAP BC </p>
</td>
<td>
<p align="left"></p>
<p align="left">Reads messages from and writes messages to an LDAP server</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">SAP BC </p>
</td>
<td>
<p align="left"></p>
<p align="left">Provides functionality for interacting with a SAP R/3 system within a JBI environment.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">SIP BC </p>
</td>
<td>
<p align="left"></p>
<p align="left">Integrates media capabilities from communications networks using the SIP protocol (Session Initiation Protocol)</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">FTP </p>
</td>
<td>
<p align="left"></p>
<p align="left">BC Polls for files on an FTP server, and provides for uploading files to an FTP server</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">File </p>
</td>
<td>
<p align="left"></p>
<p align="left">BC Polls for files on the file system, and provides for writing files to the file system</p>
</td>
</tr>
</table>
<p> </p>
<p >Number of Binding components reaches 30 and covers variety of standards and protocols. Table 2 lists the most widely used binding components regardless of either it are in beta or stable state. You can find a list of all components at <a href="https://open-esb.dev.java.net/Components.html">https://open-esb.dev.java.net/Components.html</a>. The list contains all necessary information like states, in maintenance mode or deprecated components and so on.</p>
<p><strong>Administration and management</strong></p>
<p >One important feature of a middleware is the possibility to administrate, monitor, and manage the middleware in ac effective and preferment way. OpenESB follows the same path that GlassFish does and provides very profound administration functionalities including a CLI and web based administration. Administration console provides monitoring information for service engines and binding components and deployed artifact.</p>
<p><strong><em>2 Getting OpenESB running</em></strong></p>
<p >Every big software need some sort of manual for installing and running the application, the manual includes information about compatible architecture, operating systems and runtime platforms. In our case we can install OpenESB on any operating system which there is a Java 5 runtime environment available for it. The supported platforms include Windows, Linux flavors, Solaris flavors, and Mac OSX flavors.</p>
<p><strong><em>2.1 Downloading and installing</em></strong></p>
<p >OpenESB is based on GlassFish and therefore it has the same packaging policy and schema for different operating systems. In our exploration we will use GlassFish ESB version 2 which is available at <a href="https://open-esb.dev.java.net/Downloads.html">https://open-esb.dev.java.net/Downloads.html</a>. Make sure that you select the right version for your operating system and underlying architecture.</p>
<p >GlassFish ESB bundle contains the runtime bits which is consisting of JBI components and service engines along with the JBI container itself. The distribution package also contains the development time components which include NetBeans IDE and additional modules for supporting bundler JBI runtime components.</p>
<p >The installation process is quite simple; the installer asks for installation path and configuration information like GlassFish instance port, administration credentials and so on. By now you should be very good with the installation process. Before starting the installation process, ensure that you have something around 600MB of free space in the partition that you want to install the package.</p>
<p >Installing both GlassFish ESB runtime and NetBeans IDE inside one parent directory is a good practice as we have all development related artifacts in the same place. </p>
<p><strong><em>2.2 Getting familiar with GlassFish ESB </em></strong></p>
<p >I assume that we installed GlassFish ESB in a folder named glassfishesb_home, content of this folder is shown in figure 2</p>
<p> <img src="http://dl.dropbox.com/u/334201/jn-blog-files/figure17.2.png" /></p>
<p>Figure 2 GlassFish ESB installation directory’s content</p>
<p >The content is very straight forward and cleans for such a massive development and deployment system. The glassfish folder includes GlassFish version 2ur2 along with stable versions of OpenESB container and components while the netbeans directory contains NetBeans IDE along with all necessary modules to support GlassFish ESB functionalities in design time.</p>
<p >We can start the server separately by running start_glassfish_domain1 script for times that we do not need the development environment running. Otherwise we can start NetBeans IDE by running start_netbeans script and then letting NetBeans to start the server when required.</p>
<p><strong><em>3 Developing and testing a simple application</em></strong></p>
<p >NetBeans IDE is a very feature rich IDE for developing Java EE applications and inclusion of SOA and Composite application development functionalities which targets OpenESB make the IDE a perfect development tools for developing composite applications and integration components. In this section we create a very simple BPEL based application to show how the overall process works.</p>
<p><strong><em>3.1 The sample scenario</em></strong></p>
<p >It is important to understand what we want to build and what features of OpenESB artifacts we want to use to implement the required functionalities. We have a portal like system which users can add a whether Portlet to see the current weather of their home city. We want to store some statistics which later on helps us determine which country and cities has largest number of users which use the Portlet weather. </p>
<p >To achieve this goal we used two web services, the first one translate the IP address of our client to its location including country and city and the second service provides us with current weather condition. We should somehow weave these services together to achieve the desired result. We also need to log all access to these web services with details related to country, city and date in a text file or database table to perform the statistical analysis and extract the usage portion for each country and each city in each country.</p>
<p >We will only use two BEPL components including the Database BC and BPEL SE. with these two component we can achieve a complete solution for our problem which otherwise could take more time to implement with much less flexibility in term of applying new and updated business rules.</p>
<p><strong><em>3.2 Creating the BPEL Module project</em></strong></p>
<p >Run NetBeans IDE and switch to Services view (CTRL+5), expand the database node and right click on the Java DB instance and select Start Server from the context menu. Expand the drivers’ node and right click on Java DB (Network) node and select Connect Using.</p>
<p >When the New Database Connection opened, change different attributes of the connection as follow:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li> </li>
<p  style=" -qt-block-indent:1;">Database URL: jdbc:derby://127.0.0.1:1527/WeatherInfo;create=true</p>
<li> </li>
<p  style=" -qt-block-indent:1;">User: APP</p>
<li> </li>
</ul>
<p  style=" -qt-block-indent:1;">Password: APP</p>
<p >Click OK and NetBeans will create a new connection to our database. Expand the connection node, right click on the Tables node and select Create Table item. Create a table named wRequestLog with fields listed in the table 3.</p>
<p >Table 3 The wRequestLog table’s fields</p>
<table border="0" width="346" cellspacing="0" cellpadding="7">
<tr>
<td width="159">
<p align="left"></p>
<p align="left"><strong>Field Name</strong> </p>
</td>
<td width="159">
<p align="left"></p>
<p align="left"><strong>Field Type</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">rDate</p>
</td>
<td>
<p align="left"></p>
<p align="left">Varchar(30)</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Country</p>
</td>
<td>
<p align="left"></p>
<p align="left">Varchar(30)</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">City</p>
</td>
<td>
<p align="left"></p>
<p align="left">Varchar(30)</p>
</td>
</tr>
</table>
<p> </p>
<p >The composite application runs inside the container and for accessing our WeatherInfo database we need to create a connection pool and data source in GlassFish application server. Create a connection pool for the above database and then create a data source named jdbc/winfo.</p>
<p >To create the connection pool you can use following asadmin command.</p>
<p><code>create-jdbc-connection-pool --datasourceclassname org.apache.derby.jdbc.ClientDataSource --restype javax.sql.XADataSource --property portNumber=1527:password=APP:user=APP:serverName=localhost:databaseName=WeatherInfo WinfoPool</code></p>
<p >I am sure that you remember how we used to create data sources but I provide the corresponding asadmin command if you have just forget the spelling <img src='http://kalali.me/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
<p><code>create-jdbc-resource --connectionpoolid WinfoPool jdbc/winfo</code></p>
<p >Now we are ready to take one step further and create the project and its related files like copy of WSDL documents, BPEL process file and so on.</p>
<p >Run the SOA enabled NetBeans IDE and from the main menu select File&gt;New&gt;Project and from categories select SOA and from projects list select BEPL Module click next and change the project name to WeatherInfo.</p>
<p >Right click on project node in project view (CTRL+1) and select New&gt;Other, a window will open, from the categories select XML and from file types select External WSDL Document and click next. We want to create a WSDL from a URL therefore use <a href="http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl">http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl</a> as the URL and click finish. NetBeans will create a reference to the WSDL file along with a local copy of the WSDL file which we may edit to tailor it to our requirement. This web service provides us with location of a given IP address. The IP2Geo web service is provided by CDYNE Corporation and I get a trial license for using the web service in the book.</p>
<p >Follow the same procedure and create a new WSDL file from <a href="http://www.webservicex.com/globalweather.asmx?WSDL">http://www.webservicex.com/globalweather.asmx?WSDL</a>. This web service takes a city name along with the country name and returns the current weather. The Global Weather web service is provided by WebserviceX.</p>
<p ><span style=" color:#000000;"> We have two more steps and then we are finished with creating our project’s basic artifacts. The first artifact is a WSDL descriptor which let us use Database Binding Component to record all requests and the second artifact is the WSDL descriptor which describe input and output types of our provided service which is our BPEL process.</p>
<p >To create the database binding component, right click on the project node and select New&gt;WSDL Document the wizard will open and guide you through the process. In the first page of wizard use the following information: </p>
<p style=" -qt-block-indent:1;">
<ul>
<li> </li>
<p  style=" -qt-block-indent:1;">Change the name to DBLOGBC</p>
<li> </li>
<p  style=" -qt-block-indent:1;">Change the WSDL Type to Concrete WSDL Document; two new attributes will become available.</p>
<li> </li>
</ul>
<p  style=" -qt-block-indent:1;">Change the Binding to Database and change the Type to Prepared Statement.</p>
<p  style=" -qt-block-indent:1;">Click next, in this page we should determine which database connection we want to use, select the connection URL that we made in previous step and click Next. In this step we need to enter a valid prepared statement which the binding component will execute against the database. Enter the following snippet as the prepared statement value and then press Discover Parameters.</p>
<p >insert into APP.WREQUESTLOG (rdate,country,city) values (?,?,?)</p>
<p >Change the parameters name according to figure 3 and click Next then click Finish and we are done with defining a database binding component which can integrate into the solution and insert our records into database.</p>
<p> <img src="http://dl.dropbox.com/u/334201/jn-blog-files/figure17.3.png" /></p>
<p>Figure 3 Database binding component’s prepared statement definition</p>
<p >The OpenESB version 2 design time modules does not works very good for naming the attributes and operations. We need to rename them manually to have easier mapping and navigation inside the project artifact later. Open the DBLOGBC.wsdl in the source editor and replace all instance of newuntitled_Operation with log_Operation. Also look for jdbc/__defaultDS and replace it with jdbc/winfo. Depending on your NetBeans and OpenESB design time component the default data source name may differ or even the wizard may asks you for the data source name but you can always manually edit the jdbc:address element of the DatabaseBC’s wsdl file to make the correct configuration.</p>
<p >You remember that we changed the parameters name, but your OpenESB design time modules may forget to apply the naming in the XSD file and therefore we will face some ambiguity problems during variables mapping in next steps. So open the DBLOGBC.xsd in the source editor and make following changes:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li> </li>
<p  style=" -qt-block-indent:1;">param1 should change to rDate</p>
<li> </li>
<p  style=" -qt-block-indent:1;">param2 should change to Country</p>
<li> </li>
</ul>
<p  style=" -qt-block-indent:1;">param3 should change to City</p>
<p >Here comes the last step before creating the BPEL process, in this step we define the process communication interface which external clients will use to invoke our process and utilize its service.</p>
<p >Right click on the project node and select New&gt;WSDL Document, when the wizard opened change the name to wInfoProcess; for the WSDL type select Concrete WSDL Document; for the binding choose SOAP and for the type attribute select RPC Literal press Next. Change the input message part name to IPAddress and change the output message part name to weatherInfo. </p>
<p >We are finished with defining all basic artifacts prior to designing the process, now we should just continue with designing the BPEL process itself. To do so, right click on the project node and select New&gt;BPEL Process, change the name to wInfoProcess and click Finish. Now NetBeans should open the BPEL process in the BPEL designer which is a design time module of OpenESB. </p>
<p >In the right side of the IDE you can see components plat and in the left side the project explorer is in place. First let’s create the partner links which connect the BPEL process to other involved parties like external web services and our database binding component. The BPEL designer has three sections, left right and the middle section, the left and right side are used for partner links. Therefore drag and drop the WSDL files from project explorer into the design are as listed in table 4. When you drop a WSDL into the BPEL designer left or right side a window will open which allows you to change the partner link attribute and characteristics. We accept default values for all attributes expect for the partner link name which are listed in the table.</p>
<p >Table 4 adding WSDLs to BPEL process designer </p>
<table border="0" width="518" cellspacing="0" cellpadding="7">
<tr>
<td width="159">
<p align="left"></p>
<p align="left"><strong>WSDL name</strong> </p>
</td>
<td width="126">
<p align="left"></p>
<p align="left"><strong>BPEL designer area</strong></p>
</td>
<td width="191">
<p align="left"></p>
<p align="left"><strong>Changes required for partner link</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">ip2geo.asmx.wsdl</p>
</td>
<td>
<p align="left"></p>
<p align="left">Right Side</p>
</td>
<td>
<p align="left"></p>
<p align="left">Change the name to Positioning</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">globalweather.asmx.wsdl</p>
</td>
<td>
<p align="left"></p>
<p align="left">Right Side</p>
</td>
<td>
<p align="left"></p>
<p align="left">Change the name to Weather</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">DBLOGBC.wsdl</p>
</td>
<td>
<p align="left"></p>
<p align="left">Right Side</p>
</td>
<td>
<p align="left"></p>
<p align="left">Change the name to Logger</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">wInfoProcess.wsdl</p>
</td>
<td>
<p align="left"></p>
<p align="left">Left Side</p>
</td>
<td>
<p align="left"></p>
<p align="left">Change the name to WInfoProcess</p>
</td>
</tr>
</table>
<p >By now your designer window should be similar to figure 5. Partner Links in the left side meant to be internal to the BPEL process and those in the right side are external to the BPEL process.</p>
<p><img src="http://dl.dropbox.com/u/334201/jn-blog-files/figure17.5.png" /></p>
<p>Figure 5 The BPEL designer after adding all partner links.</p>
<p >Now we need to add BPEL elements to the process to implement the business logic that we discussed. From top to button we need to add the following elements to the BPEL designer window. The final view of designer window after we finish adding elements will be similar to figure 6.</p>
<p>
<img src="http://dl.dropbox.com/u/334201/jn-blog-files/figure17.6.png" /></p>
<p> Figure 6 BPEL designer view adding all necessary elements</p>
<p >Table 5 shows the complete list of all elements which we should add to the designer. To add the elements we should drag and drop them from the right side Palette into the middle area of the designer. Designer will show you all possible places for dropping the element by shoeing an orange circle in that position. To rename an element we can simply select the element and press F2 or double click on the element name. To connect an element to one of the partners, click on the element, an envelop will appear, drag and connect the element to the partner link mentioned in the table 5</p>
<p >Table 5 List of required BPEL elements which we should add to the designer window</p>
<table border="0" width="392" cellspacing="0" cellpadding="7">
<tr>
<td width="116">
<p align="left"></p>
<p align="left"><strong>Element Type</strong> </p>
</td>
<td width="119">
<p align="left"></p>
<p align="left"><strong>Element Name</strong></p>
</td>
<td width="116">
<p align="left"></p>
<p align="left"><strong>Partner Link</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >Receive</p>
</td>
<td>
<p align="left"></p>
<p >GetWeatherInfo</p>
</td>
<td>
<p align="left"></p>
<p >WInfoProcess</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >Assign</p>
</td>
<td>
<p align="left"></p>
<p >AssignIP</p>
</td>
<td>
<p align="left"></p>
<p >&#8212;-</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >Invoke</p>
</td>
<td>
<p align="left"></p>
<p >InvokeToResolveIP</p>
</td>
<td>
<p align="left"></p>
<p >Positioning</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >Assign</p>
</td>
<td>
<p align="left"></p>
<p >AssignCityAndCountry</p>
</td>
<td>
<p align="left"></p>
<p >&#8212;-</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >Flow (Structured Activity)</p>
</td>
<td>
<p align="left"></p>
<p >LogAndGetWeather</p>
</td>
<td>
<p align="left"></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >Invoke (Inside Flow)</p>
</td>
<td>
<p align="left"></p>
<p >GetWeather</p>
</td>
<td>
<p align="left"></p>
<p >Weather</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >Invoke (Inside Flow)</p>
</td>
<td>
<p align="left"></p>
<p >LogInformation</p>
</td>
<td>
<p align="left"></p>
<p >Logger</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >Assign</p>
</td>
<td>
<p align="left"></p>
<p >AssignWeather</p>
</td>
<td>
<p align="left"></p>
<p >&#8212;-</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >Reply</p>
</td>
<td>
<p align="left"></p>
<p >ReplyTheInfoToCaller</p>
</td>
<td>
<p align="left"></p>
<p >WInfoProcess</p>
</td>
</tr>
</table>
<p >Now we need to add variables and variables assignment and our work with the process and the process designer is finished. In this step we will create all variables and then we will move toward assigning these variables to each other. To create the variables:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li> </li>
<p  style=" -qt-block-indent:1;">Double click on GetWeatherInfo and for the input variable click create, accept the defaults and click OK buttons as much as required to see the designer window again.</p>
<li> </li>
<p  style=" -qt-block-indent:1;">Double click on InvokeToResolveIP and create both output and input variable the same way that you create the variable for the GetWeatherInfo.</p>
<li> </li>
<p  style=" -qt-block-indent:1;">Double click on GetWeather and make sure that you select GetWeather as the operation and create the input and output variables similar to previous steps.</p>
<li> </li>
<p  style=" -qt-block-indent:1;">Double click on LogInformation and create input and output variables, accept defaults for variable names and other attributes.</p>
<li> </li>
</ul>
<p  style=" -qt-block-indent:1;">Finally double click on the reply button and for the normal response create a variable and accept the defaults for its name and other attributes.</p>
<p >Now we should be able to assign the variables to each other to make the data flow possible in the process. Thankfully NetBeans come with a very nice and easy to use Assign variable editor called Mapper which we can use to assign the variables to each other. Double click on the AssignIP element and use the following procedure to assign the received IP in the previous step to input variable of InvokeToResolveIP. </p>
<p >In the left side of the Mapper window select output button to ensure that it is filtered for output variables and in the right side select input button to ensure that we are looking at input variables.</p>
<p >Expand the WInfoProcessOperationIn from the left side and expand ResolveIPIn from the right side, make sure that you expand them as much as it does not expand anymore. Now from the left side select IPAddress and connect it to ipAddress in the right side. From the Mapper top menu bar select String and add a String Literal to the middle section of the Mapper window. Change its value to 0 and connect it to licenseKey variable in the right side. Now we are finished with the first assign element. Now switch to the designer view to finish the mapping for AssignCityAndCountry element.</p>
<p >Double click on the AssignCityAndCountry element and assign the variables as follow:</p>
<p >Let’s assign the city name and country name to the GetWeather invoke element. To do so, from the left side expand ResolveIPOut and from the right side expand GetWeatherIn. From the left side, assign city and country parameters of the ResolveIPOut to similar parameters of the GetWeatherIn in the right side. Now we need to assign the same information to our database log operation therefore, expand the Log_operationIn and assign the city and country from the left side to its parameters. We have an rDate parameter which we should use a Current Date &amp; Time predicate. So, from the top menu bar select Date And Time and drop a Current Date &amp; Time predicate into the middle section of the Mapper window. Connect the new predicate to rDate variable of the Log_OperationIn. We are finished with the second variable assignment and one last item remains which we should complete. Figure 6 shows the Mapper window after assigning all variables.</p>
<p> <img src="http://dl.dropbox.com/u/334201/jn-blog-files/figure17.7.png" /></p>
<p>Figure 7 Mapper window with complete AssignCityAndCountry assignment</p>
<p >One more variable assignment and we are finished with the BPEL process development. Double click on AssignWeather element and assign the output of GetWeatherOut parameter to WInfoProcessOperationOut parameter. Ok, the name looks unlikely and you may thing that it is an output variable but believe me it is an input variable.</p>
<p><strong><em>3.2 Creating the Composite Application project</em></strong></p>
<p >A composite application is the project type that we can use to deploy a composite application into the JBI container. Select File&gt;New Project; from the categories select SOA and from Projects select Composite application and click next. Change the project name to WinfoCA and click finish. The composite application is created and is ready for adding JBI modules.</p>
<p >Right click on the project node and select Add JBI Module, select WeatherInfo project. The CASA editor opens which shows the BEPL module without any relation. Right click on WinfoCA project node and select Clean and Build. NetBeans will compile the composite application and its included JBI modules. When we issue a build command NetBeans refresh the CASA editor and we can add new module, change a data flow between components and so on.</p>
<p><strong><em>3.4 Deploying and testing sample project</em></strong></p>
<p >Deploying and testing a composite application is very easy using the well integrated Netbeans, GlassFish and OpenESB. To deploy the application, right click on the WinfoCA node and select deploy. NetBeans will deploy the assembly to OpneESB runtime. To create a test case for the composite application, expand the WinfoCA node and right click on Test node. A wizard will start that help us generate the test case.</p>
<p >In the first page, wizard asks for the test case name, it can be WinfoTest at the second step it asks us to choose which WSDL file we want to test. Expand the WeatherInfo node and select winfoprocess.wsdl press next. Now we should select which operation we want to test, select winfProrocessOperation and click finish. Now we have a test case created, expand the test case in project view and double click on input node to edit the test case input values. Double clicking the input node results in opening an XML file in the editor. The XML file is a SOAP message which we should change its parameters value to suite our test requirement. Therefore change the value of IPAddress element to 209.85.171.100 which is one the Google IP addresses. Save the file and we are finished with creating the test case.</p>
<p >Right click on WinfoTest and select run. IDE will invoke the operation defined in the WSDL file by passing the SOAP message we created to it. Then the output result will appear under the output node of the test case. The output should be information about current weather in Mountain View in the United States.</p>
<p >You can debug a BPEL process and generally a JBI application using NetBeans. The IDE allows you to view the variables during different steps of BPEL execution. The simplest way that we can use to debug the BPEL module is adding our required breakpoint and then executing the test using debug mode. </p>
<p><strong><em>3.5 OpenESB administration from within NetBeans IDE</em></strong></p>
<p >NetBeans IDE is very well integrated with OpenESB for not only for developing and testing applications but also for administration and monitoring purposes. All of these functionalities are hidden inside the NetBeans integration adapter for OpenESB.</p>
<p >Press CTRL+5 to open the servers tab and then expand the servers node, expand the OpenESB server instance and finally expand JBI node. Now your server view should be similar to figure 8. Now press CTRL+SHIFT+7 to open the Properties window and then select JBI node. It is wonderful that you can change configuration of the JBI container from within the IDE to continue your work without leaving the IDE and switching between different windows.</p>
<p> <img src="http://dl.dropbox.com/u/334201/jn-blog-files/figure17.8.png" /></p>
<p>Figure 8 The OpenESB node in NetBeans Server view</p>
<p >Expand the Service Engines node and select sun-bpel-engine node, the Properties view shows you the entire configuration and read only attributes of the BPEL engine. You can enable the monitoring by checking the checkbox or you can enable the persisting feature to have your BPEL process recovered after any possible crash.</p>
<p >Right click on the sun-bpel-engine node and explore what operations you can perform on the engine from context menu. We can start, stop, upgrade, uninstall and perform any other lifecycle related task using the context menu. We can view the different endpoints used in BPEL process deployed in the BPEL engine using the Show Endpoints Statistics menu item. This menu item helps us to understand whether our services are called during our test period or not and if they are called what was the response semantic and quality.</p>
<p><strong><em>4 OpenESB administration</em></strong></p>
<p >The same administration channels which we saw for GlassFish are available for OpenESB and GlassFish ESB. OpenESB CLI commands are integrated with GlassFish CLI utility and follow the same principals. And the Web Based administration console uses GlassFish administration console to present required administration capabilities.</p>
<p><strong><em>4.1 The CLI utility</em></strong></p>
<p >OpenESB CLI administration is completely integrated with GlassFish administration and has the same set of characteristics. The only major difference is lack of some commands as GlassFish ESB version 2 is based on GlassFish version 2 and any new functionality that is included in GlassFish version 3 is not present in version 2.</p>
<p><strong>Service assembly administration commands</strong></p>
<p >JBI container like Java EE container has its own application type which is called a JBI service assembly or simply an assembly. Usually the overall procedure of creating and deploying an assembly is done using build systems or IDE but there some commands in the OpenESB CLI which let us administrate the assemblies. All of the OpenESB CLI commands are remote with all characteristics of a remote command like default target server, and so on.</p>
<p >Deploying and undeploying a service assembly are two most basic tasks related to OpenESB administration. In the previous step we developed and deployed an application using NetBeans, now lets undeploy the application and then deploy it using the CLI commands.</p>
<p >To underply the application we can use undeploy-jbi-service-assembly command. For example to undeploy the WinfoCA composite application we can use:</p>
<p ><code>asadmin&gt; undeploy-jbi-service-assembly WinfoCA</code></p>
<p >Now we can deploy the application archive using the deploy-jbi-service-assembly command. NetBeans puts the built packages into a directory named dist inside the project directory. Let’s deploy the WinfoCA application from that particular directory. </p>
<p ><code>deploy-jbi-service-assembly /opt/article/WinfoCA/dist/WinfoCA.zip</code></p>
<p >This command deploy the application to the default target server with default attributes like application name and so on.</p>
<p >To list all deployed service assembly we can use list-jbi-service-assemblies command. Now that we have one application deployed into the container this command should show a list containing WinfoCA similar to:</p>
<p><code>asadmin&gt; list-jbi-service-assemblies</code></p>
<p><code>WinfoCA</code></p>
<p><code>Command list-jbi-service-assemblies executed successfully.</code></p>
<p >Each service assembely contains one or more service units which connect services, binding components, and service engines along with any deployment artifacts like XSLT documents, BPEL process and so on. To view these service units we can use show-jbi-service-assembly command. Figure 9 shows how we can use the command to view detailed information for WinfoCA composite application.</p>
<p><img src="http://dl.dropbox.com/u/334201/jn-blog-files/figure17.9.png" /></p>
<p>Figure 9 viewing the detailed information for an assembly </p>
<p >We can stop, start and forcefully shutdown a service assembly when required by using the OpenESB provided commands.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li> </li>
<p  style=" -qt-block-indent:1;">To stop the WinfoCA service assembly: stop-jbi-service-assembly WinfoCA</p>
<li> </li>
<p  style=" -qt-block-indent:1;">To start the WinfoCA service assembly if it is stopped: start-jbi-service-assembly WinfoCA</p>
<li> </li>
</ul>
<p  style=" -qt-block-indent:1;">To forcefully shutdown the WinfoCA service assembly if required: shut-down-jbi-service-assembly WinfoCA</p>
<p >There are more JBI service assembly commands in the OpenESB CLI which you can find them using ./asadmin help command.</p>
<p><strong>Components administration commands</strong></p>
<p >There two major types of JBI components including service engines and binding components which we may need to deal with. These two types are accompanied with another type named shared library which contains common library classes for several components. Table 6 shows important commands in this set along with an small explanation about each one of them.</p>
<p >Table 6 Important JBI components administration commands</p>
<table border="0" width="518" cellspacing="0" cellpadding="7">
<tr>
<td width="245">
<p align="left"></p>
<p align="left"><strong>Command </strong> </p>
</td>
<td width="245">
<p align="left"></p>
<p align="left"><strong>Explanation</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >start-jbi-component</p>
<p >stop-jbi-component</p>
</td>
<td>
<p align="left"></p>
<p align="left">These commands can be used to start and stop binding components. Stopping a binding component result in any related service unit to stop.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >list-jbi-binding-components</p>
<p >list-jbi-service-engines</p>
<p >list-jbi-shared-libraries</p>
</td>
<td>
<p align="left"></p>
<p align="left">Showing a list of deployed JBI components</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >show-jbi-service-engine</p>
<p >show-jbi-shared-library</p>
<p >show-jbi-binding-component</p>
</td>
<td>
<p align="left"></p>
<p align="left">Show detailed information about a given JBI component which is deployed in the target container.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >install-jbi-component</p>
<p >install-jbi-shared-library</p>
<p >install-jbi-service-engine</p>
</td>
<td>
<p align="left"></p>
<p align="left">Installing different JBI components into the target container.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >uninstall-jbi-component</p>
<p >uninstall-jbi-shared-library</p>
</td>
<td>
<p align="left"></p>
<p align="left">Uninstalling given JBI component from the target server.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p >shut-down-jbi-component</p>
<p >shut-down-jbi-service-assembly</p>
</td>
<td>
<p align="left"></p>
<p align="left">Shutdown the given component. Any deployed service unit on the target component will shutdown consequently</p>
</td>
</tr>
</table>
<p >Although there are many other command which an administrator may need during his daily tasks but we learned the most important commands in the section. In the next section we will take a look at web based administration console features for OpenESB.</p>
<p><strong><em>4.2 Administration console</em></strong></p>
<p >One good point about GlassFish and its companion product is the unified administration channels including CLI, JMX and web based administration console which let us use a unified look and feel and familiar environment to administrate all the infrastructure.</p>
<p >All of JBI administration capabilities are listed under the JBI node in the navigation tree. When you expand all nodes you can see something similar to figure 10. As you can see in figure 10 the JBI node also helps us have a big picture view of our service units’ deployment on different service engines and binding components.</p>
<p> <img src="http://dl.dropbox.com/u/334201/jn-blog-files/figure17.10.png" /></p>
<p>Figure 10 OpenESB administration node in the GlassFish administration console</p>
<p >The JBI node itself allows us to configure the container settings like Logging, general statistics, and general configuration related to JBI artifacts installation. Subsequent nodes let us administrate the deployed applications, binding components, service engines and shared libraries. </p>
<p><strong>Service assembly administration</strong></p>
<p >Administration console provides deploy, undeploy, start, stop and shutdown operations for service assemblies. We also can view monitoring information for a deployed service assembles.</p>
<p >For each service assembly we may have one or more service units, we can view service units included in a service assembly along with accessing some monitoring information about them. </p>
<p><strong>JBI components administration</strong></p>
<p >Installing, uninstalling, starting, stopping and shutting down a JBI component which can be either a service engine or a biding component provided in the Components node. Administration console provides us with capabilities which allow us to change the component configuration; its loggers logging level, viewing the descriptor file for the component, and most important thing viewing detailed monitoring information about requests and request processing by each component.</p>
<p >We can see view which service units from which service assemblies are deployed on a component and navigate to the service unit or service assembly configuration.</p>
<p><strong>JBI shared libraries administration</strong></p>
<p >For the shared libraries, we can install, uninstall and view the depended components on each shared libraries to ensure that uninstalling the library will not cause unexpected result in other components.</p>
<p><strong><em>4.3 Installing new components</em></strong></p>
<p >OpenESB project provides many components out of the box but there are tens of components available in the OpenESB website at <a href="https://open-esb.dev.java.net/Components.html">https://open-esb.dev.java.net/Components.html</a>. From this page we can navigate to each component WIKI page and download the required and install them into OpenESB and NetBeans. But another effort is undergo to let the developers to download one single installer for each component and let the installer install all required artifacts like shared libraries, runtime engines and design time NetBeans modules. Latest build of installers for all components are available at <a href="http://download.java.net/jbi/binaries/installers/single-component/v2/nightly/latest/">http://download.java.net/jbi/binaries/installers/single-component/v2/nightly/latest/</a>.</p>
<p >Installing the components using the installers available at the above page is very straight forward. the installer asks for NetBeans and OpenESB (GlassFish) directory and complete the installation. </p>
<p><strong><em>5 Summary</em></strong></p>
<p >In this article we discussed almost all basics of OpenESB administration and application development in a crush course mode. We saw how JBI and OpenESB are related, how OpenESB and GlassFish ESB are similar products with different naming. We developed a sample JBI service assembly which utilizing several binding components and service engines and finally we deployed the application into OpenESB and performed functional testing using NetBeans IDE.</p>
<p >We discussed how we can install and administrate OpenESB. We discussed CLI and administration console for managing OpenESB and we learned that OpenESB administration channels uses similar rules and look and feel that GlassFish administration and CLI uses.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/introducing-openesb-from-development-to-administration-and-management/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introducing NIO.2 (JSR 203) Part 1: What are new features?</title>
		<link>http://kalali.me/introducing-nio-2-jsr-203-part-1-what-are-new-features/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-nio-2-jsr-203-part-1-what-are-new-features</link>
		<comments>http://kalali.me/introducing-nio-2-jsr-203-part-1-what-are-new-features/#comments</comments>
		<pubDate>Thu, 20 May 2010 04:55:14 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Asynchronous I/O]]></category>
		<category><![CDATA[Attributes]]></category>
		<category><![CDATA[Multicasting]]></category>
		<category><![CDATA[NIO.2]]></category>
		<category><![CDATA[SPI]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=374</guid>
		<description><![CDATA[I will write a series of blog to discuss what are the new features introduced in NIO.2 (JSR 203). The NIO.2 implementation is a part of OpenJDK project and we can alreay use it by downloading a copy of OpenJDK binary.  In the first entry I will just go through what are these new I/O [...]]]></description>
			<content:encoded><![CDATA[<p>I will write a series of blog to discuss what are the new features introduced in NIO.2 (JSR 203). The <a href="http://openjdk.java.net/projects/nio/">NIO.2 implementation</a> is a part of <a href="http://openjdk.java.net/">OpenJDK</a> project and we can alreay use it by downloading a copy of OpenJDK <a href="http://download.java.net/jdk7/binaries/">binary</a>.  In the first entry I will just go through what are these new I/O features of Java 7, which help developer iron out better applications easier.</p>
<p>Talking about File systems support and features which let us  deal with file system we can name the following features:</p>
<p style="-qt-block-indent: 1;">
<ol>
<li><strong>Platform friendly-ness of NIO.2</strong>: We can deal with all file systems in a unified model.</li>
<li><strong>File tree walk:</strong> We can walk on a file tree and examine each node using the built-in APIs, NIO.2 to let us know whether the current member is a file, a directory or a symbolic link. We can then perform any operation we want on that node.</li>
<li><strong>File Operations (Copy, Delete, Move):</strong> Basic operations are supported with plethora of options. The move operation can be performed in atomic way.</li>
<li><strong>Symbolic links support:</strong> count soft and hard links as well as managing them.</li>
<li><strong>Support for file attributes in NIO.2:</strong> Managing file systems attributes is fully supported for different file systems including DOS, POSIX&#8230;</li>
<li><strong>File system change notification:</strong> We can setup a watch service and receive notification when a change happens on the path we are watching.</li>
<li><strong>SPI for providing new file systems support,</strong> for example to support zip, zfs, btrfs, we can implement the provider interfaces and use the unified API to access that specific file system using our implementation</li>
</ol>
<p>Working with sockets and reding/ writing files we can name the following features:</p>
<p style="-qt-block-indent: 1;">
<ol>
<li><strong>Multicasting is now supported</strong> in the DatagramChannel meaning that we can send and receive IP datagrams from a complete group. Both IPv4 and IPv6 are supported.</li>
<li><strong>Asynchronous I/O for sockets and Files</strong>: Now we can have Asynchronous read and write both on channles and files. It basically means we can have event driven I/O over both networks and files.</li>
</ol>
<p>Other improvement, features:</p>
<p style="-qt-block-indent: 1;">
<ol>
<li>Support for very large multi gigabyte buffers</li>
<li>Some MXBeans are included to monitor IO specific buffers.</li>
<li>Interoperability between Java 7 IO and previous versions using the Path API.</li>
</ol>
<p>I will post sample codes for each of these features in upcomming entries. So stay tuned if you want to learn more about NIO.2</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/introducing-nio-2-jsr-203-part-1-what-are-new-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GlassFish Security book FAQ 1: Custom Security Realm in GlassFish</title>
		<link>http://kalali.me/glassfish-security-book-faq-1-custom-security-realm-in-glassfish/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=glassfish-security-book-faq-1-custom-security-realm-in-glassfish</link>
		<comments>http://kalali.me/glassfish-security-book-faq-1-custom-security-realm-in-glassfish/#comments</comments>
		<pubDate>Tue, 18 May 2010 14:36:49 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[GlassFish Security]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[Certificate Realm]]></category>
		<category><![CDATA[Custom Realm]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=372</guid>
		<description><![CDATA[I decided to write down the answer for some questions which my book&#8217;s readers email me or ask me via twitter in my weblog so everyone can benefit from the answers. Here is the answer to the first question which involves custom security realms. GlassFish supports 5 types of security realms out of the box [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to write down the answer for some questions which my book&#8217;s readers email me or ask me via twitter in my weblog so everyone can benefit from the answers. Here is the answer to the first question which involves custom security realms.</p>
<p><a href="http://www.glassfish.org"><strong>GlassFish</strong></a> supports 5 types of security realms out of the box which are sd follow:</p>
<p style="-qt-block-indent: 1;">
<ol>
<li><strong>File Realm:</strong> Usefull for development and testing purposes. GlassFish provids a user/ group management interface for this realm. We can add user and groups using the administration console. When using this realm all usernames, passwords and groups are stored in a plain text file.</li>
<li><strong>JDBC Realm:</strong> In production environment we store user information including but not limited to username, passwords and groups in an RDBMS and then configure a JDBC realm to authenticate the given credentials againts the information stored in the datase.</li>
<li><strong>LDAP Realm:</strong> Sometimes we have all user details stored in an LDAP like Active Directory or Redhat Directory Server, OpenDS or Sun Java System Directory Server Enterprise Edition.</li>
<li><strong>Solaris Realm:</strong> This realm is used to authenticate users with a Solaris user directory.</li>
<li><strong>Certificate Realm: </strong>The certificate realm allows us to conduct mutual SSL authentication based on the client certificates.</li>
</ol>
<p>Sometimes our users information is stored in a silo different than all of this mentioned storages and we need to use that source for authentication and access control. For example assume that we have our users information including username, passwords and group membership stored in an Object Database and we need to authenticate our enterprise application&#8217;s users with that storage. In such times we should either think about having a synchronized RDMBS keeping update user information and use JDBC realm for authentication and authorization or we should develop  a custom security realm which uses the object database as a source for authentication.</p>
<p>Setting up synchronization between the e.g object database and RDBS can be tricky while developing a custom authentication realm is much easier using GlassFish provided SPIs.</p>
<p>Second chapter of <a href="http://www.packtpub.com/codeigniter-1-7-professional-development/book/mid/070510qymd89?utm_source=adamgriffiths.co.uk&amp;utm_medium=affiliate&amp;utm_content=authorsite&amp;utm_campaign=mdb_003261">GlassFish security book</a> discusses GlassFish security realms in details and discuss a sample application which uses these realms for authenticating and authorizing users. In the same chapter, developing custom security realms is discussed along with developing a sample realm.</p>
<p>In the same chapter GlassFish support for  <a href="http://jcp.org/en/jsr/detail?id=196">JSR-196</a> (Java Authentication Service Provider Interface for Containers) is discussed to complete the ring of authentication and authorization in Java EE in general and GlassFish application server in particular.</p>
<p><a href="http://www.packtpub.com/glassfish-security-with-java-ee/book/mid/180510gq2lyz?utm_source=java.net&amp;utm_medium=affiliate&amp;utm_content=blog&amp;utm_campaign=mdb_003525"><img src="https://www.packtpub.com//sites/default/files/9386_MockupCover.jpg" alt="" width="480" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/glassfish-security-book-faq-1-custom-security-realm-in-glassfish/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java EE Security Refcard is now available for download at no cost.</title>
		<link>http://kalali.me/java-ee-security-refcard-is-now-available-for-download-at-no-cost/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=java-ee-security-refcard-is-now-available-for-download-at-no-cost</link>
		<comments>http://kalali.me/java-ee-security-refcard-is-now-available-for-download-at-no-cost/#comments</comments>
		<pubDate>Mon, 17 May 2010 10:38:29 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[GlassFish Security]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[Geronimo]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=370</guid>
		<description><![CDATA[Java EE Security refcard is available for download. This refcard covers Java EE 6 security and discuss how each application server supports the specs. The refcard covers authentication, authorization, and transport security in Web Application, EJB application and web services by introducing the concept and the related annotations and deployment descriptors which help us realize [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://refcardz.dzone.com/refcardz/getting-started-java-ee">Java EE Security refcard</a> is available for download. This refcard covers Java EE 6 security and discuss how each application server supports the specs. The refcard covers authentication, authorization, and transport security in Web Application, EJB application and web services by introducing the concept and the related annotations and deployment descriptors which help us realize the concept.</p>
<p><a href="http://www.glassfish.org">GlassFish</a>, <a href="http://geronimo.apache.org/">Geronimo</a> and <a href="http://www.jboss.org/">JBoss</a> are discussed in the refcard to show how we can use the vendor specific deployent descriptors for implementing the security design of our applications.</p>
<p>Following list shows how what are covered in this.</p>
<p style="-qt-block-indent: 1;">
<ul>
<li>Security in Java EE applications</li>
<li>Authentication an Authorization in Java EE</li>
<li>Web Applications Security
<ul type="circle">
<li>Authentication and Authorization in Web Module</li>
<li>Enforcing Transport Security</li>
<li>Other Security Elements of Web application deployment descriptors</li>
<li>Using Annotations to enforce security in Web modules</li>
<li>Programmatic Security in Web Module</li>
</ul>
</li>
<p style="-qt-block-indent: 2;">
<li>EJB Applications Security
<ul type="circle">
<li>EJB module deployment descriptors</li>
<li>Security Annotation of EJB modules in Java EE 6</li>
<li>Securing EJB Modules programmatically</li>
</ul>
</li>
<p style="-qt-block-indent: 2;">
<li>Application Client Security
<ul type="circle">
<li>Security enforcement in Geronimo ACC</li>
<li>Security enforcement in JBoss ACC</li>
</ul>
</li>
<p style="-qt-block-indent: 2;">
<li>Defining Security in Enterprise application level</li>
<li>Securing Web Services in Java EE</li>
</ul>
<p style="-qt-block-indent: 2;">
<ul type="circle">
<li>Web Services Security in Web Modules</li>
<li>Web Services Security in EJB Modules</li>
<li>Web Services Authentication in GlassFish</li>
<li>Web Services Authentication in Geronimo</li>
<li>Web Services Authentication in JBoss</li>
</ul>
<p>The refcard comes with 4 figures showing relation between different element and components in Java EE  along with 7 tables explaning the deployment descriptors elements and security annotations. For most of the above headings you will find sample code included in the refcard showing how we can do implement the discussed functionality according to Java EE and mentioned application Servers.</p>
<p><a href="http://refcardz.dzone.com/refcardz/getting-started-java-ee?oid=hom22841"><img src="http://www.java.net/sites/default/files/22841.png" alt="" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/java-ee-security-refcard-is-now-available-for-download-at-no-cost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GlassFish v3 and EJBCA 3.x a fair couple for mutual SSL authentication.</title>
		<link>http://kalali.me/glassfish-v3-and-ejbca-3-x-a-fair-couple-for-mutual-ssl-authentication/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=glassfish-v3-and-ejbca-3-x-a-fair-couple-for-mutual-ssl-authentication</link>
		<comments>http://kalali.me/glassfish-v3-and-ejbca-3-x-a-fair-couple-for-mutual-ssl-authentication/#comments</comments>
		<pubDate>Thu, 13 May 2010 15:22:48 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[GlassFish Security]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[EJBCA]]></category>
		<category><![CDATA[Mutual authentication]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=368</guid>
		<description><![CDATA[Please use the following articles while I am updating this entry How to have your Own CA and configure Glassfish and your clients for mutual authentication? How to have your Own CA and configure Glassfish and your clients for mutual authentication?, Part II Please post any comment or question here so we can have one [...]]]></description>
			<content:encoded><![CDATA[<p>Please use the following articles while I am updating this entry<strong> </strong></p>
<p style="-qt-block-indent: 1;">
<ol>
<li><a href="http://weblogs.java.net/blog/2007/08/16/how-have-your-own-ca-and-configure-glassfish-and-your-clients-mutual-authentication">How to have your Own CA and configure Glassfish and your clients for mutual authentication?</a></li>
<li><a href="http://weblogs.java.net/blog/2007/08/23/how-have-your-own-ca-and-configure-glassfish-and-your-clients-mutual-authentication-">How to have your Own CA and configure Glassfish and your clients for mutual authentication?, Part II</a><a href="http://weblogs.java.net/blog/2007/08/16/how-have-your-own-ca-and-configure-glassfish-and-your-clients-mutual-authentication"><br />
</a></li>
</ol>
<p>Please post any comment or question here so we can have one main reference for this.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/glassfish-v3-and-ejbca-3-x-a-fair-couple-for-mutual-ssl-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GlassFish Security Book Which Covers GlassFish v3 security, Java EE 6 security, and OpenSSO has just been published.</title>
		<link>http://kalali.me/glassfish-security-book-which-covers-glassfish-v3-security-java-ee-6-security-and-opensso-has-just-been-published/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=glassfish-security-book-which-covers-glassfish-v3-security-java-ee-6-security-and-opensso-has-just-been-published</link>
		<comments>http://kalali.me/glassfish-security-book-which-covers-glassfish-v3-security-java-ee-6-security-and-opensso-has-just-been-published/#comments</comments>
		<pubDate>Thu, 13 May 2010 15:12:56 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Book Review]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[GlassFish Security]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[EJB]]></category>
		<category><![CDATA[OpenDS]]></category>
		<category><![CDATA[OpenSSO]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SSO]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=366</guid>
		<description><![CDATA[The Book in Details: Security was, is, and will be one of the most important aspects of Enterprise Applications and one of the most challenging areas for architects, developers, and administrators. It is mandatory for Java EE application developers to secure their enterprise applications using Glassfish security features. Learn to secure Java EE artifacts (like [...]]]></description>
			<content:encoded><![CDATA[<p><strong>The Book in Details:</strong></p>
<p>Security was, is, and will be one of the most important aspects of Enterprise Applications and one of the most challenging areas for architects, developers, and administrators. It is mandatory for Java EE application developers to secure their enterprise applications using Glassfish security features.</p>
<p>Learn to secure Java EE artifacts (like Servlets and EJB methods), configure and use GlassFish JAAS modules, and establish environment and network security using this practical guide filled with examples. One of the things you will love about this book is that it covers the advantages of protecting application servers and web service providers using OpenSSO.</p>
<p>The book starts by introducing Java EE security in Web, EJB, and Application Client modules. Then it introduces the Security Realms provided in GlassFish, which developers and administrators can use to complete the authentication and authorization setup. In the next step, we develop a completely secure Java EE application with Web, EJB, and Application Client modules.</p>
<p>The next part includes a detailed and practical guide to setting up, configuring, and extending GlassFish security. This part covers everything an administrator needs to know about GlassFish security, starting from installation and operating environment security, listeners and password security, through policy enforcement, to auditing and developing new auditing modules.</p>
<p>Before starting the third major part of the book, we have a chapter on OpenDS discussing how to install, and administrate OpenDS. The chapter covers importing and exporting data, setting up replications, backup and recovery and finally developing LDAP based solutions using OpenDS and Java.</p>
<p>Finally the third part starts by introducing OpenSSO and continues with guiding you through OpenSSO features, installation, configuration and how you can use it to secure Java EE applications in general and web services in particular.</p>
<p>Inspired from real development cases, this practical guide shows you how to secure a GlassFish installation and how to develop applications with secure authentication based on GlassFish, Java EE, and OpenSSO capabilities.</p>
<p><strong>What you will learn from this book :</strong></p>
<p style="-qt-block-indent: 1;">
<ul>
<li>Develop secure Java EE applications including Web, EJB, and Application client modules.</li>
<li>Reuse the security assets you have by learning GlassFish security realms in great details along with the sample for each realm.</li>
<li>Secure GlassFish installation including operating system security and JVM policy configuration.</li>
<li>Secure Java EE applications using OpenSSO and set up Single Sign-On (SSO) between multiple applications.</li>
<li>Secure web services using Java EE built-in features, OpenSSO and WS-Security.</li>
<li>Secure network listeners and passwords using GlassFish provided facilities.</li>
<li>Learn using OpenSSO services, SDKs, and agents to secure Java EE enterprise applications including Web Services.</li>
<li>Learn using OpenDS both as administrator and as an LDAP solution developer.</li>
<li>All command lines and more than 90% of the book content applies for both GlassFish 3.x and 2.x.</li>
</ul>
<p><strong>Approach</strong></p>
<p>Security is driven by requirement and design and we implement security on the basis of the requirements provided by analysts. In this book, we take a programmatic approach to understand Java EE and GlassFish security.</p>
<p>You will find plenty of code samples in this book. It is easy to secure your application when you have a demonstration of a complete and working application explained in the book, isn&#8217;t it? Each chapter starts with the importance and relevance of the topic by introducing some Java EE applications requirement, which will encourage you to read it further.</p>
<p><strong>Who this book is written for</strong></p>
<p>This book is for application designers, developers and administrators who work with GlassFish and are keen to understand Java EE and GlassFish security.</p>
<p>To take full advantage of this book, you need to be familiar with Java EE and GlassFish application servers. You will love this book if you are looking for a book that covers Java EE security and using GlassFish features to create secure Java EE applications, or to secure the GlassFish installation and operating environment and using OpenSSO.</p>
<p><a href="http://www.packtpub.com/glassfish-security-with-java-ee/book/mid/180510gq2lyz?utm_source=java.net&amp;utm_medium=affiliate&amp;utm_content=blog&amp;utm_campaign=mdb_003525/"><img src="https://www.packtpub.com//sites/default/files/9386_MockupCover.jpg" alt="" width="800" height="1015" /></a> var gaJsHost</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/glassfish-security-book-which-covers-glassfish-v3-security-java-ee-6-security-and-opensso-has-just-been-published/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning GlassFish v3 Command Line Administration Interface (CLI)</title>
		<link>http://kalali.me/learning-glassfish-v3-command-line-administration-interface-cli/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=learning-glassfish-v3-command-line-administration-interface-cli</link>
		<comments>http://kalali.me/learning-glassfish-v3-command-line-administration-interface-cli/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 04:47:24 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[GlassFish v3]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=364</guid>
		<description><![CDATA[Learning GlassFish v3 Command Line Administration Interface (CLI) Terminals and consoles was one of the earliest types of communication interfaces between a system administrator and the system administration layer. Due to this long time presence,  command line administration consoles become one the most utilized administration channel for configuring different software ranging from database engines to [...]]]></description>
			<content:encoded><![CDATA[<h2><em>Learning GlassFish v3 Command Line Administration Interface (CLI)</em></h2>
<p>Terminals and consoles was one of the earliest types of communication interfaces between a system administrator and the system administration layer. Due to this long time presence,  command line administration consoles become one the most utilized administration channel for configuring different software ranging from database engines to router’s embedded operating systems.</p>
<p>GlassFish provides several administration channels; one of them is the command line administration interface or CLI from now on.  The CLI has many unique features which make it very convenient for command line advocates and new administrators which like to get familiar with CLI and use it in the daily basis.  The CLI allows us to manage, administrate, and monitor any resources which application server exposes to the administrators. So we can perform all of our administration tasks just by firing up a terminal, navigating to glassfish bin directory and executing the asadmin script which is either a shell script in UNIX based operating systems or a batch file in Windows operating system.</p>
<p>The CLI has some degree of embedded intelligence which helps us to simply find the correct spelling and similar commands to the command or phrase that we try. Therefore with basic knowledge of GlassFish application server administration we can find out the command that we need and proceed with the task list which we have in front.</p>
<p><strong><em>1 The CLI environment</em></strong></p>
<p>CLI is an administration interface which let administrators and developers to change configurations like changing a listener port; performing life cycle related tasks like deploying a Web application, or creating a new domain; monitoring different aspects of the application server; and finally performing maintenance duties like creating backup from the domain configuration, preparing maintenance reports and so on.</p>
<p>Door to the CLI interface is a script which is place in glassfish_home/bin directory. For Linux and UNIX platforms it is a shell script named asadmin and for the Windows platform it is a batch file named asadmin.bat. So, before we start doing anything with the CLI interface we need to either have glassfish_home/bin in the system path or we should be in the same directory which the script resides.</p>
<p><strong> </strong></p>
<p><strong>Add glassfish_home/bin to operating system path</strong></p>
<p>We can add glassfish_home/bin to windows operating system path by using the following procedure. You should have the glassfish_home variable already defined, if not you can replace %glassfish_home% with the full path to glassfish installation directory.</p>
<p style="-qt-block-indent: 1;">
<ul type="square">
<li>Right click on My Computer icon and select properties item</li>
<li>Select advanced tab in the from the tab set</li>
<li>Click on environment variables button, you will see two set of variables one for user and one for the system. I suggest you choose the user space to add your variable or update the currently defined variable.</li>
<li>If you can not find path in the list of variables, create a new variable named path and sets its value to %glassfish_home%/bin. If the variable is present then add ;glassfish_home/bin to the end of the variable’s value.</li>
</ul>
<p>Close all cmd windows and open a new one to have the new path applied</p>
<p>And for UNIX and Linux machines, we can add it to operating system path by using the following procedure. Replace &#8220;${glassfish_home}&#8221; with the full installation of Glassfish.</p>
<p>Open a text editor like ktext, gedit or any editor which you are familiar with</p>
<p>Open ~/.bashrc file using the file menu</p>
<p>At the end of the file (last line) add export PATH=&#8221;${glassfish_home}&#8221;/bin:&#8221;${PATH}&#8221;</p>
<p>Close all terminals and fire up a new terminal console to have the effects applied</p>
<p><strong>Info</strong></p>
<p>We can execute the asadmin.bat in windows by calling asadmin.bat or asadmin in a cmd windows. We should be either in the bin directory or we should have the script in path.</p>
<p>For Linux and UNIX, if we have the script in path we can call asadmin in a terminal window, if we do not have it in the path then we should be in the bin directory and execute it by typing ./asadmin in the terminal window.</p>
<p><strong>Info</strong></p>
<p>In this article I will use an operating system natural syntax, for example I will use asadmin version which can be interpreted as asadmin.bat version  in windows or ./asadmin version in UNIX or the asadmin version itself when we have asadmin in our path.</p>
<p><strong><em>2 Getting started with CLI</em></strong></p>
<p><strong><em>2.1 The commands format</em></strong></p>
<p>The asadmin script is the door to GlassFish command line interface and all of its commands follow a de-facto naming convention and a standard format which we need to remember. All command names are self explaining and we can understand the command purpose from the command name. All of the asadmin commands use one or multiple words as the command name to completely explain the command purpose. These words which form the command name are separated using a dash (-).</p>
<p>The naming convention also provides another learning point about the asadmin commands. Commands are categorized into lifecycle management commands, configuration commands, listing commands and monitoring commands. Each command starts with a verb which determines the command nature, for example: create, delete, update, list, and configure are the starting words for many of asadmin commands.  The command syntax is shown in the following snippet.</p>
<p><code>command-name options operands</code></p>
<p>The command-name can be start-domain, stop-domain, and so on. The options are parameters which affects the command execution, for example the domain instance port. the JDBC connection pool data source class name and so on.  The operand are usually name of the resources which the command may affect, like name of the connection pool that we want to create, name of the domain which we want to start and so on.</p>
<p><strong><em>2.2 The asadmin operating modes</em></strong></p>
<p>The asadmin utility which we use to execute our administrative commands operates in two modes. Each mode is suitable for specific set of tasks and has its own characteristics when it comes to performance and productivity.</p>
<p><strong>Headless operating mode</strong></p>
<p>In the headless mode which is very suitable for writing scripts  we call the asadmin  utility and pass the command name along with its options and operands. The asadmin utility launches a JVM and execute the command. The result of the command will be either 0 as failure or 1 as a success. An example of this mode is similar to the following script:</p>
<p>asadmin version</p>
<p>This will simply execute the version command which shows the application server version. To get help for a command in this mode we can use asadmin help version or we can use asadmin version &#8211;help.</p>
<p><strong>Multimodes operating mode</strong></p>
<p>This operating mode let use execute multiple commands in one JVM instance, therefore it is faster for executing commands. This execution mode is not suitable for script developers as we should execute the commands in asadmin environment and not in the shell command line.</p>
<p>To execute a command in this mode we should enter the asadmin environment and then enter our commands along with options and operands. For example:</p>
<p><code>asadmin  A</code></p>
<p><code>asadmin&gt; version --help B</code></p>
<p><strong>A: Hit enter</strong></p>
<p><strong>B: Command name with parameters</strong></p>
<p>The asadmin utility is an operating system native shell script which wrap around the actual Java application responsible for executing the administration commands which we issue. Later on we will see how this script can fall useful for administrating some domains from a system which is behind a proxy.</p>
<p><strong><em>2.3 Local commands</em></strong></p>
<p>Two sets of commands are present in asadmin which help administrators perform variety of tasks. Local commands are a set of commands which either affects the environment which application server is running or it needs accessing the application server environment locally to execute some scripts or batch files to perform a job.</p>
<p>A good example of local commands is domain lifecycle management commands which include creating a new domain, deleting a currently available domain, or starting a domain. All of these commands need to either access the application server installation directory layout or need to run a script on the target machine to perform the task.</p>
<p>Another place which we can discuss the local commands is the Java DB copy included with the GlassFish application server installation bundle. The following command start the database on the local machine. The command starts the database by creating another Java process directly by using the operating system shell.</p>
<p><code>asadmin start-database</code></p>
<p>You may wonder why this command has not options or operands. Generally all GlassFish administration commands need the minimum possible options and operands to perform the task when we use default setting and configuration.</p>
<p>Each command has its own set of parameters but most of the asadmin commands, either local or remote, have some shared parameters which are listed in table 1. Command’s parameters can have a default value which will be used if we do not specify it. The default value for each parameter is underlined.</p>
<p>Table 1 List of shared parameters between local and remote commands</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<p><strong>Parameter</strong></td>
<td>
<p><strong>Acceptable values</strong></td>
<td>
<p><strong>Description</strong></td>
</tr>
<tr>
<td>
<p>&#8211;terse or –t</td>
<td>
<p><span style="text-decoration: underline;">false</span>, true</td>
<td>
<p>Indicates that any output data  must  be  very  concise</td>
</tr>
<tr>
<td>
<p>&#8211;echo, -e</td>
<td>
<p>true, <span style="text-decoration: underline;">false</span></td>
<td>
<p>If set to true, the command-line statement is echoed on the standard output.</td>
</tr>
<tr>
<td>
<p>&#8211;interactive, -I</td>
<td>
<p><span style="text-decoration: underline;">true</span>, false</td>
<td>
<p>If set to true, only the required password options are prompted.</td>
</tr>
<tr>
<td>
<p>&#8211;passwordfile</td>
<td>
<p>Path to the password file</td>
<td>
<p>We will discuss it in section 5 of this article</td>
</tr>
<tr>
<td>
<p>&#8211;user, -u</td>
<td>
<p>No default value</td>
<td>
<p>A user with administrative privilege on target domain.</td>
</tr>
</tbody>
</table>
<p>These parameters have no effect on the command execution but they just change the way that the command shows us the information and how we interact with the commands.</p>
<p><strong><em>2.4 Remote commands</em></strong></p>
<p>In the Opposite side of the local commands we have remote commands which form a set of commands that affects the running application server instance configuration and access the application server environment and file system using an application deployed in the application server itself. Therefore the target instance should be running and there should be a network route between the administration workstation and the GlassFish instance running on the server machine.</p>
<p>When we execute a remote command we should let the asadmin know where the target application server instance is running and what the instance administration port is.  The asadmin uses this information along with the authentication information to communicate with the application server over HTTP or HTTPs using a REST like URL pattern for commands and parameters. Figure 1 demonstrates the remote and local commands.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_471gvc9wqzh_b" alt="" width="504" height="227" /></p>
<p>Figure 1 The asadmin utility communication with remote and local GlassFish domain and installation</p>
<p>In figure 1 you can see that in the running GlassFish instance there is an application deployed under /__asadmin/ context and listens for incoming asadmin commands. This application is listening on admin listener which is by default uses port number 4848.</p>
<p>Listing 1 shows a sample command content when it is heading toward the application server. It should have already flashed a light in your head about the RESTful Web services development articles or books that you have already read.</p>
<p><strong>Listing 1 content of HTTP request for version command</strong></p>
<p><code>GET /__asadmin/version HTTP/1.1</code></p>
<p><code>Content-type: application/octet-stream</code></p>
<p><code>Connection: Keep-Alive</code></p>
<p><code>Authorization: Basic YWRtaW46YWRtaW5hZG1pbg==</code></p>
<p><code>User-Agent: hk2-agent     #A </code></p>
<p><code>Cache-Control: no-cache</code></p>
<p><code>Pragma: no-cache</code></p>
<p><code>Host: localhost:4848</code></p>
<p><code>Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2</code></p>
<p><strong>#A The asadmin’s agent name</strong></p>
<p>Listing 2 shows the response generated by application server for version command. As you can see, the response is plain and simple.</p>
<p><strong>Listing 2 response generated by application server for version command</strong></p>
<p><code>HTTP/1.1 200 OK</code></p>
<p><code>Content-Type: text/html</code></p>
<p><code>Transfer-Encoding: chunked</code></p>
<p><code>Date: Mon, 12 Jan 2009 19:26:01 GMT</code></p>
<p><code>Signature-Version: 1.0</code></p>
<p><code>message: GlassFish v3 Prelude (build b28c)</code></p>
<p><code>exit-code: SUCCESS </code> #A</p>
<p><strong> </strong></p>
<p>If you are thinking that trying URLs in your browser will result in some output, you are completely right. For example if you try browsing <a href="http://127.0.0.1:4848/__asadmin/uptime"><span style="font-family: 'Verdana';">http://127.0.0.1:4848/__asadmin/uptime</span></a> you will get a result page similar to figure 2.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_472cxz8pvf9_b" alt="" width="503" height="97" /></p>
<p>Figure 2 Using browsers to run asadmin commands and view the result in browser</p>
<p>Now you may have some questions about how a command can generate an HTML oriented output in the browser while it can generates a plain text output when we use asadmin to execute the same command. The answer can be found in the way that browser identifies itself and asadmin utility identifies. The asadmin utility uses hk2-agent as the agent name and asadmin web application respond to this types of agent with a plain text response while it provides a full readable html for other agent types.</p>
<p>The only time that we feel difference between these two sets of commands is when we try to execute a local command on a remote machine.  For example creating a domain on a remote machine is not possible unless we have a node agent installed on that machine and we are using DAS to control that machine.</p>
<p>A good example of remote commands is application deployment command. We can deploy an application archive like an EAR or WAR file using asadmin. The deployment command will upload the file to the server and server takes care of the deployment. Following command will deploy the gia.war to the default glassfish instance.</p>
<p>asadmin deploy gia.war</p>
<p>The deploy commands has several parameters, we will discuss these parameters in details in subsequent sections. You may have already asked yourself how we identify which domain we want to execute a command against. Your answer is behind some shared parameters between all remote commands to distinguish the target domain which the command affects. These parameters are listed in table 2 along with the description and default values.</p>
<p>Table 2 List of all shared parameters between remote commands</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<p><strong>Parameter</strong></td>
<td>
<p><strong>Default values</strong></td>
<td>
<p><strong>Description</strong></td>
</tr>
<tr>
<td>
<p>&#8211;host, -H</td>
<td>
<p>localhost</td>
<td>
<p>when no value is determine for this parameter, the asadmin utility will try to communicate with localhost</td>
</tr>
<tr>
<td>
<p>&#8211;port, -p</td>
<td>
<p>4848</td>
<td>
<p>when no value is determine for this parameter, the asadmin utility will try to communicate with the determined host on port 4848</td>
</tr>
<tr>
<td>
<p>&#8211;secure, -s</td>
<td>
<p>false</td>
<td>
<p>If we have our asadmin application on a secure listener then we will use this parameter to prevent any security breach.</td>
</tr>
</tbody>
</table>
<p>All of these default parameters value’s assumption allows us to have more compact, easy to write and understand commands. Based on the connate of this table we can say that the sample deploy command will deploy the application into a domain running on localhost with port 4848 assigned to its admin listener.</p>
<p><strong><em>3 Performing common tasks with CLI</em></strong></p>
<p>Application server administration is composed of some common tasks which deal with common concepts of Java EE application servers like domain administration, application lifecycle administration, and managed resources administration. Along with these common tasks there are many other tasks which might be common between application servers or not. These tasks includes listeners administration, resource adapter administration, application server security administration which includes both application server security and Java EE related security definitions, virtual servers administration, monitoring and so on. In this section we will discuss the common administration tasks.</p>
<p><strong><em>3.1 Domain lifecycle administration</em></strong></p>
<p>Domains are foundation of GlassFish application server instances; each domain is an independent instance of application server which uses the same application server installation and hardware resources. Domain lifecycle administration covers creating, starting, stopping, configuration backup, deleting the domain, and domain configuration recovery using previously created backups.</p>
<p><strong>Creating a new domain</strong></p>
<p>Creating a new domain is fairly simple when you know what attributes distinguishes one domain from another. A sample command which creates a domain is as follow:</p>
<p><code>create-domain --user admin --adminport 4747  --domaindir /opt/dev/apps/domains/GiADomain --profile developer --instanceport 8282 --domainproperties jms.port=8687 --savemasterpassword=true --passwordfile=/opt/dev/apps/passfile.txt  --savelogin=true GiADomain</code></p>
<p>This is a sample of create-domain command with most of the applicable parameters. We are using &#8211;adminport to determine the admin port, &#8211;domaindir let us create the domain in none default path like what we used instead of glassfish_home/domains which is the default directory. The &#8211;instanceport let us determine the port that default application listener uses. Some of the domain properties like JMS port, JMX port and so on can be determined using the &#8211;domainproperties parameter. All parameters are self describing except for following three parameters which you need to understand them thoroughly.</p>
<p style="-qt-block-indent: 1;">
<ul type="square">
<li>The &#8211;savemasterpassword parameter: Setting this option to true asks the domain creating process to save the master password into a file and facilitate the unattended (headless) domain startup. We will discuss this password in more details in section 4 of this article. For now just remember that default value for master password is changeit. I am sure that value of the password is talking for the importance of changing it.</li>
<li> The &#8211;passwordfile parameter: The asadmin utility policy encourages the administrators not to enter the password in the console and instead use a file which includes the required password. During the domain Creating two passwords are required which are domain administration password and master password. To avoid typing the passwords we can store them in a plain text file similar to the following snippet and pass it to any command that we execute instead of typing the passwords in an interactive way.</li>
</ul>
<p><code>AS_ADMIN_PASSWORD=adminadmin</code></p>
<p><code>AS_ADMIN_MASTERPASSWORD=changeit</code></p>
<p>The file content is in properties file format and can be created using any text editor. If we do not use the &#8211;passwordfile parameter and a password file containing the passwords, the asadmin utility will asks for passwords interactively.</p>
<p style="-qt-block-indent: 1;">
<ul type="square">
<li>The &#8211;savelogin parameter: We will discuss automatic login with more details in section 4 of this article, but to be brief, this parameter make it possible to execute our commands on different domains without providing username and password on every command execution.</li>
</ul>
<p><strong>Starting and stopping a domain</strong></p>
<p>We can start a domain using the start-domain command. An example of starting a domain is similar to the following snippet.</p>
<p><code>start-domain --debug=true  --verbose=true --user admin --passwordfile=/opt/dev/apps/passfile.txt </code></p>
<p><code>--domaindir= /opt/dev/apps/domains/  GiADomain </code></p>
<p>Although the command can be as simple as start-domain domain1 but that is for occasions when we are using all of the default values for any parameter and no customization has happened during the time which we create the domain. The &#8211;debug=true means that domain is started in debug mode and we can attach our debugger to the running instance. The &#8211;verbose=true means that we want to see all messages that application server emits during the startup; it is useful to catch errors and troubleshoot. The &#8211;passwordfile parameter lift the need to enter the admin and master passwords. The file content is similar to password file we used during the domain creation. And finally we need to determine where the domain resides if we create the domain in a non-standard location.</p>
<p>To stop a domain we can use a command similar to the following snippet which is fairly simple.</p>
<p><code>stop-domain  --domaindir= /opt/dev/apps/domains/ GiADomain</code></p>
<p>We just need to provide the path to the directory which contains the domain. The only applicable shared parameters are the items that we used. None of the other shared parameters is applicable in this command.</p>
<p><strong>Domain utility commands</strong></p>
<p>There are two utility commands for domain administration. The first command lists all of the domains which reside in the given directory along with the domain status indicating whether the domain is running or not. And the second command checks the structure of domain.xml file.</p>
<p><code> list-domains --domaindir=/opt/dev/apps/domains/</code></p>
<p><code> verify-domain-xml  --verbose=true --domaindir= /opt/dev/apps/domains/  GiADomain</code></p>
<p>The verify-domain-xml is very useful when we edit the domain.xml file manually.</p>
<p><strong>Domain configuration backup and recovery</strong></p>
<p>Yes, we can backup a domain configuration and later on restore that backup if we messed up with the domain configuration. Each backup file is an archive which contains description files and vital domain configuration files including domain.xml. By default all backups are placed inside a directory named backups which resides inside the domain directory. The backup file names follow a pattern similar to sjsas_backup_v00001.zip which means that it is the first backup of this domain. To create a backup a command similar to the following snippet will do the trick.</p>
<p><code>backup-domain --description "backup made for glassfish in action book" --domaindir /opt/dev/apps/domains/ GiADomain</code></p>
<p>After some times we will have several backup archives for each of our domains, we will need a command to get a list of all available backups or backups related to one single domain. To get list of backups for a single domain we can use:</p>
<p><code>list-backups --domaindir /opt/dev/apps/domains/ GiADomain</code></p>
<p>Or to get a list of all backups of all domains in the default domains directory we can use list-backups command alone with no parameters.</p>
<p>Now that we can list the available backups for each domain we need command which allows us to restore a domain. To restore a domain to one of its previous backups we should stop the domain and then use the restore command which is similar to:</p>
<p><code>restore-domain --domaindir /opt/dev/apps/domains/ --filename sjsas_backup_v00001.zip GiADomain</code></p>
<p>The command will simply pick up the backup archive and restore the given domain using its content.</p>
<p><strong>Deleting a domain</strong></p>
<p>We should deal with this command very carefully as it will delete the domain directory with all of its content including backups, deployed applications, configuration files and so on. To delete a domain we can use delete-domain command as follow to delete our GiADomain domain.</p>
<p><code>delete-domaind --domaindir=/opt/dev/apps/domains/ GiADomain</code></p>
<p>Domain management is the most basic task related to application server administration. Every asadmin command including domain administration commands has manual pages included in the asadmin commands package and accessible using asadmin utility. An example of getting help for create-domain command is similar to:</p>
<p><code>asadmin help create-domain</code></p>
<p>You can see complete list of parameters and their associated values for each of the discussed command using the help command. All of the domain administration commands are local commands. We can use list-commands command to see the list of all available commands in both remote and local categories.</p>
<p><strong><em>3.2 Applications lifecycle administration’</em></strong></p>
<p>Applications including web, enterprise, and resource adapter, and so on are our bits inside the application server which our clients relay on to get the required services. Applications can be deployed from command line in a very effective and customizable manner. Like all other administration commands application deployment is a single parameter command when we want to use the default parameters.</p>
<p><strong>Deploying and un-deploying application</strong></p>
<p>To deploy an application independently from its type (WAR, EAR, RAR, and so on) we can use deploy command. The command which is one of the most basic remote commands deploys any kind of application known to the GlassFish application server to its dedicated container. The command has many options which are omitted to show the common use case. The GlassFish instance should be up and running to use deploy or any other remote command.</p>
<p><code>deploy   --host  127.0.0.1 --port 4747  --user  admin –name aName --contextroot cRoot --upload=true --dbvendorname derby --createtables=true  /home/masoud/GiA.ear</code></p>
<p>Deploying a web application using default parameters is as simple as passing the archive to the deploy command. The context name will be same as the archive file.</p>
<p><code>deploy </code><code>GiA.war</code></p>
<p>We can remove an application using the undeploy command. The command will remove the application bits from the application server directories along with removing it from the list of known applications in the domain.xml file. Following snippet shows how we can use it.</p>
<p><code>undeploy  --droptables=true </code><code>aName</code></p>
<p>The undeply command uses the application name to remove it from the application server; we have the liberty to drop the automatically created tables (for enterprise applications) automatically. Deploying and undeploying other application types is similar to enterprise application deployment. You can view the complete list of parameters by executing deploy with no parameter or you can view the complete help content by using help deploy command.</p>
<p><strong>Application utility commands</strong></p>
<p>For domains with developer profile we have only one utility command named list-applications which list the deployed applications. In addition to all shared parameter this command has one important parameter named &#8211;type which accepts application,    connector, ejb, jruby, and web as its value. Following command will list all web applications deployed in out domain.</p>
<p><code>list-applications --type=web</code></p>
<p>You can see all commands related to application administration by trying asadmin application which will show all commands which has application word in the command name.</p>
<p><strong><em>3.3 Application server managed resources</em></strong></p>
<p>Dealing with managed resources is one of the most recurring tasks which an administrator faces during the application deployment and development. The most important types of managed resources are JDBC and JMS resources which we will discuss in this section.</p>
<p><strong>JDBC connection pool administration</strong></p>
<p>A JDBC connection pool is a group of reusable connections for a particular database. Because creating each new physical connection is time consuming, the server maintains a pool of available connections to increase performance. When an application requests a connection, it obtains one from the pool and when the application closes the connection, the connection is returned to the pool instead of being closed. To create a JDBC connection pool we can use create-jdbc-connection-pool command.</p>
<p><code>create-jdbc-connection-pool --user admin </code></p>
<p><code>--passwordfile=/opt/dev/apps/passfile.txt  --host localhost --port 4747 </code></p>
<p>&#8211;datasourceclassname org.apache.derby.jdbc.ClientDataSource &#8211;restype javax.sql.XADataSource</p>
<p><code>--property portNumber=1527:password=APP:user=APP:serverName=</code></p>
<p><code>localhost:databaseName=GiADatabase:create=true GiA_Derby_Pool</code></p>
<p>The command may looks scary at the beginning but if you take a closer look you can see that all of the parameters and values are well known for you. We ca delete a JDBC connection pool using delete-jdbc-connection-pool which in addition to shared parameters accept an operand which is the name of the connection pool which we want to delete</p>
<p>Now that we have a connection pool we need a reference to the connection pool in the JNDI tree to ensure that our applications can access the connection pool through the application server.</p>
<p><strong>JDBC resources administration</strong></p>
<p>A JDBC resource or a data source is the mediator between application and the connection pool by providing a JNDI name to access the connection pool. Multiple JDBC resources can specify a single connection pool.</p>
<p>create-jdbc-resource &#8211;user admin &#8211;port 4747 &#8211;host localhost &#8211;passwordfile=/opt/dev/apps/passfile.txt</p>
<p><code>--connectionpoolid GiA_Derby_Pool jdbc/GiAPool</code></p>
<p>We determined a name for our JDBC connection pool when we create the pool. And when we want to create the data source we use that name to identity the JDBC connection pool we want to specify in the JDBC resource.</p>
<p>We can delete a JDBC resource using delete-jdbc-resource which in addition to shared parameters accepts an operand which is name of the connection pool that we want to delete.</p>
<p><strong>JMS Destination administration</strong></p>
<p>In enterprise applications, asynchronous communication is one of the in-evitable requirements. JMS destinations are virtually places which each message are headed to. JMS clients are listening on the same destinations to receive these messages. We can create a JMS destination either a Queue or Topic by create-jmsdest command.</p>
<p><code>create-jmsdest --user admin --passwordfile=/opt/dev/apps/passfile.txt --host localhost --port 4747 --desttype queue  --property User=public:Password=public GiAQueue</code></p>
<p>We can create a JMS topic by changing the value of &#8211;desttype parameter to topic. To delete a JMS destination we can use delete-jmsdest command which accept the name of destination which we want to delete as an operand. For example the following command will delete the JMS queue which we create in previous step.<br />
delete-jmsdest GiAQueue</p>
<p>Make sure that you create the above queue again as we will need it in the next steps.</p>
<p><strong>JMS resources administration</strong></p>
<p>JMS connection factories are door to consuming and producing JMS messages. We need to define these factories prior to be able to access a JMS destination. To create a JMS connection factory we can use creste-jms-resource command. For example:</p>
<p><code>create-jms-resource --user admin --passwordfile=/opt/dev/apps/passfile.txt  --host localhost --port 4747  --restype javax.jms.QueueConnectionFactory --property ClientId=MyID:UserName=guest:Password=guest jms/GiAQueueConnectionFactory</code></p>
<p>Our sample command creates a connection factory which provides us with queue connections. When we need to interact with a JMS topic we can change the &#8211;restype parameter to javax.jms.TopicConnectionFactory.</p>
<p>Deleting a JMS resource is possible by using delete-jms-resource command which takes the resource name which we want to delete as a parameter in addition to the shared parameters.</p>
<p><strong>Utility commands</strong></p>
<p>There are several utility commands related to manage resources, table 3 shows these commands along with a sample and description.</p>
<p>Table 3 Some asadmin utility commands for administering managed resources</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<p><strong>Command</strong></td>
<td>
<p><strong>Sample</strong></td>
<td>
<p><strong>Description</strong></td>
</tr>
<tr>
<td>
<p>flush-jmsdest</td>
<td>
<p>flush-jmsdest GiAQueue*</td>
<td>
<p>purges the messages in a JMS destination</td>
</tr>
<tr>
<td>
<p>jms-ping</td>
<td>
<p>jms-ping</td>
<td>
<p>checks to see if the JMS provider is running, the command can ping cluster wide configurations</td>
</tr>
<tr>
<td>
<p>list-jms-resources</td>
<td>
<p>ist-jms-resources &#8211;restype javax.jms.TopicConnectionFactory</td>
<td>
<p>List all JMS resources</td>
</tr>
<tr>
<td>
<p>list-jmsdest</td>
<td>
<p>list-jmsdest</td>
<td>
<p>List all JMS destinations</td>
</tr>
<tr>
<td>
<p>list-jdbc-connection-pools</td>
<td>
<p>list-jdbc-connection-pools</td>
<td>
<p>List all JDBC connection pools</td>
</tr>
<tr>
<td>
<p>list-jdbc-resources</td>
<td>
<p>list-jdbc-resources</td>
<td>
<p>List all JDBC data sources</td>
</tr>
</tbody>
</table>
<p>*I removed all shared parameters to fit the commands in the table.</p>
<p>The asadmin utility has a very rich set of commands for administrating the managed resources. We learned basic commands here.</p>
<p><strong><em>3 Monitoring with CLI</em></strong></p>
<p>Monitoring is an integral part of the administrators daily task list. Monitoring helps us to: find possible problems, detect performance bottlenecks, find system resource shortage, plan system capacity or upgrade, and finally monitor the daily performance of the system. The GlassFish application server infrastructure allows us to monitor almost any object which corresponds to a Java EE concept. For example we can monitor an HTTP listener, a Servlet, or a JDBC connection pool.</p>
<p>To monitor an object, system should gather statistics about that object and this statistics gathering has some overhead even in ideal software as more byte codes should be executed to gather the statistics. Based on the fact that GlassFish application server should be well tuned out of the box, all monitoring functionalities are turned off to prevent any extra overhead during the system work hours.</p>
<p>GlassFish provides 3 monitoring level for any object available for monitoring. These levels include:</p>
<p style="-qt-block-indent: 1;">
<ul type="square">
<li>OFF: No monitoring information is gathered</li>
<li>LOW: Only object’s attributes changes are monitored</li>
<li>HIGH: In addition to attributes methods execution is counted</li>
</ul>
<p>The asadmin utility provides multiple ways for getting statistical data from the application server core. Multiple commands are introduced to facilitate our job in viewing this statistical information. These commands include:</p>
<p style="-qt-block-indent: 1;">
<ul type="square">
<li>The monitor command: We can use this command to view common statistical information about different application server services, we can filter the statistics for only on monitor-able object in the service or we can view cumulative statistical information about all objects in that particular service. For example all JDBC connection pools or just one single JDBC connection pool statistics can be viewed using the monitor command.</li>
<li>The list command: We can use this command to get the hierarchic of all monitor-able and configuration objects or specific type of objects like JDBC connection pools. The list command has an important boolean parameter named monitor which determine whether we want to see monitor-able objects or configuration objects.</li>
<li>The set command: We can use this command to change the monitoring level of a monitor-able object. And in broader view, We can use it to change application server configuration by changing the attributes of configuration objects.</li>
<li>The get command: We can get customized monitoring information about different attributes of different monitor-able objects. In broader view, we can use this command to view value of any configuration object’s attributes.</li>
</ul>
<p><strong><em>3.1 Dotted names </em></strong></p>
<p>All monitor-able and configuration objects shape a tree composed of these objects and their children objects. The children objects have attributes which are either the monitoring factor or configuration elements. Objects in the tree are separated using a dot and therefore we can simply navigate from the root object to any of lower level child objects. For example if we execute list &#8211;monitor=true server we will get a list of all monitor-able objects which are direct child of server objects. The list can be similar to the following snippet.</p>
<p><code>server.applications</code></p>
<p><code>server.connector-service</code></p>
<p><code>server.http-service</code></p>
<p><code>server.jms-service</code></p>
<p><code>server.jvm</code></p>
<p><code>server.orb</code></p>
<p><code>server.resources</code></p>
<p><code>server.thread-pools</code></p>
<p><code>server.transaction-service</code></p>
<p>After getting the high level child we can go deeper toward leaf nodes by listing the immediate or related children of any top level object. For example to get immediate children or http-service object we can use list &#8211;monitor=true server.http-service to show all immediate children of http-service object which can result in an output similar to:</p>
<p><code>server.http-service.__asadmin</code></p>
<p><code>server.http-service.connection-queue</code></p>
<p><code>server.http-service.file-cache</code></p>
<p><code>server.http-service.keep-alive</code></p>
<p><code>server.http-service.pwc-thread-pool</code></p>
<p><code>server.http-service.server</code></p>
<p>We can further do down and monitor any monitor-able object in the application server. We can use list &#8211;monitor=true server.http-service.* to view a recursive list of immediate children and children of those immediate children. We use * with list command as a place holder for any part of the dotted name. For example we can use server.jvm.* or server.resource* to get all children of server.jvm or all children which starts with resource.</p>
<p>The dotted names are not provided for sole monitoring purposes, we can use them to view and change the configuration of application server by using the asadmin utility. We can get list of configurable objects by omitting the &#8211;monitor=true parameter from the list command.</p>
<p><strong>Enabling the GlassFish monitoring </strong></p>
<p>GlassFish monitoring is turned off when we install the application server, we need to enable the monitoring system to gather statistical information for us. To do so, we can use set command to change the monitoring level for one or all of the GlassFish services like JDBC connection pool, HTTP listener, and so on.  But before changing the monitoring level from OFF to HIGH we can check and see the current level by using a simple get command similar to the following snippet.</p>
<p>get server.monitoring-service.module-monitoring-levels.*</p>
<p>Executing this snippet shows us a result similar to the following snippet which means that monitoring is OFF for all services.</p>
<p><code>server.monitoring-service.module-monitoring-levels.connector-service=OFF</code></p>
<p><code>server.monitoring-service.module-monitoring-levels.ejb-container=OFF</code></p>
<p><code>server.monitoring-service.module-monitoring-levels.http-service=OFF</code></p>
<p><code>server.monitoring-service.module-monitoring-levels.jdbc-connection-pool=OFF</code></p>
<p><code>server.monitoring-service.module-monitoring-levels.jms-service=OFF</code></p>
<p><code>server.monitoring-service.module-monitoring-levels.jvm=OFF</code></p>
<p><code>server.monitoring-service.module-monitoring-levels.orb=OFF</code></p>
<p><code>server.monitoring-service.module-monitoring-levels.thread-pool=OFF</code></p>
<p><code>server.monitoring-service.module-monitoring-levels.transaction-service=OFF</code></p>
<p><code>server.monitoring-service.module-monitoring-levels.web-container=OFF</code></p>
<p>We can enable the monitoring for JDBC connection pools by using set command as follow:</p>
<p>Set server.monitoring-service.module-monitoring-levels.jdbc-connection-pool=HIGH</p>
<p>Now we are sure that any activity involving any of the JDBC connection pool will be monitored and its statistical information will be available for us to view and analyze.</p>
<p><strong><em>3.2 The monitor command</em></strong></p>
<p>Using monitor command is the simplest way to view monitoring information about GlassFish application server. Following snippet shows the monitor command syntax. I have not included the shared parameters to make it easier to read and see the command specific parameters.</p>
<p>monitor &#8211;type  monitor_type [--filename file_name] [--interval interval]</p>
<p>[--filter filter_name]   instance_name</p>
<p>We can save the command output to CSV files using the &#8211;filename parameter and we can determine the interval which the command uses to retrieve the statistics by using the &#8211;interval parameter. The instance_name argument let us use this command on a DAS to retrieve the statistics related to one of the DAS member instances. Two other parameters determine what service and which object in the service we want to monitor. Most important acceptable values for &#8211;type parameter is listed in table 4 along with related description.</p>
<p>Table 4 acceptable values for the monitor command’s type parameter</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<p><strong>Value</strong></td>
<td>
<p><strong>Description</strong></td>
</tr>
<tr>
<td>
<p>statefulsession</td>
<td>
<p>Statistics related to State full Session Beans</td>
</tr>
<tr>
<td>
<p>statelesssession</td>
<td>
<p>Statistics related to Stateless Session Beans</td>
</tr>
<tr>
<td>
<p>connectorpool</td>
<td>
<p>JCA connector pool statistics</td>
</tr>
<tr>
<td>
<p>endpoint</td>
<td>
<p>Web services end point statistics</td>
</tr>
<tr>
<td>
<p>entitybean</td>
<td>
<p>Entity Beans statistics</td>
</tr>
<tr>
<td>
<p>filecache</td>
<td>
<p>GlassFish HTTP level cache system statistics</td>
</tr>
<tr>
<td>
<p>httplistener</td>
<td>
<p>HTT listener statistics</td>
</tr>
<tr>
<td>
<p>httpservice</td>
<td>
<p>HTTP service statistics</td>
</tr>
<tr>
<td>
<p>jdbcpool</td>
<td>
<p>JDBC connection pool statistics</td>
</tr>
<tr>
<td>
<p>jvm</td>
<td>
<p>Underlying JVM statistics</td>
</tr>
<tr>
<td>
<p>servlet</td>
<td>
<p>Servlet statistics</td>
</tr>
</tbody>
</table>
<p>You can see an example monitoring command to monitor our newly created JDBC connection pool in the following snippet.</p>
<p>monitor &#8211;type jdbcpool &#8211;interval 10 &#8211;filter GiA_Derby_Pool server</p>
<p>We just want to view the statistics related to one JDBC connection pool on the default instance. The interval for retrieving the statistics is 10 seconds. The output for this command is very similar to figure 3.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_473c975wjhg_b" alt="" width="503" height="78" /></p>
<p>Figure 3 Outputs for monitoring GiA_Derby_Pool JDBC connection pool using monitor command</p>
<p>Monitoring results are categorized under some column and for each column we have several statistic factors like highest number of free connections, and current number of free connections. Next service which we want to monitor is the application server runtime or the JVM instance that our application server is running on. To monitor the JVM we can use a command similar to the following snippet.</p>
<p>monitor &#8211;type jvm &#8211;interval 1 server</p>
<p>Command output is similar to figure 4 which shows almost no changes in heap size during the monitoring period.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_474hd8f48dd_b" alt="" width="503" height="104" /></p>
<p>Figure 4 outputs for JVM monitoring using the monitor command</p>
<p>The monitor command combined with LOW monitoring level is very useful when we need to get an overview of different GlassFish services in production environment.</p>
<p><strong><em>3.3 Monitoring and configuration by get and set commands</em></strong></p>
<p><strong>Explain more about get and set commands</strong></p>
<p><strong> </strong></p>
<p><strong>Monitoring a JDBC connection pool</strong></p>
<p>Now we want to use these set of four commands to monitor our newly created JDBC connection pool.</p>
<p><code>get --monitor=true server.resources.GiA_Derby_Pool.*</code></p>
<p>This command will return a handful set of statistical information about our connection pool. Although we can change the command in order to get only one of the connection pool attributes instead of complete statistical set. To get number of free connections in our JDBC pool we can use the following command</p>
<p><code>get --monitor=true  server.resources.DerbyPool.numconnfree-current</code></p>
<p>We can use get to view the configuration attributes of any configurable object in the application server. If we try to use get without &#8211;monitor=true, we should give try to view a configuration attribute instead of a monitoring attribute. For example to view the maximum pool size for our connection pool we can use the following command:</p>
<p><code>get server.resources.jdbc-connection-pool.DerbyPool.max-pool-size</code></p>
<p>We can use set command alongside with get command to change the configuration parameters using the dotted names and asadmin utility.</p>
<p><code>set server.resources.jdbc-connection-pool.DerbyPool.max-pool-size=64</code></p>
<p>It is very simple and effective to get detailed monitoring information out of the application server to catch up with performance related issues.</p>
<p><strong><em>4 CLI security</em></strong></p>
<p>The CLI is our means to administrate the application server. As well as it can be very useful for daily tasks it can be catastrophic if we fail to protect it well from the unauthorized access.</p>
<p><strong><em>4.1 The asadmin related credentials</em></strong></p>
<p>In the commands which we studied in this article you saw that for some of them we used the &#8211;user and &#8211;passwordfile parameters and for some of them we did not. The main reason behind the fact that we could execute a command with or without providing any credentials refers back to the way that we create the domain. If you look at the command we used to create the domain you can see that we used &#8211;savemasterpassword=true and &#8211;savelogin=true.  These two parameters save the domain credentials and asadmin reuse those credentials whenever we want to execute a command.</p>
<p><strong>The so called master password</strong></p>
<p>The master password is designated to protect the domain encrypted files like digital certificate store from unauthorized access.</p>
<p>When we start a GlassFish domain, startup process needs to read these certificates and therefore it need to open the certificates store files. GlassFish needs master password to open the store files and therefore we should either provide the master password during the start-domain command execution in an interactive way or we should use the &#8211;passwordfile parameter to provide the process with the master password.</p>
<p>The most common situation for using a previously saved master password is when we need our application server to start in an unattended environment, like when we make a Windows service or Linux Daemon for it.</p>
<p>To provide this password for the application server startup process, we should use the &#8211;savemasterpassword=true during the domain creation. If we use this parameter the master password will be saved into a file named master-password which resides inside the domain/config directory.</p>
<p>We said that the master password protects some files from unauthorized access. One of the file set that master password protects is the digital certificates storage files which differ between developer and cluster profile.</p>
<p><strong>The domain administration credentials</strong></p>
<p>So far, we that we can execute asadmin commands with or without providing the password file. You may ask, how it is possible that we are not entering the password and nor we are providing the password file and hence we saw that our command are carried out by the  asadmin.</p>
<p>We did not provide any password in an interactive manner or any password file for asadmin to carry out our command because we used a parameter during the domain creation. The &#8211;savelogin=true asks the domain creation command to save the administration password of our domain into a file name .asadminpass which is located inside our home directory. The content of this file is similar to the following snippet.</p>
<p><code>asadmin://admin@localhost:4747 YWRtaW5hZG1pbg==</code></p>
<p>The syntax simply determine what is the administration username and administration password for a domain that is running on localhost and uses 4747 as its administration port Sure the password is encrypted to prevent anyone learning it without being authorized.</p>
<p>There is an asadmin command which perform a similar task to what &#8211;savelogin does for domains that are already created.  We can use this command to save the credentials to prevent the asadmin utility asking for them either in an interactive mode or as  &#8211;passwordfile parameter. Following snippet shows how we can use login command.</p>
<p><code>login   --host localhost --port 9138</code></p>
<p>This command will interactively ask for administration username and administration password and after a successful authentication it will save the provided credentials into the .asadminpass file. After we execute this command the content of .asadminpass will be similar to the following snippet.</p>
<p><code>asadmin://admin@localhost:4747 YWRtaW5hZG1pbg==</code></p>
<p><code>asadmin://admin@localhost:9138 YWRtaW5hZG1pbg==</code></p>
<p>The .asadminpass contains the SHA hashed copy of passwords therefore it is not possible for anyone to recover the original passwords if he can grasp the file.</p>
<p>The login command falls very useful when we need to administrate several domains from our administration workstation. We can simply login into each remote or local domain that we need to administrate and then asadmin will pickup the correct credential from the .asadminpass file based on the &#8211;host and &#8211;port parameters.</p>
<p><strong>Changing passwords</strong></p>
<p>As and administrator we usually like to change our passwords from time to time to ensure keep a higher level of security precautions. GlassFish let us simply change the master or administration password using some provided commands.</p>
<p>To change the master password we must be sure that application server is not running and then we can the change-master-password as follow:</p>
<p><code>Change-master-password --domaindir=/opt/dev/apps/domains/ --savemasterpassword=true GiADomain</code></p>
<p>After executing this command, the asadmin utility will interactively asks us for the new master password which must be at least 8 characters. And we use the &#8211;savemasterpassword to ensure that the master password is saved and during the domain startup we do not need to provide the asadmin with it. We need to change the password file if we are using it to feed the asadmin utility with the master password.</p>
<p>To change the administration password we can use change-admin-password which is a remote command and need the application server to be running. Following snippet shows how we can change the administration password for a given username.</p>
<p><code>change-admin-password --host 127.0.0.1 --port 4747 --user admin</code></p>
<p>After executing this command, asadmin will asks for administration password and then change the password of the given user. If we change the password for a user, we will need to login into that domain again if we need to use automatic login. Also we need to change the password file if we are using it to feed the asadmin utility with its required passwords.</p>
<p>In advanced administration article we will discuss how we can add more administration users and how we can use an already credentials store like an LDAP for administration authentication.</p>
<p><strong><em>4.2 Protecting passwords</em></strong></p>
<p>We have many places in any application server which we need to provide it wit some username and passwords which the application server will use to communicate with external systems like JMS brokers and Databases. Usually each part of the overall infrastructure has its own level of policy and permission set which lead to the fact that we should protect these passwords and avoid leaving these passwords in plain text format in any place, even in the application server configuration files which can be opened using any text editor.</p>
<p>GlassFish provides a very elegant way for protecting these passwords by providing us with the required commands and infrastructure to encrypt the passwords and use the encrypted password’s assigned alias in the application server configuration files. The encrypted passwords are stored inside an encrypted file named domain-passwords which resides inside the domain’s config directory. The domain-passwords file is encrypted using the master password and if the master password compromised then these file can be decrypted.</p>
<p>The command for creating password aliases is a remote command named create-password-alias and a sample usage is as following snippet:</p>
<p><code>create-password-alias --user admin --host localhost --port 4747 GiA_Derby_Pool_Alias</code></p>
<p>After we execute this command asadmin utility will ask for the password which we want this alias to hold.  Although asadmin may asks for administration credentials if we are not logged in.</p>
<p>Now that we create the alias we can use it by using the alias accessing syntax which follows the ${ALIAS=password-alias-password} format. For example if we want to create the JDBC connection pool that we create in 3.3 we can change the command as follow:</p>
<p><code>create-jdbc-connection-pool --user admin  --host localhost --port 4747 </code></p>
<p><code>--datasourceclassname org.apache.derby.jdbc.ClientDataSource --restype javax.sql.XADataSource </code></p>
<p><code>--property portNumber=1527:password=</code><code>${ALIAS= GiA_Derby_Pool_Alias }</code><code>:user=APP:serverName=</code></p>
<p><code>localhost:databaseName=GiADatabase:create=true GiA_Derby_Pool</code></p>
<p>Password aliasing is not present just for external resources, but it can be used to protect the content of the password file which contains administration and master password for using instead of typing the password when the asadmin interactively asks for it.  We can simply create a password alias for administration password and for the master password and use them in password file. Sample content for a password file with aliased password is like.</p>
<p><code>AS_ADMIN_PASSWORD=${ALIAS=admin-alias}</code></p>
<p><code>AS_ADMIN_MAPPEDPASSWORD=${ALIAS=master-alias}</code></p>
<p>Like all other administration commands, the alias administration commands set have some other commands which help with the commands administration. Other commands in the set are</p>
<p style="-qt-block-indent: 1;">
<ul type="square">
<li>The delete-password-alias command: We can delete an alias when we are sure we are no longer using it.</li>
<li>The list-password-aliases command: We can get a list of all aliases that we have in our domain-password file.</li>
<li>The update-password-alias command: We can update an alias by changing the password that it holds.</li>
</ul>
<p>Password aliasing is very helpful when we do not want to give our passwords to the personal in charge of application server management or administration tasks. Instead we can provide them aliased password which they can use.</p>
<p><strong><em>5 Summary</em></strong></p>
<p>The GlassFish command line administration interface is one of the most powerful and feature complete command line based administration utilities in the application server markets.  The asadmin utility provides all required commands which we need to administrate any part of the application server directly from the command line instead of wandering in the XML configuration files or third party utilities or the web based administration console.</p>
<p>The asadmin utility is a not only a client side application which we can use to administrate an application and instead it is a composition of client side and a server side application which makes it possible to use the asadmin utility to administrate remote domains as well as local domains.</p>
<p>The asadmin utility has enough intelligence embedded in its routines which helps us find the required commands and the command structure simply by entering a part of command. By using asadmin utility we can administrate domains, applications, and application server managed resources.</p>
<p>When it comes to security, which is one of the highest concerns of the administrators, GlassFish provides many measures to protect passwords and keep the possibility of compromising passwords to the lowest possible value by using encryption for storing external resource passwords and asadmin administration passwords.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/learning-glassfish-v3-command-line-administration-interface-cli/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Manage, Administrate and Monitor GlassFish v3 from Java code using AMX &amp; JMX</title>
		<link>http://kalali.me/manage-administrate-and-monitor-glassfish-v3-from-java-code-using-amx-jmx/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=manage-administrate-and-monitor-glassfish-v3-from-java-code-using-amx-jmx</link>
		<comments>http://kalali.me/manage-administrate-and-monitor-glassfish-v3-from-java-code-using-amx-jmx/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 02:46:20 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Modularity]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Persistence]]></category>
		<category><![CDATA[Administrate]]></category>
		<category><![CDATA[AMX]]></category>
		<category><![CDATA[JMX]]></category>
		<category><![CDATA[manage]]></category>
		<category><![CDATA[monitor]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=362</guid>
		<description><![CDATA[Management is one of the most crucial parts of an application server set of functionalities. Development of the application which we deploy into the server happens once with minor development iteration during the software lifecycle, but the management is a lifetime task. One of the very powerful features of the GlassFish application server is the [...]]]></description>
			<content:encoded><![CDATA[<p>Management is one of the most crucial parts of an application server set of functionalities. Development of the application which we deploy into the server happens once with minor development iteration during the software lifecycle, but the management is a lifetime task. One of the very powerful features of the GlassFish application server is the powerful administration and management channels that it provides for different level of administrators and developers whom want to extend the application server administration and management interfaces.</p>
<p>GlassFish as an application server capable or serving mission critical and large scale applications benefits from several administration channel including the CLI, web based administration console and finally the possibility to manage the application server by using standard Java management extension or the JMX.</p>
<p>Not only GlassFish fully expose its management functionalities as JMX MBeans but also it provides a very easier way to manage the application server using local objects which proxies JMX MBeans. These local objects are provided as AMX APIs which lift the need for learning JMX by administers and developers whom want to interact with the application server by code.</p>
<p>GlassFish provides very powerful monitoring APIs in term of AMX MBeans which let developers and administrators monitor any aspect of anything inside the application server using Java code without need to understand the JMX APIs or complexity of monitoring factors and statistics gathering. These monitoring APIs allows developers to monitor a bulk of Java EE functionalities together or just monitor or single attribute of a single configuration piece.</p>
<p>GlassFish self management capability is another powerful feature based on the AMX and JMX APIs to let administrators easily automate daily tasks which can consume a handful amount of time without automation. Self management can manage the application server dynamically by monitoring the application server in runtime and changing the application server configuration dynamically based on predefined rules.</p>
<p><strong><em>1 Java Management eXtension (JMX)</em></strong></p>
<p>JMX, native to Java platform, introduced to let Java developers have a standard and easy to learn and use way for managing and monitoring their Java applications and Java enabled devices. We as architects, designers and developers of Java applications which can be as small as an in house invoice management or as big as a running stock exchange system need a way to expose management of our developed software to other industry accepted management software and JMX is the answer to these need.</p>
<p><strong><em>1.1 What is JMX?</em></strong></p>
<p>JMX is a part of Java Standard edition and was present from early days of Java platform existence and seen many enhancements during Java platform evolution.  The JMX related specifications define the architecture, design patterns, APIs, and services in the Java programming language for managing and monitoring applications and Java enabled devices.</p>
<p>Using the JMX technology, we can develop Java classes which perform the management and monitoring tasks and expose a set of their functionalities or attributes by means of an interface to which later on are exposed to JMX clients through specific JMX services. The objects which we use to perform and expose management functionalities are called Managed Beans or MBeans in brief.</p>
<p>In order for MBeans to be accessible to JMX clients, which will use them to perform management tasks or gathers monitoring data, they need to be registered in a registry which later on let our JMX client application to find and initialize them. This registry is one of the fundamental JMX services and called MBean Server.</p>
<p>Now that we have our MBeans registered with a registry, we should have a way to let clients communicate with the running application which registered the MBeans to execute our MBeans operations, this part of the system is called JMX connectors which let us communicate with the agent from a remote or local management station. The JMX connector and adapter API provides a two way converter which can transparently connect to JMX agent over different protocols and provides a standard way for management software to communicate with the JMX agents regardless of communication protocol.</p>
<p><strong><em>1.2 JMX architecture</em></strong></p>
<p>The JMX benefits from a layered architecture heavily based on the interfaces to provide independency between different layers in term of how each layer works and how the data and services are provided for each layer by its previous one.</p>
<p>We can divide the JMX architecture to three layers. Each layer only relay on its direct bottom layer and is not aware of its upper layer functionalities. These layers are: instrumentation, agent, and management layers. Each layer provides some services either for other layers, in-JVM clients or remote clients running in other JVMs. Figure 1 shows different layers of JMX architecture.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_453d85ffcdw_b" alt="" width="401" height="221" /></p>
<p>Figure 1 JMX layerd architecture and each layer components</p>
<p><strong>Instrumentation layer</strong></p>
<p>This layer contains MBeans and the resources that MBeans are intended to manage. Any resource that has a Java object representative can be instrumented by MBeans. MBeans can change the value of object’s attributes or call its operations which can affect the resource that this particular Java object represents. In addition to MBeans, notification model and MBean metadata objects are categorized in this layer. There are two different types of MBeans for different use cases, these types include:</p>
<p>Standard MBeans: Standard MBeans consisting of an MBean interface which define the exposed operations and properties (using getters and setters) and the MBean implementation class. The MBean implementation class and the interface naming should follow a standard naming pattern in Standard MBeans. There is another type of standard MBeans which lift the urge for following the naming pattern called MXBeans. The Standard MBeans naming pattern for MBeans interface is ClassNameMBean and the implementation class is ClassName. For the MXBeans naming pattern for the interface is AnythingMXBean and the implementation class can have any name. We will discuss this naming matter in more details later on.</p>
<p>Dynamic MBeans: A dynamic MBean implements javax.management.DynamicMBean, instead of implementing an static interface with a set of predefined methods. Dynamic MBeans relies on javax.management.MBeanInfo that represents the attributes and operations exposed by them. MBeans client application call generic getters and setters whose implementation must resolve the attribute or operation name to its intended behavior. Faster implementation of JMX management MBeans for an already completed application and the amount of information provided by MBeans metadata classes are two benefits of Dynamic MBeans.</p>
<p>Notification Model: JMX technology introduces a notification model based on the Java event model. Using this event model MBeans can emit notifications and any interested party can receive and process them, interested parties can be management applications or other MBeans.</p>
<p>MBean Metadata Classes: These classes contain the structures to describe all components of an MBean&#8217;s management interface including its attributes, operations, notification, and constructors. For each of these, the MBeanInfo class include a name, a description and its particular characteristics (for example, an attribute is readable, writeable, or both; for an operation, the signature of its parameter and return types).</p>
<p><strong>Agent layer</strong></p>
<p>This layer contains the JMX Agents which are intended to expose the MBeans to management applications. The JMX agent’s implementation specifications fall under this layer. Agents are usually located in the same JVM that MBeans are located but it is not an obligation. The JMX agent consisting of an MBean server and some helper services which facilitate MBeans operations. Management software access the agent trough an adapter or connecter based on the management application communication protocol.</p>
<p>MBean Server: This is the MBeans registry, where management applications will look to find which MBeans are available to them to use. The registry expose the MBeans management interface and not the implementation class. The MBeans registry provides two interfaces for accessing the MBeans from a remote and in the same JVM client. MBeans can be registered by another MBeans, by the management application or by the Agent itself. MBeans are distinguished by a unique name which we will discuss more in AMX section.</p>
<p>Agent Services: there some helper services for MBeans and agent to facilitate some functionalities. These services include: Timer, dynamic class loader, observers to observer numeric or string based properties of MBeans, and finally relation service which define associations between MBeans and enforces the cardinality of the relation based on predefined relation types.</p>
<p><strong>Management layer</strong></p>
<p>The Management tier contains components required for developing management applications capable of communicating with JMX agents. Such components provide an interface for a management application to interact with JMX agents through a connector. This layer may contain multiple adapters and connectors to expose the JMX agent and its attached MBeans to different management platforms like SNMP or exposing them in a semantic rich format like HTML.</p>
<p><strong>JMX related JSRs</strong></p>
<p>There are six different JSRs defined for the JMX related specifications during past 10 years. These JSRs include:</p>
<p>JMX 1.2 (JSR 3): First version of JMX which was included in J2SE 1.2</p>
<p>J2EE Management (JSR 77): A set of standard MBeans to expose application servers’ resources like applications, domains, and so on for management purposes.</p>
<p>JMX Remote API 1.0 (JSR 160): interaction with the JMX agents using RMI from a remove locaten.</p>
<p>Monitoring and Management Specification for the JVM (JSR 174): a set of API and standard MBeans for exposing JVMs management to any interested management software.</p>
<p>JMX 2.0 (JSR 255): The new version of JMX for Java 0 which introduces using generics, annotation, extended monitors, and so on.</p>
<p>Web Services Connector for JMX Agents (JSR 262): define an specification which leads to use Web Services to access JMX instrumentation remotely.</p>
<p><strong><em> </em></strong></p>
<p><strong><em>1.3 JMX benefits</em></strong></p>
<p>What are JMX benefits that JCP defined a lot of JSRs for it and on top of it, why we did not follow another management standard like IEEE Std 828-1990. The reason is behind the following JMX benefits:</p>
<p>Java needs an open to extend and close to change API for integration with emerging requirement and technologies, JMX does this by its layered architecture.</p>
<p>The JMX is based on already well defined and proven Java technologies like Java event model for providing some of required functionalities.</p>
<p>The JMX specification and implementation let us use it in any Java enabled software in any scale.</p>
<p>Almost no change is required for an application to become manageable by JMX.</p>
<p>Many vendors uses Java to enable their devices, JMX provide one standard to manage both software and hardware.</p>
<p>You can imagine many other benefits for JMX which are not listed above.</p>
<p><strong><em>1.4 Managed Beans (MBeans)</em></strong></p>
<p>We discussed that generally there are two types of MBeans which we can choose to implement our instrumentation layer. Dynamic MBeans are a bit more complex and we would rather skip them in this crash course, so in this section we will discuss how MXBeans can be developed, used locally and remotely to prepare ourselves for understanding and using AMX to manage GlassFish.</p>
<p>We said that we should write an interface which defines all exposed operation of the MBeans both for the MXBeans and standard MBeans. So first we will write the interface. Listing 1 shows the WorkerMXBean interface, the interface has two methods which supposed to change a configuration in a worker thread and two properties which return the current number of workers threads and maximum number of worker threads. Number of current workers thread is read only and maximum number of threads is both readable and updateable.</p>
<p><strong>Listing 1 The MXBean interface for </strong><strong>WorkerMXBean</strong></p>
<p>@MXBean</p>
<p>public interface WorkerIF</p>
<p>{</p>
<p>public int getWorkersCount();</p>
<p>public int getMaxWorkers();</p>
<p>public void setMaxWorkers(int newMaxWorkers);</p>
<p>public int stopAllWorkers();</p>
<p>}</p>
<p>I did not told you that we can forget about the naming conversion for MXBean interfaces if we are intended to use Java annotation. As you can see we simply marked the interface as an MBean interface and defined some setter and getter methods along with one operation which will stop some workers and return the number of stopped workers.</p>
<p>The implementation of our MXBean interface will just implement some getter and setters along with a dummy operation which just print a message in standard output.</p>
<p><strong>Listing 2 the Worker MXBean implementation</strong></p>
<p>public class Worker implements WorkerIF {</p>
<p>private int maxWorkers;</p>
<p>private int workersCount;</p>
<p>public Worker() {</p>
<p>}</p>
<p>public int getWorkersCount() {</p>
<p>return workersCount;</p>
<p>}</p>
<p>public int getMaxWorkers() {</p>
<p>return maxWorkers;</p>
<p>}</p>
<p>public void setMaxWorkers(int newMaxWorkers) {</p>
<p>this.maxWorkers = newMaxWorkers;</p>
<p>}</p>
<p>public int stopAllWorkers() {</p>
<p>System.out.println(&#8220;Stopping all workers&#8221;);</p>
<p>return 5;</p>
<p>}</p>
<p>}</p>
<p>We did not follow any naming convention because we are using MXBean along with the annotation. If it was a standard MBean then we should have named the interface as WorkerMBean and the implementation class should have been Worker.</p>
<p>Now we should register the MBean to some MBean server to make it available to any management software. Listing 3 shows how we can develop a simple agent which will host the MBean server along with the registered MBeans.</p>
<p><strong>Please replace the numbers with cueballs</strong></p>
<p><strong>Listing 3 How MBeans server works in a simple agent named WorkerAgent</strong></p>
<p>public class WorkerAgent {</p>
<p>public WorkerAgent() {</p>
<p>MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); #1</p>
<p>Worker workerBean = new Worker();                  #2</p>
<p>ObjectName workerName = null;</p>
<p>try {</p>
<p>workerName = new                                #3 ObjectName(&#8220;article:name=firstWorkerBean&#8221;);</p>
<p>mbs.registerMBean(workerBean, workerName);          #4</p>
<p>System.out.println(&#8220;Enter to exit&#8230;&#8221;);            #5</p>
<p>System.in.read();</p>
<p>} catch(Exception e) {</p>
<p>e.printStackTrace();</p>
<p>}</p>
<p>}</p>
<p>public static void main(String argv[]) {</p>
<p>WorkerAgent agent = new WorkerAgent();</p>
<p>System.out.println(&#8220;Worker Agent is running&#8230;&#8221;);</p>
<p>}</p>
<p>}</p>
<p>At #1 we get the platform MBean Server to register our MBean. Platform MBean server is the default JVM MBean server. At #2 we initialize an instance of our MBean.</p>
<p>At #3 we create a new ObjectName for our MBean. Each JVM may use many libraries which each of them can register tens of MBeans, so MBeans should be uniquely identified in MBean server to prevent any naming collision. The ObjectName follow a format to represent an MBean name in order to ensure that it is shown in a correct place in the management tree and lift any possibility for naming conflict. An ObjectName is made up of two parts, a domain and a name value pair separated by a colon. In our case the domain portion is article and the description is name=name=firstWorkerBean</p>
<p>At #4 as register the MBean to the MBean server. At #5 we just make sure that our application will not close automatically and let us examine the MBean.</p>
<p>Sample code for this chapter is provided along with the book, you can run the sample codes by following the readme.txt file included in the chapter06 directory of source code bundle. Using the sample code you will just use Maven to build and run the application and JConsole to monitor it. But the behind the scene procedure described in the following paragraph.</p>
<p>To run the application and see how our MBean will appear in a management console which is standard JConsole bundled with JDK. To enable the JMX management agent for local access we need to pass the -Dcom.sun.management.jmxremote to the JVM. This command will let the management console to use inter process communication to communicate with the management agent.  Now that you have the application running you can run JConsole. Open a terminal window and run jconsle. When JConsole opens, it shows a window which let us select either a remote or a local JVM to connect. Just scan the list of local JVMs to find WorkerAgent under name column; select it and press connect to connect to the JVM. Figure 2 shows the new Connection window of JConsole which we talked about.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_454g345brc8_b" alt="" width="413" height="169" /></p>
<p>Figure 2 The New Connection window of JConsole</p>
<p>Now you will see how JConsole shows different aspects of the selected JVM including memory meters, threads status, loaded classes, JVM overview which includes the OS overview and finally the MBeans. Select MBeans tab and you can see a tree of all MBeans registered with the platform MBean server along with your MBean. You should remember what I said about ObjectName class, the tree clearly shows how a domain includes its child MBeans. When you expand article node you will see something similar to figure 3.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_455dgzx8scg_b" alt="" width="281" height="205" /></p>
<p>Figure 3 JConsole navigation tree and effect of ObjectName format on the MBean placing in the tree</p>
<p>And if you click on stopAllWorkers node the context panel of the JConsole will load a page similar to figure 4 which also shows the result of executing he method.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_456fhg2d2f6_b" alt="" width="438" height="444" /></p>
<p>Figure 4 The content panel of JConsole after selecting stopAllWorkers method of the WorkerMBean</p>
<p>It was how we can connect to a local JVM, in the 1.6 we will discuss connecting to a JVM process from a remote location to manage the system using JMX.</p>
<p><strong><em>1.5 JMX Notification</em></strong></p>
<p>The JMX API defines a notification and notification subscription model to enable MBeans generate notifications to signal a state change, a detected event, or a problem.</p>
<p>To generate notifications, an MBean must implement the interface NotificationEmitter or extend NotificationBroadcasterSupport. To send a notification, we need to construct an instance of the class javax.management.Notification or a one of its subclasses like AttributeChangedNotification, and pass the instance to NotificationBroadcasterSupport.sendNotification.</p>
<p>Every notification has a source. The source is the object name of the MBean that generated the notification.</p>
<p>Each notification has a sequence number. This number can be used to order notifications coming from the same source when order matters and there is a risk of the notifications being handled in the wrong order. The sequence number can be zero, but preferably the number increments for each notification from a given MBean.</p>
<p><strong>Please replace the # with cueball in the source and the paragraph </strong></p>
<p><strong><em>1.6</em></strong> <strong><em>Remote</em></strong> <strong><em>management</em></strong></p>
<p>To manage our worker application from a remote location using a JMX console like JConsole we will just need to ensure that an RMI connector is open in our JVM and all appropriate settings like port number, authentication mechanism, transport security and so on are provided. So, to run our sample application with remote management enabled we can pass the following parameters to the java command.</p>
<p>-Dcom.sun.management.jmxremote.port=10006     #1</p>
<p>-Dcom.sun.management.jmxremote.authenticate=true #2</p>
<p>-Dcom.sun.management.jmxremote.password.file=passwordFile.txt #3</p>
<p>-Dcom.sun.management.jmxremote.ssl=false #4</p>
<p>At #1 we determine a port for the RMI connector to listen for incoming connections. At #2 we enable authentication in order to protect our management portal. At #3 we provide the path to a password file which contains the list of username and password in plain text. In the password file, each username and password pair are placed in one line with an space between them. At #4 we disable SSL for transport layer.</p>
<p>To connect to a JVM which started with these parameters, we should choose remote in the New Connection window of JConsole and provide the service:jmx:rmi:///jndi/rmi://127.0.0.1:10006/jmxrmi as Remote Process URL along with one of the credentials which we defined in the passwordFile.txt.</p>
<p><strong><em>2 Application Server Management eXtension (AMX)</em></strong></p>
<p>GlassFish fully adheres to the J2EE management (JSR 77) in term of exposing the application server configuration as JMX MBeans but dealing with JMX is not easy and likeable for all developers, so Sun has included a set of client side proxies over the JSR 77 MBeans and other additional MBeans of their own to make the presence of JMX completely hidden for the developers who want to develop management extensions for GlassFish. This API set is named AMX and usually we use them to develop management rules.</p>
<p><strong><em>2.1 J2EE management (JSR 77)</em></strong></p>
<p>Before we dig into AMX we need to know what JSR 77 is and how it helps us to using JMX and AMX for managing the application server. JSR 77 specification introduces a set of MBeans and services which let any JMX compatible client manage Java EE container’s deployed objects and Java EE services.</p>
<p>The specification defines a set of MBeans which models all Java EE concepts in a hierarchic of MBeans. The specification determines which attributes and operation each MBeans must have and what should be the effect of calling a method on the managed objects. Specification defines a set of events which should be exposed to JMX clients by the MBeans. The specification also defines a set of attributes’ statistics which should be exposed by the JSR 77 MBeans to the JMX client for performance monitoring.</p>
<p>Services and MBeans provided by JSR 77 covers:</p>
<p>Monitoring performance statistics of managed artifacts in the Java EE container. Managed objects like EJBs, Servlets, and so on.</p>
<p>Event subscription for important events of the managed objects like stopping or starting an application.</p>
<p>Managing state of different standard managed objects if the Java EE container like changing an attribute of a JDBC connection pool or underplaying an application.</p>
<p>Navigation between Managed objects.</p>
<p><strong>Managed objects</strong></p>
<p>The artifacts that JSR 77 exposes their management, monitoring to JMX clients include a broad range of Java EE components and services. Figure 5 shows the first level of the Managed objects in the Managed objects hierarchic. As you can see in the figure all objects inherits four attributes which later on will be used to determine whether an object state is manageable, the object provides statistics or the object provide events for its important performed actions.</p>
<p>The objectName attribute which we discussed before has the same use and format, for example amx:j2eeType=X-JDBCConnectionPoolConfig,name=DerbyPool represent a connection pool named DerbyPool in the amx domain, the j2eeType attribute shows the MBean’s type.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_45778vk6jcd_b" alt="" width="503" height="305" /></p>
<p>Figure 5 first level hierarchic of JSR 77 Managed objects which based on the specification must be exposed for JMX management.</p>
<p>Now that you saw how broad the scope of JSR 77 is you ask what the use of these MBeans is and how they work and can be used.</p>
<p>Simple answer is that as soon as a Managed object become live in the application server a corresponding JSR 77 MBeans will get initialized for it by the application server management layer. For example as soon as you create a JDBC connection pool a new MBeans will appear under the JDBCConnectionPoolConfig node of connected JConsole which represent the newly created JDBC connection.  Figure 6 shows the DerbyPool under the JDBCConnectionPoolConfig node in JConsole.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_458fsdxx3fv_b" alt="" width="277" height="408" /></p>
<p>Figure 6 The DerbyPool place under JDBCConnectionPoolConfig node in JConsole</p>
<p>In the figure 5 you can see that we can manage All deployed objects using the JSR 77 exposed MBeans, these objects J2EE applications and modules which are shown in figure A deployed application may have EJB, Web, and any other modules; Glassfish management service will initialize a new insistence of appreciated MBeans for each module in the deployed application. The management service uses ObjectName which we discussed before to uniquely identify each MBean instance and later on we will use this unique name to access each deployed artifact independently.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_459d4tk4ggr_b" alt="" width="504" height="289" /></p>
<p>Figure 7 The specification urge implementation of MBeans to manage all shown deployable objects</p>
<p>Getting lower into the deployed modules we will have Servlets, EJBs and so on. The JSR 77 specification provided MBeans for managing EJBs and Servlets. The EJB MBeans inherit the EJB MBean and includes all necessary attributes and method to manage different types of EJBs. Figure 8 represent the EJB sub classes.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_460cz2cjqhp_b" alt="" width="353" height="224" /></p>
<p>Figure 8 All MBeans related to EJB management in GlassFish application server, based on JSR 77</p>
<p>Java EE resources is one the most colorful area in the Java EE specification and the JSR 77 provides MBeans for managing all standard resources managed bye Java EE containers. Figure 9 shows which types of resources are exposed for management by the JSR 77.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_461ggntkqzc_b" alt="" width="503" height="305" /></p>
<p>Figure 9 Java EE resources manageable by the JSR 77 MBeans</p>
<p>All of Java EE base concepts are covered by the JSR 77 in order to make it possible for the 3rd party management solution developers to integrate Java EE application server management into their solutions.</p>
<p><strong>The events propagated by JSR 77</strong></p>
<p>In the beginning of this section we talked about events that interested parties can receive from JSR 77 MBeans. These events are as follow for different type of JSR 77 MBeans.</p>
<p>J2SEEServer: An event when the corresponding server enters RUNNING, STOPPED, or FAILED state</p>
<p>EntityBean: An event when the corresponding Entity Bean enters RUNNING, STOPPED, or FAILED state</p>
<p>MessageDrivenBean: An event when the corresponding Entity Bean enters RUNNING, STOPPED, or FAILED state</p>
<p>J2EEResource: An event when the corresponding J2EE Resource enters RUNNING, STOPPED, or FAILED state</p>
<p>JDBCResource: An event when the corresponding JDBC data source enters RUNNING, STOPPED, or FAILED state</p>
<p>JCAResource: An event when a JCA connection factory or managed connection factory entered RUNNING, STOPPED, or FAILED state</p>
<p><strong>The monitoring statistics exposed by JSR 77 </strong></p>
<p>The specification urge exposing some statistics related to different Java EE components by JSR 77 MBeans. The required statistics by the specification includes:</p>
<p>Servlet statistics: Servlet related statistics which include Number of currently loaded Servlets; Maximum number of Servlets loaded which were active, and so on.</p>
<p>EJB statistics: EJB related statistics which Include include Number of currently loaded EJBs, Maximum number of live EJBs, and so on.</p>
<p>JavaMail statistics: JavaMail related statistics which Include maximum number of sessions, total count of connections, and so on.</p>
<p>JTA statistics: Statistics for JTA resources which includes successful transactions, failed transactions and so on.</p>
<p>JCA statistics: JCA related statistics which includes both the non-pooled connections and the connection pools associated with the referencing JCA resource.</p>
<p>JDBC resource statistics: JDBC resource related statistics for both non-pooled connections and the connection pools associated with the referencing JDBC resource, connection factory. The statistics include total number of opened and closed connections, maximum number of connections in the pool, and so on. This is really helpful to find connection leak for an specific connection pool.</p>
<p>JMS statistics: The JMS related including statistics for connection session, JMS producer, and JMS consumer.</p>
<p>Application server JVM Statistics: The JVM related statistics. Information like different memory sector size, threading information, class loaders and loaded classes and so on.</p>
<p><strong><em> </em></strong></p>
<p><strong><em>2.2 Remotely accessing JSR 77 MBeans by Java code</em></strong></p>
<p>Include a sample code which shows accessing JSR 77  MBeans from remote location using java code to show how cumbersome it is and how simple AMX made it. // Done</p>
<p>Now that we discussed the details of the JSR 77 MBeans, let’s see how we can access the DerbyPool MBeans from java code and then how we can change an attribute which represent maximum number of connections in the connection pool. Listing 4 show the sample code which will access a GlassFish instance with default port for JMX listener (the default port is 8686)</p>
<p><strong>Listing 4 Accessing a JSR 77 MBean for changing DerbyPool’s </strong><strong>MaxPoolSize</strong> <strong>attribute.</strong></p>
<p>public class RemoteClient {</p>
<p>private MBeanServerConnection mbsc = null;</p>
<p>private ObjectName derbyPool;</p>
<p>public static void main(String[] args) {</p>
<p>try {</p>
<p>RemoteClient client = new RemoteClient(); #A</p>
<p>client.connect();                          #B</p>
<p>client.changeMaxPoolSize();              #c</p>
<p>} catch (Exception e) {</p>
<p>e.printStackTrace();</p>
<p>}</p>
<p>}</p>
<p>private void connect() throws Exception {</p>
<p>JMXServiceURL jmxUrl =</p>
<p>new JMXServiceURL(&#8220;service:jmx:rmi:///jndi/rmi://127.0.0.1:8686/jmxrmi&#8221;); #1</p>
<p>Map env = new HashMap();</p>
<p>String[] credentials = new String[]{&#8220;admin&#8221;, &#8220;adminadmin&#8221;};</p>
<p>env.put(JMXConnector.CREDENTIALS, credentials);              #2</p>
<p>JMXConnector jmxc =</p>
<p>JMXConnectorFactory.connect(jmxUrl, env);             #3</p>
<p>mbsc = jmxc.getMBeanServerConnection();                     #4</p>
<p>}</p>
<p>private void changeMaxPoolSize() throws Exception {</p>
<p>String query = &#8220;amx:j2eeType=X-JDBCConnectionPoolConfig,name=DerbyPool&#8221;;</p>
<p>ObjectName queryName = new ObjectName(query);             #5</p>
<p>Set s = mbsc.queryNames(queryName, null);                   #6</p>
<p>derbyPool = (ObjectName) s.iterator().next();</p>
<p>mbsc.setAttribute(derbyPool, new Attribute(&#8220;MaxPoolSize&#8221;, new Integer(64)));                                                   #7</p>
<p>}</p>
<p>}</p>
<p><strong>#A initiate an instance of the class</strong></p>
<p><strong>#B get the JMX connection</strong></p>
<p><strong>#C change the attribute’s value</strong></p>
<p>At #1 we create a URL to GlassFish JMX service. At #2 we prepared the credentials which we should provide for connecting to the JMX service. At #3 we initialize the connector. At #4 we create a connection to GlassFish’s MBean server. At #5 we query the registered MBeans for an MBean similar to our DerbyPool MBean. At #6 we get the result of the query inside a set. We are sure that we have an MBean with the give name otherwise we should have checked to see whether the set is empty or not. At #7 we just change the attribute. You can check the attribute in JConsole and you will se that it change in the JConsole as well.</p>
<p>In the sample code we just update the DerbyPool’s maximum number of connections to 64. it can be counted as one of the simplest task related to JSR 77, management, and using JMX. Using plain JMX for a complex task will overhaul us with many lines of complex reflection based codes which are hard to maintain and debug.</p>
<p><strong><em>2.3 Application Server Management eXtension (AMX)</em></strong></p>
<p>Now that you see how hard it is to work with JSR 77 MBeans I can tell you that you are not going to use JSR 77 MBeans directly in your management applications, although you can.</p>
<p><strong>What is AMX</strong></p>
<p>In The AMX APIs java.lang.reflect.proxy is used to generate Java objects which implement the various AMX interfaces. Each proxy internally stores the JMX ObjectName of a server-side JMX MBean who’s MBeanInfo corresponds to the AMX interface implemented by the proxy.</p>
<p>So, in the same time we have JMX MBeans for using trough any JMX compliant management software and we have the AMX dynamic proxies to use them as easy to use local objects for managing the application server.</p>
<p>The GlassFish administration architecture is based on the concept of administration domain. An administration domain is responsible for managing multiple resources which are based on the same administration domain.  A resource can be a cluster of multiple GlassFish instances, a single GlassFish instance, and a JDBC connection pool inside the instance and so on. Hundreds of AMX interfaces are defined to proxy all of the GlassFish managed resources which themselves are defined as JSR 77 MBeans for client side access. All of these interfaces are placed under com.sun.appserv.management package.</p>
<p>There are several benefits in AMX dynamic proxies over the JMX MBeans, which are as follow:</p>
<p>Strongly typed methods and attributes for compile time type checking</p>
<p>Structural consistency with both the domain.xml configuration files.</p>
<p>Consistent and structured naming for methods, attributes and interfaces.</p>
<p>Possibility to navigate from a leaf AMX bean up to the DAS.</p>
<p><strong> </strong></p>
<p><strong>AMX</strong> <strong>MBeans</strong></p>
<p>AMXdefines different types of MBean for different purposes or reasons, namely, configuration MBeans, monitoring MBeans, utility MBeans and JSR 77 MBeans. All AMX MBeans shares some common characteristics including:</p>
<p>They all implement the com.sun.appserv.management.base.AMX interface which contains methods and fields for checking the interface type, group, reaching its container and its root domain.</p>
<p>They all have a j2eeType and name property within their ObjectName. The j2eeType attribute specifies the interface we are dealing with.</p>
<p>All MBeans that logically contain other MBeans implement the com.sun.appserv.management.base.Container interface. Using the container interface we can navigate from a leaf AMX Bean to the DAS and vice-versa. For example by having the domain AMX Bean we can get a list of all connection pools or EJB modules in deployed in the domain.</p>
<p>JSR 77 MBeans that have a corresponding configuration or monitoring peer expose it using getConfigPeer or getMonitoringPeer. However; there are many configuration and monitoring MBeans that do not correspond to JSR 77 MBeans.</p>
<p><strong> </strong></p>
<p><strong>Configuration MBeans</strong></p>
<p>We discussed that there are several types of MBeans in the AMX framework, one of them is the configuration MBeans. Basically these MBeans represent domain.xml and other configuration file content and structure.</p>
<p>In GlassFish all configuration information are stored in one central repository named DAS, in a single instance installation the instance act as DAS and in a clustered installation the DAS responsibility is sole taking care of the configuration and propagating it to all instances. The information stored in the repository are exposed to any interested party like an administration console trough AMX interfaces.</p>
<p>Any developer with familiarity with domain.xml structure will find him very comfortable with configuration interfaces.</p>
<p><strong>Monitoring MBeans</strong></p>
<p>Monitoring MBeans provide transient monitoring information about all the vital components</p>
<p>of the Application Server. A monitoring interface can either provides statistics or not and if it provides statistics it should implements the MonitoringStats interface which is JSR 77 compliant interface for providing statistics.</p>
<p><strong>Utility</strong> <strong>MBeans</strong></p>
<p>UtilityMBeans provide commonly used services to the Application Server. These MBeans all extend either or both of the Utility and Singleton interfaces. All of these MBeans interface are located in com.sun.appserv.management.base package. Notable utility MBeans are listed in table 1</p>
<p>Table 1 AMX Utility MBeans along with description</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<p><strong>MBean interface</strong></td>
<td>
<p><strong>description</strong></td>
</tr>
<tr>
<td>
<p>SystemInfo</td>
<td>
<p>Provides information about application server capabilities like clustering support</td>
</tr>
<tr>
<td>
<p>QueryMgr</td>
<td>
<p>Provides JMX-like queries which are restricted to AMX MBeans.</td>
</tr>
<tr>
<td>
<p>BulkAccess</td>
<td>
<p>Provides network-efficient “bulk” calls whereby many Attributes or Operations in many MBeans may be fetched and invoked in one invocation, thus minimizing network overhead.</td>
</tr>
<tr>
<td>
<p>NotificationService</td>
<td>
<p>Provides buffering and selective dynamic listening for Notifications on AMX MBeans.</td>
</tr>
<tr>
<td>
<p>UploadDownloadMgr</td>
<td>
<p>Supports uploading and downloading of files to/from the application server.</td>
</tr>
</tbody>
</table>
<p><strong>Java EE Management</strong> <strong>MBeans</strong></p>
<p>The Java EE management MBeans implement, and in some cases extend, the management</p>
<p>Hierarchy as defined by JSR 77, which specifies the management model for the whole Java EE platform. All JSR 77 MBeans in the AMX domain offer access to configuration and monitoring MBeans using the getMonitoringPeer and getConfigPeer methods.</p>
<p><strong>Dynamic Client Proxies</strong></p>
<p>Dynamic Client Proxies are an important part of the AMX API, and enhance ease-of-use for the programmer. JMX MBeans can be used directly by an MBeanServerConnection to the server. However, client proxies greatly simplify access to Attributes and operations on MBeans, offering get/set methods and type-safe invocation of operations. Compiling against the AMX interfaces means that compile-time checking is performed, as opposed to server-side runtime checking, when invoked generically through MBeanServerConnection.</p>
<p>See the API documentation for the com.sun.appserv.management package and its sub-packages for more information about using proxies. The API documentation explains the use of AMX with proxies. If you are using JMX directly (for example, by using MBeanServerConnection), the return type, argument types, and method names might vary as needed for the difference between a strongly-typed proxy interface and generic MBeanServerConnection or ObjectName  interface.</p>
<p><strong>Changing the DerbyPool attributes using AMX</strong></p>
<p>In listing 4 you saw how we can use JMX and pure JSR 77 approach to change the attributes of a JDBC connection pool, in this part we are going to perform the same operation using AMX to see how much easier and more effective the AMX is.</p>
<p><strong>Listing 5 Using AMX to change DerbyPool MaxPoolSize attribute</strong></p>
<p>AppserverConnectionSource appserverConnectionSource = new AppserverConnectionSource(AppserverConnectionSource.PROTOCOL_RMI, &#8220;127.0.0.1&#8243;, 8686, &#8220;admin&#8221;, &#8220;adminadmin&#8221;,null,null);              #1</p>
<p>DomainRoot dRoot = appserverConnectionSource.getDomainRoot(); #2</p>
<p>JDBCConnectionPoolConfig cpConf= dRoot.getContainee(XTypes.JDBC_CONNECTION_POOL_CONFIG, &#8220;DerbyPool&#8221;); #3</p>
<p>cpConf.setMaxPoolSize(&#8220;100&#8243;);            #4</p>
<p>You are not mistaking it with another idea or code, that four lines of code let us change the maximum pool size of the DerbyPool.</p>
<p>At #1 we create a connection to the server that we want to perform our management operation on it. Several protocols can be used to connect to the application server management layer. As you can se when we construct the appserverConnectionSource  instance we used AppserverConnectionSource.PROTOCOL_RMI as the communication protocol to ensure that we will not need some JAR files from OpenPDK project. Two other protocols which we can use are AppserverConnectionSource.PROTOCOL_HTTP and AppserverConnectionSource.PROTOCOL_JMXMP. The connection that we made does not uses TLS, but we can use TLS to ensure transport security.</p>
<p>At #2 we get the AMX domain root which later on let us navigate between all AMX leafs which are servers, clusters, connection pools, and listeners and so on.  At #3 we query for an AMX MBean which its name is DerbyPool and its j2eeType is equal to XTypes.JDBC_CONNECTION_POOL_CONFIG. At #4 we set a new value for the attribute of our choice which is MaxPoolSize attribute.</p>
<p><strong>Monitoring GlassFish using AMX</strong></p>
<p>The monitoring term comes to the developers and administrators mind whenever they are dealing with performance tuning, but monitoring can also be used for management purposes like automation of specific tasks which without automation need an administrator to take care of it. An example of these types of monitoring is critical condition notifications which can be send either via email or SMS or any other gateway which the administrators and system managers prefer.</p>
<p>Imagine that you have a system running on top of GlassFish and you want to be notified whenever acquiring connections from a connection pool named DerbyPool is taking longer than 35 seconds.</p>
<p>You also want to store all information related to the connection pool when the pool is closing to saturate. For example when there are only 5 connections to give away before the pool get saturated.</p>
<p>So we need to write an application which monitor the GlassFish connection pool, check its statistics regularly and if the above criteria meets, our application should send us an email or an SMS along with saving the connection pool information.</p>
<p>AMX, provides us with all required means to monitor the connection pool and be notified when any connection pool attributes or any of its monitoring attributes changes so we will just use our current AMX knowledge along with two new concepts about the AMX.</p>
<p>The first concept that we will use is AMX monitoring MBeans which provides us with all statistics about the Managed Objects that they monitor. Using the AMX monitoring MBeans is the same as using other AMX MBeans like the connection pool MBean.</p>
<p>The other concept is the notification mechanism which AMX provides on top of already established JMX notification mechanism. The notification mechanism is fairly simple, we register our interest for some notification and we will receive the notifications whenever the MBeans emit a notification.</p>
<p>We know that we can configure GlassFish to collect statistics about almost all Managed Objects by changing the monitoring level from OFF to either LOW or HIGH. In our sample code we will change the monitoring level manually using our code and then use the same statistics that administration console shows to check for the connection pool consumed connections.</p>
<p>Listing 6 shows sample applications which monitor DerbyPool and notify the administrator whenever acquiring connection take longer than accepted. The application saves all statistics information when the connection pool gets close to its saturation.</p>
<p><strong>Please Replace the numbers with cueballs</strong></p>
<p><strong>Listing 6 monitoring a connection pool and notifying the administrator when connection pool is going to reach the maximum size</strong></p>
<p>public class AMXMonitor implements NotificationListener {      #1</p>
<p>AttributeChangeNotificationFilter filter;                                          #2</p>
<p>AppserverConnectionSource appserverConnectionSource;</p>
<p>private int cPoolSize;</p>
<p>private DomainRoot dRoot;</p>
<p>JDBCConnectionPoolMonitor derbyCPMon;                                          #3</p>
<p>JDBCConnectionPoolConfig cpConf;</p>
<p>private void initialize() {</p>
<p>try {</p>
<p>appserverConnectionSource = new AppserverConnectionSource(AppserverConnectionSource.PROTOCOL_RMI, &#8220;127.0.0.1&#8243;, 8686, &#8220;admin&#8221;, &#8220;adminadmin&#8221;, null, null);</p>
<p>dRoot = appserverConnectionSource.getDomainRoot();</p>
<p>Set&lt;String&gt; stpr = dRoot.getDomainConfig().getConfigConfigMap().keySet();             #4</p>
<p>ConfigConfig conf=     dRoot.getDomainConfig().getConfigConfigMap().get(&#8220;server-config&#8221;); #4</p>
<p>conf.getMonitoringServiceConfig().getModuleMonitoringLevelsConfig().setJDBCConnectionPool(ModuleMonitoringLevelValues.HIGH); #4</p>
<p>cpConf = dRoot.getContainee(XTypes.JDBC_CONNECTION_POOL_CONFIG, &#8220;DerbyPool&#8221;);</p>
<p>cPoolSize = Integer.getInteger(cpConf.getMaxPoolSize());</p>
<p>filter = new AttributeChangeNotificationFilter();         #2</p>
<p>filter.enableAttribute(&#8220;ConnRequestWaitTime_Current&#8221;);       #2</p>
<p>filter.enableAttribute(&#8220;NumConnUsed_Current&#8221;);             #2</p>
<p>Set&lt;JDBCConnectionPoolMonitor&gt; jdbcCPM =</p>
<p>dRoot.getQueryMgr().queryJ2EETypeSet</p>
<p>(XTypes.JDBC_CONNECTION_POOL_MONITOR);                           #5</p>
<p>for (JDBCConnectionPoolMonitor mon : jdbcCPM) {</p>
<p>if (mon.getName().equalsIgnoreCase(&#8220;DerbyPool&#8221;)) {</p>
<p>derbyCPMon = mon;</p>
<p>break;</p>
<p>}</p>
<p>}</p>
<p>derbyCPMon = dRoot.getContainee(XTypes.JDBC_CONNECTION_POOL_MONITOR, &#8220;DerbyPool&#8221;);   #5</p>
<p>derbyCPMon.addNotificationListener(this, filter, null);  #5</p>
<p>} catch (Exception ex) {</p>
<p>ex.printStackTrace();</p>
<p>}</p>
<p>}</p>
<p>public void handleNotification(Notification notification, Object handback) {</p>
<p>AttributeChangeNotification notif = (AttributeChangeNotification) notification;                                                                                                    #6</p>
<p>if (notif.getAttributeName().equals(&#8220;ConnRequestWaitTime_Current&#8221;)) {</p>
<p>int curWaitTime = Integer.getInteger((String) notif.getNewValue());                                                                                    #7</p>
<p>if (curWaitTime &gt; 3500) {</p>
<p>saveInfoToFile();</p>
<p>sendNotification(&#8220;Current wait time is: &#8221; + curWaitTime);</p>
<p>}</p>
<p>} else {</p>
<p>int curPoolSize = Integer.valueOf((String) notif.getNewValue());                                                        #8</p>
<p>if (curPoolSize &gt; cPoolSize &#8211; 5) {</p>
<p>saveInfoToFile();</p>
<p>sendNotification(&#8220;Current pool size is: &#8221; + curPoolSize);</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>private void saveInfoToFile() {</p>
<p>try {</p>
<p>FileWriter fw = new FileWriter(new File(&#8220;stats_&#8221; + (new Date()).toString()) + &#8220;.sts&#8221;);</p>
<p>Statistic[] stats = derbyCPMon.getStatistics(derbyCPMon.getStatisticNames()); #9</p>
<p>for (int i = 0; i &lt; stats.length; i++) {</p>
<p>fw.write(stats[i].getName() + &#8221; : &#8221; + stats[i].getUnit()); #10</p>
<p>}</p>
<p>} catch (IOException ex) {</p>
<p>ex.printStackTrace();</p>
<p>}</p>
<p>}</p>
<p>private void sendNotification(String message) {</p>
<p>}</p>
<p>public static void main(String[] args) {</p>
<p>AMXMonitor mon = new AMXMonitor();</p>
<p>mon.initialize();</p>
<p>}</p>
<p>}</p>
<p>At #1 we implement the NotificationListener interface as we are going to use the JMX notification mechanism. At #2 we define an AttributeChangeNotificationFilter which filter the notifications to a subset that we are interested. We also add the attributes that we are interested to the set of non-filtered attribute change notification. At #3 we define and initialize an AMX MBeans which represent DerbyPool monitoring information.  We will get an instance not found exception the connection pool had no activities yet. At #4 we change the monitoring level of JDBC connection pools to ensure that GlassFish gather the required statistics. At #5 we find our designated connection pool monitoring MBean and add a new filtered listener to it.</p>
<p>The handleNotification method is the only method in the NotificationListener interface which we need to implement. At #6 we convert the received notification to AttributeChangeNotification as we know that the notification is of this type. At #7 we are dealing with change in the ConnRequestWaitTime_Current attribute. We get its new value to check for our condition. In the same time we can get the old value if we are interested. At #8 we are dealing with NumConnUsed_Current attribute and later on with calling the saveToFile method and sendNotification methods.</p>
<p>At #9 we get names of all connection pool monitoring factors and at #10 we just write the monitoring attribute’s name along with its value to a text file.</p>
<p><strong>AMX and Dotted Names</strong></p>
<p>AMX is designed with ease of use and efficiency in mind. So in addition to using standard JMX programming model, the getters and setters, we can use another hierarchical model to access all AMX MBeans attributes. In the dotted named model each attribute of an MBean starts from its root which is either the domain for all configuration MBeans and server for all runtime MBeans. For example domain.resources.jdbc-connection-pool.DerbyPool.max-pool-size represents the maximum pool size for the DerbyPool which we discussed before.</p>
<p>Two interfaces are provided to access the dotted names either for monitoring or for management and configuration purposes. The MonitoringDottedNames is provided to assists with reading an attribute. The other interface is ConfigDottedNames which provides writing access to attributes using the dotted format. We can get an instance of its implementation using dRoot.getMonitoringDottedNames().</p>
<p><strong><em>3 GlassFish Management Rule</em></strong></p>
<p>The above sample application is promising especially when you want to have tens or rules for automatic management, but running a separate process and watching that process is not in taste of many administrators. GlassFish application server provides an very effective way to deploy such management rules into GlassFish application server for sake of simplicity and integration. Benefits and use cases of the Management Rules can be summarized as follow:</p>
<p>Manage complexity by self-configuring based on the conditions</p>
<p>Keep administrators free for complex tasks by automating mundane management tasks</p>
<p>Improve performance by self-tuning in unpredictable run-time conditions</p>
<p>Automatically adjusting the system for availability by preventing problems and recovering from one (self healing)</p>
<p>Enhancing security measures by taking self-protective actions when security threats are detected</p>
<p>A GlassFish Management Rule is a set of:</p>
<p>Event: An event uses the JMX notification mechanism to trigger actions. Events can range from an MBean attribute change to specific log messages.</p>
<p>Action: Actions are associated with events and are triggered when related events happen. Actions can be MBeans that implement the NotificationListener interface.</p>
<p>When we deploy a Management Rule into GlassFish, GlassFish will register our MBean in the MBean server and register its interests for the notification type that we determined. Therefore, upon any event which our MBean is registered for, the handleNotification method of our MBeans will execute. GlassFish provides some pre-defined types of events which we can choose to register our MBean’s interest. These events are as follow:</p>
<p>Monitor events: These types of events trigger an action based on an MBean attribute change.</p>
<p>Notification events: Every MBean which implements the NotificationBroadcaster interface can be source of this event type.</p>
<p>System events: This is a set of predefined events that come from the internal infrastructure of GlassFish application server. These events include: lifecycle, log, timer, trace, and cluster events.</p>
<p>Now, let’s see how we can achieve a similar functionality that our AMXMonitor application provides from The GlassFish Management Rules. First we need to change our application to a mere JMX MBean which implements NotificationListener interface and perform required action which is, for example, sending an email or SMS, in the handleNotification method.</p>
<p>Changing the application to MBean should be very easy; we just need to define an MBean interface and then the MBean implementation which will just implement one single method, the handleNotification method.</p>
<p>Now that we have our MBeans compiled JAR file, we can deploy it using the administration console. So open the GlassFish administration console, navigate to the Custom MBeqns node and deploy the MBeans by providing the path to the JAR file and the name of the MBeans implementation class. Now that we have our MBeans deployed into GlassFish, it is available for the class loader to be used as an action for a Management Rule, so in order to create the Management Rule, use the following procedure.</p>
<p>In the navigation tree select Configuration node, select Management Rules node. In the content panel select New and user dcpRule as the name, make sure that you teak the enabled checkbox, select monitor in the event type combo box and let the events to be recorded in the log files, press next to navigate to the second page of the wizard.</p>
<p>In the second page, for the Observed MBean field enter amx:X-ServerRootMonitor=server,j2eeType=X-JDBCConnectionPoolMonitor,name=DerbyPool and for the observed attribute enter ConnRequestWaitTime_Current. For the monitor type select counter. The number type is int and the initial threshold is 35000 which indicate the number which if the monitored attribute exceed, our action will start.</p>
<p>Scroll down and for the action, select AMXMonitor which is the name of our MBean which we deployed in previous step.</p>
<p>You saw that the overall process is fairly simple, but there are some limitations like possibility to monitor one single MBean and attribute at a time. Therefore we need to create another Management Rule for NumConnUsed_Current attribute.</p>
<p>Now that we reached to the end of this article, you should be fairly familiar with JMX, AMX and GlassFish Management Rules. In next articles we will use the knowledge that we gained here to create administration commands and create monitoring solutions.</p>
<p><strong><em>4 Summary </em></strong></p>
<p>We toughly discussed managing GlassFish using Java code by discussing JMX which is the foundation of all Java based management solutions and framework. We discussed JMX architecture, event model and different types of MBeans which are included in the JMX programming model. We also covered AMX as the GlassFish way providing its management functionalities to client side applications which are not interested in using complicated JMX APIs.</p>
<p>We discussed GlassFish management using AMX APIs to show how much simpler the AMX is when we compare it to the plain JMX implementation and we covered GlassFish monitoring using the AMX APIs.</p>
<p>You saw how we can use GlassFish’s Self management and self administration functionalities to automate some tasks to keep administrators free from dealing with low level repetitive administration and management tasks.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/manage-administrate-and-monitor-glassfish-v3-from-java-code-using-amx-jmx/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Oracle is NOT taking back OpenSolaris, ZDNet Dana Blankenhorn got it wrong.</title>
		<link>http://kalali.me/oracle-is-not-taking-back-opensolaris-zdnet-dana-blankenhorn-got-it-wrong/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=oracle-is-not-taking-back-opensolaris-zdnet-dana-blankenhorn-got-it-wrong</link>
		<comments>http://kalali.me/oracle-is-not-taking-back-opensolaris-zdnet-dana-blankenhorn-got-it-wrong/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 14:45:15 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[OpenSolaris]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Sun]]></category>
		<category><![CDATA[FUD]]></category>
		<category><![CDATA[ZDNet]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=360</guid>
		<description><![CDATA[Once again the FUD around Solaris and OpenSolaris fate started to spread after Dana Blankenhorn misunderstood the licensing terms and used a eye catching and visitor increasing title, Oracle taking back OpenSolaris, for his blog entry. Well, from this article we can get that even the veteran writers can get things wrong and spread incorrect [...]]]></description>
			<content:encoded><![CDATA[<p>Once again the FUD around Solaris and OpenSolaris fate started to spread after Dana Blankenhorn misunderstood the licensing terms and used a eye catching and visitor increasing title, <a href="http://blogs.zdnet.com/open-source/?p=6154">Oracle taking back OpenSolaris</a>, for his blog entry. Well, from this article we can get that even the veteran writers can get things wrong and spread incorrect news <img src='http://kalali.me/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Folks, Solairs is one of the biggest Sun assets that Oracle is now own by taking over Sun . Solaris and OpenSolaris are going to be around in a much better shape than before because Oracle is betting its fight for the market share on this operating system to form a complete stack including storage, hardware, OS, middle-ware, support and so on.</p>
<p>Oracle may change the licensing terms for the Solaris OS, which is the <em>Commercial</em> distribution of OpenSolaris (with some added/ removed components) supported by Sun in old era, but to close the OpenSolaris code-base, no way. Changing the licensing terms can be result of Oracle seeking a higher revenue stream from the product and I bet Oracle will be able to get more out of Solaris than Sun because of its powerful marketing department <img src='http://kalali.me/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p>
<p>Looking at the these FUD from any angel tells you that they are not correct because of at least the following reasons:</p>
<p style="-qt-block-indent: 1;">
<ul>
<li>OpenSolaris has a large community around it which Oracle do not like to send away.</li>
<li>The Solaris/ OpenSolaris adoption highly increased after Sun pushed the source codes into OpenSolaris project. The whole Solaris on Z architecture, adoption of OpenSolaris increased so adoption of Solaris itself. Long story short, just take a look at <a title="http://www.genunix.org/" href="http://www.genunix.org/">http://www.genunix.org/</a> and <a title="http://hub.opensolaris.org/bin/view/Main/downloads" href="http://hub.opensolaris.org/bin/view/Main/downloads">http://hub.opensolaris.org/bin/view/Main/downloads</a> to see how many active distributions are based on OpenSolaris core.</li>
<li>Solaris/ OpenSolaris is more important to Oracle to let it fall apart  because it has a lot to offer in Oracle strategy of offering end to end stack of its own.</li>
</ul>
<p>People are talking about why the 2010.3 release is not released when it is already first days of April, the answer is &#8220;A few more weeks of development and testing will gives us a more stable OS&#8221; if you want to check the latest features which will be included in the 2010.3, grab the latest build (which is build 134 right now) from <a title="http://www.genunix.org/dist/indiana/" href="http://www.genunix.org/dist/indiana/">http://www.genunix.org/dist/indiana/</a> and play with it, but keep it in mind the build is not production ready yet. If you want the source code of OpenSolaris, take a look at <a title="http://hub.opensolaris.org/bin/view/Main/get" href="http://hub.opensolaris.org/bin/view/Main/get">http://hub.opensolaris.org/bin/view/Main/get</a> to get the source code and build the OS yourself.</p>
<p>I am wondering what these people are getting from spreading wrong words and incorrect news about thins they have no clue about. Folks, Solaris OS is not OpenSolaris. OpenSolaris is CCDL licensed (except for some parts which are not CCDLed (<a title="http://hub.opensolaris.org/bin/view/Main/no_source" href="http://hub.opensolaris.org/bin/view/Main/no_source">http://hub.opensolaris.org/bin/view/Main/no_source</a>)  while the Solaris distribution contains some of OpenSolaris components and features. some value added components and well along with some license/ distribution fees and first class support from Oracle.</p>
<p>Well, it was my personal feelings about the whole issue of OpenSolaris/ Solaris FUDs flying around.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/oracle-is-not-taking-back-opensolaris-zdnet-dana-blankenhorn-got-it-wrong/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GlassFish Modularity System, How extend GlassFish CLI and Web Administration Console (Part 2: Developing Sample Modules)</title>
		<link>http://kalali.me/glassfish-modularity-system-how-extend-glassfish-cli-and-web-administration-console-part-2-developing-sample-modules/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=glassfish-modularity-system-how-extend-glassfish-cli-and-web-administration-console-part-2-developing-sample-modules</link>
		<comments>http://kalali.me/glassfish-modularity-system-how-extend-glassfish-cli-and-web-administration-console-part-2-developing-sample-modules/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 04:22:50 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Modularity]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Administration Console]]></category>
		<category><![CDATA[extend]]></category>
		<category><![CDATA[Module]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=358</guid>
		<description><![CDATA[Extending GlassFish CLI and Administration Console, Developing the sample Modules Administrators are always looking for a more effective, easier to use, and less time consuming tool to use as the interface sitting between them and what they supposed to administrate and manage. GlassFish provide effective, easy to access and easy to simple to navigate in [...]]]></description>
			<content:encoded><![CDATA[<p><em>Extending GlassFish CLI and Administration Console, Developing the sample Modules </em></p>
<p>Administrators are always looking for a more effective, easier to use, and less time consuming tool to use as the interface sitting between them and what they supposed to administrate and manage. GlassFish provide effective, easy to access and easy to simple to navigate in administration channels which cover all day to day tasks that administrators need to perform. But when it comes to administration, administrators usually write their own shell scripts to automate some tasks; they use CRON or other schedulers to schedule automatic tasks, and so on to achieve their own customized administration flow.</p>
<p>By using GlassFish console, it is simply possible to use shell scripts, or CRON to further extends the administration and facilitate the daily tasks. But sometimes it is far better to have a more sophisticated and mature way to extend and customize the administration interfaces. GlassFish provides all necessary interfaces and required services to allow administrators or developers to develop new modules for GlassFish administration interfaces to add a new feature or enhance already available capabilities.</p>
<p>GlassFish administration channels extendibility is not only for easing the administrator tasks to customize the administration interfaces, but also it is present to let container developers develop administration interfaces for their containers fully integrated with already available interfaces and fully compatible with the present administration console look and feels. Using administration console extendibility developers can develop new administration console commands very easily by utilizing already available services and dependency injection which provide them with all available environmental objects that they need.</p>
<p>This article covers how we can develop new commands for the CLI console and how we can develop new modules to add some new pages and navigation nodes to web administration console.</p>
<p><strong><em>1 CLI console extendability </em></strong></p>
<p>GlassFish CLI can be considered the easiest to accesses administration console for experienced administrators as they are better the keyboard and like automated and scripted tasks instead of clicking the mouse in a web page to see the result.  Not only GlassFish CLI is very command and feature rich, but also its design is based on the same modularity concepts that the whole application server is based on.</p>
<p>CLI modularity is very helpful for those who wants to extends GlassFish by providing new set of commands for their container, deploying new monitoring probes and providing the corresponding CLI commands for accessing the monitoring information,  developing new commands which may be required by administrators and are not already in place, and so on.</p>
<p><strong><em>1.1 Prepare your development environment</em></strong></p>
<p>This is a hands on article which involve us with developing some new modules for GlassFish application server and deploying the modules to GlassFish application server, therefore we should be able to compile the modules which usually uses HK2 services in the inside and are bundled as OSGI bundle for the deployment.</p>
<p>Although we can use an IDE like NetBeans to build the sample codes but we are going to use a more IDE agnostic way like using Apache Maven to ensure that we can simply manage the dependency hurdle and make the sample codes easily imported to IDE of your choice. Get Maven from <a href="http://maven.apache.org/download.html">http://maven.apache.org/download.html</a> and install it according to the installation instruction provided in the same page. Then you are ready to further dig into developing modules.</p>
<p><strong><em>1.2 CLI modularity and extendibility </em></strong></p>
<p>We discussed about how GlassFish utilize OSGI and HK2 for providing a modular architecture, one place which this modular architecture shows itself is CLI modularity. We know that all extendibility point in GlassFish are based on contracts and contracts providers which in simple though there are interfaces and interface implementation along with some annotation to mark and further configure the contract implementation.</p>
<p>We are talking about adding new commands to CLI dynamically by placing an OSGI bundle in the module directory of GlassFish, either the module just contains CLI commands or it contains CLI commands, web based administration console pages, and a container implementation. So, at first there is no predefined list of known commands and commands loads on-demand and as soon as you try to use one of them. For example when you issue ./asadmin list-commands CLI framework will check for all provider which implements the admin command contract and shows the list by extracting the information from each provider (implementation). CLI commands can use dependency injection provided by HK2 and also each command may extract some information and provide them to other components which might be interested in using them.</p>
<p>Like all providers in the GlassFish modularity system, we should annotated each command implementation using @Service annotation to ensure that HK2 will treat the implementation as a service for lifecycle management and service locating. CLI commands like any other HK2 service should have a scope which determines how the lifecycle of the command is managed by HK2.  Usually we should ensure that each command is just live in the context of its execution and not beyond that context. Therefore we annotate each command with a correct scope like PerLookup.class scope which result in initiating a command in each lookup.</p>
<p>All that we need to know for developing CLI commands is summarized in understanding some interfaces and helper classes.  Other required knowledge is around the AMX and HK2.</p>
<p>Each CLI command must implements a contract which is an interface named org.jvnet.hk2.annotations.Contract.AdminCommand which is shown in listing 1.</p>
<p><strong>Listing 1 The AdminCommand interface which any CLI command have to implement</strong></p>
<p><code><br />
@Contract                                           #1<br />
public interface AdminCommand {<br />
public void execute(AdminCommandContext context);            #2<br />
}</p>
<p></code></p>
<p>The AdminCommand interface has one method which is called by asadmin utility when we call the associated command. At #1 we define the interface as a contact which HK2 service providers can implements. At #2 we have the execute method which accept a argument of type org.glassfish.api.admin.AdminCommandContext which is shown in listing 2. This class is a set of utilities which allows developer to have access to some contextual variables like reporting, logging, and command parameters which the last one will be deprecated.</p>
<p><strong>Listing 2 The </strong><strong>AdminCommandContext </strong><strong>class</strong><strong> which is a bridge between inside the command and outside the command execution context</strong></p>
<p><code><br />
public class AdminCommandContext implements ExecutionContext {</p>
<p>public  ActionReport report;<br />
public final Properties params;<br />
public final Logger logger;<br />
private List&lt;File&gt; uploadedFiles;</p>
<p>public AdminCommandContext(Logger logger, ActionReport report, Properties params) {<br />
this(logger, report, params, null);<br />
}</p>
<p>public AdminCommandContext(Logger logger, ActionReport report, Properties params,<br />
List&lt;File&gt; uploadedFiles) {<br />
this.logger = logger;<br />
this.report = report;<br />
this.params = params;<br />
this.uploadedFiles = (uploadedFiles == null) ? emptyFileList() : uploadedFiles;<br />
}</p>
<p>private static List&lt;File&gt; emptyFileList() {<br />
return Collections.emptyList();<br />
}</p>
<p>public ActionReport getActionReport() {<br />
return report;<br />
}</p>
<p>public void setActionReport(ActionReport newReport) {<br />
report = newReport;<br />
}</p>
<p>public Properties getCommandParameters() {<br />
return params;<br />
}</p>
<p>public Logger getLogger() {<br />
return logger;<br />
}</p>
<p>public List&lt;File&gt; getUploadedFiles() {<br />
return uploadedFiles;<br />
}<br />
}</p>
<p></code></p>
<p>The only unfamiliar class is the org.glassfish.api.ActionReport abstract class which has several sub classes that allow us as CLI command developers to report the result of our command execution to the original caller. Several sub classes are defined to make it possible to report back the result of the execution in different environment like returning an HTML, JSON or plain text report about the execution. The report may include exit code, possible exceptions, failure or the success, and so on based on the reporter type. Important sub classes of the ActionReport are listed in table 1</p>
<p>Table 1 all available reporters which can be used to report the result of a command execution</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<p><strong>Reporter class</strong></td>
<td>
<p><strong>Description</strong></td>
</tr>
<tr>
<td>
<p>HTMLActionReporter</td>
<td>
<p>Generate an HTML document containing report information</td>
</tr>
<tr>
<td>
<p>JsonActionReporter</td>
<td>
<p>A JSON document containing the report information</td>
</tr>
<tr>
<td>
<p>PlainTextActionReporter</td>
<td>
<p>A plain text report which provides necessary report information as plain text</td>
</tr>
<tr>
<td>
<p>PropsFileActionReporter</td>
<td>
<p>A properties file containing all report elements</td>
</tr>
<tr>
<td>
<p>SilentActionReport</td>
<td>
<p>No report at all</td>
</tr>
<tr>
<td>
<p>XMLActionReporter</td>
<td>
<p>A machine readable XML document containing all report elements</td>
</tr>
</tbody>
</table>
<p>All of these reporters except the SilentActionReport which is placed inside org.glassfish.embed.impl are placed in the com.sun.enterprise.v3.common package.</p>
<p>Now we need a way to pass some parameters to our command, determine which parameters are necessary and which one are optional, which one need argument and what should be the type of the argument. There is an annotation which let us annotate properties of the AdminCommand implementation class to mark them as parameters. The annotation which we should use to mark a property as a parameter is @Param and is placed in org.glassfish.api package.</p>
<p><strong>Listing 3 The Parameters annotation which we can use to have a parameterized CLI command</strong></p>
<p><code><br />
@Retention(RUNTIME)<br />
@Target({METHOD,FIELD})<br />
public @interface Param {<br />
public String name() default "";<br />
public String acceptableValues() default "";<br />
public boolean optional() default false;<br />
public String shortName() default "";<br />
public boolean primary() default false;<br />
}<br />
</code></p>
<p>As you can see, the annotation can be place either on a setter method or on a filed. Annotation has several elements including the parameter name which by default is the same as the property name, a list of comma separated acceptable values, the short name for the parameter, whether the parameter is optional or not and finally whether the parameter name is required to be included or not.  In each command only one parameter can be primary.</p>
<p>When we mark a property or a setter method with @Param annotation, CLI framework will try to initialize the parameter with the given value and then it will call the execute method. During the initialization, CLI framework check different attributes of a parameter like its necessity, short name, its acceptable value and so on.</p>
<p>The last thing which we should think about a CLI command is its internationalization and the possibility to show the localized version of text messages about the command and parameters to the client. This requirement is covered using another annotation named @I18n, the associated interface is placed in org.glassfish.api. Listing 3 shows the I18n interface declaration.</p>
<p><strong>Listing 4 I18n Interface which we should use to provide internationalized messages for our CLI command</strong></p>
<p><code><br />
@Retention(RUNTIME)<br />
@Target({TYPE,METHOD,FIELD})<br />
public @interface I18n {<br />
public String value();<br />
}</p>
<p></code></p>
<p>The annotation can be used both for properties and for annotating methods. At runtime the CLI framework will extract and inject the localized value into the variable based on the current locale of the JVM.</p>
<p>The localization file which is a standard resource bundle should follow the same key=value format which we used for any properties file. The standard name for the file is LocalStrings_Language_Country.properties an example file can be LocalStrings_en_US.properties for United States English or LocalStrings.properties as the default bundle for any locale which has no corresponding locale file in the bundle.</p>
<p><strong><em>1.3 A CLI command which returns the operating system details</em></strong></p>
<p>First we will develop a very simple CLI command in this section to get more familiar with the abstracts that we discussed before and then we will develop a more sophisticated command which will teach us more details about CLI framework and capability.</p>
<p>First command that we are going to develop just shows us what is operating system which our application server is running on and it will shows some information about the OS like architecture, JVM version, JVM vendor and so on. Our command name is get-platform-details.</p>
<p>First let’s look at the maven build file and analyze its content, although I am not going to scrutinize on the Maven build file but we will look at elements related to our CLI command development.</p>
<p><strong>Listing 5 Maven build file for creating a get-platform-details CLI command </strong></p>
<p><code><br />
&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br />
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;<br />
&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;                       #1<br />
&lt;parent&gt;<br />
&lt;groupId&gt;org.glassfish.pluggability&lt;/groupId&gt;<br />
&lt;artifactId&gt;pluggability&lt;/artifactId&gt;<br />
&lt;version&gt;3.0-SNAPSHOT&lt;/version&gt;<br />
&lt;/parent&gt;<br />
&lt;artifactId&gt;glassfish.book.chapter platformDetailsCommand &lt;/artifactId&gt;<br />
&lt;packaging&gt;hk2-jar&lt;/packaging&gt;                             #2<br />
&lt;name&gt;platform-details-command&lt;/name&gt;<br />
&lt;description&gt;GlassFish in Action, Chapter 13, Platform Details Command &lt;/description&gt;<br />
&lt;dependencies&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.glassfish.admin&lt;/groupId&gt;<br />
&lt;artifactId&gt;cli-framework&lt;/artifactId&gt;<br />
&lt;version&gt;${project.parent.version}&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.glassfish.common&lt;/groupId&gt;<br />
&lt;artifactId&gt;common-util&lt;/artifactId&gt;<br />
&lt;version&gt;${project.parent.version}&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;/dependencies&gt;<br />
&lt;build&gt;<br />
&lt;resources&gt;<br />
&lt;resource&gt;<br />
&lt;directory&gt;src/main/resources&lt;/directory&gt;         #3<br />
&lt;includes&gt;<br />
&lt;include&gt;**/*.1&lt;/include&gt;<br />
&lt;/includes&gt;<br />
&lt;/resource&gt;<br />
&lt;/resources&gt;<br />
&lt;/build&gt;<br />
&lt;/project&gt;<br />
</code></p>
<p>You will find more details in the POM file included in the sample source code accompanying the book, but what is shown in the listing is enough to build a CLI command module.  At #1 we define the OSGI Manifest version. at #2 we are ensuring that the bundle which we are creating is built using the HK2 module specification which means inclusion of all OSGI related description like imported and exported packages in the MANIFEST.MF file which will be generated by Maven and resides inside the META-INF folder of the final JAR file. At #3 we ensure that Maven will include our help file for the command. The help file name should be similar to the command name and it can include anything textual.  We usually follows a UNIX like man files structure to create help files for the commands. The help file will be shown when we call ./asadmin get-platform-details &#8211;help. Figure 1 shows the directory layout of our sample command project.  As you can see we have two similar directory layout for the manual file and java source codes and the POM.XML file is in the root of the cli-platform-details-command directory.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_444g7gt6jck_b" alt="" width="425" height="298" /></p>
<p>Figure 1 Directory layout of the get-platform-details command project.</p>
<p>Now let’s see what the source code for the command is and what would be the outcome of the build process. Listing 6 shows the source code for the command itself which when we execute ./asadmin get-platform-details GlassFish CLI will try to call its execute method. The result after executing the command is similar to figure 2, as you can see our command has executed successfully.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_445f4k3k9dt_b" alt="" width="503" height="142" /></p>
<p>Figure 2 Sample output for calling get-platform-details with runtime as the parameter</p>
<p>Now you can develop your own command and test it to see a similar result in the terminal window.</p>
<p><strong>Listing 6 Source code for PlatformDetails.java which is a CLI command</strong></p>
<p><code><br />
@Service(name = "get-platform-details")               #1<br />
@Scoped(PerLookup.class)                                  #2<br />
public class PlatformDetails implements AdminCommand {           #3</p>
<p>ActionReport report;<br />
OperatingSystemMXBean osmb = ManagementFactory.getOperatingSystemMXBean();                  #4<br />
RuntimeMXBean rtmb = ManagementFactory.getRuntimeMXBean();     #5<br />
// this value can be either runtime or os for our demo<br />
@Param(name = "detailsset", shortName = "DS", primary = true, optional = false)                                                        #6<br />
String detailsSet;</p>
<p>public void execute(AdminCommandContext context) {<br />
try {</p>
<p>report = context.getActionReport();<br />
StringBuffer reportBuf;<br />
if (detailsSet.equalsIgnoreCase("os")) {<br />
reportBuf = new StringBuffer("OS details: n");<br />
reportBuf.append("OS Name: " + osmb.getName() + "n");<br />
reportBuf.append("OS Version: " + osmb.getVersion() + "n");<br />
reportBuf.append("OS Architecture: " + osmb.getArch() + "n");<br />
reportBuf.append("Available Processor: " + osmb.getAvailableProcessors() + "n");<br />
reportBuf.append("Average Load: " + osmb.getSystemLoadAverage() + "n");<br />
report.setMessage(reportBuf.toString());            #7<br />
report.setActionExitCode(ExitCode.SUCCESS);         #8</p>
<p>} else if (detailsSet.equalsIgnoreCase("runtime")) {</p>
<p>reportBuf = new StringBuffer("Runtime details: n");<br />
reportBuf.append("Virtual Machine Name: " + rtmb.getVmName() + "n");<br />
reportBuf.append("VM Vendor: " + rtmb.getVmVendor() + "n");<br />
reportBuf.append("VM Version: " + rtmb.getVmVersion() + "n");<br />
reportBuf.append("VM Start Time: " + rtmb.getStartTime() + "n");<br />
reportBuf.append("UpTime: " + rtmb.getUptime() + "n");<br />
report.setMessage(reportBuf.toString());<br />
report.setActionExitCode(ExitCode.SUCCESS);</p>
<p>} else {<br />
report.setActionExitCode(ExitCode.FAILURE);         #9<br />
report.setMessage("Th given value for " +<br />
"detailsset parameter is not acceptable, the value " +<br />
"can be either 'runtime' or 'os'");<br />
}</p>
<p>} catch (Exception ex) {</p>
<p>report.setActionExitCode(ExitCode.FAILURE);<br />
report.setMessage("Command failed with the following error:n" + ex.getMessage());<br />
context.getLogger().log(Level.SEVERE, "get-platform-details " + detailsSet + " failed", ex);</p>
<p>}</p>
<p>}<br />
}</p>
<p></code></p>
<p>At #1 we are marking the implementation as a provider which implements a contract. The provided service name is get-platform-details which are the same as our CLI command name. At #2 we are setting a correct scope for the command as we do not like to see the same result every time that we initiate the command either for different domains. At #3 we are implementing the contract interface. At #4 and #5 we get MBeans which provides the information that we need, this MBeans can be either our local server MBeans or the remote running instance if we use the &#8211;host and &#8211;port  to execute the command against a remote instance. At #6 we are defining a parameter which is not optional, the parameter name is detailsset which we will use it by &#8211;detailsset when we want to execute the command. The short name for the parameter is DS which we will use as –DS when we want to execute the command. The command is primary so we do not need to name the parameter, we can just pass the value and CLI framework will assign the value to this parameter. Pay attention to the parameter name and the containing variable. If we do not use name element of the @Param annotation the parameter name will be the same as the variable name. At #7 we set the output which we want to show to the user as the report object’s message. At #8 we set the exit condition to successful as we managed to execute the command successfully. At #9 we set the exit code as a failure as the value passed for the parameter is not recognizable, we show a suitable message to user to help him diagnose the problem. At #10 we faced an exception, so we log the exception and set the exit command as a failure.</p>
<p>GlassFish CLI commands fall under two broad categories, one is the local commands like create-domain or start-domain commands which execute locally and you can not pass remote connection parameters including &#8211;host, &#8211;port parameters and expect to see the command executed on a remote glassfish installation. These commands extend com.sun.enterprise.cli.framework.Command abstract class or one of subclasses like com.sun.enterprise.admin.cli.BaseLifeCycleCommand.  And do not need anything like an already running GlassFish instance.</p>
<p>Next command which we will study is another command which will list some details about the JMS service of target domain, but this time we will discuss resource injection and some details around localization of command messages.</p>
<p>Listing 7 shows source code for a command which shows some information about domain JMS service including starting arguments, JMS service type, address list behavior and so on. Although the source code shows how we can get some details but setting the values for each attribute is the same as getting them.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_446fqvkdghr_b" alt="" width="505" height="119" /></p>
<p>Figure 3 shows the result of executing this command on a domain created with default parameters.</p>
<p><strong>Listing 7 Source code for remote command named get-jms-details </strong></p>
<p><code><br />
@Service(name = "get-jms-details")<br />
@Scoped(PerLookup.class)<br />
@I18n("get-jms-details")                       #1<br />
public class JMSDetails implements AdminCommand {</code></p>
<p><code>@Inject                                      #2<br />
JmsService jmsService;<br />
@Inject<br />
JmsHost jmsHost;<br />
@Inject<br />
JmsAvailability jmsAvailability;<br />
ActionReport report;<br />
@Param(name = "detailsset", acceptableValues = "all,service,host,availability",<br />
shortName = "DS", primary = true, optional = false) #3<br />
@I18n("get-jms-details.details_set")                #4<br />
String detailsSet;<br />
final private static LocalStringManagerImpl localStrings = new LocalStringManagerImpl(JMSDetails.class);             #5</p>
<p>public void execute(AdminCommandContext context) {<br />
try {<br />
report = context.getActionReport();<br />
StringBuffer reportBuf = new StringBuffer("");<br />
if (detailsSet.equalsIgnoreCase("all") || detailsSet.equalsIgnoreCase("service")) {<br />
reportBuf.append("Default Host: " + jmsService.getDefaultJmsHost() + "n");<br />
reportBuf.append("MQ Service: " + jmsService.getMqService() + "n");<br />
reportBuf.append("Reconnection Attempts: " + jmsService.getReconnectAttempts() + "n");<br />
reportBuf.append("Startup Arguments: " + jmsService.getStartArgs() + "n");<br />
} else if (detailsSet.equalsIgnoreCase("all") || detailsSet.equalsIgnoreCase("host")) {<br />
reportBuf.append("Host Address: " + jmsHost.getHost() + "n");<br />
reportBuf.append("Port Number: " + jmsHost.getPort() + "n");<br />
} else if (detailsSet.equalsIgnoreCase("all") || detailsSet.equalsIgnoreCase("availability")) {<br />
reportBuf.append("Is Availability Enabled: " + jmsAvailability.getAvailabilityEnabled() + "n");<br />
reportBuf.append("Availability Storage Pool Name: " + jmsAvailability.getMqStorePoolName() + "n");<br />
}<br />
report.setMessage(reportBuf.toString());<br />
report.setActionExitCode(ExitCode.SUCCESS);</p>
<p>} catch (Exception ex) {<br />
report.setActionExitCode(ExitCode.FAILURE);<br />
report.setMessage(localStrings.getLocalString("get-jms-details.failed", "Command failed to execute with the {0} as given parameter", detailsSet) + ". The exception message is:" +<br />
ex.getMessage());  #6<br />
context.getLogger().log(Level.SEVERE, "get-jms-details " + detailsSet + " failed", ex);</p>
<p>}</p>
<p>}<br />
}</p>
<p></code></p>
<p><code><br />
</code></p>
<p>You are right the code looks similar to the first sample but more complex in using some non familiar classes and use of resource injection and localization stuff. We used resource injection in order to access GlassFish configurations. All configuration interfaces which we can obtain using injection are inside com.sun.enterprise.config.serverbeans. Now let’s analyze the code where it is important and somehow unfamiliar.  At #1 we are telling the framework that this command short help message key in the localization file is get-jms-details. At #2 we are injecting some configuration Beans into our variables. At #3 we ensure that the CLI framework will check the given value for the parameter to see whether it is one of the acceptable values or not. At #4 we are determining the localization key for the parameter help message. At #5 we initialize the string localization manager to get appreciated string values from the bundle files. At #6 we are showing a localized error message using the string localization manager.</p>
<p>Listing 5 shows LocalStrings.properties file content which we will shortly discuss where it should be placed to allows the CLI framework to find it and load the necessary messages from it.</p>
<p><strong>Listing 8 An Snippet of localization file content for a command named restart</strong><strong>-domain</strong></p>
<p>get-jms-details=Getting the Detailed information about JMS service and host in the target domain.                #1</p>
<p>get-jms-details.details_set=The set of details which is required, the value can be all, service, host, or availability.           #2</p>
<p>get-jms-details.failed=Command failed to execute with the {0} as given parameter.          #3</p>
<p>At #1 we include a description of the command; at #2 we include description of the detailsset parameter using the assigned localization key. At #3 we include the localized version of the error message which we want to show when the command fails. As you can see we used place holders to include the parameter value. Figure 4 shows the directory layout of the get-jms-details project. As you can see we placed the LocalStrings.properties file next to the command source code.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_447gdvc95dp_b" alt="" width="473" height="251" /></p>
<p>Figure 4 Directory layout of the get-platform-details command project.</p>
<p>Developing more complex CLI commands follow the same rule as developing these simple commands. All that you need to develop a new command is starting a new project using the given maven POM files and discovering the new things that you can do.</p>
<p><strong><em>2 Administration console pluggability</em></strong></p>
<p>You know that administration console a very easy to use channel for administrating a single instance or multiple clusters with tens of instances and variety of managed resources. All of these functionalities were based on navigation tree, tabs, and content pages which we could use to perform our required tasks. You may wonder how we can extend these functionalities without changing the main web application which is known as admingui to get new functionalities in the same look and feel that already available functionalities are presented.  The answer lies again in the application server overall design, HK2 and OSGI along with some JSF Templating and use of Woodstock JSF component suite. We are going to write an administration console which let us upload and install new OSGI bundles by using browser from remote locations.</p>
<p><strong><em>2.1 Administration console architecture</em></strong></p>
<p>Before we start discussing how we can extend the administration console in a non-intrusive way we should learn more about the console architecture and how it really works. Administration console is a set of OSGI bundles and each bundle includes some administration console specific artifacts in addition to the default OSGI manifest file and Maven related artifacts.</p>
<p>One of the most basic artifacts which are required by an administration console plugin is a descriptor which defines where our administration console navigation items should appear. For example are going to add a new node to the navigation tree, or we want to add a new tab to a currently available tab set like Application Server page tab set.  The file which describes this navigation items and their places is named console-config.xml and should be placed inside META-INF/admingui folder of the final OSGI bundle.</p>
<p>The second thing which is required to make it possible for our module to be recognized by the HK2 kernel is the HK2 administration console plugin’s contract implementation. So, the second basic item in the administration console plug-in is an HK2 service provider which is nothing more than a typical Java class, annotated with @Service annotation that implements the org.glassfish.api.admingui.ConsoleProvider interface. The console provider interface has only one method named getConfiguration. We need to implement this method if we want to use a non-standard place for the console-config.xml file.</p>
<p>In addition to the basic requirement we have some other artifacts which should be present in order to see some effects in the administration console from our plug-in side. There requirements includes, JSF fragment files to add the node, tab, content, and common task button to administration console on places which are described in the console-config.xml file.  These JSF fragments uses JSFTemplating project tags to define nodes, tabs, and buttons which should appear in the integration points.</p>
<p>Until now we include just a node in a navigation tree, a tab in one of the tab sets, or a common task button or group in the common tasks page. What else we need to include? We need some pages to show when administrators clicked on a tree node or on a common task button. So we should add JSF fragments implemented using JSFTemplating tags to show the real content to the administrators. For example imagine that we want to write a module to deploy OSGI bundles, we will need to show a page which let users select a file along with a button which they can press to upload and install the bundle.</p>
<p>Now that we shown the page which let users select a file, we should have some business logic or handlers which receives the uploaded file and write it in the correct place. As we use JSFTemplating for developing pages, we will JSFTemplating handlers to handle the business logic.</p>
<p>Our functionality related artifacts are mentioned, but everything is not summarized in functionalities, we should provide localized administration pages to our administrators whom like to use their local languages when dealing with administration related tasks. We also need to provide some help files which will guide the administrators when they need to read a manual before digging into the action.</p>
<p>After we have all of this content and configurations in place, the administration console’s add on service query for all providers which implements the ConsoleProvider interface, then the service tries to get the configuration file if it couldn’t find the file in its default place by calling the getConfiguration method of the contract implementation. After that the administration console framework uses the configuration file and provided integration points template files and later on the content template files and handlers.</p>
<p><strong><em>2.2 JSFTemplating </em></strong></p>
<p>JSFTemplating is a sun sponsored project hosted in <a href="https://jsftemplating.dev.java.net/">https://jsftemplating.dev.java.net/</a> which provides templating for JSF. By utilizing JSFTemplating we can create web pages or components using template files, template files. Inside template files we can use JSFTemplating, and Facelets syntax, other syntax support may be provided in future. All syntaxes support all of JSFTemplating&#8217;s features such as accessing page session, event triggering and event handler’s support and dynamic reloading of page content. Let’s analyze a template file which is shown in listing 9 to see what we are going to use when we develop administration console plug-ins.</p>
<p><strong>Listing 9 A simple JSFTemplating template file</strong></p>
<p><code><br />
&lt;!initPage<br />
setResourceBundle(key="i18n" bundle="mypackage.resource");<br />
/&gt;                                 #1<br />
&lt;sun:page&gt;<br />
&lt;sun:html&gt;<br />
&lt;sun:head id="head" /&gt;<br />
&lt;sun:body&gt;<br />
#include /header.inc<br />
&lt;sun:form id="form"&gt;<br />
"&lt;p&gt;#{i18n["welcome.msg"]}&lt;/p&gt;        #2<br />
&lt;sun:label value="#{anOut}"&gt;        #3<br />
&lt;!beforeEncode<br />
GiA.getResponse(userInput="#{in}"                   response=&gt;$pageSession{anOut});<br />
/&gt;<br />
&lt;/sun:label&gt;<br />
"&lt;br /&gt;&lt;br /&gt;<br />
&lt;sun:textField id="in" value="#{pageSession.in}" /&gt; #4<br />
"&lt;br /&gt;&lt;br /&gt;<br />
&lt;sun:button text="$resource{i18n.button.text}" /&gt;<br />
&lt;sun:hyperlink text="cheat"&gt;<br />
&lt;!command<br />
setPageSessionAttribute(key="in" value="sds");  #5<br />
/&gt;<br />
&lt;/sun:hyperlink&gt;<br />
&lt;/sun:form&gt;<br />
#include /footer.inc          #6<br />
&lt;/sun:body&gt;<br />
&lt;/sun:html&gt;<br />
&lt;/sun:page&gt;</p>
<p></code></p>
<p>At #1 we determine the resource file which we want to use to get localized text content.  We define a key for accessing the object. At #2 we are simply using our localization resource file to show a welcome message and as you have already noticed it is Facelet syntax. At #3 we are using a handler for one of the predefined events of JSFTemplating events. In the event we are sending out the value of in variable to our method and after getting back the method’s execution result we set the result into a variable named anOut in the page scope. And we use the same variable to initialize the Label component. You can see how a handler will look like in listing 10.  The event that we used makes it possible to change the text before it gets displayed. There are several pre-defined events which some of them are listed in table 2. At #4 we are using the in variable’s value to initialize the text field content. At #5 we are using a pre-defined command as the handler for the hyperlink click. At #6 we are including another template file into this template file. All of the components that we used in this template file are equivalent of WoodStock project’s components.</p>
<p>Table 2 JSFTemplating pre-defined events which can call a handler</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<p><strong>Event</strong></td>
<td>
<p><strong>Description</strong></td>
</tr>
<tr>
<td>
<p>AfterCreate, BeforeCreate</td>
<td>
<p>Event handling commences before or after the component is created</td>
</tr>
<tr>
<td>
<p>AfterEncode, BeforeEncode</td>
<td>
<p>Event handling commences before or after content of a component get displayed</td>
</tr>
<tr>
<td>
<p>Command</td>
<td>
<p>Command has invoked, for example a link or a button is clicked</td>
</tr>
<tr>
<td>
<p>InitPage</td>
<td>
<p>Page initialization phase, when components values are getting sets</td>
</tr>
</tbody>
</table>
<p><strong>Listing 10 The GiA.getResponse handler which has been used in listing 9</strong></p>
<p><code><br />
@Handler(id = "GiA.getResponse",<br />
input = {<br />
@HandlerInput(name = "in", type = String.class)},<br />
output = {<br />
@HandlerOutput(name = "response", type = String.class)<br />
})<br />
public static void getResponse(HandlerContext handlerCtx) {<br />
}</p>
<p></code></p>
<p>In listing 10 you can see that the handler id were using in JSF page instead of the method fully qualified name. During the compilation, all handlers id, their fully qualified name, and their input and output parameters will get extracted by apt into a file named Handler.map which resides inside a folder named jsftemplating. The jsftemplating folder is placed inside the META-INF folder. Handler.map structure is similar to standard properties file containing variable=value pairs.</p>
<p>Now that we have some knowledge about the JSFTemplating project and the administration console architecture we can create our plug-in which let us install any GlassFish module in form of OSGI bundle using administration console. After we saw how a real plug-in can be developed we can proceed to learn more details about integration points and changing administration console theme and brand.</p>
<p><strong><em>13.2.3</em></strong> <strong><em>OSGI bundle installer plug-in</em></strong></p>
<p>Now we want to create a plug-in which will let us upload an OSGI module and install it into the application server by copying the file into modules directory. First let’s see figure 5 which shows the file and directory layout of the plug-in source codes, and then we can discuss each artifact in details.</p>
<p>In figure 5, at the top level we have out Maven build file with one source directory containing standard Maven directory structure for Jar files which is a main directory with java and resources directory inside it. The java directory is self describing as it contains the handler and service provider implementation.  The resources directory again is standard for Maven Jar packager. Maven will copy the content of the resources folder directly in the root of the Jar file. Content of the resources folder is as follow:</p>
<p>glassfish folder: this folder contains a directory layout similar to java folder, the only file stored in this folder is our localization resource file which is named Strings.properties</p>
<p style="-qt-block-indent: 1;">
<ul type="square">
<li>images: graphic file which we want to use in our plug-in for example in the navigation tree</li>
<li>js: a JavaScript file which contains some functions which we will use in the plug-in</li>
<li>META-INF: during the development time we will have only one folder named admingui inside the META-INF folder, this folder holds the console-config.xml. After bulding the project some other folders including maven, jsftemplating and inhabitants will be created by the maven.</li>
<li>pages: this folder contains all of our JSF template files.</li>
</ul>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_448f8stx8dg_b" alt="" width="413" height="284" /></p>
<p>Figure 5 directory layout of the administration console plug-in to install OSGI bundles</p>
<p>Some folders are mandatory like META-INF but we can put other folders’ content directly inside the resources folder. But we will end up with an unorganized structure. Now we can discuss each artifact in details. You can see content of the console-config.xml in listing 11.</p>
<p><code><br />
&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;console-config id="GiA-OSGI-Module-Install"&gt;                  #1<br />
&lt;integration-point  id="CommonTask-Install-OSGI"          #2<br />
type="org.glassfish.admingui:commonTask"          #3<br />
parentId="deployment"                           #4<br />
priority="300"                                   #5<br />
content="pages/CommonTask.jsf" /&gt;             #6<br />
&lt;integration-point  id="Applications-OSGI"<br />
type="org.glassfish.admingui:treeNode"       #7<br />
priority="500"<br />
parentId="applications"                       #8<br />
content="pages/TreeNode.jsf" /&gt;                #9<br />
&lt;/console-config&gt;<br />
</code></p>
<p>content: The content for the integration point, typically a JavaServer Faces page.</p>
<p>This XML file describe which integration points we want to use, and what is the priority our navigation node in comparison with already existing navigation nodes. At #1 we give our plugin a unique ID because later on we will access our web pages and resources using this ID. At #2 we define an integration point again with a unique ID. At #3 we determine that this integration point is a common task which we want to add under deployment tasks group #4. At #5 the priority number says that all integration points with an smaller priority number will be proceed before this integration point and therefore our common tasks button will be placed after them. At #6 we determine which template file should be proceed to fill in the integration point place holder, in this integration point the template file contains a button which will fill the place holder.</p>
<p>At #7 we determine that we want to add some tree node to the navigation tree by using org.glassfish.admingui:treeNode as integration point type. At #8 we determine that our tree node should be placed under the applications node. At #9 we are telling that the template page which will fill the place holder is pages/TreeNode.jsf. To summarize we can say generally each console-config.xml file consists of several integration points’ description elements and each integration point element has 4 or 5 attributes. These attributes are as follow:</p>
<p>Id: An identifier for the integration point.</p>
<p>parentId:  The ID of the integration point&#8217;s parent. You can see A list of all parentid(s) in listing 3</p>
<p>type: The type of the integration point. You can see A list of all parentid(s) in listing 3</p>
<p>priority:  A numeric value that specifies the relative ordering of integration points for add-on components that specify the same parentId . This attribute is optional.</p>
<p>The second basic artifact which we discussed is the service provider which is simple Java class implementing the org.glassfish.api.admingui.ConsoleProvider interface. The listing 12 shows InstallOSGIBundle bundle which is the service provider for our plug-in.</p>
<p><strong>Listing 12 Content of the InstallOSGIBundle.java, the plug-in service provider</strong></p>
<p><code><br />
@Service(name = "install-OSGI-bundle") #A<br />
@Scoped(PerLookup.class)  #b<br />
public class InstallOSGIBundle<br />
implements ConsoleProvider {  #c</p>
<p>public URL getConfiguration() {<br />
return null;<br />
}<br />
}<br />
</code></p>
<p><strong>#A: Service has name</strong></p>
<p><strong>#B: Service is scoped</strong></p>
<p><strong>#C: Service implements the interface</strong></p>
<p>After we saw the basic artifacts, including the service provider implementation and how we can define where in the administration console navigational system we want to put our navigational items, we can see what the content of template files which we use in the console-config.xml file is. Listing 13 shows the TreeNode.jsf file content.</p>
<p><strong>Listing 13 Content of the </strong><strong>TreeNode.jsf template file which create a node in navigation tree</strong></p>
<p>&lt;!initPage</p>
<p>setResourceBundle(key=&#8221;GiA&#8221; bundle=&#8221;glassfish.book.chapteradmingui.plugin.Strings&#8221;) #1</p>
<p><code><br />
&lt;!initPage<br />
setResourceBundle(key="GiA" bundle="glassfish.book.chapteradmingui.plugin.Strings") #1<br />
/&gt;<br />
&lt;sun:treeNode id="GFiA_TreeNode"            #2<br />
imageURL="resource/images/icon.png"  #3<br />
text="$resource{GiA.OSGI.install.tree.title}" #4<br />
url="GiA-OSGI-Module-Install/pages/installOSGI.jsf" #5<br />
target="main"         #6<br />
expanded="$boolean{false}"&gt;       #7<br />
&lt;/sun:treeNode&gt;<br />
</code></p>
<p>You can see the changes that this template will cause in figure 6, but the description of the code is as follow. At #1 we are using a JSFTemplating event to initialize the resource bundle. At #2 we are telling that we have a tree node with the GFiA_TreeNode as its ID which let us access the node using JavaScript. At #3 we determine the icon which we want to appear next to the tree node, you can see that we are using resource/images/icon.png as the path to the icon, the resource prefix lead us to the root of the resources folder. At #4 we are telling that we want the title of the tree node to be fetched from the resource bundle. At #5 we are determining which page should be loaded when administrator clicked the button. We are using facesContext.externalContext.requestContextPath we are getting the web application path, the GiA-OSGI-Module-Install is our plug-in id and we can access whatever we have inside the resources folder by prefixing its path with GiA-OSGI-Module-Install, you can see GiA-OSGI-Module-Install in listing 11. At #6 we are telling that the page should opens in the main frame (the content frame) and at #7 we are telling that the node should not be expanded by default. #7 effects are visible when we have some sub nodes.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_449cxdctq4x_b" alt="" width="327" height="383" /></p>
<p>Figure 6 the effects of TreeNode.jsf template file on the administration console navigation tree node</p>
<p>You can see that we have our own icon which is loaded directly from the images folder which is resided inside the resources directory. The tree node text is fetched from the resource bundle file.</p>
<p>Listing 14 shows CommonTask.jsf which causes the administration console service to place a button in the common task section under the deployment group, the result of this fragment on the common tasks page is shown in figure 7.</p>
<p><strong>Listing 14 Content of the CommonTask.jsf file which is a template to fill the navigation item place</strong></p>
<p><code><br />
&lt;!initPage<br />
setResourceBundle(key="GiA" bundle="glassfish.book.chapteradmingui.plugin.Strings")<br />
/&gt;<br />
&lt;sun:commonTask                                             #1<br />
text="$resource{GiA.OSGI.install.task.title}"<br />
toolTip="$resource{GiA.OSGI.install.tree.Tooltip}"<br />
onClick="admingui.nav.selectTreeNodeById('form:tree:application:GFiA_TreeNode');                                                       #2<br />
parent.location='#{facesContext.externalContext.requestContextPath}/GiA-OSGI-Module-Install/pages/installOSGI.jsf'; return false;"     #3</p>
<p>&gt;<br />
&lt;/sun:commonTask&gt;</p>
<p></code></p>
<p>At #1 we are using a commonTask component of the JSFTemplating framework, we use a localized string for its text and tool tip. At #2 we are changing the state of the tree node defined in the console-config.xml when the component receives a click; this is for ensuring that the navigation tree shows where the use is. And at #4 we are telling that we want to load pages/installOSGI.jsf which this button is clicked.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_450gzfd44d7_b" alt="" width="503" height="214" /></p>
<p>Figure 7 Effects of the listing 13 on the common task page of the administration console</p>
<p>We fetched the button title and its tool tip from the resource file which we included in the resource folder as described in the sample project folder layout in figure 5.</p>
<p>Next file which we will discuss is the actual operation file which provides the administrators with an interface to select upload and install an OSGI bundle. The file as we already discussed is named installOSGI.jsf and listing 15 shows its content.</p>
<p><strong>Listing 15 The </strong><strong>installOSGI.jsf file content, this file provide interface for uploading the OSGI file</strong></p>
<p><code><br />
&lt;sun:page id="install-osgi-bundle-page" &gt;  #1<br />
&lt;!beforeCreate<br />
setResourceBundle(key="GiA" bundle="glassfish.book.chapteradmingui.plugin.Strings");<br />
/&gt;<br />
&lt;sun:html&gt;<br />
&lt;sun:head id="propertyhead" title="$resource{GiA.OSGI.install.header.title}"&gt;      #2<br />
&lt;sun:script url="/resource/js/glassfishUtils.js" /&gt; #3<br />
&lt;/sun:head&gt;<br />
&lt;sun:body&gt;<br />
&lt;sun:form id="OSGI-Install-form" enctype="multipart/form-data"&gt;<br />
&lt;sun:title id="title" title="$resource{GiA.OSGI.install.form.title}" helpText="$resource{GiA.OSGI.install.form.help.title}"&gt;<br />
&lt;sun:upload id="fileupload" style="margin-left: 17pt" columns="$int{50}"<br />
uploadedFile="#{requestScope.uploadedFile}"<br />
&gt; #4<br />
&lt;/sun:upload&gt;<br />
&lt;sun:button id="uploadButton" text="$resource{GiA.OSGI.install.form.Install_button}"<br />
onClick="javascript:<br />
return submitAndDisable(this, '$resource{GiA.OSGI.install.form.cancel_processing}');<br />
"&gt; #5<br />
&lt;!command<br />
GiA.uploadFile(file="#{uploadedFile}");</p>
<p>redirect(page="#{request.contextPath}/GiA-OSGI-Module-Install/pages/OSGIModuleInstalled.jsf");<br />
/&gt;  #6<br />
&lt;/sun:button&gt;<br />
&lt;/sun:button&gt;<br />
&lt;/sun:title&gt;<br />
&lt;/sun:form&gt;<br />
&lt;/sun:body&gt;<br />
&lt;/sun:html&gt;<br />
&lt;/sun:page&gt;<br />
</code></p>
<p>I agree that the file content may look scary, but if you look more carefully you can see many familiar elements and patterns. Figure 8 shows this page in the administration console. In the listing 14, at #1 we are starting a page component and we use its beforeCreate event to load the localized resource bundle. At #2 we are giving the page a title which is loaded from the resource bundle. At #3 we are load a JavaScript file which contains one helper JavaScript method. As you can see we prefixed the file path with resource. At #4 we are using a fileUpload component and the binary content of the uploaded files goes to uploadedFile in the request scope. At #5 we use the helper JavaScript method to submit the form and disable the Install button. At #6 we are calling a custom handler with GiA.uploadFile as its ID. We pass the request scoped uploadedFile variable to the handler method. After the command executed, we #6 we redirect to a simple page which shows a message indicating that the module is installed.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_451gthw66ck_b" alt="" width="503" height="94" /></p>
<p>Figure 8 The installOSGI.jsf page in the administration console</p>
<p>Now, let’s see what is behind this page, how this handler works, how it can find the module directory and how the installation process commences. Listing 16 shows the InstallOSGIBundleHandlers class which contains only one handler for writing the uploaded file in the modules directory of GlassFish installation which owns the running domain.</p>
<p><strong>Listing 16 The content of </strong><strong>InstallOSGIBundleHandlers which is file uploading handler</strong></p>
<p><code><br />
public class InstallOSGIBundleHandlers {  #A</p>
<p>@Handler(id = "GiA.uploadFile",  #1<br />
input = {<br />
@HandlerInput(name = "file", type = UploadedFile.class)}) #2<br />
public static void uploadFileToTempDir(HandlerContext handlerCtx) { #3<br />
try {<br />
UploadedFile uploadedFile = (UploadedFile) handlerCtx.getInputValue("file"); #4<br />
String name = uploadedFile.getOriginalName();<br />
String asInstallPath = AMXRoot.getInstance().getDomainRoot().getInstallDir(); #5<br />
String modulesDir = asInstallPath + "/modules";<br />
String serverSidePath = modulesDir + "/" + name;<br />
uploadedFile.write(new File(serverSidePath));<br />
} catch (Exception ex) {<br />
GuiUtil.handleException(handlerCtx, ex); #6<br />
}<br />
}<br />
}<br />
</code></p>
<p><strong>#A Class Declaration</strong></p>
<p>As you can see in the listing, it is really simple to write handlers and working with GlassFish APIs. at #1 we are defining a handler, the handler ID element allows us to use it in the template file. At #2 we define the handler input parameter named file the parameter type is com.sun.webui.jsf.model.UploadedFile. At #3 we are implementing the handler method. At #4 we are extracting the file content from the context. At #5 we are using and AMX utility class to find the GlassFish installation path which owns the currently running domain. There many utility classes in the org.glassfish.admingui.common.util package. At #6 we are handling any possible exception using the GlassFish way. We can define output parameters for our handler and after the command executed, decide where to redirect the user based on the value of the output parameter.</p>
<p>There are 3 other files which we will briefly discuss, the first file which is shown in listing 17 is the JavaScript file which I used in installOSGI.jsf and is placed inside the js directory. We discussed the file in listing 15 discussions.</p>
<p><strong>Listing 17 Content of the glassfishUtils.js file</strong></p>
<p><code><br />
function submitAndDisable(button, msg, target) {<br />
button.className='Btn1Dis';<br />
button.disabled=true;<br />
button.form.action += "?" + button.name + "=" + encodeURI(button.value);<br />
button.value=msg;<br />
if (target) {<br />
button.form.target = target;<br />
}<br />
button.form.submit();<br />
return true;<br />
}<br />
</code></p>
<p>The function receives three parameters, the button which it will disable, the message which it will set as the button title when the button disabled and finally the target that the button’s owner form will submit to.</p>
<p>Listing 17 shows the next file which we should take a look at.  String.properties is our localization file located deep in resources directory under  glassfish.book.chapteradmingui.plugin package. Although it is a standard localization file, but it is not bad to take a look and remember the first time that we faced with resource bundle files.</p>
<p><strong>Listing 18 Content of the Strings.properties file</strong></p>
<p><code><br />
OSGI.install.header.title=Install OSGI bundle by uploading the file into the server.<br />
OSGI.install.form.title=Install OSGI bundle by uploading the file into the server.<br />
OSGI.install.form.help.title=Browse and select your OSGI bundle to install it in the server's modules directory<br />
OSGI.install.form.button_processing=Processing<br />
OSGI.install.form.Install_button=Install<br />
OSGI.install.tree.title=Install OSGI Bundle<br />
OSGI.install.task.title=Install OSGI Bundle<br />
OSGI.install.tree.Tooltip=Simply install OSGI bundle by uploading the bundle from the administration console.<br />
</code></p>
<p>And finally our Maven build file, the build file as we discussed in the beginning of the section is placed in the top level directory of our project. If you want to review the directory layout, take a look at figure 5.</p>
<p><strong>Listing 19 The plug-in project Maven build file, pom.xml</strong></p>
<p><code><br />
&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;<br />
&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;<br />
&lt;parent&gt;<br />
&lt;groupId&gt;org.glassfish.admingui&lt;/groupId&gt; #A<br />
&lt;artifactId&gt;admingui&lt;/artifactId&gt;<br />
&lt;version&gt;3.0-SNAPSHOT&lt;/version&gt;<br />
&lt;/parent&gt;<br />
&lt;artifactId&gt;glassfish.book.chapterAdminConsolePlugin&lt;/artifactId&gt;<br />
&lt;packaging&gt;hk2-jar&lt;/packaging&gt;           #B<br />
&lt;name&gt;OSGI-bundle-Installation-Adming-Plugin&lt;/name&gt;<br />
&lt;description&gt;GlassFish in Action, Chapter 13, Admin console plugin to install OSGI bundle&lt;/description&gt;<br />
&lt;dependencies&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.glassfish.common&lt;/groupId&gt;<br />
&lt;artifactId&gt;glassfish-api&lt;/artifactId&gt;<br />
&lt;version&gt;${project.version}&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.glassfish.admingui&lt;/groupId&gt;<br />
&lt;artifactId&gt;console-common&lt;/artifactId&gt;<br />
&lt;version&gt;${project.version}&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.glassfish.admingui&lt;/groupId&gt;<br />
&lt;artifactId&gt;console-plugin-service&lt;/artifactId&gt;<br />
&lt;version&gt;${project.version}&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.glassfish.common&lt;/groupId&gt;<br />
&lt;artifactId&gt;amx-api&lt;/artifactId&gt;<br />
&lt;version&gt;${project.version}&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.glassfish.deployment&lt;/groupId&gt;<br />
&lt;artifactId&gt;deployment-client&lt;/artifactId&gt;<br />
&lt;version&gt;${project.version}&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;/dependencies&gt;<br />
&lt;/project&gt;<br />
</code></p>
<p>#A Project Group ID</p>
<p>#B HK2 Special Packagin</p>
<p>The pom.xml file which is available for download in <a href="http://www.manning.com/kalali">www.manning.com/kalali</a> is more complete with some comment which explains other elements, but the 19 listings content is sufficient for building the plug-in.</p>
<p>Now that you have a solid understanding of how an administration console plug-in works, we can extends our discussion to other integration points and their corresponding JSFTemplating components.</p>
<p>Table 3 shows integration points and the related JSFTemplating component along with some explanation about each item. As you can see we have 5 more types of integration points with different attributes and navigational places.</p>
<p>Table 3 List of all integration points along with the related JSFTemplating compoent</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<p><strong>Integration point*</strong></td>
<td>
<p><strong>Values for ParentID attribute</strong></td>
<td>
<p><strong>Corresponding JSFTemplating compoent</strong></td>
</tr>
<tr>
<td>
<p>treeNode</td>
<td>
<p>tree, applicationServer</p>
<p>applications, webApplications</p>
<p>resources, configuration</p>
<p>node,  webContainer</p>
<p>httpService</td>
<td>
<p>sun:treeNode which</p>
<p>is equivalent of the Project Woodstock tag  webuijsf:treeNode</td>
</tr>
<tr>
<td>
<p>serverInstTab</td>
<td>
<p>serverInstTab, add tabs and sub tabs to Application Server page</td>
<td>
<p>sun:tab which is equivalent of the project Woodstock tag webuijsf:tab</td>
</tr>
<tr>
<td>
<p>commonTask</td>
<td>
<p>deployment, monitoring,updatecenter, documentation</td>
<td>
<p>sun:commonTask which</p>
<p>is equivalent of the Project Woodstock tag  webuijsf:commonTask.</td>
</tr>
<tr>
<td>
<p>commonTask</td>
<td>
<p>commonTasksSection, it allows us to create our own common tasks group</td>
<td>
<p>sun:commonTasksGroup .</p>
<p>which</p>
<p>is equivalent of the Project Woodstock tag  webuijsf:commonTasksGroup</td>
</tr>
<tr>
<td>
<p>customtheme</td>
<td>
<p>masthead, loginimage, loginform, versioninfo</td>
<td>
<p>This integration point let us change the login form, header and version information of the application server for changing the application server brand</td>
</tr>
</tbody>
</table>
<p>* All of the first column values have org.glassfish.admingui: as prefix</p>
<p>Now you are quipped with enough knowledge to develop extensions for GlassFish administration console to facilitate your won daily tasks or provide your plug-ins to other administrators which are interested in same administration tasks which you are performing using your developed plug-ins.</p>
<p><strong><em>3 Summary</em></strong></p>
<p>Understanding an administration console from end user point of view is something and understanding it from a developer’s perspective is another, using the first one you can administrate the application server and using the second one you can manage, enhance and administrate the administration console itself. In this article we learned how we can develop new asadmin or CLI commands to ease our daily tasks or extends the GlassFish application server as a 3rd party partner. We learned how we can develop and extend the web based administration console which leads us to reviewing the JSFTemplating project and a fast pointing to AMX helper classes.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/glassfish-modularity-system-how-extend-glassfish-cli-and-web-administration-console-part-2-developing-sample-modules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Spring Security to enforce authentication and authorization on Spring Remoting Services Invoked from a Java SE client&#8230;</title>
		<link>http://kalali.me/using-spring-security-to-enforce-authentication-and-authorization-on-spring-remoting-services-invoked-from-a-java-se-client/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-spring-security-to-enforce-authentication-and-authorization-on-spring-remoting-services-invoked-from-a-java-se-client</link>
		<comments>http://kalali.me/using-spring-security-to-enforce-authentication-and-authorization-on-spring-remoting-services-invoked-from-a-java-se-client/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 10:11:37 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[JavaSE]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Spring Remoting]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=356</guid>
		<description><![CDATA[Spring framework is one of the biggest and the most comprehensive frameworks Java Community can utilize to cover most of the  end to end requirement of a software system when it come to implementation. Spring Security and Spring Remoting are two important parts of the framework which covers security in a descriptive way and let [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Spring&lt;br &gt;&lt;/a&gt; framework" href="http://www.springsource.org/">Spring framework</a> is one of the biggest and the most comprehensive frameworks Java Community can utilize to cover most of the  end to end requirement of a software system when it come to implementation.<br />
<a title="Spring Security" href="http://static.springsource.org/spring-security/site/">Spring Security</a> and <a title="Spring Remoting" href="http://static.springsource.org/spring/docs/2.0.x/reference/remoting.html">Spring Remoting</a> are two important parts of the framework which covers security in a descriptive way and let us have remote invocation of a spring bean methods using a local proxy.</p>
<p>In this entry I will show you how we can use spring security to secure a spring bean exposed over HTTP and invoke its secured methods from an standalone client. In our sample we are developing an Spring service which returns the list of roles which are assigned to that currently authenticated user. I will develop a simple web application congaing an secured Spring service then I will develop a simple Java SE client to invoke that secured service.</p>
<p>To develop the service we need to have a service interface which is as follow:</p>
<pre> package springhttp;
public interface SecurityServiceIF {
public String[] getRoles();
}</pre>
<p>Then we need to have an implementation of this interface which will do the actual job of extracting the roles for the currently authenticated user.</p>
<pre>package springhttp;
public class SecurityService implements SecurityServiceIF {</pre>
<pre>public String[] getRoles() {
Collection&lt;GrantedAuthority&gt; col = SecurityContextHolder.getContext().getAuthentication().getAuthorities();
String[] roles = new String[col.size()];
int i = 0;
for (Iterator&lt;GrantedAuthority&gt; it = col.iterator(); it.hasNext();) {</pre>
<pre>GrantedAuthority grantedAuthority = it.next();
roles[i] = grantedAuthority.getAuthority();
i++;
}
return roles;
}
}</pre>
<p>Now we should define this remote service in a descriptor file. Here we will use <em>remote-servlet.xml</em> file to describe the service. The file can be placed inside the WEB-INF of the web application. The file content is as follow:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"&gt;
&lt;beans&gt;</pre>
<pre>&lt;bean name="/securityService"
class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"&gt;
&lt;property name="serviceInterface" value="springhttp.SecurityServiceIF" /&gt;
&lt;property name="service" ref="securityService" /&gt;
&lt;/bean&gt;</pre>
<pre>&lt;/beans&gt;</pre>
<p>We are simply using <em>/securityService</em> as the relative URL to expose our <em>SecurityService</em> implementation.</p>
<p>The next configuration file is the Spring application context in which we define all of our beans, beans weaving and configurations. The file name is <em>applicationContext.xml</em> and it is located inside the <em>WEB-INF</em> directory.</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd   http://www.springframework.org/schema/security   http://www.springframework.org/schema/security/spring-security-3.0.xsd "&gt;

&lt;bean id="securityService" class="springhttp.SecurityService"&gt;
&lt;/bean&gt;

&lt;security:http realm="SecRemoting"&gt;
&lt;security:http-basic/&gt;
&lt;security:intercept-url pattern="/securityService" access="ROLE_ADMIN" /&gt;
&lt;/security:http&gt;

&lt;security:authentication-manager alias="authenticationManager"&gt;
&lt;security:authentication-provider&gt;
&lt;security:user-service id="uds"&gt;
&lt;security:user name="Jami" password="Jami"
authorities="ROLE_USER, ROLE_MANAGER" /&gt;
&lt;security:user name="bob" password="bob"
authorities="ROLE_USER,ROLE_ADMIN" /&gt;
&lt;/security:user-service&gt;
&lt;/security:authentication-provider&gt;
&lt;/security:authentication-manager&gt;

&lt;bean id="digestProcessingFilter"
class="org.springframework.security.web.authentication.www.DigestAuthenticationFilter"&gt;
&lt;property name="userDetailsService" ref="uds" /&gt;
&lt;property name="authenticationEntryPoint"
ref="digestProcessingFilterEntryPoint" /&gt;
&lt;/bean&gt;

&lt;bean id="digestProcessingFilterEntryPoint"
class="org.springframework.security.web.authentication.www.DigestAuthenticationEntryPoint"&gt;
&lt;property name="realmName" value="ThisIsTheDigestRealm" /&gt;
&lt;property name="key" value="acegi" /&gt;
&lt;property name="nonceValiditySeconds" value="10" /&gt;
&lt;/bean&gt;

&lt;bean id="springSecurityFilterChain"
class="org.springframework.security.web.FilterChainProxy"&gt;
&lt;security:filter-chain-map path-type="ant"&gt;
&lt;security:filter-chain pattern="/**"
filters="httpSessionContextIntegrationFilter,digestProcessingFilter,exceptionTranslationFilter,filterSecurityInterceptor" /&gt;
&lt;/security:filter-chain-map&gt;
&lt;/bean&gt;

&lt;bean id="httpSessionContextIntegrationFilter"
class="org.springframework.security.web.context.HttpSessionContextIntegrationFilter" /&gt;
&lt;bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased"&gt;
&lt;property name="decisionVoters"&gt;
&lt;list&gt;

&lt;bean class="org.springframework.security.access.vote.RoleVoter" /&gt;
&lt;bean class="org.springframework.security.access.vote.AuthenticatedVoter" /&gt;
&lt;/list&gt;
&lt;/property&gt;
&lt;/bean&gt;

&lt;bean id="exceptionTranslationFilter"  class="org.springframework.security.web.access.ExceptionTranslationFilter"&gt;
&lt;property name="authenticationEntryPoint"
ref="digestProcessingFilterEntryPoint" /&gt;
&lt;/bean&gt;
&lt;/beans&gt;</pre>
<p>Most of the above code is default spring configurations except for the following parts which I am going to explain in more details. The first snippet is defining the bean itself:</p>
<pre>&lt;bean id="securityService" class="springhttp.SecurityService"&gt;
&lt;/bean&gt;</pre>
<p>The second part is when we specify the security restrictions on the application itself. We are instructing the spring security to only allow an specific role to invoke the <em>securityService</em></p>
<pre>&lt;security:http realm="SecRemoting"&gt;
&lt;security:http-basic/&gt;
&lt;security:intercept-url pattern="/securityService" access="ROLE_ADMIN" /&gt;
&lt;/security:http&gt;</pre>
<p>The third part is whe<br />
n we define the identity repository where our users and role assignment are stored.</p>
<pre>&lt;security:authentication-manager alias="authenticationManager"&gt;
&lt;security:authentication-provider&gt;
&lt;security:user-service id="uds"&gt;
&lt;security:user name="jimi" password="jimi"
authorities="ROLE_USER, ROLE_MANAGER" /&gt;
&lt;security:user name="bob" password="bob"
authorities="ROLE_USER,ROLE_ADMIN" /&gt;
&lt;/security:user-service&gt;
&lt;/security:authentication-provider&gt;
&lt;/security:authentication-manager&gt;</pre>
<p>As you can see we are using the simple in memory user service, you may configure the an LDAP, JDBC, or a custom user service in the production environment. All other parts of the <em>applicationContext.xml</em> are Spring security filter definition. You can find explanation about any of then in <a title="Spring Security Documentation" href="http://static.springsource.org/spring-security/site/docs/">Spring Security Documentation</a> or by googling for it. <strong>To enforce security restrictions on the SercurityService for any local invocation we can simply change the first disucssed snippet as follow to allow ROLE_ADMIN and ROLE_MANAGER to invoke the service locall. </strong></p>
<pre> &lt;bean id="securityService" class="springhttp.SecurityService"&gt;
&lt;security:intercept-methods&gt;
&lt;security:protect
method="springhttp.SecurityService.getRoles" access="ROLE_MANAGER" /&gt;
&lt;/security:intercept-methods&gt;
&lt;/bean&gt;</pre>
<p>Now that we have all Spring configuration files in place, we need to add some elements to <em>web.xml</em> in order to let spring framework kick start. Following changes need to be included in the <em>web.xml</em> file.</p>
<pre>&lt;listener&gt;
&lt;listener-class&gt;
org.springframework.web.context.ContextLoaderListener
&lt;/listener-class&gt;
&lt;/listener&gt;
&lt;context-param&gt;
&lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
&lt;param-value&gt;
/WEB-INF/applicationContext.xml
&lt;/param-value&gt;
&lt;/context-param&gt;
&lt;filter&gt;
&lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
&lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
&lt;/filter&gt;
&lt;filter-mapping&gt;
&lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
&lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;
&lt;servlet&gt;
&lt;servlet-name&gt;remote&lt;/servlet-name&gt;
&lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
&lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
&lt;/servlet&gt;
&lt;servlet-mapping&gt;
&lt;servlet-name&gt;remote&lt;/servlet-name&gt;
&lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;</pre>
<p>Now that the server part is over, we can develop the client application to invoke this service we developed. The code for the client class is as follow:</p>
<pre>package client;
public class Main {</pre>
<pre>public static void main(final String[] arguments) {
final ApplicationContext context =
new ClassPathXmlApplicationContext(
"client/spring-http-client-config.xml");
String user = "bob";
String pw = "bob";
SecurityContextImpl sc = new SecurityContextImpl();
Authentication auth = new UsernamePasswordAuthenticationToken(user,
pw);

sc.setAuthentication(auth);
SecurityContextHolder.setContext(sc);

String[] roles = ((SecurityServiceIF) context.getBean("securityService")).getRoles();
for (int i = 0; i &lt; roles.length; i++) {
System.out.println("Role:" + roles[i]);
}

}
}</pre>
<p>As you can see we are initializing the application context using a xml file. We will discuss that XML file in few minutes. After the application context initialization we are creating a <em>SecurityContextImpl</em>,   and a <em>UsernamePasswordAuthenticationToken</em> then we pass the token to the security context and finally use this security context to pass it on to the server for authentication and further authorization.</p>
<p>Finally we invoke the <em>getRoles()</em> method of our <em>SecurityService</em> which returns the set of roles assigned to the currently authenticated user and print its role to the default output stream.</p>
<p>Now, the <em>spring-http-client-config.xml</em> content:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"&gt;</pre>
<pre>&lt;bean id="securityService"
class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"&gt;
&lt;property name="serviceUrl" value="http://localhost:8084/sremoting/securityService" /&gt;
&lt;property name="serviceInterface" value="client.SecurityServiceIF" /&gt;
&lt;property name="httpInvokerRequestExecutor"&gt;
&lt;bean class="org.springframework.security.remoting.httpinvoker.AuthenticationSimpleHttpInvokerRequestExecutor"  /&gt;
&lt;/property&gt;
&lt;/bean&gt;
&lt;/beans&gt;</pre>
<p>As you can see we are just setting some properties like <em>serviceURL</em> bean name, the <em>httpInvokerRequestExecutor</em> and so on. the only thing which you may need to change to run the sample is the <em>serviceUrl</em>.<br />
You can download the complete sample code form <a href="http://dl.dropbox.com/u/334201/jn-blog-files/Spring-Remoting-Security-Sample.zip">here</a>. These are two <a title="NetBeans" href="http://netbeans.org/">NetBeans</a> project, a web application and a Java SE one. You may need to add Spring libraries to the project prior to any other attempt.</p>
<p>The <em>SecurityService</em> implementation is borrowed from Elvis weblog available at <a title="http://elvisfromhell.blogspot.com/2008/06/this-was-hard-one.html" href="http://elvisfromhell.blogspot.com/2008/06/this-was-hard-one.html">http://elvisfromhell.blogspot.com/2008/06/this-was-hard-one.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/using-spring-security-to-enforce-authentication-and-authorization-on-spring-remoting-services-invoked-from-a-java-se-client/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>GlassFish Modularity System, How extend GlassFish CLI and Web Administration Console (Part I, The architecture)</title>
		<link>http://kalali.me/glassfish-modularity-system-how-extend-glassfish-cli-and-web-administration-console-part-i-the-architecture/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=glassfish-modularity-system-how-extend-glassfish-cli-and-web-administration-console-part-i-the-architecture</link>
		<comments>http://kalali.me/glassfish-modularity-system-how-extend-glassfish-cli-and-web-administration-console-part-i-the-architecture/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 10:42:34 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Modularity]]></category>
		<category><![CDATA[HK2]]></category>
		<category><![CDATA[Modular]]></category>
		<category><![CDATA[OSGI]]></category>
		<category><![CDATA[Update Center]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=354</guid>
		<description><![CDATA[Modularity is the essential design and implementation consideration which every software architects and designers should have in mind to get an easy to develop, maintain and extend software. GlassFish is an application server which highly benefits from a modularity system to provide different level of functionalities for different deployment and case studies. GlassFish fully supports [...]]]></description>
			<content:encoded><![CDATA[<p>Modularity is the essential design and implementation consideration which every software architects and designers should have in mind to get an easy to develop, maintain and extend software. </p>
<p>GlassFish is an application server which highly benefits from a modularity system to provide different level of functionalities for different deployment and case studies. GlassFish fully supports Java EE profiles, so it provides a lot of features which suits different case studies and different type of use cases. Every deployment and case study requires a subset of functionalities to be provided, administrated and maintained so, both GlassFish users, application developers, and GlassFish development team can highly benefits from modularity to reduce the overall costs for development, maintenance, administration and management of each deployment type that GlassFish supports.</p>
<p>Looking from functionalities point of view GlassFish provides extension points for further extending: administration console, CLI, containers, and monitoring capabilities of GlassFish application server in a non-intrusive and modular way.</p>
<p>From development point of view, GlassFish uses OSGI for module lifecycle management while it uses HK2 for service layer functionalities like dependency injection, service instances management, service load and unload sequence, and so on.</p>
<p>Looking from integration point GlassFish modular architecture provides many benefits for different level of integration. In bigger picture Glassfish can be deployed into a bigger OSGI container which for example may be running your enterprise application, GlassFish has many advanced subsystem like its monitoring infrastructure  which can be used in any enterprise level application for extendable monitoring, and thanks to GlassFish modularity these capabilities can be easily extracted from GlassFish without any class path dependencies headache and versioning conflicts.</p>
<p><strong><em>GlassFish Modularity</em></strong></p>
<p>GlassFish supports modularity by providing extension points and required SPIs to add new functionalities in administration console, CLI, monitoring, and possibility to develop new containers to host new type of applications.</p>
<p>Not only modular architecture provides easy extendibility but also it provides better performance and much faster starts and stops sequences as the modular architecture loads modules as soon as they get referenced by another module and not during the startup. For example, Ruby container will not start unless a Ruby on Rails application gets deployed into application server.</p>
<p>GlassFish modular system uses a combination of two module systems including well known OSGI and HK2 as an early implementation of Java module system (JSR-277). OSGI provides module and module lifecycle layers functionalities to let application server fits into bigger deployment which uses OSGI framework.  It also makes It possible to benefits from well designed and tested OSGI modularity and lifecycle management techniques which are included in OSGI. The HK2 provides service layer functionality and guarantee a smooth migration to Java SE 7 module system (JSR-277). To make it simple, HK2 is the framework which we use to develop the Java classes that we have inside our module and perform the main tasks.</p>
<p>We talked about GlassFish modules, but these modules need another entity to load, unload and feed them with their intended responsibilities which the module designed to accept.  The entity which takes care of loading and unloading modules is GlassFish kernel which itself is an OSGI bundle which implemented Kernel services.</p>
<p>When GlassFish starts, either normally using its internal OSGI framework or using an external OSGI framework, First it loads GlassFish kernel and check for all available services by looking into the implementation of different contracts in the class path and. Kernel will only loads services which are necessary during the startup or services which are referenced from another service as one of its dependencies.</p>
<p>Containers services will only starts if an application get deployed into the container, administration console extensions load as soon as administration console loads, CLI commands loads on demand and system does not preload all commands when asadmin starts, monitoring modules starts when a client bind to them.</p>
<p>GlassFish modular system does not only apply to application server specific capabilities like administration console extension, but it also applies on Java EE specifications implementation. GlassFish uses different OSGI modules for different Java EE specifications like Servlet 3 and JSF 2. These specifications are bundled using OSGI to make it easier to update the system when a new release of each specification is available.</p>
<p>Different GlassFish modules fit into different categories around GlassFish kernel. These categorizations of modules are result of modules implementing GlassFish provided interfaces for different extendibility points. We will discuss the extension points in mode details in section 3.</p>
<p> </p>
<p> </p>
<p>New features added to GlassFish using the modularity system will not differ from GlassFish out of the box features because new modules completely fit into the overall provided features.</p>
<p>All extendibility points in GlassFish designed to ensure that adding new type of containers for hosting programming languages and framework other than Java is easy to cope with. Every container that is available for GlassFish application server adds its own set of CLI commands, administration console web pages and navigation nodes, and its own monitoring modules to measure its required metrics.</p>
<p><strong><em> </em></strong></p>
<p><strong><em>2 Introducing OSGI</em></strong><strong><em> </em></strong></p>
<p>The OSGI is an extensive framework introduced to add modularity capabilities to Java before Java SE 7 being shipped. Essentially OSGI is a composition of several layers of functionalities which are building on top of each other to free Java developers from headache of overcoming the class loader complexity, dynamic plug ability, libraries versioning, code visibility, dependency management; and a publish, find and bind service model to decouple bundles. Layering OSGI gives us something similar to Figure 1.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_431gs3cxhp3_b" width="501" height="253" /></p>
<p>Figure 1 OSGI layers, GlassFish uses all except the service layer. An OSGI based application may utilize all or some of the layers in addition to OS and Java platform which OSGI is running on.</p>
<p>              OSGI runs on hand held devices with CDC profile support and Java SE. so variety of operating systems and devices can benefits from OSGI. Over this minimum platform, OSGI layers march one over the other and based on the principals of layered architecture each layer can only see its bottom layer and not its upper layer.</p>
<p>Bundle or module layer is closest to Java SE platform, OSGI bundles are Jar files which some more Meta data information, these metadata generally defines modules required and provided interfaces, but it does this task in a very effective manner. OSGI bundles provide 7 defections to help with dependencies, versioning. These definitions include:</p>
<p>       Multi-version support: several versions of the same bundle can exist in the framework. And depended bundles can use the versions that satisfy their requirements.</p>
<p>       Bundle fragments: Allows bundle content to be extended, bundles can merge to form one bundle and expose a unified export and import attributes.</p>
<p>       Bundle dependencies: Allows for tight coupling of bundles when required Import everything that another, specific bundle exports Allows re-exporting and split packages</p>
<p>       Explicit code boundaries and dependencies: Bundles can explicitly their internal packages or declare dependencies on external packages.</p>
<p>       Arbitrary export/import attributes for more control: Exporters can attach arbitrary attributes to their exports; importers can match against these arbitrary attributes when they find the required package and before importing.</p>
<p>       Sophisticated class space consistency model</p>
<p>       Package filtering for fine-grained class visibility: Exporters may declare that certain classes are included/ excluded from the exported package.</p>
<p>All of these definitions are included in the MANIFEST.MF file which is an easy to read and create text file located inside the META-INF directory of jar files. Listing 4 shows a sample MANIFEST.MF file.</p>
<p><strong>Listing 4 sample MANIFIST.MF file which shows some OSGI modules definitions</strong></p>
<p><code><br />
Bundle-ManifestVersion: 2                                       #1<br />
Bundle-SymbolicName: gfbook.samples.chapter12                    #2<br />
Bundle-Version: 1.1.0                                            #2<br />
Bundle-Activator: gfbook.samples.chapterActivator             #3 <br />
Bundle-ClassPath: .,gfbook/lib/juice.jar                          #4<br />
Bundle-NativeCode:                                                #5<br />
serialport.so; osname=Linux; processor=x86,                        #5<br />
serialport.dll; osname=Windows 98; processor=x86                   #5<br />
Import-Package: gfbook.samples.chapter7; version=&quot;[1.0.0,1.1.0)&quot;;  #6<br />
resolution:=&quot;optional&quot;                                             #6<br />
Export-Package:                                                    #7<br />
gfbook.samples.chapterservices.monitoring; version=1.1;          #7<br />
vendor=&quot;gfbook.samples:&quot;; exclude:=&quot;*Impl&quot;,                         #7<br />
gfbook.samples.chapterservices.logging; version=1.1;             #8<br />
uses:=&quot;samples.chapter7.services&quot;                                   #8<br />
</code></p>
<p>GlassFish uses OSGI Revision 4 and the version number at #1 indicates it. At #2 we uniquely identify this bundle with a name and its version together. At #3 we determine a Class which implements BundleActivator interface in order to let the bundle get notified when it stops or starts. It lets the developers to perform initialization and perform some checks when the bundle starts or perform some cleanup when the bundle stops. At #4 we define our bundle internal class path, a bundle can has JAR files inside it and bundle class loader check this class path when it looks for a classes that it requires in the same order given in the Bundle-ClassPath header. At #5 we define the bundle native dependencies per operating system.</p>
<p>At #6 we define an optional dependency on some packages, as you can see our bundle can use any version inside the given version range. At #7 we describe the exported packages along with the version and excluded classes using wildcard notation. At #8 we define that if any bundle import gfbook.samples.chapterservices.logging from our bundle and the importer bundle needs samples.chapter7.services it should use the same bundle for satisfying this import that our package uses.</p>
<p>Next layer in OSGI modularity system is the Life Cycle layer which makes it possible for bundles to installed, dependency checked, started, activated, stopped, and uninstalled dynamically. It relies on the module layer for the class path related tasks like class locating and class loading. This layer adds some APIs for managing the modules in run time. Figure 2 shows functionalities of this layer.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_432f2cvbnr8_b" width="417" height="260" /></p>
<p>Figure 2 OSGI life cycle layer states. A module need to be stopped and has no dependency to be uninstalled.</p>
<p>     Installed: the bundle has been installed and but all bundle dependencies have not been satisfied, for example one of its imported packages in not exported by any of currently resolved bundles.</p>
<p>     Resolved: Bundle is installed and all of its dependencies are satisfied, this is an in-transit state and bundles do not stay in this state.</p>
<p>       Starting: Another temporary state which a bundle goes through when it is going to be activated.</p>
<p>       Active: Bundle is active and running.</p>
<p>     Stopping: A temporary state which a bundle goes through when it is going to be stopped.</p>
<p>       Uninstalled: Bundle is not in the framework anymore.</p>
<p>Next layer in OSGI mode is the Service model, the layer which is not used by eclipse provides several functionalities for the deployed bundles. First it provides some common services which are common in all applications, services like logging and security. Secondly it provides a set of APIs which bundles developers can use to developed OSGI friendly services and publish them in the OSGI framework service registry, search for services that their bundles need in the registry and bind to the services that they need. This layer is not used by GlassFish.</p>
<p>All that GlassFish taken from OSGI is its bundle and life cycle management layers. Adhering to these two layer guidelines let GlassFish be able to fit in bigger systems which are OSGI compliant and it can host new modules based on OSGI modularity system. Now that you know How GlassFish modularity system uses OSGI, you are ready to see what is inside these modules and what GlassFish propose for developing the module functionalities.</p>
<p><strong><em>3 Introducing HK2</em></strong></p>
<p>We said that GlassFish uses HK2 for service layer functionalities. First question which you may ask is OSGI service model has not utilized for GlassFish; answer is that the HK2 is more aligned with Java Module System (JSR-277) which is going to be a part of Java Runtime in Java SE 7 and eventually replacing HK2 with Java SE modularity system will be easier that replacing OSGI service model layer with Java SE service model layer.</p>
<p><strong><em>3.1 What HK2 is</em></strong></p>
<p>GlassFish as a modular application system should have a kernel which all modules plug into it to provide some functionality which call services. In order for the kernel to place the services in the right category and place, services are developed based on some contracts which are provided by the GlassFish application server designer and developers.</p>
<p>A contract describes the extension point building blocks and a service is an implementation which fits that particular building blocks. HK2 is a general purpose modularity system and can be used in any application which requires a modular design.</p>
<p>An HK2 service should adhere to a contract and it means nothing but extending an interface which HK2 kernel knows its structure and knows how to use it. But interfaces alone can not provide all information which a module may require to identify itself to the kernel. So HK2 provides a set of annotations which let the developers to provide some META data with the component to make it possible for the kernel to place it in the correct place.</p>
<p>A system which looks for modularity should have a complex requirement which leas to a architecture, and modularity is one of many helpers with design and development of a complex software.</p>
<p>In software as big as GlassFish objects need other objects during the construction, they need configuration during construction or after the construction during a method execution, objects may need to provides some of their internal objects available for other object which may need them, objects need to be categorized into different scopes to prevent any interference between objects that need scoped information and objects that runs without storing any state information (stateless).</p>
<p>First things first</p>
<p>Do we need to discuss contract and service annotation source code?</p>
<p>, after we developed a service by implementing a contract which is an interface, we should have a way to inform HK2 that our implementation is a service, it has a name and it has a scope. To do this we use a @Service annotation, listing 1 shows an example of using @Service annotation.</p>
<p><strong>Listing 1 HK2 @Service annotation</strong></p>
<p><code><br />
@Service (name=&quot;restart-domain&quot;,                                  #1<br />
scope=org.jvnet.hk2.component.PerLookup.class,                                    <br />
factory=gfbook.chapterCommandFactory)<br />
public class RestartDomain implements AdminCommand {                     #2<br />
...<br />
}</p>
<p></code></p>
<p>Very simple, just an annotated POJO provide the system with all required information to accept it as a CLI command. At #1 we define the name of the service that we want to develop, late on we define the scope of the component. At #2 implement the contract interface to make it possible for the kernel to use our service in the way that it knows. Scope can be one of the built-in scopes or any custom implemented scope by implementing org.jvnet.hk2.component.Scope contract. The custom scopes should take care of the objects lifecycle. Built-in scopes are:</p>
<p> </p>
<p>     Per Lookup scope: Components in this scope will create new instances every time someone asks for it, the implementation class is: org.jvnet.hk2.component.</p>
<p>     Singleton scope: Objects in this scope stay alive until the session’s ends and any subsequent call for instantiating such objects end in returning the available object. The implementation class is: org.jvnet.hk2.component.Singleton.</p>
<p>The @Service annotation accepts several optional elements as follow, these elements are just for sake of better and more readable, maintainable and customizable code, otherwise they are not required and HK2 determine default values for each element.</p>
<p>       The name element defines the name of the service. The default value is an empty string.</p>
<p>     The scope element defines the scope to which this service implementation is tied. The default value is org.jvnet.hk2.component.PerLookup.class.</p>
<p>     The factory element defines the factory class for the service implementation, if the service is created by a factory class rather than by calling the default constructor. If this element is specified, the factory component is activated, and Factory.getObject is used instead of the default constructor.</p>
<p> </p>
<p>What if our service requires accessing another service or another object? How we will decide whether we should initiate a new object and use it or use a currently available object? Should we as service developers really involve with a complex service or object initialization task?</p>
<p>First let’s look at instantiation, HK2 is an IOC pattern implementation and so, No object instantiation will need to go though calling new() method and instead you will ask the IOC to return an instance of your required component. In HK2, ComponentManager class is in charge of providing a registry for instantiated components, and also it bear the responsibility of initializing components that are not initialized upon a client request. Clients ask ComponentManager for a component By calling getComponent(ClassT contract). And ComponentManager manager ensure that either it returns a correct instance based on available instance and their scopes or it create a new instance by traversing the entire object graph required for initializing the component. The ComponentManager methods are threading safe and maintain no session information between consequent calls.</p>
<p>Components developers need to have some control to ensure all required resources and configuration are ready after the construction and before any other operation; also they may need to perform some housekeeping and cleanup before destroying the object. So two interfaces are provided which components can implement them to register for a notification upon object construction and destruction. There two interfaces are org.jvnet.hk2.component.PostConstruct and org.jvnet.hk2.component.PreDestroy, each interface just has one method named postConstruct and preDestroy. The ComponentManager is also in charge of resource injection to components properties during construction and also resource extraction from components.</p>
<p>First lets see resource extraction which may be unfamiliar, Some components may create an internal object which carry some information required by some other components in the system or similar components which are going to be constructed. These internal objects can be marked with @Extract annotation which is located at org.jvnet.hk2.annotations.Extract. This annotation makes define the property to be extracted and placed in a predefined scope or the default scope which is PerLookup scope.</p>
<p>After an object is extracted, HK2 place it inside a container of type org.jvnet.hk2.component.Habitat, the container will provide any object which needs one of its inhabitants. Listing 2 shows how a property of an object can be marked as an extraction.</p>
<p><strong>Listing 2 The HK2 extraction sample</strong></p>
<p><code><br />
@Service (name=&quot;restart-domain&quot;,                                 scope=org.jvnet.hk2.component.PerLookup.class,                                    <br />
factory=gfbook.chapterCommandFactory)<br />
public class RestartDomain implements AdminCommand {                   <br />
@Extract                                                                                                                  #1<br />
LoggerService logger;<br />
@Extract                                                                                                  #2<br />
public CounterService getCounterService() {...}<br />
}<br />
 </code></p>
<p>At #1 we mark a property for extraction and at #2 we extract the object from a getter method, so remember that @Extract annotation works both on property and getter level. Now let’s see how these inhabitant objects can be used by another service which needs these two functionalities.</p>
<p><strong>Listing 3 The HK2 extraction sample</strong></p>
<p><code><br />
@Service (name=&quot;restart-domain&quot;,                                 scope=org.jvnet.hk2.component.PerLookup.class,                                    <br />
factory=gfbook.chapterCommandFactory)<br />
public class RestartDomain implements AdminCommand {                   <br />
@Inject protected Habitat habitat;                                                                      #1<br />
public void performAudition() {<br />
LoggerService logger = habitat.getComponent(LoggerService.class);         #2<br />
CounterService counter = habitat.getComponent(CounterService.class);       #2<br />
}<br />
}<br />
<code></p>
<p>At #1 we inject the container into a property of these object, you see this is world of IOC, and we have no explicit object creation, at #2 we ask habitat to provide us with instance of LoggerService and CounterService.</p>
<p>Now you should have required understanding of OSGI Bundle layer and HK2 basics we can get our hands down to write some GlassFish modules to see how these two can be used to GlassFish modules in this article  and the upcomming one.</p>
<p> </p>
<p><strong><em>4 GlassFish Containers and Containers extendibility</em></strong></p>
<p>GlassFish is a multi purpose application server which can host different kind of applications developed using variety of programming languages like Ruby, Groovy and PHP in addition to support for Java EE platform based applications.</p>
<p>The concept of container makes it possible to let GlassFish application server host new types of applications which can be developed using either Java programming language or other programming languages. Imagine that you want to develop a new container which can host a brand new type of application. These type of application will let GlassFish users to deploy a new type of archived package which contains descriptor files along with required classes for performing scheduled tasks in a container managed way. The new type of application is developed using Java and for sure it can access all GlassFish application server content and in the same way it can access some operating system related scripts like shell scripts for performing operating system related tasks on schedule.</p>
<p>GlassFish may have tens of different type containers for different type of applications so, before anything else, each container must have a name in order to make it possible for GlassFish kernel to access them easily. In the next step, GlassFish should have some mechanism to determine which container an application should be deployed to. Then there should be a mechanism to determine which URL patterns should be passed to a specific container for further processing. And finally, each application has some set of classes which container should load them to process the incoming request, so a class loader with full understanding of the application directory structure is required to load the application classes.  Figure 3 shows the procedure of application deployment from the moment that a deployment command received by GlassFish up to the stage that the container becomes available to GlassFish deployment manager. </p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_433f64jrbdt_b" width="336" height="456" /></p>
<p>Figure 3 Application deployment activities in GlassFish</p>
<p>Is this figure too busy? Also, there are some typos in it, so keep this flagged</p>
<p>  from early start until GlassFish get the designated container name.</p>
<p>Figure 4 shows activities that happen after the container become available to GlassFish application deployment manager up to the point that GlassFish get a class loader for the deployed application. </p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_434fjqfcfc4_b" width="503" height="351" /></p>
<p>Figure 4 Activities which happens after GlassFish get the specific container name</p>
<p>GlassFish container SPI provides several interfaces which container developers can consider implementing them to develop their containers. These interfaces provide necessary functionalities for each activity in figure 3. First let’s see what are required for the first step which is checking the deployment artifact which can be a compressed file or a directory.</p>
<p>When an artifact is passed to GlassFish for deployment, first the artifact goes though a check to see which type of archive it is and which container can host this application. So we need to be able to check an archive and determine whether is compatible with our container or not. To do this we must implements an interface with the fully qualified name as org.glassfish.api.container.Sniffer, GlassFish creates a list of all Sniffer implementations and pass the archive to each one of them to see whether an Sniffer know the archive or not. Listing 4 shows a dummy Sniffer implementation</p>
<p> </p>
<p><strong>Listing 4 Sniffer interface</strong></p>
<p><code><br />
@Service(name = &quot;TextApplicationSniffer&quot;)<br />
@Scoped(Singleton.class)<br />
public interface TextApplicationSniffer implements Sniffer{<br />
public boolean handles(ReadableArchive source, ClassLoader loader){} #1<br />
public Class&lt;? extends Annotation&gt;[] getAnnotationTypes(){} #2<br />
public String[] getURLPatterns(){}                                  #3<br />
public String getModuleType(){}                                     #4<br />
public Module[] setup(String containerHome, Logger logger) throws IOException(){}                                                      #9<br />
public void tearDown(){}                                           #5<br />
public String[] getContainersNames(){}                             #6<br />
   public boolean isUserVisible(){}                                   #7<br />
public Map&lt;String,String&gt; getDeploymentConfigurations(final          ReadableArchive source) throws IOException{}                           #8<br />
}<br />
<code></p>
<p>An implementation of Sniffer interface should return true or false based on the fact that either it understands the archive or not #1. ReadableArchive interface implementations provide us a virtual representation of the archive content and let us check for specific files or file size or it let us check for presence of another archive inside the current one and so on.</p>
<p>If we intend to use a more complex analyze of the archive, for example by checking the presence of a specific annotation we should return list of annotations in getAnnotationTypes #2. GlassFish scan the archive for presence of one the annotations and continue with this Sniffer if a class is annotated by one of these annotations.</p>
<p>If this is the Sniffer that understands the archive then GlassFish asks for a URL patterns that GlassFish should call the container service method when a request matches that pattern#3. At #4 we define the module name which can be a simple string.</p>
<p>At #5 we just remove everything related to this container from the module system. At #6 we should return a list of all containers that this specific Sniffer can enable.</p>
<p>At #7, we determine whether the container is visible to users when they deploy an application into the container or not and at #8 we should return all interesting configuration of the archive which can be used during the deployment or runtime of the application.</p>
<p>The most important method in the Sniffer interface is the setup method which will setup the container if container is not already installed. #9 As you have already noticed the method have the path to container home directory so, the container is not installed already Sniffer can download the required bundles from the repositories and configure the container with default configurations. The method returns a list of all modules that are required by the container; using this list GlassFish prevent removal of any of these modules and check for the container class to resume the operation. </p>
<p>The org.glassfish.api.container.Container is the GlassFish container contract which each container should implements, Container interface is the entry point for GlassFish container extendibility. Listing 5 shows a dummy Container implementation. Container class does not need to perform anything specific, all tasks will delegate to another class which perform the </p>
<p><strong>Listing 5 dummy container implemenatation</strong></p>
<p><code><br />
@Service(name = &quot;gfbook.chaptercontainer.TextApplicationContainer&quot;)       #1<br />
public class TextApplicationContainer implements Container {                 #2<br />
  public Class&lt;? extends Deployer&gt; getDeployer() {              #3<br />
      return gfbook.chaptercontainer.TextApplicationDeployer.class;#3<br />
  }<br />
  public String getName() {<br />
      return &quot; Text Container&quot;;                   #4<br />
  }<br />
</code></p>
<p>At #1 we define a unique name for our container, we can use fully qualified class name to ensure that it is unique. At #2 we implement the container contract to let the GlassFish kernel use our container in the way that it knows. At # we return our Deployer interface implementation class name which will take care of tasks like loading, unloading, preparing, and other application related tasks. At #4 we return a human readable name for our container.</p>
<p>You can see that container has nothing special except that it has an implementation of org.glassfish.api.deployment.Deployer which GlassFish kernel will use to delegate the deployment task. Listing 6 shows snippet code from Text application container’s deployer implementation.</p>
<p><strong>Listing 6 Deployer implementation of TextApplication container</strong></p>
<p><code><br />
@Service<br />
public class TextApplicationDeployer implements Deployer&lt;TextContainer,    TextApplication&gt; {                   #1<br />
              public boolean prepare(DeploymentContext context) {    } #2<br />
    public &lt;T&gt; T loadMetaData(Class&lt;T&gt; type, DeploymentContext context) { }#3<br />
    public MetaData getMetaData() {}#4<br />
    public TextApplication load(TextContainer container, DeploymentContext context) {}                               #5<br />
    public void unload(TextApplication container, DeploymentContext context) {}                  #6<br />
    public void clean(DeploymentContext context) {}  #6<br />
}<br />
</code></p>
<p>Methods that are shown in the code snippet are just mandatory methods of Deployer contract that, our implementation may have some helper methods too. At #1 we define our class as an HK2 service which implements Deployer interface.</p>
<p>At #2 we prepare the application for deployment it can be unzipping some archive files or pre-processing the application deployment descriptors to extract some required information for deployment task. Several methods of the Deployer interface accept a org.glassfish.api.deployment.DeploymentContext as one of its parameters, this interface provides all contextual information about the currently under processing application. For example application content in term of files and directories, accessing the application class loader, all parameters which passed to deploy command and so on.</p>
<p>At #3 we return a set of MetaData that is associated with our application, these metadata can contain information like application name and so on. At #4 we should return an instance of org.glassfish.api.deployment.MetaData which contains special requirement which this Deployer instance needs these requirement can be loading a set of classes before loading the application using a separate class loader, or a set of metadata that our Deployer instance will provides after successfully loading the application. We will discuss the MetaData in more details in next step. At #5 we load the application and return an implementation of org.glassfish.api.deployment. The ApplicationContainer manages the lifecycle of the application and its execution environment. At #6 we undeploy the application from the container which means that our application should not be available in the container anymore. At #7 we clean any temporary file created during the prepare method execution.</p>
<p>Now the TextApplication class which implements application management tasks like starting application, stopping application. The sample snippet for this class can be similar to listing 7.</p>
<p> </p>
<p><strong>Listing 7 Snippet code for TextApplication class</strong></p>
<p><code><br />
public class TextApplication extends TextApplicationAdapter<br />
                implements ApplicationContainer{ #1<br />
  public boolean start(ApplicationContext startupContext) {   }<br />
  public boolean stop(ApplicationContext stopContext) {  }<br />
  public boolean resume()<br />
  public ClassLoader getClassLoader() {  }<br />
  public boolean suspend()<br />
  public Object getDescriptor() {  } #2<br />
}<br />
</code></p>
<p>All portion of the code should be self explaining except that in #2 we return the application descriptor to GlassFish deployment layer and in #1 which we do a lot of works including interfacing our container with Grizzly (the web layer of GlassFish).</p>
<p>You remember that in listing 6 we returned an instance of TextApplication when the container calls the load method of the Deployer object, this object is responsible for application lifecycle including what you can see in the listing 7 and also it is responsible for interfacing our container with Grizzly layer. Listing 8 shows the snippet of the TextApplicationAdapter abstract class implementation. Extending the com.sun.grizzly.tcp.http11.GrizzlyAdapter helps with developing custom containers which need to interact with HTTP layer of GlassFish. The com.sun.grizzly.tcp.http11.GrizzlyAdapter has one abstract method which we talk about it when we were discussing the Sniffer interface implementation and that method is the void service(GrizzlyRequest request, GrizzlyResponse response) which is called when ever a request hits a URL matching with one of the container’s deployed application.</p>
<p> </p>
<p> </p>
<p><strong><em>5 GlassFish</em></strong> <strong><em>Update</em></strong> <strong><em>Center</em></strong></p>
<p> </p>
<p>Glassfish update center is one of its outstanding features which help developers and system administrators to spend less time on updating and distributing applications on multiple GlassFish instances. In this section we will dig more into how update center works, and how we can develop new package for the update center.</p>
<p>The update center name may be misleading that it can just works for updating the system, but reality is that it has more functionalities than what its name reveal. Figure 1.3 shows update center Swing client running in a Linux machine. At your left hand you will see a navigation tree which let you select what kid of information you want to view regarding update center functionalities. These tasks include:</p>
<p>       Available Updates: The Available Updates node includes information about available updates for installation. It shows the basic details about each available update and identifies if the update is new and whether its installation needs a restart to complete. You can select the desired component from the table and click install. </p>
<p>       Installed Software: The Installed Software node shows the software components currently installed. This is the place which you can remove any of not required piece of software from your GlassFish installation and let it run lightly. Upon trying to uninstall any component GlassFish will check to find what components are depending on it and let you decide whether you want to remove all of them or not. The Details section of the window shows more information for the installed software including technical specifications, product support, documentation, and other useful resources.</p>
<p>       Available Software: The Available Software node shows all the software components available for installation through the Update Center. These are new set of components like new containers, new JDBC drivers, and new web applications and so on. The Details section of the window shows more information for the installed software including technical specifications, product support, documentation and other useful resources.</p>
<p>Now that we know what the update center can do, let’s see how we should bootstrap it in our application server. GlassFish is the modular application server and so, update center itself is a module which can be present or not, by default the update center modules are not bundled with GlassFish installation and GlassFish download and installs its bit upon the first access, just like GlassFish administration console.</p>
<p>GlassFish installer will bootstrap the GlassFish Update Center during installation if a internet connection was available. If your environment had no Internet connection during the installation you can bootstrap the update center by navigating to GlassFish_Home/bin and running updatetool script, it is either a shell script or a batch file. After you execute the command it will download the necessary bits and configure the update center. Running the command again will result in seeing the update center tool GUI similar to figure 5.</p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_435d9jbdvf8_b" width="503" height="224" /></p>
<p>Figure 5 Update Center Tool, it can manage multiple application installation</p>
<p>In the Navigation Tree you can see that several installations can be managed using a single Update Center front end. These are installed image in the system along with manually create image for GlassFish in Action Book.</p>
<p><strong><em>5.1 Update center in the administration console</em></strong></p>
<p>GlassFish administration system is all about effectiveness, integration and ease of use so the same update center functionalities are available in the GlassFish administration console to let the administrators check and install updates without having shell level access to their machines. Administrators can navigate to Update Center page in GlassFish administration page and see which updates and which new features are available for their installed version. </p>
<p>Figure 5 shows web based update center page with all features that desktop based version has. Integrating the update center functionalities into administration console is along with GlassFish promises to keep all administration tasks for a single machine or a cluster integrated into one single application.</p>
<p> </p>
<p> </p>
<p> </p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_436drmsbsdn_b" width="503" height="251" />Figure 6 Update center pages in GlassFish administration console with the same functionalities of desktop GUI.</p>
<p>I know that you want to ask, what about update notification, how often I should check for updates. GlassFish development team knows that administrators like to be notified for available updates, therefore there are two mechanisms for you to get notified about available updates. The first way is by means of the notification text which appears in the top bar of the administration console as shown in figure 7. </p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_437g2z6pdd8_b" width="504" height="180" /></p>
<p>Figure 7 Update center web based notification and integration of the notification icon in Gnome desktop</p>
<p>You are asking for more passive way of notification, are a CLI advocate administrator, then you can use the Try Icon notification system which notifies you about available updates by showing a bulb in your system try. There is no different if you are using Solaris, Linux or windows, you can activate the notification icon simply by issuing the following command in the GlassFish_Home/updatetool/bin/ directory.</p>
<p>./updatetool --register</p>
<p>And you are done, the registration of update center notification icon is finished and after your next startup you can see the notification icon which notifies you about availability of new updates and features. Figure 7 shows the two notification mechanism discussed.</p>
<p>The update center helps us to keep our application server up to date by notifying us about availability of new packages and features. This features and packages as we already know either should be OSGI bundles or they should be some other types of packages which can be used for transferring any type of files. The update center uses a general packaging system to deliver the requested packages which may contains one or more OSGI bundles, operating system binary files, graphic and text and any other types of contents.</p>
<p>This general purpose and very powerful packaging system is called pkg(5) Image Packaging System or in brief IPS.</p>
<p><strong><em>6</em></strong> <strong><em>GlassFish packages distribution</em></strong></p>
<p>Update center as we can see in the GlassFish use case, helps us to keep our application server up to date and let us install new components or remove currently installed components to keep the house clean of not required components. But the so called update center is much more important and bigger than just updating the GlassFish installation. Update center is part of a bigger general purpose binary package distribution for distributing modular software systems in different operating system without interfering with the operating system installation sub-system or so called root permission.</p>
<p>GlassFish version 2 has an update center, which you can use to manage the GlassFish installation however that update tool was using a module model like NetBeans NBM files to transfer the updates from the server to local installation. But in GlassFish version 3 the update center system and GlassFish installation system has completely changed. We know that the GlassFish installer and OpenInstaller framework, you may remember from 2.2 that that GlassFish installer uses a specific type of binary distribution system designed by OpenSolaris named pkg(5) Image Packaging System (IPS). Now we are going to discuss IPS in more details along with its relation with GlassFish update center. The IPS developed using Python to ensure that it is platform independent and will execute on every platform with minimal required dependencies.</p>
<p><strong><em>6.1 PKG(5) Image Packaging System, simply IPS</em></strong></p>
<p>The IPS is a software delivery system based heavily on using network repositories to distribute the software system either completely from the network repositories or in a mixture of using network repositories and initially downloaded packages. Generally speaking IPS helps with distributing and updating software system on different levels independent of the operating system and the platform that the software is going to be installed. </p>
<p>IPS is consisting of several components which Some of them are mandatory for maintaining a system based on IPS and some of them are just provided to let us make the overall procedure of creating, maintaining, and using IPS based software distribution easier.</p>
<p>       End user Utilities: There is a set of command line utilities that let the end users to interact with the server side software which serve as repository front end to let clients fetch and install updates and new features for their installed software.</p>
<p>       GUI based Client side software: like the Java based Update Center  which is in use by GlassFish</p>
<p>       API for interacting with IPS: There are some Java APIs provided for Java developers to be able to perform IPS related tasks from their Java applications, it provides better integration with java application and more flexibilities for ISVs and OEMs to develop their own client side applications.</p>
<p>       Installation images: An Installation image is a set of packages for an application that provides some or all of its functionalities.</p>
<p>       Servers side utilities: An HTTP server which sit in front of the physical repository to interact with the clients.</p>
<p>       Development utilities: A set of utilities that helps developers with creating IPS packages. The build systems integration as a subset of development utilities. For now IPS integration with Maven and ANT is available which integrate and automate creating and publishing the package to repositories with the build system.</p>
<p>In IPS, a software installation is called an image that we can say is a customized mirror of the installation repositories in term of installed packages. Different types of images are defined in the IPS including:</p>
<p>       Operating system level images: This type of images is just in use for distributing Operating systems and operating system upgrades. Images in this level are called Full images and partial images.</p>
<p>       Custom application level image: This is the image level which software developers and distributes can use to distribute their application. This image is called user images and does not require the host operating system to be based on IPS.</p>
<p>Let’s see how GlassFish installer is related to IPS, GlassFish installer solely asks the user for the path which user wants to expand GlassFish IPS image and perform the initial configuration on the expanded image. These initial configurations include creating of a default domain along with setting the key repositories for domain password and master password. The expanded image will interact with some preconfigured network repository to fetch information about updates and new features which are available for expanded GlassFish image.</p>
<p>Package repositories, which installation image interact with, contain packages which lead to updating, completing or adding new features to an already installed image. These packages can differ from one operating system to another and Because of these differences different repositories are required for different operating systems. </p>
<p>An installation image can be as big as an operating system image or as small as necessary bootstrapping files to bootstrap the IPS and let it perform the rest of installation task. So a user image can be categorized under one of the following types:</p>
<p>       The image with some basic required functionality, for example GlassFish web container. These basic functionalities can be operating system independent for sake of simplicity in distributing the main image. The image can contain complete IPS system including its utilities and client application like GlassFish update center or it may just contain a script to bootstrap the IPS system installation.</p>
<p>       The image may contains the very basic and minimal packages to bootstrap the IPS system, the user will run the IPS bootstrapping script to install more IPS related packages like graphical Update Center client and later on install all required features by using these IPS utilities.</p>
<p><strong><em>6.2 Creating packages using IPS</em></strong></p>
<p>Now that we have an understanding of what is IPS and what is its relation with GlassFish installer and GlassFish itself we can get our hands on IPS utilities and see how we can use command line utilities or use the IPS to create new packages. Figure 8 shows GlassFish directory structure after bootstrapping the Update Center. Keep it in mind that bootstrapping the GlassFish Update Center result in installation of pkg(5) IPS utilities.</p>
<p>You may ask what the relation GlassFish modularity, extendibility, OSGI and HK2 is with IPS, IPS image is zip files containing the GlassFish directory layout including its files like its OSGI bungles, JAR files, documentation and so on. Later on, each IPS package which can be an update to currently installed features or a brand new feature is a zip file which can contain one or more OSGI bundle along with their related documentation and thing like that.</p>
<p>Two directories in GlassFish directory structure are related to IPS and GlassFish Update Center. The pkg directory includes all necessary files for IPS system which includes man pages, libraries which Java developers can use to develop their own application on top of IPS system or their own application for bootstrapping the IPS; it also includes a minimal Python distribution to let users execute the IPS scripts. The vendor-packages contain all packages downloaded and installed for this image which is the Update Center image.</p>
<p>From now on, we referee to pkg folder with the name ips_home so you should replace it with the real path to the pkg directory or you can set an environment variable with this name pointing to that directory.</p>
<p> </p>
<p> </p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_438dcdjh2fs_b" width="208" height="296" /></p>
<p>Figure 8 Update center and pkg(5) IPS directory layout</p>
<p>The bin directory that resides inside the pkg directory includes IPS scripts for both developers and end users, these scripts are listed in table 1 with their description.</p>
<p>Table 1 IPS scripts with associated description</p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><strong>Script</strong> </p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>Description</strong></p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">pkg</p>
</td>
<td>
<p align="left"></p>
<p align="left">Can be used to create and update images</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">pkg.depotd</p>
</td>
<td>
<p align="left"></p>
<p align="left">This is the repository server for the image packaging system. The pkg or other retrieval clients send packages and catalog recovery request to the repository server.</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">pkgsend</p>
<p align="left"> </p>
</td>
<td>
<p align="left"></p>
<p align="left">Let us publish new packages and new package versions to an image packaging depot server.</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">pkgrecv</p>
</td>
<td>
<p align="left"></p>
<p align="left">Let us download the contents of a package from a server. Content format is suitable for pkgsend command.</p>
</td>
</tr>
</table>
<p>You can see some Python scripts in the bin directory. These scripts perform the real tasks explained for each of the above operating system friendly scripts.</p>
<p>The updatetool folder is where Update Center GUI application is located along with its documentation and related scripts. The bin directory contains two scripts for running the Update Center and registering the desktop notifier which keeps you posted about new updates and available feature by showing a balloon with the related message in your system try section. The vendor-packages folder contains all packages downloaded and installed for this image which is the Update Center image.</p>
<p>Now let’s see how we can setup a repository, create a package and publish the package into the repository. I am just going to create a very basic package to show the procedure, the package may not be useful for GlassFish or any other application.</p>
<p>First of all we need a directory to act as the depot of our packages, a place which we are sure our user has the read and write permission along with enough space for our packages.  So create a directory named repository, the directory can be inside the ips_home directory. Now start the repository server by issuing the following command inside the ips_home/bin directory.</p>
<p>./pkg.depotd -d ../repository -p 10005</p>
<p>To check that your repository is running open <a href="http://127.0.0.1:10005/">http://127.0.0.1:10005</a> in your browser and you should see something similar to figure 9 which includes some information about your repository status. </p>
<p><img src="http://docs.google.com/File?id=ajhfp4djcnw6_439zwwq5qgz_b" width="297" height="243" /></p>
<p>Figure 9 The Repository status which we can see by pointing the browser to the repository URL.</p>
<p> </p>
<p>Now we have our repository server running and waiting for us to push our packages into it and later on download those packages by our client side utilities like pkg or Update Center.</p>
<p>Our packages should be placed in the package repository and the command which can do this for us is pkgsend command. You should already though about the urge for a way to describe content of a package, its version, description, and so on. The pkgsend command let us open a transaction and add all package attribute, its included files and directory layout and finally close the transaction which lead to pkgsend sends our package to the repository. The pkgsend command can acts in a transactional way which means we can have a set of packages which we need either all of them in the repository or none of them. This model guaranteed that we may never have incompatible packages in the repository during the time that we push updates. To create a sample package we need some contents, so create a directory inside the pkg directory and name it sample_package, put two text files named readme.txt and license.txt inside it. Inside the sample_package directory create a directory named figures with an image file named figure1.jpg inside it. These are dummy files and their content can be anything that you like. You may add some more files and create a directory structure to test more complex structured packages. Listing 8 shows a series of commands which we can use to create and push the package that we have just prepared its content to the repository that we create in previous step. I assumed that you are using Linux so the commands are Linuxish and you should enter them line by line in the terminal window which can be either a gnome-terminal or any other terminal of your choice. If you want to see how a transaction works you can point your browser to <a href="http://127.0.0.1:10005/">http://127.0.0.1:10005/</a> during the executing of listing 8 commands.</p>
<p><strong>Listing 8 Create and push the sample package to our repository</strong></p>
<p><code><br />
export PKG_REPO=http://127.0.0.1:10005/                           #1<br />
eval './pkgsend open GFiASample@1.0'                              #2<br />
./pkgsend add set name=&quot;pkg.name&quot; value=&quot;GFiASamplePackage&quot;      #3<br />
./pkgsend add set name=&quot;pkg.description&quot; value=&quot;sample description&quot; #4<br />
./pkgsend add set name=&quot;pkg.detailed_url&quot; value=&quot;sample.com/kalali&quot; #5  <br />
./pkgsend add file ../sample_package/readme.txt path=GFiA/README.txt  #6<br />
./pkgsend add dir path=GFiA/images/                      #7<br />
./pkgsend add file ../sample_package/figures/f.jpg path=GFiA/figs/f.jpg #8<br />
./pkgsend add license ../sample_package/license.txt license=GPL         #9<br />
./pkgsend close               #10<br />
 <br />
</code></p>
<p>At #1 we export an environment variable which IPS scripts will use as the repository URL, otherwise we should pass the URL with –s <a href="http://127.0.0.1:10005/">http://127.0.0.1:10005/</a> in each command execution. At #2 we open a transaction named <a href="mailto:GFiASample@1.0">GFiASample@1.0</a> for uploading a package. At #3 we add the package name.  At #4 we add the package description which will appear in the description column of the Update Center GUI application or pkg command information retrieval.  At #5 we add the URL which contain complementary information, Update Center fetch the information from provided URL and it will show them in the description pane. At #6 we add a text file along with its extraction path; At #7 we add a directory which our package installation will create in the destination image. At #8 we add a file to our previously created directory. At #9 we add the package license type along with the license file, later on license type can be used to query the available packages based on their licenses. And finally at #10 we close the transaction will result in appearance of the package in the package repository.</p>
<p>Now we have one package in our repository, you can find the number packages in the repository by opening the repository URL which is http://127.0.0.1:10005/ in your browser.</p>
<p>You may already recognize a pattern in using pkgsend command and its parameters, and if you did you are correct because pkgsend commands are following a pattern which is similar to pkgsend subcommand [subcommand parameters]. List of important pkgsend subcommand is shown in table 2.</p>
<p>Table 2 List of pkgsend subcommands which can be used to send a package to repository</p>
<p> </p>
</p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><strong>Subcommand</strong> </p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>Description</strong></p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">open</p>
</td>
<td>
<p align="left"></p>
<p align="left">Begins a transaction on the package specified by package name. </p>
<p align="left">Syntax : pkgsend open pkg_name</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">add</p>
</td>
<td>
<p align="left"></p>
<p align="left">Adds a resource associated with an action to the current transaction.</p>
<p align="left">Syntax : pkgsend add action [action attributes]</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">close</p>
</td>
<td>
<p align="left"></p>
<p align="left">Close the current transaction.</p>
<p align="left">Syntax : pkgsend close</p>
</td>
</tr>
</table>
<p> </p>
<p>You can see complete list of subcommands in the pkgsend man files or in the pkg(5) project website located at <a href="http://www.opensolaris.org/os/project/pkg/">http://www.opensolaris.org/os/project/pkg/</a>.</p>
<p>The add subcommand is the most usefull subcommand between the pkgsend subcommands, it takes actions which we need to the transaction along with the actions attributes. You have already seen how we can use set, file, dir, and license actions. As you see each action may accept one or more named attributes. Other important actions are listed in table 3.</p>
<p>Table 3 list of other important add actions </p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><strong>Action</strong> </p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>Description and Key Attributes</strong></p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Link</p>
</td>
<td>
<p align="left"></p>
<p align="left">The link action represents a symbolic link. The path attribute define the file system path where the symlink is installed.</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Hardlink</p>
</td>
<td>
<p align="left"></p>
<p align="left">The hardlink action represents a physical link.The path attributes define the file system path where the symlink is installed.</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Driver</p>
</td>
<td>
<p align="left"></p>
<p align="left">The driver action represents a device driver. It does not reference a payload, the driver files must be installed as file actions. The name attribute represent the name of the driver. This is usually, but not always, the file name of the driver binary.</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Depend</p>
</td>
<td>
<p align="left"></p>
<p align="left">The depend action represents a dependency between packages. A package might depend on another package to work or to install. Dependencies are optional.</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Group</p>
</td>
<td>
<p align="left"></p>
<p align="left">The group action defines a UNIX  group. No support is present for group passwords. Groups defined with this action initially have no user-list. Users can be added with the user action.</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">User</p>
</td>
<td>
<p align="left"></p>
<p align="left">The user action defines a UNIX user as defined in /etc/passwd, /etc/shadow, /etc/group and /etc/ftpd/ftpusers files. Users defined with this attribute have entries added to the appropriate files.</p>
</td>
</tr>
</table>
<p> </p>
<p>Now that we are finished with the pkgsend, let’s see what alternatives we have in using our package repository. We can either install the package into an already installed package like our GlassFish installation or we can create a new package in our client machine and install the package into that particular image.</p>
<p>To install the package in the current GlassFish installation open Update Center, select GlassFish node in the navigation tree and then select Image Properties from file menu or press CTRL+I to open the image properties window. Add a new repository; enter GFiA.Repository as name and <a href="http://127.0.0.1:10005/">http://127.0.0.1:10005/</a> as the repository URL.  Now you should be able to refresh the Available Add-ons list and select GFiA Sample  Package for installation.</p>
<p>The installation process will be fairly simple as it will just execute the given actions one by one which will result in creation of a GFiA directory inside the GlassFish installation directory with two text files inside it. The package installation also creates the figs directory inside GFiA directory along with adding the image file inside it. </p>
<p>You get the idea that you can copy your package files anywhere in the host image (GlassFish installation in this case) so, when you want to distribute your OSGI bundle you will only need to put the bundle inside an already existing directory named modules in the GlassFish installation directory.</p>
<p>The other way in using our package repository is creating a new image in our client system and then installing the package in this new image. Although we can create the image and install our package into it using Update Tool, but is joyful to use command line utilities to accomplish the task.</p>
<p style=" -qt-block-indent:1;">
<ol>
<li>Create the local image:</li>
</ol>
<p>./pkg image-create -U -a GFiA.Repository =http://localhost:10005/ /home/user/GFiA</p>
<p>The command will create a user image which is determined by the –U parameter; its default package repository is our local repository and it is determined by –a parameter. And finally the path to image location is /home/user/GFiA which is the place where our image will extract.</p>
<p style=" -qt-block-indent:1;">
<ol>
<li>Set a Title and Description in the Image:</li>
</ol>
<p>./pkg set-property title &quot;GlassFish in Action Image&quot;</p>
<p>./pkg set-property description &quot;GlassFish in Action Book image which is created in Chapter &quot;</p>
<p style=" -qt-block-indent:1;">
<ol>
<li>install the GFiASamplePackage into the newly created image</li>
</ol>
<p>./pkg  /home/user/GFiA install GFiASamplePackage</p>
<p>As you can see we can install the package into any installation image by providing the installation image path.</p>
<p>You as a developer or project manager can use IPS to distribute your own application from the ground and keep yourself free from updating hurdle. The IPS toolkit is available at <a href="http://wikis.sun.com/display/IpsBestPractices/Downloads">http://wikis.sun.com/display/IpsBestPractices/Downloads</a>. </p>
<p> </p>
<p><strong><em>6 Summary</em></strong></p>
<p>GlassFish modular architecture opens the way for an easy update and maintenance of the application server along with providing the possibility to use its modules outside the application server in ISVs or develop new modules to extend the application server functionalities.</p>
<p>Using OSGI let the application server to be deployed inside a bigger software system based on the OSGI and let the system administrators and maintainers to deal with one single installation with one single underplaying module management system.</p>
<p>GlassFish container development provides the opportunity to develop new type of severs which can contain new types of applications without going deep into network server development. It is also suitable as the container can interface with other containers in the application server to use managed resources like JDBC connection pools or EJBs.</p>
<p>GlassFish update center can be seen as one of the most initiative features of the application server as it takes care of many headaches which administrators usually face for updating and patching the application server. The Update center automatically check for available updates for our installed version of GlassFish and in blink of an eye it will install the updates for us without making us go through the compatibility check between the available update and our installation.</p>
<p>Update center notification mechanism can keep us posted for new updates either when we are doing daily administration task in the administration console or by showing the famous bulb in our desktop notification area.</p>
<p>The Application server is platform independent and so it needs a platform agnostic distributing mechanism and the pkg(5) IPS is a proven binary distribution system which GlassFish used to distribute its binary.</p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/glassfish-modularity-system-how-extend-glassfish-cli-and-web-administration-console-part-i-the-architecture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenMQ, the Open source Message Queuing, for beginners and professionals (OpenMQ from A to Z)</title>
		<link>http://kalali.me/openmq-the-open-source-message-queuing-for-beginners-and-professionals-openmq-from-a-to-z/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=openmq-the-open-source-message-queuing-for-beginners-and-professionals-openmq-from-a-to-z</link>
		<comments>http://kalali.me/openmq-the-open-source-message-queuing-for-beginners-and-professionals-openmq-from-a-to-z/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 11:15:19 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[GlassFish Security]]></category>
		<category><![CDATA[High Availability]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[OpenMQ]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=350</guid>
		<description><![CDATA[Talking about messaging imply two basic functionalities which all other provided features are built around them; these two capabilities include support for topics and queues which basically lets a message to be consumed by as many interested consumer  as subscribed or at just one of the interested consumer(s). Messaging middleware was present in the industry [...]]]></description>
			<content:encoded><![CDATA[<p>Talking about messaging imply two basic functionalities which all other provided features are built around them; these two capabilities include support for topics and queues which basically lets a message to be consumed by as many interested consumer  as subscribed or at just one of the interested consumer(s).</p>
<p>Messaging middleware was present in the industry before Java come along and every one of them had its own interfaces for providing the messaging services. There were no standard interfaces which vendors try to comply with it in order to increase the compatibility, interoperability, ease of use, and portability. The art of Java community was defining Java Messaging System (JMS) as a standard set of interfaces to interact with this type of middleware from Java based applications.</p>
<p>Asynchronous communication of data and events is one of the always present communication models in an enterprise application to resolve some requirements like long running process delegation, batch processing, loose coupling or different systems, updating dynamically growing or shrinking clients’ set, and so on. Messaging can be considered as one of important basics required by every advanced middleware system software stack which provides essentials required to define a SOA as it provides the required basics for loose coupling. </p>
<p><a href="https://mq.dev.java.net/">Open MQ</a> is an open source project mostly sponsored by Sun Microsystems for providing the Java community with a high performance, cross platform message queuing system with commercial usage friendly licenses including CDDL and GPL. Open MQ which is hosted at mq.dev.java.net shares the same code base that Sun Java System Message Queue uses. This shared code base means that any feature available in the commercial product is also available in the open source project and the only difference between them is that for the commercial one you should pay a license fee and in return you will get professional level support from Sun engineers while with the open source alternative you do not have commercial level support and instead you can use community provided support.</p>
<p><a href="https://mq.dev.java.net/">Open MQ</a> provides a broad range of functionalities in security, high availability, performance management and tuning,  monitoring, multiple language support, and so on which lead easier utilization of its base functionalities in the overall software architecture.</p>
<p><strong><em>1 Introducing Open MQ</em></strong></p>
<p> </p>
<p>Open MQ is the umbrella project for multiple components which forms Open MQ and Sun Java System Message queue which is name of the productized sibling of Open MQ. These components include:</p>
<p>§     Message broker or messaging server</p>
<p>Message broker is the heart of the messaging system which generally maintains the message queues and topics, manage the clients connections and their requests, control the clients access to queues and topics either for reading or writing, and so on.</p>
<p>§     Client libraries</p>
<p>Client libraries provide APIs which let developers interact with the message broker from different programming languages. Open MQ provides Java and C libraries in addition to a platform and programming language agnostic interaction mechanism.</p>
<p>§     Administrative tools</p>
<p>Glassfish provides a set of very intuitive and easy to use administration tools including tools for broker’s life cycle management, broker monitoring, and destination life cycle management and so on.</p>
<p><strong><em>1.1 Installing Open MQ</em></strong></p>
<p>From version 4.3, Open MQ provides an easy to use installer which is platform depended as it is bundled with compiled copy of client libraries and administration tools. Download bits for installer are available at <a href="https://mq.dev.java.net/downloads.html">https://mq.dev.java.net/downloads.html</a>, download the binary copy compatible with your operating system. Make sure that you have JDK 1.5 or above already installed before you try to install Open MQ. Virtually Open MQ works on any operating system capable of running JDK 1.5 and above. </p>
<p><strong>Beauty of open source</strong></p>
<p>You might be using an operating system for development or deployment which is not included in table 1; in this case you can simply download the source code archive from the same page mentioned above and build the source code yourself. The building instructions are available at http://download.java.net/mq/open-mq/4.3/b05/Compiling and Running OpenMQ 4.3 in NetBeans.txt which is straight forward. Even if you could not manage to build the binary tools you can still use Open MQ and JMS on that operating system and run your management tools from a supported operating system.</p>
<p> </p>
<p>To install Open MQ extract the downloaded archive and run installer script or executable file depending on your operating system, as you can see installer is straight forward and does not require any special user interaction except accepting some defaults.</p>
<p>After we complete the installation process we will have a directory structure similar to figure 1 in the installation path we select during the installation.</p>
<p><img src="http://www.java.net/sites/default/files/1.png" width="303" height="447" /></p>
<p>Figure 1 Open MQ installation directory structure</p>
<p> </p>
<p>As you can suggest from the figure, we have some Meta directory related to installer application and a directory named <em>mq</em> that contains Open MQ related files. Table 1 lists Open MQ directories along with their descriptions.</p>
<p>Table 1 Important items inside Open MQ installation directory </p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><strong>Directory name</strong> </p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>Description</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">bin</p>
</td>
<td>
<p align="left"></p>
<p align="left">All administration utilities resides here</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">include</p>
</td>
<td>
<p align="left"></p>
<p align="left">Required headers for using OpenMQ C APIs</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">lib</p>
</td>
<td>
<p align="left"></p>
<p align="left">All JAR files and some native dependencies (NSS) resides here</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">lib/*.war</p>
</td>
<td>
<p align="left"></p>
<p align="left">HTTP and HTTP tunneling for firewall restricted configuration, Universal Messaging service for language agnostic use of Open MQ.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">var/instances</p>
</td>
<td>
<p align="left"></p>
<p align="left">Configuration files for different broker instances created on this Open MQ installation are stored inside this folder by default.</p>
</td>
</tr>
</table>
<p> </p>
<p><strong><em>2 Open MQ administration</em></strong></p>
<p>Every server side application requires some level of administration and management to keep it up and running and Open MQ is not an exception. As we discussed in article introduction each messaging system must have some basic capabilities including point to point to point and publish subscribe mechanism for distributing messages. So, basic administration should evolve around the same concept.</p>
<p><strong><em>2.1 Queue and Topic administration and management</em></strong></p>
<p>When a broker receive a message it should put the message in a queue, topic or discard it. Queues and topics are called physical destinations as they are latest place in the broker space that a message should be placed.</p>
<p>In Open MQ we can use two administration utilities for creating queues and topics, imqadmin and <em>imqcmd</em> which the first one is a simple swing application and the later one is a command line utility. In order to create a queue we can execute the following command in the bin directory of Open MQ installation.</p>
<p> </p>
<p><code>imqcmd create dst -n smsQueue -t q -o &quot;maxNumMsgs=1000&quot; -o &quot;limitBehavior=REMOVE_OLDEST&quot; –o &quot;useDMQ&quot;</code></p>
<p> </p>
<p> </p>
<p>This command simply creates a destination of type queue, this queue will not store more than 1000 message and if producers try to put more messages in the queue it will remove oldest present message to open up some space for new messages. Removed message will be placed in an specific queue named Dead Messages Queue (DMQ). The queue that we create using this command is named <em>smsQueue. </em>This command creates the queue on the local Open MQ instance which is running on localhost port 7676. We can use –b to ask <em>imqcmd</em> to communicate with a remote server. Following command create a topic named <em>smsTopic</em> on a server running on 192.168.100.1:7676, remember that default username and password for the default broker is admin.</p>
<p> </p>
<p><code>imqcmd –b 192.168.100.1:7676 create dst -n smsTopic -t t</code></p>
<p> </p>
<p><em>imqcmd</em> is a very complete and feature rich command, we can use it to monitor the physical destinations. A sample command to monitor the destination can be like:</p>
<p> </p>
<p><code>imqcmd metrics dst -m rts -n smsQueue -t q</code></p>
<p>Sample output for this command is similar to figure 2 which shows consuming and producing messages’ rates of <em>smsQueue.</em> The only thing about the command is that -m argument which determine which type of metrics we need to see, different types of observable metrics for physical destinations includes: </p>
<p>§              con, which will show  destination consumer information</p>
<p>§              dsk, disk usage by This destination</p>
<p>§              rts, as already said it shows  message rates</p>
<p>§              ttl, shows message total, it is the default metric type if none specified</p>
<p> </p>
<p><img src="http://www.java.net/sites/default/files/2.png" width="504" height="91" /></p>
<p>Figure 2 sample output for OpenMQ monitoring command</p>
<p> </p>
<p>There some other operation which we may perform on destinations:</p>
<p>§              Listing destinations: imqcmd list dst</p>
<p>§              Emptying a destination: imqcmd purge dst -n ase -t q</p>
<p>§              Pausing, resuming a destination: imqcmd pause dst -n ase -t q</p>
<p>§              Updating a destination: imqcmd update dst -t q -n smsQueue -o &quot;maxNumProducers=5&quot;</p>
<p>§              Query destination information: imqcmd query dst -t q -n smsQueue</p>
<p>§              Destroy a destination: imqcmd destroy dst -n smsTopic -t t</p>
<p><strong><em>2.2</em></strong> <strong><em>Brokers administration and managemetn</em></strong></p>
<p>We discussed that when we install Open MQ it creates a default broker which will start when we run <em>imqbrokerd</em> without any additional parameters. An Open MQ installation can have multiple brokers running on different ports with different configuration. We can create a new broker by executing following command which will create the broker and start it for accepting further commands or incoming messages.</p>
<p><code>imqbrokerd -port 7677 -name broker02</code></p>
<p> </p>
<p>In table 1 we talked about a <em>var/instances</em> directory which all configuration files related to brokers reside inside it. If you look at this folder after executing the above command you will see two directories name <em>imqbroker</em> and <em>broker02</em> which corresponds to default and newly created broker. Table 2 shows important artifacts residing inside <em>broker02</em> directory.</p>
<p> </p>
<p>Table 2 Brokers important files and directories </p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><strong>File or directory name</strong> </p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>Description</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">etc/ accesscontrol.properties</p>
</td>
<td>
<p align="left"></p>
<p align="left">Configurations related to access controls, roles, authentication source and mechanism are stored here.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">etc/passfile</p>
</td>
<td>
<p align="left"></p>
<p align="left">Users and password for accessing Open MQ are stored here</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">fs370 (directory)</p>
</td>
<td>
<p align="left"></p>
<p align="left">Broker file based message stores, physical destinations, and so on. </p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">log (directory)</p>
</td>
<td>
<p align="left"></p>
<p align="left">Open MQ log files</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">props/ config.properties</p>
</td>
<td>
<p align="left"></p>
<p align="left">All configurations relate to this broker are stored inside this file, configurations like services, security, clustering, and so on.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">lock (file)</p>
</td>
<td>
<p align="left"></p>
<p align="left">Exists when the broker is running and shows broker’s name, host and port </p>
</td>
</tr>
</table>
<p> </p>
<p>Open MQ has a very initiative configuration mechanism, first of all there are some default configuration which apply on Open MQ installation, there is an installation configuration file which we can use to override the default configurations, then each broker has its own configuration file which can override the installation configuration parameters and finally, we can override  broker (instance) level configurations by overriding them by passing their values to  <em>imqbrokerd</em> when staring a broker. When we create a broker we can change its configuration by editing the <em>config.properties</em> file mentioned in table 2. Table 3 lists all other mentioned configuration files and their default location on your hard disk.</p>
<p>Table 3 Open MQ configuration files path and descriptions</p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><strong>Configuration file location</strong> </p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>Configuration file description</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">default.properties</p>
</td>
<td>
<p align="left"></p>
<p align="left">Located in lib/props/broker* directory, for determining default configuration parameters</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">install.properties</p>
</td>
<td>
<p align="left"></p>
<p align="left">Located in lib/props/broker* directory, for determining installation configuration parameters</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">config.properties</p>
</td>
<td>
<p align="left"></p>
<p align="left">Located inside props** folder of instance directory</p>
</td>
</tr>
</table>
<p>* We discussed this directory in table 2</p>
<p>** This directory discussed in table 4</p>
<p>Now that we understand how we can create a broker, let’s see how we can administrate and manage a broker. In order to manage a broker we use <em>imqcmd</em> utilities which were also discussed in previous section for destination administration.</p>
<p>There are several level of monitoring data associated with a broker including incoming and outgoing messages and packets (<em>-m ttl</em>), messages and packet incoming and outgoing rate (<em>-m rts</em>), and finally operational related statistics like connections, threads and heap size (<em>-m cxn</em>). Following command returns message and packets rate for a broker running on localhost, listening on port 7677, the statistics updates each 10 seconds.</p>
<p><code>imqcmd metrics bkr  -b 127.0.0.1:7677 -m rts -int 10 -u admin</code></p>
<p>As you can see we passed the username with –u parameter and server will not ask for the username again. We can not pass the associated password directly in the command line and instead we can use a plain text file which includes the associated password. the password file should contains: </p>
<p><code>imq.imqcmd.password=admin</code></p>
<p>Default password for Open MQ administrator user is admin and as you can see the password file is a simple properties file. Table 4 list some other common tasks related to brokers along with a description and a sample command.</p>
<p>Table 4 Broker administration and management</p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><strong>Task</strong> </p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>Description and sample command</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">pause and resume</p>
</td>
<td>
<p align="left"></p>
<p align="left">Make the broker to stop or resume accepting connections on all services.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Quiescence, un-quiescence</p>
</td>
<td>
<p align="left"></p>
<p align="left">Issuing quiescence on a broker because it to stop accepting new connections, but it serve already connected connections, and un-quiescence command will return it to normal mode.</p>
<p align="left">imqcmd quiesce bkr -b 127.0.0.1:7677 -u admin –passfile passfile.txt</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Update a broker</p>
</td>
<td>
<p align="left"></p>
<p align="left">Update a broker attributes like</p>
<p align="left">imqcmd update bkr –o “imq.log.level=ERROR”</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Shutdown broker</p>
</td>
<td>
<p align="left"></p>
<p align="left">imqcmd shutdown bkr -b 127.0.0.1:7677 -time 90 -u admin</p>
<p align="left">The sample command shutdown the broker after 90 seconds and during this time it only serves already established connections</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Query broker</p>
</td>
<td>
<p align="left"></p>
<p align="left">Shows broker information</p>
<p align="left">./imqcmd query bkr –b 127.0.0.1:7677 –u admin</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p><strong><em>3</em></strong> <strong><em>Open MQ security</em></strong></p>
<p>After getting the sense of Open MQ basics we can look at its security mode to be able to setup a secure system based on Open MQ messaging capability. We will discuss connection authentication to ensure that a user is allowed to create a connection either as a producer or consumer, access control or authorization to check whether the connected user can send a message to a specific queue or not. Security the transport step is a responsibility of messaging server administrators, Open MQ support SSL and TLS for preventing message tamper and providing the required level of encryption but we will not discuss it as it is out of this article scope.</p>
<p>Open MQ provides supports for two types of user repository out of the box along with facilities to use JAAS modules for authentication.  User information repositories which can be used out of the box includes flat file user information repository and directory server with an LDAP communication interface.</p>
<p><strong><em>3.1 Authentication</em></strong></p>
<p>Authentication happens before a new connection establishes. To configure Open MQ perform authentication we should provide an authentication source along with editing the configuration files to enable the authentication and configure it to use our prepared user information repository.</p>
<p><strong>Flat file authentication</strong></p>
<p>Flat File authentication rely on a flat file which contains username, encoded password, role name, each line of this files contains mentioned properties of one user. A sample line can be similar to:</p>
<p><code>admin:-2d5455c8583c24eec82c7a1e273ea02e:admin:1</code></p>
<p>Default location of each broker’s password file is the broker’s home directory/etc/passwd, later on when we use imq<em>usermgr</em> utility we either edit this file or the file that we described using related properties which are mentioned in table 5.</p>
<p>To configure a broker instance to perform authentication before establishing any connection we can either use <em>imqcmd</em> to update the broker’s properties or we can directly edit its configuration file which is mentioned in table 5. In order to configure <em>broker02</em> that we create in section 1.2 to perform authenticate before establishing a connection we need add properties listed in table 5 to <em>config.properties</em> file which is located inside <em>props</em> directory or broker’s home directory, broker directory structure and configuration files are listed in table 3 and 2.</p>
<p>We can ignore two later attributes as we want to use the default file in its default path,. So, shutdown the broker, add listed attributes to its configuration file and start it again. Now we can simply uses <em>imqusrmgr</em> to perform CRUD operations on our user repository associated to our target broker.</p>
<p> </p>
<p>Table 5 required changes to enable connection authentication for broker02</p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><strong>Required information by broker</strong> </p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>Corresponding property in configuration file</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">What kind of user information repository we want to use</p>
</td>
<td>
<p align="left"></p>
<p align="left">imq.authentication.basic.user_repository=file</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">What is password encoding</p>
</td>
<td>
<p align="left"></p>
<p align="left">imq.authentication.type=digest</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Path to directory containing password file</p>
</td>
<td>
<p align="left"></p>
<p align="left">imq.passfile.dirpath=path/to/the/folder</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Path to password file which contains passwords</p>
</td>
<td>
<p align="left"></p>
<p align="left">imq.passfile.name=password/file/name</p>
</td>
</tr>
</table>
<p> </p>
<p>Now that we configured the broker to perform authentication we need some mechanism to add, remove, or update the user information repository content. Table 6 shows how we can use <em>imqusermgr</em> utility to perform CRUD operations on <em>broker02.</em></p>
<p>Table 6 Flat file user information repository management using <em>imqusermgr</em></p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><strong>CRUD operation</strong> </p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>Sample command</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Create user</p>
</td>
<td>
<p align="left"></p>
<p align="left">Add a user to user group, other groups are admin and anonymous.</p>
<p align="left">imqusermgr add -u user01 -p password01 -i broker02 -g user</p>
<p align="left"> </p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">List users</p>
</td>
<td>
<p align="left"></p>
<p align="left">imqusermgr list -i broker02</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Update a user </p>
</td>
<td>
<p align="left"></p>
<p align="left">Change the user status to inactive.</p>
<p align="left">imqusermgr update -u user01 -a false -i broker02</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Remove a user</p>
</td>
<td>
<p align="left"></p>
<p align="left">Remove user01 from broker02</p>
<p align="left">imqusermgr delete -u user01 -i broker02</p>
</td>
</tr>
</table>
<p>Now create another user as follow:</p>
<p>imqusermgr add -u user02 -p password02 -i broker02 -g user</p>
<p>We will use these two users in defining authorization rules and later on in section 4 to see how we can connect to Open MQ from Java code when authentication is enabled. </p>
<p> </p>
<p>All other utilities that we discussed need the Open MQ to be running and all of them we able to perform the required action on remote Open MQ instances but this command only works on local instances and does not require the instance to be running.</p>
<p><strong><em>3.2 Authorization</em></strong></p>
<p>After we enabled authentication which result in the broker checking user credentials before establishing the connection we may need to check the connected user’s permissions before we let it perform a specific operation like connecting to a service, putting message into a queue (acting as a producer), subscribing to a topic (acting as a consumer), browsing a physical destination, or automatic creation of physical destinations,. All these permissions can be defined using a very simple syntax which is shown below:</p>
<p> </p>
<p>resourceType. resourceVariant. operation. access. principalType= principals</p>
<p> </p>
<p>In this syntax we have 6 variable elements which are described in table 7.</p>
<p>Table 7 different elements in each Open MQ authorization rule </p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><strong>Element</strong> </p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>Description</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">resourceType</p>
</td>
<td>
<p align="left"></p>
<p align="left">Type of resource to which the rule applies:</p>
<p align="left">connection: Connections</p>
<p align="left">queue:Queue destinations</p>
<p align="left">topic: Topic destinations</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">resourceVariant</p>
</td>
<td>
<p align="left"></p>
<p align="left">Specific resource (connection service type or destination) to which the rule applies.</p>
<p align="left">An asterisk (*) may be used as a wild-card character to denote all resources of a given type: for example, a rule beginning with queue.* applies to all queue destinations.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">operation</p>
</td>
<td>
<p align="left"></p>
<p align="left">Operation to which the rule applies. This syntax element is not used for resourceType=connection</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">access</p>
</td>
<td>
<p align="left"></p>
<p align="left">Level of access authorized:</p>
<p align="left">allow: Authorize user to perform operation</p>
<p align="left">deny: Prohibit user from performing operation</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">principalType</p>
</td>
<td>
<p align="left"></p>
<p align="left">Type of principal (user or group) to which the rule applies:</p>
<p align="left">user: Individual user</p>
<p align="left">group: User group</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">principals</p>
</td>
<td>
<p align="left"></p>
<p align="left">List of principals (users or groups) to whom the rule applies, separated by commas.</p>
<p align="left">An asterisk (*) may be used as a wild-card character to denote all users or all groups: for example, a rule ending with user=* applies to all users.</p>
</td>
</tr>
</table>
<p> </p>
<p><strong>Enabling authoriization</strong></p>
<p>To enable authorization we will have to do a bit more than what we did for authentication because in addition to enabling the authorization we need to define roles privileges. Open MQ provides a text based file to describe the access controlling rules. Default path for this file is inside the <em>etc</em> directory of broker home, and the default name is <em>accesscontrol.properties</em>. If we do not provide the path for this file when configuring Open MQ for authorization, Open MQ will pick up the default file.</p>
<p>In order to enable authorization we need to add following attributes to one of configuration files depending on how much wide we want the authorization be applied. Second attribute is not necessary if we want to use default file path.</p>
<p> </p>
<p>§              To Enable the authorization: imq.accesscontrol.enabled=true</p>
<p style=" -qt-block-indent:1;">
<ul type="square">
<li>Determine the access control description file path: imq.accesscontrol.file.filename= path/toaccess/contro/file</li>
</ul>
<p>Defining access control roles inside the access control file is an easy task, we just need use the rules syntax and limited set of variable values to define simple or complex access control roles. Listing 1 shows list of rules which we need to add to our access control file that either can be the default file or another file in the specific path that we should describe in the configuration file. If you are using default access control configuration file make sure that you comment all already defined rules by adding # sign in beginning of each line.</p>
<p><strong>Listing 1 Open MQ access control rules definition</strong></p>
<p><code><br />
#connection authorization rules<br />
connection.ADMIN.allow.group=admin                            #1<br />
connection.ADMIN.allow.user=user01                            #1<br />
connection.NORMAL.allow.group=*                                          #2<br />
 <br />
#queue authorization rules<br />
queue.smsQueue.produce.allow.user=user01,user02                                          #3<br />
queue.smsQueue.consume.allow.user=user01,user02                                          #4<br />
queue.*.browse.allow.user=*                                                                      #5<br />
 <br />
#topic authorization rules<br />
topic.smsTopic.*.allow.group=*                                                                      #6<br />
topic.smsTopic.produce.deny.user=user01                                                        #7<br />
topic.*.produce.deny.group=anonymous                                                        #8             <br />
topic.*.consume.allow.user=*                                                                      #9<br />
 <br />
#Auto creating destinations authorization rules<br />
queue.create.allow.user=*                                                                      #10<br />
topic.create.allow.group=user                                                                      #11<br />
topic.create.deny.user=user01                                                                      #12<br />
</code></p>
<p> </p>
<p>By adding content of listing 1 to access control description file, we are applying following rules in Open MQ authentication, first of all we are letting admin group to connect to the system as administrator #1 and the only user01 as a normal user has previledge to connect to system as administrator #1. We let any user from any group to connect as a normal user to the broker#2. At #3 we let any of users that we create before to either act as a producer and at #4 we let these two users to act as producers of smsQueue destination. Because of rules we defined at #3 and #4 no other user can act as a consumer or producer of any other queue in the system. At #5 we let any user to browse any queue in the system. At #6 we let any operation on smsTopic by any group of users and later on at #7 we define a rule to deny user01 from acting as a smsTopic producer. As you can see generalized rules can be overridden by more specific rules as we did it for denying user01 from acting as a producer. At #8 we deny anonymous from acting as producer of smsTopic. At #9 we let any user from any group to act as a consumer of any present topic in the system. At #10 we allow any user to use auto destination creating facility. At #11 we just let one specific group to automatically create topics while one single user has no privilege to automatically create a topic #12.</p>
<p><strong>WARNING</strong></p>
<p>If we use an empty access control definition file no user can connect to the system so, no operation will be possible in the system by any user. Open MQ default permission for any operation is denial, so if we need to change the default permission to allow we should add allows rules to the access control definition file.</p>
<p>Now we can simply connect to Open MQ by using user01 to perform administrative tasks. For example executing these commands will create our sample queue and topics in the broker that we create in section 1.2. When imqcmd asked for username and password user user01 and password01</p>
<p> </p>
<p><code>imqcmd  –b 127.0.0.1:7677 create dst -n smsQueue -t q -o &quot;maxNumMsgs=1000&quot; -o &quot;limitBehavior=REMOVE_OLDEST&quot; –o &quot;useDMQ&quot;</code></p>
<p> </p>
<p><code>imqcmd –b 127.0.0.1:7677 create dst -n smsTopic -t t</code></p>
<p> </p>
<p>As you can see we can simply define very complex authorization rules using a simple text file and its rules definition syntax.</p>
<p>So far, we tried and use simple text file for user management and authentication purposes, but in addition to using text file, Open MQ can use a more robust and enterprise friendly user repository like OpenDS.  When we use directory service as the user information repository we will no more manage it using the Open MQ command line utilities and instead the enterprise wide administrators perform user management from one central location and we as Open MQ administrators or developers just define out authorization rules.</p>
<p>In order to configure Open MQ to use a directory server (like Open DS) as the user repository we need to add the properties listed in table 8 to our broker or installation configuration file.</p>
<p> </p>
<p>Table 8 Configuring Open MQ to use OpenDS as the user information repository</p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><strong>Required information by broker</strong> </p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>Corresponding property in configuration file</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Determine user information repository type</p>
</td>
<td>
<p align="left"></p>
<p align="left">imq.authentication.basic.user_repository=ldap</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Determine password exchange encryption, in this case it is base-64 encoding similar to directory server method.</p>
</td>
<td>
<p align="left"></p>
<p align="left">imq.authentication.type=basic</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">*Directory server host and port</p>
</td>
<td>
<p align="left"></p>
<p align="left">imq.user_repository.ldap.server=127.0.0.1:7677</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">A DN for binding and searching.</p>
</td>
<td>
<p align="left"></p>
<p align="left">imq.user_repository.ldap.principal=cn=gf cn=admin</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Provided DN password</p>
</td>
<td>
<p align="left"></p>
<p align="left">imq.user_repository.ldap.password=admin</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">User attribute name to compare the username.</p>
</td>
<td>
<p align="left"></p>
<p align="left">imq.user_repository.ldap.uidattr=uid</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">**User’s group name</p>
</td>
<td>
<p align="left"></p>
<p align="left">imq.user_repository.ldap.gidattr=groupid</p>
</td>
</tr>
</table>
<p>* Multiple directory server address can be determined for high availability reasons, for example ldap://127.0.0.1:7677 ldap://192.168.1.1:7677  each address should be separated from other address by an space.</p>
<p>** User’s group name(s) attribute is vendor dependent and vary from one directory service to other directory services.</p>
<p>There are several other attributes which can be used to either tweak the LDAP authentication in term of security and performance, but essential properties are listed in table 10.  Other properties which can be used are available at Sun Java System Message Queue Administration Guide available at <a href="http://docs.sun.com/app/docs/coll/1307.5">http://docs.sun.com/app/docs/coll/1307.5</a>.</p>
<p><strong>The key to use directory service is to know the schema</strong></p>
<p>The key behind a successful use of a directory service in any system is to know the directory service itself and the schema that we are dealing with. For example different schemas uses different attribute names and for each property of a directory service object so before diving into using a directory service implementation make sure that you know both the directory server and its schema.</p>
<p><strong><em>4 clustering and high availability</em></strong></p>
<p>We know that redundancy is one of the high availability enabler. We discussed data and service availability along with horizontal and vertical scalability of software solutions. OpenMQ like any other component of a software solution which drive an enterprise should be highly available sometimes both for data and service layer and sometimes just for service layer.</p>
<p>The engine behind the JMS interface in the message broker which its tasks is managing destinations, routing and delivering messages, checking with the security and so on. Therefore if we could keep the brokers and related services available for the clients, then we have the service availability in place. Later on if we manage to keep the state of queues, topics, durable subscribers, transactions and so on preserved in event of a broker failure then we can provide out clients with high availability in both service and data layer.</p>
<p>Open MQ provides two types of clustering, conventional clusters and high availability clusters, which can be used depending on the high availability degree required for messaging component in the whole software solution.</p>
<p>Conventional clusters which provide service availability but not data availability. If one broker in a cluster fails, clients connected to that broker can reconnect to another broker in the cluster but may be unable to access some data while they are reconnected to the alternate broker. Figure 3 shows how conventional cluster member and potential clients work together.</p>
<p><img src=" http://www.java.net/sites/default/files/3.png" width="288" height="239" /></p>
<p>Figure 3 Open MQ Conventional clustering, one MQ broker act as the master broker to keep track of changes and propagate it to other cluster members</p>
<p>As you can see in the figure 3, in conventional clusters, we have different brokers running with no shared data. But in conventional cluster configuration is shared by a master broker that propagates changes between different cluster members to keep them up to dated about destinations and durable subscribers. Master broker keep newly joined or offline members which become online after a period of time synchronized with new configuration information and durable subscribers. Each client is connected to one broker and will use that broker until the broker fails (get offline, a disaster happens, and so on) which will connect to another broker in the same cluster.</p>
<p>High availability clusters provide both service availability and data availability. If one broker in a cluster fails, clients connected to that broker are automatically connected to that broker in the cluster which takes over the failed broker&#8217;s store. Clients continue to operate with all persistent data available to the new broker at all times. Figure 4 shows how high availability clusters’ members and potential clients work together.</p>
<p><img src="http://www.java.net/sites/default/files/4.png" width="504" height="326" />Figure 4 Open MQHigh availability cluster, no single point of failure as all information are stored in a highly available database and all cluster member interact with that database</p>
<p>As you can see in figure 4 we have one central highly available database which we relay upon for storing any kind of dynamic data like transactions, destinations, messages, durable subscribers, and so on. These database itself should be highly available, usually a cluster of different database instances running on different machines in different geographical locations. Each client connect to one broker and continue using the same broker until broker fails, in term of the broker failure, another broker will take over all of the failed broker responsibilities like open transactions, and durable subscribers. Then client will reconnect to the broker that takes over of failed broker’s responsibilities.</p>
<p>All in all we can summarize the differences between conventional clusters and high availability clusters as listed in table 9.</p>
<p>Table 9 comparison between high availability clusters and conventional clusters</p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><strong>Functionality</strong> </p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>Conventional cluster</strong></p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>High availability cluster</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Performance</p>
</td>
<td>
<p align="left"></p>
<p align="left">Faster</p>
</td>
<td>
<p align="left"></p>
<p align="left">Slower</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Service availability</p>
</td>
<td>
<p align="left"></p>
<p align="left">Yes, but partial when master broker is not available</p>
</td>
<td>
<p align="left"></p>
<p align="left">Yes</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Data availability</p>
</td>
<td>
<p align="left"></p>
<p align="left">No, a failed broker can cause data lose</p>
</td>
<td>
<p align="left"></p>
<p align="left">Yes</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Transparent failover recovery</p>
</td>
<td>
<p align="left"></p>
<p align="left">May not be possible if failover occurs during a commit</p>
</td>
<td>
<p align="left"></p>
<p align="left">May not be possible if failover</p>
<p align="left">occurs during a commit and the</p>
<p align="left">client cannot reconnect to any</p>
<p align="left">Other broker in the cluster</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Configuration</p>
</td>
<td>
<p align="left"></p>
<p align="left">Done by setting appropriate cluster configuration broker properties</p>
</td>
<td>
<p align="left"></p>
<p align="left">Done by setting appropriate cluster configuration broker properties</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">3rd party software requirement</p>
</td>
<td>
<p align="left"></p>
<p align="left">None</p>
</td>
<td>
<p align="left"></p>
<p align="left">Highly available database</p>
</td>
</tr>
</table>
<p> </p>
<p>Usually when we are talking about data availability we need to accept the slight performance overhead, you remember that we had similar condition with GlassFish HADB backed clusters.</p>
<p>We said that high availability clusters use a database to store dynamic information; some databases tested with OpenMQ include ORACLE RAC, MySQL, Derby, PostgreSQL, and HADB. We usually use a high available database to maximize the data availability and reduce the risk of losing data.</p>
<p>We can configure a highly available messaging infrastructure by a following a set of simple steps; First you need to create as many brokers as you need in your messaging infrastructure, so create brokers as discussed in 1.2, In second step we need to configure the brokers to use a shared database for dynamic data storage and act as a cluster member. To perform this step we need to add some changes to the each broker configuration file, these changes includes adding the content of listing 2 to broker’s configuration file</p>
<p><strong>Listing 2 Required properties for making a broker highly available</strong></p>
<p><code>#data store configuration</code></p>
<p><code>imq.persist.store=jdbc                          #1</code></p>
<p><code>imq.persist.jdbc.dbVendor=mysql                  #2</code></p>
<p><code>imq.persist.jdbc.mysql.driver=com.mysql.jdbc.Driver   #2</code></p>
<p><code>imq.persist.jdbc.mysql.property.url=jdbc:mysql://localhost:3306 #2</code></p>
<p><code>imq.persist.jdbc.mysql.property.databasename=jmsStore</code><code>        </code><code> #2</code></p>
<p><code>imq.persist.jdbc.mysql.user=privilegedUser                  #2</code></p>
<p><code>imq.persist.jdbc.mysql.needpassword=true                    #2</code></p>
<p><code>imq.persist.jdbc.mysql.password=dbpassword                   #2</code></p>
<p><code> </code></p>
<p><code>#cluster related configuration</code></p>
<p><code>imq.cluster.ha=true                                          #3</code></p>
<p><code>imq.cluster.clusterid=e.cluster01                           #3</code></p>
<p><code>imq.brokerid=e.broker02                                      #4</code></p>
<p> </p>
<p> </p>
<p><strong>Please remove the numbers in the above listing and following paragraph with cueballs</strong></p>
<p>At #1 we define that data store is of type JDBC and not Open MQ managed binary files, for high availability clusters it must be jdbc instead of file. At #2 we provide required configuration parameters for Open MQ to be able to connect to the database, we can replace mysql with oracle, derby, hadb or postgresql if we want to. At #3 we configure this broker as a member of a high availability cluster named e.cluster01, and finally at #4 we determine the unique name of this broker. Make sure that each broker should have a unique name in the entire cluster and different clusters using the same database need to be uniquely identified.</p>
<p>Now we have a database server available for our messaging infrastructure high availability and we configured all of our brokers to use this database, the last step is creating the database that Open MQ is going to use to store the dynamic data. To create the initial schema we should use following command:</p>
<p><code>./imqdbmgr create all –b broker_name</code></p>
<p>This command creates the database, required tables, and initializes the database with topology related information. As you can see we passed a broker name to the command, this means that we want the imqdbmgr to use that specific broker’s configuration file to create the database. As you remember we can have multiple brokers in the same Open MQ installation and each broker can operate completely independent from other brokers.</p>
<p>The imqdbmgr command has many usages including: upgrading storage from old Open MQ versions, creating backups, restoring backups and so on. To see a complete list of its commands and parameters execute the command with –h parameter.</p>
<p>Now you should have a good understanding of Open MQ clustering and high availability. In next section we will discuss how we can use Open MQ from a Java SE application and later on we will see how Open MQ is related to GlassFish and GlassFish clustering architecture. </p>
<p>Excellent segue</p>
<p>Thanks, I am learning</p>
<p> </p>
<p> </p>
<p><strong><em>5 Open MQ management using JMX</em></strong></p>
<p>Open MQ provides a very rich set of JMX MBeans to expose administration and management interface of Open MQ. These MBeans can also be used to monitor the Open MQ using JMX. Generally any task which we can do using imqcmd can be done using JMX code or a JMX console like JDK’s Java Monitoring and Management Console, jconsole, utility.</p>
<p>Administrative tasks that we can do using JMX include managing brokers, services, destinations, consumers, producers. And so on. Meantime management and monitoring is possible using JMX, for example we can monitor destinations using our code or change the configuration of the JMX broker dynamically using our own code or a JMX console. Some use cases of the JMX connection channel includes:</p>
<p style=" -qt-block-indent:1;">
<ul type="square">
<li>We can include JMX code in our JMS client application to monitor application performance and, based on the results, to reconfigure the JMS objects you use to improve performance.</li>
<li>We can write JMX clients that monitor the broker to identify use patterns and performance problems, and we can use the JMX API to reconfigure the broker to optimize performance.</li>
<li>We can write a JMX client to automate regular maintenance tasks, rolling upgrades, and so on.</li>
<li>We can write a JMX application that constitutes your own version of imqcmd, and we can use it instead of imqcmd.</li>
</ul>
<p>To connect to Open MQ broker using a JMX console we can use service:jmx:rmi:///jndi/rmi://host:port/server  as the connection URL pattern.  Listing 3 shows how we can use Java code to pause jms service temporarily.</p>
<p><strong>Please replace numbers with cueballs in following sample codes and paragraphs</strong></p>
<p> </p>
<p><strong>Listing 3 pausing the jms service using Java code, JMX and admin connection factory</strong></p>
<p><code>AdminConnectionFactory  acf = new AdminConnectionFactory();             #1</code></p>
<p><code>acf.setProperty(AdminConnectionConfiguration.imqAddress, &quot;192.168.1.1:7677&quot;);                                                       #2</code></p>
<p><code>JMXConnector  jmxc = acf.createConnection(&quot;admin&quot;, &quot;admin&quot;);          #3</code></p>
<p><code>MBeanServerConnection  mbsc = jmxc.getMBeanServerConnection();           #4</code></p>
<p><code>ObjectName  serviceConfigName = MQObjectName.createServiceConfig(&quot;jms&quot;); #5</code></p>
<p><code>mbsc.invoke(serviceConfigName, ServiceOperations.PAUSE, null, null);    #6</code></p>
<p><code>jmxc.close();        </code>                                                   #7</p>
<p> </p>
<p>This sample code uses admin connection factory which brings some dependencies on Open MQ classes which make you add imqjmx.jar to your class path. This file is located in Open MQ installation lib directory. At #1 we create an administration connection factory, this class is an Open MQ helper class which make this sample code depending on Open MQ libraries, at #2 we configure the factory to gives us connection to a non-default host, the default host is 127.0.0.1:7676 at #3 we set the credentials which we want to use to make the connection, at #4 we get the connection to MBean server. At #5 we get jms service MBean and at #6 we invoke one of its operation and finally we close the connection at #7.</p>
<p>Listing 4 shows a pure JMX sample code for reading MaxNumProducers attributes of a smsQueue.</p>
<p><strong>Listing 4</strong><strong>Reading smsQueue attributes using pure JMX code</strong></p>
<p><code>HashMap   environment = new HashMap();                       #1</code></p>
<p><code>String[]  credentials = new String[] {&quot;admin&quot;, &quot;admin&quot;};   #1</code></p>
<p><code>environment.put (JMXConnector.CREDENTIALS, credentials);     #1</code></p>
<p><code>JMXServiceURL  url;</code></p>
<p><code>url = new JMXServiceURL(&quot;service:jmx:rmi:///jndi/rmi://192.168.1.1:7677/server&quot;); #2</code></p>
<p><code>JMXConnector  jmxc = JMXConnectorFactory.connect(url, environment); #3</code></p>
<p><code>MBeanServerConnection  mbsc = jmxc.getMBeanServerConnection(); #4</code></p>
<p><code>ObjectName  destConfigName= MQObjectName.createDestinationConfig(DestinationType.QUEUE, &quot;smsQueu&quot;); #5</code></p>
<p><code>Integer  attrValue= (Integer)mbsc.getAttribute(destConfigName,DestinationAttributes.MAX_NUM_PRODUCERS); #6</code></p>
<p><code>System.out.println( &quot;Maximum number of producers: &quot; + attrValue );</code></p>
<p><code>jmxc.close();                                                        #7</code></p>
<p> </p>
<p>At #1 and #2 we determine the parameters that JMX needs to create a connection, at #3 we create the JMX connection, at #4 we get a connection to the Open MQ’s MBean server, at #5 get the MBean representing our smsQueue, at #6 we get value of an attribute which represent the maximum number of permitted producers and finally we close the connection at #7.</p>
<p>To learn more about JMX interfaces and programming model for Open MQ you can check Sun Java System Message Queue 4.2 Developer&#8217;s Guide for JMX Clients which is located at <a href="http://docs.sun.com/app/docs/doc/820-5207">http://docs.sun.com/app/docs/doc/820-5207</a>.</p>
<p><strong><em>6 Using Open MQ</em></strong></p>
<p>Open MQ messaging infrastructure can be accessed from variety of channels and programming languages, we can perform messaging tasks using Java, C, and virtually any programming language capable of performing HTTP communication. When it comes to java we can access the broker functionalities either using JMS or JMX.</p>
<p>Open MQ directly provides APIs for accessing the broker using C and Java but for other languages it takes a relatively evolutionary approach by providing a HTTP gateway for communicating between any language like python, JavaScript (AJAX), C#, and so on. This approach is called Universal Messaging System (UMS) which introduce in Open MQ 4.3. in this section we only discuss Java and OpenMQ and other supported mechanism and languages are out of scope. You can find more information about them at http://mq.dev.java.net</p>
<p><strong><em>6.1 Using Open MQ from Java</em></strong></p>
<p>We may use Open MQ either directly or by using application server managed resources, here we just discuss how we can use Open MQ from Java SE as using JMS service from Java EE is straight forward. </p>
<p>Open MQ provides a broad range of functionalities wrapped in a set of JMS compliant APIs, you can perform usual JMS operation like producing and consuming messages or you can gather metrics related to different resources using the JMS API. Listing 5 shows how sample applications which communicate with a cluster of open MQ brokers. Running the application will result in sending a message and consuming the same message. In order to execute listing 5 and 6 you will need to add imq.jar, imqjmx.jar and jms.jar to your classpath. These files are inside the imq installation lib directory. </p>
<p><strong>Listing 5 Producing and consuming mesaages from a Java SE application</strong></p>
<p><code><br />
public class QueueClient implements MessageListener {      #1<br />
   public void startClientConsumer()throws JMSException {<br />
   com.sun.messaging.ConnectionFactory connectionFactory = new com.sun.messaging.ConnectionFactory();            <br />
connectionFactory.setProperty(com.sun.messaging.ConnectionConfiguration.imqAddressList, &quot;mq://127.0.0.1:7676,mq://127.0.0.1:7677&quot;);          #2<br />
connectionFactory.setProperty(ConnectionConfiguration.imqReconnectEnabled, &quot;true&quot;); #3<br />
connectionFactory.setProperty(ConnectionConfiguration.imqReconnectAttempts, &quot;5&quot;); #3<br />
connectionFactory.setProperty(ConnectionConfiguration.imqReconnectInterval, &quot;500&quot;); #3<br />
connectionFactory.setProperty(ConnectionConfiguration.imqAddressListBehavior, &quot;RANDOM&quot;); #3<br />
   javax.jms.QueueConnection queueConnection = connectionFactory.createQueueConnection(&quot;user01&quot;, &quot;password01&quot;); #4<br />
   javax.jms.Queue smsQueue = null;<br />
   javax.jms.Session session = queueConnection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);               #5<br />
   javax.jms.MessageProducer producer = session.createProducer(smsQueue);<br />
   Message msg = session.createTextMessage(&quot;A sample sms message&quot;);<br />
   producer.send(msg);                 #6<br />
   javax.jms.MessageConsumer consumer = session.createConsumer(smsQueue);<br />
   consumer.setMessageListener(this);         #7<br />
   queueConnection.start();                #8<br />
   }</p>
<p>   public void onMessage(Message sms) {<br />
try {<br />
   String smsContent = ((javax.jms.TextMessage) sms).getText(); #9<br />
   System.out.println(smsContent);<br />
} catch (JMSException ex) {<br />
  ex.printStackTrace();<br />
}<br />
   }<br />
}<br />
</code></p>
<p>As you can see in listing 5 we used JMS programming model to communicate with the Open MQ for producing and consuming messages. At #1 we use the QueueClient class to implement MessageListener interface. At #2 we create a connection factory which connects to one of a cluster member; at #3 we define the behavior of the connection factory in relation to the cluster members. At #4 we provide a privileged user to connect to the brokers. At #5 we create a session which automatically acknowledges receiving the messages. At #6 we send a text message to the queue. At #7 we set QueueClient as the message listener for our consumer. At #8 we start receiving messages from the server and finally at #9 we consume the message in the onMessage method which is MessageListener interface method for processing the incoming messages.</p>
<p>We said that Open MQ provides some functionality which let us retirve monitoring information using JMS APIs. It means that we can receive JMS messages containing Open MQ metrics. But before we can receive such messages we should know where these messages are published and how we should configure Open MQ to publish these messages.</p>
<p>First we need to add some configuration to enable gathering metrics and the interval that these metrics should be gathered, to do this we need to add following properties to one of the configuration files which we discussed in table 5.</p>
<p> </p>
<p><code>imq.metrics.topic.enabled=true</code></p>
<p><code>imq.metrics.topic.interval=30</code></p>
<p> </p>
<p>Now that we enabled the metric gathering, Open MQ will gather brokers, destinations list, JVM, queue, and topics metrics and send each type of these metrics to a pre-configured topic. Broker gathers and sends the metrics messages based on the provided interval. Table 10 shows the topic names for each type of metric information.</p>
<p> </p>
<p>Table 10 Topic names for each type of metric information.</p>
<p><strong> </strong></p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><strong>Topic Name</strong> </p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>Description</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">mq.metrics.broker</p>
</td>
<td>
<p align="left"></p>
<p align="left">Broker metrics: information on connections, message flow, and volume of messages in the broker.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">mq.metrics.jvm</p>
</td>
<td>
<p align="left"></p>
<p align="left">Java Virtual Machine metrics: information on memory usage in the JVM.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">mq.metrics.destination_list</p>
</td>
<td>
<p align="left"></p>
<p align="left">A list of all destinations on the broker, and their types.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">mq.metrics.destination.queue.<em>queueName</em></p>
</td>
<td>
<p align="left"></p>
<p align="left">Destination metrics for a queue of the specified name. Metrics data includes number of consumers, message flow or volume, disk usage, and more. Specify the destination name for the <em>queueName</em> variable.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">mq.metrics.destination.topic.<em>topicName</em></p>
</td>
<td>
<p align="left"></p>
<p align="left">Destination metrics for a topic of the specified name. Metrics data includes number of consumers, message flow or volume, disk usage, and more. Specify the destination name for the <em>topicName</em> variable.</p>
</td>
</tr>
</table>
<p>Now that we know which topics we should subscribe for our metrics we should think about the security of these topics and privileged users which can subscribe to these topics. To configure the authorization for these topics we can simply define some rules in access control file which we discussed in 2.2. Syntax and template for defining authorization for these resources is similar to:</p>
<p><cpde> <br />
topic.mq.metrics.broker.consume.deny.user=*<br />
topic.mq.metrics.broker.consume.allow.user=user01,user02<br />
topic.mq.metrics.destination.topic.t1.consume.deny.user=*<br />
topic.mq.metrics.destination.topic.t1.consume.allow.user=user01<br />
</code></p>
<p>Now that we have the security in place we can write a sample code to retrieve smsQueue metrics, listing 6 shows how we can retrieve smsQueue metrics.</p>
<p><strong>listing 6 retrieving </strong><strong>smsQueue</strong><strong> metrics using brokers metrics messages</strong></p>
<p><code><br />
public void onMessage(Message metricsMessage) {<br />
        try {<br />
 <br />
            String metricTopicName = &quot;mq.metrics.destination.queue.smsQueue&quot;;<br />
            MapMessage mapMsg = (MapMessage) metricsMessage;<br />
            String metrics[] = new String[11];<br />
            int i = 0;<br />
            metrics[i++] = Long.toString(mapMsg.getLong(&quot;numMsgsIn&quot;));<br />
            metrics[i++] = Long.toString(mapMsg.getLong(&quot;numMsgsOut&quot;));<br />
            metrics[i++] = Long.toString(mapMsg.getLong(&quot;msgBytesIn&quot;));<br />
            metrics[i++] = Long.toString(mapMsg.getLong(&quot;msgBytesOut&quot;));<br />
            metrics[i++] = Long.toString(mapMsg.getLong(&quot;numMsgs&quot;));<br />
            metrics[i++] = Long.toString(mapMsg.getLong(&quot;peakNumMsgs&quot;));<br />
            metrics[i++] = Long.toString(mapMsg.getLong(&quot;avgNumMsgs&quot;));<br />
            metrics[i++] = Long.toString(mapMsg.getLong(&quot;totalMsgBytes&quot;) / 1024);<br />
            metrics[i++] = Long.toString(mapMsg.getLong(&quot;peakTotalMsgBytes&quot;) / 1024);<br />
            metrics[i++] = Long.toString(mapMsg.getLong(&quot;avgTotalMsgBytes&quot;) / 1024);<br />
            metrics[i++] = Long.toString(mapMsg.getLong(&quot;peakMsgBytes&quot;) / 1024);<br />
 <br />
        } catch (Exception ex) {<br />
            ex.printStackTrace();<br />
        }<br />
    }<br />
 </code></p>
<p>Listing 6 only shows onMessage method of the message listener class, other part of the code is trivial and very similar to listing 5 with slight changes like subscribing to a topic named mq.metrics.destination.queue.smsQueue instead of smsQueue.</p>
<p>A list of all possible metrics for each type of resource which are properties of the received map message can be found in chapter 20 of Sun Java System Message Queue 4.2 Developer's Guide for Java Clients which is located at <a href="http://docs.sun.com/app/docs/doc/820-5205/aeqej?a=view">docs.sun.com/app/docs/doc/820-5205/aeqej?a=view</a></p>
<p><strong><em>7 GlassFish and Open MQ</em></strong></p>
<p> </p>
<p>GlassFish like other Java EE application servers need to provide messaging functionality behind its JMS implementation. GlassFish uses Open MQ as message broker behind its JMS implementation. GlassFish supports Java Connector architecture 1.5 and using this specification it integrates with Open MQ. If you take a closer look at table 1.4 you can see that by default, different GlassFish installation profiles uses different way of communication with JMS broker which ranges from an embedded instance, local or Open MQ server running on a remote host. Embedded MQ broker is only mode that Open MQ runs in the same process that GlassFish itself runs. In local mode starting and stopping Open MQ server is done by the application server itself. GlassFish starts the associated Open MQ server when GlassFish starts and stop them when GlassFish stops. Finally remote mode means that starting and stopping Open MQ server should be done independently and an administrator or an automated script should take care of the tasks.</p>
<p>We know that how we can setup a glassfish cluster both with an in-memory replication and also a high available cluster with HADB backend for persisting transient information like sessions, JMS messages, and so on. Here in this section we discuss the GlassFish in memory and HADB backed clusters’ relation with Open MQ in more details to let you have a better understanding of the overall architecture of a highly available solution.</p>
<p>First let’s see what happens when we setup an in-memory cluster; after we configure the cluster, we have several instances in the cluster which uses a local Open MQ broker instance for messaging tasks. When we start the cluster all GlassFish instance starts and upon each instances startup, corresponding Open MQ broker starts.</p>
<p>You remember that we discussed conventional clusters which need no backend database for storing the transient data, and instead use one broker as the master broker to propagate changes and keep other broker instances up to date. In GlassFish in-memory replicated clusters, Open MQ broker associated with the first GlassFish instance that we create act as the master broker. A sample deployment diagram for in-memory replicated cluster and its relation with Open MQ is shown in figure 5</p>
<p><img src="http://www.java.net/sites/default/files/5.png" width="445" height="401" /></p>
<p>Figure 5 Open MQ and GlassFish in an in-memory replicated cluster of GlassFish instances. Open MQ will work as conventional cluster which lead in one broker acting as the master broker.</p>
<p> </p>
<p>When it come to enterprise profiles, we usually uses independent high available cluster of Open MQ brokers with a database backend  with a highly available cluster of GlassFish instances which are backed by a highly available HADB cluster.  We discussed that each GlassFish instance can have multiple Open MQ brokers to choose between when it creates a connection to the broker, to configure glassfish to use multiple brokers of a cluster we can add al available brokers to glassfish instance and then let the glassfish manage how to distribute the load between broker instances.  To add multiple brokers to a Glassfish instance we can follow these steps:</p>
<p style=" -qt-block-indent:1;">
<ul type="square">
<li>Open Glassfish administration console</li>
<li>Navigate to instance configuration node or default configuration node of glassfish application server based on either you want to change the glassfish cluster’s instances configuration or a single instance configuration.</li>
<li>Navigate to Configuration&gt; Java Message Service&gt; JMS Hosts from the navigation tree</li>
</ul>
<p>§    Remove the default_JMS_host</p>
<p>§   Add as much hosts as you like this instance or cluster use, each host represent a broker in your cluster</p>
<p style=" -qt-block-indent:1;">
<ul type="square">
<li>Navigate to Configuration&gt; Java Message Service and change the fields value as shown in table 11</li>
</ul>
<p> </p>
<p>Table 11 Glassfish configuration for using a standalone JMS cluster</p>
<p><strong> </strong></p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><strong>Field</strong> </p>
</td>
<td>
<p align="left"></p>
<p align="left"><strong>Value and description</strong></p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Type</p>
</td>
<td>
<p align="left"></p>
<p align="left">We  discussed different types of integration in this section, we will use remote standalone cluster of brokers</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Startup Timeout</p>
</td>
<td>
<p align="left"></p>
<p align="left">Time that GlassFish waits during its startup time before it gives up on JMS service startup, if it gives up no JMS service will be available</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Start Arguments</p>
</td>
<td>
<p align="left"></p>
<p align="left">We can pass any arguments that we can pass to imqbrokerd command using these field</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Reconnect, Reconnect Interval, Reconnect Attempts</p>
</td>
<td>
<p align="left"></p>
<p align="left">We should enable the reconnection, set a meaningful number of retries to connect to the brokers and a meaningful wait time between reconnection</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Default JMS Host</p>
</td>
<td>
<p align="left"></p>
<p align="left">It determines which broker will be used to execute and communicate administrative commands on the cluster. Commands like creating a destination and so on</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Address List Behavior</p>
</td>
<td>
<p align="left"></p>
<p align="left">It can be used to determine how GlassFish select a broker when it creates a connection; it can either random or based on the first available broker in the available host list. First broker has the highest priority.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">Address List Iterations</p>
</td>
<td>
<p align="left"></p>
<p align="left">How many times GlassFish should reiterate over the available hosts list in order to establish a connection if the brokers are not available at first iteration</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">MQ Scheme</p>
</td>
<td>
<p align="left"></p>
<p align="left">Please refer to table 13</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">MQ Service</p>
</td>
<td>
<p align="left"></p>
<p align="left">Please refer to table 13</p>
</td>
</tr>
</table>
<p> </p>
<p>As you can see we can configure GlassFish to use a cluster of Open MQ brokers very easily.  You may like to know how this configuration affects your MDB or a JMS connection that you acquire from the application server, I should say that when you create a connection using a connection factory, GlassFish check the JMS service configuration and return a connection which has the address of a healthy broker as its host address, the selection of the broker is based on the Address List Behavior value, it can select a healthy broker at random or the first healthy host starting from the top of the hosts list.</p>
<p>Open MQ is one of the most feature complete message broker implementation available in the open source and commercial market, it provides a lot of feature including the possibility of using multiple connection protocols for sack simplicity and vast types of clients that may need to connect to it. Two concepts are introduced to cover this connection protocol flexibility:</p>
<p style=" -qt-block-indent:1;">
<ul type="square">
<li>Open MQ Service: Different connection handling services implemented to support variety of connection protocols. All available connection services are listed at table 12.</li>
<li>Open MQ Scheme: Determine the connection schema between an Open MQ client, a connection factory, and the brokers.  Supported schemas are listed at table 12.</li>
</ul>
<p>The full syntax for a message service address is scheme://address-syntax and before using any of the schemas we should ensure that its corresponding service is already enabled. By setting a broker’s imq.service.activelist property, you can configure it to run any or all of these connection services. The value of this property is a list of connection services to be activated when the broker is started up; if the property is not specified explicitly, the jms and admin services will be activated by default.</p>
<p>Table 12 available services and schemas in Open MQ 4.3</p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left">Schema </p>
</td>
<td>
<p align="left"></p>
<p align="left">Service</p>
</td>
<td>
<p align="left"></p>
<p align="left">Description</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">mq</p>
</td>
<td>
<p align="left"></p>
<p align="left">jms and  ssljms</p>
</td>
<td>
<p align="left"></p>
<p align="left">Uses the broker’s port mapper to assign a port dynamically for either the jms or ssljms connection service.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">mqtcp</p>
</td>
<td>
<p align="left"></p>
<p align="left">jms and admin</p>
</td>
<td>
<p align="left"></p>
<p align="left">Bypasses the port mapper and connects directly to a specified port, using the jms connection service.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">mqssl</p>
</td>
<td>
<p align="left"></p>
<p align="left">ssljms and  ssladmin</p>
</td>
<td>
<p align="left"></p>
<p align="left">Makes a SSL connection to a specified port, using the ssljms connection service.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">http</p>
</td>
<td>
<p align="left"></p>
<p align="left">httpjms</p>
</td>
<td>
<p align="left"></p>
<p align="left">Makes a HTTP connection to the Open MQ tunnel Servlet at a specified URL, using the httpjms connection service.</p>
<p align="left">
</td>
</tr>
<tr>
<td>
<p align="left"></p>
<p align="left">https</p>
</td>
<td>
<p align="left"></p>
<p align="left">httpsjms</p>
</td>
<td>
<p align="left"></p>
<p align="left">Makes a HTTPS connection to the Open MQ tunnel Servlet at a specified URL, using the httpsjms connection service.</p>
</td>
</tr>
</table>
<p> </p>
<p>We usually enable the services that we need and leave other services to stay disabled. Enabling each service need its own measure for firewalls configuration and authorization.</p>
<p> </p>
<p><strong>Performance consideration</strong></p>
<p>Performance is always a hurdle in any large scale system because of relatively large number of components which are involved in the system architecture. Open MQ is a high performance messaging system, however you should know that performance differs greatly depending on many different factors including:</p>
<p>The network topology</p>
<p>Transport protocols used</p>
<p>Quality of service</p>
<p>Topics versus queues</p>
<p>Durable messaging versus reliable (some buffering takes place but if a consumer is down long enough the messages are discarded)</p>
<p>Message timeout</p>
<p>Hardware, network, JVM and operating system</p>
<p>Number of producers, number of consumers</p>
<p>Distribution of messages across destinations along with message size</p>
<p> </p>
<p><strong><em> Summary</em></strong></p>
<p>Messaging is one of the most basic and fundamental requirement in every large scale application and in this article So far you learned what is OpenMQ, how does it works, what are its main components, how it can be administrated either using Java code and JMX or using its command line utilities. You learned how a J2SE application can connect to Open MQ using JMS interfaces and act as a consumer or producer. We discussed how we can configure Open MQ to perform access control management. You learned how OpenMQ broker instances can be created and configured to work in a mission critical system.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/openmq-the-open-source-message-queuing-for-beginners-and-professionals-openmq-from-a-to-z/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to prepare for, and install GoDaddy SSL certificate into GlassFish v3</title>
		<link>http://kalali.me/how-to-prepare-for-and-install-godaddy-ssl-certificate-into-glassfish-v3/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-prepare-for-and-install-godaddy-ssl-certificate-into-glassfish-v3</link>
		<comments>http://kalali.me/how-to-prepare-for-and-install-godaddy-ssl-certificate-into-glassfish-v3/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 05:33:28 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[GlassFish Security]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Digital Certificate]]></category>
		<category><![CDATA[GoDaddy]]></category>
		<category><![CDATA[Keytool]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=348</guid>
		<description><![CDATA[Here are steps showing you how to prepare and install a SSL certificate purchased from Godaddy into GlassFish v3 server. To learn more about Godaddy certificates and step to buy a certificate you need to take a look at http://www.godaddy.com/ssl/ssl-certificates.aspx?app_hdr=. After you understand what Godaddy offer and whether it suites your requirement you can use [...]]]></description>
			<content:encoded><![CDATA[<p>Here are steps showing you how to prepare and install a SSL certificate purchased from Godaddy into GlassFish v3 server. To learn more about Godaddy certificates and step to buy a certificate you need to take a look at <a href="http://www.godaddy.com/ssl/ssl-certificates.aspx?app_hdr=">http://www.godaddy.com/ssl/ssl-certificates.aspx?app_hdr=</a>. After you understand what Godaddy offer and whether it suites your requirement you can use the following steps to get and install the certificate into GlassFish.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Generate a keypair for your server using the following command. This command will generate a <a href="http://en.wikipedia.org/wiki/Public-key_cryptography">keypair</a> and store it into a keystore of type <a href="http://java.sun.com/javase/6/docs/api/java/security/KeyStore.html">JKS</a>. later on we will submit the public key portion and other details provided during the key generation to a CA to sing it for us.</li>
<p style=" -qt-block-indent:1;"><code> keytool -keysize 2048 -genkey -alias wwww.domain.com -keyalg RSA -dname &quot;CN=wwww.domain.com,O=company,L=city,S=State,C=Countery&quot; -keypass changeit -storepass changeit -keystore server.keystore </code></p>
<p style=" -qt-block-indent:1;"> </p>
<li>You may check whether you entered correct information in the key generation phase by checking the key using the following command:</li>
<p style=" -qt-block-indent:1;"><code> keytool -list -v -alias wwww.domain.com -keystore server.keystore </code></p>
<p style=" -qt-block-indent:1;"> </p>
<li>Generate a CSR which you should submit to Godaddy to sing it for you. This CSR contains the public key which matchs the private key you generated previously.:</li>
<p style=" -qt-block-indent:1;"> </p>
<p style=" -qt-block-indent:1;"><code> keytool -certreq -alias www.domain.com -keystore server.keystore -storepass changeit -keypass changeit -file server-2048.csr </code></p>
<p style=" -qt-block-indent:1;"><strong>Now, before you submit the CSR, make sure that you backed-up the server.keystore in a safe place because it contains your PK and if you lose it your certificate will be useless. Make sure that the file is in a safe place because if a malicious person gets his hands on it you will be in trouble unless you change your certificate. Using the PK included in that file anyone, with basic knowledge, can decrypt messages encrypted with your public key.</strong></p>
<p style=" -qt-block-indent:1;">Now that you created a backup of the server.keystore and purchased your certificate from godaddy its time to import them into designated keystores. Note that godaddy will give you a certificate named something like domain.com.crt, you will need to download godaddy CA certificates from its repository located at <a href="https://certs.godaddy.com/repository/">https://certs.godaddy.com/repository/</a>. You will need to download the following ones:</p>
<p style=" -qt-block-indent:2;">
<ul type="circle">
<li><a href="https://certs.godaddy.com/anonymous/repository.seam;jsessionid=FB5374DEBF8288372FDCDDC54114EF72.web001?streamfilename=valicert_class2_root.crt&#038;actionMethod=anonymous%2Frepository.xhtml%3Arepository.streamFile%28%27%27%29&#038;cid=50373">valicert_class2_root.crt</a></li>
<li><a href="https://certs.godaddy.com/anonymous/repository.seam;jsessionid=FB5374DEBF8288372FDCDDC54114EF72.web001?streamfilename=gd_cross_intermediate.crt&#038;actionMethod=anonymous%2Frepository.xhtml%3Arepository.streamFile%28%27%27%29&#038;cid=50373">gd_cross_intermediate.crt</a></li>
<li><a href="https://certs.godaddy.com/anonymous/repository.seam;jsessionid=FB5374DEBF8288372FDCDDC54114EF72.web001?streamfilename=gd_intermediate.crt&#038;actionMethod=anonymous%2Frepository.xhtml%3Arepository.streamFile%28%27%27%29&#038;cid=50373">gd_intermediate.crt</a></li>
</ul>
<p style=" -qt-block-indent:1;">Now place all of the following files into a $domain.dir and fire a terminal (cmd) and execute the following commands:</p>
<p style=" -qt-block-indent:2;">
<ul type="circle">
<li><a href="https://certs.godaddy.com/anonymous/repository.seam;jsessionid=FB5374DEBF8288372FDCDDC54114EF72.web001?streamfilename=valicert_class2_root.crt&#038;actionMethod=anonymous%2Frepository.xhtml%3Arepository.streamFile%28%27%27%29&#038;cid=50373">valicert_class2_root.crt</a></li>
<li><a href="https://certs.godaddy.com/anonymous/repository.seam;jsessionid=FB5374DEBF8288372FDCDDC54114EF72.web001?streamfilename=gd_cross_intermediate.crt&#038;actionMethod=anonymous%2Frepository.xhtml%3Arepository.streamFile%28%27%27%29&#038;cid=50373">gd_cross_intermediate.crt</a></li>
<li><a href="https://certs.godaddy.com/anonymous/repository.seam;jsessionid=FB5374DEBF8288372FDCDDC54114EF72.web001?streamfilename=gd_intermediate.crt&#038;actionMethod=anonymous%2Frepository.xhtml%3Arepository.streamFile%28%27%27%29&#038;cid=50373">gd_intermediate.crt</a></li>
<li>domain.com.crt, this is what Godaddy gives you as the certificate.</li>
</ul>
<li>Import the root certificate into the glassfish key store to make it possible for the secondary certificates to get validated. The keytool may tell you that the certificate already exists in the global ca cert store. If so, do not import this one:</li>
<p style=" -qt-block-indent:1;"><code>keytool -import -alias root -keystore keystore.jks -trustcacerts -file valicert_class2_root.crt</code></p>
<p style=" -qt-block-indent:1;"> </p>
<li>import secondary CA certificates into the keystore to make it possible for the server certificate signed by godaddy to validated and accepted.</li>
<p style=" -qt-block-indent:1;"><code>keytool -import -alias cross -keystore keystore.jks -trustcacerts -file gd_cross_intermediate.crt</code></p>
<p style=" -qt-block-indent:1;"><code>keytool -import -alias intermed -keystore keystore.jks -trustcacerts -file gd_intermediate.crt</code></p>
<li>import the server certificate into tke keystore. Make sure that the alias used for the certificate must be same as the alias used for the PK. otherwise the validation chain wont get completed and therefore the certificate won’t be imported into the keystore.</li>
</ul>
<p style=" -qt-block-indent:1;"><code>keytool -import -alias www.domain.com -keystore keystore.jks -trustcacerts -file shoptalkk.com.crt</code></p>
<p>The certificate installation is finished, the only left step is chaning the certificate nickname in your domain.xml file to the new alias name we used in the above commands.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Make sure that the domain is stopped using asadmin stop-domain domain_name</li>
<li>create a backup of the domain.xml</li>
<li>Open domain.xml in a text editor like gedit, kate or wordpad and replace all occurrence of s1as with www.domain.com which is the certificate alias</li>
<li>save the domain and start the domain in verbose mode using asadmin start-domain &#8211;verbose domain_name</li>
<li>Open https://server:8181/ and see whether it works properly or not. if you use the exact https://domain.com:8181/ you should get no warning and the whole thing should work properly. If you use https://localhost:8181/ you will get a warning about a misused certificate. it will explain that the certiificate is issued for www.domain.com but it is installed on localhost&#8230;.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/how-to-prepare-for-and-install-godaddy-ssl-certificate-into-glassfish-v3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>And GlassFish v3 is Here</title>
		<link>http://kalali.me/and-glassfish-v3-is-here/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=and-glassfish-v3-is-here</link>
		<comments>http://kalali.me/and-glassfish-v3-is-here/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 19:12:36 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Modularity]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[GlassFish v3]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=346</guid>
		<description><![CDATA[The long awaited and the most looked upon version of GlassFish released today. GlassFish v3 fully implements Java EE 6 specification which means EJB 3.1, Servlet 3, JAX-RS, JPA 2, Contexts and Dependency Injection for Java EE, Bean validation, Java EE profiles and so on.   GlassFish is not only the most up to date [...]]]></description>
			<content:encoded><![CDATA[<p>The long awaited and the most looked upon version of <a href="https://glassfish.dev.java.net/">GlassFish</a> released today. GlassFish v3 fully implements <a href="http://java.sun.com/javaee/">Java EE 6</a> specification which means EJB 3.1, Servlet 3, JAX-RS, JPA 2, Contexts and Dependency Injection for Java EE, Bean validation, Java EE profiles and so on.</p>
<p> </p>
<p>GlassFish is not only the most up to date application server but it also benefits from a very good architecture. <a href="https://glassfish.dev.java.net/">GlassFish</a> architecture provides extensions points and contracts which 3rd party developers can use to add functionality to <a href="https://glassfish.dev.java.net/">GlassFish</a> (even the administration console is plubable).</p>
<p> </p>
<p>GlassFish v3 is an important milestone in <a href="https://glassfish.dev.java.net/">GlassFish</a> life because now it is fully based on OSGI modularity framework which means <a href="https://glassfish.dev.java.net/">GlassFish</a> can be integrated into a bigger OSGI system.</p>
<p> </p>
<p>In addition to Java EE profiles, <a href="https://glassfish.dev.java.net/">GlassFish</a> v3 is also available as an embedded application server which we can use for testing purpose or any other kind of in process use cases.</p>
<p> </p>
<p>What I like the most about <a href="https://glassfish.dev.java.net/">GlassFish</a> is its close integration with many other well developed products like <a href="https://open-esb.dev.java.net/">OpenESB</a>, <a href="https://opensso.dev.java.net/">OpenSSO</a>, IDEs, and so on in addition to its superb performance and administration channels.</p>
<p> </p>
<p><a href="https://glassfish.dev.java.net/">GlassFish</a> v3 adds another reason to make one consider it as the prime option for deploying simple and complex application, and that is its extensibility which so far made it possible to host different kind of scripting language based applications like application based on RoR or PHP in the same process which hosts the Java EE applications.</p>
<p> </p>
<p><a href="https://glassfish.dev.java.net/">GlassFish</a> v3 is available for download at: <a href="https://glassfish.dev.java.net/">https://glassfish.dev.java.net/</a></p>
<p> </p>
<p>Like GlassFish v2, Sun Microsystems provides support for GlassFish if you need a higher level of assurance and guranteed support. to get more information on the provided support model take a look at <a href="http://www.sun.com/software/products/glassfishv3/">GlassFish Enterprise Home-page</a>.</p>
<p> </p>
<p>And if you are interested there is a <a href="http://refcardz.dzone.com/refcardz/getting-started-glassfish"><strong>GlassFish V3 Refcard</strong></a> published by DZone and authored by me which introduces <a href="https://glassfish.dev.java.net/">GlassFish</a> v3 in more details and gives you all you need to start working with <a href="https://glassfish.dev.java.net/">GlassFish</a> v3.</p>
<p> </p>
<p> </p>
<p>I have an <a href="http://www.packtpub.com/glassfish-security-with-java-ee/"><strong>Upcoming Book</strong></a> about <a href="https://glassfish.dev.java.net/">GlassFish</a> which is due to be published on April 2010 by <a href="http://www.packtpub.com/">Packt Publishing</a>. The book mainly discuss <a href="https://glassfish.dev.java.net/">GlassFish</a> security (administration and configuration), Java EE security and using <a href="https://opensso.dev.java.net/">OpenSSO</a> to secure Java EE applications in general and Java EE web services in particular.</p>
<p> </p>
<p>To learn more about <a href="http://java.sun.com/javaee/">Java EE 6</a>, you can take a look at Sun<a href="http://java.sun.com/javaee/"> Java EE 6</a> white paper located at: <a href="https://www.sun.com/offers/docs/java_EE6_overview_paper.pdf">https://www.sun.com/offers/docs/java_EE6_overview_paper.pdf</a></p>
<p> </p>
<p>Another way for you to meet GlassFish folks, other GlassFish community members and to learn more about GlassFish v3 is to join the <a href="http://www.sun.com/software/products/glassfishv3/GlassFish_Conference_Flyer.pdf"><strong>Virtual Conference about GlassFish</strong></a> v3 which is supposed to take place on 15th of December.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/and-glassfish-v3-is-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NetBeans 6.8 joined the GlassFish v3 in the release feast.</title>
		<link>http://kalali.me/netbeans-6-8-joined-the-glassfish-v3-in-the-release-feast/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=netbeans-6-8-joined-the-glassfish-v3-in-the-release-feast</link>
		<comments>http://kalali.me/netbeans-6-8-joined-the-glassfish-v3-in-the-release-feast/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 19:09:42 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=344</guid>
		<description><![CDATA[NetBeans 6.8 released coordinated with GlassFish v3 today. NetBeans 6.8 can be considered a fine step ahead of NetBeans because Sun is officially supporting the NetBeans RCP platform as a product from now on. NetBeans 6.8 features are as follow: Java Enterprise Edition 6 support Web Projects with JavaServer Faces 2.0 (Facelets) JavaFX 1.2.1 support [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://netbeans.org/community/releases/68/">NetBeans 6.8</a> released coordinated with <a href="http://weblogs.java.net/blog/kalali/archive/2009/12/10/and-glassfish-v3-here">GlassFish v3</a> today. <a href="http://netbeans.org/community/releases/68/">NetBeans 6.8</a> can be considered a fine step ahead of <a href="http://netbeans.org/">NetBeans</a> because Sun is officially supporting the <a href="http://platform.netbeans.org/">NetBeans RCP platform</a> as a product from now on.</p>
<p><a href="http://netbeans.org/community/releases/68/">NetBeans 6.8</a> features are as follow:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Java Enterprise Edition 6 support</li>
<li>Web Projects with JavaServer Faces 2.0 (Facelets)</li>
<li>JavaFX 1.2.1 support</li>
<li>Kenai.com: Connected Developer</li>
<li>Full support for PHP 5.3. NetBeans is now a modern IDE for PHP as well as for Java</li>
<li>Full Maven support for new projects and importing projects</li>
<li>Full support for Ruby and Support for creating Rails 2.3.4 apps</li>
<li>Full development cycle is provided for C/C++</li>
</ul>
<p>More information:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li><a href="http://netbeans.org/features/index.html">NetBeans IDE 6.8 Features</a></li>
<li><a href="http://netbeans.org/kb/index.html">NetBeans IDE 6.8 Tutorials and Documentation</a></li>
<li><a href="http://platform.netbeans.org/">NetBeans Platform 6.8</a></li>
<li><a href="http://netbeans.org/kb/docs/intro-screencasts.html"> Videos of NetBeans IDE 6.8 in Action</a></li>
</ul>
<p>NetBeans ECP, which the IDE is based on, is a first tier application development platform for Java platform. Anyone looking to develop a desktop application should definitly take a look at NetBeans RCP before making a decision about the framework or platform he or she wants to use.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/netbeans-6-8-joined-the-glassfish-v3-in-the-release-feast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GlassFish Application Server v3 Refcard Available &#8211; Download Now</title>
		<link>http://kalali.me/glassfish-application-server-v3-refcard-available-download-now/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=glassfish-application-server-v3-refcard-available-download-now</link>
		<comments>http://kalali.me/glassfish-application-server-v3-refcard-available-download-now/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 12:52:20 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[GlassFish Security]]></category>
		<category><![CDATA[High Availability]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[GlassFish v3]]></category>
		<category><![CDATA[learn]]></category>
		<category><![CDATA[manage]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=342</guid>
		<description><![CDATA[I authored a new refcard covering GlassFish v3, This refcard is different from my previous one which covers GlassFish v2. This new refcard discuss the following items:   Introduction to GlassFish application server v3. GlassFish v3 versions, installation and directory structure. Glassfish v3 daily administration tasks. Glassfish v3 Restful interface for monitoring and administration. GlassFish [...]]]></description>
			<content:encoded><![CDATA[<p><strong>I authored a new refcard covering GlassFish v3, This </strong><a href="http://refcardz.dzone.com/refcardz/getting-started-glassfish?oid=hom14073"><strong>refcard</strong></a><strong> is different from my </strong><a href="http://refcardz.dzone.com/refcardz/glassfish-application-server"><strong>previous</strong></a><strong> one which covers GlassFish v2. This new refcard discuss the following items:</strong></p>
<p> </p>
<p style=" -qt-block-indent:1;">
<ol>
<li>Introduction to <a href="https://glassfish.dev.java.net/">GlassFish application server</a> v3.</li>
<li><strong>GlassFish v3</strong> versions, installation and directory structure.</li>
<li><strong>Glassfish v3</strong> daily administration tasks.</li>
<li><strong>Glassfish v3</strong> Restful interface for monitoring and administration.</li>
<li><strong>GlassFish v3</strong> JMX interface for administration and management.</li>
<li>Securing <strong>GlassFish v3</strong>.</li>
<li><strong>GlassFish v3</strong> performance tuning tips.</li>
<li><strong>GlassFish v3</strong> extendibility and extension points.</li>
<li>Troubleshooting <strong>GlassFish v3.</strong></li>
<li><strong>GlassFish update tool</strong></li>
</ol>
<p>You can download the refcard free of charge from <a href="http://refcardz.dzone.com/refcardz/getting-started-glassfish?oid=hom14073">here</a>.</p>
<p><a href="http://refcardz.dzone.com/refcardz/getting-started-glassfish?oid=hom14073"><img src="http://refcardz.dzone.com/sites/all/files/refcardz/covers/14321.png" /></a> </p>
<p>The refcard includes several tables and illustration to describe different topics which will help with easier learning and remembering things.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/glassfish-application-server-v3-refcard-available-download-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Architecting a system need a wide knowledge of technologies, COTS, projects, standards&#8230;.</title>
		<link>http://kalali.me/architecting-a-system-need-a-wide-knowledge-of-technologies-cots-projects-standards/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=architecting-a-system-need-a-wide-knowledge-of-technologies-cots-projects-standards</link>
		<comments>http://kalali.me/architecting-a-system-need-a-wide-knowledge-of-technologies-cots-projects-standards/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 12:12:22 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[COTS]]></category>
		<category><![CDATA[Technologies]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=340</guid>
		<description><![CDATA[When we start working on a new project as an architect we are dealing basically with a set of requirement which our architecture should be able to act as a foundation for the design and implementation of those requirements in form of a software system. to let the customer fulfill its requirements in a better [...]]]></description>
			<content:encoded><![CDATA[<p>When we start working on a new project as an architect we are dealing basically with a set of requirement which our architecture should be able to act as a foundation for the design and implementation of those requirements in form of a software system. to let the customer fulfill its requirements in a better and more efficient way.</p>
<p>Preparing the architecture for a software system means not only the architect to be familiar with the domain but also he should well aware of new technologies, frameworks, COTS, and standards available not only for the domain he is working on but also for the development platform which will realize the architecture into a working piece of software.</p>
<p>Knowing a platform is the foundation for knowing the related technologies, standards and popular frameworks around that platform, but to know the COTS, or open source projects around the same domain we are going to work on we will need to have some experience in implementing some software in the similar fields or we should have some research in the similar domain.</p>
<p>Having enough experience in doing architecture, knowing the domain, the platform and the free or commercial enablers form the necessaries in creating a good architecture but it is not enough because of the advancement in deployment models which one can select to develop and deploy the system independent of the domain itself. Having knowledge and experience with component models, modularity frameworks, integration standards and solutions, and deployment model form the next set of necessities in creating a good architecture.</p>
<p>Finally, I think being passionate in doing something play a big role in being successful in it. So, being passionate is the most notable requirement for an architect and without it, the architect will not be able to achieve his goal which is nothing but preparing a good architecture and realizing it to a good software.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/architecting-a-system-need-a-wide-knowledge-of-technologies-cots-projects-standards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>State of Open Source Java EE Application Servers</title>
		<link>http://kalali.me/state-of-open-source-java-ee-application-servers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=state-of-open-source-java-ee-application-servers</link>
		<comments>http://kalali.me/state-of-open-source-java-ee-application-servers/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 07:56:53 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Comparison]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Geronimo]]></category>
		<category><![CDATA[JonAS]]></category>
		<category><![CDATA[Resin]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=338</guid>
		<description><![CDATA[This is a very basic review of active and available open source Java EE Application servers and Servlet container (Web containers) to let the community know which active containers are available and what is the general status of each container. The article can simply act as a start point for anyone need to select one [...]]]></description>
			<content:encoded><![CDATA[<p>This is a very basic review of active and available open source Java EE Application servers and Servlet container (Web containers) to let the community know which active containers are available and what is the general status of each container. The article can simply act as a start point for anyone need to select one of them for later use in development or product. Detailed comparison of these production cover many pages of a tick book.</p>
<h2>Full blown Open Source Java EE Application Servers:</h2>
<p><a href="http://www.caucho.com/projects/resin/"><strong>Resin</strong></a>, a well known product from <a href="http://www.caucho.com/">Caucho</a> is an open source Java EE application server which has been around for quite a long time and many small and large deployment of it are serving small and large systems like DZone itself.</p>
<p>Current stable version of Resin is 3.1.9 which fully support Java EE 5 and the development version which will replace the current one is 4.0.1. Resin licensing <img src="http://www.caucho.com/wp-content/themes/caucho/images/caucho-download-blue.gif" alt="" width="180" height="100" />Schema is a bit different with other alternatives. They provide a GPL-ed version for open source distributer and evaluators while commercial usage requires paying Caucho some per/CPU &#8211; per/year fees. Different editions of Resin is available with a different set of features and capabilities and each edition has its own pricing schema. You can find more about the different versions and licensing fees at: <a href="http://www.caucho.com/products/sales/"><strong>Licensing</strong></a></p>
<p>Resin come with Clustering, high availability support and benefits from an integrated caching system. Similar to GlassFish Resin support hosting PHP applications using Quercus.</p>
<p>For the administration and management, Resin took an alternate path by providing a light weight monitoring application to let administrators and developers see status of different services in the application server and left the the administrators to perform administrative and configuration tasks trough configuration files.</p>
<p>When it come to development tools support you can expect NetBeans, Eclipse and IntelliJ integration along with integration with Ant, Maven, and Ivy.</p>
<p style="-qt-block-indent: 1;">
<ul>
<li>Download link: <a href="http://www.caucho.com/download/">http://www.caucho.com/download/</a> You can get version 4.0.1</li>
<li>How to start: goto <em>install_dir/bin</em> and issue <em>/resin.sh start </em>or <em>resin.bat start</em> dependin on your OS</li>
<li>Monitoring Console: details: URL: <a href="http://127.0.0.1:8080/resin-admin/">http://127.0.0.1:8080/resin-admin/</a> You will need to create a user and password to proceed further. Follow the on-screen steps to create the user and password.</li>
</ul>
<p><a href="http://geronimo.apache.org/"><strong>Geronimo</strong></a>: The Apache Java EE application server which is obviously distributed under ASF. Geronimo lacks behind GlassFish when it come to implementing new Java EE specification but it benefits from a good<a href="http://geronimo.apache.org/"><img src="http://upload.wikimedia.org/wikipedia/en/9/96/Apache_Geronimo_Logo_Large.png" alt="" width="140" height="92" /></a> administration console compared to JBoss. Clustering is available trough 3rd party products like Terracotta and there is no out of the box support for clustering and high availability. Geronimo is well integrated with other apache projects like ServiceMix and ActiveMA. Current version of Geronimo is v2.1.4 and fully support Java EE 5 specification. Commercial support for Geronimo is available through IBM WebSphere Application Server Community Edition.</p>
<p>Two separate distribution of Geronimo is available, one with Jetty as web container and the other one with Tomcat as the web container. All Major IDEs support Geronimo as a development server.</p>
<p style="-qt-block-indent: 1;">
<ul>
<li>Download link: <a href="http://geronimo.apache.org/apache-geronimo-v214-release.html">http://geronimo.apache.org/apache-geronimo-v214-release.html</a></li>
<li>How to start: goto install_dir/bin and issue <em>./geronimo.sh start</em> or <em>geronimo.bat start</em> depending on the OS</li>
<li>administration console details: URL: <a href="http://localhost:8080/console/">http://localhost:8080/console/</a> credentials: system/manager</li>
</ul>
<p><a href="https://glassfish.dev.java.net/"><strong>GlassFish</strong></a>: Mainly developed by sun Microsystems and benefits from a modular, and extend-able architecture. GlassFish is in the front line of providing the community with new Java EE specification implementation and in the same time it provides all users with features like: advanced administration channels, out of the box<a href="https://glassfish.dev.java.net/"><img src="http://blogs.sun.com/theaquarium/resource/GlassFish-Logo-140_92.jpg" alt="" width="140" height="92" /></a> clustering and high availability, OSGI runtime deployment and so on. Using Glassfish means that users can easily sign a contract and get support from Sun without need to change the deployment bits. current GlassFish stable version is GlassFish 2.1.1 and the next major version is GlassFish v3 which is a fully Java EE 6 compliant and OSGI based application server. The new version is due to be released on November this year. Open source GlassFish is accessible under CDDL and GPL licenses.</p>
<p>GlassFish benefits from integration with a wide set of Sun products starting from operating system (Solaris) up to the IDE (NetBeans). GlassFish ESB, Open Portal, OpenSSO and OpenMQ are some of the notable projects that GlassFish is well integrated with.</p>
<p>Another strength in GlassFish is integration with Sun HADB which can form a proven highly available infrastructure without spending any penny for the required software and licenses.</p>
<p>All Major IDEs support GlassFish as a development server and it means an easy start for developing Java EE applications using GlassFish.</p>
<p style="-qt-block-indent: 1;">
<ul>
<li>Downlod link: <a href="https://glassfish.dev.java.net/downloads/v2.1.1-final.html">https://glassfish.dev.java.net/downloads/v2.1.1-final.html<br />
</a></li>
<li>How to start: goto intall_dir/bin and issue <em>asadmin start-domain</em></li>
<li>Administration console details: URL: <a href="http://localhost:4848/">http://localhost:4848</a> Default credentials: admin/adminadmin</li>
</ul>
<p><a href="http://www.jboss.org/jbossas/"><strong>JBoss</strong></a>: It was present in the open source community longer than other projects and benefits from Red hat support. JBoss Application server provides Clustering and high availability out of the box but the administration console which included in the distribution from version 5.1 is not advanced enough to let administrators manage the all application server resources . The included administration and management console is an embedded <a href="http://www.jboss.org/jbossas/"><img src="http://i.zdnet.com/blogs/jboss_logo.jpg" alt="" width="140" height="70" /></a>version of Jopr (http://www.jboss.org/jopr). This console will acts as a single point of administration and management for all JBoss technologies like ESB, cache et. Current version of JBoss is 5.1.0.GA and next upcoming version is 5.2. JBoss is distributed under LGPL and anyone interested can get commercial support from Red Hat. JBoss community distribution and enterprise distribution are two different package and and moving from community support to commercial support means installing an alternate version of Jboss named JBoss Enterprise Middleware.</p>
<p>JBoss application server benefits from integration with a wide range of middleware provided by JBoss. This products include caching, BPM, ESB, portal and so on. On the development side, it benefits from JBoss Developer Studio (not available for free) which is based on Eclipse and provide tooling for wide range of middlewares provided by Jboss.</p>
<p>All Major IDEs support JBoss as a<br />
development server and it means an easy start for developing applications on top of this application server</p>
<p style="-qt-block-indent: 1;">
<ul>
<li>Download link: <a href="http://www.jboss.org/jbossas/downloads/">http://www.jboss.org/jbossas/downloads/</a></li>
<li>How to start: goto install_dir/bin and issue <em>./run.sh</em> or <em>./run.bat</em> depending on the OS</li>
<li>administration console details: URL: <a href="http://localhost:8080/admin-console/">http://localhost:8080/admin-console/</a> default credentials: admin/admin</li>
</ul>
<p><a href="http://wiki.jonas.ow2.org/xwiki/bin/view/Main/WebHome"><strong>JOnAS</strong></a> is one the flagship projects in OW2 consortium and in contrast with having less buzz in the news and blogosphere it benefits from a profound modular architecture based on OSGI. JOnAS administration console is well designed and benefits from a slick user interface. Jonas benefits form integration with JASMINe for <a href="http://wiki.jonas.ow2.org/xwiki/bin/view/Main/WebHome"><img src="http://www.easybeans.net/xwiki/bin/download/Main/WebHome/logo_jonas.png" alt="" /></a>designing, deploying and administrating a clustered environment.</p>
<p>Current version of Jonas is 5.1 which fully support Java EE 5, the next planned version is 5.2 which is due to be released in Feb 2010 with basic support of Java EE and self management. Major IDEs like Eclipse and NetBeans support JOnAS as a development server. Jonas is distributed under LGPL</p>
<p style="-qt-block-indent: 1;">
<ul>
<li>Download link: <a href="http://wiki.jonas.ow2.org/xwiki/bin/view/Main/Downloads">http://wiki.jonas.ow2.org/xwiki/bin/view/Main/Downloads</a></li>
<li>How to start: goto install_dir/bin and issue <em>./jonas start</em> or <em>jonas.bat start</em> depending on the OS</li>
<li>administration console details: URL: <a href="http://localhost:9000/jonasAdmin/">http://localhost:9000/jonasAdmin/</a> Credentials: admin/admin</li>
</ul>
<h2>Servlet Containers:</h2>
<p><a href="http://www.eclipse.org/jetty/"><strong>Jetty</strong></a><strong>: </strong>Jetty is considered an alternative to Tomcat to some level. Because of the differences between these containers architecture each of them has its user base. Jetty is considered lighter, easier to embed and highly modular while Tomcat is considered more feature rich. Both projects benefit from a good performance under<a href="http://www.eclipse.org/jetty/"><img src="http://www.eclipse.org/jetty/images/jetty-logo-80x22.png" alt="" width="283" height="80" /></a> heavy load but it certainly can change from version to version and between different use cases. A cluster of jetty instances can be configured using any of Gigaspaces, WADI, Terracotta, etc. Jetty does not have a management console and everything should go through the configuration files by adding required changes to the configuration files. A good comparison between Tomcat and Jetty can be found at: <a href="http://www.webtide.com/choose/jetty.jsp">http://www.webtide.com/choose/jetty.jsp</a></p>
<p style="-qt-block-indent: 1;">
<ul>
<li>Download link: <a href="http://www.eclipse.org/jetty/downloads.php">http://www.eclipse.org/jetty/downloads.php</a></li>
<li>How to start: goto<em> install_dir/bin</em> and issue<em> ./jetty.sh start </em>or<em> jetty.bat start</em> depending on the OS</li>
<li>Administration console details: No administration console.</li>
</ul>
<p><strong>Note</strong>: before attempting to start Jetty add following line in the install_dir/bin/jetty.sh or jetty.bat depending on the OS.</p>
<p>For Windows:</p>
<pre>set JETTY_HOME=path/to/jetty/install/dir</pre>
<p>For Linux, UNIX..:</p>
<pre>export JETTY_HOME=path/to/jetty/install/dir</pre>
<p style="-qt-block-indent: 1;">
<ul>
<li>Download link: <a href="http://tomcat.apache.org/download-60.cgi#6.0.20">http://tomcat.apache.org/download-60.cgi#6.0.20 </a></li>
<li>How to start: goto <em>install_dir/bin</em> and issue <em>./startup.sh</em> or <em>startup.bat</em> depending on the OS</li>
<li>Administration console details: URL: <a href="http://127.0.0.1:8080/manager/html">http://127.0.0.1:8080/manager/html</a> Credentials: admin/admin</li>
</ul>
<p>Note: before starting tomcat add following line in the <em>install_dir/conf/tomcat-users.xml</em> inside the<em> tomcat-users</em> node:</p>
<pre>&lt;user username="tomcat" password="tomcat" roles="manager"/&gt;</pre>
<p><strong>Conclusion:</strong> None of this projects can fit all development and deployment plans and requirement. Each of them has its strenghts and weak points compared to other 5 competitive projects. What one need to do is testing all of them and decide which one is better.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/state-of-open-source-java-ee-application-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Karmic Koala and using more than 3 GB of RAM  in its 32 bit installation.</title>
		<link>http://kalali.me/karmic-koala-and-using-more-than-3-gb-of-ram-in-its-32-bit-installation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=karmic-koala-and-using-more-than-3-gb-of-ram-in-its-32-bit-installation</link>
		<comments>http://kalali.me/karmic-koala-and-using-more-than-3-gb-of-ram-in-its-32-bit-installation/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 08:11:11 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[32 bit]]></category>
		<category><![CDATA[Increase RAM]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=336</guid>
		<description><![CDATA[I upgraded my laptop OS to Karmic Koala (Ubuntu 9.10) beta version to play with new features and capabilities provided in this release. Out of habit or whatever I am using 32 bit version of the OS both on the laptop and desktop (both are 64 bit) and I rather prefer to stay with 32 [...]]]></description>
			<content:encoded><![CDATA[<p>I upgraded my laptop OS to Karmic Koala (Ubuntu 9.10) beta version to play with new features and capabilities provided in this release.</p>
<p>Out of habit or whatever I am using 32 bit version of the OS both on the laptop and desktop (both are 64 bit) and I rather prefer to stay with 32 bits as some application sucks on 64 bit (are they still suck?). Well in previous versions I replaced the kernel with a server kernel to have access to all of my 4 GB of RAM but in the new release it is not possible to install the server kernel for 32 bit architecture as it is dropped <img src='http://kalali.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . To get more information about provided kernels take a look at : <a href="https://wiki.ubuntu.com/KernelTeam/Specs/KarmicKernelFlavours">https://wiki.ubuntu.com/KernelTeam/Specs/KarmicKernelFlavours</a></p>
<p>So, how we can use more than 3GB of ram on a 32 bit Ubuntu? It is simply possible by installing the<strong><em> linux-generic-pae</em></strong> meta package. you can install it simply by using the following command or clicking on <a href="apt:linux-generic-pae">apt:linux-generic-pae</a> link if you are using Firefox. (I do not know whether other browser can handle the link type correctly, do they?)</p>
<pre>sudo apt-get install linux-generic-pae</pre>
<p>The above command will install <strong>linux-image-2.6.31-13-generic-pae</strong> and <strong>linux-image-generic-pae</strong> or newer version when available. You may need to install the l<strong>inux-headers-generic-pae</strong> if you are planning some development.</p>
<p>Now you need to restart the system and boot using the new kernel. By default Ubuntu should use the latest kernel version available in the system.</p>
<p>To see the amount of recognized RAM use <strong><em>free</em></strong> command &#8230;. just type the command in the terminal and you will understand.</p>
<p>If you can not use more than 3GB of ram after restarting the machine it means that Ubuntu is using the generic kernel and you should either remove the generic kernel or you should change the boot configuration.</p>
<p>To make the new grub show the boot loading menu you should open<strong><em> /etc/default/grub</em></strong> and comment the<em> </em><strong><em>GRUB_HIDDEN_TIMEOUT=0 </em></strong>after commenting this property and saving the file you will need to execute the following command which will generatet he /boot/grub/grub.cfg file:</p>
<pre>sudo update-grub</pre>
<p>Now you should be able to see the boot loader menu to choose the kernel version you want to boot with.</p>
<p>To remove generic kernel packages you can use a command like the following command depending the kernel version you want to remove.</p>
<pre>
sudo apt-get remove linux-image-2.6.31-13-generic linux-image-generic</pre>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/karmic-koala-and-using-more-than-3-gb-of-ram-in-its-32-bit-installation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fanurio: A management solution for freelancers.</title>
		<link>http://kalali.me/fanurio-a-management-solution-for-freelancers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=fanurio-a-management-solution-for-freelancers</link>
		<comments>http://kalali.me/fanurio-a-management-solution-for-freelancers/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 15:23:08 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Software Review]]></category>
		<category><![CDATA[Fanurio]]></category>
		<category><![CDATA[freelancing]]></category>
		<category><![CDATA[Review]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=334</guid>
		<description><![CDATA[Well, everyone used to freelance for some time and some people freelance for their entire working life. An integral part of freelancing is interacting with customers and keeping track of projects, tasks, and services related to each customer. A freelancer can start with Excel sheets to keep track of working hour spent on a task [...]]]></description>
			<content:encoded><![CDATA[<p>Well, everyone used to freelance for some time and some people freelance for their entire working life. An integral part of freelancing is interacting with customers and keeping track of projects, tasks, and services related to each customer.</p>
<p>A freelancer can start with Excel sheets to keep track of working hour spent on a task in a project and finally calculate how much the client should pay for the time s/he spent on the project by summing the amount of time s/he spent on each task.</p>
<p>At some point freelancers will find themselves in need for a better management solution to keep track of everything related to the customers, projects, services, tasks, payments, invoices and so on.</p>
<p>This is when the freelancer will start looking for a software to manage them. a software which we can define customer and projects and then we start adding time slices to the project and shows us how much time we spent on the project and how much cash we should ask the customer to pay.</p>
<p>The above solution will work for sometimes and after that a more complex management solution will be required to manage the customers, projects, services, tasks, spent time, unit of works and so on and so on. this is when we start looking for a software capable of doing all things with the smallest amount of time devoted to keeping the record of time spent for a customer.</p>
<p>The search for such a tool will took longer than you think because there are more than a handful of software doing the management tasks and selecting a good one will take some time.</p>
<p>I have been in this path and up to 3 months ago I was using <a href="http://www.ehour.nl/">eHour</a> to manage my work with different customer on multiple projects for each customer but after some time i felt the need for a more automated software which means a more complete in term features like:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Bill-able and non-billable tasks and services</li>
<li>Multiple way of measuring the work units</li>
<li>Simple accounting and invoice/ payment management</li>
<li>customizable invoice templates for different customer/projects.</li>
<li>Simple way of measuring the time I spent for each task/ service / project&#8230;</li>
<li>easy back up restore for the database</li>
<li>Cross platform with easy data migration between different platform.</li>
<li>etc</li>
</ul>
<p>All of these requirement satisfied when I start using <a href="http://www.fanuriotimetracking.com/">Fanurio</a>. The software is simple, slick and amazingly complete comparing with other software I tried during the evaluation period.</p>
<p>I simply start the application, it sits in the System Tray (Windows, Linux, Mac&#8230;). I click the start time, when required I pause the time and when finished I stop the time. I select which customer, which project and which service I want the time to be appended and it is finished.</p>
<p><img src="http://www.java.net/sites/default/files/image-01-masoud.png" /></p>
<p>As you have already guessed software is developed using Java and benefits from a very good and easy to use GUI. A feature that I learned about after about two weeks is an alternate view which shows a timer counting amount of time we spent since we started the timer.</p>
<p><img src="http://www.java.net/sites/default/files/image-02-masoud.png" /></p>
<p>Down to technical terms, this application uses <a href="http://hsqldb.org/">HSQL</a>, Swing,<a href="http://www.jgoodies.com/freeware/looks/"> JGoodies Looks</a>, <a href="www.lowagie.com/iText/">Itext</a> for PDF generation and rendering (Invoices can be generated in PDF or HTML) among other libraries. It also uses the <a href="http://ehcache.sourceforge.net/">ehcache</a> and <a href="https://www.hibernate.org/ ">Hibernate</a> in addition to using <a href="http://freemarker.org/">Freemarker</a> for templates.</p>
<p>With all good features there is an small drawback which probably means nothing for 99% of developers. The software does not support Arabic text properly both in the GUI and in the generated PDF files. The encoding of HTML files are not correct as well (it can be viewed by changing the encoding from View menu) I think the GUI drawback is related to JGoodies Looks and the fact that generated PDF files are not in correct order is because of how developers are generating the PDF files. I am sure that this will be fixed in the next version and thanks to the auto-update feature of the software we can simply update the software with new features and bug fixes.</p>
<p>This software shows how good we can combine open source projects to create an actual and working piece of software. I recommend you try it before starting a witch hunt for a good freelancing management software.</p>
<p>You can find more information and a trial version at <a href="http://www.fanuriotimetracking.com/">http://www.fanuriotimetracking.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/fanurio-a-management-solution-for-freelancers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Competition is good but to what extend and at what expense&#8230;</title>
		<link>http://kalali.me/competition-is-good-but-to-what-extend-and-at-what-expense/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=competition-is-good-but-to-what-extend-and-at-what-expense</link>
		<comments>http://kalali.me/competition-is-good-but-to-what-extend-and-at-what-expense/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 07:49:14 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Cometition]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=332</guid>
		<description><![CDATA[It is always said that competition between different producer and companies producing similar products is good for the end users and consumer of those products because the each company tried to provide better products to satisfy the consumer and finally receive more income. All of the above are true when we are discussing commercial entities [...]]]></description>
			<content:encoded><![CDATA[<p>It is always said that competition between different producer and companies producing similar products is good for the end users and consumer of those products because the each company tried to provide better products to satisfy the consumer and finally receive more income.</p>
<p>All of the above are true when we are discussing commercial entities which produce the products, for example ORACLE and IBM competition lead to better database and set of middle-ware. But I believe it is not the case for open source projects and specially for smaller open source projects.</p>
<p>Looking around we can find at least 10 different open source blogging clients, MP3 meta data editing tools, media players, instant messaging clients and so on. Except for the first project, other similar projects started after there was something usable around. Developers working on each of these projects work to implement same set of features without looking for potential income while if they combine the engineering and working hours with each-other they could develop a far better project without waiting the time for developing similar functionalities over and over.</p>
<p>There are tens of good projects abandoned because another similar project gained the momentum, developers left the project and start working on another open source one. The result is waist of a developer time and talent which can make big differences in already established projects. Imagine that all developers working on different instant messaging project combine the effort and work on one of available IM projects, wouldn&#8217;t that please everyone in the community?</p>
<p>I think it even make the developers happy because it will result in a better working software which any developer enjoys.</p>
<p>I know that there are architectural differences between projects and developers think that they will do the job better than the previous one, I was there once and I know how does it feel, but believe me, working together on a single project makes much more sense than working on 10 separate projects with similar goals and later on seeing 7 of them abandoned.</p>
<p>Again, I am not referring to well funded projects like Gnome, KDE, Eclipse, NetBeans, GlassFish, etc. But rather I am referring to projects which we start as a hubby or as a thesis or to learn some new technologies. A good portion of our efforts can benefits an already established project instead of being deserted after we satisfied our requirement which is learning something, passing a course and so on.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/competition-is-good-but-to-what-extend-and-at-what-expense/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using dynamically generated JFreeChart&#8217;s charts and  JasperReports</title>
		<link>http://kalali.me/using-dynamically-generated-jfreecharts-charts-and-jasperreports/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-dynamically-generated-jfreecharts-charts-and-jasperreports</link>
		<comments>http://kalali.me/using-dynamically-generated-jfreecharts-charts-and-jasperreports/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 15:17:41 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Dynamic]]></category>
		<category><![CDATA[Include]]></category>
		<category><![CDATA[JasperReport]]></category>
		<category><![CDATA[JFreeChart]]></category>
		<category><![CDATA[Reporting]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=330</guid>
		<description><![CDATA[If you are reading this blog it means you want to use JasperReport with dynamically programmatically generated images. An example of such use cases in generating complex charts using JFreeChart and then including these charts into reports. Each report in JasperReport uses a datasource to populate the fields, we need to use JRBeanCollectionDataSource which can [...]]]></description>
			<content:encoded><![CDATA[<p>If you are reading this blog it means you want to use JasperReport with dynamically programmatically generated images. An example of such use cases in generating complex charts using JFreeChart and then including these charts into reports.</p>
<p>Each report in JasperReport uses a datasource to populate the fields, we need to use JRBeanCollectionDataSource which can be considered as a simple collection of JavaBeans. Each object in the JRBeanCollectionDataSource can be used to populate one row of the report or it can be used to prepare calculated values and so on.</p>
<p>Each Report in JasperReport is basically an XML file which describe the report. in our case the report description document is like:</p>
<pre>

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;jasperReport xmlns=&quot;http://jasperreports.sourceforge.net/jasperreports&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd&quot; name=&quot;DataSourceReport&quot; pageWidth=&quot;595&quot; pageHeight=&quot;842&quot; columnWidth=&quot;515&quot; leftMargin=&quot;40&quot; rightMargin=&quot;40&quot; topMargin=&quot;50&quot; bottomMargin=&quot;50&quot;&gt;
	&lt;style name=&quot;Sans_Normal&quot; isDefault=&quot;true&quot; fontName=&quot;DejaVu Sans&quot; fontSize=&quot;12&quot; isBold=&quot;false&quot; isItalic=&quot;false&quot; isUnderline=&quot;false&quot; isStrikeThrough=&quot;false&quot;/&gt;
	&lt;style name=&quot;Sans_Bold&quot; isDefault=&quot;false&quot; fontName=&quot;DejaVu Sans&quot; fontSize=&quot;12&quot; isBold=&quot;true&quot; isItalic=&quot;false&quot; isUnderline=&quot;false&quot; isStrikeThrough=&quot;false&quot;/&gt;
	&lt;style name=&quot;Sans_Italic&quot; isDefault=&quot;false&quot; fontName=&quot;DejaVu Sans&quot; fontSize=&quot;12&quot; isBold=&quot;false&quot; isItalic=&quot;true&quot; isUnderline=&quot;false&quot; isStrikeThrough=&quot;false&quot;/&gt;
	&lt;field name=&quot;image&quot; class=&quot;java.awt.image.BufferedImage&quot;/&gt;
	&lt;field name=&quot;description&quot; class=&quot;java.lang.String&quot;/&gt;
	&lt;detail&gt;
		&lt;band height=&quot;180&quot;&gt;
			&lt;image scaleImage=&quot;RetainShape&quot; hAlign=&quot;Center&quot; isUsingCache=&quot;true&quot; isLazy=&quot;true&quot;&gt;
				&lt;reportElement x=&quot;67&quot; y=&quot;17&quot; width=&quot;344&quot; height=&quot;140&quot;/&gt;
				&lt;imageExpression class=&quot;java.awt.Image&quot;&gt;&lt;![CDATA[$F{image}]]&gt;&lt;/imageExpression&gt;
			&lt;/image&gt;
			&lt;textField&gt;
				&lt;reportElement x=&quot;83&quot; y=&quot;157&quot; width=&quot;311&quot; height=&quot;20&quot;/&gt;
				&lt;textElement/&gt;
				&lt;textFieldExpression class=&quot;java.lang.String&quot;&gt;&lt;![CDATA[$F{description}]]&gt;&lt;/textFieldExpression&gt;
			&lt;/textField&gt;
		&lt;/band&gt;
	&lt;/detail&gt;
&lt;/jasperReport&gt;
</pre>
<p>As you can see I defined two fields named <em>image</em> and <em>description</em> which are two property of the ReportBean objects included in the data source. The report looks as follow in the IreportDesigner (I am using NetBeans plugin for developing reports).</p>
<p><img src="http://www.java.net/sites/default/files/image1-kalali.jpg" alt="report in the designer" /></p>
<p>Lets see what is the JavaBean class we want to use to carry the report fields from our Java code to the JasperReport engine.</p>
<pre><code> public class ChartBean {      public ChartBean(BufferedImage image, String description) { setImage(image); setDescription(description);     }           private java.awt.image.BufferedImage image;     private String description;      public String getDescription() {         return description;     }      public void setDescription(String description) {         this.description = description;     }      public BufferedImage getImage() {         return image;     }      public void setImage(BufferedImage image) {         this.image = image;     }   } </code>
</pre>
<p>Now we need to prepare the datasource for the report, to prepare the datasource I wrote a method like the following snippet which uses another method to extract the BufferedImage from the JFreeChart items which we want to include in the report.</p>
<pre><code>     public JRBeanCollectionDataSource prepareDataSource() {           List charts = new ArrayList();

        for (int i = 0; i &lt; 5; i++) {
            JFreeChart chart = createChart(&quot;This is chart number: &quot; + i);
            BufferedImage bi = extractImage(chart, 800, 600);
            ChartBean chartBean = new ChartBean(bi, &quot;This is description for Chart: &quot; + i);
            charts.add(chartBean);
        }

        return new JRBeanCollectionDataSource(charts);
    }
</code>
</pre>
<p>The createChart method create some sample charts which we will include in the report. the method is simpley creating some dummy ring charts without any specific and meaningful data.</p>
<pre><code> private JFreeChart createChart(String chartTitle) {           DefaultPieDataset piedataset = new DefaultPieDataset();         piedataset.setValue(&quot;One&quot;, new Double(43.200000000000003D));         piedataset.setValue(&quot;Two&quot;, new Double(10D));         piedataset.setValue(&quot;Three&quot;, new Double(27.5D));         piedataset.setValue(&quot;Four&quot;, new Double(17.5D));         piedataset.setValue(&quot;Five&quot;, new Double(11D));         piedataset.setValue(&quot;Six&quot;, new Double(19.399999999999999D));           JFreeChart jfreechart = ChartFactory.createRingChart(chartTitle, piedataset, false, true, false);          RingPlot ringplot = (RingPlot) jfreechart.getPlot();         ringplot.setLabelFont(new Font(&quot;SansSerif&quot;, 0, 12));         ringplot.setNoDataMessage(&quot;No data available&quot;);         ringplot.setSectionDepth(0.34999999999999998D);         ringplot.setCircular(false);         ringplot.setLabelGap(0.02D);         return jfreechart;     } </code>
</pre>
<p>The other method which need to be explained is extractImage which simply create a BufferedImage from a given JfreeChart object.</p>
<pre><code>  public BufferedImage extractImage(JFreeChart chart, int width, int height) {         BufferedImage img =                 new BufferedImage(width, height,                 BufferedImage.TYPE_INT_RGB);          Graphics2D g2 = img.createGraphics();        chart.draw(g2, new Rectangle2D.Double(0, 0, width, height));          g2.dispose();         return img;      } </code>
</pre>
<p>Finally I have a method named showReport which uses the created datasource to prepare a report and then uses JRViewer to show the report. The code snippet is as follow:</p>
<pre><code>   public void showReport(JRBeanCollectionDataSource dataSource) {          try {             Map parameters = new HashMap();             JasperDesign jasperDesign = JRXmlLoader.load(this.getClass().getResourceAsStream(&quot;/jasperdynamic/report.jrxml&quot;));             JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);             JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource);             JRViewer viewer = new JRViewer(jasperPrint);             viewer.setSize(850, 500);             viewer.setMinimumSize(new Dimension(850, 510));             viewer.setPreferredSize(new Dimension(850, 510));              this.setLayout(new BorderLayout(10, 10));              this.setSize(850, 500);              this.getContentPane().add(viewer);             this.setVisible(true);          } catch (Exception ex) { ex.printStackTrace();         }     } </code>
</pre>
<p>And the complete code for the application application class is as follow:</p>
<pre><code> /*  * To change this template, choose Tools | Templates  * and open the template in the editor.  */ package jasperdynamic;  import javax.swing.JFrame; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import net.sf.jasperreports.engine.JasperCompileManager; import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperReport; import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; import net.sf.jasperreports.engine.design.JasperDesign; import net.sf.jasperreports.engine.xml.JRXmlLoader; import net.sf.jasperreports.view.JRViewer; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.RingPlot; import org.jfree.data.general.DefaultPieDataset;  /**  *  * @author masoud  */ public class Main extends JFrame {      /**      * @param args the command line arguments      */     public static void main(String[] args) {         Main m = new Main();          m.showReport(m.prepareDataSource());      }      public JRBeanCollectionDataSource prepareDataSource() {           List charts = new ArrayList();

        for (int i = 0; i &lt; 5; i++) {
            JFreeChart chart = createChart(&quot;This is chart number: &quot; + i);
            BufferedImage bi = extractImage(chart, 800, 600);
            ChartBean chartBean = new ChartBean(bi, &quot;This is description for Chart: &quot; + i);
            charts.add(chartBean);
        }

        return new JRBeanCollectionDataSource(charts);
    }

    public BufferedImage extractImage(JFreeChart chart, int width, int height) {
        BufferedImage img =
                new BufferedImage(width, height,
                BufferedImage.TYPE_INT_RGB);

        Graphics2D g2 = img.createGraphics();
       chart.draw(g2, new Rectangle2D.Double(0, 0, width, height));

        g2.dispose();
        return img;

    }

    public void showReport(JRBeanCollectionDataSource dataSource) {

        try {
            Map parameters = new HashMap();
            JasperDesign jasperDesign = JRXmlLoader.load(this.getClass().getResourceAsStream(&quot;/jasperdynamic/report.jrxml&quot;));
            JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
            JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource);
            JRViewer viewer = new JRViewer(jasperPrint);
            viewer.setSize(850, 500);
            viewer.setMinimumSize(new Dimension(850, 510));
            viewer.setPreferredSize(new Dimension(850, 510));

            this.setLayout(new BorderLayout(10, 10));

            this.setSize(850, 500);

            this.getContentPane().add(viewer);
            this.setVisible(true);

        } catch (Exception ex) {
ex.printStackTrace();
        }
    }

    private JFreeChart createChart(String chartTitle) {

        DefaultPieDataset piedataset = new DefaultPieDataset();
        piedataset.setValue(&quot;One&quot;, new Double(43.200000000000003D));
        piedataset.setValue(&quot;Two&quot;, new Double(10D));
        piedataset.setValue(&quot;Three&quot;, new Double(27.5D));
        piedataset.setValue(&quot;Four&quot;, new Double(17.5D));
        piedataset.setValue(&quot;Five&quot;, new Double(11D));
        piedataset.setValue(&quot;Six&quot;, new Double(19.399999999999999D));

        JFreeChart jfreechart = ChartFactory.createRingChart(chartTitle, piedataset, false, true, false);

        RingPlot ringplot = (RingPlot) jfreechart.getPlot();
        ringplot.setLabelFont(new Font(&quot;SansSerif&quot;, 0, 12));
        ringplot.setNoDataMessage(&quot;No data available&quot;);
        ringplot.setSectionDepth(0.34999999999999998D);
        ringplot.setCircular(false);
        ringplot.setLabelGap(0.02D);
        return jfreechart;
    }
}

</code>
</pre>
<p>Following image shows how the report will look like after we run the program. and the complete source code can be downloaded from <a href="http://www.java.net/sites/default/files/JasperDynamic.zip"><strong>Here</strong></a></p>
<p><img src="http://www.java.net/sites/default/files/image2-kalali.jpg" alt="report in the designer" />var </p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/using-dynamically-generated-jfreecharts-charts-and-jasperreports/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>So you want to develop a rich client application on top of NetBeans RCP?</title>
		<link>http://kalali.me/so-you-want-to-develop-a-rich-client-application-on-top-of-netbeans-rcp/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=so-you-want-to-develop-a-rich-client-application-on-top-of-netbeans-rcp</link>
		<comments>http://kalali.me/so-you-want-to-develop-a-rich-client-application-on-top-of-netbeans-rcp/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 07:57:55 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Modularity]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Module]]></category>
		<category><![CDATA[Plan]]></category>
		<category><![CDATA[RCP]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=328</guid>
		<description><![CDATA[I was involved with development of a RCP application based on NetBeans platform and now I find few minutes to share some of the experience with you. All standard coding and best practices are applicable here. Use project management systems like Trac or any project management system that you know. Never start a project without [...]]]></description>
			<content:encoded><![CDATA[<p>I was involved with development of a RCP application based on NetBeans platform and now I find few minutes to share some of the experience with you.</p>
<p>All standard coding and best practices are applicable here. Use project management systems like <a href="http://trac.edgewall.org/" target="_blank">Trac </a>or any project management system that you know. Never start a project without a project management system. Use coding standard, unit testing, desing and implementation documents versioning, design discussion sessions and so on.</p>
<p>Prepare all library wrappers and give them proper names. In NetBeans RCP we can not add JAR files to modules and instead JAR files need to be wrapped inside library wrapper modules and then this modules can be included in list of other modules dependencies. Use proper names for library wrappers, for example: jfreechart-wrapper-1.0.13. Never think about having one fat wrapper which contains all required libraries.</p>
<p>Avoid including the same JAR files in more than one wrapper which will be used by one module. instead include all common JAR files in one wrapper and include that wrapper in the dependencies of each wrapper which need it.</p>
<p>Think ahead and decide which modules you want to have and how these modules depends on each other. For example: A module which holds the domain mode and persistence layer (it will be wrapper inside a library wrapper if persistence layer is based on JPA), a module which contains all Web Services access objects (Again, this is a Java SE project wrapped inside a library wrapper), a module for reporting, a module for security implementation, a module to host all utility classes and common resources like icons, graphics, configuration files, etc.</p>
<p>Avoid circular dependencies. You can not access Security module from persistence and then using persistence objects from security module. Best practice is to define some logical layer and ensure that each layer can only access the layer under it and not any other layer.</p>
<p>If acceptable by customer, prepare an update center and push updates using the update center to avoid over working. The update center will help with distributing the software updates which can be new modules, updates, bug fixes etc.<br />Keep these FAQs close as they will help you along the way:<br /><a href="http://deadlock.netbeans.org/hudson/job/faqsuck/lastSuccessfulBuild/artifact/other/faqsuck/build/faq.html" target="_blank">http://wiki.netbeans.org/NetBeansDeveloperFAQ</a><br /><a href="http://deadlock.netbeans.org/hudson/job/faqsuck/lastSuccessfulBuild/artifact/other/faqsuck/build/faq.html" target="_blank">http://deadlock.netbeans.org/hudson/job/faqsuck/lastSuccessfulBuild/artifact/other/faqsuck/build/faq.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/so-you-want-to-develop-a-rich-client-application-on-top-of-netbeans-rcp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JPA and a First tier application performance problems</title>
		<link>http://kalali.me/jpa-and-a-first-tier-application-performance-problems/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jpa-and-a-first-tier-application-performance-problems</link>
		<comments>http://kalali.me/jpa-and-a-first-tier-application-performance-problems/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 15:54:12 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Persistence]]></category>
		<category><![CDATA[RDBMS]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[Object Graph]]></category>
		<category><![CDATA[Relationship]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=326</guid>
		<description><![CDATA[Well, this is the second time I am using the new blogging platform of Java.net. This time it was much easier and with less hurdle. I want to write about JPA, performance, caching and related things. Though it wont be very well organized but it may come useful for new JPA developers. recently I have [...]]]></description>
			<content:encoded><![CDATA[<p>Well, this is the second time I am using the new blogging platform of Java.net. This time it was much easier and with less hurdle.</p>
<p>I want to write about JPA, performance, caching and related things. Though it wont be very well organized but it may come useful for new JPA developers. recently I have assigned a task to work on performance problems of a first tier application and further extend it with some new forms and reports and address some usability glitch in the software. The application was developed by a company which no longer exists. The developer company was dissolved before they finishing the development cycles. </p>
<p>The performance issue was very important for the customer, so I start investigating the performance problem first. First things first, I run the application on client machine and hell it was slow, very slow indeed. it took some 15 seconds for the application to open a Jframe with two auto completing JCombobox on it. I though maybe it is the first time I am accessing the database and application is trying to initialize a soft client side cache. So, I closed the JFrame and open it again. the result was almost the same. I checked network and DNS resolving was fast and no substantial network delay was in place. I thought the problem is either in a poor development or something is wrong on database machine.</p>
<p>I asked an operator about the performance and I understand that is a data access problem. and I should focus on that area.</p>
<p>I opened a terminal to Database server machine and checked how much load it is taking when I open that particular JFrame, well there was no substantial load on the server. indeed there was no load on the server. I briefly check to see what kind of indexing we have on two tables where I though are used to load items of JComboBox/se and hell, No index was created. The developers either was crazy not to have any index except for the default PK index or they have forgotten to execute their post installation script. </p>
<p>I asked for the source code of the application to see what is going on in the application code. The application is based on TopLink Essential which is a part of GlassFish project, contributed by Oracle for data access. I had some previous experience with Toplink and I was sure that there is nothing wrong with the persistence provider itself.</p>
<p>Application source code was documented but not enough to understand the code easily. I locate that JFrame form and checked how they are loading the content of JCombobox/es. Well, they were calling an static method from a DAO class which returns a list an Object named A then it was iterating over the list and loading the JComboBox with A.property1 of. I though why on earth they are fetching the entire object to use on property?</p>
<p>I checked the second JC and I found the same steps, A DAO method were called which returns a list and then the JC was loaded using D.property1.<br />I start looking at these two entities to see what is going on with them and I find that each of them has a one to many relation with at least one other entities. So we basically had something like:</p>
<p>A &#8212;&#8211;1&#8212;&#8211;N&#8212;&#8211;&gt;B&#8212;&#8212;1&#8212;&#8212;&#8212;-N&#8212;&#8212;&gt;C<br />D &#8212;&#8211;1&#8212;&#8211;N&#8212;&#8211;&gt;E</p>
<p>There were no FetchType determined for the relationships so, Toplink assume FetchType.EAGER for the relationships by default. The FetchType.EAGER means that JPA eagerly loads all related records from database and create all corresponding objects before we even start using them. <br />What does that means? It Means that for the first JComboBox that client application creates num(A)+num(B)+num(C)+num(A)*num(B)*num(C) objects just to show a list of names in a JComboBox. Very funny hu? </p>
<p>I create a development database setup the development environment (NetBeans works well with ANT based projects) and start changing the code. I didn&#8217;t change the fetch types instead I changed the JPA queries to ensure that I am only loading one field and not all fields which have eager fetching relationships. I compiled and problem for this particular form were solved. I added two indexes to ensure that I am getting the result as fast as possible.</p>
<p>I was thinking about JPA caching and why JPA was not able to improve the overall performance after I closed the form and re-opened it. I think the data load was more than what JPA could cache by default.</p>
<p>I will blog more about these application and its problems. I believe it was either a prototype of the developers were intended to reiterate over the code to improve the performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/jpa-and-a-first-tier-application-performance-problems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My refcard for Oracle Berkeley DB Java edition published by DZone</title>
		<link>http://kalali.me/my-refcard-for-oracle-berkeley-db-java-edition-published-by-dzone/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=my-refcard-for-oracle-berkeley-db-java-edition-published-by-dzone</link>
		<comments>http://kalali.me/my-refcard-for-oracle-berkeley-db-java-edition-published-by-dzone/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 06:15:25 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Persistence]]></category>
		<category><![CDATA[RDBMS]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[Berkeley DB]]></category>
		<category><![CDATA[Development.]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=324</guid>
		<description><![CDATA[The refcard discuss the following items:  The BDB Family : An introduction to different DBD family members, including BDB Base Edition, BDB XML edition and BDB Java Edition with tables comparing their features. Key Features: Key features of BDB family members and BDB Java Edition exclusive features are explained here Introducing Berkeley DB Java Edition [...]]]></description>
			<content:encoded><![CDATA[</p>
<p><strong>The </strong><a href="http://refcardz.dzone.com/refcardz/getting-started-oracle?oid=hom12484"><strong>refcard</strong></a><strong> discuss the following items:</strong> </p>
<p style=" -qt-block-indent:1;">
<ol>
<li><a href="http://www.oracle.com/database/berkeley-db/index.html"><strong>The BDB Family</strong></a><strong> </strong>: An introduction to different DBD family members, including BDB Base Edition, BDB XML edition and BDB Java Edition with tables comparing their features.</li>
<li><strong>Key Features</strong>: Key features of BDB family members and BDB Java Edition exclusive features are explained here</li>
<li><strong> Introducing Berkeley DB Java Edition includin: </strong></li>
</ol>
<p style=" -qt-block-indent:1;">
<ul>
<li><strong>Installation: </strong>How to install the BDB JE and which JAR files are required to be in class path.</li>
<li><strong>Description of Access APIs:</strong> Three different types of access APIs are explained and a working sample for each type of access APIs is included. Discussed APIs are Base API (Key/Value pair store and retrieval), DPL (Direct Persistence Layer for object persistence), Collections API(Using the BDB JE as an on-disk collection</li>
</ul>
<p>         4. <strong>BDB Java Edition environment anatomy:</strong> How BDB JE store information on hard disk and what is directory and file layout of BDB JE is discussed here<br />5. <strong>BDB Java Edition APIs characteristics:</strong> What makes BDB JE different and how these differences can help developers in different scenarios.<br />6. <strong>Transaction Support:</strong> explanation and sample code for using Transaction with Base API and DPL<br />7.<strong> Persisting Complex Object Graph using DPL:</strong> How to define relation between objects using annotation and how to persist and retrieve related objects is explained here<br />8. <strong>BDB JE Backup/Recovery and Tuning:</strong> How to create backup, restore the backup and what tuning factor can be used to fine tune the BDB JE is explained here<br />9. <strong>Helper Utilities:</strong> Helper utilities for exporting and importing data are explained here<br />You can download the refcard free of charge from <a href="http://refcardz.dzone.com/refcardz/getting-started-oracle?oid=hom12484">here</a>.</p>
<p><a href="http://refcardz.dzone.com/refcardz/getting-started-oracle?oid=hom12484"><img src="http://refcardz.dzone.com/sites/all/files/refcardz/covers/12484.png" /></a> </p>
<p>You will find several tables and illustrations to make understanding the the whole concept of BDB JE and differences between BDB JE, BDB XML Edition and BDB Base Edition better. All included sample codes are fully explained.</p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/my-refcard-for-oracle-berkeley-db-java-edition-published-by-dzone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick NetBeans RCP Tip: How to reuse an already open TopComponent instead of creating a new one.</title>
		<link>http://kalali.me/quick-netbeans-rcp-tip-how-to-reuse-an-already-open-topcomponent-instead-of-creating-a-new-one/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quick-netbeans-rcp-tip-how-to-reuse-an-already-open-topcomponent-instead-of-creating-a-new-one</link>
		<comments>http://kalali.me/quick-netbeans-rcp-tip-how-to-reuse-an-already-open-topcomponent-instead-of-creating-a-new-one/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 03:51:45 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Modularity]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[NetBeans RCP]]></category>
		<category><![CDATA[Reuse]]></category>
		<category><![CDATA[TopComponent.]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=322</guid>
		<description><![CDATA[Well, NetBeans RCP is a flagship product of NetBeans Project which the famous NetBeans IDE is based on it. To reuse an already opened TopComponent in an RCP application we can use a code similar to following listing, Assume that the TopComponent name is ContractorInfoTopComponent and we want to reuse the already opened tab instead [...]]]></description>
			<content:encoded><![CDATA[<p> Well, <a href="http://platform.netbeans.org">NetBeans RCP</a> is a flagship product of <a href="http://netbeans.org">NetBeans Project</a> which the famous NetBeans IDE is based on it. To reuse an already opened TopComponent in an RCP application we can use a code similar to following listing, Assume that the TopComponent name is ContractorInfoTopComponent and we want to reuse the already opened tab instead of creating a new one. </p>
<pre><code>
Set tset = WindowManager.getDefault().getRegistry().getOpened();

            for (TopComponent t : tset) {
                  if (t instanceof ContractorInfoTopComponent) {
                    ContractorInfoTopComponent citc = (ContractorInfoTopComponent) t;
        	    citc.requestActive();
                }
            }
</code>
<a href="http://platform.netbeans.org">NetBeans RCP</a> is the answer to creating complex and large scale swing applications in a modular way. </pre>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/quick-netbeans-rcp-tip-how-to-reuse-an-already-open-topcomponent-instead-of-creating-a-new-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NetBeans 6.7 is here. Grab your copy and explore tens of new features</title>
		<link>http://kalali.me/netbeans-6-7-is-here-grab-your-copy-and-explore-tens-of-new-features/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=netbeans-6-7-is-here-grab-your-copy-and-explore-tens-of-new-features</link>
		<comments>http://kalali.me/netbeans-6-7-is-here-grab-your-copy-and-explore-tens-of-new-features/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 16:30:22 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[6.7]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=320</guid>
		<description><![CDATA[NetBeans 6.7 is available for download. NetBeans team decided to release more often to provide developers with new features sooner than later. This new release model ensure that as soon as a set of certain features are developed and stabilized can be accessed by developers to develop faster, easier and with more confidence over availability [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.netbeans.org">NetBeans 6.7</a> is available for download. NetBeans team decided to release more often to provide developers with new features sooner than later. This new release model ensure that as soon as a set of certain features are developed and stabilized can be accessed by developers to develop faster, easier and with more confidence over availability of support for latest standards and frameworks.</p>
<h3><a href="http://www.netbeans.org/community/releases/67/">NetBeans IDE 6.7 Overview</a></h3>
<p>NetBeans IDE 6.7 is integrated with Project Kenai, a collaborative environment for developers to host open-source projects. With Kenai and the NetBeans IDE, a team of developers is able to create projects, check out, edit, debug, build, discuss, and commit code, all through one easy-to-use interface!</p>
<p>The release also builds on the success of NetBeans 6.5 with native support for Maven; GlassFish, issue tracker and Hudson integrations; and enhancements to Java, PHP, Ruby, Groovy and C/C++. Highlights of the 6.7 release include support for JavaScript 1.7, Ruby Remote Debugging, and integration of the Java ME SDK 3.0.</p>
<p align="center">
<p>If you were following NetBeans releases you should know that NetBeans IDE is now available through several mirrors to ensure that users can get the IDE as fast as possible and no release rush will cause the servers to slow down. The first one is updated with NetBeans 6.7 release and the second one is still offering 6.5.1 as the latest release.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li><a href="ftp://ftp.c3sl.ufpr.br/netbeans/">ftp://ftp.c3sl.ufpr.br/netbeans/</a></li>
<li><a href="ftp://ftp.cs.pu.edu.tw/pub/NetBeans/">ftp://ftp.cs.pu.edu.tw/pub/NetBeans/</a></li>
</ul>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/netbeans-6-7-is-here-grab-your-copy-and-explore-tens-of-new-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Win your Copy of Wiley&#8217;s OpenSolaris Bible book</title>
		<link>http://kalali.me/win-your-copy-of-wileys-opensolaris-bible-book/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=win-your-copy-of-wileys-opensolaris-bible-book</link>
		<comments>http://kalali.me/win-your-copy-of-wileys-opensolaris-bible-book/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 08:08:03 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Book Review]]></category>
		<category><![CDATA[OpenSolaris]]></category>
		<category><![CDATA[Book]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[Win copy]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=318</guid>
		<description><![CDATA[OpenSolaris can be considered both a desktop Operating system and a very stable and capable server operating system specially for enterprise scale deployments where virtualization is required in different level along with SA and high availability which are inseparable parts of an enterprise. There are few books available for OpenSoalris including Pro OpenSolaris and OpenSolaris [...]]]></description>
			<content:encoded><![CDATA[</p>
<table border="0" cellspacing="2" cellpadding="0">
<tr>
<td>
<p align="left"></p>
<p align="left"><a href="http://OpenSolaris.org">OpenSolaris</a> can be considered both a desktop Operating system and a very stable and capable server operating system specially for enterprise scale deployments where virtualization is required in different level along with SA and high availability which are inseparable parts of an enterprise.</p>
<p align="left">There are few books available for OpenSoalris including <a href="http://www.apress.com/book/view/1430218916">Pro OpenSolaris</a> and <a href="http://eu.wiley.com/WileyCDA/WileyTitle/productCd-0470385480.html">OpenSolaris Bible</a> which one can choose between them. I was reading OpenSolaris bible and post a review in DZone which may helps other to get a better understanding of the book content and quality </p>
</td>
<td>
<p align="left"><a href="http://books.dzone.com/reviews/win-your-copy-opensolaris"><img src="http://media.wiley.com/product_data/coverImage/80/04703854/0470385480.jpg" /></a></p>
</td>
</tr>
</table>
<p>The <a href="http://eu.wiley.com/WileyCDA/WileyTitle/productCd-0470385480.html">OpenSolaris Bible</a> book review is located at <a href="http://www.dzone.com/links/win_your_copy_opensolaris_bible.html"> DZone IT books Zone</a>. This is the first part of the review and you can get familiar with the book and what it is going to cover in first 11 chapters.Some free chapters are included in the review which you can download them to get familiar with the following topics:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li><strong>Chapter 1:</strong> What Is OpenSolaris?</li>
<li><strong>Chapter 3:</strong> OpenSolaris Crash Course.</li>
<li><strong>Chapter 8:</strong> ZFS.</li>
</ul>
<p>If you have a question about the book, just post them at <a href="http://books.dzone.com/reviews/win-your-copy-opensolaris">book review page</a> and in addition to getting your answer try your chance to win a free copy.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/win-your-copy-of-wileys-opensolaris-bible-book/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JMS Over HTTP using OpenMQ (Sun Java System Message Queue and HTTP tunneling)</title>
		<link>http://kalali.me/jms-over-http-using-openmq-sun-java-system-message-queue-and-http-tunneling/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jms-over-http-using-openmq-sun-java-system-message-queue-and-http-tunneling</link>
		<comments>http://kalali.me/jms-over-http-using-openmq-sun-java-system-message-queue-and-http-tunneling/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 16:01:31 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[JMS]]></category>
		<category><![CDATA[OpenMQ]]></category>
		<category><![CDATA[tunneling]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=316</guid>
		<description><![CDATA[You may have already faced situation when you need to have messaging capabilities in your application while your client application runs in an environment which you have no control over its network configuration and restrictions. Such situation lead to the fact that you can not use JMS communication over designated ports like 7676 and so. [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>You may have already faced situation when you need to have messaging capabilities in your application while your client application runs in an environment which you have no control over its network configuration and restrictions. Such situation lead to the fact that you can not use JMS communication over designated ports like 7676 and so.</p>
<p>You may simply put JMS away and follow another protocol or even plain HTTP communication to address your architecture and design requirement, but we can not easily put pure JMS API capabilities away as we may need durable subscription over a proven and already well tested and established design and architecture. Different JMS implementation providers provide different type capabilities to address such a requirement. ActiveMQ provide HTTP and HTTPS transport for JMS API and described it <a href="http://activemq.apache.org/http-and-https-transports-reference.html" target="_blank">here</a>.</p>
<p><a href="http://mq.dev.java.net/" target="_blank">OpenMQ</a> provide different transport protocol and access channels to access OpenMQ functionalities from different prgramming . One of the access channles which involve HTTP is named <a href="https://mq.dev.java.net/4.3-content/ums/umsIntro.html" target="_blank">Universal Message Service (UMS)</a> which provide a simple REST interaction template to place messages and comsume them from any programming language and device which can interact with a network server. UMS has some limitations which is simply understandable based on the RESTful nature of UMS. For current version of OpenMQ, it only supports Message Queues as destinations so there is no publish-subscribe functionality available.</p>
<p>Another capability which involve HTTP is JMS over HTTP or simply JMS HTTP tunneling. OpenMQ JMS implementation supports HTTP/s as transport protocol if we configure the message broker properly. Well I said the JMS implementation support HTTP/S as a transport protocol which means we as user of the JMS API see almost no difference in the way that we use the JMS API. We can use publish-subscribe, point to point, durable subscription, transaction and whatever provided in the JMS API.</p>
<p>First, lets overview the OpenMQ installation and configuration then we will take a look at an example to see what changes between using JMS API and JMS API over HTTP transport. Installation process is as follow:</p>
<p style=" -qt-block-indent:1;">
<p style=" -qt-block-indent:1;">OpenMQ project provides a Java EE web application which interact with OpenMQ broker from one side and Sun JMS implementation on the other side. Interaction of this application with the client and MQ broker is highly customizable in different aspects like Broker port number, client poll inrval, Broker address and so on.</p>
<ul>
<li>Download OpenMQ from <a href="https://mq.dev.java.net/" target="_blank">https://mq.dev.java.net/</a> it should be a zip which is different for each platform.</li>
<li>Install the MQ by unzipping the above file and running <em>./installer</em> or <em>installer.bat</em> or so.</li>
<li>After the installation completed, go to <em>install_folder/var/mq/instances/imqbroker/props</em> and open the <em>config.properties</em> in a text editor like notepad or emeditor or gedit.</li>
<li>Add the following line to the end of the above file:</li>
<pre style=" -qt-block-indent:1;"><code> imq.service.activelist=jms,admin,httpjms </code></pre>
<li>Now goto <em>install_folder/mq/lib/</em> and pick the <em>imqhttp.war</em> file. deploy the file into your Servlet container or application server (I went with GlassFish). After you deployed the file start the application server or Servlet container</li>
<li>Now it is time to start the MQ broker: launch a terminal or cmd console and goto install_folder/mq/bin now execute ./imqbrokerd -port 7979 (it maybe like imqbrokerd.bat -port 7979 for Windows ) This command will start the MQ broker and keep it listening on port 7979 for incoming connection</li>
<li>To test the overall operations: Open a browser and tray to surf <em>http://127.0.0.1:8080/imqhttp/tunnel</em> or whatever URL which points to the newly deployed application . If you saw &quot;HTTP tunneling Servlet ready.&quot; as the first line in the response page then we are ready for last step.</li>
</ul>
<p>Now let&#8217;s see how we can publish some messages, this sample code assume that we have configured the message broker and assumes that we have the following two JAR files in the classpath. These JAR files are available in <em>install_folder/mq/lib/</em> </p>
<ol>
<li>imq.jar</li>
<li>jms.jar</li>
</ol>
<p>Now the Publisher code:</p>
<pre><code> public class Publisher {      public void publish(String messageContent) {         try {             String addressList = &quot;http://127.0.0.1:8080/imqhttp/tunnel&quot;;             com.sun.messaging.TopicConnectionFactory topicConnectionFactory = new com.sun.messaging.TopicConnectionFactory();             topicConnectionFactory.setProperty(com.sun.messaging.ConnectionConfiguration.imqAddressList, addressList);             javax.jms.Topic top;             javax.jms.Connection con = topicConnectionFactory.createTopicConnection(&quot;admin&quot;, &quot;admin&quot;);              javax.jms.Session session = con.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);             top = session.createTopic(&quot;DIRECT_TOPIC&quot;);             MessageProducer prod = session.createProducer(top);             Message textMessage = session.createTextMessage(messageContent);             prod.send(textMessage);          prod.close();         session.close();         con.close();                  } catch (JMSException ex) {             ex.printStackTrace();         }      }      public static void main(String args[]) {          Publisher p = new Publisher();         for (int i = 1; i &lt; 10; i++) {             p.publish(&quot;Sample Text Message Content: &quot; + i);         }     } } </code>
</pre>
<p>As you can see the only difference is the connection URL which uses <em>http</em> instead of <em>mq</em> and point to a Servlet container address instead of pointing to the Broker listening address.</p>
<p>The subscriber sample code follow a similar pattern. Here I write a sample durable subscriber so you can see that we can use durable subscribtion over HTTP. But you should note that HTTP transport uses polling and continuesly open communication channel which can introduce some overload on the server.</p>
<pre><code> class SimpleListener implements MessageListener {      public void onMessage(Message msg) {         System.out.println(&quot;On Message Called&quot;);         if (msg instanceof TextMessage) {             try {                 System.out.print(((TextMessage) msg).getText());             } catch (JMSException ex) {                 ex.printStackTrace();             }          }     } }  public class Subscriber {      /**      * @param args the command line arguments      */     public void subscribe(String clientID, String susbscritpionID) {         try {             // TODO code application logic here              String addressList = &quot;http://127.0.0.1:8080/imqhttp/tunnel&quot;;             com.sun.messaging.TopicConnectionFactory topicConnectionFactory = new com.sun.messaging.TopicConnectionFactory();             topicConnectionFactory.setProperty(com.sun.messaging.ConnectionConfiguration.imqAddressList, addressList);             javax.jms.Topic top;             javax.jms.Connection con = topicConnectionFactory.createTopicConnection(&quot;admin&quot;, &quot;admin&quot;);             con.setClientID(clientID);             javax.jms.Session session = con.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);             top = session.createTopic(&quot;DIRECT_TOPIC&quot;);             TopicSubscriber topicSubscriber = session.createDurableSubscriber(top, susbscritpionID);             topicSubscriber.setMessageListener(new SimpleListener());              con.start();           } catch (JMSException ex) {             ex.printStackTrace();         }     }      public static void main(String args[]) {          Subscriber sub = new Subscriber();         sub.subscribe(&quot;C19&quot;, &quot;C1_011&quot;);     } } </code>
</pre>
<p>Now how you can test the entire example and monitor the MQ? it is very simple by utilizing the provided tools.</p>
<p>Do the following steps to test the overall durable subscription system:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Run a subscriber</li>
<li>Run another subscriber with a different client ID</li>
<li>Run a publisher once or twice</li>
<li>Kill the second subscriber</li>
<li>Run a publisher once</li>
<li>Run the subscriber and you can see that the subscriber will fetch all messages which arrived after it shut down-ed.</li>
</ul>
<p>Note that we can not have two separate client with same client ID running because the broker will not be able to distinguish which client it should send the messages.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>You can monitor the queue and the broker using:<em> ./imqadmin</em> which can be found in <em>install_folder/mq/bin</em> this software shows how many durable subscribers are around and how many messages are pending for each subscriber and so on.</li>
<li>You can monitor the Queue in real-time mode using the following command which can be executed in <em>install_folder/mq/bin </em></li>
</ul>
<p><em>./imqcmd -b 127.0.0.1:7979 metrics dst -t t -n DIRECT_TOPIC </em> The command will ask for username and password, give admin/admin for it</p>
<p>The sample code for this entry can be found <a href="http://weblogs.java.net/blog/kalali/archive/files/jms.http.zip">Here</a>. The sample code is a NetBeans project with the publisher and the subscriber source code.</p>
<p>A complete documentation of OpenMQ is available at its <a href="http://docs.sun.com/app/docs/doc/820-5897/fxjbo?a=view" target="_blank">documentation centre</a>. You can see how you can change different port numbers or configure different properties of the Broker and HTTP tunneling web application communication.</p>
<p> </p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/jms-over-http-using-openmq-sun-java-system-message-queue-and-http-tunneling/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Monitoring GlassFish application server&#8217;s HTTP Service  using VisualVM.</title>
		<link>http://kalali.me/monitoring-glassfish-application-servers-http-service-using-visualvm/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=monitoring-glassfish-application-servers-http-service-using-visualvm</link>
		<comments>http://kalali.me/monitoring-glassfish-application-servers-http-service-using-visualvm/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 20:10:54 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[HTTO Service]]></category>
		<category><![CDATA[monitor]]></category>
		<category><![CDATA[Threads]]></category>
		<category><![CDATA[VisualVM]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=314</guid>
		<description><![CDATA[Monitoring GlassFish HTTP service using VisualVM. GlassFish application server has some motniroting features which are exposed through its administration chanlles including Administration Console and asadmin utility. I disucssed some of these features here and in this we will see how we can use visualvm and its plugin as a desktop application to monitor GlassFish HTTP [...]]]></description>
			<content:encoded><![CDATA[<p>Monitoring GlassFish HTTP service using VisualVM.</p>
<p><a href="http://glassfish.dev.java.net">GlassFish</a> application server has some motniroting features which are exposed through its administration chanlles including Administration Console and asadmin utility. I disucssed some of these features <a href="http://weblogs.java.net/blog/kalali/archive/2007/05/glassfish_versi_1.html">here</a> and in this we will see how we can use <a href="http://visualvm.dev.java.net">visualvm</a> and its plugin as a desktop application to monitor GlassFish HTTP service.</p>
<p>VisualVM is JDK tool based on NetBeans platform, NetBeans profiler, and a handful of plug-ins which let us profile any Java application running in JDK 6 or 7. VisualVM does not works with older JDK or any JRE either 6 or 7. Starting from JDK 6 update 7 visualVM is included in the Sun JDK distribution.</p>
<p>Downloading and installing latest version of visualVM is straight forward, just point to <a href="https://visualvm.dev.java.net/download.html">Download Page</a> grab the zip file, extract the zip file content and you are ready to go. Follow the installation instruction (4 very easy steps) <a href="https://visualvm.dev.java.net/download.html#first_steps"> here</a></p>
<p>Now, to monitor GlassFish HTTP service we need to install a visualVM plugin that can interact with GlassFish application server through its JMX/ AMX API to gather the statistics and let us view them live in our desktop application. Run visualVM using the provided script in the bin directory, Open Tools&gt;Plugins menu item and from the available plug-ins section select VisualVM-GlassFish and press install button to install the plug-in. Restart VisualVM and now we are ready to connect to a GlassFish instance.</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/files/A_figure01.jpeg" alt="A_figure01.jpeg" width="843" height="531" /></p>
<p>Now we have two options, we can either monitor a local Glassfish instance or we can select to monitor a remote Glassfish instance. All local JVM are listed under the local node and in order to create a remote connection we need to register the host under the Remote node by right clicking on the node and adding the remote host, in my case I add 192.168.1.100. Now on the remote host we may have several JXM enabled applications running, each application on its own port. Default JMX port for GlassFish application server is 8686, therefore to add a GlassFish application server running on 192.168.1.100 we can right click on its node under the Remote node and select add JMX connection, a window will open which asks you to provide the connection information including port number and credentials. default administration credentials for GlassFish are admin/ adminadmin as username/ password. <img src="http://weblogs.java.net/blog/kalali/archive/files/A_figure02.jpeg" alt="A_figure02.jpeg" width="457" height="268" /></p>
<p>Now that The remote GlassFish is registered the right side panel should be similar to the fillowing figure</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/files/A_figure03.jpeg" alt="A_figure03.jpeg" width="260" height="561" /></p>
<p>In my case I have a remote and a local GlassFish instances, When you double click on an instance a window will open that shows all monitoring information which VisialVM can gather about the running application in different panels, something similar to the following figure</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/files/A_figure04.jpeg" alt="A_figure04.jpeg" width="777" height="600" /></p>
<p>This page shows general information about the JVM which we are going to monitor and some of the plug-in specific configuration which we may need to change. Make sure that you turn the HTTP Service monitoring level and WebContainer Monitoring Level to High or LOW which will result in GlassFish gathering monitoring statistics about the HTTP Service.</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/files/A_figure05.jpeg" alt="A_figure05.jpeg" width="800" height="618" /></p>
<p>Now let your application server get some hit from the clients and then switch to HTTP Service Tab in order to get a general overview of your Server HTTP Service performance. Failed, Incoming, Average connections, Keep Alive, and File Cache performance can be monitored here. Following Figure shows HTTP Service Tab</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/files/A_figure06.jpeg" alt="A_figure06.jpeg" width="800" height="618" /></p>
<p>Now the funny part begins, Assuming that we have a dozen of application hosted in the same GlassFish instance we expect to be able to monitor each application separately to see how HTTP service is performing for that particular application. It is easy and do-able in no more than 3 steps. Under the GlassFish node you can see Model and under the Model you can see different web applications that you have hosted in your server, double clicking on any of those applications result in viewing the HTTP Service statistics for that particular application. For example If I double click on the admingui I will get a result page similar to the next figure.</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/files/A_figure07.jpeg" alt="A_figure07.jpeg" width="777" height="600" /></p>
<p>The fun part continues further I tell you that you can monitor different servlets used in your application separately. for example I can expand the admingui node and double click on ThemeServlet to get an statistical view similar to the next figure.</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/files/A_figure08.jpeg" alt="A_figure08.jpeg" width="777" height="600" /></p>
<p>All statistical information which are shown includes two major factors, processing time and error/ request count. in addition to average processing time, maximum processing time, and so on.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/monitoring-glassfish-application-servers-http-service-using-visualvm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WSJ says: &#8220;IBM in Talks to Buy Sun&#8221;. But Why would IBM buy Sun Microsystems?</title>
		<link>http://kalali.me/wsj-says-ibm-in-talks-to-buy-sun-but-why-would-ibm-buy-sun-microsystems/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wsj-says-ibm-in-talks-to-buy-sun-but-why-would-ibm-buy-sun-microsystems</link>
		<comments>http://kalali.me/wsj-says-ibm-in-talks-to-buy-sun-but-why-would-ibm-buy-sun-microsystems/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 10:21:47 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Comparison]]></category>
		<category><![CDATA[IBM]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Sun]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[Products]]></category>
		<category><![CDATA[WSJ]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=312</guid>
		<description><![CDATA[The Wall Street Journal Published an article which discuss possibility of IBM buying Sun Microsystems, but why on earth should IBM take over Sun Microsystems when every product which Sun offer has a counterpart in IBM arsenal. In software range Sun offers Operating System, Database, Application server family of products, identity management family of product, [...]]]></description>
			<content:encoded><![CDATA[<p>The Wall Street Journal <a href="http://online.wsj.com/article/SB123735124997967063.html?mod=">Published</a> an article which discuss possibility of IBM buying Sun Microsystems, but why on earth should IBM take over Sun Microsystems when every product which Sun offer has a counterpart in IBM arsenal.</p>
<p>In software range Sun offers Operating System, Database, Application server family of products, identity management family of product, Integration series of products either developed by Sun or acquired from other companies, Software development tools including NetBeans and its related add-ons. All of these products has a counterpart in IBM series of products.</p>
<p>In hardware range Sun offers Storages, X86 and Sparc servers, and networking solutions. All of these products have their counterpart in IBM arsenal and having them add no exceptional value to IBM set of available products which make IBM take over Sun Microsystems.</p>
<p>But Why would IBM think about buying Sun Microsystems and what Sun own that IBM does not?</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>First Sun owns Java and all rights over its patents and source codes</li>
<li>Sun owns some products which I am not aware of any counterpart in IBM offering, these products includes: VirtualBox and X86 virtualization, and Sun xVM Ops for data centre management</li>
<li>It is told that IBM has the largest patents arsenal but Sun owns enough patents which IBM might be interested to own them</li>
<li>Although IBM has AIX and there are some undergo efforts to port Solaris to Z architecture but maybe IBM has some more plans with Solaris</li>
</ul>
<p>A list of Sun software with their counterpart in IBM arsenal:</p>
</p>
<table border="1" cellspacing="2" cellpadding="0">
<tr>
<td bgcolor="#c0c0c0">
<p align="left"><span style=" background-color:#c0c0c0;">Sun Product </span></p>
</td>
<td bgcolor="#c0c0c0">
<p align="left"><span style=" background-color:#c0c0c0;">IBM counterpart</span></p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"><a href="http://openjdk.java.net/">Sun JDK*</a></p>
</td>
<td>
<p align="left">IBM <a href="http://www.ibm.com/developerworks/java/jdk/">JDK</a>, although I think IBM licensed Some part of Sun JDK to avoid developing them again (class path?)</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"><a href="http://www.netbeans.org/">NetBeans</a> and <a href="http://developers.sun.com/sunstudio"> Sun Studio</a> series of products (For Java, C++ and so on)*</p>
</td>
<td>
<p align="left"><a href="http://www.eclipse.org/">Eclipse</a> and <a href="http://www.ibm.com/software/rational/">Rational line of products</a>(For Java, C++ and so on)</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">Sun middle-ware product line including but not limited to: <a href="http://GlassFish.dev.java.net/">GlassFish</a>, <a href="https://portlet-container.dev.java.net/">Portal</a>, Sun Identity management, <a href="https://www.sun.com/software/javaenterprisesystem/javacaps/index.jsp/">JCAPS</a> and <a href="https://open-esb.dev.java.net/">OpenESB</a>, and so on.*</p>
</td>
<td>
<p align="left"><a href="http://www.ibm.com/websphere/">IBM Websphere</a> product line including but not limited to: Application server, Portal, Tivoli Identity management, ESB, and so on.</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"><a href="http://www.sun.com/software/solaris/"> Sun Solaris*</a></p>
</td>
<td>
<p align="left"><a href="http://www.ibm.com/servers/aix"> IBM AIX</a>, <a href="http://www.ibm.com/systems/z/os/zos/">Z/OS</a>, Z/VM and whatever Z starting word that you can write here</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"><a href="http://www.sun.com/software/products/mysql/index.jsp"> MySQL</a> as a product which Sun owns, Java DB and PostGreSQL support*</p>
</td>
<td>
<p align="left"><a href="http://www.ibm.com/db2"> DB2</a>, DB2 express edition, DB2 community edition, Informix dynamic server(is it still alive?)</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"><a href="http://www.javafx.com">JavaFX</a></p>
</td>
<td>
<p align="left">Nothing that I am aware of</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"><a href="http://www.virtualbox.org/">X86 virtualization*</a></p>
</td>
<td>
<p align="left">Nothing that I am aware of</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"><a href="www.sun.com/software/products/xvmopscenter/index.jsp">Data Centre management(Sun xVM Ops center)</a></p>
</td>
<td>
<p align="left">Nothing that I am aware of</p>
</td>
</tr>
</table>
<p>*All of these products except JCAPS and Sun xVM Ops are open source. And all of them are high quality with a well established community of user and third party companies which are involved in their development.</p>
<p>Now, Why could be possible reason that we hear &quot;IBM in Talks to Buy Sun&quot;? The reason can be:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Patents and rights that Sun is holding over Java, Sparc and Solaris</li>
<li>The Open Source model which Sun introduced and looks to be successful</li>
<li>Open Source products that Sun is developing and have gained enough attraction from the community which result in &quot;IBM in Talks to Buy Sun&quot; once more.</li>
<li>Brilliant architects, engineers, and evangelists which are working for Sun Microsytems</li>
<li>Some software and functionalities which IBM does not own</li>
<li>Customers and community to gain more market share, specially in middle range market</li>
<li>Maybe IBM is interested in un-released Sun Cloud Computing&#8230; Sun is known to either does not enter an area or if entered provides a very good product or service in that area, technically speaking.</li>
</ul>
<p>What can happen if IBM take over Sun Microsytems? The answer is: no one knows expect those IBM super managers which are possibly thinking about this take over. But some predictions:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Java will evolve much faster as IBM has more man power to assign to it</li>
<li>OpenSolaris will get more attention and possibly replace AIX in long term</li>
<li>MySQL and Sun middle-ware products will form a big bundle of highly integrated, high quality Open Source products and bring more revenue to IBM</li>
<li>IBM will lay off some Sun employees, specially in sales and marketing section because they have many sales and marketing employees</li>
<li>NetBeans and Eclipse? I can not comment with more than 20 percent of certainty, but I think either IBM kill all middle-ware or work on NetBeans development for as long as they provide all NetBeans functionalities that support Sun middle-ware development in Eclipse</li>
<li>JavaFX will see a boost in development as IBM can afford more man power</li>
<li>Swing and SWT story? I think IBM will keep Swing as a part of JRE but hey will push SWT as a part of the JRE to ensure it will get enough chance of growing in the market</li>
<li>Responsibilities for providing support for Java, JCP, TCK and&#8230; will be given to a foundation organized by IBM, Oracle, RedHat, &#8230;</li>
</ul>
<p>I may have missed some items due to short term forgetfulness or being completely unaware of their presence. If you happen to know them, let me know and I will include it in this blog.</p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/wsj-says-ibm-in-talks-to-buy-sun-but-why-would-ibm-buy-sun-microsystems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Experimenting replication and failover recovery (High Availability) with OpenDS 1.3 Build 1</title>
		<link>http://kalali.me/experimenting-replication-and-failover-recovery-high-availability-with-opends-1-3-build-1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=experimenting-replication-and-failover-recovery-high-availability-with-opends-1-3-build-1</link>
		<comments>http://kalali.me/experimenting-replication-and-failover-recovery-high-availability-with-opends-1-3-build-1/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 09:48:20 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[High Availability]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Clustering]]></category>
		<category><![CDATA[Failover]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[OpenDS]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=310</guid>
		<description><![CDATA[If you do not know what OpenDS is, then you can simply learn about it by looking at its website located at http://www.opends.org But a brief description is: OpenDS is a high performance, feature rich and pure Java based, directory server which is under active development by Sun Microsystems. Today I grabbed OpenDS 1.3 build [...]]]></description>
			<content:encoded><![CDATA[<p>If you do not know what OpenDS is, then you can simply learn about it by looking at its website located at <a href="http://www.opends.org"> http://www.opends.org </a> But a brief description is: OpenDS is a high performance, feature rich and pure Java based, directory server which is under active development by Sun Microsystems.</p>
<p>Today I grabbed OpenDS 1.3 build 1 to see what is new and check its replication and fail-over recovery. You can grab a copy at <a href="https://www.opends.org/promoted-builds/latest/">https://www.opends.org/promoted-builds/latest/</a>. First thing that I noticed is the new control panel which replaces the old likely status panel. You can see an screen-shot of the control panel right here.</p>
<p> </p>
<p>Although the control panel has good set of features and functionalities and it is very good to have a built-in LDAP browser and management utility coming with the OpenDS but this control panel is not user friendly enough. I think we will see some changes for this control panel in new future. for example some better menu design, tab based content pane instead of opening new window,&#8230; To run the control-panel application you can run control-panel script either from bat or bin directory</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/files/figure01.jpeg" alt="figure01.jpeg" width="842" height="679" /></p>
<p>Down to business, I though I can test the replication and fail over recovery of OpenDS replication by some simple Java code and the new control panel application. To install OpenDS in an specific directory, extract the zip file in that directory and run setup script. I installed first instance of OpenDS server in /home/masoud/opends1.3/OpenDS-1.3.0-inst01. The installation process is quite simple, you just need to execute the setup script, it opens a GUI setup application which guide you through the installation. Following screenshots shows the installation process for first instance.</p>
<p><strong>Welcome page:</strong> <br /><img src="http://weblogs.java.net/blog/kalali/archive/files/figure02.jpeg" alt="figure02.jpeg" /><br /><strong>Server Setting page: I used </strong><strong><em>admin</em></strong><strong> as password</strong> <br /><img src="http://weblogs.java.net/blog/kalali/archive/files/figure03.jpeg" alt="figure03.jpeg" /><br /><strong>Topology Options</strong> <br /><img src="http://weblogs.java.net/blog/kalali/archive/files/figure04.jpeg" alt="figure04.jpeg" /><br /><strong>Directory Data</strong> <br /><img src="http://weblogs.java.net/blog/kalali/archive/files/figure05.jpeg" alt="figure05.jpeg" /><br /><strong>Installation review page</strong> <br /><img src="http://weblogs.java.net/blog/kalali/archive/files/figure06.jpeg" alt="figure06.jpeg" /><br /><strong>Installation finished</strong> <br /><img src="http://weblogs.java.net/blog/kalali/archive/files/figure07.jpeg" alt="figure07.jpeg" /></p>
<p>Installation application will open the control-panel application, the control panel needs administration credentials to connect to the directory server. administration credentials are <em>cn=Directory Manager</em> as the bind DN and <em>admin</em> as password. (If you used anything else then you should use your own credentials)</p>
<p>Now we should install the second directory server instance, this instance will form a replication group with instance 02, I extracted the zip file into /home/masoud/opends1.3/OpenDS-1.3.0-inst02 and then execute the setup script to commence with the installation. Following screen shots shows the installation process:</p>
<p><strong>Welcome page:</strong> <br /><img src="http://weblogs.java.net/blog/kalali/archive/files/figure08.jpeg" alt="figure08.jpeg" /><br />Server Setting page: I used <em>admin</em> as password, as you can see port numbers are different because default ports are in use and setup application try to use new port numbers instead. <br /><img src="http://weblogs.java.net/blog/kalali/archive/files/figure09.jpeg" alt="figure09.jpeg" /></p>
<p>Topology Options: Here we are adding this server instance to a replication topology which already has one member. We connect this instance to another instance in the topology by providing the setup application with host name, administration port and administration credentials of that server. In my case both instances are installed on the same machine.</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/files/figure10.jpeg" alt="figure10.jpeg" /></p>
<p>Global Administration: A administration credentials which can be used to manage the whole replication topology. I used admin/admin for username/password</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/files/figure11.jpeg" alt="figure11.jpeg" /></p>
<p>Data Replication: As we want to have a replica of our remote server we should select &quot;Create local instance of existing base DNs and&#8230;.&quot;, And we should select the Base DNs which we want to replication</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/files/figure12.jpeg" alt="figure12.jpeg" /></p>
<p> </p>
<p>Review: review the installation and if you found anything wrong you can go back and fix it</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/files/figure13.jpeg" alt="figure13.jpeg" /></p>
<p>As both installation tasks are finished we have our replication topology installed, and configured.</p>
<p>So far, we should have two control-panel open. Each one of them can manage one of our installation and if it comes to data management, if we change data in one control-panel we can see the change in other control panel.</p>
<p>To test the replication configuration, in one of the control-panel applications, under the Directory Data tab, select manage entries and then delete some entries, now go to the other control-panel and you will those entries are gone. To make the test more understandable about fail-over recover, stop one server, delete some entries in other server, start the server which you have stopped and you should see that all deleted record are deleted in the new server as soon as it has been started.</p>
<p><strong>Directory Data tab:</strong> <br /><img src="http://weblogs.java.net/blog/kalali/archive/files/figure14.jpeg" alt="figure14.jpeg" /><br /><strong>Deleting some entries:</strong> <br /><img src="http://weblogs.java.net/blog/kalali/archive/files/figure15.jpeg" alt="figure15.jpeg" /></p>
<p>We have a replication topology configured and working, what we can do with this topology from a Java application? The answer is simple: as we can not afford to see our client applications stopped working because a directory server machine is down or a router which route the clients to one of the server is not working and so on&#8230; we need to have our Java application uses any available server instead of depending on one server and then stop working when the server is down.</p>
<p>following sample code shows how we can use these two instances to prevent our client application stop working when one instance is down.</p>
<pre>

import java.util.Date;
import java.util.Hashtable;

import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.InitialDirContext;

public class Main {

    public static void main(String[] args) throws NamingException {

        final Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY, &quot;com.sun.jndi.ldap.LdapCtxFactory&quot;);
        env.put(Context.PROVIDER_URL, &quot;ldap://192.168.1.100:2389 ldap://192.168.1.100:1389&quot;);
        env.put(Context.SECURITY_PRINCIPAL, &quot;cn=Directory Manager&quot;);
        env.put(Context.SECURITY_CREDENTIALS, &quot;admin&quot;);
        env.put(Context.SECURITY_AUTHENTICATION, &quot;simple&quot;);
        Timer t = new Timer();
        TimerTask ts = new TimerTask() {

            @Override
            public void run() {
                try {
                    InitialDirContext ctx = new InitialDirContext(env);
                    Attributes attrs = ctx.getAttributes(&quot;&quot;);
                    final NamingEnumeration enm = attrs.getAll();
                    System.out.println(enm.next());
                    ctx.close();
                } catch (NamingException ex) {
                    ex.printStackTrace();
                }
            }
        };
</pre>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/experimenting-replication-and-failover-recovery-high-availability-with-opends-1-3-build-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Not a good design in Thinkpad T400 USB ports and some thougths on selecting an ebook readers</title>
		<link>http://kalali.me/not-a-good-design-in-thinkpad-t400-usb-ports-and-some-thougths-on-selecting-an-ebook-readers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=not-a-good-design-in-thinkpad-t400-usb-ports-and-some-thougths-on-selecting-an-ebook-readers</link>
		<comments>http://kalali.me/not-a-good-design-in-thinkpad-t400-usb-ports-and-some-thougths-on-selecting-an-ebook-readers/#comments</comments>
		<pubDate>Sun, 21 Dec 2008 16:23:19 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Gadget]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Laptop]]></category>
		<category><![CDATA[Thinkpad]]></category>
		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=308</guid>
		<description><![CDATA[I received my T400 some weeks ago,Sure I create the recovery DVDs and installed a brand new Ubunut 8.10 on it. But so far there are two things which make me crazy: First, why there is no horizontal USB port on the laptop and all ports are vertical? what if we need to plug a [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>I received my T400 some weeks ago,Sure I create the recovery DVDs and installed a brand new Ubunut 8.10 on it. But so far there are two things which make me crazy:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>First, why there is no horizontal USB port on the laptop and all ports are vertical? what if we need to plug a device which its height is bigger than T400 port distance with the desk? I didnt had the time to take some photos so I used an available one. this is the photo taken from Lenovo forums which shows Thinkpad T400 <img src="http://farm4.static.flickr.com/3232/2774790879_83011a1d6a.jpg" /></li>
<li>The other flaw, is the keyboard lamp which is supposed to let us see the keyboard clearly in the dark, but problem is that it is not angled enough to illuminate the keyboard and instead it blind our eyes.</li>
</ul>
<h3>And about the so called ebook readers:</h3>
<p>About 1.5 years ago I searched to find a good ebook reader for myself and my digging into the market has no result except that I come across two &quot;to be available&quot; ebook readers which could be answer to all of my requirements, The first one was the Epson-Seiko ebook reader which as far as I can remember, based on the available information it was light, as big as an A4 paper with and comes with a multicolour screen. The other one was an ebook reader from a company named Plastic Logic. although at that time there was no detailed information about their ebook reader, but the amount of information which they provided in their website suggests that it is the best option that I can have.</p>
<p>few days ago one of my friends asked my opinion about the Amazon Kindle and it triggered another search in the ebook readers market. First I tried to find about the Epson-Seiko reader with no luck but I found that the plastic logic reader is going to be available early in 2009 which is very very good news for me.</p>
<p><a href="http://www.plasticlogic.com/product.html">Plastic logic reader</a> is very durable, very lightweight, it is in size of A4 which is what I need at first place, It is can help in reading PDF and MS Office documents among others, come with wifi, bluetooth in addition to USB 2.0 support.</p>
<p>I am waiting to see this device hitting the shelves, I will definitely buy one as soon as It become available.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/not-a-good-design-in-thinkpad-t400-usb-ports-and-some-thougths-on-selecting-an-ebook-readers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using XML in Java refcard is available for download as free as speech</title>
		<link>http://kalali.me/using-xml-in-java-refcard-is-available-for-download-as-free-as-speech/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-xml-in-java-refcard-is-available-for-download-as-free-as-speech</link>
		<comments>http://kalali.me/using-xml-in-java-refcard-is-available-for-download-as-free-as-speech/#comments</comments>
		<pubDate>Sun, 21 Dec 2008 16:23:19 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[DTD]]></category>
		<category><![CDATA[Parsing]]></category>
		<category><![CDATA[refcard]]></category>
		<category><![CDATA[Stax]]></category>
		<category><![CDATA[Validation]]></category>
		<category><![CDATA[XSD]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=306</guid>
		<description><![CDATA[I wrote a new refcard for Dzone, the refcard is about using XML in java and generally covers: What is XML XML usage use cases, when to use and when not to use what we have in Java for dealing with XML documents What DTD and XSD are How we can perform validation using XSD [...]]]></description>
			<content:encoded><![CDATA[</p>
<table border="0" cellspacing="2" cellpadding="0">
<tr>
<td>
<p align="left"><img src="http://weblogs.java.net/blog/kalali/archive/files/206.png" alt="206.png" width="206" height="266" /></p>
</td>
<td>
<p align="left"></p>
<p align="left">I wrote a new <a href="http://refcardz.dzone.com/refcardz/using-xml-java"> refcard</a> for <a href="http://dzone.com/">Dzone</a>, the refcard is about using XML in java and generally covers:</p>
<p align="left" style=" -qt-block-indent:1;">
<ul>
<li align="left">What is XML</li>
<li align="left">XML usage use cases, when to use and when not to use</li>
<li align="left">what we have in Java for dealing with XML documents</li>
<li align="left">What DTD and XSD are</li>
<li align="left">How we can perform validation using XSD and DTD in different parsers</li>
<li align="left">What is different between different techniques of parsing XML documents</li>
<li align="left">Basics of XPath.</li>
<li align="left">Some performance tips</li>
</ul>
<p align="left">This is my second Refcard, the <a href="http://weblogs.java.net/blog/kalali/archive/2008/07/glassfish_refca.html">first refcard</a> was about <a href="Http://glassfish.dev.java.net">GlassFish</a> administration and it was an instant success. An updated version of GlassFish refcarsd is published and is available at <a href="http://refcardz.dzone.com/refcardz/glassfish-application-server"> GlassFish V3 refcard</a>. The updated version covers some new features of upcoming GlassFish v3.</p>
</td>
</tr>
</table></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/using-xml-in-java-refcard-is-available-for-download-as-free-as-speech/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One suite of JSF components to rule them all</title>
		<link>http://kalali.me/one-suite-of-jsf-components-to-rule-them-all/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=one-suite-of-jsf-components-to-rule-them-all</link>
		<comments>http://kalali.me/one-suite-of-jsf-components-to-rule-them-all/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 04:28:24 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[ICESoft]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[WoodStock]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=304</guid>
		<description><![CDATA[Sun Microsystems and ICESoft put a joined effort to back one single JSF component suite. It looks like that Sun realised that re-use and cooperation is another key of a successful business so they are trying to spent less resources on things that are already available in the community by providing some level of support [...]]]></description>
			<content:encoded><![CDATA[</p>
<p><a href="http://www.netbeans.org">Sun Microsystems </a>and <a href="http://www.icesoft.com/">ICESoft</a> put a <a href="http://www.netbeans.org/servlets/NewsItemView?newsItemID=1324">joined</a> effort to back one single JSF component suite. It looks like that Sun realised that re-use and cooperation is another key of a successful business so they are trying to spent less resources on things that are already available in the community by providing some level of support and funding instead of starting the same suite from the scratch.</p>
<p>Sun abandoned further development and support of <a href="https://woodstock.dev.java.net/"> WoodStock</a> components set which was the primary set of components in the <a href="http://www.netbeans.org">NetBeans IDE</a> visual web development project. And instead they put some effort together with ICESoft to provides a <a href="http://www.icefaces.org/main/product/woodstock-migration.iface">migration path</a> from WoodStock suite to ICESoft component suite.</p>
<p>Although I like WoodStock compoents suite but the move is much more promising than development of the woodstock project in long term as there are more man power behind the ICESoft component set as from now that what was behind the WoodStock project.</p>
<p>ICESoft which is a long term provider and developer of JSF components has a NetBeans module which let developers simply use the ICEFaces components in their projects. <a href="http://www.icefaces.org/main/downloads/os-downloads.iface?category=NetBeans"> New version</a> of the module support working on projects with both ICEFaces and WoodStock components.</p>
<p>There is a <a href="http://www.icefaces.org/main/resources/woodstock-icefaces-mapping.iface"> comparison matrix</a> between between the two component suite and <a href="http://www.icefaces.org/main/product/woodstock-migration.iface">promising roadmap</a> which you can consult.</p>
<p> </p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/one-suite-of-jsf-components-to-rule-them-all/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some thoughts on the JBoss AS 5 release</title>
		<link>http://kalali.me/some-thoughts-on-the-jboss-as-5-release/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=some-thoughts-on-the-jboss-as-5-release</link>
		<comments>http://kalali.me/some-thoughts-on-the-jboss-as-5-release/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 14:37:04 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Comparison]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Modularity]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[GlassFish v3]]></category>
		<category><![CDATA[JBoss 5]]></category>
		<category><![CDATA[modularity]]></category>
		<category><![CDATA[OSGI]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=302</guid>
		<description><![CDATA[JBoss application server 5 GA released after a very long period of silence from &#34;JBoss, a division of Red Hat&#34;. The new version of JBoss application server supports Java EE 5 and is based on modularity concept with a small kernel named JBoss MicroContainer in the core and all functionalities as modules around the kernel. [...]]]></description>
			<content:encoded><![CDATA[</p>
<p><a href="http://www.jboss.org"> JBoss</a> application server 5 GA released after a very long period of silence from &quot;JBoss, a division of Red Hat&quot;. The new version of JBoss application server supports Java EE 5 and is based on modularity concept with a small kernel named <a href="http://www.jboss.org/jbossmc/">JBoss MicroContainer</a> in the core and all functionalities as modules around the kernel. JBoss kernel is POJO based and all modules follows the same principals, some configuration files are required to configure the services which the kernel will load. JBoss modularity system is niether based on OSGI nor drafts of the to be released Java SE modularity system.</p>
<p>JBoss 5, uses the MicroContainer to ensure an easy implementation of Java EE 6 profiles and also let the developers and administrators to easily disable some features and enable some other features.</p>
<p>I think from version 5, JBoss application server development will see some dramatic changes, the modules will be developed independently and therefore, the release cycle will be a mixed model of hot module releases like updates and patches and major releases which is an integration of all available modules. Although JBoss is far from providing a solid foundation in term providing a package distribution system and all required software to keep an eye on the updated modules and installing them, but that is the path which I think they will follow.</p>
<p>With all this architectural changes, JBoss 5 has a drawback. There is no changes in the administration at all, 3 years of development produces no changes in what administrators use to manage the servers, clusters and applications which are assets of the company which they work for. The same old JMX based administration console is what administrators should deal with for some few months or years until Red Hat finishes the development of their new administration console. Yes, the have a project named <a href="http://www.jboss.org/jopr/"> Jopr</a> to provide a neat SEAM based administration console, but when it will be ready to get bundled with AS, no one knows.</p>
<p>Today <a href="http://GlassFish.dev.java.net"> GlassFish</a> is the dominant open source application server and it gained the market share in absence of the Open Source application servers steward, JBoss. The steward re-appeared but its re-appearance is not that promising because of many advantages which its replacement, GlassFish, provides over it.</p>
<p><a href="http://GlassFish.dev.java.net"> GlassFish v3</a> uses a modular architecture based on the standards.The OSGI as the bundle layer and <a href="HK2.dev.java.net">HK2</a> which is an early implementation of JSR-277, Java SE modularity system, for the service layer. There is no need to edit an XML file, just drop the bundle and it is installed or remove the bundle and it will not load the next time. Also you can utilize the very easy to use update Centre which in addition to managing the currently installed modules, let you install updates or brand new features by selecting the features that you need and waiting for the download to finishes.</p>
<p>GlassFish v3 distribution is based on a solid binary distribution system named <a href="http://www.opensolaris.org/os/project/pkg/">pkg(5) Image Packaging System</a> or simply IPS which is a operating system independent software distribution system based on network repository of the software packages. The IPS helps keeping GlassFish up to date automatically with in the blink of an eye. it let you install the new features and updates by some clicks in the desktop GUI, web based administration console, or using the command line</p>
<p>GlassFish v3 provides very solid administration channels including the JMX console, the web based administration console and the command line administration tools which one can use to administrate all aspects of the application server from mere deploying an application to large scale management of a cluster farm.</p>
<p>And Finally GlassFish version 3 supports Java EE 6 and its final version will be available by the middle of 2009. if you want to know about GlassFish for Java EE 5, you should know that the version which supports Java EE 5 released in May 2006 and its 3rd major updates is <a href="http://wiki.glassfish.java.net/Wiki.jsp?page=PlanForGlassFishV2.1">GlassFish 2.1</a> which is scheduled to be released on Jan 2009</p>
<p> </p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/some-thoughts-on-the-jboss-as-5-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Netbeans 6.5 is at your door step, take a look at shining new features</title>
		<link>http://kalali.me/netbeans-6-5-is-at-your-door-step-take-a-look-at-shining-new-features/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=netbeans-6-5-is-at-your-door-step-take-a-look-at-shining-new-features</link>
		<comments>http://kalali.me/netbeans-6-5-is-at-your-door-step-take-a-look-at-shining-new-features/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 15:17:22 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[NetBeans RCP]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[J2ME]]></category>
		<category><![CDATA[Java EE 5]]></category>
		<category><![CDATA[Netbeans 6.5]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[RoR]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=300</guid>
		<description><![CDATA[NetBeans IDE seen a lot of changes during past three years, the evolutionary changes starts with NetBeans 5 and later on continued to NetBeans 5.5 when Sun Microsystems released more of its code base under the open source license. The main reason behind the feature rich releases can be seen behind the unifiyng of Sun [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>NetBeans IDE seen a lot of changes during past three years, the evolutionary changes starts with NetBeans 5 and later on continued to NetBeans 5.5 when Sun Microsystems released more of its code base under the open source license.</p>
<p>The main reason behind the feature rich releases can be seen behind the unifiyng of Sun closed source line of IDEs engineering team with NetBeans engineering teams, and further expanding the team with new engineers and evangelists.</p>
<p>NetBeans 6 goal was improved editor, improved SOA support and improved Java EE support, while <a href="http://www.netbeans.org/community/releases/65/"> NetBeans version 6.5</a> is mostly targets editor enhancement, web applications and scripting language support. While you can deploy your application to GlassFish version 3 prelude in NetBeans 6.5, NetBeans 7 will be the first IDE with Java EE 6 support including JSF 2.0 and Web Beans</p>
<p>What of what you can expect from NetBeans 6.5 is as follow:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Full PHP development support</li>
<li>Full RoR development support (Ruby on Rails)</li>
<li>Full Groovy and Grails development supports</li>
<li>Improved J2ME application development</li>
<li>Improved C++ application development (editor, project life cycle, etc)</li>
<li>Improved SQL editor with good integration with MySQL</li>
<li>Improved Editor, many small changes to make the over all code navigation easier, many changes to make the IDE GUI more accessible</li>
<li>RESTful web services, Spring, and Hibernate support</li>
<li>Improved profiler with remote profiling support</li>
<li>AJAX support by providing debugging, library manager, built-in support for Yahoo UI, WoodStock, jQuery, dojo, scriptaculous, prototype</li>
</ul>
<p>If you want to see more new features, which are numerous, you can tale a look at <a href="http://wiki.netbeans.org/NewAndNoteWorthy"> its well covered list of features with a lot of screen shots</a></p>
<p>You are eager to see how these features works? You were looking for an IDE with these broad range of features out of the box? you can wait until 20th of the November or you can try its <a href="http://download.netbeans.org/netbeans/6.5/rc/">Release candidate 2</a> right now, by using RC2 you can check the features and <a href="http://www.netbeans.org/community/issues.html"> report </a>any bug that you encounter to ensure that the final release is bug free.</p>
<p> </p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/netbeans-6-5-is-at-your-door-step-take-a-look-at-shining-new-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One pager review of GlassFish version 3 features</title>
		<link>http://kalali.me/one-pager-review-of-glassfish-version-3-features/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=one-pager-review-of-glassfish-version-3-features</link>
		<comments>http://kalali.me/one-pager-review-of-glassfish-version-3-features/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 07:00:33 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[embedded]]></category>
		<category><![CDATA[features]]></category>
		<category><![CDATA[GlassFish v3]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Pluggable containers]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[scripting languages]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=298</guid>
		<description><![CDATA[Modular architecture GlassFish V3 uses a modular architecture to address the emerging requirements in the Application serverâ€™s market and container profiles concept of the Java EE 6. GlassFish uses OSGI for module management, and inside the OSGI modules it uses HK2 module system for configuration and service management. So far, Administration console, CLI, and application [...]]]></description>
			<content:encoded><![CDATA[</p>
<h3>Modular architecture</h3>
<p>GlassFish V3 uses a modular architecture to address the emerging requirements in the Application serverâ€™s market and container profiles concept of the Java EE 6. GlassFish uses OSGI for module management, and inside the OSGI modules it uses HK2 module system for configuration and service management. So far, Administration console, CLI, and application types containers, can be extended using this modular system.  Java EE components can be replaced by any other compatible implantation using the OSGI modeling system.</p>
<h3>Pluggable containers, scripting language support:</h3>
<p>GlassFish V3 introduces new innovation in supporting different types of applications by letting the administrators and system managers to deploy different types of applications which are coming from different platforms and frameworks like Ruby On Rails, Grails, Quercus, and so on in the same applications server instance that they deploy the Java EE applications and therefore a unified administration infrastructure will be used to deal with all required administrative and management tasks. Containers load when they are required, for example when no PHP application is deployed, PHP container does not has any overhead over the application server.</p>
<h3>CLI and administration console extendibility:</h3>
<p>With GlassFish V3 it is possible to extend GlassFish CLI by developing new commands (extending an interface and using some HK2 services if required) as OSGI modules and simply putting them into GlassFish modules directory. The rest of the tasks of picking the module and responding to your command is what GlassFish module system does. Web based administration console can be extended using the same mechanism, but this time you can develop some JSF web pages to which you need to add to Administration console along with some descriptors which determine what is the pageâ€™s parent node in navigation tree and so on.</p>
<h3>Role based security:</h3>
<p>GlassFish V3 administration console is equipped with fine grained access management system which let the System Administrator to define new role with limited set of permission on using administration console.</p>
<h3>An Embeddable Application server:</h3>
<p>GlassFish version 3 can be used as an embedded application server (run in the same JVM that the client application runs) with full support of Java EE 6. Embedded application server can be used for packaged software, unit testing, building new functionalities on top of Java EE 6 and so on.</p>
<h3>Flashlight, the probing framework:</h3>
<p>Flashlight infrastructure introduced to remove the heavy burden of monitoring from application server and apply a very small percent of overhead whenever a client starts looking at the monitoring information. It let the developers and administrators to view variety of sever attributes in runtime and if they need to view any factor which is not provided by default (their own source code monitoring information) they can embed monitoring probes in sensitive parts of their code when they develop the software and later use the monitoring information that probes collect to see how that sensitive part of the application works.</p>
<h3>REST monitoring support:</h3>
<p>Glassfish Monitoring information can be received using RESTfull interfaces provided  in GlassFish V3, using this monitoring feature developers and administrators can gather statistics related to any attributes that they like using any programming language with REST or HTTP support.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/one-pager-review-of-glassfish-version-3-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GlassFish refcard is available for download for free</title>
		<link>http://kalali.me/glassfish-refcard-is-available-for-download-for-free/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=glassfish-refcard-is-available-for-download-for-free</link>
		<comments>http://kalali.me/glassfish-refcard-is-available-for-download-for-free/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 02:58:33 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[GlassFish Security]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[refcard]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=296</guid>
		<description><![CDATA[In case that you are a glassfish administrator or a developer who uses glassfish in day to day development tasks then you will find GlassFish Reference Card a valuable source of information to keep you away from searching the web or administration references. The reference card contains most important administration commands, security tips, performance tuning [...]]]></description>
			<content:encoded><![CDATA[</p>
<table border="0" cellspacing="2" cellpadding="0">
<tr>
<td>
<p align="left"><img src="http://refcardz.dzone.com/sites/all/files/refcardz/covers/3638.png" alt="GlassFish Application Server" width="206" height="266" /></p>
</td>
<td>
<p align="left"></p>
<p align="left">In case that you are a glassfish administrator or a developer who uses glassfish in day to day development tasks then you will find GlassFish Reference Card a valuable source of information to keep you away from searching the web or administration references.</p>
<p align="left">The reference card contains most important administration commands, security tips, performance tuning tips, clustering and monitoring instructions along with explanation around troube shooting and GlassFish directory structure.</p>
<p align="left">Just navigate to <a href="http://refcardz.dzone.com/announcements/glassfish">http://refcardz.dzone.com/announcements/glassfish</a> and download the reference card.</p>
<p align="left">You can find many other refcardz in variety of topics at <a href="http://refcardz.dzone.com/">http://refcardz.dzone.com/</a></p>
</td>
</tr>
</table>
<p> </p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/glassfish-refcard-is-available-for-download-for-free/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NetBeans Platform Certification and training.</title>
		<link>http://kalali.me/netbeans-platform-certification-and-training/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=netbeans-platform-certification-and-training</link>
		<comments>http://kalali.me/netbeans-platform-certification-and-training/#comments</comments>
		<pubDate>Tue, 20 May 2008 05:13:16 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Modularity]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[NetBeans RCP]]></category>
		<category><![CDATA[Certification]]></category>
		<category><![CDATA[NetBeans Platform]]></category>
		<category><![CDATA[RCP]]></category>
		<category><![CDATA[training]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=294</guid>
		<description><![CDATA[Netbeans is well known for beeing a great IDE for developing Java SE, Java EE, C++, Java ME, Sun SPOT, Ruby on Rail, PHP, Groovy, &#8230; but NetBeans has more to offer when it come to developing highly modular desktop applications. The desktop application can be from any possible category like Business oriented, scientific, utilities, [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>Netbeans is well known for beeing a great IDE for developing <a href="http://www.netbeans.org/features/java/index.html">Java SE</a>, <a href="http://www.netbeans.org/features/web/java-ee.html">Java EE</a>, <a href="http://www.netbeans.org/features/cpp/index.html">C++</a>, <a href="http://www.netbeans.org/features/javame/index.html">Java ME</a>, Sun SPOT, <a href="http://www.netbeans.org/features/ruby/index.html">Ruby on Rail</a>, <a href="http://www.netbeans.org/kb/61/php/installing-and-configuring-required-software.html">PHP</a>, Groovy, &#8230; but NetBeans has more to offer when it come to developing highly modular desktop applications. The desktop application can be from any possible category like Business oriented, scientific, utilities, development tools, entertinement, etc. You can find a list of applications based on NetBeans platform <a href="http://platform.netbeans.org/screenshots.html">here</a> And it is provided by the NetBeans platform which what NetBeans IDE and all of its complementary packs and plugins are developed based on it.</p>
<p> </p>
<p>If you are a <a href="http://platform.netbeans.org/">Platform</a> developer you may already know that there are many <a href="http://www.netbeans.org/kb/support.html">valuable resources</a> like <a href="http://www.sun.com/books/catalog/rich_client_programming.xml">books</a> and <a href="http://platform.netbeans.org/tutorials">articles</a> already available to start with developing applications on top of NetBeans platform. In addition to all of there resources, NetBeans provides you with another option, <a href="http://edu.netbeans.org/courses/nbplatform-certified-training/"> NetBeans Platform Certified Training</a>, through this program you can freely attend training courses and get certification based on the level of knowledge and experience that you demonestrate at the end or through the program.</p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/netbeans-platform-certification-and-training/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Secure GlassFish installation,  Part II</title>
		<link>http://kalali.me/how-to-secure-glassfish-installation-part-ii/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-secure-glassfish-installation-part-ii</link>
		<comments>http://kalali.me/how-to-secure-glassfish-installation-part-ii/#comments</comments>
		<pubDate>Sun, 17 Feb 2008 17:04:15 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[GlassFish Security]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[Digital Certificate]]></category>
		<category><![CDATA[EJBCA]]></category>
		<category><![CDATA[Listeners]]></category>
		<category><![CDATA[Mutual authentication]]></category>
		<category><![CDATA[Secure Connection]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=292</guid>
		<description><![CDATA[In order to secure the application server you need to secure its communication ways with outside world, It means you will need to secure all ports and listeners. There are 3 kind of listeners in Glassfish application server that you will need to take care of them First of all make sure that you secured [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>In order to secure the application server you need to secure its communication ways with outside world, It means you will need to secure all ports and listeners.</p>
<p>There are 3 kind of listeners in Glassfish application server that you will need to take care of them</p>
<p>First of all make sure that you secured the administration listener, make sure that you have enabled <strong>Security</strong> for administrator listener and set an specific IP address for it to listen on. Usually we are not going to use administration console from outside of the internal network, so let it listen only on interfaces that you need it to listen perhaps the interface that connect the server to your LAN. In order to do this, open administration console and navigate to:</p>
<pre><code> Configuration&gt; HTTP Service&gt; HTTP Listeners&gt; admin-listener </code>
</pre>
<p>Change the <strong>Network Address</strong> as appropriated, check the <strong>Security </strong>check box, and in the <strong>SSL Tab</strong> enable <strong>Client Authentication</strong>, in order to find out how you should use Client Certificate, take a look at my previous posts about SSL and securing GlassFish Application Server. You have two other Http listeners to take care of, so make sure that you change their Network Address and enable the Security facilities if required</p>
<p>There is another listener which you need to take care of, It is your IIOP listener. IIOP listener let you create a context to lookup into your JNDI, etc. In order to configure the IIOP listeners you should navigate to:</p>
<pre><code> Configuration&gt; ORB&gt; IIOP Listeners </code>
</pre>
<p>Here you can see that there are 3 different listeners already created and configure for different purposes. You should not allow the first non-secure listener (<strong>orb-listener-1</strong>) to listen over a public network as there is no authentication or transfer layer security for this listener, but the second one (<strong>SSL</strong>) have transport layer security and the third one (<strong>SSL_MUTUALAUTH</strong>) has mutual authentication which guarantee that listener will only process request come after a client cert authentication. make sure that you configure the listeners to listen on correct Network address and remove or disable the listeners those that you do not need. You can disable a listener by looking at listener details page which provides a check box for it.</p>
<p>Another listener which you need to take care of is your JMX connector listener, You can view and edit its configuration by navigating to:</p>
<pre><code> Configuration&gt; Admin Service&gt; system </code>
</pre>
<p>Here you are able to change the realm that this listener use to authenticate the users that are trying to connect to JMX listener, you can change the realm to an specific realm which you have made only for JMX users or let it use you administration realm. You can change the Network Address that this listener is using along with enabling the SSL and Client Cert Authentication in order to secure the data transfer and guarantee that only users with correct digital certification can use your JMX connector to control the application server</p>
<p>PS: All of the listeners that you can configure in your administration console allows you to have <strong>Mutual Authentication</strong> (Client Cert Authentication) which ensure that both parties have verify-able certifications. This certifications can come from well known providers like VeriSign or your own CA. on the other hand all listeners allows you to specify an specific alias for them, which means that each listener mutual authentication can be configured completely independent from other listeners, for example you can have two alias one for administration console and one for JMX connector in order to prevent JMX users to connect to administration console.</p>
<p>For more information you can take a look at my older posts related to this matter:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li><a href="http://weblogs.java.net/blog/kalali/archive/2007/12/how_to_secure_g_1.html"> How to secure GlassFish application server, Part I</a></li>
<li><a href="http://weblogs.java.net/blog/kalali/archive/2007/08/how_to_have_you_1.html"> Make your Own CA using EJBCA, Part I</a></li>
<li><a href="http://weblogs.java.net/blog/kalali/archive/2007/08/how_to_have_you.html"> Make you own CA using EJBCA, Part II</a></li>
</ul>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/how-to-secure-glassfish-installation-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The train starts running, NetBeans Innovators Grants has just announced.</title>
		<link>http://kalali.me/the-train-starts-running-netbeans-innovators-grants-has-just-announced/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-train-starts-running-netbeans-innovators-grants-has-just-announced</link>
		<comments>http://kalali.me/the-train-starts-running-netbeans-innovators-grants-has-just-announced/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 12:11:47 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Innovators Grants]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=290</guid>
		<description><![CDATA[The train start running, NetBeans Innovators Grants has just announced. Are you an RCP developer looking for some financial support to implenent some modules on top of NetBeans RCP? Are you familiar with NetBeans IDE and also you have some ideas in your sleeve, ideas to enhance the IDE functionalitis, ideas about new functionalities, etc? [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>The train start running, NetBeans Innovators Grants has just announced.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Are you an <strong>RCP</strong> developer looking for some financial support to implenent some modules on top of NetBeans RCP?</li>
<li>Are you familiar with <strong>NetBeans IDE</strong> and also you have some ideas in your sleeve, ideas to enhance the IDE functionalitis, ideas about new functionalities, etc?</li>
<li>Do you know some bugs/ RFEs in issuzilla which you can fix them, but you were looking for financial support?</li>
<li>Do you have some cool ideas about some sample projects or blueprints showing How one can develop Java/ J2EE/ J2ME/ Ruby/ C++ projects using NetBeans IDE and its capabilities?</li>
</ul>
<p>If you fit into one of the above categories, you can join the <a href="http://www.netbeans.org/grant/"> NetBeans Innovators Grants</a>, a sub program of <a href="http://www.sun.com/aboutsun/pr/2007-12/sunflash.20071205.1.xml"> SUN Microsystems US$ 1 million Program </a> which is intended to help people develop open source projects sponsored by SUN Microsystems.</p>
<p>Take a look at <a href="http://www.netbeans.org/grant/"> NetBeans Innovators Grants Home Page</a>, read it carefully, check <a href="http://www.netbeans.org/grant/grantdetails.html">SubMission Details</a> page to gain some understanding of what is expected in your submission, and after you prepared your project proposal you can come to <a href="http://www.netbeans.org/grant/grant-submission-form.html">Proposal Submission</a> page and file in the forms with your project details in order to jump into the contest train.</p>
<p>Another item which could be the subject of a project is contributing articles, tutorials and sample codes to NetBeans Zone located at <a href="http://netbeans.dzone.com/"> Netbeans Zone</a>, this web site. it is intended to be the most complete source of articles, links,&#8230;. for NetBeans platform and IDE.</p>
<p>P.S: Make sure that you read the legal page located at: <a href="http://www.netbeans.org/grant/grantlegal.html">Legal information</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/the-train-starts-running-netbeans-innovators-grants-has-just-announced/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Four open source Java application servers compared</title>
		<link>http://kalali.me/four-open-source-java-application-servers-compared/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=four-open-source-java-application-servers-compared</link>
		<comments>http://kalali.me/four-open-source-java-application-servers-compared/#comments</comments>
		<pubDate>Tue, 11 Dec 2007 17:41:35 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Comparison]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[IBM]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Clustering]]></category>
		<category><![CDATA[EJB]]></category>
		<category><![CDATA[Extendability]]></category>
		<category><![CDATA[Geronimo]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=288</guid>
		<description><![CDATA[I was looking at feeds that my email client fetched during the day and I find am interesting one which lead me to an article written by Jonathan Campbell. Article can be found at http://www.javaworld.com/javaworld/jw-12-2007/jw-12-appservers.html Jonathan compared 3 different application server/ servlet container by thier support of Java EE 5 and some other factors. article [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>I was looking at feeds that my email client fetched during the day and I find am interesting one which lead me to an article written by Jonathan Campbell. Article can be found at <a href="http://www.javaworld.com/javaworld/jw-12-2007/jw-12-appservers.html">http://www.javaworld.com/javaworld/jw-12-2007/jw-12-appservers.html</a></p>
<p>Jonathan compared 3 different application server/ servlet container by thier support of Java EE 5 and some other factors. article explained about each feature that he compared application servers based on it. Jonathan did not included <a href="http://GlassFish.dev.java.net">GlassFish</a> in his review of &quot;open source Java application servers&quot; and only included 3 application servers/ Servlet containers including Tomcat, Jboss and Geronimo. <img src='http://kalali.me/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> , So I thought I should include some facts here in order to make the comparison fair to all parties.</p>
<p>Including Glassfish into Jonathan matrix will give us the following table: <strong>*Notice*</strong></p>
</p>
<table border="1" cellspacing="2" cellpadding="0">
<tr>
<td>
<p align="center"><strong>Feature</strong> </p>
</td>
<td>
<p align="center"><strong>JBoss 4.2</strong></p>
</td>
<td>
<p align="center"><strong>Geronimo 2</strong></p>
</td>
<td>
<p align="center"><strong>Tomcat 6</strong></p>
</td>
<td>
<p align="center"><a href="http://GlassFish.dev.java.net"><strong>GlassFish</strong></a><strong> 2</strong></p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">Java EE 5 compliance</p>
</td>
<td>
<p align="left">Partial</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">No</p>
</td>
<td>
<p align="left">Yes</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">EJB 3.0 capable</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Available</p>
</td>
<td>
<p align="left">Yes</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">JSP 2.1 and 2.5 capable</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">JavaServer Faces 1.2 support</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Available</p>
</td>
<td>
<p align="left">Yes</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">Custom plug-in support</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">No</p>
</td>
<td>
<p align="left">?</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">Business-rules engine support</p>
</td>
<td>
<p align="left">Available</p>
</td>
<td>
<p align="left">Available</p>
</td>
<td>
<p align="left">Available</p>
</td>
<td>
<p align="left">Available</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">Hibernate 3.x support</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Available</p>
</td>
<td>
<p align="left">Available</p>
</td>
<td>
<p align="left">Yes, based on below description</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">JBoss Seam support</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Available</p>
</td>
<td>
<p align="left">Yes</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">Clustering support</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Partial</p>
</td>
<td>
<p align="left">Yes</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">Eclipse IDE connector support</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
</tr>
</table>
<p> </p>
<p><strong>Following descriptions further explain some of what Glassfish can provides in relation of the above table</strong></p>
<p style=" -qt-block-indent:1;">
<ul>
<li><a href="http://GlassFish.dev.java.net">GlassFish</a> fully support Java EE 5 with all its related JSRs like JSP 2.1 (JSR 245), Servlet 2.5(154), EJB 3.0(JSR 245), etc.</li>
<li><a href="http://GlassFish.dev.java.net">GlassFish</a> support clustering and cluster management out of the box, a cluster can be configured from both CLI and Administration console.</li>
<li><a href="http://GlassFish.dev.java.net">GlassFish</a> administration console allows you to configure your load balancer <img src='http://kalali.me/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> , for example you can configure a Sun Java Web Server which works as load balancer to add or add/ remove an instance from its list of servers, either manually or automatically if a new node joined the cluster or removed from the cluster</li>
<li><a href="http://GlassFish.dev.java.net">GlassFish</a> allows you to manage resources for entire cluster at once instead of applying them for each instance, for example you can deploy a web application into a cluster of 10 instances instead of deploying it seperately for each instance.</li>
<li><a href="http://GlassFish.dev.java.net">GlassFish</a> has a very wide array documentation both from Sun Microsystems (for free) and from <a href="http://GlassFish.dev.java.net">GlassFish</a> community.</li>
<li><a href="http://GlassFish.dev.java.net">GlassFish</a> installation is as easy as executing 2 commands.</li>
<li>Deploying applications into <a href="http://GlassFish.dev.java.net">GlassFish</a> or even an entire cluster of glassfish instances is just 2 clicks away.</li>
<li>Quality of <a href="http://GlassFish.dev.java.net">GlassFish</a> components is out of any question, Metro is well known for supporting new WS-* standards, EJB support uses Toplink Essentials, MQ server is Sun open sourced MQ, etc.</li>
<li><a href="http://GlassFish.dev.java.net">GlassFish</a> has very good interoperability with some other open source projects like, OpenESB and OpenSSO which allows you to have what you need to kick start your J2EE application without looking at any additional configuration.</li>
<li>Certainly performance is something which everyone should have in mind before considering other feaures, take a look at http://www.spec.org/jAppServer2004/results/res2007q3/jAppServer2004-20070703-00073.html and http://weblogs.java.net/blog/sdo/archive/2007/07/sjsas_91_glassf.html to find out more about how much capable <a href="http://GlassFish.dev.java.net">GlassFish</a> is.</li>
<li><a href="http://GlassFish.dev.java.net">GlassFish</a> has connectors for both Eclipse and Netbeans, although other mentioned servers have a connector in Netbeans and Eclipse.</li>
<li>Seam support is available from <a href="http://GlassFish.dev.java.net">GlassFish</a> 1 upward.</li>
<li>Business rule engine support is available from OpenESB project integration.</li>
<li>About hibernate support, I cannot understand whether Jonathan means to use Hibernate as a persistence provider or plainly as an ORM, by the way both of this ?features? are available for <a href="http://GlassFish.dev.java.net">GlassFish</a> users.</li>
<li><a href="http://GlassFish.dev.java.net">GlassFish</a> has an Update center, which allows you to update your application server from a remote repository.</li>
<li><a href="http://GlassFish.dev.java.net">GlassFish</a> runs on all mentioned platforms, from Windows to AIX (Glasdfish 2 update 1 runs on AIX) and there is no restriction for you to run it on your platform of choice.</li>
</ul>
<p>Mentioned items are in relation to what orginal article tried to compare. <a href="http://GlassFish.dev.java.net">GlassFish</a> can be used by a ROR developer by its integration with first class ROR IDE (Netbeans 6), It can serve you VOIP and SIP requirement by means of sailfin,etc. Any user with any kind of requirement will find <a href="http://GlassFish.dev.java.net">GlassFish</a> a suitable application server.</p>
<p>Although Jonathan did not mentioned <a href="http://GlassFish.dev.java.net">GlassFish</a> directly, but he gives his opinion by writing:<em>In my experience commercial application servers have more bugs than the open source servers compared in this article, and they are more difficult to install. Deployment can also be an issue &#8212; </em><strong><em>at least with the recent version of Sun&#8217;s Java Application Server.</em></strong> The article co<br />
uld be more complete if Jonathan included <a href="http://GlassFish.dev.java.net">GlassFish</a> in his comparsion chart and at then end he could write that <a href="http://GlassFish.dev.java.net">GlassFish</a> has problematic deployment procedure</p>
<p> </p>
<p>An statement which looks odd to me is: <em>In my experience commercial application servers have more bugs than the open source servers compared in this article, and they are more difficult to install.</em>, Althogh it will be a complex procedure to setup a Cluser of Websphere (as a commercial application servers ) using websphere XD, Object Grid, and other available packages that faciliate enterprise scale deployment of Websphere, but WebSphere has a decent performance and reliability which is very hard to deny.</p>
<p><strong>Notice:</strong> Some parts of this table taken from Jonathan Campbell article published by javaworld and is available at <a href="http://www.javaworld.com/javaworld/jw-12-2007/jw-12-appservers.html">http://www.javaworld.com/javaworld/jw-12-2007/jw-12-appservers.html</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/four-open-source-java-application-servers-compared/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Secure GlassFish installation.</title>
		<link>http://kalali.me/how-to-secure-glassfish-installation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-secure-glassfish-installation</link>
		<comments>http://kalali.me/how-to-secure-glassfish-installation/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 18:19:30 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[GlassFish Security]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[CertDB]]></category>
		<category><![CDATA[Change Passwords]]></category>
		<category><![CDATA[Digital Certificates]]></category>
		<category><![CDATA[Listeners]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=286</guid>
		<description><![CDATA[It is some days that I saw some posts about securing Glassfish in production environment, so I thought I write some of my experience here to let other secure the glassfish easier. There are some basic items that you will need to relay on in order to have a secure Glassfish installation.   secure access [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>It is some days that I saw some posts about securing Glassfish in production environment, so I thought I write some of my experience here to let other secure the glassfish easier. There are some basic items that you will need to relay on in order to have a secure Glassfish installation.</p>
<p> </p>
<p style=" -qt-block-indent:1;">
<ol>
<li>secure access to administration console, both web based and CLI.</li>
<li>secure all ports and listeners that application server uses to interact with outside applications.</li>
<li>secure your environment from GlassFish; Yes, glassfish can be evil if you have buggy software installed on you application server.</li>
<li>secure your application server from the environment that it is operating on it.</li>
<li>secure glassfish directories in order to prevent any accidental changes, use, etc in glassfish configuration files.</li>
<li>Take care of all logging if you are not going to secure Glassfish on the file system.</li>
<li>tips and tricks which are not mentioned in the above sections.</li>
<li>firewalls, network security, clustered environment tips and tricks</li>
</ol>
<p> </p>
<p>But how you can do these, I will explain each item in as much details as I can begin with securing your administration console. As you know administration console is the main interaction point with an application server, however must of application servers let you perform all changes from a CLI or direct editing of server.xml, domain.xml and so on. But Web based administration console is the most open to access part of application server, So letâ€™s see how we can secure it:</p>
<p>You will need to change administration password from the default one, do it by using the following command in CLI when your application server is running.</p>
<pre><code> change-admin-password </code></pre>
<p> </p>
<p>Using this command you can change your administration password both for CLI and Web based console. The output of the command may differ from version or profile to another version and profile but it will asks you to enter old and new password, in case that it asks to accept a certificate accept it, you will change it later.</p>
<p>Second thing that you should change is master-password, make sure that you stop your application server before issuing the command as it will not work when the as is running. Following command in asadmin console will do it for you. Default master password value is â€œchangeitâ€</p>
<pre><code> change-master-password </code></pre>
<p> </p>
<p>Now you are sure that your administration console and keystore files are protected using a new password which you know.</p>
<p>Its time to take a closer look at application server web based console protection, you need to make sure that you have most possible protection over your administration console by limiting access to it using firewalls and after that you can add another level of protection and transmission integrity by using a mutual authentication using Digital Certificate.</p>
<p>By changing the administration http listener to use an a digital certificate specific for administration console and changing its setting to use client-cert authentication or mutual authentication you can ensure that your administration console will only opens in a browser which has a digital certificate signed by a CA known to your administration listener.</p>
<p>This way you can be sure that only the guys with that specific digital certificate will have access to your admin console and the administrator will not fool by anyone to connect to a mock server. On the other hand you have full protection of SSL over your transmitted data. To learn how you can setup your own CA and add keys to glassfish keystore take a look at some older entry of my weblog. however those entry shows how you can use digital certificate when your AS uses jks files ant certDB files.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/how-to-secure-glassfish-installation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to have your Own CA and configure Glassfish and your clients for mutual authentication?, Part II</title>
		<link>http://kalali.me/how-to-have-your-own-ca-and-configure-glassfish-and-your-clients-for-mutual-authentication-part-ii/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-have-your-own-ca-and-configure-glassfish-and-your-clients-for-mutual-authentication-part-ii</link>
		<comments>http://kalali.me/how-to-have-your-own-ca-and-configure-glassfish-and-your-clients-for-mutual-authentication-part-ii/#comments</comments>
		<pubDate>Thu, 23 Aug 2007 17:49:26 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[GlassFish Security]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[Digital Certificate]]></category>
		<category><![CDATA[EJBCA]]></category>
		<category><![CDATA[Mutual authentication]]></category>
		<category><![CDATA[Secure Connection]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=284</guid>
		<description><![CDATA[In the second part of the series, you can see how we can utilize EJBCA to create certification for a client side application which will communicate with Glassfish server when Client cert authentication (Mutual Authentication) is enabled whether by changing the listener attributes or by describing it in the web-config.xml. In order to create client [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>In the second part of the series, you can see how we can utilize EJBCA to create certification for a client side application which will communicate with Glassfish server when Client cert authentication (Mutual Authentication) is enabled whether by changing the listener attributes or by describing it in the web-config.xml.</p>
<p>In order to create client certification we will need to perform following steps as described in <strong>4 sections</strong>:</p>
<h5>Section 1: Creating clients certification profile:</h5>
<p style=" -qt-block-indent:1;">
<ul>
<li>Go to <a href="https://localhost:8080/ejbca/"> https://localhost:8080/ejbca/</a> and select <strong>Administration</strong>.</li>
<li>Select <strong>Edit Certification profiles </strong>from the left side menu.</li>
<li>Enter a name for the profile and press add button. I choose <strong>Clients</strong> as the name.</li>
<li>From the list select <strong>Clients</strong> Item and press <strong> Edit </strong>button.</li>
<li>Now profile edit page will open change the attribute as follow: </li>
<p style=" -qt-block-indent:2;">
<ul type="circle">
<li>for <strong>Key Usage </strong> you should select at least Digital Signature and <strong>Key Encypherment.</strong></li>
<li>From  <strong>Extended Key Usage </strong>select <strong>Client Authentication</strong></li>
</ul>
<li>press save button.</li>
</ul>
<h5>Section 2: Create servers end entities profile:</h5>
<p>Now you have create a profile which in next sections you can create certifications which will comply with it. Now we will need to create an <strong> End Entity Profile</strong> so follow these steps to create it.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>From the left side menu click on  <strong>edit end entities profile </strong>.</li>
<li>Enter <strong>ClientsProfile</strong> as profile name and press add button.</li>
<li>From the list select <strong>ClientsProfile </strong>and press <strong> Edit End Entity Profile</strong> button.</li>
<li>Enter a user name and a password for the profile, I choose cAdmin/ cAdminAdmin.</li>
<li>Enter the common name</li>
<li>From the list of <strong>Available Certificate Profiles  </strong> select <strong>Clients </strong>which we made in last step.</li>
<li>select <strong>JKS </strong>as <strong>default token.</strong></li>
<li>click Save</li>
</ul>
<p>Now we are reaching an step in which we will create the real certificate that client will use to prove its identity and initiate SSL enabled session. To create the certificate perform following steps:</p>
<h5>Section 3: Create Client certification</h5>
<p style=" -qt-block-indent:1;">
<ul>
<li>From the left side menu select <strong>add end entity </strong>link.</li>
<li>Select <strong>ClientsProfile </strong>as <strong>End Entity Profile.</strong></li>
<li>Enter all information as you like.</li>
<li>Select <strong>JKS </strong>as <strong>Token.</strong></li>
<li>press <strong>add end entity</strong> button</li>
</ul>
<h5>Section 4: Use the certification in Client Application.</h5>
<p>You are done, the certification is ready to be downloaded and used.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Go to <a href="https://localhost:8080/ejbca/">https://localhost:8080/ejbca/</a>  and select <strong>Certification Enrollment.</strong></li>
<li>Select Manually for a Server</li>
<li>Enter user name and password which you have entered for end entity in previous step.</li>
<li>Click OK.</li>
</ul>
<p>By pressing OK a JKS file will download to your computer.</p>
<p>Create two copies of the file and Rename them  to keystore.JKS and cacerts.jks. In order to create a SSL enabled client, either web service client or any type of socket client which need to use SSL you can follow one of the following path:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>When you want to run your java application pass following parameter to JVM, it will ask JVM to use your cacerts.jks and keystore.jks during initialing SSL communication and authentication.</li>
</ul>
<pre><code>-Djavax.net.ssl.trustStore=&quot;Truststore_Location&quot;    -Djavax.net.ssl.trustStorePassword=&quot;Truststore_Password&quot;   -Djavax.net.ssl.keyStore =&quot;Keystore_Location&quot; -Djavax.net.ssl.keyStorePassword=&quot;Keystore_Password&quot;</code></pre>
<p style=" -qt-block-indent:1;">
<ul>
<li>Second way is adding the same parameter to your JVM during execution of your application code. using this way you are not forced to pass parameter and disclose your key stores passwords.</li>
</ul>
<pre><code> System.getProperties.put(&quot;javax.net.ssl.trustStore&quot;,&quot;Truststore_Location&quot;); System.getProperties.put(&quot;javax.net.ssl.trustStorePassword&quot;,&quot;Truststore_Password&quot;); System.getProperties.put(&quot;javax.net.ssl.keyStore&quot;,&quot;Keystore_Location&quot;);  System.getProperties.put(&quot;javax.net.ssl.keyStorePassword&quot;,&quot;Keystore_Password&quot;); </code></pre>
<p>Make sure that you are using correct location and password for your files, passwords are same as one you used to download the JKS files.</p>
<p>I should say again that you can explore and perhaps learn more about jks files, keys and certification by exploreing your stores, you can use jks file editor located at <a href="http://members.aon.at/bhuber14/nbm.html">http://members.aon.at/bhuber14/nbm.html</a>. Also if you are may find more cool key store editor in <a href="plugins.netbeans.org/PluginPortal/"> NetBeans Module Portal</a></p>
<p>For more information or maybe to find some of your questions answered you may take a look at:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li><a href="http://www.ryandelaplante.com/rdelaplante/entry/ssl_and_http_basic_authentication"> http://www.ryandelaplante.com/rdelaplante/entry/ssl_and_http_basic_authentication</a></li>
<li><a href="blogs.sun.com/swchan/entry/how_to_use_verisign_cert"> blogs.sun.com/swchan/entry/how_to_use_verisign_cert</a></li>
</ul>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/how-to-have-your-own-ca-and-configure-glassfish-and-your-clients-for-mutual-authentication-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to have your Own CA and configure Glassfish and your clients for mutual authentication?</title>
		<link>http://kalali.me/how-to-have-your-own-ca-and-configure-glassfish-and-your-clients-for-mutual-authentication/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-have-your-own-ca-and-configure-glassfish-and-your-clients-for-mutual-authentication</link>
		<comments>http://kalali.me/how-to-have-your-own-ca-and-configure-glassfish-and-your-clients-for-mutual-authentication/#comments</comments>
		<pubDate>Thu, 16 Aug 2007 12:35:51 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java EE Security]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[Digital Certificate]]></category>
		<category><![CDATA[EJBCA]]></category>
		<category><![CDATA[Mutual authentication]]></category>
		<category><![CDATA[Secure Connection]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=282</guid>
		<description><![CDATA[One of the most repeated question in GlassFish mailing list is SSL, Certification, Mutual Authentication,&#8230;. In this Entry I will try to address some of this questions by giving an step by step guide for using EJBCA to issue certificate, use them in both glassfish and clients which connect to glassfish in some manner. clients [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most repeated question in GlassFish mailing list is SSL, Certification, Mutual Authentication,&#8230;. In this Entry I will try to address some of this questions by giving an step by step guide for using EJBCA to issue certificate, use them in both glassfish and clients which connect to glassfish in some manner. clients like web browser, standalone java applications,&#8230;</p>
<p>There are several tutorial and blog entry about configuring glassfish to use some specific certification in order to perform server authentication for clients over SSL and each of those weblog is an invaluable source of information. In this blog entry and perhaps the next one I will address another concerns which some people has for their <a href="http://glassfish.dev.java.net">GlassFish</a> and client security. Some times we are running an application within an enterprise and we need to have mutual authentication for every clients that connect to server so we will need to have one certification for client and another one for our glassfish server. both of this certification should be valid (issued by an already known CA within glassfish trust store and client trust store). For these two entries I assume that our client and server will just accept certification issued by our own CA which is based on EJBCA.</p>
<p>Before we start the main job you will need to download and install EJBCA from its <a href="http://sourceforge.net/projects/ejbca">web site</a>, then you will need to install it according to its manual which you can find in <a href="http://ejbca.sourceforge.net/manual.html">documentation</a> section. After you installed and could view EJBCA administration console then you can follow the rest of the entry.</p>
<h5> </h5>
<p>In order to create server certification we will need to perform following steps as described in <strong>4 sections</strong>:</p>
<h5>Section 1: Creating servers certification profile:</h5>
<p style=" -qt-block-indent:1;">
<ul>
<li>Go to <a href="https://localhost:8080/ejbca/"> https://localhost:8080/ejbca/</a> and select <strong>Administration</strong>.</li>
<li>Select <strong>Edit Certification profiles </strong>from the left side menu.</li>
<li>Enter a name for the profile and press add button. I choose <strong> servers</strong> as the name.</li>
<li>From the list select <strong>servers </strong>Item and press <strong> Edit </strong>button.</li>
<li>Now profile edit page will open change the attribute as follow: </li>
<p style=" -qt-block-indent:2;">
<ul type="circle">
<li>for <strong>Key Usage </strong> you should select at least Digital Signature and <strong>Key Encypherment.</strong></li>
<li>From  <strong>Extended Key Usage </strong>select <strong>Server Authentication</strong></li>
</ul>
<li>press save button.</li>
</ul>
<h5>Section 2: Create servers end entities profile:</h5>
<p>Now you have create a profile which in next sections you can create certifications which will comply with it. Now we will need to create an <strong> End Entity Profile</strong> so follow these steps to create it.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>From the left side menu click on  <strong>edit end entities profile </strong>.</li>
<li>Enter <strong>ServersProfile</strong> as profile name and press add button.</li>
<li>From the list select <strong>ServersProfile </strong>and press <strong> Edit End Entity Profile</strong> button.</li>
<li>Enter a user name and a password for the profile, I choose sAdmin/ sAdminAdmin.</li>
<li>Enter the common name</li>
<li>From the list of <strong>Available Certificate Profiles  </strong> select <strong>Servers </strong>which we made in last step.</li>
<li>select <strong>JKS </strong>as <strong>default token.</strong></li>
<li>click Save</li>
</ul>
<p>Now we are reaching an step in which we will create the real certificate that Glassfish will use  in its SSL enabled listener. To create the certificate perform following steps:</p>
<h5>Section 3: Create server certification</h5>
<p style=" -qt-block-indent:1;">
<ul>
<li>From the left side menu select <strong>add end entity </strong>link.</li>
<li>Select <strong>ServersProfile </strong>as <strong>End Entity Profile.</strong></li>
<li>Enter all information as you like but make sure that CN should be Exact and fully qualified name of your sever as will access it from clients, for example if you are going to access the serve as <strong> computer1.mydomain.com</strong> then the CN should be the same if you are going to access it as Comuter1 then the CN should be that.</li>
<li>Select <strong>JKS </strong>as <strong>Token.</strong></li>
<li>press <strong>add end entity</strong> button</li>
</ul>
<h5>Section 4: Use the certification in Application Server.</h5>
<p>You are done, the certification is ready to be downloaded and used.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Go to <a href="https://localhost:8080/ejbca/">https://localhost:8080/ejbca/</a>  and select <strong>Certification Enrollment.</strong></li>
<li>Select Manually for a Server</li>
<li>enter user name and password which you have entered for end entity in previous step.</li>
<li>Click OK.</li>
</ul>
<p>By pressing OK a JKS file will download to your computer.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Create two copies of the file and Rename them  to keystore.JKS and cacerts.jks.</li>
<li>Goto Glassfish/domains/domain1 (If domain 1 is the domain that you want to configure for SSL).</li>
<li>Make sure that application server is stopped by issuing the following command.</li>
</ul>
<pre><code>	Glassfish_home/bin/asadmin  stop-domain domain1	</code></pre>
<p style=" -qt-block-indent:1;">
<ul>
<li>Now we need to change the master password in order to let glassfish open our new cacert.jks and keystore.jks so perform following command.</li>
</ul>
<pre><code>	Glassfish_home/bin/asadmin  change-master-password  \Here you should write the password that you choosed in last step/// --savemasterpassword=true</code></pre>
<p style=" -qt-block-indent:1;">
<ul>
<li>Now Goto glassfish_home/domains/domain1/config and create a backup from cacert.jks and keystore.jks.</li>
<li>Copy files that we create in first step of this section to this folder (overwrite the original files).</li>
<li>Open domain.xml (it is in domain1/config folder) by a text editor and replace all <strong>s1as </strong>occurrences with<strong> CN</strong> name that you have choose in <strong>section 3</strong>.</li>
<li>Start the application server.</li>
</ul>
<p>You are done, you application server should start normally, but you have some more steps before you complete the mutual authentication capability.</p>
<h5>Section 5: Enabling mutual authentication for a listener.</h5>
<p>Open application server administration console and from the left side menu select <strong>Configuration&gt; HTTP Service&gt; HTTP Listeners&gt; http-listener-2, </strong>now you should check the <strong>Security </strong>check box and select <strong>SSL </strong>tab, now make sure that you have checked <strong>Client Authentication </strong>check box.</p>
<p>You are done, point your browser to <a href="https://computer1.mydomain.com:8181"> https://computer1.mydomain.com:8181</a> you will see that this page will only open for the browser that you have imported EJBCA administration certification. it means that both server and client must prove their identity before they could communicate.</p>
<p>In next entry of this series I will demonstrate steps that you need to follow in order to create a stand alone web service client.</p>
<p>Make sure that you need to delete the private key of you server from cacerts.jks (it is not necessary by the way). Best way to explore you key stores is using keytool which you can find more information about it <a href="http://members.aon.at/bhuber14/nbm.html">Here</a>. Also if you are may find more cool key store editor in <a href="plugins.netbeans.org/PluginPortal/"> NetBeans Module Portal</a></p>
<p>For more information or maybe to find some of your questions answered you may take a look at:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li><a href="http://www.ryandelaplante.com/rdelaplante/entry/ssl_and_http_basic_authentication"> http://w<br />
ww.ryandelaplante.com/rdelaplante/entry/ssl_and_http_basic_authentication</a></li>
<li><a href="blogs.sun.com/swchan/entry/how_to_use_verisign_cert"> blogs.sun.com/swchan/entry/how_to_use_verisign_cert</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/how-to-have-your-own-ca-and-configure-glassfish-and-your-clients-for-mutual-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SHIFT+ALT+ENTER, a cool NetBeans shortcut</title>
		<link>http://kalali.me/shiftaltenter-a-cool-netbeans-shortcut/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=shiftaltenter-a-cool-netbeans-shortcut</link>
		<comments>http://kalali.me/shiftaltenter-a-cool-netbeans-shortcut/#comments</comments>
		<pubDate>Thu, 14 Jun 2007 14:44:09 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Full Screen]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=280</guid>
		<description><![CDATA[Today accidentally I find a coll shortcut in NetBeans, it do something fun, if you press ALT+SHIFT+ENTER IDE switch to full screen, it will remove Title bar, status bar, and toolbar to give you a little more space when you are writing your code. Here is an image of netbeans in this mode, you will [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>Today accidentally I find a coll shortcut in NetBeans, it do something fun, if you press ALT+SHIFT+ENTER IDE switch to full screen, it will remove Title bar, status bar, and toolbar to give you a little more space when you are writing your code.</p>
<p>Here is an image of netbeans in this mode, you will find it usefull.</p>
<p><a href="http://weblogs.java.net/blog/kalali/archive/images/full-screen.png" class="fancyboxgroup" rel="gallery-280"><img src="http://weblogs.java.net/blog/kalali/archive/images/full-screen-thumb.png" alt="full-screen-thumb.png" width="250" height="200" /></a></p>
<p>Also If you are looking for some NetBeans sample you can take a look at <a href="http://www.netbeans.org/kb/samples/index.html">NetBeans IDE Sample Applications</a> which is a good start point for you to find some ready to run samples for different platform from java SE to RoR which is fully supported in NetBeans 6.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/shiftaltenter-a-cool-netbeans-shortcut/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>something fun in Feisty Fawn</title>
		<link>http://kalali.me/something-fun-in-feisty-fawn/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=something-fun-in-feisty-fawn</link>
		<comments>http://kalali.me/something-fun-in-feisty-fawn/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 14:54:04 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Feisty Fawn]]></category>
		<category><![CDATA[Linx]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=278</guid>
		<description><![CDATA[It is sometimes that I use Ubuntu in home as primary OS, a shortcut that I am used to use is ALT+Space to minimize, maximize or restore a window. But in Ubuntu or maybe in Gnome, It is my first time that i use Gnome as primary desktop, this key combination act differently. When I [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>It is sometimes that I use Ubuntu in home as primary OS, a shortcut that I am used to use is ALT+Space to minimize, maximize or restore a window. But in Ubuntu or maybe in Gnome, It is my first time that i use Gnome as primary desktop, this key combination act differently.</p>
<p>When I pressed ALT+Space as i used to do it and it showd a semi transparent window which let me select one of application links that are present in Gnome/Ubuntu menu a link to some web site, a folder in my home directory or something else which i have not descovered yet.</p>
<p>The opened window allows you shows all menu items that begins with your typed character and let you select your target shortcut</p>
<p>Here is an screenshot of this window. a wonderful thingy, by the way maybe it is not Gnome built in feature and one of additional packages that i installed add it to Gnome.</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/fun_with_ubunut.png" alt="fun_with_ubunut.png" width="484" height="330" /></p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/something-fun-in-feisty-fawn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GlassFish version 2 monitoring capabilities</title>
		<link>http://kalali.me/glassfish-version-2-monitoring-capabilities/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=glassfish-version-2-monitoring-capabilities</link>
		<comments>http://kalali.me/glassfish-version-2-monitoring-capabilities/#comments</comments>
		<pubDate>Sun, 27 May 2007 18:29:24 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[AMX]]></category>
		<category><![CDATA[Connection Leak]]></category>
		<category><![CDATA[JMX]]></category>
		<category><![CDATA[JVM]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=276</guid>
		<description><![CDATA[GlassFish version 2 monitoring capabilities GlassFish version 2 provides good mentoring information about different aspects of application server and all of your applications that are deployed into GlassFish but before it can show those statistical information you need to configure its monitoring service. Figure 1. Although this statistical and monitoring information and the way that [...]]]></description>
			<content:encoded><![CDATA[</p>
<h3>GlassFish version 2 monitoring capabilities</h3>
<p>GlassFish version 2 provides good mentoring information about different aspects of application server and all of your applications that are deployed into GlassFish but before it can show those statistical information you need to configure its monitoring service. Figure 1.</p>
<p>Although this statistical and monitoring information and the way that they are presented is not as luxurious as weblog and websphere one&#8217;s but they are good enought to help you track what is going in your server.</p>
<p>To enable monitoring service of GlassFish you need Commence with openning administration console, Locate the configuration node and expand it now select monitoring now choose all components that you want to monitor, select high for more details and sure more overhead and low for less details and less overhead. Figure 1.</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/gf_monit_f1.png" alt="Configure your monitoring" /></p>
<p>Now you should be able to see some monitoring detailsby going to monitoring pages, monitorig pages are placed under different nodes in administration console based on your installation profile. If you are not sure about your glassfish profile, follow the developer profile item.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>For the cluster or enterprise profile In the tree component, select Common Tasks, then click View Monitoring Data.</li>
<li>For the developer profile, in the tree component, select the Application Server node. Click the Monitor tab.</li>
</ul>
<p>Glassfish categorize monitoring information under three categories, these categories are as follow:</p>
<p><strong>Call Flow:</strong>shows you how many requests are replyed successfully or with a failure and how much time consumed for that request in different layer of application server. Figure 2</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/gf_monit_f2.png" alt="Call Flow" /></p>
<p><strong>Runtime:</strong>this category provides information about JVM, Garbage Collection, HTTP service, Listeners (http/s), ect. for example under JMV node of these category you can use memory item to view fine grained details about your application server heap. Figure 3</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/gf_monit_f3.png" alt="Runtime" /></p>
<p><strong>Applications:</strong>Let you select an application and view details about that application components, for example you can view how much time a servlet has called and how time its call taked. Figure 4</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/gf_monit_f4.png" alt="Applications" /></p>
<p><strong>Resources:</strong>here you can view detailed information about all of your resources like connection pools, connectors, jms connection factories, etc. For example you can view fair amount of details about your connection pool in order to hunt possible connection leake or to tune your connection pool. Figure 5</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/gf_monit_f5.png" alt="Resources" /></p>
<p><strong>Transactions:</strong>These allows you to view what is state of transactions that are running inside your application server.</p>
<p>It is my first blow entry written from my Ubuntu 7.04 installation and I am happy with my switch from OpenSuse to Feisty Fawn <img src='http://kalali.me/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/glassfish-version-2-monitoring-capabilities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to install and  use OpenSSO CLI (Command Line Administration Interface)</title>
		<link>http://kalali.me/how-to-install-and-use-opensso-cli-command-line-administration-interface/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-install-and-use-opensso-cli-command-line-administration-interface</link>
		<comments>http://kalali.me/how-to-install-and-use-opensso-cli-command-line-administration-interface/#comments</comments>
		<pubDate>Thu, 17 May 2007 19:34:32 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[OpenSSO]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=274</guid>
		<description><![CDATA[OpenSSO  which is open source branch of Sun Java Access Manager has several module which you should install and configure in case that you want to have similar bundle from its open source branch. One of main components is OpenSSO itself which you can obtain from  Its nightly builds page; just make sure to select [...]]]></description>
			<content:encoded><![CDATA[</p>
<p><a href="https://opensso.dev.java.net">OpenSSO</a>  which is open source branch of Sun Java Access Manager has several module which you should install and configure in case that you want to have similar bundle from its open source branch.</p>
<p>One of main components is OpenSSO itself which you can obtain from  <a href="http://download.java.net/general/opensso/nightly/amserver">Its nightly builds page</a>; just make sure to select <strong>latest</strong> link which will take you to the download page with links to OpenSSO modules.<br />OpenSSO file name should be <strong>OpenSSO.war</strong>; this file is server side application that handle all authentication and authorization related activities. in the download page you can see several other modules, for this blog entry I will give you some details about installing OpenSSO and <strong> Administration Command Line Tools. </strong>((It should be last row link in component download page).</p>
<p>To install OpenSSO, you can follow a detailed installation instruction in <a href="http://blogs.sun.com/aorhan/resource/installation-guide.pdf">OpenSSO easy installation</a> just make sure that you remember value that you determined for  <strong>Configuration directory </strong>because we will use it to install CLI (<strong>C</strong>ommand <strong>L</strong>ine administration <strong>I</strong>nterface).</p>
<p>Now that you have installed OpenSSO you can install its CLI package. Download <strong>amAdminTools.zip </strong>and extract it somewhere in your hard dist. after you have extracted it follow this sequence to complete its installation open a terminal (cmd)  and navigate to directory that you extract the <strong>amAdminTools.zip; </strong>execute: setup -p  &lt;OPENSSO_CONFIGURATION_DIRECTORY&gt;</p>
<p>It should echo some text indicating that installation is successful. If you want to know more, Installation is nothing more than creation of batch files that I will talk about one of  them in next step. this batch files use some files that are located in opensso configuration directory to perform their operations.</p>
<p>the file that I will talk about is named <strong>amadm.bat </strong>or <strong>amadm.sh </strong>this file let you manage your OpenSSO installation from a command line interface even if opensso server is running. all sub commands of this command has a set of 2 common parameter</p>
<p style=" -qt-block-indent:1;">
<ol>
<li>-u amAdmin : this is default administration username. you can create more users with administration privileges.</li>
<li>-w &lt;password&gt; it is your password which you determined during opensso installation.</li>
</ol>
<p>Now lets try some commands</p>
<pre><code> amadm.bat create-realm -e /realm12 -u amAdmin -w adminadmin </code>
</pre>
<p>This command will create a new realm and put its parent is root realm.</p>
<pre><code> amadm.bat list-realms -e / -u amAdmin -w adminadmin </code>
</pre>
<p>This command list all realms that are created under parentship of root realm.</p>
<pre><code> amadm.bat list-identities -e / -x &quot;*&quot; -t User -u amAdmin -w adminadmin </code>
</pre>
<p>This command list all identities of type User which are exists in root realm. you can find a list of all sub commands by calling</p>
<pre><code> amadm.bat </code>
</pre>
<p>By default root realm is named openSSO and your created realm will be a child of that realm, Now you can open openSSO web based administraton console and check the result of CLI with it</p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/how-to-install-and-use-opensso-cli-command-line-administration-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What happend to JavaRSS.com?</title>
		<link>http://kalali.me/what-happend-to-javarss-com/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=what-happend-to-javarss-com</link>
		<comments>http://kalali.me/what-happend-to-javarss-com/#comments</comments>
		<pubDate>Fri, 11 May 2007 19:56:06 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[hacked]]></category>
		<category><![CDATA[JavaRSS]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=272</guid>
		<description><![CDATA[It is some times that http://www.javarss.com/ is not as it was before, indeed it looks to be hacked or something like that. What I really want to know is, what will happen next? why its host provider did not take any action  to remove this ugly page from the web site front page? I hope [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>It is some times that <a href="http://www.javarss.com/"> http://www.javarss.com/</a> is not as it was before, indeed it looks to be <a href="http://en.wikipedia.org/wiki/Hack">hacked</a> or something like that. What I really want to know is, what will happen next? why its host provider did not take any action  to remove <a href="http:/weblogs.java.net/blog/kalali/archive/images/java_rss.JPG" class="fancyboxgroup" rel="gallery-272">this</a> ugly page from the web site front page?</p>
<p>I hope website owner could find a way to make it functional again.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/what-happend-to-javarss-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A scenario based tutorial about using NetBeans BPEL, JBI and Web service developemt features</title>
		<link>http://kalali.me/a-scenario-based-tutorial-about-using-netbeans-bpel-jbi-and-web-service-developemt-features/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-scenario-based-tutorial-about-using-netbeans-bpel-jbi-and-web-service-developemt-features</link>
		<comments>http://kalali.me/a-scenario-based-tutorial-about-using-netbeans-bpel-jbi-and-web-service-developemt-features/#comments</comments>
		<pubDate>Fri, 11 May 2007 17:03:43 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[BPEL]]></category>
		<category><![CDATA[Case Study]]></category>
		<category><![CDATA[JMS]]></category>
		<category><![CDATA[OpenESB]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[WSDL]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=270</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://kalali.me/a-scenario-based-tutorial-about-using-netbeans-bpel-jbi-and-web-service-developemt-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NetBeans 6 M7 released. There are some cool features available and cool modules in UC.</title>
		<link>http://kalali.me/netbeans-6-m7-released-there-are-some-cool-features-available-and-cool-modules-in-uc/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=netbeans-6-m7-released-there-are-some-cool-features-available-and-cool-modules-in-uc</link>
		<comments>http://kalali.me/netbeans-6-m7-released-there-are-some-cool-features-available-and-cool-modules-in-uc/#comments</comments>
		<pubDate>Thu, 22 Feb 2007 07:11:50 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=268</guid>
		<description><![CDATA[NetBeans 6 milestone 7  has released and you can download it from NetBeans web site by at least two methods Traditional setup file for separate packs using new NetBeans installer which allows you to customize your package before you download it. Traditional method for downloading NetBeans 6 which is a development build is using http://www.netbeans.info/downloads/dev.php [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>NetBeans 6 milestone 7  has released and you can download it from NetBeans web site by at least two methods</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Traditional setup file for separate packs</li>
<li>using new NetBeans installer which allows you to customize your package before you download it.</li>
</ul>
<p>Traditional method for downloading NetBeans 6 which is a development build is using <a href="http://www.netbeans.info/downloads/dev.php" title="http://www.netbeans.info/downloads/dev.php"> http://www.netbeans.info/downloads/dev.php</a> and the new installer which I am going to talk about is available at <a href="http://nbi.netbeans.org/" title="http://nbi.netbeans.org/"> http://nbi.netbeans.org/</a> .<br /><a href="http://pack.google.com/">Google pack</a> installer is somehow similar to new NetBeans installer. In one simple paragraph it allows you to customize what you need in one mega installer and then you can download your customized package to your local machine to install those components into your system.<br />features that new installer has and I really like them are as follow (sure you may find some there feature that I have not mentioned )</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Download what you need by customizing the download package.</li>
</ul>
<p><span style=" color:#ff0000;"> </span><img src="http://kajcarpet.com/mimages/nb6_m7_image1.jpg" alt="Download section" width="884" height="362" /><span style=" color:#ff0000;">.</span></p>
<p style=" -qt-block-indent:1;">
<ul>
<li>From bundle that you have download you may not install all of them at the same time.</li>
</ul>
<p><img src="http://kajcarpet.com/mimages/nb6_m7_image2.jpg" alt="Installer first round" width="650" height="500" /></p>
<p>When you choose to install glassfish you have option to select its path, ports, and default JDK which are important options.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>You are allowed to uninstall some of components when you do not need them by running the installer again.</li>
</ul>
<p><img src="http://kajcarpet.com/mimages/nb6_m7_image3.jpg" alt="Uninstalling" width="650" height="500" /></p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Installer register any component that you install into other components (Application server, mobility features,&#8230;.).</li>
<li>Tight integration with windows <em>add or remove programs.</em></li>
<li>And many other features that I do not noticed yet.<em><br /></em></li>
</ul>
<p>But there are some other cool changes in NetBeans IDE, look what we have as our icon set, it remind me some of Firefox themes with fantasy icons. I hope we could see some modularity mechanism for icons which will allows NetBeans fans to develop some new icon set or use older version of icon set. <br /><a href="http://kajcarpet.com/mimages/nb6_m7_image4.jpg" class="fancyboxgroup" rel="gallery-268"> </a><a href="http://kajcarpet.com/mimages/nb6_m7_image4.jpg" class="fancyboxgroup" rel="gallery-268"><img src="http://kajcarpet.com/mimages/nb6_m7_image4_small.jpg" alt="new icons" width="208" height="175" /></a></p>
<p>Based on <a href="http://wiki.netbeans.org/wiki/view/NB6FeaturePlan" title="NetBeans 6 Feature Plan"> NetBeans 6 Feature Plan</a>  we will have RoR and JavaScript support in NetBeans 6 M7, so this features should be inside our downloaded IDE or in update center, lets look and see what does we have in NetBeans new project and file and also in update centers.<br />Yes, we have JavaScript and ROR support built-in. </p>
<p>Lets see what else we can find in update center that is not available for 5.5.* or in NetBeans 6 M7 out of the box.</p>
</p>
<table border="0" cellspacing="2" cellpadding="0">
<tr>
<td>
<p align="left"><img src="http://kajcarpet.com/mimages/nb6_m7_image5.jpg" alt="RoR" width="299" height="319" /></p>
</td>
<td>
<p align="left">As you can see RoR support is available in update center. <br />If you are one of those RoR fans you should be happy now.</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"><img src="http://kajcarpet.com/mimages/nb6_m7_image6.jpg" alt="Languages" width="302" height="459" /></p>
</td>
<td>
<p align="left">Ok, there are tens of new language support based on new common scripting language support.<br />Support for this languages is in several levels, from syntax highlight to code completion.<br />you can try one that you need and if you find it useful you can vote for this future. NetBeans development team will value community inputs.</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"><img src="http://kajcarpet.com/mimages/nb6_m7_image7.jpg" alt="Maven support" width="643" height="467" /></p>
</td>
<td>
<p align="left">There are some other good module which i have selected to be installed. As you can see Maven support is there too.</p>
</td>
</tr>
</table>
<p> </p>
<p>OK, what that really amazed me about new modules for NetBeans IDE is Jasper Report Visual designer, Its really cool to see a report designer for jasper report integrated into NetBeans.</p>
<p>I know that it has some basic integration but it is the initial release of this really cool module. here are some images of Jasper report designer integrated into NetBeans.</p>
<p><a href="http://kajcarpet.com/mimages/jarvis.jpg" class="fancyboxgroup" rel="gallery-268"> </a><a href="http://kajcarpet.com/mimages/jarvis.jpg" class="fancyboxgroup" rel="gallery-268"><img src="http://kajcarpet.com/mimages/jarvis_small.jpg" alt="jarvis" width="200" height="162" /></a></p>
<p>the project home page is <a href="https://jarvis.dev.java.net/" title="https://jarvis.dev.java.net/"> https://jarvis.dev.java.net/</a> credits goes to developer of this really required module.</p>
<p>NetBeans 6 release is as amazing as NetBeans 5 release was.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/netbeans-6-m7-released-there-are-some-cool-features-available-and-cool-modules-in-uc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hibernate dynamic mapping and Dom4J enabled sessions</title>
		<link>http://kalali.me/hibernate-dynamic-mapping-and-dom4j-enabled-sessions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hibernate-dynamic-mapping-and-dom4j-enabled-sessions</link>
		<comments>http://kalali.me/hibernate-dynamic-mapping-and-dom4j-enabled-sessions/#comments</comments>
		<pubDate>Sun, 11 Feb 2007 20:23:50 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Persistence]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Dom4j]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[MAP]]></category>
		<category><![CDATA[POJO]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=266</guid>
		<description><![CDATA[Hibernate from version 3.0? provide a very useful feature for people who develop application frameworks. Indeed this feature allows you to work directly with XML documents and elements which represent entities.Imagine that you have an application or an SDK which help users to manipulate data from different RDBMSs. Hibernate provide rich configuration facilities which help [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>Hibernate from version 3.0? provide a very useful feature for people who develop application frameworks. Indeed this feature allows you to work directly with XML documents and elements which represent entities.<br />Imagine that you have an application or an SDK which help users to manipulate data from different RDBMSs. Hibernate provide rich configuration facilities which help you configure  Hibernate dynamically in term of adding mapping data or other configuration artifacts that usually stores in hibernate.cfg.xml or equal properties files.</p>
<p>As we are planning to use Hibernate dynamic mapping and Dom4J entity mode i am going to blog about it during my evaluation.<br />OK, Hibernate provide 3 kinds of entity mode</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>POJO</li>
<li>DOM4J</li>
<li>MAP</li>
</ul>
<p> Default mode sets to be POJO as it is most commonly used mode. This modes tell session how it should handle entities. We can configure a session to use any of this modes when we need that mode, but we can configure it in hibernate configuration file for by adding a property like</p>
<pre>
 &lt;property name=&quot;default_entity_mode&quot;&gt;dom4j&lt;/property&gt;</pre>
<p> To hibernate.cfg.xml . but for our sample we will create a session with dom4j entity mode. you can find a complete sample for this blog entry <a href="http://weblogs.java.net/blog/kalali/archive/files/Dynamic-Mapping.zip" title="Hibernate dom4j entity mode sample">here</a> . Make sure that you read readme file in project folder before you go toward executing it. For this sample I used <a href="http://www.netbeans.org" title="Netbeans 6.0">Netbeans 6.0</a> M6 (which really rules) and <a href="http://www.hibernate.org" title="Hibernate 3.2.1">Hibernate 3.2.1</a> . I wont tell steps to create project, XML file or &#8230; but just actions and core required for hibernate side. you can see project structure in the following  image.</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/hibernate_dom4j_1_1.JPG" alt="Hibernate dom4j session project structure" width="245" height="389" /></p>
<p>As you can see it is a basic ant based project.<br />Let me give you content of each file and explain about it as much as i could. First of all lets see what we have in hibernate.cfg.xml</p>
<pre>
 &lt;?xml version='1.0' encoding='utf-8'?&gt; &lt;!DOCTYPE hibernate-configuration
 PUBLIC &quot;-//Hibernate/Hibernate Configuration DTD//EN&quot;
 &quot;http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd&quot;&gt;
 &lt;hibernate-configuration&gt;
     &lt;session-factory &gt;
         &lt;property name=&quot;hibernate.connection.driver_class&quot;&gt;com.mysql.jdbc.Driver&lt;/property&gt;
         &lt;property name=&quot;hibernate.connection.url&quot;&gt;jdbc:mysql://localhost/hiberDynamic&lt;/property&gt;
         &lt;property name=&quot;hibernate.connection.username&quot;&gt;root&lt;/property&gt;
         &lt;property name=&quot;hibernate.connection.password&quot;&gt;root&lt;/property&gt;
         &lt;property name=&quot;hibernate.c3p0.min_size&quot;&gt;5&lt;/property&gt;
         &lt;property name=&quot;hibernate.c3p0.max_size&quot;&gt;20&lt;/property&gt;
         &lt;property name=&quot;hibernate.c3p0.timeout&quot;&gt;300&lt;/property&gt;
         &lt;property name=&quot;hibernate.c3p0.max_statements&quot;&gt;50&lt;/property&gt;
         &lt;property name=&quot;hibernate.c3p0.idle_test_period&quot;&gt;3000&lt;/property&gt;
         &lt;property name=&quot;dialect&quot;&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
         &lt;!--&lt;property name=&quot;default_entity_mode&quot;&gt;dom4j&lt;/property&gt; --&gt;
         &lt;mapping resource=&quot;dynamic/Student.hbm.xml&quot;/&gt;
     &lt;/session-factory&gt;
 &lt;/hibernate-configuration&gt;
</pre>
<p> The configuration file is a simple and traditional hibernate configuration file with pooling enabled and  dialect sets to MySQL ones.<br />We have one mapping file which is named <em>student.hbm.xml </em>so we include it into the configuration file. If you do not have MySQL around then use Derby which is included into NetBeans <img src='http://kalali.me/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  .</p>
<pre>
 Log4J configuration is another traditional one, as you see
 log4j.appender.stdout=org.apache.log4j.FileAppender
 log4j.appender.stdout.File=messages_dynamic.log
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
 log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
 log4j.rootLogger=WARN, stdout
 </pre>
<p>We used a file appender which send formatted log entry into a file named messages_dynamic.log in project root directory. next file which we are going to take a look is <em>Student.hbm.xml  </em>it is our mapping file, where we define the student as a dynamic entity.</p>
<pre>
 &lt;?xml version=&quot;1.0&quot;?&gt;
 &lt;!DOCTYPE hibernate-mapping PUBLIC
 &quot;-//Hibernate/Hibernate Mapping DTD//EN&quot;
 &quot;http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd&quot;&gt;

 &lt;hibernate-mapping&gt;
     &lt;class  entity-name=&quot;Student&quot; table=&quot;Student&quot;&gt;
         &lt;id name=&quot;id&quot; column=&quot;STUDENT_ID&quot; type=&quot;long&quot;&gt;
             &lt;generator class=&quot;native&quot;/&gt;
         &lt;/id&gt;
         &lt;property  name=&quot;name&quot; type= &quot;string&quot;  column=&quot;STUDENT_NAME&quot;/&gt;
         &lt;property name=&quot;lastName&quot; type=&quot;string&quot; column=&quot;STUDENT_LAST_NAME&quot; /&gt;
     &lt;/class&gt;
 &lt;/hibernate-mapping&gt;
</pre>
<p> As you  can see there is just one change in  mapping file, we have entity-name attribute instead of class attribute. You should know that can have both class and entity-name attribute so an entity could be dynamic or mapped to a concrete class.</p>
<p>Next step is looking at our HibernateUtil which is known to the community for Hibernate booting and  hibernate instance management.<br />here is its code:</p>
<pre>

 package persistence;
 import org.hibernate.*;
 import org.hibernate.cfg.*;

 public class HibernateUtil {
   
     private static SessionFactory sessionFactory;
     static {
         try {
             sessionFactory = new Configuration().configure().buildSessionFactory();
        } catch (Throwable ex) {
             throw new ExceptionInInitializerError(ex);
         }
     }
    
     public static SessionFactory getSessionFactory() {
         return sessionFactory;
     }
     public static void shutdown() {
        
         getSessionFactory().close();
     }
 }
 </pre>
<p>Noting extra here. lets look at last part in which we try to use dom4j session to manipulate our data.</p>
<p></p>
<pre>
 package dynamic;
 import java.util.*;
 import org.hibernate.EntityMode;
 import org.hibernate.Query;
 import org.hibernate.Session;
 import org.hibernate.Transaction;
 import persistence.HibernateUtil;
 import org.dom4j.*;

 public class DynamicMapping {
    
     public static void main(String[] args) {
         Session session = HibernateUtil.getSessionFactory().openSession().getSession(EntityMode.DOM4J);
         Transaction tx = session.beginTransaction();
 Query deleteQuery = session.createQuery(&quot;delete from Student&quot;);
 deleteQuery.executeUpdate();
 tx.commit();

 tx = session.beginTransaction();
         //create some some student and save them
         {
             Element anStudent = DocumentHelper.createElement(&quot;Student&quot;);
             Element nameElement = DocumentHelper.createElement(&quot;name&quot;);
             nameElement.setText(&quot;Alice&quot;);
            
             Element lastNameElement = DocumentHelper.createElement(&quot;lastName&quot;);
             lastNameElement.setText(&quot;Cooper&quot;);
            
             anStudent.add(nameElement);
             anStudent.add(lastNameElement);
             session.save(anStudent);
         }
         {
             Element anStudent = DocumentHelper.createElement(&quot;Student&quot;);
             Element nameElement = DocumentHelper.createElement(&quot;name&quot;);
             nameElement.setText(&quot;Lea&quot;);
            
             Element lastNameElement = DocumentHelper.createElement(&quot;lastName&quot;);
             lastNameElement.setText(&quot;Connor&quot;);
            
             anStudent.add(nameElement);
             anStudent.add(lastNameElement);
             session.save(anStudent);
         }
        
         tx.commit();
         //List all student
         Query q = session.createQuery(&quot;from Student &quot;);
        
         List students = q.list();
         org.dom4j.Element el = (org.dom4j.Element)students.get(0);
         System.out.println(el.getText());
         for (Iterator it = students.iterator(); it.hasNext();) {
             org.dom4j.Element student = (org.dom4j.Element)it.next();
            
            
             System.out.println(&quot;Printing an Student details: &quot;);
            
             for ( Iterator i = student.elementIterator(); i.hasNext(); ) {
                 Element element = (Element) i.next();
                 System.out.println( element.getName()+&quot;:  &quot;+ element.getText());
             }
         }
         //retrieve an student, update and save it
        
         q = session.createQuery(&quot;from Student where  name =:studentName &quot;);
         q.setParameter(&quot;studentName&quot;, &quot;Alice&quot;);
         Element alice = (Element) q.uniqueResult();
        
         alice.element(&quot;name&quot;).setText(&quot;No Alice any more&quot;);
         tx=session.beginTransaction();
         session.save(alice);
         tx.commit();
        
         session.close();
         HibernateUtil.shutdown();
     }
 }
 </pre>
<p>In the begging we create a session with dom4j entity mode. so it will return Dom4J elements as our entities. in next two blocks i have create two students one is <em>Alice Cooper </em>and the other is <em>John connor  </em>(what does this name remind you? <img src='http://kalali.me/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  . we simply ask our session to save them as we do for usual POJO mode. Session know what to do with dom4j elements as it is configured as a DOM4J session.<br />In Second block we query our table and retrieve all entities into a list, but this list is not a list of Student POJOs instead it is a list of DOM4J elements. so we need to do some XML processing when we want to extract our entity properties. you can learn more about DOM4J at <a href="http://www.dom4j.org/guide.html" title="Dom4j guide">Here</a> .</p>
<p>Next step we retrieve a single row, edit and save it into our database, Its all simple DOM4J operation which you should use over some elements to manipulate your data.</p>
<p>Build file that i used contains two target that we will use during this project. first one is hbm2ddl which will create our database structure and the second one is run target which will execute our main class. it is not required to include build file here  you can download the sample and check it yourself. make sure you look at readme file before digging into execution of application.</p>
<p>In next few days I will try to do a simple benchmark for some simple CRUD operation to have a basic clue about DOM4J entity mode in our environment.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/hibernate-dynamic-mapping-and-dom4j-enabled-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jonas Joins to Netbeans supported application servers</title>
		<link>http://kalali.me/jonas-joins-to-netbeans-supported-application-servers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jonas-joins-to-netbeans-supported-application-servers</link>
		<comments>http://kalali.me/jonas-joins-to-netbeans-supported-application-servers/#comments</comments>
		<pubDate>Sun, 17 Sep 2006 16:52:24 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Java EE]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[JonAS]]></category>
		<category><![CDATA[JOnbAS]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=264</guid>
		<description><![CDATA[Jonas Joins to Netbeans supported Application serversBy release of first public version of JOnbAS List of netbeans supported application servers growth to Sun java application server (Glassfish) JBoss application server Tomcat servlet container WebLogic application server JonAs application server and im sure this is a growing list.by my experiences , Netbeans has very good support [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>Jonas Joins to Netbeans supported Application servers<br />By release of first public version of <a href="http://jonbas.sourceforge.net/" title="It is home page for JOnbAS Netbeans Module"><strong>JOnbAS</strong></a> List of netbeans supported application servers growth to</p>
<p style=" -qt-block-indent:1;">
<ol>
<li>Sun java application server (Glassfish)</li>
<li>JBoss application server</li>
<li>Tomcat servlet container</li>
<li>WebLogic application server</li>
<li>JonAs application server</li>
</ol>
<p>and im sure this is a growing list.<br />by my experiences , Netbeans has very good support for application server.<br />specially its support for Glassfish (Sun microsystem itself application server) outstanding.<br />with the current module you can :</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Starting and stopping the server</li>
<li>Java and JSP debugging</li>
<li>Generating the default server specific deployment descriptors</li>
<li>Deploying, undeploying the Web, EJB and EAR modules</li>
<li>Browsing the deployed WAR, EJB and EAR modules</li>
</ul>
<p>which is almost enough.</p>
<p>I think sooner or later we will see good support for <a href="http://geronimo.apache.org" title="Geronimo application server">Geronimo</a> , <a href="http://www.caucho.com/" title="Resin application server">Resin</a> and <a href="http://www.mortbay.org/" title="Jetty servlet container">Jetty</a> as contributed or independed modules, and it is that time which Netbeans application server support has no reason not be the best.</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/jonas-joins-to-netbeans-supported-application-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Netbeans 5.5 and Jdeveloper 10.1.3.1 both sounds very good&#8230;</title>
		<link>http://kalali.me/netbeans-5-5-and-jdeveloper-10-1-3-1-both-sounds-very-good/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=netbeans-5-5-and-jdeveloper-10-1-3-1-both-sounds-very-good</link>
		<comments>http://kalali.me/netbeans-5-5-and-jdeveloper-10-1-3-1-both-sounds-very-good/#comments</comments>
		<pubDate>Fri, 25 Aug 2006 10:45:54 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Comparison]]></category>
		<category><![CDATA[JDeveloper]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Compare]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=262</guid>
		<description><![CDATA[Netbeans 5.5 and Jdeveloper 10.1.3.1 which one ?Both Jdeveloper and Netbeans that i am talking about them are in beta and developer preview stage.Netbeans as an Opensource IDE has its own fast growing user community. Netbeans 5.5 beta 2 let features include : develop and deploy on tomcat / Glassfish and Jboss out of the [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>Netbeans 5.5 and Jdeveloper 10.1.3.1 which one ?<br />Both Jdeveloper and Netbeans that i am talking about them are in beta and developer preview stage.<br />Netbeans as an Opensource IDE has its own fast growing user community.</p>
<p><strong>Netbeans 5.5 beta 2 let features include :</strong></p>
<p style=" -qt-block-indent:1;">
<ul>
<li>develop and deploy on tomcat / Glassfish and Jboss out of the box.</li>
<li>As core features it has many code generation facilitis which can help to bootstrap an application ,it has code generation for CMPs , session facades ,ws client stub&#8230;.</li>
<li>Having an almost first class profiler , first class J2me development pack</li>
<li>New c/c++ development pack</li>
<li>good support for SVN and CVS</li>
<li>very good Swing designer</li>
<li>developer collaboration module</li>
<li>Heavy support of SUN by giving the source codes for some of its extra pack</li>
</ul>
<p>which Made NetBeans a good choice for developers.</p>
<p>One of the packs that donated by sunÂ· is Enterprise pack , Enterprise pack features in brief are as follow :</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>UML 2 compliant modeler</li>
<li>visual BPEL</li>
<li>visual WSDL designer</li>
<li>xml visual tools for xml schema declaration &#8230;</li>
<li>facilities to develop web service and apply security on them.</li>
</ul>
<p>Sun announced that it will add Java Studio creator to NetBeans Stack as another package.<br />having Creator can attract many users to Netbeans as it provide a rich set of feature for web application developers.</p>
<p><strong>but what about Oracle JDeveloper 10.1.3.1?<br /></strong>some times ago Oracle announced that it will let developers to use JBeveloper for free . so Jdeveloper and Netbeans from one point of view are the same ,<strong>You will not pay any penny for them.<br /></strong>Oracle really boosts JDeveloper in recent years which made JDeveloper a choice for j2ee application developers <br />JDeveloper Editor has changed to a very powerful editor with a good refactoring support.<br />opposite to Netbeans which you need to download several package to gain most of its feature you will not need to download any extra package to make use of jdeveloper as it is appropriated.<br />Â·</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Oracle have much more code generation falsities that Netbeans .</li>
<li>visual ESB modeling allows you to assemble you ESB component visually (its ESB is not JBI compliant)</li>
<li>visual WSDL designer</li>
<li>visual xml development tools</li>
<li>good swing designer and data binding using oracle ADF</li>
<li>good JSF / Struts support , indeed Jdeveloper JSF support with its ADF faces is brilliant.</li>
<li>WYSIWYG for HTML and jsp pages with support of third party jsf libraries like Myfaces.</li>
<li>first class database development facilities ( for oracle database mostly).</li>
<li>Only you can use oracle server suite as development server there is no support for other application servers.</li>
<li>No support for c/c++ development (AFAIK).</li>
<li>built-in profiler</li>
<li>very powerful web page generation which can bootstrap a data driven web page design.</li>
<li>UML modeler (1.4 compliant)</li>
<li>very rich set of facilities for Web service development</li>
<li>&#8230;</li>
</ul>
<p>I think JDeveloper (for now) is ahead of NetBeans as it provide much more facilities for developers , but for later version we can not tell anything because NetBeans people are unpredictable , as they prove their credibility by release of NetBeans 5.</p>
<p>What you have read is my opinion which might be biased. we never can say that one IDE is 100% better than another , it is just context oriented and the users view point. but one thing is completely obvious that JDeveloper and NetBeans both are going to provide rich facilities for SOA. NetBeans by means ofÂ· Enterprise pack and using glassfish with integrated BPMS from intalio andÂ· what it has acquired from seebyond.<br />and oracle with its SOA suite and JDeveloper , both are going to make choice harder for developers.</p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/netbeans-5-5-and-jdeveloper-10-1-3-1-both-sounds-very-good/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Develop web application with netbeans ,seam and Glassfish</title>
		<link>http://kalali.me/develop-web-application-with-netbeans-seam-and-glassfish/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=develop-web-application-with-netbeans-seam-and-glassfish</link>
		<comments>http://kalali.me/develop-web-application-with-netbeans-seam-and-glassfish/#comments</comments>
		<pubDate>Tue, 15 Aug 2006 08:35:41 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Persistence]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Seam]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=260</guid>
		<description><![CDATA[In this two part series I will try to show you how easily you can  build applications using NetBeans 5.5 based on  seam , facelets , jsf and new EJB 3 standard. I will not discuss any of framework in details as you can find detailed information about each of them in their homepage and [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>In this two part series I will try to show you how easily you can  build applications using NetBeans 5.5 based on  seam , facelets , jsf and new EJB 3 standard.</p>
<p>I will not discuss any of framework in details as you can find detailed information about each of them in their homepage and some other articles.<br />I want just show , How you can use NetBeans with some leading frameworks to build your web based applications. I will not discuss NetBeans specific tasks in details .<br />I will more focus on leveraging this stuff together using NetBeans IDE.</p>
<p><strong>What you will need to follow  this series :</strong></p>
<p style=" -qt-block-indent:1;">
<ul>
<li>NetBeans enterprise edition 5.5 , you will need Glassfish or JBoss to continue with this series. check and make sure that your NetBeans has application server bundled otherwise get a copy of glassfish from its website.</li>
<li>seam 1.0.1 GA  or newer.</li>
</ul>
<p>seam distribution contain Facelets too , but i strongly suggest you get Facelets distribution separately and take a look at its samples and very good documentation. indeed both Facelets and seam has very good documentation.</p>
<p>In this entry I will introduce each of this frameworks in very brief  to make the series stand alone , and i will show you how to setup the development environment and we will go with first part which is developing seam layer codes.</p>
<p>JBoss seam is created to leverage maximum possible feature of Java EE 5 standards like JSF and EJB3.<br />seam , seamlessly integrate EJB3 as a backend with JSF as presentation , meanwhile provide management of long running process <br />by using JBPM . and give you ability to focus on your business logic rather than silly data providing stuff. By leveraging Facelets helps you to do even more with seam and JSF.</p>
<p><strong>To name its features I can say:</strong></p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Lesser XML, More Annotation. (please do not blame me for naming annotation and XML in one line <img src='http://kalali.me/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> )</li>
<li>it let you go with your business logic rather thinking and resolving some common issue like user conversation state.</li>
<li>seam has a more flexible context model , it has 8 context , by means of this context you can manage your application more effective. for example a business process live in business process context .</li>
<li>Accessing each component in entire seam context with one unique name.</li>
<li>Managing workplaces and conversations .</li>
<li>It easily will let you develop Portlet by providing a Portlet context . we will discuss this item in latter parts</li>
</ul>
<p>With many more features.</p>
<p>But about JSF , JSF is  a web framework , it is  Standard and  Developed under JSR 127.<br /><strong>Some of JSF features are as follow:</strong></p>
<p style=" -qt-block-indent:1;">
<ul>
<li> User interface framework</li>
<li> Server-side UI components</li>
<li> Event model , something like desktop applications event model , but very reduced.</li>
<li> Component state</li>
<li> Renderers , Render Kits , for example ADF faces has a telnet render which make it possible to render a ADF faces application for a  telnet client.</li>
<li> Validation</li>
<li> Type conversion</li>
<li> Internationalization</li>
</ul>
<p>about Facelets , we will discuss more in next articles , but for now you should know that Facelets bring some view related enhancement and features to JSF community . <br /><strong>To name some of features :</strong></p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Facelets make it possible to develop your entire web pages using your favorite page designer like Dream weaver or Microsoft FrontPage. to achieve this feature it introduce a new attribute, jsfc ,that make it possible to change each html element  to a JSF equal component. it is similar to Tapestry &#8216;s <code>jwcid</code> attribute. So you can use all binding and event handling stuff of JSF and availability and ease of use of html WYSIWYG.</li>
<li>Facelets provide a template-ing  features like Velocity&#8217;s for JSF . it allows you to test JSF views out of container.</li>
<li>Some decoration features like what tile bring to struts community and SiteMesh ,generally, to all java based web application.</li>
</ul>
<p>lets start the job of creating simplest sample <img src='http://kalali.me/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  .</p>
<p>I assume that you download seam and extract it in seam_home Also your NetBeans 5.5 is running and an application server capable of  containing ejb3 (Glassfish) is configured with your IDE.</p>
<p>for sake of simplicity we make one   Library in our NetBeans IDE to make our job easier. as you know each library could contain some jar files, etc&#8230;</p>
<p><strong>Create a library name it seam and add the following jar files to it , the first <br /></strong>seam_homejboss-seam.jar<br />seam_homejboss-seam-ui.jar<br />seam_homehibernate-all.jar<br />seam_homethirdparty-all.jar</p>
<p>add seam library  to Registeration-EJBModule and Registeration-WebModule</p>
<p>Switch to runtime view (CTRL+5).Extend database node  , if you have no database created in your embedded derby  then create a database and create a table with following  characteristics<br />Table Name: users<br />Fields :</p>
</p>
<table border="1" width="46%" cellspacing="2" cellpadding="0">
<tr>
<td width="168">
<p align="left">username </p>
</td>
<td>
<p align="left">varcahr(255) , primary key</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">password</p>
</td>
<td>
<p align="left">varchar(255) , not null</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">name</p>
</td>
<td>
<p align="left">varcahr(255) , not null</p>
</td>
</tr>
</table>
<p>after you create this table , create a new enterprise application project by going to , file&gt;new project&gt;enterprise application<br />name it Registeration. make sure that you have selected the Java EE 5 as j2ee version.</p>
<p>go to project view (CTRL+1) And select Registeration-ejbModule , right click on it and select <strong>CMP entity bean from database&#8230;</strong> <br />Now you should be able to select the JDBC connection that you have made in above step and give it a package name.<br />click next and select users table from left column and add it to right column.<br />click finish.<br />That&#8217;s it , you have your CMP ready to go.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>what we need to add to the CMP bean class in addition to its created structure</li>
<li>another constructor with all the CMP  fields.</li>
<li>some annotation for getters , to help us in validation</li>
</ul>
<p>final shape of users CMP will be like :</p>
<p> </p>
<pre>

package cmps;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
/**
 *
 * @author Masoud Kalali
 */
@Entity
@Name(&quot;user&quot;)
@Scope(org.jboss.seam.ScopeType.SESSION)
@Table(name=&quot;users&quot;)
public class Users implements Serializable{
   private static final long serialVersionUID = 1881413500711441951L;
    private String username;

    private String password;

    private String name;

    /** Creates a new instance of Users */
    public Users() {
    }

    public  Users(String name, String password, String username)
 {
this.name = name;
this.password = password;
this.username = username;
}

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = &quot;username&quot;, nullable = false)
     @Length(min=5, max=15)
    public String getUsername() {
        return this.username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Column(name = &quot;password&quot;, nullable = false)
     @Length(min=5, max=15)
    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = &quot;name&quot;, nullable = false)
     @Length(min=5, max=15)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
</pre>
<p> </p>
<p>we are finished with our POJO EJB <img src='http://kalali.me/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  , now lets go and handle web layer stuff , from now we are working with seam view layer and JSF , I will talk about Facelets later in other articles of this series.</p>
<p>as I said in sample scenario we have just one action , so we can use a  managed bean or plain java object or whatever that is useable here as action listener or use a stateless session bean (using session bean is what JBoss offer) so we will use a stateless session bean to implement our action listener , it will also helps you to see how an stateless session bean is implemented in java EE 5.<br />so create a session bean by using , <strong>file &gt; new &gt; session bean , </strong>now you can select session bean type to be stateless , and change the package name to be <strong>sbeans<br /></strong>click finish  , editor will open up and show you the stateless seasion bean class.    <br />change the class body , in a way that final class looks like :</p>
<pre>
import cmps.Users;
import java.util.List;

import javax.ejb.Stateless;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.hibernate.validator.Valid;
import org.jboss.seam.annotations.Factory;

import org.jboss.seam.annotations.IfInvalid;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Outcome;
import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.core.FacesMessages;
import org.jboss.seam.ejb.SeamInterceptor;

@Stateless
@Name(&quot;&quot;)
public class ActionBean implements sbeans.ActionLocal
{

   @IfInvalid(outcome=Outcome.REDISPLAY)
   public String ()
   {
      List existing = em.createQuery(&quot;select username from User where username=:username&quot;)
         .setParameter(&quot;username&quot;, user.getUsername())
         .getResultList();
      if (existing.size()==0)
      {
         em.persist(user);
         return &quot;success&quot;;
      }
      else
      {
         FacesMessages.instance().add(&quot;User #{user.username} already exists&quot;);
         return &quot;success&quot;;
      }
   }

}</pre>
<p><span style=" font-family:'Times New Roman';">we will need to add same method signature to our session bean local interface , so add the method signature to </span><span style=" font-family:'Times New Roman';"><em> ActionLocal </em></span><span style=" font-family:'Times New Roman';">class. it will looks like :</span></p>
<pre>
package sbeans;

/**
 * This is the business interface for Action enterprise bean.
 */
public interface ActionLocal {
      public String ();
}
</pre>
<p><span style=" font-family:'Times New Roman';">now we are finished with the action , you may ask what are those annotation stuff in the session bean , so I should ask you to take a look at seam reference or wait until next part of this series. I should say that it is a very same version of seam sample that is implemented again in NetBeans IDE.</span><br /><span style=" font-family:'Times New Roman';">we are finished with EJBModule for now , lets take a look at what we will have in web module. first of all you need to add JSF framework to web module to do this , right click on web module and select properties , go to frameworks node and add JSF framework to the project. In web module we just have 2 JSF pages , one to , one to show the that s/he ed . Create following JSF files ,</span></p>
<table border="1" width="100%" cellspacing="2" cellpadding="0">
<tr>
<td width="123">
<p align="left"><span style=" font-family:'Times New Roman';"> register.jsp</span> </p>
</td>
<td>
<p align="left">same as seam sample register.jsp , used for registering purpose</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"><span style=" font-family:'Times New Roman';">registered.jsp</span></p>
</td>
<td>
<p align="left">same as seam sample registered.jsp , used for showing the user that he/she is ed</p>
</td>
</tr>
</table>
<p dir="ltr"><span style=" font-family:'Times New Roman';">we need to add some navigation case to our faces-config.xml , so extend web module note and under configuration files open the faces-config.xml we should add 4 navigation case to it , so right click inside the editor ,which show content of faces-config.xml, and select add navigation rule. a dialog will open , just fill the dialog as following table show</span></p>
<table border="1" width="100%" cellspacing="2" cellpadding="0">
<tr>
<td>
<p align="left">Rule From View </p>
</td>
<td>
<p align="left">/register.jsp</p>
</td>
</tr>
</table>
<p><span style=" font-family:'Times New Roman';">Now right click in the editor and add 4 new navigation case , these cases will handle navigating from one view to another. </span></p>
<table border="1" width="100%" cellspacing="2" cellpadding="0">
<tr>
<td>
<p align="left">From View </p>
</td>
<td>
<p align="left">From Outcome</p>
</td>
<td>
<p align="left">To view</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">/register.jsp</p>
</td>
<td>
<p align="left">success</p>
</td>
<td>
<p align="left">registered.jsp</p>
</td>
</tr>
</table>
<p><span style=" font-family:'Times New Roman';">lets code with the register.jsp , open the register.jsp in your NetBeans editor change the content to : </span></p>
<pre>
&lt;%@ taglib uri=&quot;http://java.sun.com/jsf/html&quot; prefix=&quot;h&quot; %&gt;
&lt;%@ taglib uri=&quot;http://java.sun.com/jsf/core&quot; prefix=&quot;f&quot; %&gt;
&lt;%@ taglib prefix=&quot;s&quot; uri=&quot;http://jboss.com/products/seam/taglib&quot;%&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt; New User&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;f:view&gt;
&lt;h:form&gt;
&lt;table border=&quot;0&quot;&gt;
              &lt;s:validateAll&gt;
&lt;tr&gt;
&lt;td&gt;Username&lt;/td&gt;
&lt;td&gt;&lt;h:inputText id=&quot;username&quot; value=&quot;#{user.username}&quot; required=&quot;true&quot; /&gt;&lt;/td&gt;
&lt;td&gt;      &lt;h:message for=&quot;username&quot;/&gt;       &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Real Name&lt;/td&gt;
&lt;td&gt;&lt;h:inputText  id=&quot;name&quot; value=&quot;#{user.name}&quot; required=&quot;true&quot; /&gt;&lt;/td&gt;
&lt;td&gt;      &lt;h:message for=&quot;name&quot;/&gt;       &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Password&lt;/td&gt;
&lt;td&gt;&lt;h:inputSecret id=&quot;password&quot; value=&quot;#{user.password}&quot;  required=&quot;true&quot; /&gt;&lt;/td&gt;
&lt;td&gt;      &lt;h:message for=&quot;password&quot;/&gt;       &lt;/td&gt;
&lt;/tr&gt;
          &lt;/s:validateAll&gt;
&lt;/table&gt;
&lt;h:messages globalOnly=&quot;true&quot;/&gt;
&lt;h:commandButton type=&quot;submit&quot; value=&quot;&quot; action=&quot;#{.}&quot;/&gt;
&lt;/h:form&gt;
&lt;/f:view&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>No we need to create the registered.jsp which show that our user is registered. open the file in your editor and change its content to looks like :</p>
<pre>
&lt;%@ taglib uri=&quot;http://java.sun.com/jsf/html&quot; prefix=&quot;h&quot; %&gt;
&lt;%@ taglib uri=&quot;http://java.sun.com/jsf/core&quot; prefix=&quot;f&quot; %&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Successfully ed New User&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;f:view&gt;
Welcome, &lt;h:outputText value=&quot;#{user.name}&quot;/&gt;,
you are successfully ed as &lt;h:outputText value=&quot;#{user.username}&quot;/&gt;.
&lt;/f:view&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Now we are almost finished with JSf files , there are some changes that we should make in web.xml and faces-config.xml.first open web.xml and add the following lines to it.make sure the you add them directly inside &lt;web-app&gt; node.</p>
<pre>
 &lt;context-param&gt;
		&lt;description&gt;
		&lt;/description&gt;
		&lt;param-name&gt;org.jboss.seam.core.init.jndiPattern&lt;/param-name&gt;
		&lt;param-value&gt;java:comp/env/registration/#{ejbName}/local&lt;/param-value&gt;
&lt;/context-param&gt;

&lt;listener&gt;
	&lt;listener-class&gt;org.jboss.seam.servlet.SeamListener&lt;/listener-class&gt;
&lt;/listener&gt;

&lt;ejb-local-ref&gt;
	&lt;ejb-ref-name&gt;registration/RegisterActionBean/local&lt;/ejb-ref-name&gt;
	&lt;ejb-ref-type&gt;Session&lt;/ejb-ref-type&gt;
	&lt;local&gt;sbeans.RegisterActionLocal&lt;/local&gt;
&lt;	ejb-link&gt;RegisterActionBean&lt;/ejb-link&gt;
&lt;/ejb-local-ref&gt;
</pre>
<p>Now open faces-config.xml and add the following lines to it.</p>
<pre>
&lt;lifecycle&gt; &lt;phase-listener&gt;org.jboss.seam.jsf.SeamPhaseListener&lt;/phase-listener&gt; &lt;/lifecycle&gt;
</pre>
<p>That&#8217;s it , you are finished creating your first seam sample in netbeans , lets execute the application and see the result. press f6 and wait until your browser opens , navigate to <a href="http://localhost:8080/Registration-WebModule/faces/index.jsp"> http://localhost:8080/Registration-WebModule/faces/register.jsp</a> enter some information and then press register button.</p>
<p>You can check whether it applied or not by switching to runtime view and checking your Users table data . you can find complete explanation of jsp/java codes in Seam tutorial chapter 1 at : <a href="http://docs.jboss.com/seam/1.0.0.GA/reference/en/html/tutorial.html"> http://docs.jboss.com/seam/1.0.0.GA/reference/en/html/tutorial.html</a></p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/develop-web-application-with-netbeans-seam-and-glassfish/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Step by Step toward a jms sample in NetBeans and yes GlassFish. part 2 :  Remote Client</title>
		<link>http://kalali.me/step-by-step-toward-a-jms-sample-in-netbeans-and-yes-glassfish-part-2-remote-client/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=step-by-step-toward-a-jms-sample-in-netbeans-and-yes-glassfish-part-2-remote-client</link>
		<comments>http://kalali.me/step-by-step-toward-a-jms-sample-in-netbeans-and-yes-glassfish-part-2-remote-client/#comments</comments>
		<pubDate>Wed, 10 May 2006 09:31:03 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[JMS]]></category>
		<category><![CDATA[queue]]></category>
		<category><![CDATA[Remote Client]]></category>
		<category><![CDATA[topic]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=258</guid>
		<description><![CDATA[In previous part you saw that how easy is to make an MDB to consume messages and a jsp/Servlet Front End to send message to a queue.in this part i will show you how you can send message to a queue from a remote j2se client. you should know that in jms sending and reciving [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>In previous part you saw that how easy is to make an MDB to consume messages and a jsp/Servlet Front End to send message to a queue.<br />in this part i will show you how you can send message to a queue from a remote j2se client. you should know that in jms sending and reciving mesages has similar steps , some small changes require to consume message from a j2se client instead of sending messages.<br />to make it more clear , the main purpose of an MDB is to consume messages as they arrive , The MDB <em>onMessage(..)</em> is called whenever a message become available in destination that MDB is binded to it.</p>
<p>sure we can do what ever we want after message recieved. for example you can send the message that you recive from a queue to several topics , you can process it to do some database operation&#8230;. usually we use JMS for executing Asynchronous operations ,bringing more decoupling of a system components&#8230;.</p>
<p>but lets come to our own steps to create a simple remote client that will sends some messages to <strong>tQueue</strong> that we made in <a href="http://weblogs.java.net/blog/kalali/archive/2006/05/step_by_step_to.html">first part</a> of this series. then we will see that our messages are reciveing by TMDB. As you know we used a context object to locate the <strong>Queue </strong>and <strong>ConnectionFactory </strong>. the servlet code was like:</p>
<pre>
...
  Context ctx = new InitialContext();
...
</pre>
<p>By default a JNDI client assume that it is in a correctly configured environment , so when we do not pass a <em>HatshTable </em> to IinitialContext , the InitialContextFactory will return a context configured with that environment .In server environment we do not need to explicity pass parameters to InitialContext unless we need to initiate a context for another environment.<br />But, what are this parameters and how we can use them to initiate a context for none default environemtn or in places that there is no default environemt pre-configured , situation like standalone remote clients? <br />in a such situation we should configure the <strong>InitialContext</strong> using a HashTable that contain some parameters, There are several parameter that can be used to configure the initialContext but Two most important ones are :</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>provider url , for glassfish in iiop format it is : <em>iiop://127.0.0.1:3700</em> We can use a key like <strong>Context.PROVIDER_URL</strong> to put its value into hashtable , also we may use <strong>java.naming.provider.url</strong> String to put value of this parameter into HashTable . this parameter is vendor dependent. </li>
<li>initial context factory , for glassfish it is : <em>com.sun.appserv.naming.S1ASCtxFactory</em> This is another important parameter that we must set before we can access a JNDI Tree , indeed it is totaly vendor dependent because each vendor has its own implementation for its JNDI access. This factory will create the context object along with the url that you put into the hashtable. we may use Context.INITIAL_CONTEXT_FACTORY or &quot;java.naming.factory.initial&quot; string as a key to put this value into the hashtable</li>
</ul>
<p>As i said there are some other parameters that you can set , like security parameters for authentication and &#8230;. but those are not necessary.<br />I should tell that we can also make this parameter to be the jvm default parameter and allows the Initialcontext to return a context without need to pass any arguments. in this way we need to pass parameters to java command when we want to start it. for example you can use :<br />java -Djava.naming.provider.url=&quot;iiop://127.0.0.1:3700&quot; -Djava.naming.factory.initial=&quot;com.sun.appserv.naming.S1ASCtxFactory&quot; to start our application. this way you allows the Initialcontext to return a context without need to configure it by a HashTable. For our Sample we will use a hashtable to configure the InitialContext , but you can try to pass parameters to java instead and observ the execution of your application.<br />To create a j2se remote client we need to add some jar files to our project , <a href="http://www.netbeans.org">NetBeans </a> provide its own way to manage jar files that may be used in more than one project. it is Libraries&#8230;. <br />Run NetBeans, From <strong>Tools</strong> menu select <strong>Library Manager</strong> , create a new library and name it <strong>jms</strong> . Now you can add as much jar files to this library as you need , then it will be reuseable for your other projects. <br />add following jar files to this library , I use glassfish_home as installation directory of glassfish.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>glassfish_home/lib/appserv-rt.jar</li>
<li>glassfish_home/lib/javaee.jar</li>
<li>glassfish_home/lib/install/applications/jmsra/jmsra.jar</li>
<li>glassfish_home/lib/install/applications/jmsra/imqbroker.jar</li>
<li>glassfish_home/imq/lib/imq.jar</li>
<li>glassfish_home/lib/appserv-admin.jar</li>
<li>glassfish_home/imq/lib/jms.jar</li>
</ul>
<p>Create a j2se project using , File &gt; new project &gt; general &gt; java application. name the application jmsClient and allow the IDE to create a Main class for you.<br />You shoud add that library that you create to this project. to do this , expand the project node , right click on the libraries and select add library Now from the library list select jms .<br />Up to now you have done 30% of creating an stand alone remote client to interact with your jms resources like connectionFactories and destinations.<br />Now we need to code the main method of main class . expand the jmsClient node , expand the source packages and finally open the main class of your project. <br />The overall look of your code shoul be like the following :</p>
<pre>
public class JmsClient {
    Context ctx;
    public JmsClient() {
        Hashtable properties = new Hashtable(2);
        properties.put(Context.PROVIDER_URL,&quot;iiop://127.0.0.1:3700&quot;);
        properties.put(Context.INITIAL_CONTEXT_FACTORY,&quot;com.sun.appserv.naming.S1ASCtxFactory&quot;);
        try {
            ctx = new InitialContext(properties);
        } catch (NamingException ex) {
            ex.printStackTrace();
        }
    }
   public Object lookup(String name){
        try {
            return ctx.lookup(name);
        } catch (NamingException ex) {
            ex.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        JmsClient client = new JmsClient();
        try{
            ConnectionFactory     connectionFactory = (ConnectionFactory)client.lookup(&quot;jms/tConnectionFactory&quot;);
            Queue     queue = (Queue)client.lookup(&quot;jms/tQueue&quot;);
            javax.jms.Connection  connection = connectionFactory.createConnection();
            javax.jms.Session        session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
            MessageProducer messageProducer = session.createProducer(queue);
            for(int i=0;i&lt;5;i++) {
                TextMessage message = session.createTextMessage(&quot;It is a message from main class &quot;+  &quot;: &quot;+ i);
                System.out.println( &quot;It come from main class:&quot;+ message.getText());
                messageProducer.send(message);
            }
        } catch(Exception ex){
            ex.printStackTrace();
        }
    }
}
</pre>
<p>Now lets see what the above code means , i will not go indepth because JMS APIs are discussed too much <img src='http://kalali.me/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  . <br />In constructor we configured a context object named ctx<br />we encapsulate the lookpu task in a method named <em>lookup(&#8230;)</em> we usually use a service locator or cached service locator to locate our objects in JNDI because JNDI lokups are time consumer<br />In main method:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>we create a ConnectionFactory by looking it up in the jndi by using our context and dummy <strong>lookup(&#8230;)</strong> method.</li>
<li>we create a Queue by looking it up in the jndi by using our context and dummy <strong>lookup(&#8230;)</strong> method.</li>
<li>Then we create a connection using that ConnectionFactory</li>
<li>we obtain a Session (jms Session) using our connection</li>
<li>we made the messageproducer which is our tools to send message to that Queue ,</li>
<li>in a loop we create and sent 5 text message to the queue.</li>
</ul>
<p>Now lets run the program and see the result , to run the application you nedd to complete the <a href="http://weblogs.java.net/blog/kalali/archive/2006/05/step_by_step_to.html">first part</a> of this series , then you should run the application server , and if you like to have a demonestration like what i will show you , you should deploy the application that we made in first part. <br />i assume you have completed first part and you have the application server running , Now run the client that we made and what you will see in output window should be like : </p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/nb_jms_client2.JPG" title="output window, generated by main class in stand alone application" /></p>
<p>and if you take a look at application server log file (in runtime tab , expand the servers node and rigt click on the <a href="http://glassfish.dev.java.net">glassfish </a> instance , now select view server log..) what you should see in the server log should be something like : </p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/nb_jms_client1.JPG" title="server log window, generated by TMDB" /></p>
<p>messages that we send via standalone client will reach the queue that the MDB is listening on it , as soon as we send a message MDB will pick it up and start processing it. <br />you can download the standalone client project from <a href="http://weblogs.java.net/blog/kalali/archive/jmsClient.zip">here</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/step-by-step-toward-a-jms-sample-in-netbeans-and-yes-glassfish-part-2-remote-client/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>GlassFish is Open source , but how much Open it is ?</title>
		<link>http://kalali.me/glassfish-is-open-source-but-how-much-open-it-is/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=glassfish-is-open-source-but-how-much-open-it-is</link>
		<comments>http://kalali.me/glassfish-is-open-source-but-how-much-open-it-is/#comments</comments>
		<pubDate>Tue, 09 May 2006 05:37:00 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[licenses]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=256</guid>
		<description><![CDATA[We know that GlassFish is opensource under CDDL license , being opensource is good but having a good and open relation with community is very good. GlassFish has the most active community between opensource project that i have been involve a bit closer than observing , having that TheAquarium weblog make it magnifisant.Meanwhile you think [...]]]></description>
			<content:encoded><![CDATA[<p>We know that <a href="https://glassfish.dev.java.net/" title="GlassFish"><strong>GlassFish</strong></a> is opensource under CDDL license , being opensource is good but having a good and open relation with community is very good. <br />GlassFish has the most active community between opensource project that i have been involve a bit closer than observing , having that <a href="http://blogs.sun.com/roller/page/theaquarium" title="TheAquarium">TheAquarium </a>weblog make it magnifisant.Meanwhile you think that that weblogs is available in more that 3 languages, and it shows how much hard GlassFish people works to provide community with information that they need.<br />its <a href="http://wiki.java.net/bin/view/Projects/GlassFish" title="Wiki">Wiki</a> is a great source of information and shows how much far GlassFish people goes in making a good communication with the community.<br />wiki pages update very often , you will find new information in its wiki / weblogs whenever you look at them.I think there is more with this glassfish to reveal than being just reference implementation of <strong>Java EE 5</strong>. <br />if you check <a href="http://blogs.sun.com/roller/page/theaquarium" title="TheAquarium">TheAquarium </a> in a daily basis you will see that Glassfish components are going to Maven repository of java .net very fastly , and it means that we can use maven for our project which are based on java ee 5.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/glassfish-is-open-source-but-how-much-open-it-is/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Step by Step toward a jms sample in NetBeans and yes GlassFish</title>
		<link>http://kalali.me/step-by-step-toward-a-jms-sample-in-netbeans-and-yes-glassfish/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=step-by-step-toward-a-jms-sample-in-netbeans-and-yes-glassfish</link>
		<comments>http://kalali.me/step-by-step-toward-a-jms-sample-in-netbeans-and-yes-glassfish/#comments</comments>
		<pubDate>Fri, 05 May 2006 10:10:18 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[JMS]]></category>
		<category><![CDATA[MDB]]></category>
		<category><![CDATA[queue]]></category>
		<category><![CDATA[topic]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=254</guid>
		<description><![CDATA[Java EE 5 brings many ease of use in EJB development world and certainly it is one of biggest step ahead in java EE land.NetBeans 5.5 is another big step toward making development on top Java EE some easier. NetBeans is a very easy to learn and use because it does not bring many stuff [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>Java EE 5 brings many ease of use in EJB development world and certainly it is one of biggest step ahead in java EE land.<br />NetBeans 5.5 is another big step toward making development on top Java EE some easier. NetBeans is a very easy to learn and use because it does not bring many stuff on the screen to <strong>&quot;Occupy all the space&quot;</strong> instead it provide maximum useability by means of limited number of views.<br />GlassFish as Reference implementation of JAVA EE 5 , provide you with all service that are named in java EE spec but it is not similar to older RI version of J2EE ,just remember J2EE 1.3 RI <br />it is much more better in term of functionality, performance, ease of use and &#8230;<br />here I will tell you steps that you need to follow to build a simple MDB , a web based message producer and a remote message producer.</p>
<p>when you follow this entry you will be able to deal with basic aspect of JMS in Action and not only on your papers. but what do we need to have our JMS application running ?</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>A JMS implementation that is configured with our server , it can be done using embedded servers that are shipped with application servers or using remote / local MQ servers.<br />GlassFish uses Sun message Queue , which is going to be available under the same license that GlassFish is provided. You can find more information about open source version at : <a href="http://mq.dev.java.net" title="http://mq.dev.java.net">http://mq.dev.java.net</a></li>
<li>You also need to setup a Queue and a connection factory in your application server.<span style=" color:#ff0000;">* </span></li>
<li>you should Create an MDB , and then implement the onMessage() method in way that you like.</li>
</ul>
<p><span style=" color:#ff0000;">*</span>I should tell you that you can create your Queue and connection factory in many ways , yes more than two ways .</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>use GlassFish server web based administration console</li>
<li>use GlassFish command line console</li>
<li>using NetBeans 5.5 , yes NetBeans provide you some wizard thingy to make JMS / JDBC resources from withing NetBeans and then registering them to Application server.</li>
</ul>
<p>I assume you know NetBeans and you registered GlassFish as an application server in <strong>NetBeans server manager</strong> <br />To create Queue and connection follow these steps :</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Run The IDE and go to runtime tab , expand server node and start the GlassFish instance.</li>
<li>right click on GlassFish node and select <strong>view admin console</strong></li>
<li>login to admin console ,In left side navigation panel , expand the resources and expand JMS resources</li>
<li>click on <strong>connection factories</strong> and from main frame click on new button , fill in the values as following ones </li>
<p style=" -qt-block-indent:2;">
<ul type="circle">
<li>JNDI Name: jms/tConnectionFactory</li>
<li>Type: javax.jmsConnectionFactory<span style=" color:#ff0000;"> **</span></li>
<li>Description: some description here</li>
<li>give it a name like : tConnectionFactory</li>
<li>Click OK button</li>
</ul>
<p style=" -qt-block-indent:1;"><span style=" color:#ff0000;">**</span> in JMS 1.1 we can use same factory for both publish/subscribe and point-to-point messaging </p>
<li>now we need to create a queue to be our messages destination, click on <strong>destination resources</strong> from main frame click on new and fill in the values as following ones </li>
</ul>
<p style=" -qt-block-indent:2;">
<ul type="circle">
<li>JNDI Name: jms/tQueue</li>
<li>Type: javax.JMS.Queue</li>
<li>Description: some description here</li>
<li>give it a name like : tQueue</li>
<li>Click Save button</li>
</ul>
<p>Now we have our JMS Configuration ready to serve some MDB and remote client. Create a new enterprise application with two kind of modules , one EJB module and one web module , name it whatever you want but I named this sample <strong>jms</strong> <br />go to project view , right click on EJB module and select <strong>NewMessage-Driven Bean&#8230;</strong> <br />a window will open and ask you for some attributes of this MDB fill in the names like :</p>
<p style=" -qt-block-indent:1;">
<ul>
<li><strong>EJB Name :</strong> TMDB</li>
<li><strong>package :</strong> mdbs</li>
<li><strong>Mapped Name</strong> : jms/tQueue<span style=" color:#ff0000;">***</span></li>
</ul>
<p>click finish and you are done , your MDB skeleton is ready and you just need to implement the <em>onMessage(&#8230;)</em> method.<br /><span style=" color:#ff0000;">***</span> This is where our MDB is assigned to , whether it is a topic in publish/subscribe scenario or a queue in point-to-point scenario.<br />Now change the implementation of your <em>onMessage(&#8230;)</em> as following , we also add one private object to our class , make sure that you include it too.</p>
<pre>
  @Resource
    private MessageDrivenContext mdc;
    public void onMessage(Message message) {

        TextMessage msg = null;
        try {
            if (message instanceof TextMessage) {
                msg = (TextMessage) message;
System.out.println(&quot;A Message received in TMDB: &quot; +
                        msg.getText());
            } else {
               System.out.println(&quot;Message of wrong type: &quot; +
                        message.getClass().getName());

            }
        } catch (JMSException e) {
            e.printStackTrace();
            mdc.setRollbackOnly();
        } catch (Throwable te) {
            te.printStackTrace();
        }
    }
</pre>
<p>we just made one more change in class skeleton and that is our MessageDrivenContext variable , we usually use this to call setRollbackOnly(&#8230;) when we use an MDB in a transactional scenario for this sample you simpley can ignore it.<br />Now lets make our web application to send some messages to that Queue and let the MDB fetch and process them. <br />wxpand web application node , and double click on index.jsp after it opens , change its content like the following , sure you can use component platte to drag and drop items to jsp source file <img src='http://kalali.me/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
<pre>&lt;%@page contentType=&quot;text/html&quot;%&gt;

&lt;%@page pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;
   &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html&gt;
    &lt;head&gt;

        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
        &lt;title&gt;JSP Page&lt;/title&gt;

    &lt;/head&gt;
    &lt;body&gt;
&lt;center&gt;
&lt;form action=&quot;sendMessage&quot;&gt;
            &lt;table  cellspacing=&quot;20&quot; &gt;

                &lt;tbody&gt;
                    &lt;tr&gt;
                        &lt;td&gt;Enter some message: &lt;/td&gt;
                        &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;message&quot; value=&quot;Enter your message here&quot; width=&quot;30&quot; /&gt;&lt;/td&gt;

                    &lt;/tr&gt;
                &lt;/tbody&gt;
            &lt;/table&gt;

                &lt;input type=&quot;submit&quot; value=&quot;Send The message&quot; name=&quot;send&quot; /&gt;

            &lt;/center&gt;
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Now we need to build a servlet , which will send messages to our Queue , for this task you need to do these steps :</p>
<p style=" -qt-block-indent:1;">
<ol>
<li>Right click on web application node and select <strong>New &gt; Servlet&#8230;</strong></li>
<li>change its <strong>Name</strong> to <em>sendMessage</em> give it a package name and click finish</li>
<li>change the <em>processRequest(..)</em> method body as following list</li>
</ol>
<pre>
 protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType(&quot;text/html;charset=UTF-8&quot;);
        PrintWriter out = response.getWriter();
        //start the jms stuff

        try{
            Context ctx = new InitialContext();
            ConnectionFactory     connectionFactory = (ConnectionFactory)ctx.lookup(&quot;jms/tConnectionFactory&quot;);
            Queue     queue = (Queue)ctx.lookup(&quot;jms/tQueue&quot;);
            javax.jms.Connection  connection = connectionFactory.createConnection();
            javax.jms.Session        session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
            MessageProducer messageProducer = session.createProducer(queue);
            TextMessage message = session.createTextMessage();
            message.setText(request.getParameter(&quot;message&quot;));
            System.out.println( &quot;It come from Servlet:&quot;+ message.getText());
            messageProducer.send(message);

//message sent , it was all

            //show what we have done in this servlet
            out.println(&quot;&lt;html&gt;&quot;);
            out.println(&quot;&lt;head&gt;&quot;);
            out.println(&quot;&lt;title&gt;Servlet sendMessage&lt;/title&gt;&quot;);
            out.println(&quot;&lt;/head&gt;&quot;);
            out.println(&quot;&lt;body&gt;&quot;);
            out.println(&quot;&lt;center&gt;&quot;);
            out.print(&quot;Servlet Send this message &lt;h2&gt;&quot;+request.getParameter(&quot;message&quot;) + &quot;&lt;/h2&gt;  to this Queue : &lt;h2&gt;&quot;+queue.getQueueName()+&quot;&lt;/h2&gt;&quot;);
            out.println(&quot;&lt;/center&gt;&quot;);
            out.println(&quot;&lt;/body&gt;&quot;);
            out.println(&quot;&lt;/html&gt;&quot;);

        } catch(Exception ex){
            ex.printStackTrace();
        }

        out.close();
    }
</pre>
<p>It was all you should do to create a JMS point to point sample. <br />to view what you have Done , press F6 , if you did all the above as i said you will see a page like :</p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/nb_jms1.JPG" title="Index web page , where you enter your message" /></p>
<p>Now just give it a message and press the button , what you will see should looks like the following image , in case that your praise the NetBeans and GlassFish as i did <img src='http://kalali.me/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  </p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/nb_jms2.JPG" title="result web page , generated by servlet " /></p>
<p>and if you look at Application server log file , you will see something similar to : (to view the application server log file go to runtime view , right click on glassfish node and select view log file) </p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/nb_jms3.JPG" title="result web page , generated by servlet " /></p>
<p>You can download the project from <a href="http://weblogs.java.net/blog/kalali/archive/jms.zip"> here</a> but make sure that you build the connection factory and queue because project will need them . <br />In next part i will show you how easily you can make a remote client to deal with your jms destinations.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/step-by-step-toward-a-jms-sample-in-netbeans-and-yes-glassfish/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Simply backup  and restore your domains in GlassFish Using GlassFish Command Console</title>
		<link>http://kalali.me/simply-backup-and-restore-your-domains-in-glassfish-using-glassfish-command-console/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=simply-backup-and-restore-your-domains-in-glassfish-using-glassfish-command-console</link>
		<comments>http://kalali.me/simply-backup-and-restore-your-domains-in-glassfish-using-glassfish-command-console/#comments</comments>
		<pubDate>Tue, 25 Apr 2006 20:53:46 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[restore]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=252</guid>
		<description><![CDATA[Do you ever though about creating a backup copy of your domains in GlassFish , for example before doing something unpredictable , meanwhile you like your domain because of its configurations ?here is simple steps to create backup and restore those backup. before we go any further you should know , domaindir that we see [...]]]></description>
			<content:encoded><![CDATA[<p>Do you ever though about creating a backup copy of your domains in GlassFish , for example before doing something unpredictable , meanwhile you like your domain because of its configurations ?<br />here is simple steps to create backup and restore those backup. <br />before we go any further you should know , <em>domaindir</em> that we see in many of asadmin commands has a default value its default value is : <em>GlassFish_home/domains</em> , in all of those commands that has domaindir parameter, if you explicitly do not identify the domaindir asadmin will use the default values. So , when you use domain1 in some command , asadmin will look inside GlassFish_home/domains for that particular domain. steps to create a backup :</p>
<p style=" -qt-block-indent:1;">
<ol>
<li>Execute asadmin from bin directory under GlassFish_home<br />in case that you want to create a backup from a domain named domain1 (which is default domain) </li>
<li>execute : <em>backup-domain &#8211;description &quot;I made this backup before changing default domain descriptor&quot; domain1</em><br />after you execute this command , asadmin will create a folder named <em>backups</em> inside GlassFish_home/domains/domain1 and place a zip file there. The zip file is a backup of your domain . For example the zip file could be : <em>sjsas_backup_v00001.zip</em> it means that it is first backup that you create for this domain.<br />if you open the zip file you can see a file named <em>backup.properties</em> which contain informations like : <strong><br />#Backup Status<br />#Wed Apr 26 01:00:40 IRDT 2006<br />timestamp.human=Wed Apr 26 01:00:40 IRDT 2006<br />domain.name=domain1<br />user.name=Masoud Kalali<br />domain.dir=F:\glassfish\domains\domain1<br />domains.dir=F:\glassfish\domains<br />timestamp.msec=1146004240218<br />description=I made this backup before chaning default domain descriptor<br />backup.file=F:\glassfish\domains\domain1\backups\sjsas_backup_v00001.zip<br /></strong> </li>
</ol>
<p><strong>There</strong> is a command which helps you to find out how much backups you have and shows you information related to each backup entry you made.This command is : <em>list-backups</em> it get an operand , the operand will be your domain name. You can also tell it that your domain dir is not the default place using &#8211;domaindir parameter.</p>
<p>Now lets see how we can restore this backup using asadmin administration console.<br />there is a command named <em>restore-domain</em> , this command will restore a domain using a backup file. Simply you need just to pass an operand which is your domain name. If you do this , it will restore your domain using your latest backup .<br /><strong>So</strong> if I execute : <em>restore-domain domain1</em> it will looks inside the backups folder (the default place) and select latest backup then it will try to restore the domain using that backup.<br />you can use &#8211;filename parameter to specify another backup file which should be passed using a full path.<br />I should say that this command accept domaindir parameter as other commands that we talked about them this time.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/simply-backup-and-restore-your-domains-in-glassfish-using-glassfish-command-console/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>overview of XML Parsing in java , different methods and libraries</title>
		<link>http://kalali.me/overview-of-xml-parsing-in-java-different-methods-and-libraries/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=overview-of-xml-parsing-in-java-different-methods-and-libraries</link>
		<comments>http://kalali.me/overview-of-xml-parsing-in-java-different-methods-and-libraries/#comments</comments>
		<pubDate>Mon, 24 Apr 2006 08:30:00 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Comparison]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Dom4j]]></category>
		<category><![CDATA[JAXP]]></category>
		<category><![CDATA[Stax]]></category>
		<category><![CDATA[Xerces]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=250</guid>
		<description><![CDATA[what are different technologies and implementations to simply pars some XML files ?What Java provide you to pars XML files ?Iin this blog entry After answering the above questions , i will introduce (by name and method of parsing) some XML parser available in java land.we may talk more about each of them in next [...]]]></description>
			<content:encoded><![CDATA[<p>what are different technologies and implementations to simply pars some XML files ?<br />What Java provide you to pars XML files ?<br />Iin this blog entry After answering the above questions , i will introduce (by name and method of parsing) some XML parser available in java land.we may talk more about each of them in next entries.<br />First lets see what are different methods to pars XML files. There are Two major XML parsing method , one of them is Old and Standard method using a DOM (Documet Object Model) and the other is Stream and Event Based Parsing.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>In DOM metod we fetch entiere XML document into memory and create a Objective representation of it in the memory then we can traverse the document using a very rich set of methods which DOM interfaces defined. So wen can access the document tree in any time and change its elements or attributes on emand.<br />But it will need a high amount of memory to store the Document Tree , so it is not suitable when you have resource (memory) limitation. as you know Current Browsers use this model, so we can easily use javaScript to access an elements and Change them in runtime base on our needs.Using DOM you can create and write XML files.</li>
</ul>
<p style=" -qt-block-indent:1;">
<ul>
<li>Other model Use Streaming and is event based, what does it means ? it means that it go trough the document from start to end , and as soon as it(the Streaming parser) sees some text nodes , attribute , Maleformed elements&#8230; it will trigger an Event which you are listening for , so it is a one way parsing which in , you can not change the elements or its attributes as you can do in DOM .In Streaming model you do not need a high amount of memory becasue you are not going to create a model of your document in memory.using Stream parsers you can create an XML file.</li>
</ul>
<p>but we should notice that we have Another categorizing for XML parser refer to parser and client communication mechanism , there are two kind of communication mechanism between parsers and client that use those parsers , by this categorizing we have two kind of parses :</p>
<p style=" -qt-block-indent:1;">
<ul>
<li><strong>Push parser</strong></li>
<li><strong>Pull parser</strong></li>
</ul>
<p>Parsers that we have had before StAX are push parsers, which parser push XML data to client whether it needs those data or not or even it is ready to recieve data or not. <br />Pull Parsers which come along with StaX parsers provide another mechanism for letting Client to have the data . it give the ability of asking for XML data to client , so Client will recive Data when it asks for those Data. <br />Now you should know that DOM / SAX are both push parsers , and the only pull parser implementation that i used is StAX.<br />some features that make StAX a suitable parsing method when you need just to pars xml files while there is no need to create or update an XML file, you should know that StAX is one was parser as SAX parsers are.</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>With StAX you can write XML documents too , meanwhile with SAX you can not write XML documents.</li>
<li>using StAX as i will show you in next part is much easier than using SAX</li>
<li>In pull parsing your own code has the control of Parser client Thread becasue its you that engage with Parser MeanWhile in a push parser it is parse that is mainStream in your code becase it parse and give the parsed data back to you whether you ask for it or not</li>
<li>You can works with several XML Streams (parsing and processing them ) in pull parsing mode when your client code is one thread, meanwhile you can not do this in a push parsing mode</li>
</ul>
<p>Now Lets see what XML parsers support which models: </p>
</p>
<table border="1" width="100%" cellspacing="2" cellpadding="0">
<tr>
<td>
<p align="center"><strong>Model / XML Parsing Library</strong> </p>
</td>
<td>
<p align="center"><a href="http://xml.apache.org/crimson/"><strong> Crimson</strong></a><strong> <br />1.1.3</strong></p>
</td>
<td>
<p align="center"><a href="http://xerces.apache.org/xerces-j/"><strong> Xerces</strong></a><strong> <br />1.4.4</strong></p>
</td>
<td>
<p align="center"><a href="http://jaxp.dev.java.net/"><strong>JAXP</strong></a><strong> <br />1.3</strong></p>
</td>
<td>
<p align="center"><strong> </strong></p>
<p dir="rtl" align="center"><a href="http://people.apache.org/~andyc/neko/doc/pull/index.html"><strong> NekoPull</strong></a><a href="http://people.apache.org/~andyc/neko/doc/pull/index.html"><span style=" vertical-align:super;"><strong>1</strong></span></a><strong><br />0.2.4</strong><span style=" vertical-align:super;"><strong>  </strong></span><strong> </strong></p>
</td>
<td>
<p align="center"><a href="http://piccolo.sourceforge.net/"><strong> Piccolo</strong></a><strong> <br />1.04</strong></p>
</td>
<td>
<p align="center"><a href="http://stax.codehaus.org/"><strong>StAX</strong></a><strong> <br />1.2 RC</strong></p>
</td>
<td>
<p align="center"><a href="http://www.dom4j.org/compare.html"><strong> dom4j</strong></a><strong> <br />1.6.1</strong></p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">Push Parsing</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">No</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">No</p>
</td>
<td>
<p align="left">Yes</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">Pull Parsing</p>
</td>
<td>
<p align="left">No</p>
</td>
<td>
<p align="left">No</p>
</td>
<td>
<p align="left">No</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">No</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">No</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">Stream Parsing  implementation (SAX)</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">DOM Parsing implementation</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">Yes</p>
</td>
<td>
<p align="left">No</p>
</td>
<td>
<p align="left">No</p>
</td>
<td>
<p align="left">No</p>
</td>
<td>
<p align="left">Yes</p>
</td>
</tr>
</table>
<p> </p>
<p>1- It Extends  <a href="http://xml.apache.org/xerces2-j/xni.html">XNI</a> to provide pull parsing.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/overview-of-xml-parsing-in-java-different-methods-and-libraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An overview of Different Software development models  with a deeper look at RUP Development model</title>
		<link>http://kalali.me/an-overview-of-different-software-development-models-with-a-deeper-look-at-rup-development-model/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=an-overview-of-different-software-development-models-with-a-deeper-look-at-rup-development-model</link>
		<comments>http://kalali.me/an-overview-of-different-software-development-models-with-a-deeper-look-at-rup-development-model/#comments</comments>
		<pubDate>Thu, 20 Apr 2006 18:57:38 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Methodologies]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[EUP]]></category>
		<category><![CDATA[Iterative]]></category>
		<category><![CDATA[RUP]]></category>
		<category><![CDATA[SDLC]]></category>
		<category><![CDATA[Spiral]]></category>
		<category><![CDATA[Waterfall]]></category>
		<category><![CDATA[XP]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=248</guid>
		<description><![CDATA[Here is an Presentation that i made last year . it is about different lifecycle models like spiral , waterfall and iterative models. this presentation contain following contents : Part I Basics and Explanations Terms and definitions Well known Life Cycle models / Methodologies Waterfall Spiral Iterative XP Part II RUP as a SDP Life [...]]]></description>
			<content:encoded><![CDATA[<p>Here is an Presentation that i made last year . it is about different lifecycle models like spiral , waterfall and iterative models.<br />
this presentation contain following contents :</p>
<p style="-qt-block-indent: 1;">
<ol>
<li><span style="font-size: x-large;"><strong>Part I</strong></span>
<ol>
<li><span style="font-size: x-large;">Basics and Explanations</span></li>
</ol>
<ol>
<li><span style="font-size: large;">Terms and definitions</span></li>
<li><span style="font-size: large;">Well known Life Cycle models / Methodologies</span></li>
</ol>
<ol>
<li>Waterfall</li>
<li>Spiral</li>
<li>Iterative</li>
<li>XP</li>
</ol>
</li>
<p style="-qt-block-indent: 2;">
<p style="-qt-block-indent: 3;">
<p style="-qt-block-indent: 4;">
<li><span style="font-size: x-large;"><strong>Part II</strong></span></li>
</ol>
<p style="-qt-block-indent: 2;">
<ol>
<li><span style="font-size: x-large;">RUP as a SDP Life Cycle Model</span>
<ol>
<li><span style="font-size: large;">Phases and Milestones</span></li>
<li><span style="font-size: large;">RUP and System Evolution</span></li>
</ol>
</li>
<p style="-qt-block-indent: 3;">
<li><span style="font-size: x-large;">EUP (Explanation)</span></li>
</ol>
<p>You can get OO.org ODP from <a title="Here" href="http://dl.dropbox.com/u/334201/jn-blog-files/RUP_lifeCycle.odp">Here</a><br />
Hoping you find it useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/an-overview-of-different-software-development-models-with-a-deeper-look-at-rup-development-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing some FrameWorks and applications on Glassfish build 40+  part V , And some tips about Application deployment</title>
		<link>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40-part-v-and-some-tips-about-application-deployment/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-some-frameworks-and-applications-on-glassfish-build-40-part-v-and-some-tips-about-application-deployment</link>
		<comments>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40-part-v-and-some-tips-about-application-deployment/#comments</comments>
		<pubDate>Tue, 11 Apr 2006 18:32:34 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[DWR]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=246</guid>
		<description><![CDATA[It is a short entry that shows i used DWR Ajax Toolkit On GlassFish But to make the entry a bit more usefull , i would like to tell you how you can deploy an application to GlassFish . so far I know two methods that allows us to deploy application into GlassFish , Using [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>It is a short entry that shows i used <a href="http://getahead.ltd.uk/dwr/" title="DWR Ajax Toolkit">DWR Ajax Toolkit</a> On <a href="http://glassfish.dev.java.net" title="GlassFish ">GlassFish </a> But to make the entry a bit more usefull , i would like to tell you how you can deploy an application to <a href="http://glassfish.dev.java.net" title="GlassFish ">GlassFish </a>. <br />so far I know two methods that allows us to deploy application into <a href="http://glassfish.dev.java.net" title="GlassFish ">GlassFish </a>,</p>
<p style=" -qt-block-indent:1;">
<ol>
<li>Using its web based Admin console which usally run on port 4848</li>
<li>Using the Autodeply library of your desierd Domain</li>
<li>Using Asadmin administration console</li>
</ol>
<p>Lets see how we can deply sample war file of <a href="http://getahead.ltd.uk/dwr/" title="DWR Ajax Toolkit">DWR Ajax Toolkit</a> using each of the above methods. A war file like this one has simplest form of deployment because we have no resource definition , for example there is no datasource , connection pool , jms destination ,&#8230;. which needs to be defined. To start your server goto GlassFish_Home/bin and execute<br /><em>asadmin start-domain</em> it will start the application server default domain , in case that you did not change the administration port then you can access the web based admin console using <a href="http://127.0.0.1:4848/asadmin/admingui/TopFrameset" title="http://127.0.0.1:4848/asadmin/admingui/TopFrameset">http://127.0.0.1:4848/asadmin/admingui/TopFrameset</a> <br />after you loged in just in your left panel click on the web applications node , you will see that content frame shows you all deployed application and also provide some buttons to deploy new web application something like : </p>
<p><a href="http://weblogs.java.net/blog/kalali/archive/images/DWR_1.JPG" class="fancyboxgroup" rel="gallery-246" title="Web based admin console"><img src="http://weblogs.java.net/blog/kalali/archive/images/DWR_1_small.jpg" /></a> </p>
<p>click on deploy and you will see the web application deployment page , here you can browse to WAR file ad select it to be deployed into current Domain.lets do it by selecting DWR.war which we download from DWR website. next image show how the war file deployment will looks like </p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/DWR_2.JPG" title="Web application deployment" /></p>
<p>Now press next , and you will see that DWR is deployed very easily. Now you can naviate to Web applications node and see your DWR entry in web application list , lets check and see how does it works on glassfish.<br />To check that it works on <a href="http://glassfish.dev.java.net" title="GlassFish ">GlassFish </a> it will be enough to run one of its samples. so do it yourself to see what happens. I for my sel <a href="http://127.0.0.1:8080/dwr/dwr/test/JDate" title="JDate Sample">JDate Sample</a> as the first one and i saw that it works fine. </p>
<p><a href="http://weblogs.java.net/blog/kalali/archive/images/DWR_3.JPG" class="fancyboxgroup" rel="gallery-246" title="DWR Working in GlassFish"><img src="http://weblogs.java.net/blog/kalali/archive/images/DWR_3_small.jpg" /></a> </p>
<p>Now lets see how we can deploy the application using autodeploy folder , this folder is located in your domain folder somewhere like : </p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/DWR_4.JPG" alt="Auto Deploy Folder Place" width="202" height="173" /></p>
<p>you can use this folder to deploy all kind of applications , so you can put a war file inside that folder and GlassFish will deploy it for you , you can put an EAR file there and <a href="http://glassfish.dev.java.net" title="GlassFish ">GlassFish </a> will deploy it for you even You can deploy Resource Adapters (RAR files) using this folder.<br />to test this folder , goto web administration console and inside web applications management page undeploy DWR project then come back here and put DWR.war inside autodeploy folder now go to web based management console and you will see DWR in deployed web application list.</p>
<p>Now that you find out how this magic folder works , lets see how that administration Script ( asadmin.bat/sh) works for us. it is even easier than the previus one , you just need to call : <em>Glassfish_Home/bin/asadmin deploy c:/DWR.war</em> </p>
<p><img src="http://weblogs.java.net/blog/kalali/archive/images/DWR_5.JPG" alt="Deployment Using Console" width="662" height="136" /></p>
<p>In next parts i will talk more about deploying application into GlassFish , we will see how an ear file or rar file can be deployed and be configured to works inside <a href="http://glassfish.dev.java.net" title="GlassFish ">GlassFish </a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40-part-v-and-some-tips-about-application-deployment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing some FrameWorks and applications on Glassfish build 40+  part IV</title>
		<link>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40-part-iv/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-some-frameworks-and-applications-on-glassfish-build-40-part-iv</link>
		<comments>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40-part-iv/#comments</comments>
		<pubDate>Fri, 31 Mar 2006 19:30:34 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[AMX]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[JMX]]></category>
		<category><![CDATA[MC4J]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=244</guid>
		<description><![CDATA[This time i want to setup and test a utility that i am using with my Application server to mange them and monitor them.Utility that i will use is Mc4j A very powerful and flexible jmx console built on top of Netbeans Platform .so to follow this blog entry you will need GlassFish build 40+ [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>This time i want to setup and test a utility that i am using with my Application server to mange them and monitor them.<br />Utility that i will use is <a href="http://mc4j.sourceforge.net/" title="Mc4j">Mc4j</a> A very powerful and flexible jmx console built on top of <a href="http://platform.netbeans.org" title="Netbeans Platform">Netbeans Platform</a> .<br />so to follow this blog entry you will need <a href="http://glassfish.dev.java.net" title="GlassFish ">GlassFish </a> build 40+ , although i am testing it on buid 42 .Also you will need to have <a href="http://mc4j.sourceforge.net/" title="Mc4j">Mc4j</a> version 1.2 beta 9 or newer.<br />first lets see what is JMX in very brief JMX like other java Stuff is an standard with some JSR related to it that handle requirement to manage java based applications in an standard and unified way it will allows to create powerful distributed management and monitoring system across different servers and aplications.<br />if you use jmx rule to build your configuration system then your application could be managed via any standard JMX console and any other application can interact with your application management system in an standard way.<br />How this become possible ? indeed you provide some java classes which are named managed beans or simply MBeans that provide access to other obects (mainly exposed or configurable objects) or your system. each MBean then register in another Object which is named MBean server.<br />? An MBean server with some services to handle MBeans compose a JMX Agent.this JMX agent provide facilities that remote application could communicate and manage your application.<br />but why we use JMXTechnology . i think some of reasons for using jmx is :</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>It provice an standard way to manage applications.</li>
<li>the architecture is well though and easily extendable.</li>
<li>You can integrate it with other management system because of its non intrusive nature.</li>
</ul>
<p>For me , it is really suite that i use one application as a management console to manage my servers and applications that are running on them.<br />Lets see how we can use <a href="http://mc4j.sourceforge.net/" title="Mc4j">Mc4j</a> to manage GlassFish. If you run mc4j you will see that it provide opens up and bring a friendly environment like netbeans. something like : </p>
<p><a href="http://weblogs.java.net/blog/kalali/archive/images/jmx_1.jpg" class="fancyboxgroup" rel="gallery-244"><img src="http://weblogs.java.net/blog/kalali/archive/images/jmx_1_small.jpg" /></a> </p>
<p>To access Glassfish management trough JMX you need to register the GlassFish as a server in mc4j , so in management menu choose create server connection. a dialog will opens let it be there. now go to your GlassFish installation bin directory. execute <strong>asadmin start-domain</strong> in case that you have one domain in your application server then that domain will start and a page like the following will shown up. </p>
<p><a href="http://weblogs.java.net/blog/kalali/archive/images/jmx_2.jpg" class="fancyboxgroup" rel="gallery-244"><img src="http://weblogs.java.net/blog/kalali/archive/images/jmx_2_small.jpg" /></a> </p>
<p>as you see in the image and in your own console window it shows up something related to jmx in your console , a url that you will use to access the JMX agent of glassFish trough mc4J copy that url and goto mc4j wizard window.<br />configure the MC4J wizard window like the following image by selecting the SJSAS as server type and pasring that url in server url, now you will need just to enteruser name and password which by default are <strong>admin/adminadmin</strong>. now you shoule be able to see a window much like the following one , as you can see , in left panel there come a glassFish node which is lighted with green. it means that mc4j is connected to this server and you can monitor / manage this server using mc4j. </p>
<p><a href="http://weblogs.java.net/blog/kalali/archive/images/jmx_3.jpg" class="fancyboxgroup" rel="gallery-244"><img src="http://weblogs.java.net/blog/kalali/archive/images/jmx_3_small.jpg" /></a> </p>
<p>Extend the GlassFish Node and you will see manything there.You can view the server JVM status , and also you can view the server resources itself. to view the server resources you will need to extpand the MBeans / amx node which is main node for GlassFish management. <br />Happy exploration <br />some images from my own explorations <img src='http://kalali.me/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  </p>
</p>
<table border="0" cellspacing="2" cellpadding="0">
<tr>
<td>
<p align="left"><a href="http://weblogs.java.net/blog/kalali/archive/images/jmx_4.jpg" class="fancyboxgroup" rel="gallery-244"><img src="http://weblogs.java.net/blog/kalali/archive/images/jmx_4_small.jpg" /></a> </p>
</td>
<td>
<p align="left"><a href="http://weblogs.java.net/blog/kalali/archive/images/jmx_5.jpg" class="fancyboxgroup" rel="gallery-244"><img src="http://weblogs.java.net/blog/kalali/archive/images/jmx_5_small.jpg" /></a></p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">What you can do when you are netbeans based..</p>
</td>
<td>
<p align="left">dynamic Pool size chart</p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left"><a href="http://weblogs.java.net/blog/kalali/archive/images/jmx_6.jpg" class="fancyboxgroup" rel="gallery-244"><img src="http://weblogs.java.net/blog/kalali/archive/images/jmx_6_small.jpg" /></a></p>
</td>
<td>
<p align="left"><a href="http://weblogs.java.net/blog/kalali/archive/images/jmx_7.jpg" class="fancyboxgroup" rel="gallery-244"><img src="http://weblogs.java.net/blog/kalali/archive/images/jmx_7_small.jpg" /></a></p>
<p align="left">
</p>
</td>
</tr>
<tr>
<td>
<p align="left">Dynamic Pool usage Chart</p>
</td>
<td>
<p align="left">Look which action we have over OSWorkFlow web application in this MBean</p>
</td>
</tr>
</table></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40-part-iv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing some FrameWorks and applications on Glassfish build 40+  part III</title>
		<link>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40-part-iii/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-some-frameworks-and-applications-on-glassfish-build-40-part-iii</link>
		<comments>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40-part-iii/#comments</comments>
		<pubDate>Thu, 30 Mar 2006 06:38:14 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[OSWorkflow]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=242</guid>
		<description><![CDATA[This time I want to test OSWorkflow on GlassFish , for this purpose I get latest version of this application , I mean osworkflow-2.8.0.Lets see What a workFlow engine is and what is its usage , a workFlow Engine is an engine that is capable of executing WorkFlows in different level. a workFlow is a [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>This time I want to test <a href="http://www.opensymphony.com/osworkflow/" title="OSWorkflow">OSWorkflow</a> on GlassFish , for this purpose I get latest version of this application , I mean osworkflow-2.8.0.<br />Lets see What a workFlow engine is and what is its usage , a workFlow Engine is an engine that is capable of executing WorkFlows in different level. a workFlow is a graph of works , so it means that a workFlow engine can execute a graph of works , this graph describe when , how and under which circumstance a node must be executed and/or which branch of graph should be followd.there are some standards for WorkFlow engine which you can find them in the web. <br />and you should know that there are really many WorkFlow engine in Opensource market <img src='http://kalali.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  take a look at <a href="http://java-source.net/open-source/workflow-engines" title="http://java-source.net/open-source/workflow-engines">http://java-source.net/open-source/workflow-engines</a> I find that some one add my weblog entries to <a href="http://wiki.java.net/bin/view/Projects/GlassFishExtras" title="GlassFish Wiki">GlassFish Wiki</a> it looks like that I should explain more to allows every one to deploy this samples on <a href="https://glassfish.dev.java.net/" title="GlassFish">GlassFish</a>, so To follow this blog entry yourself you will need</p>
<p style=" -qt-block-indent:1;">
<ul>
<li><a href="https://glassfish.dev.java.net/" title="GlassFish">GlassFish</a> Build40+ .</li>
<li><a href="http://www.opensymphony.com/osworkflow/" title="OSWorkflow">OSWorkflow</a> version 2.8.0</li>
<li>sure you will need <a href="http://java.sun.com/products/j2se" title="JDK">JDK</a> to run GlassFish</li>
</ul>
<p>lets start the job. At first I tried the sample application on tomcat 5.5.12 to make sure that it is working and it works well on <a href="http://tomcat.apache.org/" title="Tomcat">Tomcat</a> as I expect. Now lets start the <a href="https://glassfish.dev.java.net/" title="GlassFish">GlassFish</a> and open the likely admin console to easily deploy that application. I am right going to deploy osworkflow-2.8.0-example.war into GlassFish , lets see what will happen.<br />first step has done and now I can determine new context path and application name for this application ,osworkflow-2 is a bit long to be an application context name so I choose another context name for this application , something like OSW .I clicked next and application has deployed successfully , now lets see whether it runs with success or not.<br />Browser is open and I navigate to <a href="http://localhost:28080/osw/" title="http://localhost:28080/osw/">http://localhost:28080/osw/</a> nice , it looks like that it will works. You should see some page like the following : <br /><a href="http://weblogs.java.net/blog/kalali/archive/images/osw_1.JPG" class="fancyboxgroup" rel="gallery-242" title="OSWorkflow Running on GlassFish"><img src="http://weblogs.java.net/blog/kalali/archive/images/osw_1_small.jpg" /></a> <br />Now lets see whether WorkFlow engine works correctly or not. To make sure lets load some test references by provided link in login page . So login with test/test and go to view your Works , you will see some defined Work that are waiting to mark as finish. After you create the reference data and logged in as test/test navigate to : <a href="http://localhost:28080/osw/underway.jsp" title="http://localhost:28080/osw/underway.jsp">http://localhost:28080/osw/underway.JSP</a> you will see a page like the following (but not exactly the following because I finished some jobs) now you can finish some jobs and /or create some more items and watch them. <br /><a href="http://weblogs.java.net/blog/kalali/archive/images/osw_2.JPG" class="fancyboxgroup" rel="gallery-242" title="OSWorkflow Running on GlassFish"><img src="http://weblogs.java.net/blog/kalali/archive/images/osw_2_small.jpg" /></a> <br />Now go back to manager page of OSW context I mean <a href="http://localhost:28080/osw/manager" title="http://localhost:28080/osw/manager">http://localhost:28080/osw/manager</a> and create a new user for yourself . Add some works to system and terminate some of them to make sure your deployed sample works OK.<br />for me it works fine because I add several works and then terminate them.Something like : <br /><a href="http://weblogs.java.net/blog/kalali/archive/images/osw_3.JPG" class="fancyboxgroup" rel="gallery-242" title="OSWorkflow Running on GlassFish"><img src="http://weblogs.java.net/blog/kalali/archive/images/osw_3_small.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40-part-iii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing some FrameWorks and applications on Glassfish build 40+  part II</title>
		<link>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40-part-ii/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-some-frameworks-and-applications-on-glassfish-build-40-part-ii</link>
		<comments>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40-part-ii/#comments</comments>
		<pubDate>Sun, 26 Mar 2006 15:14:32 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[OSCache]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=240</guid>
		<description><![CDATA[In this part I am going to test two other Open source frameworks on GlassFish. first of all I like to say that it is funny to test frameworks on GlassFish , at least until now , I faced no problem with deploying sample applications that come with frameworks distribution.in this part I will test [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>In this part I am going to test two other Open source frameworks on GlassFish. first of all I like to say that it is funny to test frameworks on GlassFish , at least until now , I faced no problem with deploying sample applications that come with frameworks distribution.<br />in this part I will test : <a href="http://www.opensymphony.com/oscache/" title="OsCache"> OSCache</a> from <a href="http://www.opensymphony.com/" title="opensymphony">opensymphony</a> and The famous <a href="http://facelets.dev.java.net/" title="facelets"> Facelets </a>. <br />but why I should test <a href="http://www.opensymphony.com/oscache/" title="OsCache"> OSCache</a>, and what is <a href="http://www.opensymphony.com/oscache/" title="OsCache"> OSCache</a>? let me tell you that it is a brilliant framework again from provider of WebWork and SiteMesh , it can cache what ever you like from a java object in middle layers to some part of your jsp/jsf? page in view layer. some of its features are as listed below:</p>
<p style=" -qt-block-indent:1;">
<ul>
<li>Caching Dynamic Content : you can cache some part of a JSP pages between requests. </li>
<li>Caching Binary Content : cache heavy to generate contents like Charts that does not needs to be up-to-date </li>
<li>Error Tolerance : show cached content in case that a page encounter a problem and report the problem back to some administrator </li>
</ul>
<p>I used OSCache for caching some parts of web pages and also to cache heavy to generate Charts for visitors of a web based system. In my case creating each chart needs several complex queries over a large Tables. On that time I used <a href="http://www.jfree.org" title="JFree Chart ">JFree Chart</a> to handle chart creation and <a href="http://www.opensymphony.com/oscache/" title="OsCache"> OSCache</a> to cache The generated charts even for more than 24 Hours.<br />Now that I come to test each Frameworks that I used in past with GlassFish I decide to test OSCache to. So , I deployed the sample application that come with OSCache and it works.<br />To make it more likely I test the OSCache with JSF on GlassFish , it looks like that it works fine even with JSF but sure it needs more investigation to make sure that it works when we use JSF .<br />following image shows that I run the sample application that come with OSCache with an small change (using JSF core view to include all stuff showed in the page , using a backing bean and a binding for outputText value to show current TimeStamp).</p>
<p><a href="http://weblogs.java.net/blog/kalali/archive/images/GlassFish_oscache.JPG" class="fancyboxgroup" rel="gallery-240" title="OSCache Running on GlassFish"><img src="http://weblogs.java.net/blog/kalali/archive/images/GlassFish_oscache_small.jpg" /></a> </p>
<p>Another framework that I test and I will talk about it in this entry is <a href="http://facelets.dev.java.net/" title="facelets"> Facelets </a> , but what is this framework and what can it do?in very brief Facelets bring some view related enhancement and features to JSF community .<br />To name some of features :</p>
<p style=" -qt-block-indent:1;">
<ol>
<li>Facelets make it possible to develop your entire web pages using your favorite page designer like Dreamweaver or Microsoft FrontPage. To achieve this feature it introduce a new attribute, jsfc ,that make it possible to change each HTML element to a JSF equal component. It is similar to Tapestry&#8217;s jwcid attribute. So you can use all binding and event handling stuff of JSF and availability and ease of use of HTML WYSIWYG.</li>
<li>Facelets provide a template-ing features like Velocity&#8217;s for JSF . It allows you to test JSF views out of container.</li>
<li>Some decoration features like what tile bring to struts community and SiteMesh ,generally, to all java based web application.</li>
</ol>
<p>although I want to explain a bit more about feature number 1 , WYSIWYG HTML designers and Facelets. The designer should be able to produce XHTML , it means that the generated HTML file should comply with well-formed XML files syntax.For example all tags should be closed properly and no with brief model . <br />But <a href="http://facelets.dev.java.net/" title="facelets"> Facelets </a> is really a nice piece of works and a gift to JSF community. I Like too much to use Facelets in next jobs , but we should wait and see what customer want.<br />Now lets take a look and see what will happen when we try to deploy numberguess.war which come with <a href="http://facelets.dev.java.net/" title="facelets"> Facelets </a> Distribution.<br />sweet it just run , very good to see such such sweet deployment. I remember that first time which I have tried to deploy this numberguess.war which come from Facelets 1.0.11 on tomcat I faced some problem.When I looked inside web-inf/lib folder I find that here two implementation for JSF there , one was myfaces and the other was jsf-ri implementation. I removed the myfaces.jar and it runs.<br />this image shows what I have seen after I deployed numberguess.war into GlassFish.</p>
<p><a href="http://weblogs.java.net/blog/kalali/archive/images/GlassFish_facelets.JPG" class="fancyboxgroup" rel="gallery-240" title="FaceLets Running on GlassFish"><img src="http://weblogs.java.net/blog/kalali/archive/images/GlassFish_facelets_small.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing some FrameWorks and applications on Glassfish build 40+</title>
		<link>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-some-frameworks-and-applications-on-glassfish-build-40</link>
		<comments>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40/#comments</comments>
		<pubDate>Sat, 25 Mar 2006 20:09:27 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[StringBeans]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=238</guid>
		<description><![CDATA[Now with EJB 3 , (I am talking about current date take a look at date that this entry is written) options in application server market are so limited because there are just few application server that support EJB3. some of them that i know are Jboss and GlassFish project.But GlassFish provide more than beeing [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>Now with EJB 3 , (I am talking about current date take a look at date that this entry is written) options in application server market are so limited because there are just few application server that support EJB3. some of them that i know are <a href="http://www.Jboss.com" title="Jboss">Jboss</a> and <a href="https://glassfish.dev.java.net/" title="GlassFish">GlassFish project</a>.<br />But <a href="https://glassfish.dev.java.net/" title="GlassFish">GlassFish</a> provide more than beeing EJB3 container , it is aimed to be a full Java ee 5 container. <br /><a href="https://glassfish.dev.java.net/" title="GlassFish">GlassFish</a> uses TopLink for persistance ,Contributed by <a href="http://www.ORACLE.com" title="ORACLE">ORACLE</a>, so I think when we come to performance it is compareable with <a href="http://www.jboss.com/products/jbossas" title="JBoss AS">JBoss AS</a> that uses <a href="http://www.hibernate.org" title="Hibernate ">Hibernate </a> Persistance Engine to provide EJB3.<br />In a series of weblog i will deploy some of frameworks that i used in past with Other Application server and servlet container in <a href="https://glassfish.dev.java.net/" title="GlassFish">GlassFish</a>.<br />First of all I tried to run my favorite Open source Portal on Sun application server 8.1 ,8.2 but it does not works without workaround.but now in glassFish it deployed as sweet as a candy.<br /><a href="http://www.nabh.com/portal/projects/normal/0/reset/0/0?project_id=3&#038;project_name=Stringbeans%20Portal" title="StringBeans Portal">StringBeans Portal</a> use Hibernate as ORM framework so it is database agnostic.Hope they convert the persistance layer to EJB3 . <a href="http://www.nabh.com/portal/projects/normal/0/reset/0/0?project_id=3&#038;project_name=Stringbeans%20Portal" title="StringBeans Portal">StringBeans Portal</a> is a very clean and innovative implementation of jsr-168 portlet container with many features that you can relay on them for your next portal based job.<br />It is <a href="http://www.nabh.com/portal/projects/normal/0/reset/0/0?project_id=3&#038;project_name=Stringbeans%20Portal" title="StringBeans Portal">StringBeans Portal</a> version 3.1 alpha that i checked on <a href="https://glassfish.dev.java.net/" title="GlassFish">GlassFish</a> . it is really very superior in comparesion with older versions .although older versions of this product was great too.<br />following image shows its running on <a href="https://glassfish.dev.java.net/" title="GlassFish">GlassFish</a> build 40.</p>
<p><a href="http://weblogs.java.net/blog/kalali/archive/images/glassFish_st.jpg" class="fancyboxgroup" rel="gallery-238" title="StringBeans portal running on glassfish"><img src="http://weblogs.java.net/blog/kalali/archive/images/glassFish_st_small.jpg" /></a> <br />Another framework which i tests on <a href="https://glassfish.dev.java.net/" title="GlassFish">GlassFish</a> is <a href="http://www.opensymphony.com/sitemesh/" title="SiteMesh">SiteMesh</a> A great web-page layout and decoration framework . I use it with classic JSP/Servlet cases and also with Struts . I am really happy that i know this framework.<br />I thought when i tried <a href="http://www.nabh.com/portal/projects/normal/0/reset/0/0?project_id=3&#038;project_name=Stringbeans%20Portal" title="StringBeans Portal">StringBeans Portal</a> lets test one other neat framework so i deployed sample war file that come with <a href="http://www.opensymphony.com/sitemesh/" title="SiteMesh">SiteMesh</a> distribution on <a href="https://glassfish.dev.java.net/" title="GlassFish">GlassFish</a> , and it runs with no needs for modification. next image show that sample application running on <a href="https://glassfish.dev.java.net/" title="GlassFish">GlassFish</a><br />Follwing image shows Sitemesh running on GlassFish </p>
<p><a href="http://weblogs.java.net/blog/kalali/archive/images/glassFish_sM.JPG" class="fancyboxgroup" rel="gallery-238" title="SiteMesh Running on glassfish"><img src="http://weblogs.java.net/blog/kalali/archive/images/glassFish_sM_small.JPG" /></a></p>
<hr />
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/testing-some-frameworks-and-applications-on-glassfish-build-40/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I want to share an RUP presentation that I have made before &#8230;</title>
		<link>http://kalali.me/i-want-to-share-an-rup-presentation-that-i-have-made-before/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=i-want-to-share-an-rup-presentation-that-i-have-made-before</link>
		<comments>http://kalali.me/i-want-to-share-an-rup-presentation-that-i-have-made-before/#comments</comments>
		<pubDate>Thu, 09 Mar 2006 08:24:39 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Methodologies]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[RUP]]></category>
		<category><![CDATA[Iterative Development]]></category>
		<category><![CDATA[Presentation]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=236</guid>
		<description><![CDATA[I saw that there is a poll in java.Net about Software development process. sure I vote in favor of Process that I have work in its framework before (RUP) and I prefer to work in adhere to its rules. And now I wan to share a fast overview presentation about RUP with users that like [...]]]></description>
			<content:encoded><![CDATA[<p>I saw that there is a poll in <a href="http://www.java.net">java.Net </a>about Software development process. sure I vote in favor of Process that I have work in its framework before (<a title="RUP , Rational unified process" href="http://en.wikipedia.org/wiki/RUP">RUP</a>) and I prefer to work in adhere to its rules. And now I wan to share a fast overview presentation about <a title="RUP , Rational unified process" href="http://en.wikipedia.org/wiki/RUP">RUP</a> with users that like to know this process and need a very straight and simple to follow presentation. The presentation come in 68 pages and cover the following issues.</p>
<p><span style="font-size: large;">-Terms and definitions</span><br />
<span style="font-size: large;">-What is RUP?</span><br />
-Key aspect of RUP<br />
-6 Best practices<br />
<span style="font-size: large;">-RUP Architecture</span><br />
-Dynamic aspect<br />
-Static Aspect<br />
<span style="font-size: large;">-Workers</span><br />
<span style="font-size: large;">-RUP Workflows</span><br />
<span style="font-size: large;">-Software Architecture</span><br />
<span style="font-size: large;">-RUP </span> The Product<br />
<span style="font-size: large;">-RUP VS MSF</span><br />
<span style="font-size: large;">-Conclusion</span><br />
<span style="font-size: large;">-QA</span><br />
<span style="font-size: large;">-References</span></p>
<p>I provide the ODP format for download.<br />
get the ODP from : <a href="http://dl.dropbox.com/u/334201/jn-blog-files/RUP%20presentation.odp">http://dl.dropbox.com/u/334201/jn-blog-files/RUP%20presentation.odp</a></p>
<p>By the way , do you noticed that how much smaller an ODP file is ?</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/i-want-to-share-an-rup-presentation-that-i-have-made-before/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A New Module for Netbeans IDE , an statistical  CVS Reporter&#8230;</title>
		<link>http://kalali.me/a-new-module-for-netbeans-ide-an-statistical-cvs-reporter/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-new-module-for-netbeans-ide-an-statistical-cvs-reporter</link>
		<comments>http://kalali.me/a-new-module-for-netbeans-ide-an-statistical-cvs-reporter/#comments</comments>
		<pubDate>Tue, 07 Mar 2006 17:31:34 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Modularity]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[NetBeans RCP]]></category>
		<category><![CDATA[CVS]]></category>
		<category><![CDATA[Modul Develoment]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=234</guid>
		<description><![CDATA[2 weeks ago I was looking at www.sourceforge.Net for a utility that allows me to get some statistical information from CVS repositories. There are some commercial products that do this job in a very perfect manner , but those are commercial and feature over loaded.after some search I find VCS Report , I get the [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>2 weeks ago I was looking at <a href="http://www.sourceforge.net" title="www.sourceforge.net">www.sourceforge.Net</a> for a utility that allows me to get some statistical information from CVS repositories. There are some commercial products that do this job in a very perfect manner , but those are commercial and feature over loaded.after some search I find <a href="http://www.sourceforge.net/projects/vcsreport" title="VCSReport">VCS Report</a> , I get the package and get some chart from my CVS repositories. <br />Some days ago I get the source code of the project and looked at the source ,Amazing , it uses a <a href="http://www.Netbeans.org" title="Netbeans">NetBeans </a>library to connect to CVS servers , but there is no <a href="http://www.Netbeans.org" title="Netbeans">NetBeans </a> plugin available in the download section , so I start and create a plugin for NetBeans , although it is in very early step and throw some exceptions some times but it works fine with <a href="http://www.Netbeans.org" title="Netbeans">NetBeans </a>. I will put it in my UC in next few days after i make sure that i change it to comply with <a href="http://www.Netbeans.org" title="Netbeans">NetBeans </a> in some acceptable degrees. <br />so far I create a TopComponent that contain the reporting stuff ,you can <a href="http://weblogs.java.net/blog/kalali/archive/images/cvsReport_total_image."><strong>View image</strong></a> . <br />Now Configuration system (saving and loading your previous settings) and CVS setup dialog are ordinary swing dialogs instead of NetBeans specific dialogs, indeed these are exact clone of original <a href="http://www.sourceforge.net/projects/vcsreport" title="VCSReport">VCS Report</a> dialogs. <br />CVS setup dialog is like : <br /><img src="http://weblogs.java.net/blog/kalali/archive/images/cvsReport_CVS_setup_image.jpg" title="nbCVS report main page" /><br />Password request dialog for CVS is like : <br /><img src="http://weblogs.java.net/blog/kalali/archive/images/cvsReport_Password_request_image.jpg" title="nbCVS report main page" /><br />Current Feature of plugin Comply with <a href="http://www.sourceforge.net/projects/vcsreport" title="VCSReport">VCS Report</a> features , and sure the plugin will contain all features that VCSreport implements in future as soon as possible.</p>
<p style=" -qt-block-indent:1;">
<ol>
<li>Customizable filters</li>
<li>History table</li>
<li>Statistical charts</li>
<li>HTML reports</li>
<li>CSV (Comma delimited) reports</li>
</ol>
<p>For next steps(before I make this plugin public) I thought to add at least half of the following features and enhancements.</p>
<p style=" -qt-block-indent:1;">
<ol>
<li>Both panels which are lied in north section should be converted into a wizard , so you start a wizard and it helps you to prepare a report step by step</li>
<li>CVS setup dialog should be converted to NetBeans Standard CVS setup dialog</li>
<li>It should be able to read CVS profiles that you have made in your NetBeans IDE. Like some other articles , blog posts ,&#8230; That contain an integration issue this plugin need more <strong>integration</strong> <img src='http://kalali.me/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
<li>Configuration files should be NetBeans standard configuration</li>
<li>Tasks , should be converted to NetBeans standard Tasks</li>
<li>Nor original software nor this plugin contain a progress bar , I think it should have some indicator that tell it is processing , even for very small portion of time</li>
<li>Change i18n to comply with NetBeans i18n standards</li>
</ol>
<p>I have some long term feature list which are depended on 3rd party softwares (at least I think that they depend on 3rd party softwares like <a href="http://www.Netbeans.org" title="Netbeans">NetBeans </a> and <a href="http://www.sourceforge.net/projects/vcsreport" title="VCSReport">VCS Report</a> )</p>
<p style=" -qt-block-indent:1;">
<ol>
<li>SVN (Subversion) support</li>
<li>CVS SSH support</li>
<li>More statistical charts</li>
<li>XML reports</li>
<li>Also I thought about using <a href="http://www.jfree.org/" title="JFree chart">JFree Chart</a> instead of Charts that created by the software author , Jfree Chart has much more advanced charting engine and it gives user more feature to build better software , but it will make the module bigger in download size</li>
</ol>
<p>i made this post because i am looking for some comments from developers who have knowledge about CVS internal mechanism. so if any one from the community have any suggestion , then let me know. I will add it to my ToDo list for future releases , and sure try to use your advice / comments , i will be more happy if my first release has more useability.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/a-new-module-for-netbeans-ide-an-statistical-cvs-reporter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Simple Netbeans Module , a Gmail Checker&#8230;</title>
		<link>http://kalali.me/a-simple-netbeans-module-a-gmail-checker/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-simple-netbeans-module-a-gmail-checker</link>
		<comments>http://kalali.me/a-simple-netbeans-module-a-gmail-checker/#comments</comments>
		<pubDate>Sat, 04 Mar 2006 17:45:40 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Modularity]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[NetBeans RCP]]></category>
		<category><![CDATA[Gmail Checker]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[NetBeans Module]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wordpress/?p=232</guid>
		<description><![CDATA[Some times ago I participate in NetCat 50 &#8211; a process for NetBeans IDE version 5 QA -During NetCat I find that NetBeans RCP is something that I can Pick for later Swing based clients. I start learning NetBeans RCP platform during NetCat 50 , and to evaluate my learnings I write a simple Module [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>Some times ago I participate in <a href="http://qa.netbeans.org/processes/cat/50/index.html" title="Netcat 50 , a process for Netbeans 5 QA">NetCat 50</a> &#8211; a process for NetBeans IDE version 5 QA -During NetCat I find that NetBeans RCP is something that I can Pick for later Swing based clients. </p>
<p>I start learning NetBeans RCP platform during NetCat 50 , and to evaluate my learnings I write a simple Module for NetBeans IDE . </p>
<p>The module is a GMail Checker , Module make it possible for you to see your new emails within your IDE and allows you to rotate between subjects. </p>
<p>I write Down a <a href="http://platform.netbeans.org/tutorials/nbm-gmail-checker.html" title="Tutorial on building Netbeans Module , Its case study is Gmail Checker<br />
Tutorial on building Netbeans Module">Tutorial on building NetBeans Module</a> and as a Case study I showed how user can build GMail checker him/herself. </p>
<p>To build that module I used another Open Source project , <a href="http://g4j.sourceforge.net" title="G4j  , library and client application to access Gmail service by java">http://g4j.SourceForge.Net</a>, which is Java library to access GMail service. </p>
<p>After installing the module you will see a new toolbar in your IDE , the toolbar will be like following image : </p>
<p><img src="http://platform.netbeans.org/images/tutorials/gmail/gmail1.png" title="Gmail Checker right after installation" /></p>
<p>by clicking on toolbar , it will start connection to Gmail. a NetBeans Standard progress bar will show the the progress in IDE bottom line </p>
<p><img src="http://platform.netbeans.org/images/tutorials/gmail/gmail2.png" title="Connecting To Gmail" /></p>
<p>a NetBeans Standard progress bar will show the the progress in IDE bottom line </p>
<p><img src="http://platform.netbeans.org/images/tutorials/gmail/gmail5.png" title="Progress bar indicate" /></p>
<p>after it fetch information from GMail it will show you a something like </p>
<p><img src="http://platform.netbeans.org/images/tutorials/gmail/gmail3.png" title="Information About new Emails and your free Gmail space" /></p>
<p>which tell you how much new email you have , and how much space of your GMail is occupied Now you can allow GMail Checker to rotate between subjects or do it yourself using provided buttons </p>
<p><img src="http://platform.netbeans.org/images/tutorials/gmail/gmail4.png" title="Let Gmail Checker rotate between subjects or Do it yourself" /></p>
<p>You can configure the GMail checker Options trough Its configuration panel which is an standard NetBeans configuration panel. </p>
<p>Configuration panel is something like the following image. <img src="http://weblogs.java.net/blog/kalali/archive/gmail_checker_option_dialog.jpg" alt="Gmail Checker Option Dialog" width="458" height="475" /></p>
<p>I set up an update center for my further NetBeans module , right now , you can check this UC and get your GMail Checker from there. <br /><a href="http://www.solarisict.com/updates.xml" title="Masoud Kalali Update Center">http://www.Solarisict.com/updates.xml</a> <br />If you prefer to install the module from your local drive then , you can <a href="http://weblogs.java.net/blog/kalali/archive/zipFiles/gmailChecker.zip" title="Download all in one bundle of Gmail Checker">download </a>all in one archive which contains all required modules for GMail checker. </p>
<p>you can get the source code for GMail checker from NetBeans web site , this archive contain all source code , sound files and images that I used to build this module the link to get the zip archive is <a href="http://www.netbeans.org/files/documents/4/654/GmailCheckerArchive.zip">here</a> </p>
<p>To add a new update center to NetBeans IDE and many other NetBeans Tips and tricks take a look at <a href="http://blogs.sun.com/roller/page/geertjan" title="Geertjan Weblog , A big source of Netbeans Related information">Geertjan Weblog </a>and for more NetBeans related information look at another big blog , <a href="http://blogs.sun.com/roller/page/roumen" title="Roumen Weblog , A big source of Netbeans information">Roumen Weblog </a></p></p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/a-simple-netbeans-module-a-gmail-checker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

