<?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, 27 Dec 2012 16:19:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>My last blog in 2012: My 2013 wishes and predictions&#8230;</title>
		<link>http://kalali.me/my-last-blog-in-2012-my-2013-wishes-and-predictions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=my-last-blog-in-2012-my-2013-wishes-and-predictions</link>
		<comments>http://kalali.me/my-last-blog-in-2012-my-2013-wishes-and-predictions/#comments</comments>
		<pubDate>Thu, 27 Dec 2012 11:43:12 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Java SE]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=1335</guid>
		<description><![CDATA[Last year I wrote a wish list and prediction for 2012 and this year I am going to do the same for 2013. So for 2013 in technology realm specially when focused on Java is as follow: Java SE 8 will be an awesome release despite the Jigsaw setback. Java EE 7 will bring more [...]]]></description>
				<content:encoded><![CDATA[<p>Last year I wrote a<a href="http://kalali.me/my-last-blog-in-2011-my-2012-wishes-and-predictions/"> wish list and prediction for 2012</a> and this year I am going to do the same for 2013. So for 2013 in technology realm specially when focused on Java is as follow:</p>
<ul>
<li>Java SE 8 will be an awesome release despite the Jigsaw setback.</li>
<li>Java EE 7 will bring more ease of use and clarity into the community.</li>
<li><a href="http://glassfish.java.net/">GlassFish 4</a> will be awesome and and more people will benefit from it&#8217;s modular and extensible architecture&#8230;</li>
<li>In late 2013<a href="http://netbeans.org/community/releases/roadmap.html"> NetBeans IDE 8 </a>will rock!</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 seems to be pulling it together and it is likely to keep its own operating system rather than adopting Android.</li>
<li>Google Chrome will continue eating 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</li>
<li>I wish for a very thin and edge to edge tablet and cell phone on top of android so I could switch to another phone. This will be something that Google_Moto will do.</li>
<li>Maybe I see someone with a Windows Mobile phone somewhere other than advertisements.</li>
</ul>
<p>What I wish for during 2013, unrelated to technology</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>To win more bets against my nemesis.</li>
</ul>
<p>Other predictions for 2013 which I truly like to be proven wrong for some parts:</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>It is highly likely that Syrian dictatorship loose the battle for capital city and leave the capital but they will remain a player in the country and wreck havoc for the time being.</li>
</ul>
<h3>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-2012-my-2013-wishes-and-predictions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My sessions in JavaOne 2012</title>
		<link>http://kalali.me/my-sessions-in-javaone-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=my-sessions-in-javaone-2012</link>
		<comments>http://kalali.me/my-sessions-in-javaone-2012/#comments</comments>
		<pubDate>Mon, 24 Sep 2012 15:05:21 +0000</pubDate>
		<dc:creator>Masoud Kalali</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://kalali.me/?p=1322</guid>
		<description><![CDATA[It is long since last I blogged and I go forward I find less and less time to put into tech blogging. I thought to post in my blog that I will be presenting three sessions in Java one along or accompanying another speaker.  As you may expect two sessions evolve around security and one session covers [...]]]></description>
				<content:encoded><![CDATA[<p>It is long since last I blogged and I go forward I find less and less time to put into tech blogging. I thought to post in my blog that I will be presenting three sessions in Java one along or accompanying another speaker.  As you may expect two sessions evolve around security and one session covers some interesting features and APIs provided by Java EE 7. The sessions are as follow:</p>
<p><a href="https://oracleus.activeevents.com/connect/sessionDetail.ww?SESSION_ID=11881">Top 10 OWASP security concerns and how to address them with Java EE</a>: <a href="https://twitter.com/myfear">Markus Eisele</a> and I will be presenting this session.</p>
<blockquote><p>The hottest topic for Enterprise Java applications out there is security which Java EE provides fair deal of flexibility to benefit from. This session focuses on how the top 10 OWASP application security concerns including &#8220;Broken Authentication and Session Management&#8221;, &#8220;Failure to Restrict URL Access&#8221; and &#8220;Security Misconfiguration&#8221; can be addressed using Java EE and GlassFish application server. The session covers how and where to integrate the solution for each OWASP concerns through a demo application. The demo application is developed considering the relevant best practices/design patterns involved with developing a secure application while avoiding the common pitfalls.</p></blockquote>
<p><a href="https://oracleus.activeevents.com/connect/sessionDetail.ww?SESSION_ID=11880">Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!</a>: This BOF session is hosted by a very experienced and long standing Metro/ GlassFish team member, <a href="https://twitter.com/bhakti_mehta">Bhakti Mehta</a> and me.</p>
<blockquote><p>This session focuses on how Java EE 7 provides extensive set of new and enhanced features to support standards like HTML5, WebSockets, and Server Sent Events among others.In this session we will show how these new features are designed and matched to work together for developing lightweight solutions matching end users high expectation from a web application&#8217;s responsiveness. The session will cover best practices and design patterns governing application development using JAX-RS 2.0, Async Servlet, and JSON-P (among others) as well as iterating over the pitfalls that should be avoided. During the session we will show code snippets and block diagrams that clarify use of APIs coming from the demo application we will show at the end.</p></blockquote>
<p><a href="https://oracleus.activeevents.com/connect/sessionDetail.ww?SESSION_ID=3964&amp;tclass=popup">Utilize the Full Power of GlassFish Server and Java EE Security</a>: I will be you host for this session.</p>
<blockquote><p>In this session, learn how to utilize Java EE security and what GlassFish Server technology provides to address your security requirements. The presentation explains a two-phase authentication mechanism.</p></blockquote>
<p>If you are attending JavaOne you may like to join this sessions and if you are not attending and still interested in this sessions, Keep an eye on <a href="https://twitter.com/MasoudKalali">@MasoudKalali</a> or check this blog sometime after JavaOne 2012 to get the slides.</p>
]]></content:encoded>
			<wfw:commentRss>http://kalali.me/my-sessions-in-javaone-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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" /></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" /></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..." /></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>2</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>1</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>
	</channel>
</rss>
