<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss'><id>tag:blogger.com,1999:blog-17720202</id><updated>2009-08-05T16:43:07.568-04:00</updated><title type='text'>organic thoughts</title><subtitle type='html'>seemingly random and unorganized bits of information</subtitle><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default?start-index=26&amp;max-results=25'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://vladimirvivien.com/blogs/ot/feed/atom.xml'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>38</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-17720202.post-3669275754667308859</id><published>2009-08-05T16:42:00.000-04:00</published><updated>2009-08-05T16:43:07.577-04:00</updated><title type='text'>Google Buys On2.  JavaFX Gains?</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;span face="Arial" style="font-size: 10pt;"&gt;When Google purchased YouTube back in 2006, the Flash video (FLV) format got an astronomical boots almost overnight.  The media format became even more popular, the Flash/Flex pair gained notoriety as a viable platform, Adobe fortified its arsenals in the battle for media dominance.  This single act shadowed other players such as Real, Microsoft, and to a certain extent Apple's QuickTime (when was the last time you embedded a Microsoft Media Player on your website).&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span face="Arial" style="font-size: 10pt;"&gt;Today (in &lt;a href="http://www.techcrunch.com/2009/08/05/google-acquires-video-compression-technology-company-on2-for-106-million/" mce_href="http://www.techcrunch.com/2009/08/05/google-acquires-video-compression-technology-company-on2-for-106-million/" target="_blank"&gt;TechChruch&lt;/a&gt;), it was announced that Google is purchasing On2, the media compression technology company behind many of the most popular media codecs including FLV.  This has the potential to change the course of online video technologies once again.  One can only imagine some of the implications this purchase will have&lt;/span&gt;&lt;/p&gt;  &lt;ul&gt;&lt;li class="MsoNormal"&gt;&lt;span face="Arial" style="font-size: 10pt;"&gt;It moves Google higher in the      media compression food chain and gives it complete control of the most      popular codecs used on the web.  &lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal"&gt;&lt;span face="Arial" style="font-size: 10pt;"&gt;Google may      open source the current proprietary VP6 (on which Flash video is based)      &amp;amp; VP7 codec formats that On2 licenses to companies.   They      may decide to provide needed support for the Ogg Theora format and make it      first class citizen in the compression stack.&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal"&gt;&lt;span face="Arial" style="font-size: 10pt;"&gt;With Google's push of HTML5      which includes the notion of built-in video/audio support, one can rightly      guess that we will see On2 technologies in Chrome Browser, Chrome OS, and      Android and anywhere else Google control (which is wide and far). &lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal"&gt;&lt;span face="Arial" style="font-size: 10pt;"&gt;As Ogg (Vorbis and Theora)      becomes the open source format of choice for media delivery, Google      will wield its influence on the format and direction of media deliver on the web. &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;p class="MsoNormal"&gt;&lt;span face="Arial" style="font-size: 10pt;"&gt;Why am I rambling about On2, Ogg, and video codec formats? Well, it all has to do with JavaFX.  One of the selling point of JavaFX is portable playback of Video/Audio basedon VP6 (consequently FLV). With the purchase of On2, Google will have a direct control of the destiny of media codec supported by JavaFX.&lt;span&gt;  &lt;/span&gt;Depending on how Google proceeds, we, in the Java community, may see positive developments for JavaFX and this is how:&lt;/span&gt;&lt;/p&gt;    &lt;ul&gt;&lt;li&gt;&lt;span face="Arial" style="font-size: 10pt;"&gt;Google open sources the On2 codec stack: big win for JavaFX (to a certain extent Adobe).  This will imply that JavaFX applications can take part in the online media revolution with lowered entry points.We probably will see Java bindings to the codec's API's which means building both encoders and players in Java/JavaFX.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span face="Arial" style="font-size: 10pt;"&gt;If the stack is open source, this may also mean eventual support on JavaFX mobile platforms. &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span face="Arial" style="font-size: 10pt;"&gt;Google may make On2 encoding tools available for free: another win for JavaFX! More videos being created with the supported On2 formats means more opportunities for JavaFX developers to create players.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;    &lt;p class="MsoNormal"&gt; &lt;span face="Arial" style="font-size: 10pt;"&gt;Or, Google may decide to just sit on the technologies use them to further their ambitions in Mobile, desktop OS, and web markets.   Only time will tell.&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span face="Arial" style="font-size: 10pt;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-3669275754667308859?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/3669275754667308859'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/3669275754667308859'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2009/08/google-buys-on2-javafx-gains.html' title='Google Buys On2.  JavaFX Gains?'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/17258719828741411014</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='12578099370892975121'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-2117679714381316348</id><published>2009-07-30T13:18:00.002-04:00</published><updated>2009-07-30T13:22:29.762-04:00</updated><title type='text'>NetBeans 6.7.1 + Mac OS = Sweetness</title><content type='html'>I just updated my netbeans to 6.7.x on the Mac and the difference is vivid.&lt;br /&gt;Even faster start time&lt;br /&gt;Snappier GUI&lt;br /&gt;On the Mac, the new look makes it look native&lt;br /&gt;Plus all the other goodies (Groovy, JavaFX, etc)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-2117679714381316348?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/2117679714381316348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/2117679714381316348'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2009/07/netbeans-671-mac-os-sweetness.html' title='NetBeans 6.7.1 + Mac OS = Sweetness'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/17258719828741411014</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='12578099370892975121'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-5384378840389113503</id><published>2009-04-12T04:21:00.005-04:00</published><updated>2009-04-12T05:02:02.507-04:00</updated><title type='text'>Introducing JmxLogger - Real-time Application Log Monitoring with JMX</title><content type='html'>For past month, I have been working (on/off) on JmxLogger, a logging API which lets you &lt;span style="font-weight: bold;"&gt;monitor your Java Logging or Log4J application log events in real-time using JMX&lt;/span&gt;.  I have had the idea for a while, but decided to finally capture it as project.  So, here it is.&lt;br /&gt;&lt;a href="http://code.google.com/p/jmx-logger/"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;http://code.google.com/p/jmx-logger/ &lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;JmxLogger&lt;/span&gt;&lt;br /&gt;JmxLogger makes it easy to &lt;span style="font-weight: bold;"&gt;broadcast your Java Logging or your Log4J log events&lt;/span&gt; as JMX notifications.  As such, you can easily monitor your application's activity logs in real-time.  Using familiar logging API and configuration mechanism (i.e. log4j.xml or Java Logging properties file), developers can quickly integrate realtime application log monitoring into their existing deployed code.  All it takes is a logging configuration change.&lt;br /&gt;&lt;br /&gt;The JmxLogger API provides a &lt;span style="font-weight: bold;"&gt;Java Logging Handler&lt;/span&gt; and a &lt;span style="font-weight: bold;"&gt;Log4J Appender&lt;/span&gt; which can be used to integrate between your favorite logging framework and JMX.  &lt;span style="font-weight: bold;"&gt;JmxLogger hides the complexity of dealing with JMX&lt;/span&gt;. You simply configure your logging framework as you normally do, and that's it. You are ready to broadcast your logging events as JMX notification events. &lt;h2&gt;&lt;a name="Features"&gt;Features&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;Support for &lt;strong&gt;Java Util Logging&lt;/strong&gt; API &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;Support for the &lt;strong&gt;Log4J&lt;/strong&gt; logging API &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;Easy integration&lt;/strong&gt; with your favorite logging framework &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;No coding&lt;/strong&gt; required, simply &lt;strong&gt;configure your logging framework&lt;/strong&gt; to get started. &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;Specify and control&lt;/strong&gt; the level of event to broadcast &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;Monitor event&lt;/strong&gt; through a console or listener scripts&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;Realtime monitoring of your application activity logging via JMX.&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;&lt;a name="Getting_Started"&gt;Getting Started&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a name="Getting_Started"&gt;Download the jar (generic or with log4j support) &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Getting_Started"&gt;Add jar to your classpath (in case of Log4J, you will need log4j.jar on your classpath)&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Getting_Started"&gt;Configure your favorite logging framework&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Getting_Started"&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Use JMX console (JConsole or VisualVM) to monitor your log actvities.&lt;a name="Getting_Started"&gt; &lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;root&gt;&lt;priority value="DEBUG"&gt;&lt;h3&gt;&lt;a name="Logs"&gt;JmxLogger&lt;/a&gt; Events&lt;br /&gt;&lt;/h3&gt;&lt;p&gt;When you log your application events using either Java Logging or Log4J (see project site for more detail), your &lt;span style="font-weight: bold;"&gt;log events&lt;/span&gt; will &lt;span style="font-weight: bold;"&gt;get routed&lt;/span&gt; to the &lt;span style="font-weight: bold;"&gt;JmxLogger Java Logging Handler&lt;/span&gt; or &lt;span style="font-weight: bold;"&gt;Log4J Appender&lt;/span&gt; defined in your application's logging configuration file.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Below you can see a configuration that sends log messages to the Console and a JmxLogger Logging Handler.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Using a command-line Console you can see your log message  messages as they are logged in your application.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://jmx-logger.s3.amazonaws.com/jmx-logger-console.png" /&gt; &lt;/p&gt;&lt;p&gt;The same log events are also emitted as JMX notifications. Using &lt;span style="font-weight: bold;"&gt;JConsole&lt;/span&gt;, you can &lt;span style="font-weight: bold;"&gt;see these events as they are logged in your application in real-time&lt;/span&gt;. &lt;/p&gt;&lt;p&gt;&lt;img src="http://jmx-logger.s3.amazonaws.com/jmx-logger-jconsole.png" /&gt; &lt;/p&gt;&lt;p&gt;That's it! You have seen how JmxLogger can effortlessly integrate JMX and the two standard logging API's available (Java Logging and Log4J). &lt;/p&gt;&lt;/priority&gt;&lt;/root&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-5384378840389113503?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/5384378840389113503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/5384378840389113503'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2009/04/introducing-jmxlogger-monitor-your.html' title='Introducing JmxLogger - Real-time Application Log Monitoring with JMX'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/17258719828741411014</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='12578099370892975121'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-5878977469553999447</id><published>2009-03-30T15:12:00.000-04:00</published><updated>2009-03-30T15:14:17.917-04:00</updated><title type='text'>Why Modularity Matters</title><content type='html'>In my &lt;a title="Java Modularity (1) - OSGi" href="http://vladimirvivien.com/blogs/ot/2009/03/java-modularity-with-osgi-1.html" id="h8-z"&gt;previous blog&lt;/a&gt;, I provided a summarized view of what OSGi is and how it impacts Java developers.  I got some interesting feedback.  So, in this blog entry, &lt;b&gt;I want to&lt;/b&gt; take a detour to &lt;b&gt;examine modularity itself&lt;/b&gt; and its importance &lt;b&gt;in creating robust systems&lt;/b&gt; that can scale in size and functionality.  This blog post does not discuss any specific Java technologies or platform directly.  However, it looks at how modular design has affected industries as diverse as manufacturing to software engineering.  Future posts will continue to look at OSGi and other modularization technologies.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Modularity&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;In the Merriam-Webster dictionary, &lt;b&gt;being modular&lt;/b&gt; is defined as "... &lt;b&gt;composed of standardized&lt;/b&gt;, &lt;b&gt;self-contained units&lt;/b&gt; for easy construction and flexible use ..."  The notion of &lt;b&gt;modularity is universal &lt;/b&gt;and has found usage in &lt;b&gt;process&lt;/b&gt; (policy), &lt;b&gt;manufacturing&lt;/b&gt;, &lt;b&gt;business&lt;/b&gt;, &lt;b&gt;finance&lt;/b&gt;, &lt;b&gt;engineering&lt;/b&gt;, etc.  Those who study the natural sciences have presented arguments about the &lt;b&gt;modularity of nature&lt;/b&gt;.  Biological studies have shown that the evolution of complex organisms are due in part to functional modularity (composition of smaller independent components with clear bound &amp;amp; functions) and behavioral modularity (having traits and attributes that can evolve independently).  To stay closer to the discernible realms, let's examine how contemporary usage of modularity and has affected our modern lives.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Product manufacturers&lt;/b&gt; figured out the way to &lt;b&gt;increase output&lt;/b&gt;, &lt;b&gt;increase quality&lt;/b&gt;, and &lt;b&gt;reduce cost&lt;/b&gt; pressures was &lt;b&gt;in modularity&lt;/b&gt;.  At the turn of last century, industrialist &lt;b&gt;Henry Ford&lt;/b&gt; introduced the notion of modularity in his assembly line with standardized and &lt;b&gt;interchangeable automobile parts&lt;/b&gt;.  He was able to reduce his production cycles and costs to achieve &lt;b&gt;mass production&lt;/b&gt; of his Model-T automobiles.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;adoption of modular architecture&lt;/b&gt;, not processor speed, has been argued to be the quintessential &lt;b&gt;force behind rapid growth and adoption of computing&lt;/b&gt; &lt;b&gt;technologies&lt;/b&gt;.  Today's hardware, while ever decreasing in size, offers cheap information processing power that has permeated through all industries.  Achieving such complex and powerful systems has been possible through the use of modularity.  Manufacturers independently &lt;b&gt;create standardized&lt;/b&gt;, &lt;b&gt;interchangeable  subsystems&lt;/b&gt; (microprocessor, memory chips, input/output devices, etc) that can &lt;b&gt;function together to create complex devices&lt;/b&gt;.  They have been able to build systems with high level of complexity by combining hardware modules (subsystems)  into innumerable configurations.&lt;br /&gt;&lt;br /&gt;In term of longevity, &lt;b&gt;Unix is arguably&lt;/b&gt; one of the &lt;b&gt;most successful operating system&lt;/b&gt; today.  Created in 1969, Unix has been used in all conceivable computing environment from small embedded to research class supercomputers and everything in between.  &lt;b&gt;Unix's success is attributed&lt;/b&gt; to its flexibility and depth made possible by its &lt;b&gt;simple, clean, and orthogonal design&lt;/b&gt;.  As complex an operating system as Unix is, &lt;b&gt;it is composed of simple, distinct, interacting modules &lt;/b&gt;(small programs) with clean interfaces that do one thing and does it well (and nothing more). &lt;br /&gt;&lt;br /&gt;&lt;b&gt;In the world of Java&lt;/b&gt;, there are numerous &lt;b&gt;examples of successful modular designs&lt;/b&gt;.  One of the earliest and most popular was the &lt;b&gt;JBoss application server&lt;/b&gt;.  The JBoss designers realized early on the power of modularity.  They were one of the first to build &lt;b&gt;a modular architecture on the top of the &lt;a title="Java Management eXtensions" href="http://java.sun.com/developer/technicalArticles/J2SE/jmx.html" id="ltnf"&gt;JMX&lt;/a&gt; &lt;/b&gt; (though JMX was designed for management, not a general purpose lightweight component server, its standardized API provided the tools needed to build a modular systems).  Other examples of well-known, successful modular systems include the &lt;b&gt;Eclipse &lt;/b&gt;and the &lt;b&gt;NetBeans &lt;/b&gt;desktop platforms.  Both frameworks let developers build complex desktop applications (including IDE's) using small pluggable modules that interact at runtime.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Modularity in Software&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;So, the question remains: how does one develop modular code?  In disciplines such as engineering and manufacturing, for example, there is a natural affinity to design modularity along the physical attributes of materials.  In software development, however, there are little or no affordances to provide guidance to shape code into standardized modules.  As such, &lt;b&gt;developers tend &lt;/b&gt;to take the path of least resistance and &lt;b&gt;write software systems organically &lt;/b&gt;(i.e. monolithic) where the code produced has little or no clear boundaries.  The next few paragraphs review provide some points on creating modular software.  If you already create your software as modules great, otherwise, you can use the following text as guidelines for your next projects.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;Logical Modularity&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;Generally in software, &lt;b&gt;modularity can be categorized as logical or physical&lt;/b&gt;.&lt;b&gt;  Logical Modularity&lt;/b&gt; is associated with the &lt;b&gt;internal organization of code into logically-related units&lt;/b&gt;.  In modern high level languages, logical modularity usually starts with the class, the smallest code group that can be defined.  In languages such as Java and C#, classes can be further aggregated into packages (namespace in C#) which allows developers to organize code into group of related classes (languages such as Ruby, Scala, Smalltak, Java7 support similar organizational structure with additional semantics for managed components) .&lt;br /&gt;&lt;br /&gt;In the Art of Unix Programming, author Eric S. Raymond provides an iconic rule for modularity that states "... &lt;b&gt;write simple parts connected by clean interfaces&lt;/b&gt;."  Depending on the context, &lt;b&gt;a module can be&lt;/b&gt; implemented as a single &lt;b&gt;class&lt;/b&gt;, several &lt;b&gt;classes &lt;/b&gt;in a package, or an entire &lt;b&gt;API &lt;/b&gt;(a collection of packages).  Regardless of the implementation scale of your module, you should be able to &lt;b&gt;describe its functionality in a single sentence&lt;/b&gt; (i.e. this module calculates tax per zip code).  Your module should expose its functionality as simple interfaces that shield callers from all implementation details.  The functionality of a module should be accessible through a published interface that allows the module to expose its functionalities to the outside world while hiding its implementation details (it is way beyond the scope of this blog entry to provide a comprehensive treatments of design patterns and rules for modularity in software).&lt;br /&gt;&lt;b&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;Physical Modularity&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Physical Modularity&lt;/b&gt;, is probably the earliest form of modularity introduced in software creation.  Physical modularity is comprised of two main components 1) &lt;b&gt;a file that contains compiled code&lt;/b&gt; and other resources 2) &lt;b&gt;an executing environment&lt;/b&gt; that understand how to execute the file.  Developers build and assemble their modules into compiled assets that &lt;b&gt;can be distributed&lt;/b&gt; as single or multiple files.  In Java for instance, the jar file is the unit of physical modularity for code distribution (.Net has the assembly).  The file and its associated meta data is designed to be loaded and executed by the run time environment that understands how run the compiled code.&lt;br /&gt;&lt;br /&gt;Physical modularity can also be affected by the context and scale of abstraction.  Within Java, for instance, the developer community has created and adopted s&lt;b&gt;everal physical modularity strategies&lt;/b&gt; to address different aspects of enterprise development 1) &lt;b&gt;WAR&lt;/b&gt; for web components 2) &lt;b&gt;EJB&lt;/b&gt; for distributed enterprise components 3) &lt;b&gt;EAR&lt;/b&gt; for enterprise application components 4) vendor specific modules such as &lt;b&gt;JBoss Service Archive&lt;/b&gt; (SAR).  These are usually &lt;b&gt;a variation of the JAR file format&lt;/b&gt; with special meta data to target the intended runtime environment.  The &lt;b&gt;current trend of adoption&lt;/b&gt; seems to be pointing to &lt;b&gt;OSGi&lt;/b&gt; as a &lt;b&gt;generic physical module format&lt;/b&gt; (see &lt;a title="Java Modularity (1) - OSGi" href="http://vladimirvivien.com/blogs/ot/2009/03/java-modularity-with-osgi-1.html" id="qck2"&gt;previous post&lt;/a&gt;).  &lt;b&gt;OSGi&lt;/b&gt; provides the Java environment with &lt;b&gt;additional functionalties&lt;/b&gt; that should allow developers to model their modules &lt;b&gt;to scale from small emddeable to complex enterprise components&lt;/b&gt; (a lofty goal in deed).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Why Be Modular?&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;We have seen numerous disciplines have benefited by adopting modularity in process and development efforts.  So, &lt;b&gt;why should you invest time in&lt;/b&gt; implementing a &lt;b&gt;modular architecture&lt;/b&gt; for your next project?  After all, adopting a &lt;b&gt;modular design introduces new overhead&lt;/b&gt; such as change in design practices, module files management as project grows, design- and build-time dependency management, and each group working on a module has a narrow knowledge of the code.  The following is a list of &lt;b&gt;benefits&lt;/b&gt; that you gain that &lt;b&gt;outweigh the headaches&lt;/b&gt; you may encounter in modular design.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Scalable Development&lt;/b&gt;: a modular design allows a &lt;b&gt;project to be naturally subdivided along the lines of its modules&lt;/b&gt;.  A developer (or groups of developers) can be assigned a module to implement independently which can produce an asynchronous project flow.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Testable Code Unit&lt;/b&gt;: when your code is partition into functionally-related chunks, it &lt;b&gt;facilitates the testing of each module&lt;/b&gt; independently. With the proper testing framework, developers can exercise each module (and its constituencies) without having to bring up the entire project.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Build Robust System&lt;/b&gt;: in the monolithic software design, as your system grows in complexity so does its propensity to be brittle (changes in one section causes failure in another).  Modularity lets you&lt;b&gt; build complex system composed of smaller parts&lt;/b&gt; that can be &lt;b&gt;independently managed and maintained&lt;/b&gt;.  Fixes in one portion of the code does not necessarily affect the entire system.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Easier Modification &amp;amp; Maintenance&lt;/b&gt;: post-production system maintenance is another crucial benefit of modular design.  Developers have the &lt;b&gt;ability to fix and make non-infrastructural changes&lt;/b&gt; to module &lt;b&gt;without affecting  other modules&lt;/b&gt;.  The updated module can independently go through the build and release cycle without the need to re-build and redeploy the entire system.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Functionally Scalable&lt;/b&gt;: depending on the level of sophistication of your modular design, it's possible to &lt;b&gt;introduce new functionalities&lt;/b&gt; &lt;b&gt;with little or no change to existing modules&lt;/b&gt;.  This allows your software system to scale in functionality without becoming brittle and a burden on developers.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;In this post, I wanted to provide a broad overview of modularity as a concept and its effect on software system.  We have seen how modularity is intrinsically entrenched in non-computing disciplines and how they all benefit from the practice.  Software is no different, complex systems from desktop applications to enterprise behemoth such as application servers benefit from modularity in design.  It is not the intent of this entry to insinuate that modular design means an end to buggy code.  On the contrary, developers will always write buggy code as long there's code to be written.  However, it is the intent of this entry to show that modularity is a step toward making software development, deployment, and management easier to scale and maintain.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size:130%;"&gt;References&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;1. Merriam-Webster, &lt;a title="http://www.merriam-webster.com/dictionary/Modular" href="http://www.merriam-webster.com/dictionary/Modular" id="oqa-"&gt;http://www.merriam-webster.com/dictionary/Modular&lt;/a&gt;&lt;br /&gt;2. Mark Dodgson, David Gann and Ammon Salter,  Think, Play, Do: Innovation, Technology, and Organization&lt;br /&gt;4. Carliss Young Baldwin and Kim B. Clark, Design Rules: the Power of Modularity&lt;br /&gt;4. Werner Callebaut, Diego Rasskin-Gutman, Herbert A. Simon, Modularity: understanding the development and evolution of natural complex systems&lt;br /&gt;5. Eric S. Raymond, The Art of Unix Programming, 1999&lt;br /&gt;6. Mark Fleury, Juha Lindfors, &lt;i&gt;Enabling Component Architectures with JMX&lt;/i&gt;, &lt;a title="http://www.onjava.com/pub/a/onjava/2001/02/01/jmx.html, 2001" href="http://www.onjava.com/pub/a/onjava/2001/02/01/jmx.html,%202001" id="p28e"&gt;http://www.onjava.com/pub/a/onjava/2001/02/01/jmx.html, 2001&lt;/a&gt;&lt;br /&gt;7. P. Jalote, An Integrated Approach to Software Engineering, 1997&lt;br /&gt;8. Tim Boudreau, Jaroslav Tulach, Geertjan Wielenga Rich Client Programming: Plugin into the NetBeans Platform&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-5878977469553999447?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/5878977469553999447'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/5878977469553999447'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2009/03/why-modularity-matters.html' title='Why Modularity Matters'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/17258719828741411014</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='12578099370892975121'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-1408938372725462059</id><published>2009-03-08T11:20:00.002-04:00</published><updated>2009-03-09T12:33:52.756-04:00</updated><title type='text'>Java Modularity with OSGi (1)</title><content type='html'>I am excited:  the notion of modularity is once again taking center stage in Java land.&lt;br /&gt;&lt;br /&gt;All technology platforms (OS's, languages, applications, etc) eventually face the struggle of providing an adequate level of abstraction to encapsulate modular code unit.  On the MS Windows platform, for instance, there is myriad of technologies including &lt;span class="misspell" suggestions="CL,VAL,VOL,VCR"&gt;VCL&lt;/span&gt;, &lt;span class="misspell" suggestions="BX,VB,PBX"&gt;VBX&lt;/span&gt;, &lt;span class="misspell" suggestions="COX,OX,OCR,OCT"&gt;OCX&lt;/span&gt;, &lt;span class="misspell" suggestions="Actives,Activates,Octaves,Arctics,Activeness"&gt;ActiveX&lt;/span&gt;, COM, &lt;span class="misspell" suggestions="DALL,DELL,DILL,DOLL,DULL"&gt;DLL&lt;/span&gt;, etc, that emerged over the years designed to provide modular, sharable, and distributable code units for specific domains.&lt;br /&gt;&lt;br /&gt;On the Java platform, the story is similar.  From the beginning, the JAR file format provided the means to physically package Java code and resources as modules.  The file format has served its original purpose well giving the means to distribute and reuse the large number of Java &lt;span class="misspell" suggestions="Apia's,Ape's,Apes,Apps,Apr's"&gt;API's&lt;/span&gt; that is available today.  However, while the JAR file format works great for physical modularity, it falls short, however, of supporting a logical component model.  (NOTE: vendors have developed their own component models to address their specific needs, for instance &lt;span class="misspell" suggestions="Spring Source's,Spring-Source's,Princesses"&gt;SpringSource's&lt;/span&gt; Spring Framework, &lt;span class="misspell" suggestions="Jobs,Job's,Boss,Jibs,Jabs"&gt;JBoss&lt;/span&gt; &lt;span class="misspell" suggestions="SAAR,SEAR,SOAR,SA,SAT"&gt;SAR&lt;/span&gt;, Geronimo &lt;span class="misspell" suggestions="Bean,Glean,Gena,Began,Gran"&gt;GBean&lt;/span&gt;, &lt;span class="misspell" suggestions="JIM,MC,JAM,KM,JAME"&gt;JMX&lt;/span&gt; &lt;span class="misspell" suggestions="Beans,Means,Bean's,Bans,Mans"&gt;MBeans&lt;/span&gt;, &lt;span class="misspell" suggestions="Eb's,Eba's,Job's,Jib's,Ebba's"&gt;EJB's&lt;/span&gt;, etc).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;&lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;You have probably heard about &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; and wonder how it fits in the Java landscape.  In short, &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; extends &lt;span class="misspell" suggestions="Jar's,Jae's,Jars,Car's,Gar's"&gt;JAR's&lt;/span&gt; physical modularity into a logical component model (known as bundle).  In &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt;, the bundle can be a living entity that provides services, not a mere container for code API.  As such, &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; affords system developers the following capabilities:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;A Framework&lt;/b&gt;: This is an execution environment for bundles at run-time.  Bundles are loaded, executed, and managed (see OSGi Frameworks below).&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Service Registry&lt;/b&gt;: &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; provides a container where bundles are deployed and can expose services to other registered bundles.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Life-cycle Services and Events&lt;/b&gt;: Allows addition, removal, and update of bundles dynamically at run-time.  The framework publish &lt;span class="misspell" suggestions="life cycle,life-cycle,lifestyle,limescale,fascicle"&gt;lifecycle&lt;/span&gt; events as notifications that can be captured for appropriate reactions.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Service Model&lt;/b&gt;: Ability to expose and discover service interfaces at run-time.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Bundle Isolation&lt;/b&gt;: &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; adheres to strict isolation rules.  Each bundle gets its own class loader.  Visibility of a bundle is specified at the package level, not class.  A Bundles can export its internal packages or indicate its dependency on existing packages hosted by other bundles running in the framework.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Version Dependency&lt;/b&gt;: Expressive and flexible bundle &lt;span class="misspell" suggestions="visioning,veining,version,versions,version's"&gt;versioning&lt;/span&gt; semantics with automatic dependency resolution.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Multi-version Coexistence&lt;/b&gt;: Multiple versions of same bundle can co-exists without any shadowing effect.  &lt;span style="font-weight: bold;"&gt;Client A&lt;/span&gt; can have a dependency on &lt;span style="font-weight: bold;"&gt;bundle X.1&lt;/span&gt; while &lt;span style="font-weight: bold;"&gt;client B&lt;/span&gt; has a dependency on a different version of &lt;span style="font-weight: bold;"&gt;bundle X.2&lt;/span&gt; with no risks of class path collisions (commonly known as Jar Hell).&lt;/li&gt;&lt;li&gt;&lt;b&gt;Dynamic Availability&lt;/b&gt;: part of &lt;span class="misspell" suggestions="Osage's,Sig's,Osages,Issi's,Ossie's"&gt;OSGi's&lt;/span&gt; component model is the notion of bundle dynamic availability.  &lt;b&gt;A bundle is not guaranteed to be available&lt;/b&gt;.  &lt;b&gt;This is good &lt;/b&gt;because you can remove/reload/restart a bundle at runt time (without restarting the framework).  &lt;b&gt;This is not so good&lt;/b&gt; because your bundle has to have mechanism to handle dynamic availability of bundles it depends on.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;b&gt;The &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; Bundle&lt;/b&gt;&lt;br /&gt;Because &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; was designed (from the ground up) to be a component-based platform, an &lt;span style="font-weight: bold;" class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; &lt;span style="font-weight: bold;"&gt;application is a collection of interacting bundles&lt;/span&gt;  running within the framework.  As stated earlier, an &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; bundle is based on the traditional JAR file.  However, &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; uses special meta-data in the META-INF/&lt;span style="font-weight: bold;"&gt;MANIFEST.&lt;/span&gt;&lt;span style="font-weight: bold;" class="misspell" suggestions="MFA,FM,MTF,MFG,MFR"&gt;MF&lt;/span&gt; file of the bundle to specify configuration information used by the &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; framework at &lt;span class="misspell" suggestions="run time,run-time,runtier,reunite,centime"&gt;runtime&lt;/span&gt;.  Below is an example of a &lt;span class="misspell" suggestions="MANIFEST,MAGNIFIES,MEANIES,MANGES,MANES"&gt;MANIFES&lt;/span&gt;.&lt;span class="misspell" suggestions="MFA,FM,MTF,MFG,MFR"&gt;MF&lt;/span&gt; file for a bundle&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;table class="" id="yuuv" border="1" border cellpadding="3" cellspacing="0" style="color:#999999;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td width="100%"&gt;&lt;span style="font-family:Courier New;"&gt;Bundle-&lt;span class="misspell" suggestions="Manifest Version,Manifest-Version,Manifestation"&gt;ManifestVersion&lt;/span&gt;: 2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;Bundle-&lt;span class="misspell" suggestions="Symbolic Name,Symbolic-Name"&gt;SymbolicName&lt;/span&gt;: com.services.demo&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;Bundle-Version: 1.0.0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;b&gt;Bundle-Activator&lt;/b&gt;: com.services.Activator&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;b&gt;Bundle-&lt;span class="misspell" suggestions="Class Path,Class-Path,Clasps,Clasp,Clasping"&gt;ClassPath&lt;/span&gt;&lt;/b&gt;: .,com/services/api.jar&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;b&gt;Import-Package&lt;/b&gt;:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;com.other.services; version=“[1.0.0,2.0.0)”;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;b&gt;Export-Package&lt;/b&gt;:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;com.services.sei; version=1.1;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;br /&gt;Some &lt;b&gt;important items&lt;/b&gt; to notice in the manifest meta data:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b face="Courier New"&gt;Bundle-Activator&lt;/b&gt;: specifies a class that will react to bundle life-cycle events (when the bundle starts and when the bundle stops).  You can use this event as a starting point for functionalities implemented by your bundle (sort of a main() for your &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; application).&lt;/li&gt;&lt;li&gt;&lt;b style="font-family: Courier New;"&gt;Bundle-&lt;span class="misspell" suggestions="Class Path,Class-Path,Clasps,Clasp,Clasping"&gt;ClassPath&lt;/span&gt;&lt;/b&gt;: establishes a &lt;span class="misspell" suggestions="class path,class-path,clasps,clasp,clasping"&gt;classpath&lt;/span&gt; for your bundle's internal library of classes (and jar files).&lt;/li&gt;&lt;li&gt;&lt;b style="font-family: Courier New;"&gt;Import-Package&lt;/b&gt;: this entry specifies the name of a package that the bundle depends on (and expected to be available on the platform).  Notice the version directive specified in the Import-Package declaration.  It uses an interval notation to express dependency on versions 1.0.0 &lt;= X &lt; 2.0.0&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;b style="font-family: Courier New;"&gt;Export-Package&lt;/b&gt;: declares a package in the bundle that should be made available at &lt;span class="misspell" suggestions="run time,run-time,runtier,reunite,centime"&gt;runtime&lt;/span&gt;.  When the bundle is installed in a framework, package will be visible to other installed packages running.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; Frameworks&lt;/b&gt;&lt;br /&gt;You may be wondering where/how do I run an &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; bundle?  You will need a framework.  &lt;b&gt;A framework is an implementation of the &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; service platform specifications&lt;/b&gt; that has the ability to execute bundles.  The framework itself is a small core with system level logic to load bundles.  All of the framework's functionalities come from installed bundles on the framework.  There are several framework implementations available today, the three most popular (and open source) are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;&lt;a title="Apache Felix" target="_blank" href="http://felix.apache.org/" id="oz56"&gt;Apache Felix&lt;/a&gt; &lt;/b&gt; - A small embeddable, developer friendly port of &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; service platform.  It's the basis for many popular projects including &lt;span class="misspell" suggestions="Glass fish,Glass-fish,Glassful,Goldfish,Classifies"&gt;Glassfish&lt;/span&gt; and &lt;span class="misspell" suggestions="Jonas,Jonahs,Jon's,Jones,Jonis"&gt;JOnAS&lt;/span&gt; App Servers.&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a title="Eclipse Equinox" target="_blank" href="http://www.eclipse.org/equinox/" id="vis1"&gt;Eclipse Equinox&lt;/a&gt; &lt;/b&gt; - This is the base for Eclipse &lt;span class="misspell" suggestions="ODE,IDEA,DIE,ID,IDEM"&gt;IDE&lt;/span&gt; (which a collection of bundles known as &lt;span class="misspell" suggestions="plug ins,plug-ins,polygons,plugs,plugging"&gt;plugins&lt;/span&gt; in Eclipse parlance).  It's used in many popular products such as &lt;span class="misspell" suggestions="Spring Source,Spring-Source,Springs,Springer's,Sponsors"&gt;SpringSource&lt;/span&gt; &lt;span class="misspell" suggestions="DEM,DOM,DAM,DIM,MD"&gt;DM&lt;/span&gt; Server and IBM's &lt;span class="misspell" suggestions="Web Sphere,Web-Sphere,Biosphere"&gt;WebSphere&lt;/span&gt;.&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a title="Knopflerfish" target="_blank" href="http://www.knopflerfish.org/" id="z_oa"&gt;&lt;span class="misspell" suggestions=""&gt;Knopflerfish&lt;/span&gt;&lt;/a&gt;&lt;/b&gt; - &lt;span class="misspell" suggestions=""&gt;Knopflerfish&lt;/span&gt; is one of the earliest implementations from the commercial side (gone open source) with presence in automotive, &lt;span class="misspell" suggestions="telecoms,talcum,telex,welcome,telegram"&gt;telecom&lt;/span&gt;, and home automation.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;b&gt;Why Should I Care?&lt;/b&gt;&lt;br /&gt;You will certainly wonder how &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; impacts you.  Well, if you spend most of your day &lt;b&gt;writing enterprise applications&lt;/b&gt;, then &lt;b&gt;&lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; will mean little to you&lt;/b&gt;.  As a matter of fact, vendors are working hard to &lt;b&gt;keep developers away from &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt;-specific concerns&lt;/b&gt;.  You will continue to use enterprise semantics that you are already familiar with and produce enterprise artifacts (&lt;span class="misspell" suggestions="EB,EBB,EBA,JOB,KB"&gt;EJB&lt;/span&gt;, WAR, EAR, etc) that you produce today.  Life is good, keep coding!&lt;br /&gt;&lt;br /&gt;However, if you are &lt;b&gt;system level developer&lt;/b&gt; or simply &lt;b&gt;interested in component-based&lt;/b&gt; development, &lt;b&gt;&lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; may be of great value&lt;/b&gt;.  Already, many vendors are decomposing their products into &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt;-ready jars to allow developers easy deployment on &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; runtimes.  There's also a movement of porting commonly used API's to OSGi by creating a bundle repository  (i.e. Felix Commons and Equinox Orbit). &lt;br /&gt;&lt;br /&gt;Another approach to OSGi integartion is to &lt;b&gt;embed an &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; &lt;span class="misspell" suggestions="framework,frameworks,fretwork,framework's,firework"&gt;framwork&lt;/span&gt;&lt;/b&gt; into your own development &lt;b&gt;to create a component model&lt;/b&gt;.  Eclipse has become the &lt;span class="misspell" suggestions="poster child,poster-child,postlude,pestled,postulate"&gt;posterchild&lt;/span&gt; for this approach using &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; to provide a &lt;span class="misspell" suggestions="plug in,plug-in,plugging,plaguing,ploughing"&gt;plugin&lt;/span&gt; architecture for the &lt;span class="misspell" suggestions="ODE,IDEA,DIE,ID,IDEM"&gt;IDE&lt;/span&gt;.  &lt;b&gt;Felix&lt;/b&gt;, however,  has become the favorite embeddable &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; framework because of its relative small size, easy licensing, and easy API.  One great example of embedded Felix is the &lt;span style="font-weight: bold;"&gt;SIP-Communicator desktop application &lt;/span&gt;which uses &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt;-bundles as &lt;span class="misspell" suggestions="plug ins,plug-ins,polygons,plugs,plugging"&gt;plugins&lt;/span&gt; to extend the application (I am sure there are others).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;I hope this entry got you, at least, interested in &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt;.  I think &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; is &lt;b&gt;a great start toward a unified component model for Java&lt;/b&gt;.  It will certainly get developers to (hopefully) start viewing their systems in terms of components and not just classes.  In future posts, I will look at how to use &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; practically and integrate into your development efforts.&lt;br /&gt;&lt;br /&gt;Even if you don't plan to adopt &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; right away, at least &lt;a title="check it out" target="_blank" href="http://en.wikipedia.org/wiki/OSGi" id="y8sa"&gt;check it out&lt;/a&gt; .&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;References&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;About &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; - &lt;a rel="nofollow" href="http://en.wikipedia.org/wiki/OSGi" target="_blank"&gt;http://en.wikipedia.org/wiki/OSGi&lt;/a&gt;&lt;br /&gt;&lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; Alliance – &lt;a rel="nofollow" href="http://osgi.org/" target="_blank"&gt;http://osgi.org/&lt;/a&gt;&lt;br /&gt;&lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; Articles - &lt;a title="http://www.osgi.org/Links/HomePage" href="http://www.osgi.org/Links/HomePage" id="p:9e"&gt;http://www.osgi.org/Links/HomePage&lt;/a&gt;&lt;br /&gt;&lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; on &lt;span class="misspell" suggestions="Info,Inflow,Inf,Infix,Info's"&gt;InfoQ&lt;/span&gt; - &lt;a rel="nofollow" href="http://www.infoq.com/osgi" target="_blank"&gt;http://www.infoq.com/osgi&lt;/a&gt;&lt;br /&gt;Free &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; Book By Neil &lt;span class="misspell" suggestions="Barrett,Bartlett,Ballet,Barnett,Barrette"&gt;Barlertt&lt;/span&gt; (&lt;span class="misspell" suggestions="PD,PF,PDQ,PDT,PD'S"&gt;PDF&lt;/span&gt;) - &lt;a rel="nofollow" href="http://neilbartlett.name/downloads/osgibook_preview_20090110.pdf" target="_blank"&gt;http://neilbartlett.name/downloads/osgibook_preview_20090110.pdf&lt;/a&gt;&lt;br /&gt;&lt;span class="misspell" suggestions="Eclipse Con,Eclipse-Con,Eclipsing"&gt;EclipseCon&lt;/span&gt; Presentation by Richard S. Hall (&lt;span class="misspell" suggestions="PD,PF,PDQ,PDT,PD'S"&gt;PDF&lt;/span&gt;) - &lt;a rel="nofollow" href="http://felix.apache.org/site/presentations.data/osgiapachecon-20051214.pdf" target="_blank"&gt;http://felix.apache.org/site/presentations.data/osgiapachecon-2005121…&lt;/a&gt;&lt;br /&gt;Eclipse Equinox - &lt;a rel="nofollow" href="http://www.eclipse.org/equinox/" target="_blank"&gt;http://www.eclipse.org/equinox/&lt;/a&gt;&lt;br /&gt;Apache Felix - &lt;a rel="nofollow" href="http://felix.apache.org/" target="_blank"&gt;http://felix.apache.org/&lt;/a&gt;&lt;br /&gt;&lt;span class="misspell" suggestions=""&gt;Knopflerfish&lt;/span&gt; - &lt;a rel="nofollow" href="http://www.knopflerfish.org/" target="_blank"&gt;http://www.knopflerfish.org/&lt;/a&gt;&lt;br /&gt;&lt;span class="misspell" suggestions="Spring Source,Spring-Source,Springs,Springer's,Sponsors"&gt;SpringSource&lt;/span&gt; &lt;span class="misspell" suggestions="Sig,Osage,OS,Os,Orig"&gt;OSGi&lt;/span&gt; - &lt;a rel="nofollow" href="http://www.springsource.org/osgi" target="_blank"&gt;http://www.springsource.org/osgi&lt;/a&gt;&lt;br /&gt;Sip-Communicator Presenation - &lt;a href="http://archive.fosdem.org/2007/slides/lightningtalks/SIPcommunicator.pdf"&gt;http://archive.fosdem.org/2007/slides/lightningtalks/SIPcommunicator.pdf&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-1408938372725462059?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/1408938372725462059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/1408938372725462059'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2009/03/java-modularity-with-osgi-1.html' title='Java Modularity with OSGi (1)'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-1411134257174962693</id><published>2008-12-22T14:28:00.003-05:00</published><updated>2008-12-22T15:12:39.209-05:00</updated><title type='text'>JmxBuilder Finds New Home</title><content type='html'>&lt;span style="font-weight: bold;"&gt;JmxBuilder &lt;/span&gt;has been officially &lt;span style="font-weight: bold;"&gt;incorporated in Groovy&lt;/span&gt; for the 1.6 &lt;a href="http://docs.codehaus.org/display/GROOVY/2008/12/22/Release+Candidate+for+Groovy+1.6+available"&gt;RC-1 release&lt;/a&gt;.  I am delighted that  the Groovy team thought highly of JmxBuilder to make it an addition to the language.  JmxBuilder will have much more features in 2009.  &lt;span style="font-weight: bold;"&gt;Special thanks&lt;/span&gt; to Guillame Laforge and the rest of the Groovy team for all their help in integrating the two projects.&lt;br /&gt;&lt;br /&gt;Because of this change, JmxBuilder will be moved from its current &lt;a href="http://code.google.com/p/groovy-jmx-builder/"&gt;Google code location&lt;/a&gt; once everything is migrated to codehaus.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-1411134257174962693?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/1411134257174962693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/1411134257174962693'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/12/jmxbuilder-finds-new-home.html' title='JmxBuilder Finds New Home'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-3462371520319265878</id><published>2008-12-14T10:34:00.003-05:00</published><updated>2008-12-14T10:42:08.830-05:00</updated><title type='text'>JmxBuilder (Groovy DSL for JMX) Released</title><content type='html'>&lt;p&gt;&lt;a href="http://code.google.com/p/groovy-jmx-builder/"&gt;JmxBuilder 0.5 (beta)&lt;/a&gt; has been released.  After some constructive feedback (see &lt;a href="http://groovy.dzone.com/news/introducing-groovy-jmx-builder"&gt;previous post about JmxBuilder in April&lt;/a&gt; on Dzone), I redesigned the DSL to be more robust, compact, and added new features to help export and programmatically manage MBeans at runtime. The new features focus on building JMX agents, Jmx clients, and participate in the JMX event model.  So, here it is:&lt;/p&gt;&lt;p&gt;Full description at &lt;b&gt;&lt;a href="http://code.google.com/p/groovy-jmx-builder/" target="_blank"&gt;http://code.google.com/p/groovy-jmx-builder/ &lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;JmxBuilder is a Groovy-based domain specific language for the Java Management Extension (JMX) API&lt;/b&gt;. It uses the builder pattern to create an internal DSL that &lt;b&gt;facilitates&lt;/b&gt; the &lt;b&gt;exposure of Java and Groovy beans&lt;/b&gt; &lt;b&gt;for runtime control and management&lt;/b&gt; via the MBean server.The Groovy JMX Builder DSL hides the complexity of creating and exporting management beans via the JMX API and provides a set of natural constructs to interact with the JMX infrastructure.&lt;a name="Features"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a name="Features"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Features&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/a&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a name="Features"&gt;Domain Specific Language &lt;strong&gt;(DSL) for JMX API using Builder pattern&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;Simplified JMX API's programmability&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;Maintain the &lt;strong&gt;natural Groovy syntax&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;Declaratively expose Java/Groovy objects&lt;/strong&gt; as JMX managed MBeans &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;Support &lt;strong&gt;class-embedded&lt;/strong&gt; or &lt;strong&gt;explicit descriptors&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;Inherent &lt;strong&gt;support for JMX's event model&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;Seamlessly create JMX &lt;strong&gt;event broadcasters&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;Attach event listeners&lt;/strong&gt; as inline closures &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;Use Groovy's dynamic nature to &lt;strong&gt;easily react to JMX events notifications&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;Provides a &lt;strong&gt;flexible registration policy&lt;/strong&gt; for MBean &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;No special interfaces&lt;/strong&gt; or class path restrictions &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;&lt;strong&gt;Shields developer from complexity&lt;/strong&gt; of JMX API &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;Exposes &lt;strong&gt;attribute&lt;/strong&gt;, &lt;strong&gt;constructors&lt;/strong&gt;, &lt;strong&gt;operations&lt;/strong&gt;, &lt;strong&gt;parameters&lt;/strong&gt;, and &lt;strong&gt;notifications&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;Simplifies the creation of &lt;strong&gt;connector servers&lt;/strong&gt; and &lt;strong&gt;connector clients&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a name="Features"&gt;Support for &lt;strong&gt;exporting JMX timers&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Learn More&lt;/span&gt;&lt;br /&gt;Here is where you can get more information about JmxBuilder&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a style="font-weight: bold;" href="http://groovy.dzone.com/announcements/jmxbuilder-groovy-dsl-jmx"&gt;Groovy.Dzone Writeup&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a style="font-weight: bold;" href="http://code.google.com/p/groovy-jmx-builder/"&gt;JmxBuilder Project Site&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a style="font-weight: bold;" href="http://code.google.com/p/groovy-jmx-builder/wiki/JmxBuilderReference"&gt;JmxBuilder Reference&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;Check it out.&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-3462371520319265878?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/3462371520319265878'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/3462371520319265878'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/12/jmxbuilder-groovy-dsl-for-jmx-released.html' title='JmxBuilder (Groovy DSL for JMX) Released'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-1635371810303106629</id><published>2008-12-04T10:05:00.003-05:00</published><updated>2008-12-04T10:40:13.103-05:00</updated><title type='text'>JavaFx Is Here!  Could Sun Be on the Right Path?</title><content type='html'>When I saw JavaFax at last's and this year's at JavaOne, I did walked out of the presentations a bit skeptical "... yeah right, how is Sun's going to compete with the deadly Adobe Flex/Flash combination ... it's marketing gimmic" .  Well today (and if you been following JavaFx, for a while)  Sun finally made good on its promise of delivering a Rich Media platform by officially releasing the SDK for JavaFx (at http://javafx.com, the site is being slammed, everything is slow now).&lt;br /&gt;&lt;br /&gt;I must say that I am less skeptical now and cautiously optimistic on the future of Java as a rich media platform.  This could actually work.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Java as viable rich medium&lt;/span&gt;&lt;br /&gt;Using &lt;span style="font-weight: bold;"&gt;JDK 6 update 10&lt;/span&gt; (released earlier) as a base, you now can see how applets are positioning themselves to be a formidable option to the Flex/Flash combo.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;1. Applets load gracefully&lt;/span&gt;&lt;br /&gt;&lt;img src="http://vladimirvivien.com.s3.amazonaws.com/javafx/applet-loading.jpg" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;2. Online streaming videos with Applets&lt;/span&gt;&lt;br /&gt;Here is something you have never done/seen before with Java applets.  Online videos, cool!&lt;br /&gt;&lt;img src="http://vladimirvivien.com.s3.amazonaws.com/javafx/applet-video.jpg" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;3.  Rich Applet &lt;/span&gt;&lt;br /&gt;Look at the skinning, the rich interaction options provided by this applet, yes this not flash, it's a Java applet&lt;br /&gt;&lt;br /&gt;&lt;img src="http://vladimirvivien.com.s3.amazonaws.com/javafx/image-browser-applet.jpg" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;JavaFx.Com &lt;/span&gt;&lt;br /&gt;The site has been redesigned and contains tons of examples and code for you to get started.  I have already dowloaded the SDK today and will start playing around with the technology.  You may encounter heavy traffic.&lt;br /&gt;&lt;img src="http://vladimirvivien.com.s3.amazonaws.com/javafx/javafx-explore-samples.jpg" /&gt;&lt;br /&gt;&lt;br /&gt;I hope that this is just a start and Sun and the Java community continues to support this effort that I think all Java developer will benefit from.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-1635371810303106629?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/1635371810303106629'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/1635371810303106629'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/12/javafx-is-here-could-sun-be-on-right.html' title='JavaFx Is Here!  Could Sun Be on the Right Path?'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-479010075430619280</id><published>2008-11-25T17:01:00.005-05:00</published><updated>2008-11-25T17:35:47.365-05:00</updated><title type='text'>Processing Applets on the new JDK 6 U 10</title><content type='html'>I finally downloaded the latest JDK 6 u 10 (&lt;a href="http://java.sun.com/javase/downloads/index.jsp"&gt;download&lt;/a&gt;) recently.  This is a significant release for the (once again battle front) Desktop.  At this year's JavaOne, Sun made it known that it has all intentions of going back to the desktop.  Update 10 is one of many shots, that, the hardware-originated organization plans to take at its competitors as it transforms itself (i think) into a media/content company (see Project Hydrazine and JavaFx).&lt;br /&gt;&lt;br /&gt;Anyway, after I downloaded update 10, I headed to the one location where I know I will find plenty of applets: &lt;span style="font-size:130%;"&gt;&lt;a style="font-weight: bold;" href="http://processing.org/"&gt;http://processing.org/&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Processing&lt;/span&gt; is an interesting project that started at MIT where Java is used as the center piece for teaching interactive art.  It comes with an IDE and its sole purpose is to quickly create compelling visualization interactive Applets.  The project has, since, expanded to include a hardware platform (&lt;a style="font-weight: bold;" href="http://hardware.processing.org/"&gt;hardware.processing.org&lt;/a&gt;) and even a Java ME port (&lt;a style="font-weight: bold;" href="http://mobile.processing.org"&gt;mobile.processing.org&lt;/a&gt;). Click above to explore other aspect of processing (go directly to the &lt;a style="font-weight: bold;" href="http://www.processing.org/exhibition/curated_page_new.html"&gt;showcase&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;s&lt;/span&gt; or &lt;a style="font-weight: bold;" href="http://www.processing.org/exhibition/network_page_new.html"&gt;links&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;Back to the applets.   With the latest update, all of the applets that I looked at so far took seconds to render (on my 2 yrs old machine).  Once the JRE is loaded, applets rendered in seconds, some near instantaneously.  Applets that manage the download process cleverly (with a splash screen or spinning wheel, etc) provides the sort of rich media experiences that you come to expect now a day online.&lt;br /&gt;&lt;br /&gt;I won't say that Java applets will dethrone the king of online rich media (rhymes with Flash).  But, if these improvements keep up, Adobe will certainly have welcome competition in this arena.  This is certainly good news for developers (choice is good)  and will be a boon for the end users. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Resources&lt;/span&gt;&lt;br /&gt;&lt;a href="http://java.sun.com/javase/downloads/index.jsp"&gt;&lt;/a&gt;&lt;a&gt;http://java.sun.com/javase/downloads/index.jsp&lt;/a&gt;&lt;br /&gt;&lt;a href="http://java.sun.com/javase/6/webnotes/6u10.html"&gt;http://java.sun.com/javase/6/webnotes/6u10.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://processing.org/"&gt;&lt;span style="font-weight: bold;"&gt;http://processing.org/&lt;/span&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-479010075430619280?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/479010075430619280'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/479010075430619280'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/11/processing-applets-on-new-jdk-6-u-10.html' title='Processing Applets on the new JDK 6 U 10'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-8531529616968357905</id><published>2008-06-30T13:22:00.002-04:00</published><updated>2008-06-30T13:40:56.160-04:00</updated><title type='text'>Official Groovy/Grails Support in NetBeans 6.5</title><content type='html'>Judging from the list of features that will be included in NetBeans 6.5, &lt;a style="font-weight: bold;" href="http://wiki.netbeans.org/NewAndNoteWorthyMilestone1NB65#section-NewAndNoteWorthyMilestone1NB65-Groovy"&gt;Groovy and Grails will be officially supported&lt;/a&gt; by the NB team.  From the wiki text, Groovy and Grails will be first-class citizen in NB65 with features that will include:&lt;br /&gt;- Editor support (code completion, color highlights, etc)&lt;br /&gt;- Two-way Java / Groovy class integration&lt;br /&gt;- Seamless Grail project support (support for all Grails artifacts and commands)&lt;br /&gt;- Jetty integration for development-time deployment/testing.&lt;br /&gt;&lt;br /&gt;It remains to be seen if NB65 Groovy support will be as comprehensive as IntelliJ which currently has the most extensive support for Groovy / Grails development.&lt;br /&gt;&lt;br /&gt;For more, go to:&lt;br /&gt;&lt;a href="http://wiki.netbeans.org/NewAndNoteWorthyMilestone1NB65#section-NewAndNoteWorthyMilestone1NB65-Groovy"&gt;http://wiki.netbeans.org/NewAndNoteWorthyMilestone1NB65#section-NewAndNoteWorthyMilestone1NB65-Groovy&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-8531529616968357905?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/8531529616968357905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/8531529616968357905'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/06/official-groovygrails-support-in.html' title='Official Groovy/Grails Support in NetBeans 6.5'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-2469913930383037885</id><published>2008-05-09T18:19:00.002-04:00</published><updated>2008-05-09T18:25:13.514-04:00</updated><title type='text'>JavaOne 2008 - Last Day Notables</title><content type='html'>The last day of JavaOne 2008 was heralded by the final General Session where Sun showcased several cool projects.  Here are a few you maybe interested in.  Some are useful others just plain cool:&lt;br /&gt;&lt;br /&gt;1. VisualVM - This is a great (and seems to be indispensable) tool to do VM runtime monitoring and profiling.  It runs outside of the an IDE and lets you look deep into the VM and your runninig application at runtime.  The profiler is the same that is found in NetBeans and provides a hierarchical navigation and snapshot of all activities of a running application.  Check it out at &lt;a href="https://visualvm.dev.java.net/" target="_blank"&gt;https://visualvm.dev.java.net/&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;2. NetBeans 6.1 JavaScript Support - if you do a lot of JavaScript, then the NetBeans is for you.  In the demo shown on stage, Netbeans manages to make JavaScript development as well-supported as regular Java.  The IDE provides Javadoc-like support, code completion, data structure navigation, on-the-fly documentation, even code hints, etc, etc.  While other IDE such as Intellij has had support for JavaScript for a while, this is the first glimpse of it on the NetBeans platform.&lt;br /&gt;&lt;br /&gt;3. LiveScribe (&lt;a href="http://livescribe.com/" target="_blank"&gt;http://livescribe.com&lt;/a&gt;) - this is not a developer tool, but rather a pen-base computing platform based on the Java Micro Edition.  It records pen stroke and voice as you write.  Describing it here does not do it justice, but the one demo that caught my attention was a translating demo where the presenter wrote words in one language and the pen automatically translates it into different language...&lt;br /&gt;&lt;br /&gt;4. Sentilla, Pervasive Computing Device: Sentilla sells small computing devices meant to be used in sensor networks.  Pervasive computing is the notion that everything around us will (some day) have a microchip.  Companies such as sells a platform to build and deploy these devices everywhere.&lt;br /&gt;&lt;br /&gt;5. JFugue, Music Processing Software - this open source software lets you programmatically build music players in Java.  It uses a simple text base language to describe music timing, rythm, notes, sound bank, etc.  With the JFugue API, you can create music in several ways including direct notation and pattern inference.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-2469913930383037885?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/2469913930383037885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/2469913930383037885'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/05/javaone-2008-last-day-notables.html' title='JavaOne 2008 - Last Day Notables'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-6132890863651433802</id><published>2008-05-08T21:22:00.001-04:00</published><updated>2008-05-08T21:26:17.260-04:00</updated><title type='text'>Integrating Spring and JBoss SAR Components</title><content type='html'>            &lt;font id="to:20" size="4"&gt;&lt;b id="owr30"&gt;Integrating Spring and JBoss SAR Components&lt;/b&gt;&lt;/font&gt;&lt;br id="qbzy0"&gt;          Last time I wrote about JBoss, it was a discussion on how to create a JBoss service component (SAR).  However, in many cases, a SAR component has to be integrated with other component-based technologies.  In this article, I will discuss how to accomplish this by integrating the JBoss with the Spring component model and how to expose Spring components to receive management services from within JBoss JMX Console.&lt;br id="qbzy1"&gt; &lt;br id="qbzy2"&gt; &lt;font id="ls170" size="4"&gt;&lt;b id="owr31"&gt;Integration&lt;/b&gt;&lt;/font&gt;&lt;br id="qbzy3"&gt;          The architecture and implementation of the &lt;span id="onxa0"&gt;&lt;b id="k5ka0"&gt;JBoss service component system differ vastly from the Spring Framework&lt;/b&gt;&lt;/span&gt;'s component model.  &lt;span id="onxa1"&gt;&lt;b id="k5ka1"&gt;JBoss &lt;/b&gt;&lt;/span&gt;(version 4.x and below) &lt;span id="p6xm0"&gt;&lt;b id="k5ka2"&gt;implements its internal kernel&lt;/b&gt;&lt;/span&gt;, for its component container, &lt;span id="p6xm1"&gt;&lt;b id="k5ka3"&gt;completely on the &lt;/b&gt;&lt;/span&gt;&lt;a title="Wikipedia - Java Management Exension" target="_blank" href="http://en.wikipedia.org/wiki/Java_Management_Extensions" id="vom2"&gt;&lt;b id="k5ka4"&gt;Java Management Extension API&lt;/b&gt;&lt;/a&gt;.  As such, when you build a &lt;span id="j3_i0"&gt;&lt;b id="k5ka5"&gt;JBoss components&lt;/b&gt;&lt;/span&gt;, you automatically &lt;span id="j3_i1"&gt;&lt;b id="k5ka6"&gt;inherits all the management facilities exposed by JMX&lt;/b&gt;&lt;/span&gt;.  The &lt;span id="j3_i2"&gt;&lt;b id="k5ka7"&gt;Spring &lt;/b&gt;&lt;/span&gt;container, on the other hand, is &lt;span id="d6yq0"&gt;&lt;b id="k5ka8"&gt;designed &lt;/b&gt;&lt;/span&gt;to be &lt;span id="d6yq1"&gt;&lt;b id="k5ka9"&gt;a lightweight and portable container &lt;/b&gt;&lt;/span&gt;and has the ability to host &lt;a target="_blank" title="POJO on Wikipedia" href="http://en.wikipedia.org/wiki/POJO" id="o8ds"&gt;POJO's&lt;/a&gt; as components.  Therefore, &lt;span id="mb9u0"&gt;&lt;b id="k5ka10"&gt;Spring has become the container of choice&lt;/b&gt;&lt;/span&gt; for many system designers because of its simplicity and portability to be hosted in any environment.&lt;br id="c4dc0"&gt; &lt;br id="qbzy4"&gt; &lt;img id="c-q50" style="width: 496px; height: 323px;" src="http://docs.google.com/File?id=df3qdpw5_83r987gwf6_b"&gt;&lt;br id="ftz60"&gt; &lt;div id="w6pa" style="padding: 1em 0pt; text-align: left;"&gt;As you can see, &lt;span id="r3-v0"&gt;&lt;b id="k5ka11"&gt;integrating Spring&lt;/b&gt;&lt;/span&gt; in another container r&lt;span id="r3-v1"&gt;&lt;b id="k5ka12"&gt;equires some sort of adapter&lt;/b&gt;&lt;/span&gt; that controls how and when the Spring context is created and destroyed.  As we will see later in this document, this can be easily accomplished using a few API calls.&lt;br id="ftz62"&gt; &lt;/div&gt; &lt;font id="ls171" size="3"&gt;&lt;b id="owr32"&gt;Motivation&lt;/b&gt;&lt;/font&gt;&lt;br id="qbzy6"&gt; &lt;span id="ju880"&gt;&lt;b id="owr33"&gt;Why would I want to integrate Spring and JBoss you ask?&lt;/b&gt;&lt;/span&gt; Well, there is an application domain that is not suited to be implemented as web-based apps.  Inevitably, at some point in your career, you will need to implement headless services that expose functionalities without a GUI.  These type of &lt;span id="z5nc0"&gt;&lt;b id="owr34"&gt;services &lt;/b&gt;&lt;/span&gt;are &lt;span id="z5nc1"&gt;&lt;b id="owr35"&gt;temporally durable&lt;/b&gt;&lt;/span&gt; and operate without any human intervention.  When creating these types of &lt;span id="zowh0"&gt;&lt;b id="owr36"&gt;GUI-less services&lt;/b&gt;&lt;/span&gt;, you may decide to use the Spring container as your core operating environment for  POJO components.  Since Spring exposes a uniform abstraction layer for the Enterprise Java API's,  it makes sense to code around Spring so that your implementation is portable to any environment that can host enterprise services (JBoss container, ServiceMix, Mule, EJB's, etc).  Then, your Spring components can leverage services offered by that enterprise environment (database, timers, messaging, adapters, management, etc). &lt;br id="lvrv0"&gt; &lt;br id="lvrv1"&gt; &lt;font id="hpr40" size="3"&gt;&lt;b id="owr37"&gt;Integration Point&lt;/b&gt;&lt;/font&gt;s&lt;br id="qbzy14"&gt;           The portability and programmability of the Spring container makes it an attractive platform for developers to create POJO component-driven apps.  For web-based apps, Spring provides ready-made adapters to easily integrate your Spring context within the servlet container.  However, for &lt;span id="zowh1"&gt;&lt;b id="owr38"&gt;non-web system&lt;/b&gt;&lt;/span&gt;, &lt;span id="aurk0"&gt;&lt;b id="owr39"&gt;Spring does not readily provide specific hooks for integration&lt;/b&gt;&lt;/span&gt; (this is a good thing, it keeps things simple). On the other hand, the Spring API exposes a simple API that makes programming the integration, of Spring in your environment, a seamless effort.  &lt;br id="lywe0"&gt; &lt;br id="l2nt0"&gt; &lt;div id="k:1x" style="padding: 1em 0pt; text-align: left;"&gt;&lt;img style="height: 371px; width: 707px;" id="izu50" src="http://docs.google.com/File?id=df3qdpw5_843wsfrrgw_b"&gt;&lt;/div&gt;          The picture above shows how &lt;span id="mq.v0"&gt;&lt;b id="k5ka13"&gt;Spring integration with the JBoss Application Server can be easily achieved&lt;/b&gt;&lt;/span&gt;.  You &lt;span id="xhnb0"&gt;&lt;b id="owr310"&gt;create a JBoss service component that serves as an adapter&lt;/b&gt;&lt;/span&gt; to the Spring container.  As the JBoss &lt;span id="h-kw0"&gt;&lt;b id="owr311"&gt;service object receives lifecycle events&lt;/b&gt; from the application server&lt;/span&gt;, event-handling logic can be inserted in the adapter to control the creation and management of the Spring context.  &lt;span id="g75d0"&gt;&lt;b id="k5ka14"&gt;Once booted&lt;/b&gt;&lt;/span&gt; and running, the &lt;span id="g75d1"&gt;&lt;b id="k5ka15"&gt;Spring container takes over and mounts its internal POJO components&lt;/b&gt;&lt;/span&gt; and registers them with the available &lt;span id="g75d2"&gt;&lt;b id="k5ka16"&gt;MBean Server&lt;/b&gt;&lt;/span&gt; for management.&lt;br id="qbzy9"&gt;           &lt;br id="qbzy10"&gt; &lt;font id="liwb0" size="4"&gt;&lt;b id="owr312"&gt;The Spring Directory Scanner&lt;/b&gt;&lt;/font&gt;&lt;br id="qbzy11"&gt;          Extending on the example presented in the &lt;a title="Creating A JBoss Service Archive" target="_blank" href="http://vladimirvivien.com/blogs/ot/2007/01/this-write-up-provides-look-into-jboss.html" id="l0jt"&gt;&lt;b id="k5ka17"&gt;previous blog on JBoss components&lt;/b&gt;&lt;/a&gt;,  this example demonstrates how to create a &lt;span id="hq6d0"&gt;&lt;b id="k5ka18"&gt;Spring-based directory scanner&lt;/b&gt;&lt;/span&gt; that gets hosted within the JBoss application container.  The &lt;span id="wz6a0"&gt;&lt;b id="k5ka19"&gt;previous example&lt;/b&gt;&lt;/span&gt;, all of the &lt;span id="wz6a1"&gt;&lt;b id="k5ka20"&gt;logic of the scanner was implemented directly into the JBoss&lt;/b&gt;&lt;/span&gt; service component.  While there's nothing wrong with that approach, &lt;span id="wz6a2"&gt;&lt;b id="k5ka21"&gt;it tightly couples your code with JBoss&lt;/b&gt;&lt;/span&gt; and make it far less portable.  In &lt;span id="wz_g0"&gt;&lt;b id="k5ka22"&gt;this version&lt;/b&gt;&lt;/span&gt; of the scanner, the &lt;span id="vbg20"&gt;&lt;b id="k5ka23"&gt;logic is encapsulated in POJO's hosted within a Spring&lt;/b&gt;&lt;/span&gt; context. &lt;br id="kjdr0"&gt; &lt;br id="kjdr1"&gt; &lt;div id="djsj" style="padding: 1em 0pt; text-align: left;"&gt;&lt;img id="rnl20" style="width: 714px; height: 514px;" src="http://docs.google.com/File?id=df3qdpw5_85cxpgk396_b"&gt;&lt;/div&gt;     A &lt;span id="mjqq0"&gt;&lt;b id="v0_j0"&gt;JBoss service component serves as a Spring adapter&lt;/b&gt;&lt;/span&gt; and manages the creation and destruction of the Spring context from within the JBoss container.  The &lt;span id="mjqq1"&gt;&lt;b id="v0_j1"&gt;spring context is booted up by the JBoss service component&lt;/b&gt;&lt;/span&gt; through life cycle event hooks from the server.  Upon initialization, Spring mounts its POJO's and &lt;span id="g_jc0"&gt;&lt;b id="v0_j2"&gt;exposes the Directory Scanner&lt;/b&gt;&lt;/span&gt; component &lt;span id="g-vt0"&gt;&lt;b id="v0_j3"&gt;for runtime management and control through JMX&lt;/b&gt;&lt;/span&gt;.  Using the &lt;a title="About JConsole" target="_blank" href="http://openjdk.java.net/tools/svc/jconsole/" id="jd-3"&gt;JConsole&lt;/a&gt; or JBoss' Jmx-Console, these components can be managed at runtime locally or remotely.&lt;br id="qbzy12"&gt; &lt;br id="g-vt1"&gt; &lt;font id="lg9g0" size="3"&gt;&lt;b id="v0_j4"&gt;  The Code&lt;/b&gt;&lt;/font&gt;&lt;br id="o01c0"&gt;          The code itself is simple and self explanatory.  The JBoss service component responds to JBoss application server's life cycle events.  These events are used to manage the creation and management of the Spring context.  The &lt;span id="hedl0"&gt;&lt;b id="a5yp0"&gt;Directory Scanner &lt;/b&gt;&lt;/span&gt;Spring component is driven by a Timer Task object mounted in Spring.  Every time the timer expires, it executes the scan() method on the Directory Scanner instance.&lt;br id="e1vk0"&gt; &lt;font id="azkt0" size="3"&gt;&lt;br id="t8540"&gt; &lt;/font&gt;&lt;font id="jm9d0" size="3"&gt;&lt;span id="lg9g1"&gt;&lt;b id="v0_j5"&gt;  The JBoss Service Spring Adapter&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;br id="t8541"&gt;          The JBoss service component is a a plain Java class with life cycle methods named create, destroy, start, stop.  It implements a management interface which exposes these methods for JMX control.  The component deployer will automatically execute methods create() then start() upon instantiation of the service component.&lt;br id="ke.t0"&gt; &lt;br id="ke.t1"&gt; &lt;br id="ke.t2"&gt; &lt;div id="mg8n0"&gt; &lt;table id="sj3j" border="1" bordercolor="#000000" cellpadding="3" cellspacing="0"&gt;&lt;tbody id="mg8n1"&gt; &lt;tr id="mg8n2"&gt; &lt;td id="mg8n3" width="100%"&gt;&lt;code id="cv1w0"&gt; public &lt;span id="cv1w1"&gt;&lt;b id="v0_j6"&gt;interface JBossSpringAdapterMBean &lt;/b&gt;&lt;/span&gt;{&lt;br id="mg8n4"&gt;            void create();&lt;br id="mg8n5"&gt;            void destroy();&lt;br id="mg8n6"&gt;            long getErrorCount();&lt;br id="mg8n7"&gt;            long getSpringComponentCount();&lt;br id="mg8n8"&gt;            String[] getSpringComponents();&lt;br id="mg8n9"&gt;            String getSpringConfigPath();&lt;br id="mg8n10"&gt;            boolean isSpringLoaded();&lt;br id="mg8n11"&gt;            boolean isStarted();&lt;br id="mg8n12"&gt;            void setSpringConfigPath(String path);&lt;br id="mg8n13"&gt;            void start() throws Exception;&lt;br id="mg8n14"&gt;            void stop();&lt;br id="mg8n15"&gt;        } &lt;/code&gt;&lt;br id="mg8n16"&gt; &lt;br id="mg8n17"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt; &lt;br id="qbzy16"&gt;      Besides the life cycle methods, there are other management methods that are added for convenience. For instance, there's a method that returns the error count or one that returns the list components loaded in the spring context. &lt;br id="rs1p0"&gt; &lt;br id="klk_0"&gt;       During the &lt;span id="rcah0"&gt;&lt;b id="lu8_0"&gt;deployment of the JBoss Spring adapter&lt;/b&gt;&lt;/span&gt; (implemented as JBoss service component), the &lt;span id="a40j0"&gt;&lt;b id="lu8_1"&gt;create()&lt;/b&gt;&lt;/span&gt;, &lt;span id="a40j1"&gt;&lt;b id="lu8_2"&gt;destroy()&lt;/b&gt;&lt;/span&gt;, and &lt;span id="a40j2"&gt;&lt;b id="lu8_3"&gt;start() methods&lt;/b&gt;&lt;/span&gt; of the adapter &lt;span id="fs1u0"&gt;&lt;b id="lu8_4"&gt;will be invoked&lt;/b&gt;&lt;/span&gt;&lt;span id="ppct0"&gt;&lt;b id="lu8_5"&gt; by&lt;/b&gt;&lt;/span&gt; the&lt;span id="ppct1"&gt;&lt;b id="lu8_6"&gt; JBoss service archive deployer&lt;/b&gt;&lt;/span&gt;.  This provides an opportunity to instantiate and manage the Spring context at key points during the lifetime of the adapter.  &lt;br id="t0zc2"&gt; &lt;br id="t0zc3" style="font-weight: bold;"&gt; &lt;span id="t0zc4"&gt;&lt;b id="lu8_7"&gt;Booting Spring&lt;/b&gt;&lt;/span&gt;&lt;br id="t0zc5"&gt;    The &lt;span id="eb2j0"&gt;&lt;b id="v0_j8"&gt;create&lt;/b&gt;&lt;/span&gt;() method is called &lt;span id="qr9t0"&gt;&lt;b id="lu8_8"&gt;after&lt;/b&gt;&lt;/span&gt; all the &lt;span id="qr9t1"&gt;&lt;b id="lu8_9"&gt;setters&lt;/b&gt;&lt;/span&gt; are injected with values from the JBoss service descriptor.&lt;br id="gfeg0"&gt; &lt;br id="gfeg1"&gt; &lt;div id="t3gd0"&gt; &lt;table id="au9y" border="1" bordercolor="#333333" cellpadding="3" cellspacing="0"&gt;&lt;tbody id="t3gd1"&gt; &lt;tr id="t3gd2"&gt; &lt;td id="t3gd3" width="100%"&gt;&lt;code id="e.5y0"&gt;public &lt;span id="te0l0"&gt;&lt;b id="lu8_10"&gt;class JBossSpringAdapter&lt;/b&gt;&lt;/span&gt; implements &lt;span id="te0l1"&gt;&lt;b id="lu8_11"&gt;JBossSpringAdapterMBean&lt;/b&gt;&lt;/span&gt; {&lt;br id="q3th0"&gt;     private ClassPathXmlApplicationContext &lt;span id="ktnp1"&gt;&lt;b id="v0_j9"&gt;spring&lt;/b&gt;&lt;/span&gt;; &lt;br id="ktnp2"&gt; &lt;br id="q3th1"&gt; ...   &lt;br id="t3gd4"&gt; &lt;br id="q3th2"&gt;     public void &lt;span id="e.5y1"&gt;&lt;b id="v0_j10"&gt;create&lt;/b&gt;&lt;/span&gt;(){&lt;br id="t3gd5"&gt;              log.info("**** CYCLE: CREATE ****");&lt;br id="t3gd6"&gt;              if(!created){&lt;br id="t3gd7"&gt;                  try{&lt;br id="t3gd8"&gt;                      &lt;span id="ktnp3"&gt;&lt;b id="v0_j11"&gt;spring &lt;/b&gt;&lt;/span&gt;= new &lt;span id="ktnp4"&gt;&lt;b id="v0_j12"&gt;ClassPathXmlApplicationContext&lt;/b&gt;&lt;/span&gt;(&lt;span id="eb2j1"&gt;&lt;b id="v0_j13"&gt;springConfigPath&lt;/b&gt;&lt;/span&gt;);&lt;br id="t3gd9"&gt;                      &lt;span id="eb2j2"&gt;&lt;b id="v0_j14"&gt;spring&lt;/b&gt;&lt;/span&gt;.&lt;span id="eb2j3"&gt;&lt;b id="v0_j15"&gt;registerShutdownHook&lt;/b&gt;&lt;/span&gt;();&lt;br id="t3gd10"&gt;                      created  = true;&lt;br id="t3gd11"&gt;                  }catch(Exception ex){&lt;br id="t3gd12"&gt;                      errorCount++;&lt;br id="t3gd13"&gt;                      created=false;&lt;br id="t3gd14"&gt;                      log.error("Unable to start Spring Context", ex);&lt;br id="t3gd15"&gt;                  }&lt;br id="t3gd16"&gt;              }&lt;br id="t3gd17"&gt;          }&lt;br id="q3th3"&gt; &lt;br id="t3gd18"&gt;      ...&lt;br id="t3gd19"&gt; &lt;/code&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt; &lt;br id="hhvj0"&gt;     The &lt;span id="y4.60"&gt;&lt;b id="v0_j16"&gt;create() method is used to instantiate the Spring context&lt;/b&gt;&lt;/span&gt;.  In the code snippet, the path to the &lt;span id="gtom0"&gt;&lt;b id="lu8_12"&gt;Spring context is injected during deployment&lt;/b&gt;&lt;/span&gt; from the deployment descriptor using the &lt;span id="gtom1"&gt;&lt;b id="lu8_13"&gt;setSpringConfigPath()&lt;/b&gt;&lt;/span&gt; method.  The &lt;span id="gtom2"&gt;&lt;b id="lu8_14"&gt;registerShutdownHook()&lt;/b&gt;&lt;/span&gt; method registers Spring to listens to VM shutdown signal so the context can properly deactivate all of its registered components.&lt;br id="w.vn0"&gt; &lt;br id="tooj0"&gt; &lt;span id="cs8o0"&gt;&lt;b id="lu8_15"&gt;  Shutting Down the Context&lt;/b&gt;&lt;/span&gt;&lt;br id="tooj1"&gt;    On the other hand, when your JBoss adapter class receives a shutdown signal (say, the server is shutting down for instance), you wan to have your Spring context gracefully go down as well. By providing a destroy() method, the JBoss deployer invoke that method when the server sends out a shutdown signal.&lt;br id="kn:n0"&gt; &lt;br id="kn:n1"&gt; &lt;div id="ccsm0"&gt; &lt;table id="zimi" border="1" bordercolor="#000000" cellpadding="2" cellspacing="0"&gt;&lt;tbody id="ccsm1"&gt; &lt;tr id="ccsm2"&gt; &lt;td id="ccsm3" width="100%"&gt;&lt;code id="yl9k0"&gt;    public void &lt;span id="yl9k1"&gt;&lt;b id="lu8_16"&gt;destroy&lt;/b&gt;&lt;/span&gt;() {&lt;br id="w.v20"&gt;            log.info("**** CYCLE: DESTROY ****");&lt;br id="w.v21"&gt;            if(created){&lt;br id="w.v22"&gt;                try{&lt;br id="w.v23"&gt;                    stop();&lt;br id="w.v24"&gt;                    if(spring.isActive()){&lt;br id="w.v25"&gt;                        spring.&lt;span id="yl9k2"&gt;&lt;b id="lu8_17"&gt;close&lt;/b&gt;&lt;/span&gt;();&lt;br id="w.v26"&gt;                      &amp;amp;nbsp; spring.&lt;span id="yl9k3"&gt;&lt;b id="lu8_18"&gt;destroy&lt;/b&gt;&lt;/span&gt;();&lt;br id="w.v27"&gt;                        spring = null;&lt;br id="w.v28"&gt;                    }&lt;br id="w.v29"&gt;                    created = false;&lt;br id="w.v210"&gt;                }catch(Throwable ex){&lt;br id="w.v211"&gt;                    log.error(" Failed to destroy component. ", ex);&lt;br id="w.v212"&gt;                }&lt;br id="w.v213"&gt;            }&lt;br id="w.v214"&gt;        }&lt;/code&gt;&lt;br id="w.v215"&gt; &lt;br id="ccsm4"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;br id="w.v216"&gt; &lt;span id="en5c0"&gt;&lt;b id="lu8_19"&gt;    Controlling the Spring Context&lt;/b&gt;&lt;/span&gt;&lt;br id="qd-s0"&gt;  Another desirable aspect of the adapter is the ability to &lt;span id="ymp70"&gt;&lt;b id="a5yp1"&gt;c&lt;/b&gt;&lt;/span&gt;&lt;span id="l4vt0"&gt;&lt;b id="lu8_20"&gt;ontrol the Spring context with a start / stop functionality&lt;/b&gt;&lt;/span&gt;.  While it is not a necessary, it affords a runtime convenience where the Spring context can be controlled and managed from a JMX console.&lt;br id="w.v217"&gt; &lt;/div&gt; &lt;br id="n1lz0"&gt; &lt;div id="b8l:0"&gt; &lt;table id="av4k" border="1" bordercolor="#000000" cellpadding="2" cellspacing="0"&gt;&lt;tbody id="b8l:1"&gt; &lt;tr id="b8l:2"&gt; &lt;td id="b8l:3" width="100%"&gt;&lt;code id="bmas0"&gt;...&lt;br id="c8yt0"&gt;      public void &lt;span id="w-:y0"&gt;&lt;b id="lu8_21"&gt;start&lt;/b&gt;&lt;/span&gt;() throws Exception {&lt;br id="c8yt1"&gt;          log.info("**** CYCLE: START ****");&lt;br id="c8yt2"&gt;          if(!started){&lt;br id="c8yt3"&gt;              try{&lt;br id="c8yt4"&gt;                  if(!spring.isActive()){&lt;br id="c8yt5"&gt;                      spring.refresh();&lt;br id="c8yt6"&gt;                      spring.start();&lt;br id="c8yt7"&gt;                  }&lt;br id="c8yt8"&gt;                  started = true;&lt;br id="c8yt9"&gt;                  log.info("**** Spring context started OK.****");&lt;br id="c8yt10"&gt;              }catch(Throwable ex){&lt;br id="c8yt11"&gt;                  errorCount++;&lt;br id="c8yt12"&gt;                  started = false;&lt;br id="c8yt13"&gt;                  log.error("**** Failed to start Spring context:", ex);&lt;br id="c8yt14"&gt;              }&lt;br id="c8yt15"&gt;          }&lt;br id="c8yt16"&gt;      }&lt;br id="mvtk0"&gt; &lt;br id="c8yt17"&gt;  ...&lt;br id="c8yt18"&gt; &lt;br id="mvtk1"&gt;      public void &lt;span id="c1o00"&gt;&lt;b id="lu8_22"&gt;stop&lt;/b&gt;&lt;/span&gt;() {&lt;br id="mvtk2"&gt;          log.info("**** CYCLE: STOP ****");&lt;br id="mvtk3"&gt;          if(started){&lt;br id="mvtk4"&gt;              try{&lt;br id="mvtk5"&gt;                  spring.close();&lt;br id="mvtk6"&gt;                  started = false;&lt;br id="mvtk7"&gt;              log.info("**** Spring context stopped OK.****");&lt;br id="mvtk8"&gt;              }catch(Throwable ex){&lt;br id="mvtk9"&gt;                  errorCount++;&lt;br id="mvtk10"&gt;                  started = false;&lt;br id="mvtk11"&gt;                  log.error("**** Failed to stop Spring context:", ex);&lt;br id="mvtk12"&gt;              }&lt;br id="mvtk13"&gt;          }&lt;br id="mvtk14"&gt;      }&lt;br id="mvtk15"&gt; &lt;br id="mvtk16"&gt;  ...&lt;/code&gt;&lt;br id="b8l:4"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt; &lt;br id="qxn70"&gt; &lt;span id="ui_50"&gt;&lt;b id="lu8_23"&gt;The JBoss Service Component Descriptor&lt;/b&gt;&lt;/span&gt;&lt;br id="pt2g0"&gt; The last part of creating the JBoss Spring Adapter, is to create a JBoss Service Descriptor file (jboss-service.xml).  Using this file, you can inject runtime values, and point to a descriptive &lt;span id="enf40"&gt;&lt;b id="lu8_24"&gt;xmbean descriptor file &lt;/b&gt;&lt;/span&gt;that is used to export your service archive component as an JMX MBean.&lt;br id="zng-0"&gt; &lt;br id="zng-1"&gt; &lt;div id="x_tp0"&gt; &lt;table id="nx_t" border="1" bordercolor="#000000" cellpadding="2" cellspacing="0" height="152" width="574"&gt;&lt;tbody id="x_tp1"&gt; &lt;tr id="x_tp2"&gt; &lt;td id="x_tp3" width="100%"&gt;&amp;lt;?&lt;span id="rjm_0"&gt;&lt;b id="lu8_25"&gt;xml &lt;/b&gt;&lt;/span&gt;version="1.0" encoding="UTF-8"?&amp;gt;&lt;br id="rjm_1"&gt; &amp;lt;&lt;span id="rjm_2"&gt;&lt;b id="lu8_26"&gt;server&lt;/b&gt;&lt;/span&gt;&amp;gt;&lt;br id="rjm_3"&gt;     &amp;lt;&lt;span id="rjm_4"&gt;&lt;b id="lu8_27"&gt;mbean &lt;/b&gt;&lt;/span&gt;code="integration.jboss.JBossSpringAdapter" &lt;br id="rjm_5"&gt;            name="demo.integration:name=JBossSpringAdapter,type=Adapter"&lt;br id="rjm_6"&gt;            &lt;span id="rjm_7"&gt;&lt;b id="lu8_28"&gt;xmbean-dd&lt;/b&gt;&lt;/span&gt;="META-INF/spring-adapter-xmbean.xml"&amp;gt;&lt;br id="rjm_8"&gt;         &amp;lt;attribute name="&lt;span id="d40x0"&gt;&lt;b id="z6vp0"&gt;SpringConfigPath&lt;/b&gt;&lt;/span&gt;"&amp;gt;/META-INF/spring.xml&amp;lt;/attribute&amp;gt;&lt;br id="rjm_9"&gt;     &amp;lt;/&lt;span id="rjm_10"&gt;&lt;b id="lu8_29"&gt;mbean&lt;/b&gt;&lt;/span&gt;&amp;gt;&lt;br id="rjm_11"&gt; &amp;lt;/server&amp;gt;&lt;br id="x_tp4"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;br id="rk9s0"&gt; For details about creating a JBoss service component and how to format jboss-service.xml and the Xmbean descriptor file, visit the &lt;a title="See how to create a JBoss service archive" target="_blank" href="http://docs.jboss.org/jbossas/jboss4guide/r2/html/ch2.chapter.html#ch2.writembean.sect" id="pc-y"&gt;JBoss 4 User Guide&lt;/a&gt;.&lt;br id="rjm_13"&gt; &lt;/div&gt; &lt;br style="font-weight: bold;" id="ui_51"&gt; &lt;span id="rfd20"&gt;&lt;b id="lu8_30"&gt;Deploying the JBoss Spring Service Adapter&lt;/b&gt;&lt;/span&gt;&lt;br id="ui_52"&gt; Without going into the implementation of the Spring Directory Scanner component, let's see what happens when the JBoss service archive is deployed.  We expect the JBoss SAR deployer to recognize our JBoss Spring Adapter component as a valid JBoss service archive component and deploy it.  Once deployed, we can validate the deployment through the log and through the JMX Console.&lt;br id="b7qu0"&gt; &lt;br id="e3p20"&gt; &lt;span id="if.c0"&gt;&lt;b id="a5yp2"&gt;JBoss SAR Starting&lt;/b&gt;&lt;/span&gt;&lt;br id="b7qu1"&gt; &lt;div id="ofgv" style="padding: 1em 0pt; text-align: left;"&gt;&lt;img id="w43b0" style="width: 534px; height: 108px;" src="http://docs.google.com/File?id=df3qdpw5_866wzt9rfk_b"&gt;&lt;/div&gt; During deployment, we see the &lt;span id="rfd21"&gt;&lt;b id="lu8_31"&gt;JBossSpringAdapter service component being deployed&lt;/b&gt;&lt;/span&gt; by the application server.  We can also see that the Spring context is being instantiated.&lt;br id="ffbg0"&gt; &lt;br id="e3p21"&gt; &lt;img id="rfd22" style="width: 436px; height: 413px;" src="http://docs.google.com/File?id=df3qdpw5_879qrj69c8_b"&gt;&lt;br id="plgm0"&gt; &lt;br id="plgm1"&gt; JBoss JMX Console shows &lt;span id="plgm2"&gt;&lt;b id="lu8_32"&gt;the JBoss service component JMX management interface&lt;/b&gt;&lt;/span&gt;.&lt;br id="plgm3"&gt; &lt;br id="plgm4"&gt; &lt;div id="b98a" style="padding: 1em 0pt; text-align: left;"&gt;&lt;img id="d6uu0" style="width: 273px; height: 395px;" src="http://docs.google.com/File?id=df3qdpw5_884npxp3df_b"&gt;&lt;/div&gt; The JMX operations for the Spring service adapter are shown above. Notice that &lt;span id="nxk60"&gt;&lt;b id="a5yp3"&gt;you can start and stop the spring container &lt;/b&gt;&lt;/span&gt;at runtime.  That gives you the ability to conrol the lifescyle of your Spring container at runtime without redployment of the application  . This maybe useful if you want to make a configuration change in production without redeployment of the entire application.&lt;br id="u26x0"&gt; &lt;br id="pu8z0"&gt; &lt;font id="i7am0" size="3"&gt;&lt;b id="a5yp4"&gt;The Directory Scanner Spring Component&lt;/b&gt;&lt;/font&gt;&lt;br id="if.c1"&gt; The scanner is a simple Java object which uses the standard java.io.File package to get filtered list of files in a given directory.  You will notice that there are some annotations around the class.  These are Spring-specific annotations used to expose the Directory Scanner class as a managed JMX MBean (this is not covered in this writeup).  I also introduce an interface called Controllable for good form (not necessary).&lt;br id="zqhx0"&gt; &lt;br id="zqhx1"&gt; &lt;span id="iauh0"&gt;&lt;b id="a5yp5"&gt;The Controllable Interface&lt;/b&gt;&lt;/span&gt;&lt;br id="d8iu3"&gt; &lt;br id="d8iu4"&gt; &lt;div id="t10e1"&gt;&lt;/div&gt; &lt;div id="gm.-0"&gt; &lt;table id="vef4" border="1" bordercolor="#000000" cellpadding="3" cellspacing="0" height="104" width="273"&gt;&lt;tbody id="gm.-1"&gt; &lt;tr id="gm.-2"&gt; &lt;td id="gm.-3" width="100%"&gt;&lt;br id="gm.-4"&gt; &lt;code id="iauh1"&gt; public interface &lt;span id="h-ie0"&gt;&lt;b id="a5yp6"&gt;Controllable &lt;/b&gt;&lt;/span&gt;{&lt;br id="gm.-5"&gt;     public void start();&lt;br id="gm.-6"&gt;     public void stop();&lt;br id="gm.-7"&gt; }&lt;/code&gt;&lt;br id="gm.-8"&gt; &lt;br id="gm.-9"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt; &lt;br id="wo5w0"&gt; This interface shows control points that can be implemented in the Directory Scanner.  This is not necessary, but added for completion.&lt;br id="iauh2"&gt; &lt;br id="iauh3"&gt; &lt;span id="x_810"&gt;&lt;b id="a5yp7"&gt;The Directory Scanner Class&lt;/b&gt;&lt;/span&gt;&lt;br id="iauh4"&gt; The class that implements the logic for scanning the directory is divided into three distinct sections&lt;br id="lfkt0"&gt; &lt;ul id="x_811"&gt; &lt;li id="x_812"&gt;The properties (getter/setters) for the component&lt;/li&gt; &lt;li id="x_813"&gt;The life cycle control methods&lt;/li&gt; &lt;li id="x_814"&gt;The scanning method which is invoked to do a sweep of a a directory&lt;/li&gt; &lt;/ul&gt; &lt;br id="r90w0"&gt; &lt;div id="gp0p0"&gt; &lt;table id="lxn3" border="1" bordercolor="#000000" cellpadding="2" cellspacing="0"&gt;&lt;tbody id="gp0p1"&gt; &lt;tr id="gp0p2"&gt; &lt;td id="gp0p3" width="100%"&gt;&lt;code id="h-ie1"&gt;@&lt;span id="h-ie2"&gt;&lt;b id="a5yp8"&gt;ManagedResource&lt;/b&gt;&lt;/span&gt;(description="Directory Scanner Component.",&lt;br id="gp0p4"&gt; objectName="demo.integration:name=DirectoryScanner,type=SpringComponent")&lt;br id="gp0p5"&gt; public &lt;span id="h-ie3"&gt;&lt;b id="a5yp9"&gt;class DirectoryScanner &lt;/b&gt;&lt;/span&gt;implements &lt;span id="h-ie4"&gt;&lt;b id="a5yp10"&gt;Controllable&lt;/b&gt;&lt;/span&gt;{&lt;br id="gp0p6"&gt; &lt;br id="gp0p7"&gt; ...&lt;br id="gp0p8"&gt;     &lt;br id="gp0p9"&gt;     @&lt;span id="h-ie5"&gt;&lt;b id="a5yp11"&gt;ManagedAttribute&lt;/b&gt;&lt;/span&gt;(description="Comma separated list ....")&lt;br id="gp0p10"&gt;     public String &lt;span id="h-ie6"&gt;&lt;b id="a5yp12"&gt;getExtensionList&lt;/b&gt;&lt;/span&gt;() {&lt;br id="gp0p11"&gt;         return (fileFilter != null) ? fileFilter.toString() : null;&lt;br id="gp0p12"&gt;     }&lt;br id="gp0p13"&gt;     &lt;br id="gp0p14"&gt;     @&lt;span id="h-ie7"&gt;&lt;b id="a5yp13"&gt;ManagedAttribute&lt;/b&gt;&lt;/span&gt;&lt;br id="gp0p15"&gt;     public void &lt;span id="h-ie8"&gt;&lt;b id="a5yp14"&gt;setExtensionList&lt;/b&gt;&lt;/span&gt;(String extensionList) {&lt;br id="gp0p16"&gt;         fileFilter = new FileListFilter(extensionList);&lt;br id="gp0p17"&gt;     }&lt;br id="gp0p18"&gt; &lt;br id="gp0p19"&gt;     @&lt;span id="h-ie9"&gt;&lt;b id="a5yp15"&gt;ManagedAttribute&lt;/b&gt;&lt;/span&gt;(description="The directory location to scan.")&lt;br id="gp0p20"&gt;     public String &lt;span id="h-ie10"&gt;&lt;b id="a5yp16"&gt;getLocation&lt;/b&gt;&lt;/span&gt;() {&lt;br id="gp0p21"&gt;         return (location != null) ? location.getPath() : null;&lt;br id="gp0p22"&gt;     }&lt;br id="gp0p23"&gt; &lt;br id="gp0p24"&gt;     @&lt;span id="h-ie11"&gt;&lt;b id="a5yp17"&gt;ManagedAttribute&lt;/b&gt;&lt;/span&gt;&lt;br id="gp0p25"&gt;     public void &lt;span id="h-ie12"&gt;&lt;b id="a5yp18"&gt;setLocation&lt;/b&gt;&lt;/span&gt;(String location) {&lt;br id="gp0p26"&gt;         this.location = new File(location);&lt;br id="gp0p27"&gt;     }&lt;br id="gp0p28"&gt; &lt;br id="gp0p29"&gt; ...&lt;br id="gp0p30"&gt; &lt;br id="gp0p31"&gt;     @&lt;span id="arbb0"&gt;&lt;b id="a5yp19"&gt;ManagedOperation&lt;/b&gt;&lt;/span&gt;(description="Lifecycle to start component.")&lt;br id="gp0p32"&gt;     public void &lt;span id="arbb1"&gt;&lt;b id="a5yp20"&gt;start&lt;/b&gt;&lt;/span&gt;() {&lt;br id="gp0p33"&gt;         started = true;&lt;br id="gp0p34"&gt;         log.info("**** Directory Scanner Compoennt started OK.");&lt;br id="gp0p35"&gt;     }&lt;br id="gp0p36"&gt; &lt;br id="gp0p37"&gt;     @&lt;span id="arbb2"&gt;&lt;b id="a5yp21"&gt;ManagedOperation&lt;/b&gt;&lt;/span&gt;(description="Lifecycle to stop component.")&lt;br id="gp0p38"&gt;     public void &lt;span id="arbb3"&gt;&lt;b id="a5yp22"&gt;stop&lt;/b&gt;&lt;/span&gt;() {&lt;br id="gp0p39"&gt;         started = false;&lt;br id="gp0p40"&gt;         log.info("**** Directory Scanner Compoennt stopped OK.");&lt;br id="gp0p41"&gt;     }&lt;br id="gp0p42"&gt; &lt;br id="gp0p43"&gt; ...&lt;br id="gp0p44"&gt; &lt;br id="gp0p45"&gt;     public void &lt;span id="arbb4"&gt;&lt;b id="a5yp23"&gt;scan&lt;/b&gt;&lt;/span&gt;() throws RuntimeException {&lt;br id="gp0p46"&gt;         if (started) {&lt;br id="gp0p47"&gt;             if (location != null &amp;amp;&amp;amp; location.isDirectory()) {&lt;br id="gp0p48"&gt;                 File[] list = location.listFiles(fileFilter);&lt;br id="gp0p49"&gt;                 log.info("Scanned files with extensions [ " + fileFilter.toString() + "]" +&lt;br id="gp0p50"&gt;                         " from [" + location.getAbsolutePath() + "]");&lt;br id="gp0p51"&gt;             } else {&lt;br id="gp0p52"&gt;                 log.warn("Unable to scan location  Make sure it's valid.");&lt;br id="gp0p53"&gt;             }&lt;br id="gp0p54"&gt;         }&lt;br id="gp0p55"&gt;     }&lt;br id="gp0p56"&gt; &lt;br id="gp0p57"&gt; }&lt;/code&gt;&lt;br id="gp0p58"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt; &lt;br id="e6eu0"&gt; As you can see, this is a simple class.  The thing to notice is the Spring-specific annotations that decorate the class.  They are used to export and describe the class as a JMX MBean server.  It's beyond the scope of this write up to go into the details of how to do this in Spring.  However the next section shows the Spring file that describes and wire it all together.&lt;br id="c.7y0"&gt; &lt;br style="font-weight: bold;" id="c.7y1"&gt;&lt;span id="kanm0"&gt;&lt;b id="a5yp24"&gt; The Spring Configuration File&lt;/b&gt;&lt;/span&gt;&lt;br id="c.7y2"&gt; The configuration of this component is simple and straight forward.  &lt;br id="hya00"&gt; &lt;br id="ok0o0"&gt; &lt;div id="s6ao0"&gt; &lt;table id="igif" border="1" bordercolor="#000000" cellpadding="2" cellspacing="0"&gt;&lt;tbody id="s6ao1"&gt; &lt;tr id="s6ao2"&gt; &lt;td id="s6ao3" width="100%"&gt;&lt;code id="labh0"&gt;    &amp;lt;bean id="scanner" class="component.spring.DirectoryScanner" init-method="start" destroy-method="stop"&amp;gt;&lt;br id="wadj0"&gt;         &amp;lt;property name="location" value="../../"/&amp;gt;&lt;br id="wadj1"&gt;         &amp;lt;property name="extensionList" value="*"/&amp;gt;&lt;br id="wadj2"&gt;     &amp;lt;/bean&amp;gt;&lt;/code&gt;&lt;br id="s6ao4"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt; Above, we see the &lt;span id="labh2"&gt;&lt;b id="a5yp25"&gt;DirectoryScanner &lt;/b&gt;&lt;/span&gt;being configured to scan two directory up from where the application is invoked.  Also, we set the list of files to scan.&lt;br id="hya01"&gt; &lt;br id="wadj3"&gt; &lt;br id="wadj4"&gt; &lt;div id="od8s0"&gt; &lt;table id="t93m" border="1" bordercolor="#000000" cellpadding="2" cellspacing="0" height="344" width="748"&gt;&lt;tbody id="od8s1"&gt; &lt;tr id="od8s2"&gt; &lt;td id="od8s3" width="100%"&gt;&lt;code id="labh3"&gt;    &amp;lt;bean id="timerFactory"&lt;br id="od8s4"&gt;           class="org.springframework.scheduling.timer.TimerFactoryBean"&amp;gt;&lt;br id="od8s5"&gt;         &amp;lt;property name="scheduledTimerTasks"&amp;gt;&lt;br id="od8s6"&gt;             &amp;lt;list&amp;gt;&lt;br id="od8s7"&gt;                 &amp;lt;ref bean="scheduledTimerTask" /&amp;gt;&lt;br id="od8s8"&gt;             &amp;lt;/list&amp;gt;&lt;br id="od8s9"&gt;         &amp;lt;/property&amp;gt;&lt;br id="od8s10"&gt;     &amp;lt;/bean&amp;gt;&lt;br id="od8s11"&gt;     &lt;br id="od8s12"&gt;     &amp;lt;bean id="scheduledTimerTask"&lt;br id="od8s13"&gt;           class="org.springframework.scheduling.timer.ScheduledTimerTask"&amp;gt;&lt;br id="od8s14"&gt;         &amp;lt;property name="period" value="3000" /&amp;gt;&lt;br id="od8s15"&gt;         &amp;lt;property name="timerTask" ref="timer" /&amp;gt;&lt;br id="od8s16"&gt;     &amp;lt;/bean&amp;gt;&lt;br id="od8s17"&gt;     &lt;br id="od8s18"&gt;     &amp;lt;bean id="timer"&lt;br id="od8s19"&gt;           class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean"&amp;gt;&lt;br id="od8s20"&gt;         &amp;lt;property name="targetObject" ref="scanner" /&amp;gt;&lt;br id="od8s21"&gt;         &amp;lt;property name="targetMethod" value="scan" /&amp;gt;&lt;br id="od8s22"&gt;     &amp;lt;/bean&amp;gt;&lt;/code&gt;&lt;br id="od8s24"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt; The stuff above is&lt;span id="ngng0"&gt;&lt;b id="a5yp26"&gt; boiler plate for setting up timer services&lt;/b&gt;&lt;/span&gt; from Spring.  Here we are &lt;span id="kanm1"&gt;&lt;b id="a5yp27"&gt;declaratively &lt;/b&gt;&lt;/span&gt;setting the timer to invoke the scan() method on the DirectoryScanner POJO wired above.&lt;br id="h7510"&gt; &lt;br id="h7512"&gt; &lt;div id="nrpc0"&gt; &lt;table id="mjay" border="1" bordercolor="#000000" cellpadding="2" cellspacing="0" height="344" width="749"&gt;&lt;tbody id="nrpc1"&gt; &lt;tr id="nrpc2"&gt; &lt;td id="nrpc3" width="100%"&gt;&lt;code id="labh4"&gt;    &amp;lt;bean id="exporter" class="org.springframework.jmx.export.MBeanExporter"&amp;gt;&lt;br id="p4tp0"&gt;         &amp;lt;property name="assembler" ref="assembler"/&amp;gt;&lt;br id="p4tp1"&gt;         &amp;lt;property name="namingStrategy" ref="namingStrategy"/&amp;gt;&lt;br id="p4tp2"&gt;         &amp;lt;property name="autodetect" value="true"/&amp;gt;&lt;br id="p4tp3"&gt;         &amp;lt;property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING"/&amp;gt;&lt;br id="p4tp4"&gt;     &amp;lt;/bean&amp;gt;&lt;br id="p4tp5"&gt;     &amp;lt;bean id="jmxAttributeSource"&lt;br id="p4tp6"&gt;           class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource"/&amp;gt;&lt;br id="p4tp7"&gt; &lt;br id="p4tp8"&gt;     &amp;lt;!-- will create management interface using annotation metadata --&amp;gt;&lt;br id="p4tp9"&gt;     &amp;lt;bean id="assembler"&lt;br id="p4tp10"&gt;           class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler"&amp;gt;&lt;br id="p4tp11"&gt;         &amp;lt;property name="attributeSource" ref="jmxAttributeSource"/&amp;gt;&lt;br id="p4tp12"&gt;     &amp;lt;/bean&amp;gt;&lt;br id="p4tp13"&gt; &lt;br id="p4tp14"&gt;     &amp;lt;!-- will pick up the ObjectName from the annotation --&amp;gt;&lt;br id="p4tp15"&gt;     &amp;lt;bean id="namingStrategy"&lt;br id="p4tp16"&gt;           class="org.springframework.jmx.export.naming.MetadataNamingStrategy"&amp;gt;&lt;br id="p4tp17"&gt;         &amp;lt;property name="attributeSource" ref="jmxAttributeSource"/&amp;gt;&lt;br id="p4tp18"&gt;     &amp;lt;/bean&amp;gt;&lt;/code&gt;&lt;br id="nrpc4"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt; Finally, the code snippet above &lt;span id="foi.0"&gt;&lt;b id="a5yp28"&gt;sets up the POJO to be exported &lt;/b&gt;&lt;/span&gt;as an &lt;span id="foi.1"&gt;&lt;b id="a5yp29"&gt;MBean &lt;/b&gt;&lt;/span&gt;into the running &lt;span id="foi.2"&gt;&lt;b id="a5yp30"&gt;MBeanServer&lt;/b&gt;&lt;/span&gt;.  This configuration relies on the annotation embedded in the class to derive the meta data used to describe the class inside the MBeanServer.&lt;br id="c2m20"&gt;&lt;br style="font-weight: bold;" id="c2m21"&gt;&lt;span id="u75e0"&gt;&lt;b&gt;Download Source&lt;/b&gt;&lt;/span&gt;&lt;br id="c2m22"&gt;&lt;a title="You can download" target="_blank" href="http://vladimirvivien.com.s3.amazonaws.com/jBoss-spring-integration.zip" id="k5-a"&gt;&lt;b&gt;You can download&lt;/b&gt;&lt;/a&gt; the application sample application to get the code source.&lt;br id="u75e1"&gt;&lt;br id="lihu0"&gt;&lt;font id="rvh90" size="4"&gt;&lt;b id="a5yp31"&gt;Observations&lt;/b&gt;&lt;/font&gt;&lt;br id="jcp40"&gt;&lt;ul id="h51v0"&gt;&lt;li id="h51v1"&gt;&lt;span id="rvh91"&gt;&lt;b id="a5yp32"&gt;Think in Component&lt;/b&gt;&lt;/span&gt; - &lt;span id="f-:j0"&gt;&lt;b id="a5yp33"&gt;component-based development is incredibly easy to get into and understand&lt;/b&gt;&lt;/span&gt;.  It facilitates the separation of concerns and promotes forces you into better coding practices (testing, loose coupling, re-usability, etc).&lt;/li&gt;&lt;li id="h51v2"&gt;&lt;span id="nar30"&gt;&lt;b id="a5yp34"&gt;JBoss Service Component Evolving&lt;/b&gt;&lt;/span&gt; - Starting with version 4.x, &lt;span id="f-:j1"&gt;&lt;b id="a5yp35"&gt;JBoss components can now be annoted&lt;/b&gt;&lt;/span&gt; (instead of using the descriptor file) to describe its meta characteristics for JMX.  Starting with version 5, JBoss will switch to OSGi as the executable unit for its components.&lt;/li&gt;&lt;li id="h51v3"&gt;&lt;span id="bp_10"&gt;&lt;b id="a5yp36"&gt;Exception Management&lt;/b&gt;&lt;/span&gt; - &lt;span id="xrt80"&gt;&lt;b id="a5yp37"&gt;When deploying components&lt;/b&gt;&lt;/span&gt; into a container (such as JBoss app server), great care must be taken to &lt;span id="xrt81"&gt;&lt;b id="a5yp38"&gt;handle exceptions properly&lt;/b&gt;&lt;/span&gt;.  In JBoss (version 4.x), when a component throws an &lt;span id="n6yj0"&gt;&lt;b id="a5yp39"&gt;unhandled exception&lt;/b&gt;&lt;/span&gt;, that &lt;span id="u4j50"&gt;&lt;b id="a5yp40"&gt;component is immediately disabled&lt;/b&gt;&lt;/span&gt; and shutdown.  You must catch all exceptions and handle them properly.  In &lt;span id="p27r0"&gt;&lt;b id="a5yp41"&gt;DirectoryScanner&lt;/b&gt;&lt;/span&gt;, for instance, &lt;span id="lhk70"&gt;&lt;b id="a5yp42"&gt;if the scan() method throws&lt;/b&gt;&lt;/span&gt; an exception during a scanning request, the &lt;span id="jkhl0"&gt;&lt;b id="a5yp43"&gt;entire component is deactivated&lt;/b&gt;&lt;/span&gt;.&lt;/li&gt;&lt;li id="h51v3"&gt;&lt;span id="a3vj0"&gt;&lt;b id="a5yp44"&gt;(OSGi) Components Are Here to Stay&lt;/b&gt;&lt;/span&gt; - &lt;span id="by8h0"&gt;&lt;b id="a5yp45"&gt;All major containers&lt;/b&gt;&lt;/span&gt; including &lt;span id="by8h1"&gt;&lt;b id="a5yp46"&gt;JBoss AS&lt;/b&gt;&lt;/span&gt;, &lt;span id="i8c20"&gt;&lt;b id="a5yp47"&gt;SpringSource App Platform&lt;/b&gt;&lt;/span&gt;, IBM &lt;span id="i8c21"&gt;&lt;b id="a5yp48"&gt;WebSphere&lt;/b&gt;&lt;/span&gt;, &lt;span id="i8c22"&gt;&lt;b id="a5yp49"&gt;Glassfish&lt;/b&gt;&lt;/span&gt;, and &lt;span id="i8c23"&gt;&lt;b id="a5yp50"&gt;JOnAs &lt;/b&gt;&lt;/span&gt;&lt;span id="no4x0"&gt;&lt;b id="a5yp51"&gt;support OSGi&lt;/b&gt;&lt;/span&gt; bundles as their coarse component model.&lt;br id="yjff0"&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br id="rvh92"&gt;&lt;font id="pt3i0" size="4"&gt;&lt;b id="a5yp52"&gt;Refereces&lt;/b&gt;&lt;/font&gt;&lt;br id="q1u00"&gt;&lt;ol id="c2m23"&gt;&lt;li id="c2m24"&gt;&lt;span id="c2m25"&gt;&lt;b&gt;Source for Directory Scanner&lt;/b&gt;&lt;/span&gt; - &lt;a title="http://vladimirvivien.com.s3.amazonaws.com/jBoss-spring-integration.zip" target="_blank" href="http://vladimirvivien.com.s3.amazonaws.com/jBoss-spring-integration.zip" id="x8hq"&gt;http://vladimirvivien.com.s3.amazonaws.com/jBoss-spring-integration.zip&lt;/a&gt; &lt;/li&gt;&lt;li id="c2m26"&gt;JBoss Server Microkernel - &lt;a title="http://docs.jboss.org/jbossas/jboss4guide/r4/html/ch2.chapter.html" target="_blank" href="http://docs.jboss.org/jbossas/jboss4guide/r4/html/ch2.chapter.html" id="ot7-"&gt;http://docs.jboss.org/jbossas/jboss4guide/r4/html/ch2.chapter.html&lt;/a&gt; &lt;/li&gt;&lt;li id="c2m27"&gt;Spring Documentation - &lt;a title="http://static.springframework.org/spring/docs/2.5.x/reference/index.html" target="_blank" href="http://static.springframework.org/spring/docs/2.5.x/reference/index.html" id="aumn"&gt;http://static.springframework.org/spring/docs/2.5.x/reference/index.html&lt;/a&gt; &lt;/li&gt;&lt;li id="c2m28"&gt;Spring JMX Documentation - &lt;a title="http://static.springframework.org/spring/docs/2.5.x/reference/jmx.html" target="_blank" href="http://static.springframework.org/spring/docs/2.5.x/reference/jmx.html" id="hc92"&gt;http://static.springframework.org/spring/docs/2.5.x/reference/jmx.html&lt;/a&gt; &lt;/li&gt;&lt;li id="c2m29"&gt;OSGi - &lt;a title="http://en.wikipedia.org/wiki/OSGi" target="_blank" href="http://en.wikipedia.org/wiki/OSGi" id="hsuh"&gt;http://en.wikipedia.org/wiki/OSGi&lt;/a&gt; &lt;/li&gt;&lt;li id="c2m210"&gt;OSGi and Spring - &lt;a title="http://www.infoq.com/interviews/osgi-adrian-colyer" target="_blank" href="http://www.infoq.com/interviews/osgi-adrian-colyer" id="lo7n"&gt;http://www.infoq.com/interviews/osgi-adrian-colyer&lt;/a&gt; &lt;/li&gt;&lt;/ol&gt; &lt;br id="fvy30"&gt;&lt;br id="sq100"&gt;&lt;br id="zex_0"&gt;&lt;br id="iyjz0"&gt;&lt;br id="mvaf0"&gt;&lt;br id="n5fu0"&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-6132890863651433802?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/6132890863651433802'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/6132890863651433802'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/05/integrating-spring-and-jboss-sar.html' title='Integrating Spring and JBoss SAR Components'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-6552334684584236481</id><published>2008-05-08T12:11:00.003-04:00</published><updated>2008-05-08T12:23:35.495-04:00</updated><title type='text'>JavaOne - OSGi Is Huge Here!</title><content type='html'>If you doubted that OSGi can achieve mass appeal, the list of sessions at J1 proves contrary.   Most major tool vendors has either implemented it or have plans to support OSGi bundles:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;OSGi has been in IBM's  arsenal for while now (Eclipse, Websphere, etc)&lt;/li&gt;&lt;li&gt;SpringSource's new Spring Application Platform uses OSGi has its &lt;/li&gt;&lt;li&gt;Glassfish Version 3 will be OSGi-bundle compatible&lt;/li&gt;&lt;li&gt;JBoss 5's kernel will load its component as OSGi&lt;/li&gt;&lt;li&gt;JSR 277, the Java Module system, slated for JDK7, can load OSGi bundles&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;From small embedded devices, to desktop, to the large application server, OSGi seems to be the component model that the industry is adopting.  It will be interesting to see how the corporate developer integrates OSGi in their development rituals.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-6552334684584236481?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/6552334684584236481'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/6552334684584236481'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/05/javaone-osgi-is-huge-here.html' title='JavaOne - OSGi Is Huge Here!'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-6112084086072090468</id><published>2008-05-07T10:08:00.004-04:00</published><updated>2008-05-07T10:55:39.303-04:00</updated><title type='text'>JavaOne 2008 - Sun, Lifestyle Company?</title><content type='html'>On day one of the JavaOne, the theme is clear:  JavaFx (http://javafx.com/) is here to stay.  The FX story is coalescing into a platform clearly targeting digital lifestyle experiences.  It is clear that tremendous of resources are being devoted to bring the FX story together as technology stack with support for rich that stretches from mobile devices, desktop, to the backend.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The Tools&lt;/span&gt;&lt;br /&gt;- Continued JavaFX support from NetBeans&lt;br /&gt;- &lt;span style="font-weight: bold;"&gt;Photoshop/Illustrator&lt;/span&gt; plug-in's to export art work as JavaFx artifacts directly&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The Features&lt;/span&gt;&lt;br /&gt;- JDK 6 update 10 (jdk 6u10) - setting the path for the desktop features envisioned by Sun&lt;br /&gt;- Applets - Sun is going back to the Applets as a way to augment browsing experiences.&lt;br /&gt;- Audio/Video - under the FX unbrella Sun is offereing an HD qualility a/v codec for Java&lt;br /&gt;- FX is slated to target devices such as cellphones and other mobile stacks with a consistent user experience from device to desktop.&lt;br /&gt;- Project Hydrazyne: another Sun initiative to let users easily create rich content and experiences dritributed in a Sun hosted cloud.&lt;br /&gt;&lt;br /&gt;I would like to see this effort successeed, for anything elese, just to have competition in the content technology market place.  Adobe leads that sector, Microsoft is making inroad with Silverlight, now Sun wants to give Java developer a way into the rich content user exeperience.&lt;br /&gt;&lt;br /&gt;You just have to read the blogs around the net to find doubters about this strategy laid out by Sun.  However, I think if the company remains on message, provide the tools, continue to share the vision, there will be new convert.  Lets see what happens!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-6112084086072090468?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/6112084086072090468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/6112084086072090468'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/05/javaone-2008-sun-lifestyle-company.html' title='JavaOne 2008 - Sun, Lifestyle Company?'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-4761886190472352352</id><published>2008-04-09T06:41:00.002-04:00</published><updated>2008-04-09T07:05:23.968-04:00</updated><title type='text'>Introducing Groovy JMX Builder</title><content type='html'>After I attended the &lt;span style="font-weight: bold;"&gt;Groovy/Grails Experience&lt;/span&gt; in February this year, I realize that the Groovy builder pattern can be used to façade many other API's (not just swing).  So, I decide to create, yet another builder, for the JMX API and here it is!&lt;br /&gt;&lt;br /&gt;&lt;a href="http://code.google.com/p/groovy-jmx-builder/"&gt;http://code.google.com/p/groovy-jmx-builder/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;span style="font-size:130%;"&gt;&lt;a id="Features"&gt;Features&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a id="Features"&gt;Ability to &lt;strong&gt;expose any class&lt;/strong&gt; instance for management for both Java and Groovy classes. &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a id="Features"&gt;&lt;strong&gt;No need&lt;/strong&gt; to implement a specific management interface. &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a id="Features"&gt;&lt;strong&gt;Shield developer from complexity&lt;/strong&gt; of JMX API &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a id="Features"&gt;&lt;strong&gt;Use&lt;/strong&gt; familiar Groovy &lt;strong&gt;builder pattern&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a id="Features"&gt;Exposes &lt;strong&gt;attribute&lt;/strong&gt;, &lt;strong&gt;constructors&lt;/strong&gt;, &lt;strong&gt;operations&lt;/strong&gt;, &lt;strong&gt;parameters&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Suppose you have a class called Greeter&lt;/span&gt; (on your class path) that prints out greeting to a specified person in a specified language, so the class may look like this&lt;br /&gt;&lt;br /&gt;&lt;pre class="prettyprint"&gt;&lt;a id="Example"&gt;public class Greeter {&lt;br /&gt;private String name;&lt;br /&gt;private String language = "en";&lt;br /&gt;&lt;br /&gt;// ...&lt;br /&gt;&lt;br /&gt;public String getName() {&lt;br /&gt;    return name;&lt;br /&gt;}&lt;br /&gt;public void setName(String name) {&lt;br /&gt;    this.name = name;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// ...&lt;br /&gt;&lt;br /&gt;public String greet(){&lt;br /&gt;    String greet = (String) (langs.containsKey(getLanguage()) ?&lt;br /&gt;        langs.get(getLanguage()) : langs.get("en"));&lt;br /&gt;    return greet + " " + getName();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; String greet(String person){&lt;br /&gt;    return  langs.get(language) + " " + person&lt;br /&gt;}&lt;br /&gt;}&lt;/a&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a id="Groovy_JMX_Builder"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;You can &lt;span style="font-weight: bold;"&gt;use Groovy Jmx Builder to expose an instance&lt;/span&gt; of that class for management as an MBean.&lt;br /&gt;&lt;br /&gt;&lt;pre class="prettyprint"&gt;&lt;a id="Example"&gt;def greeter = new Greeter()&lt;br /&gt;JmxBuilder jmx = new JmxBuilder()&lt;br /&gt;def server = jmx.export(svr){&lt;br /&gt; bean(greeter){&lt;br /&gt;     name("greeterDemo:service=greeting")&lt;br /&gt;     desc("This service prints a greeting on console")&lt;br /&gt;     attribute(name:"name", desc:"name of person to greet", writable:true)&lt;br /&gt;     attribute(name:"language", desc:"the language to use", editable:true)&lt;br /&gt;     operation(name:"greet", desc:"Sends greeting to user")&lt;br /&gt;     operation(name:"greet", desc:"Send greeting to user"){&lt;br /&gt;         parameter(type:"java.lang.String", name:"Person", desc:"The person to send greeting to")&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; bean(object:greeter, name:"greeterDemo:service=greeting2")&lt;br /&gt;}&lt;/a&gt;&lt;/pre&gt;You use the JmxBuilder() class to capture meta data about your class instance that will be made available at runtime for management.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;In JConsole&lt;/span&gt;, the generated MBean may look like this&lt;br /&gt;&lt;br /&gt;&lt;img src="http://groovy-jmx-builder.s3.amazonaws.com/jmx-builder-jconsole.png" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Feedbacks&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;I am interested in feedbacks for this project.  So, download it and give it a try.  I will be adding more features to it in the future.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-4761886190472352352?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/4761886190472352352'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/4761886190472352352'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/04/introducing-groovy-jmx-builder.html' title='Introducing Groovy JMX Builder'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-5142844489258748659</id><published>2008-03-04T19:02:00.001-05:00</published><updated>2008-03-04T19:04:39.929-05:00</updated><title type='text'>Using Groovy's FactoryBuilderSupport to Build Internal DSL</title><content type='html'>            &lt;font size="5"&gt;&lt;br&gt;&lt;b&gt;Using Groovy's FactoryBuilderSupport to Build Internal DSL&lt;/b&gt;&lt;/font&gt;&lt;br&gt; &lt;br&gt; Couple of weeks ago at the &lt;a href="http://groovygrails.com/gg/2gexperience" id="dwhg" title="http://groovygrails.com/gg/2gexperience"&gt;Groovy/Grails Experience&lt;/a&gt; conf, &lt;a href="http://groovy.codehaus.org/Dynamic+Groovy" id="flql" title="Groovy's meta programming"&gt;&lt;b&gt;Groovy's meta programming&lt;/b&gt;&lt;/a&gt;   was a big theme there.  Since then, I &lt;a title="http://vladimirvivien.com/blogs/ot/2008/02/creating-simple-builder-with-groovys.html" href="http://vladimirvivien.com/blogs/ot/2008/02/creating-simple-builder-with-groovys.html" id="cb5:"&gt;blogged about using Groovy's built-in Meta Object Protocol&lt;/a&gt; (MOP) mechanism to create a simple XML builder.  Then I got curious about other builders such as Swing and SwingX.  Talking to &lt;a title="http://www.jameswilliams.be/blog/entry/index" href="http://www.jameswilliams.be/blog/entry/index" id="eyxm"&gt;James Williams&lt;/a&gt; (SwingXBuilder creator), I found out that Groovy's &lt;a href="http://groovy.codehaus.org/FactoryBuilderSupport" id="cwno" title="Groovy's FactoryBuilderSupport"&gt;&lt;b&gt;FactoryBuilderSupport&lt;/b&gt;&lt;/a&gt;  interface is designed specifically to allow developers create builder-style DSL.  While the FactoryBuilderSupport provides a rich interface to create your own DSL, examples are hard to come by.  Thankfully, James had just created another builder called &lt;a title="http://www.jameswilliams.be/blog/entry/60" href="http://www.jameswilliams.be/blog/entry/60" id="us3b"&gt;Java3DBuilder&lt;/a&gt; &lt;a href="http://www.jameswilliams.be/blog/entry/60" id="phc_" title="Java3DBuilder"&gt;&lt;/a&gt; which uses the FactoryBuilder interface and a good starting point.  This shows a small example on using the FactoryBuilderSupport.&lt;br&gt; &lt;br&gt; The &lt;b&gt;FactoryBuilderSupport&lt;/b&gt; along with Groovy's &lt;b&gt;Factory&lt;/b&gt; interface offer a structured approach to constructing internal DSL's.  Unlike tapping directly into MOP to manage your DSL nodes, the factory approach requires you to explicitly register by name each node with the FactoryBuilder.  The Factory interface exposes &lt;b&gt;event callbacks&lt;/b&gt; to intercept different phases of node traversal by the FactoryBuilder which lets manage state and behavior of your DSL. Here is how &lt;b&gt;Groovy's website&lt;/b&gt; describes the Factory interface and its methods:&lt;br&gt; &lt;div id="wczc" style="padding: 1em 0pt; text-align: left;"&gt;   &lt;img src="http://docs.google.com/File?id=df3qdpw5_74f6n7mghn" style="width: 723px; height: 241px;"&gt;&lt;br&gt;   &lt;br&gt;&lt;b&gt;A quick note about newInstanceMethod()&lt;/b&gt; - when the factory builder creates a new instance of your node, it will pass in these params: an instance of the factory builder, the name of the node being processed, an argument value (if used as the form &lt;b&gt;node(arg)&lt;/b&gt; ), and optionally a &lt;b&gt;map&lt;/b&gt; if the node is used as &lt;b&gt;node(key:value...)&lt;/b&gt;.&lt;br&gt;   &lt;br&gt;&lt;font size="4"&gt;&lt;b&gt;Saying Hello, the DSL Way&lt;/b&gt;&lt;/font&gt;&lt;br&gt;So, using the information above (and some some sleuthing on my part), I was able to figure out how to use the FactoryBuilderSupport class to build a simple DSL to display a greeting message.  So, the first thing is to specify how the language will look and feel.  Since we are using the builder pattern, our DSL will have the familiar construct we have seen in other builders:&lt;br&gt;&lt;br&gt;&lt;span style="font-family: Courier New;"&gt;builder.&lt;b&gt;using&lt;/b&gt;(a given language) {&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;&lt;span style="font-family: Courier New;"&gt;    &lt;b&gt;greet&lt;/b&gt;(person1)&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;&lt;span style="font-family: Courier New;"&gt;    &lt;b&gt;greet&lt;/b&gt;(person2)&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;&lt;span style="font-family: Courier New;"&gt;    &lt;b&gt;greet&lt;/b&gt;(person4)&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;&lt;span style="font-family: Courier New;"&gt;...&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;&lt;span style="font-family: Courier New;"&gt;    &lt;b&gt;greet&lt;/b&gt;(personN)&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;&lt;span style="font-family: Courier New;"&gt;}&lt;/span&gt;&lt;br&gt;&lt;br&gt;A call to &lt;b&gt;builder.build()&lt;/b&gt; will print out the greeting in the proper language.&lt;br&gt;&lt;font size="4"&gt;&lt;br&gt;&lt;b&gt;The Code&lt;/b&gt;&lt;/font&gt;&lt;br&gt;First, let us look at the backing structure that will support our DSL.  It consists of a &lt;b&gt;Person&lt;/b&gt; object and &lt;b&gt;GroupGreeter &lt;/b&gt;class.  The latter actually stores the persons we want to greet and apply the logic to build the greeting string.&lt;br&gt;&lt;br&gt;&lt;div id="qqk_" style="padding: 1em 0pt; text-align: left;"&gt;&lt;img style="width: 698px; height: 636px;" src="http://docs.google.com/File?id=df3qdpw5_75f5h46pdn"&gt;&lt;/div&gt;The greetings can be in several languages including English, French, German, Spanish, Italian, and Portuguese.  The greetings map (line 9)stores the greeting text as well as the conjunction to use when we are greeting more than one person.&lt;br&gt;&lt;br&gt;Disclaimer: I am not a language geek.  This translation is straight from &lt;a title="http://www.google.com/language_tools" href="http://www.google.com/language_tools" id="fpal"&gt;Google Language Tools&lt;/a&gt; .  So, I am not responsible for greetings that are colloquially incorrect or used in the wrong context!&lt;br&gt;&lt;font size="4"&gt;&lt;br&gt;&lt;b&gt;On to the Builder&lt;/b&gt;&lt;/font&gt;&lt;br&gt;The next code snippet shows the &lt;b&gt;FactoryBuilderSupport&lt;/b&gt; and the factories that it manages.  Each node in your DSL is implemented by a factory instance.  In our example, the nodes are are &lt;b&gt;using&lt;/b&gt; and &lt;b&gt;greet&lt;/b&gt;.  Node using is registered with &lt;b&gt;GroupGreetingNode&lt;/b&gt; and greet is registered with class GreetingNode. &lt;br&gt;&lt;br&gt;&lt;img style="width: 851px; height: 690px;" src="http://docs.google.com/File?id=df3qdpw5_76hcgg2nch"&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;GroupGreetingNode&lt;/b&gt; represents the parent node.  It sets up a &lt;b&gt;GroupGreeter&lt;/b&gt; object (see previous section) with the language passed in as its argument and returns the newly created GroupGreeter object.  The &lt;b&gt;GreetingNode&lt;/b&gt; is a child node of the &lt;b&gt;GroupGreetingNode&lt;/b&gt;.  When the "greet" node is encountered, the builder calls newInstance() on GreetingNode and a new instance of the Person object with the name as an argument and returns the newly created person back to the builder.  The builder will eventually call setParent() on the GreetingNode.  At that point, the person object that was created in is added to the parentNode (which is an instance of GroupGreeter). That's it!&lt;br&gt;&lt;br&gt;&lt;font size="4"&gt;&lt;b&gt;Running the Code&lt;/b&gt;&lt;/font&gt;&lt;br&gt;The following shows two usage of the Greeting DSL&lt;br&gt;&lt;div id="eqf7" style="padding: 1em 0pt; text-align: left;"&gt;&lt;img style="width: 444px; height: 219px;" src="http://docs.google.com/File?id=df3qdpw5_77d4hq3zjw"&gt;&lt;/div&gt;The code above produces &lt;br&gt;&lt;br&gt;&lt;div&gt;&lt;table id="vh2t" bgcolor="#cccccc" border="0" cellpadding="3" cellspacing="0" width="100%"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td width="100%"&gt;&lt;span style="font-family: Courier New;"&gt;&lt;b&gt;Hallo, Jon, David und Ella&lt;/b&gt;&lt;/span&gt;&lt;br style="font-family: Courier New; font-weight: bold;"&gt;&lt;span style="font-family: Courier New;"&gt;&lt;b&gt; Salut Mireille&lt;/b&gt;&lt;/span&gt;&lt;br&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;font size="4"&gt;&lt;br&gt;&lt;b&gt;Observations&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;ul&gt;&lt;li&gt; The semantic for your DSL requires an appropriately fitting backing API and data structure&lt;/li&gt;&lt;li&gt;Model your backing data structure close to your DSL.  It makes implementation of the builder simpler.&lt;/li&gt;&lt;li&gt;If you can't change the backing API, try model your DSL syntax and semantic close to your API.&lt;br&gt;&lt;/li&gt;&lt;li&gt;FactoryBuilderSupport and Factory simply facilitates the traversal of the DSL nodes.  They should not be used to implement the backing data structure.&lt;/li&gt;&lt;li&gt;How you process the nodes is subjective and depends on how your backing data model is structured.&lt;/li&gt;&lt;li&gt;Process data at the intended node level.  So, a child node should process all of its data not pass it to the parent.&lt;/li&gt;&lt;/ul&gt; &lt;br&gt;&lt;font size="4"&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;/font&gt;&lt;br&gt;There's no doubt that Groovy makes developing DSL easy.  As we have seen the combination of the &lt;b&gt;FactoryBuilderSupport&lt;/b&gt; class and the &lt;b&gt;Factory&lt;/b&gt; interface provides a structured approach to creating DSL that conforms to the builder pattern.  In this write up I demonstrated how to create a simple DSL to print out greeting on the screen.  The same techniques used here are used to create more complex DSL such as &lt;b&gt;Java3DBuilder&lt;/b&gt;.&lt;br&gt;&lt;br&gt;References&lt;br&gt;0. Download Groovy source code - &lt;a title="http://vladimirvivien.com.s3.amazonaws.com/GreetingBuilderDemo.groovy" href="http://vladimirvivien.com.s3.amazonaws.com/GreetingBuilderDemo.groovy" id="a515"&gt;http://vladimirvivien.com.s3.amazonaws.com/GreetingBuilderDemo.groovy&lt;/a&gt; &lt;br&gt;1.  Dynamic Groovy - &lt;a href="http://groovy.codehaus.org/Dynamic+Groovy" id="ji:w" title="http://groovy.codehaus.org/Dynamic+Groovy"&gt;http://groovy.codehaus.org/Dynamic+Groovy&lt;/a&gt;&lt;br&gt;2. Groovy FactoryBuilderSupport - &lt;a title="http://groovy.codehaus.org/FactoryBuilderSupport" href="http://groovy.codehaus.org/FactoryBuilderSupport" id="copu"&gt;http://groovy.codehaus.org/FactoryBuilderSupport&lt;/a&gt; &lt;br&gt;3. Jame William's Java3DBuilder - &lt;a title="http://www.jameswilliams.be/blog/entry/60" href="http://www.jameswilliams.be/blog/entry/60" id="tw4x"&gt;http://www.jameswilliams.be/blog/entry/60&lt;/a&gt; &lt;br&gt;&lt;br&gt;Hope you enjoyed it!&lt;br&gt;&lt;/div&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-5142844489258748659?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/5142844489258748659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/5142844489258748659'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/03/using-groovys-factorybuildersupport-to.html' title='Using Groovy&apos;s FactoryBuilderSupport to Build Internal DSL'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-6819538851770102281</id><published>2008-02-25T18:16:00.001-05:00</published><updated>2008-02-26T07:00:58.439-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Groov'/><category scheme='http://www.blogger.com/atom/ns#' term='Dyanic Languages'/><category scheme='http://www.blogger.com/atom/ns#' term='Grails'/><title type='text'>Creating a Simple Builder with Groovy's methodMissing()</title><content type='html'>&lt;font size="5"&gt;&lt;b&gt;Creating a Simple Builder with Groovy's methodMissing()&lt;/b&gt;&lt;/font&gt;&lt;br&gt; &lt;br&gt; One of the main theme here at Groovy/Grails Experience is Meta Programming: the ability to use Groovy to dynamically modify the behavior of the language at runtime.  During one of Graeme Rocher's session, he did a live demo on how to build a simple Xml builder and Vankat Subramaniam demo'ed the creation of a simple DSL using Groovy. These sessions showed the simplicity and power of Meta programming in Groovy.  So, rather than go on and praise the merits of Groovy and make this an all fluff write up (and get crap for it from my buddy &lt;a href="http://www.jameswilliams.be/" id="qd8f" title="James Williams"&gt;James Williams&lt;/a&gt; ), I will show a concrete example below.&lt;br&gt; &lt;br&gt; &lt;font size="4"&gt;&lt;b&gt;A Simple Xml Builder in Groovy&lt;/b&gt;&lt;/font&gt;&lt;br&gt; This simple xml builder is able to handle most xml tag constructs including:&lt;br&gt; &lt;br&gt; &lt;ul&gt;   &lt;li&gt;     &lt;span style="font-family: Courier New;"&gt;&amp;lt;tag/&amp;gt;  &lt;/span&gt;   &lt;/li&gt;   &lt;li&gt;     &lt;span style="font-family: Courier New;"&gt;&amp;lt;tag atrrib="val"/&amp;gt;  &lt;/span&gt;   &lt;/li&gt;   &lt;li&gt;     &lt;span style="font-family: Courier New;"&gt;&amp;lt;tag&amp;gt;String content&amp;lt;/tag&amp;gt;&lt;/span&gt;   &lt;/li&gt;   &lt;li&gt;     &lt;span style="font-family: Courier New;"&gt;&amp;lt;tag attrib="val"&amp;gt;content&amp;lt;/tag&amp;gt;&lt;/span&gt;   &lt;/li&gt;   &lt;li&gt;     &lt;span style="font-family: Courier New;"&gt;&amp;lt;tag attrib="val"&amp;gt;&amp;lt;tag&amp;gt;... tag[n] ...&amp;lt;/tag&amp;gt;&amp;lt;/tag&amp;gt;&lt;br&gt;     &lt;br&gt;     &lt;/span&gt;   &lt;/li&gt; &lt;/ul&gt; Sorry, there is &lt;b&gt;no namespace support&lt;/b&gt; of the form &amp;lt;namespace:tag/&amp;gt;&lt;br&gt; &lt;br&gt; So, here is a sample usage of the SimpleXmlBuilder class to build XML nodes:&lt;br&gt; &lt;br&gt; &lt;div id="u.ih" style="padding: 1em 0pt; text-align: left;"&gt;   &lt;img src="http://docs.google.com/File?id=df3qdpw5_55gb848gds" style="width: 644px; height: 200px;"&gt; &lt;/div&gt; The code snippet above will generate this HTML code:&lt;br&gt; &lt;br&gt; &lt;div&gt;   &lt;table id="l549" bgcolor="#666666" border="0" cellpadding="1" cellspacing="0" width="100%"&gt;     &lt;tbody&gt;     &lt;tr&gt;       &lt;td width="100%"&gt;         &lt;font style="font-family: Courier New;" color="#000000" size="2"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;&lt;b&gt;&amp;lt;html xmlns="htt://namespace" &amp;gt;&amp;lt;header&amp;gt;&amp;lt;title&amp;gt;Hello&amp;lt;/title&amp;gt;&amp;lt;/header&amp;gt;&amp;lt;body&amp;gt;&amp;lt;p&amp;gt;Hello World Sample&amp;lt;/p&amp;gt;&amp;lt;span id="greet" style="font-family:sans-serif" &amp;gt;Hello World!!&amp;lt;/span&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;       &lt;/td&gt;     &lt;/tr&gt;     &lt;/tbody&gt;   &lt;/table&gt; &lt;/div&gt; &lt;br&gt; &lt;br&gt; &lt;font size="4"&gt;&lt;b&gt;The Code&lt;/b&gt;&lt;/font&gt;&lt;br&gt; Disclaimer: this was put together in less an hour while sitting in a session at the &lt;a href="http://groovygrails.com/gg/2gexperience" id="hw2z" title="G2 Experience"&gt;G2 Experience&lt;/a&gt;.  I am sure it can be done in a more elegant way.  The code simply evaluates each of the syntatic possiblities (discussed above) and take appropritae action.  So, with that out of the way, here is the code for simple xml builder:&lt;br&gt; &lt;br&gt; &lt;div id="rhlw" style="padding: 1em 0pt; text-align: left;"&gt;   &lt;img src="http://docs.google.com/File?id=df3qdpw5_56hjp3v8gq" style="width: 580px; height: 944px;"&gt; &lt;/div&gt; Click to &lt;a title="Download source code" href="http://vmatters.googlepages.com/SimpleBuilderDemo.groovy" id="lj56"&gt;&lt;b&gt;download the Groovy source code&lt;/b&gt;&lt;/a&gt;.&lt;br&gt;&lt;br&gt; &lt;font size="4"&gt;&lt;b&gt;MOP - methodMissing()&lt;/b&gt;&lt;/font&gt;&lt;br&gt; If you are new to Groovy then you may not understand what's going on.  &lt;b&gt;Groovy's meta object protocol (MOP)&lt;/b&gt; lets developers &lt;b&gt;expand the syntactical constraints of the core language at runtime&lt;/b&gt;.  This capability makes Groovy the perfect platform to &lt;b&gt;create Domain Specific Language (DSL)&lt;/b&gt; where you develop small language with a concise syntax to address a given domain (software dev, business, etc).  The &lt;b&gt;methodMissing() &lt;/b&gt;method is one of the hooks exposed by Groovy's MOP mechanism that &lt;b&gt;intercepts all calls to undefined methods&lt;/b&gt; on a given object.  By overriding methodMissing(), &lt;b&gt;you can implement behaviors of methods that are not statically defined on the class&lt;/b&gt;. &lt;br&gt; &lt;br&gt; When Groovy's MOP intercepts an method call,  it invokes &lt;b&gt;methodMissing(String methodName, args) &lt;/b&gt;with two parameters: the &lt;b&gt;name of the missing method&lt;/b&gt; that was invoked and an &lt;b&gt;array representing the method's parameters&lt;/b&gt;.  So, for instance, when Groovy intercepts  &lt;b&gt;xml.title("Hello")&lt;/b&gt;, the first parameter of methodMissing() has a value of &lt;b&gt;"title"&lt;/b&gt; and &lt;b&gt;args.length = 1&lt;/b&gt; where &lt;b&gt;arg[0]&lt;/b&gt; = &lt;b&gt;"Hello"&lt;/b&gt;. &lt;br&gt; &lt;br&gt; When the syntax is as follows, &lt;b&gt;xml.header {...}&lt;/b&gt;, methodMissing's method name has a value of &lt;b&gt;"header"&lt;/b&gt;.  Here, however, &lt;b&gt;args[0] is a closure&lt;/b&gt;.  A &lt;a href="http://en.wikipedia.org/wiki/Closure_%28computer_science%29" id="z1p6" title="Closure on Wikipedia"&gt;closure is an executable&lt;/a&gt; (callable) code block that can be treated as a variable.  As such, we must tell Groovy that we want to execute that code block.  However, before we blindly call the closure, we &lt;b&gt;reassign the closure's target&lt;/b&gt; to be the &lt;b&gt;SimpleXmlBuilder&lt;/b&gt; class (&lt;b&gt;args[0].delegate = this&lt;/b&gt; line 11 and 49).  Therefore, the next method dispatch request on the closure will be handled by the SimpleXmlBuilder.&lt;br&gt; &lt;br&gt; Finally, when the syntax of our builder takes the form of &lt;b&gt;xml.html(xmlns:"http;//somenamespace"){ ... }&lt;/b&gt;, Groovy's MOP invokes methodMissing where the method name is &lt;b&gt;"html"&lt;/b&gt; as expected.  In this case, however, &lt;b&gt;argument array has two memebers&lt;/b&gt;: the &lt;b&gt;first one is a map&lt;/b&gt; and the &lt;b&gt;second member&lt;/b&gt; is &lt;b&gt;another closure&lt;/b&gt;.  Knowing this, we can handle tags with both attributes and function as a container tag as shown above (starting with line 37).&lt;br&gt; &lt;br&gt; &lt;font size="4"&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;/font&gt;&lt;br&gt; &lt;br&gt; This sample code above demonstrates how Groovy's MOP mechanism can let developers change and extend the language's syntactical behavior to build functional DSL that fit specific needs.  Here, in about 30 lines of code, we created a simple XML builder which is able to output well-formed xml document.  This is a simple example and shows just a small glimpse of the capabilities of Groovy's meta programming.  I hope this inspires you to continue to explore Groovy and come up with your own use for MOP.&lt;br&gt; &lt;br&gt; &lt;font size="4"&gt;&lt;b&gt;References&lt;/b&gt;&lt;/font&gt;&lt;br&gt; 0. Download Groovy source file - &lt;a href="http://vmatters.googlepages.com/SimpleBuilderDemo.groovy" id="b0mn" title="Download Groovy source code"&gt;http://vmatters.googlepages.com/SimpleBuilderDemo.groovy&lt;/a&gt;&lt;br&gt; 1. Dynamic Groovy - &lt;a href="http://groovy.codehaus.org/Dynamic+Groovy" id="ji:w" title="http://groovy.codehaus.org/Dynamic+Groovy"&gt;http://groovy.codehaus.org/Dynamic+Groovy&lt;/a&gt;&lt;br&gt; 2. Using methodMissing and propertyMissing - &lt;a href="http://groovy.codehaus.org/Using+methodMissing+and+propertyMissing" id="rfd3" title="http://groovy.codehaus.org/Using+methodMissing+and+propertyMissing"&gt;http://groovy.codehaus.org/Using+methodMissing+and+propertyMissing&lt;/a&gt;&lt;br&gt; 3. Meta Programming with Groovy Part 1 - &lt;a href="http://groovy.dzone.com/articles/metaprogramming-groovy-i" id="rhmc" title="http://groovy.dzone.com/articles/metaprogramming-groovy-i"&gt;http://groovy.dzone.com/articles/metaprogramming-groovy-i&lt;/a&gt;&lt;br&gt; 4. Meta Programming with Groovy Part 2 - &lt;a href="http://groovy.dzone.com/articles/metaprogramming-groovy-ii-expa" id="i484" title="http://groovy.dzone.com/articles/metaprogramming-groovy-ii-expa"&gt;http://groovy.dzone.com/articles/metaprogramming-groovy-ii-expa&lt;/a&gt;&lt;br&gt; 5. Google Doc version of this write up - &lt;a id="publishedDocumentUrl" class="tabcontent" target="_blank" href="Doc?id=df3qdpw5_53chtkh89r"&gt;http://docs.google.com/Doc?id=df3qdpw5_53chtkh89r&lt;/a&gt;&lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-6819538851770102281?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/6819538851770102281'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/6819538851770102281'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/02/creating-simple-builder-with-groovys.html' title='Creating a Simple Builder with Groovy&apos;s methodMissing()'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-8711577303503848547</id><published>2008-02-05T11:12:00.000-05:00</published><updated>2008-02-07T07:42:37.767-05:00</updated><title type='text'>Integrating Groovy Classes in Spring</title><content type='html'>            &lt;font size="5"&gt;&lt;b&gt; Spring Meets Groovy!&lt;/b&gt;&lt;/font&gt;&lt;br&gt; &lt;br&gt;[&lt;b&gt;View in Google Doc: &lt;/b&gt;&lt;a title="Google Doc Version" class="tabcontent" href="Doc?id=df3qdpw5_51fqxz7cft" id="publishedDocumentUrl" target="_blank"&gt;&lt;/a&gt;&lt;a title="http://docs.google.com/Doc?id=df3qdpw5_51fqxz7cft" target="_blank" href="Doc?id=df3qdpw5_51fqxz7cft" id="rjjm"&gt;http://docs.google.com/Doc?id=df3qdpw5_51fqxz7cft&lt;/a&gt; ]&lt;br&gt;&lt;br&gt; &lt;b&gt;If you don't use Spring or care to know about it, then this write up is not for you&lt;/b&gt;.  I will look at how your Java-based Spring component can made Groovier!!  Again, as a pre-requisite, you must already be using Spring (2.0 or better) and have a working knowledge of Groovy.&lt;br&gt; &lt;br&gt; &lt;font size="4"&gt;&lt;b&gt;Why Groovy and Spring?&lt;/b&gt;&lt;/font&gt;&lt;br&gt; After more than ten years of Java, we can all agree that one language does not fit all.  We (collective Java community) have been banging square pegs into round holes (with patterns, anti-patterns, best practices, frameworks as lubricant).  With the advent of dynamic languages such Groovy and Ruby in the enterprise, we are realizing that it is time to start building &lt;b&gt;polyglot&lt;/b&gt; systems.  Poly-who, you ask??  A system that is made up of one or more languages.  Each language addresses a specific domain (i.e. structural, configuration, business, ui, etc) so that your pegs fit where they should.  We are already do this today when we write our &lt;b&gt;views in JSP's&lt;/b&gt;, &lt;b&gt;controllers in Java&lt;/b&gt;, retrieve &lt;b&gt;data using SQL&lt;/b&gt;, and &lt;b&gt;configure &lt;/b&gt;our apps using &lt;b&gt;XML&lt;/b&gt;.&lt;br&gt; &lt;br&gt;&lt;font size="3"&gt;&lt;b&gt; Groovy in Spring Example&lt;/b&gt;&lt;/font&gt;&lt;br&gt; Wiring Groovy beans in Spring is easy and require little deviation from what you already know.  You can create your beans following these steps&lt;br&gt; &lt;br&gt; &lt;font size="3"&gt;&lt;b&gt;1. Create a Java Interface&lt;/b&gt;&lt;/font&gt;&lt;br&gt; Currently, Groovy beans in Spring must implement an Java-defined interface so that Spring can get type information about your Groovy beans.  So, let's create a &lt;b&gt;Payment interface&lt;/b&gt;:&lt;br&gt; &lt;br&gt; &lt;div&gt;   &lt;table id="dbna" bgcolor="#cccccc" border="0" cellpadding="3" cellspacing="0"&gt;     &lt;tbody&gt;     &lt;tr&gt;       &lt;td width="100%"&gt;         &lt;span style="font-family: Courier New;"&gt;&lt;font size="2"&gt;package demo.vladimirvivien;&lt;br&gt;         &lt;br&gt;         import java.util.HashMap;&lt;br&gt;         &lt;br&gt;         public &lt;b&gt;interface Payment&lt;/b&gt; {&lt;br&gt;             void &lt;b&gt;pay&lt;/b&gt;(&lt;b&gt;HashMap&lt;/b&gt; info);&lt;br&gt;         }&lt;/font&gt;&lt;br&gt;         &lt;/span&gt;&lt;br&gt;       &lt;/td&gt;     &lt;/tr&gt;     &lt;/tbody&gt;   &lt;/table&gt; &lt;/div&gt; &lt;br&gt; &lt;br&gt; &lt;font size="3"&gt;&lt;b&gt;2. Implement in Groovy&lt;/b&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;br&gt; &lt;/font&gt;Create a Groovy class that implements the interface.  Place your Groovy file somewhere on the classpath.  In this example, the file is placed in groovy/CreditCardPayment.groovy.  Your Groovy class has access to any classes on the classpath as well, so you can reference other Java classes or other Groovy classes.  The class has two properties (&lt;b&gt;mechantId &lt;/b&gt;and &lt;b&gt;serviceUrl&lt;/b&gt;) which can be injected at runtime by Spring (see below).&lt;br&gt; &lt;br&gt; &lt;div&gt;   &lt;table id="yp5q" bgcolor="#cccccc" border="1" bordercolor="#000000" cellpadding="3" cellspacing="0"&gt;     &lt;tbody&gt;     &lt;tr&gt;       &lt;td width="100%"&gt;         &lt;font size="2"&gt;&lt;span style="font-family: Courier New;"&gt;import demo.vladimirvivien.Payment&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;import java.lang.Util.*&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;import org.apache.commons.logging.Log;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;import org.apache.commons.logging.LogFactory;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;br style="font-family: Courier New;"&gt;         &lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;class &lt;/span&gt;&lt;span style="font-family: Courier New;"&gt;&lt;b&gt;CreditCardPayment implements Payment &lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: Courier New;"&gt;{&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;    static Log log = LogFactory.getLog(Payment.class)&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;             &lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;    String merchantId;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;    String serviceUrl;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;             &lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;    void pay(HashMap info) {&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;        log.info("Processing Payment...")&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;                 &lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;        println "---------------------------"&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;        println "Merchant ID:t${merchantId}"&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;        println "Service URL:t${serviceUrl}"&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;        println "Payer:nt${info.PAYER_NAME}nt${info.PAYER_ADDR}ntCard:${info.PAYER_CCNUM} Exp:${info.PAYER_CCEXP}"&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;                 &lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;        // process payment here&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;    }&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;}&lt;/span&gt;&lt;/font&gt;&lt;br&gt;       &lt;/td&gt;     &lt;/tr&gt;     &lt;/tbody&gt;   &lt;/table&gt; &lt;/div&gt; &lt;br&gt;  &lt;div&gt; &lt;/div&gt; &lt;br&gt; &lt;font size="3"&gt;&lt;b&gt;3. Wire in Spring&lt;/b&gt;&lt;/font&gt;&lt;br&gt; The first thing to notice is the XML schema declaration.  It makes reference to the XML lang namespace and the lang XSD.  This allows you to use the specially provided &lt;b&gt;&amp;lt;lang:groovy/&amp;gt;&lt;/b&gt; tag.  The tag lets you wire in Groovy beans and inject property values into them.  Here, we are injecting mechantId and serviceURL with values just as we do regular Java POJO's.&lt;br&gt; &lt;br&gt; &lt;div&gt;   &lt;table id="k8n6" bgcolor="#cccccc" border="1" bordercolor="#000000" cellpadding="3" cellspacing="0"&gt;     &lt;tbody&gt;     &lt;tr&gt;       &lt;td width="100%"&gt;         &lt;span style="font-family: Courier New;"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: Courier New;"&gt;&lt;b&gt;beans &lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: Courier New;"&gt;xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;       &lt;b&gt;xmlns:lang="http://www.springframework.org/schema/lang&lt;/b&gt;"&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;       xsi:schemaLocation="&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;&lt;b&gt;http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd&lt;/b&gt;"&amp;gt;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;br style="font-family: Courier New;"&gt;             &lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;    &amp;lt;&lt;b&gt;lang:groovy&lt;/b&gt; id="&lt;b&gt;payManager&lt;/b&gt;" script-source="classpath:&lt;b&gt;groovy/CreditCardPayment.groovy&lt;/b&gt;"&amp;gt;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;        &amp;lt;lang:&lt;b&gt;property&lt;/b&gt; name="merchantId" value="ID343432-4434-34" /&amp;gt;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;        &amp;lt;lang:&lt;b&gt;property &lt;/b&gt;name="serviceUrl" value="http://paymentservice/processor.do" /&amp;gt;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;    &amp;lt;/&lt;b&gt;lang:groovy&lt;/b&gt;&amp;gt;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;&amp;lt;/&lt;b&gt;beans&lt;/b&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;       &lt;/td&gt;     &lt;/tr&gt;     &lt;/tbody&gt;   &lt;/table&gt; &lt;/div&gt; &lt;br&gt; &lt;font size="4"&gt;&lt;b&gt;Run the Example&lt;/b&gt;&lt;/font&gt;&lt;br&gt; Here, we have a Java class that runs the example.  However, you can imagine this setup working in other context such as a web application, a standalone process, or any other context where Spring can live.  Note in the code that once the Groovy bean is retrieved from the Spring context, it is used as a regular Java class.&lt;br&gt; &lt;div&gt;   &lt;table id="h4pm" bgcolor="#cccccc" border="1" bordercolor="#000000" cellpadding="3" cellspacing="0"&gt;     &lt;tbody&gt;     &lt;tr&gt;       &lt;td width="100%"&gt;         &lt;span style="font-family: Courier New;"&gt;package demo.vladimirvivien;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;import java.util.HashMap;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;import org.springframework.context.ApplicationContext;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;import org.springframework.context.support.ClassPathXmlApplicationContext;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;public &lt;b&gt;class Main&lt;/b&gt; {&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;    public &lt;b&gt;static void main(String[] args&lt;/b&gt;) {&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;        &lt;b&gt;ApplicationContext &lt;/b&gt;ctx = new &lt;b&gt;ClassPathXmlApplicationContext&lt;/b&gt;("&lt;b&gt;META-INF/spring-context.xml&lt;/b&gt;");&lt;br&gt;         &lt;br&gt;                 // pull an instance of the Groovy Payment bean&lt;br style="font-family: Courier New;"&gt;         &lt;/span&gt;&lt;span style="font-family: Courier New;"&gt;        Payment payment = (Payment) ctx.getBean("payManager");&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;        HashMap&amp;lt;String,String&amp;gt; info = new HashMap&amp;lt;String,String&amp;gt;();&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;        info.put("PAYER_NAME", "John Foo");&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;        info.put("PAYER_ADDR", "12345 Main Street, USA");&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;        info.put("PAYER_CCNUM", "1234564343343");&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;        info.put("PAYER_CCEXP", "0910");&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;       &lt;br&gt;                 // call the implemented mehod pay()&lt;br style="font-family: Courier New;"&gt;         &lt;/span&gt;&lt;span style="font-family: Courier New;"&gt;        &lt;b&gt;payment.pay(info);&lt;/b&gt;&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;    }&lt;/span&gt;&lt;br style="font-family: Courier New;"&gt;         &lt;span style="font-family: Courier New;"&gt;}&lt;/span&gt;&lt;br&gt;         &lt;br&gt;       &lt;/td&gt;     &lt;/tr&gt;     &lt;/tbody&gt;   &lt;/table&gt; &lt;/div&gt; &lt;br&gt; You should see the followings on the screen:&lt;br&gt; &lt;div&gt;   &lt;table id="a0ya" border="1" bordercolor="#000000" cellpadding="3" cellspacing="0"&gt;     &lt;tbody&gt;     &lt;tr&gt;       &lt;td width="100%"&gt;         &lt;div id="r7ho" style="padding: 1em 0pt; text-align: left;"&gt;           &lt;img src="http://docs.google.com/File?id=df3qdpw5_52dmfxz4hf" style="width: 357px; height: 112px;"&gt;         &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;     &lt;/tbody&gt;   &lt;/table&gt; &lt;/div&gt; &lt;br&gt; &lt;br&gt; &lt;font size="4"&gt;&lt;b&gt;So What?&lt;/b&gt;&lt;/font&gt; &lt;br&gt; You may be saying "Why should I care? I can do the same thing in Java!"  You would be correct.  This is not meant to supplant Java but rather complement it.  Integrating a dynamic language such as Groovy into your enterprise development gives you a new level of flexibility and configurability that was not there before (or at least requires additional steps to work smoothly).  You can use this approach in several scenarios&lt;br&gt; - &lt;b&gt;Configuration:&lt;/b&gt; Use Groovy beans to capture configuration rules for your system or for your business logic including page flow, process flow, etc.&lt;br&gt; - &lt;b&gt;Business Rules:&lt;/b&gt; some business logic tend to change.  You can use Groovy to&lt;br&gt; - &lt;b&gt;Handle Event:&lt;/b&gt; Use Groovy to react to system or application events (i.e. if inventory falls below a level, send email.  This works well in conjunction with JMX)&lt;br&gt; - &lt;b&gt;Validation:&lt;/b&gt; validation rules is another context susceptible to changes.  Capturing your validation in Groovy lets you adjust to your business needs.&lt;br&gt; - &lt;b&gt;Expose Edge Services&lt;/b&gt;: these are the services that expose functionalities at the boundaries of your system (i.e. MVC controllers, web services, REST services, etc).  See project &lt;a href="http://grails.codehaus.org/" id="n9a1" target="_blank" title="Go to Grails Site"&gt;&lt;b&gt;Grails&lt;/b&gt;&lt;/a&gt; .&lt;br&gt; &lt;br&gt;&lt;font size="4"&gt;&lt;b&gt; Conclusion&lt;/b&gt;&lt;/font&gt;&lt;br&gt; We looked at how Groovy can be integrated in your application using Spring.  Groovy is a natural choice for Polyglot programming on the Java VM given its flexibility and growing popularity.  This write up shows a small instance how Groovy can be integrated into your system using the Spring Framework.  Groovy can be injected in your enterprise stack to handle the more fluid context where logic tends to be updated to keep up with business requirements.&lt;br&gt; &lt;br&gt; &lt;font size="4"&gt;&lt;b&gt;References&lt;/b&gt;&lt;/font&gt;&lt;br&gt; 0. Google Doc for write up - &lt;a title="http://docs.google.com/Doc?id=df3qdpw5_51fqxz7cft" class="tabcontent" href="Doc?id=df3qdpw5_51fqxz7cft" id="publishedDocumentUrl" target="_blank"&gt;http://docs.google.com/Doc?id=df3qdpw5_51fqxz7cft&lt;/a&gt;&lt;br&gt; 1. Spring Dynamic Language Support - &lt;a href="http://static.springframework.org/spring/docs/2.5.x/reference/dynamic-language.html" id="jgy2" target="_blank" title="http://static.springframework.org/spring/docs/2.5.x/reference/dynamic-language.html"&gt;http://static.springframework.org/spring/docs/2.5.x/reference/dynamic-language.html&lt;/a&gt;&lt;br&gt; 2. Ola Bimi - Language Exploration (blog) - &lt;a href="http://ola-bini.blogspot.com/2008/01/language-explorations.html" id="y8ij" target="_blank" title="http://ola-bini.blogspot.com/2008/01/language-explorations.html"&gt;http://ola-bini.blogspot.com/2008/01/language-explorations.html&lt;/a&gt;&lt;br&gt; 3. Neal Ford - Polygot Programming (blog) - &lt;a href="http://memeagora.blogspot.com/2008/01/polyglot-programming-parallels-perched.html" id="wl.q" target="_blank" title="http://memeagora.blogspot.com/2008/01/polyglot-programming-parallels-perched.html"&gt;http://memeagora.blogspot.com/2008/01/polyglot-programming-parallels-perched.html&lt;/a&gt;&lt;br&gt; 3. Grok - Polyglot Programming (blog) - &lt;a href="http://www.grok-programming.com/2007/11/25/polyglot-programming-is-it-just-too-much-to-ask/" id="l77n" target="_blank" title="http://www.grok-programming.com/2007/11/25/polyglot-programming-is-it-just-too-much-to-ask/"&gt;http://www.grok-programming.com/2007/11/25/polyglot-programming-is-it-just-too-much-to-ask/&lt;/a&gt;&lt;br&gt; &lt;br&gt; &lt;br&gt;  &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-8711577303503848547?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/8711577303503848547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/8711577303503848547'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/02/spring-is-groovy-if-you-dont-use-spring.html' title='Integrating Groovy Classes in Spring'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-8426882999182036190</id><published>2008-01-20T09:36:00.000-05:00</published><updated>2008-01-20T10:16:58.322-05:00</updated><title type='text'>Grails Is Changing My Entrepreneurial Ambitions</title><content type='html'>I have been playing with Grails for a couple months now.  It made me realize the power of (G)Rails approach, mainly "... get things done ... " I have used ASP Dot Net, at least 3 Java Web Frameworks, ColdFusion (not to mention Perl), I must say Grails is by far the most enjoyable. &lt;br /&gt;&lt;br /&gt;Why all the buzz about Grails?  Well, after you understand Grails and its paradigm, In about , hmmm, 7 minutes you can have a simple, fully-functional, web application.  Grails' intuitive MVC mechanism and data access objects do most of the tedious, mind-numbing boiler plate infrastructural crap you usually have to do in other Java frameworks.  You concentrate on what you know "... your business logic ..."&lt;br /&gt;&lt;br /&gt;Grails  (&lt;a href="http://grails.codehaus.org/"&gt;http://grails.codehaus.org/&lt;/a&gt;) is based on Groovy, Hibernate, Spring and have a well-defined Plug-In architecture.  Now, you are probably thinking "... I don't want to learn these technologies ...."  The cool thing is, you don't have to!  You never see Spring nor Hibernate (unless you want to) Grails does an excellent job of shielding its users from the low-level infrastructural crap.  O, yeah, hmmm, grails generates a WAR file that you can drop on any web container.  Nothing special is needed!&lt;br /&gt;&lt;br /&gt;So, I say this length intro to Grails to get to this: if you are a consultant, own a small operation, or the guy looking to develop the next social site, Grails maybe for you.  As a startup, you know the name of the game is to get things done... Well, Grails lets you get things done... and you can actually get things done fast and the right way (did I mention that you get all the benefits of a full JEE environment without the fuss). &lt;br /&gt;&lt;br /&gt;After a few hours of development, my next project is so far along that it feels unfair... yes... it feels unfair.   It feels as if I should have more code to write... or more design decisions to make,  or more academic bs that I should be concerning myself with (pattern this pattern that)... Instead, I actually have a product, something I can play with, make changes to, and derive motivation from.&lt;br /&gt;&lt;br /&gt;Grails is all about agility... Grails bring dynamics to not only your code, but also the way you develop by giving you the ability to change make changes in mid-development with minimal impact to your level of efforts.  Give it a try!  I have!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-8426882999182036190?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/8426882999182036190'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/8426882999182036190'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/01/grails-is-changing-my-entrepreneurial.html' title='Grails Is Changing My Entrepreneurial Ambitions'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-1407695328792171360</id><published>2008-01-10T22:20:00.000-05:00</published><updated>2008-01-10T22:25:50.069-05:00</updated><title type='text'>Groovy + Spring + Broadway = { -&gt; Resource Monitoring }</title><content type='html'>So, I have been getting some feedbacks regarding Broadway after I first announced it.  So, now it's time to delve into how you can use Groovy, Spring, and Broadway to create monitors.  Using these technologies along with the Broadway API, you can build monitors that evaluate a given expression (default is Groovy) and execute a specified action when that expression returns the desired value (true or false).  In this write up, I will show how to use Groovy, Spring, and Broadway to observe two directories and keep them synchronize.  This is a trivial example, however it shows how Broadway can be integrated with Spring and Groovy to build powerful monitors (see &lt;a href="http://docs.google.com/Doc?id=df3qdpw5_50hs7pn3fv"&gt;Google Doc&lt;/a&gt;).&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;b&gt;Directory Synchronizer [&lt;a href="http://docs.google.com/Doc?id=df3qdpw5_50hs7pn3fv"&gt;Google Doc&lt;/a&gt;]&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;Broadway was designed as component-based API and therefore it plays really well with the Spring component container. As the name implies, we will setup Broadway to monitor two directories (one primary and a secondary). The monitor will keep the secondary directory synchronized with the primary.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;How Does It Work?&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;A &lt;b&gt;monitor component&lt;/b&gt; will &lt;b&gt;observe two directories directory for size differences&lt;/b&gt;. When the sizes of the two directories differ, files from the primary are copied to the secondary automatically. This can be easily accomplished using Broadway and Spring. The only required piece of code is the logic for the Action component.  The action will be executed when the monitor detects the condition (in this case, directory sizes differ). As we will see, &lt;b&gt;the logic for the Action can be captured in Groovy Beans (POGO's)&lt;/b&gt; wired in within Spring.&lt;br /&gt;&lt;br /&gt;NOTE: this is by no mean meant to be a robust directory synchronizer, you are welcome to explore ways to make this more robust (i.e caching, thread safety, two-way synchronization, etc).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;An Observed Resource&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;To make it easier to observe the directories, we will create a &lt;b&gt;component that represents the directory structure being observed&lt;/b&gt;.  This class provides a facade to the a file system and expose specific states to be observed. This sort of domain-specific observed components are not required. However, they can expose richer set of data to be observed by your monitors. NOTE: this observed directory class can be integrated using Groovy as well.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;    // Java code for ObservedDirectory&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;    public class ObservedDirectory {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        private String root;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        public String getRoot() {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                return root;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        public void setDirectoryName(String root) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                this.root = root;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        public String getDirectoryName(){&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                return root;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        public boolean isEmpty(){&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                long size = org.apache.commons.io.FileUtils.sizeOfDirectory(new File(getDirectoryName()));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                return (size &gt; 0) ? false : true;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        public long getDirectorySize(){&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                return FileUtils.sizeOfDirectory(new File(getDirectoryName()));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;Using Spring's Dynamic Language Support&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;b&gt;Spring's Dynamic Language support&lt;/b&gt; feature was introduced in starting with version 2.0. where you can wire a Groovy (JRuby or BeanShell) beans into a Spring context as if they are regular Java POJO's. This implies that you can inject values into your Groovy bean and wire with other beans in Spring context. If you want to learn more about Spring's Dyanamin Language Support, go to &lt;a title="Spring Dyanamic Language Support online documentation" href="http://static.springframework.org/spring/docs/2.0.x/reference/dynamic-language.html" id="rjsd"&gt;Spring Dyanamic Language Support online documentation&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Spring must be configured properly&lt;/b&gt; to use the dynamic language support. You must have the proper &lt;b&gt;XML schema declarations&lt;/b&gt; or your bean will not be mounted properly in the Spring context.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;&amp;lt;beans xmlns="http://www.springframework.org/schema/beans"&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;        xmlns:lang="http://www.springframework.org/schema/lang"&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;        xsi:schemaLocation="&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;        http://www.springframework.org/schema/beans&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;        http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;        http://www.springframework.org/schema/lang&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;        http://www.springframework.org/schema/lang/spring-lang-2.0.xsd"&amp;gt;&lt;/span&gt;  &lt;span style="font-family:Courier New;"&gt;...&lt;/span&gt;  &lt;span style="font-family:Courier New;"&gt;&amp;lt;/beans&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;[See the &lt;a title="full Spring Config File" href="http://code.google.com/p/broadway-monitor/wiki/SpringConfigXml" id="p0-m"&gt;&lt;b&gt;full Spring Config File&lt;/b&gt;&lt;/a&gt; ]&lt;br /&gt;&lt;br /&gt;Now, we are ready to wire the remainder for the Broadway components to create the directory synchronizer.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;Wiring Broadway Components&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;Since Broadway components follow the JavaBean notation, it's easy to wire them together in Spring. To build the directory synchronizer with Broadway, we will wire the Observed Directory component, the Monitor component, and an Action component.&lt;br /&gt;&lt;b&gt;Wire Observed Directory&lt;/b&gt;&lt;br /&gt;In the Spring configuration file, we have two observed directory components wired. The primary directory is ./dir1 and the secondary directory is ./dir2. When the size of observed directory one differ from that observed directory 2, the Action component will execute its script to syncrhonize the two directories.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;        &amp;lt;!-- ====================== Observed Resources ======================= --&amp;gt;&lt;br /&gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;        &amp;lt;bean id="firstDir"&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                class="org.broadway.demo.spring.ObservedDirectory"&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                &amp;lt;property name="directoryName" value="./dir1" /&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;        &amp;lt;/bean&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;        &amp;lt;bean id="secondDir"&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                class="org.broadway.demo.spring.ObservedDirectory"&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                &amp;lt;property name="directoryName" value="./dir2" /&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;        &amp;lt;/bean&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Wiring the Monitor&lt;/b&gt;&lt;br /&gt;The Monitor component observes state changes that is expressed by the "monitorExpression" property below. Here, we can see how we can use Groovy as an expression language to define when to take action based on the observed condition.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;        &amp;lt;!-- ======================= Monitor Setup ========================== --&amp;gt;&lt;br /&gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;        &amp;lt;bean id="monitor" class="org.broadway.monitor.BeanMonitor"&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                &amp;lt;property name="monitorExpression"&amp;gt; &lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                        &amp;lt;value&amp;gt;&amp;lt;![CDATA[context.resources.firstDir.directorySize != context.resources.secondDir.directorySize]]&amp;gt;&amp;lt;/value&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                &amp;lt;/property&amp;gt;&lt;/span&gt;                  &lt;span style="font-family:Courier New;"&gt;                &amp;lt;property name="action" ref="action"/&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                &amp;lt;property name="resourceCollector"&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                        &amp;lt;bean&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                                class="org.broadway.monitor.MappedResourceCollector"&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                                &amp;lt;property name="resources"&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                                        &amp;lt;map&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                                                &amp;lt;entry key="firstDir"  value-ref="firstDir" /&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                                                &amp;lt;entry key="secondDir" value-ref="secondDir" /&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                                        &amp;lt;/map&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                                &amp;lt;/property&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                        &amp;lt;/bean&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                &amp;lt;/property&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;        &amp;lt;/bean&amp;gt;&lt;/span&gt;&lt;br /&gt;The monitor sets up three main properties 1) The monitoring expression using Groovy as an expression language 2)A reference to the action component (see below) 3) the collection of the observed resources (stored in a map).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Wiring the Action&lt;/b&gt;&lt;br /&gt;The Action component is wired into Spring using Spring &amp;lt;lang:groovy&amp;gt; tag.  This tag facilitates the integration of Groovy objects into the Spring context and provides several other settings (such as refresh, etc).  Here, we are using the tag to point to script file located on the class path.&lt;br /&gt;&lt;br /&gt;        &amp;lt;&lt;b&gt;lang&lt;/b&gt;:&lt;b&gt;groovy &lt;/b&gt;id="action" script-source="classpath:scripts/SyncAction.groovy"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The Groovy Action Class&lt;/b&gt;&lt;br /&gt;The Groovy Action class implements the Action interface (from Broadway API) directly to carry out the logic for the synchronizer. If you don't care about the Spring dependency, this is a better option then using the ScritpedAction component provided by Broadway (see below). However, you need to do some tedious class casting to get to the values in the context object. Here is what the Groovy Action class looks like:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;class SyncAction implements Action{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        public Object execute(Context ctx){&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                HashMap resources = (HashMap)ctx.getValue(MonitorConstants.MonitorKeys.RESOURCE_COLLECTION);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                String dirPath1 = resources["firstDir"].directoryName;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                String dirPath2 = resources["secondDir"].directoryName;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                File dir1 = new File(dirPath1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                dir1.eachFile {origFile -&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                        String origFileName = origFile.name;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                        File destFile = new File(dirPath2+ File.separator + origFileName);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                        if(!destFile.exists() || (destFile.lastModified() &lt;&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                                print "Synching file File $origFile.name ...\n";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                                def fis = origFile.newInputStream();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                                new FileOutputStream(destFile).withStream {fos -&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                                        fos &lt;&lt;&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                                }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;}&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;An Alternative to Groovy Action Class&lt;/b&gt;&lt;br /&gt;If you do not want to use Spring's dynamic language support, you can still use Groovy to execute the action.  Broadway provides a component called &lt;b&gt;ScriptedAction &lt;/b&gt;that lets you specify a script file on the classpath or the system file path.  Using this option, you can specify the script for your action in a simpler way.&lt;br /&gt;&lt;br /&gt;To &lt;b&gt;wire the ScriptedAction&lt;/b&gt; do:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;b&gt;bean &lt;/b&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;id="action"&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                class="org.broadway.monitor.ScriptedAction"&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;                &amp;lt;property name="scriptFileLocation" value="scripts/synchronizeDir.groovy" /&amp;gt;&lt;/span&gt; &lt;span style="font-family:Courier New;"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;b&gt;bean&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;br /&gt;Here, the component points to a Groovy script file located on the classpath.  The Groovy script that gets executed by the ScriptedAction component is the following:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;def dirPath1 = context.resources.firstDir.directoryName;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;def dirPath2 = context.resources.secondDir.directoryName;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;print "***** Synchronizing Directories [Mirror dir2 to Dir1] *****\n";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;def File dir1 = new File(dirPath1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;dir1.eachFile {origFile -&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        def origFileName = origFile.name;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        def destFile = new File(dirPath2+ File.separator + origFileName);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        if(!destFile.exists() || (destFile.lastModified() &lt;&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                print "Synching file File $origFile.name ...\n";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                def fis = origFile.newInputStream();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                new FileOutputStream(destFile).withStream {fos -&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                        fos &lt;&lt;&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;We've seen how easy it is to use Groovy, Spring, and Broadway to wire together monitors.  This example shows how to create a directory synchronizer with little effort.  I encourage you to take a look at Broadway and let me know what you think.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;More Info&lt;br /&gt;&lt;/b&gt;Google Doc - &lt;/span&gt;&lt;a id="publishedDocumentUrl" class="tabcontent" target="_blank" href="http://docs.google.com/Doc?id=df3qdpw5_50hs7pn3fv"&gt;http://docs.google.com/Doc?id=df3qdpw5_50hs7pn3fv&lt;/a&gt;&lt;br /&gt;Broadway - &lt;a title="http://code.google.com/p/broadway-monitor/" href="http://code.google.com/p/broadway-monitor/" id="xmae"&gt;http://code.google.com/p/broadway-monitor/&lt;/a&gt;&lt;br /&gt;Download Broadway - &lt;a title="http://broadway-monitor.googlecode.com/files/broadway-0.5.zip" href="http://broadway-monitor.googlecode.com/files/broadway-0.5.zip" id="gila"&gt;http://broadway-monitor.googlecode.com/files/broadway-0.5.zip&lt;/a&gt;&lt;br /&gt;Download Tutorial - &lt;a title="http://broadway-monitor.googlecode.com/files/broadway-tutorial.zip" href="http://broadway-monitor.googlecode.com/files/broadway-tutorial.zip" id="pl26"&gt;http://broadway-monitor.googlecode.com/files/broadway-tutorial.zip&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-1407695328792171360?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/1407695328792171360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/1407695328792171360'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2008/01/groovy-spring-broadway-resource_10.html' title='Groovy + Spring + Broadway = { -&amp;gt; Resource Monitoring }'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-7964496285952662970</id><published>2007-12-31T03:45:00.000-05:00</published><updated>2007-12-31T04:19:01.812-05:00</updated><title type='text'>Introducing Project Broadway Monitor</title><content type='html'>I have been working on this on and off for the past 3 years.  As with free-time projects, it started out as something completely different and progressively turned into what it is today.  If you find the project interesting, send some feedbacks!  So, here it is:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://code.google.com/p/broadway-monitor/"&gt;&lt;span style="font-weight: bold;"&gt;Project Broadway&lt;/span&gt;&lt;/a&gt; is an extensible and customizable monitoring API.  Broadway lets developers easily create monitor components to observe pre-defined conditions and specify how to react when these conditions are encountered.&lt;br /&gt;&lt;br /&gt;&lt;img src="http://vmatters.googlepages.com/broadway-object-monitor.png" /&gt;&lt;br /&gt;&lt;br /&gt;At its core, Broadway lets you separate the monitoring concerns from the observed resources.  It has a  flexible design,   which allows it to work in any context where JavaBean-style getter property values can be read either directly through in-VM method invocation or through some detached mechanism (i.e. proxy, reflection, rmi, jmx, web service, etc).  Broadway's simplified design offers two major high level components a Monitor and an Action.  The Monitor components lets you specify resources to monitor and express some rules to monitor using a scripting language (&lt;span style="font-weight: bold;"&gt;Groovy &lt;/span&gt;is the default).  The Action component specifies the action to execute when a specified condition is realized.  Action can be pure Java classes or they can be written in scripting languages such as Groovy or JavaScript, etc.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Broadway Offers&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;Ability to monitor both in-VM and distributed resources. &lt;/li&gt;&lt;li&gt;API with rich level of programmability through a monitor DSL. &lt;/li&gt;&lt;li&gt;Leverages existing frameworks including JavaBean, JMX, Java scripting, Apache BSF, etc. &lt;/li&gt;&lt;li&gt;Support expressive monitoring rules using scripting language (default is Groovy) &lt;/li&gt;&lt;li&gt;Create compound expression to monitor multiple resources which can be in different context. &lt;/li&gt;&lt;li&gt;Architecture allows plug-in of different scripting engine supported Apache BSF (default is Groovy). &lt;/li&gt;&lt;li&gt;Scripted action component to execute script files to react to monitor expressions. &lt;/li&gt;&lt;/ul&gt;For more details, visit &lt;a style="font-weight: bold;" href="http://code.google.com/p/broadway-monitor/"&gt;http://code.google.com/p/broadway-monitor/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-7964496285952662970?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/7964496285952662970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/7964496285952662970'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2007/12/introducing-project-broadway-monitor.html' title='Introducing Project Broadway Monitor'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-6300037360247180642</id><published>2007-10-13T14:04:00.000-04:00</published><updated>2007-10-14T09:13:18.304-04:00</updated><title type='text'>NFJS Atlanta</title><content type='html'>Last weekend I attended the &lt;a href="http://www.nofluffjuststuff.com/conference/atlanta/2007/10/index.html"&gt;No Fluff Just Stuff Atlanta&lt;/a&gt; as a speaker.  The series has a wide set of topics ranging from front-end development to ESB.  There was something for everyone doing enterprise computing.  I especially enjoyed the general session talk "No I Won't Tell You Which Web Framework to Use..." by Scott Davis and Neal Ford's presentation "Building DSLs in Static and Dynamic Languages."&lt;br /&gt;&lt;br /&gt;One recurring theme gaining momentum this year is turning Java into a platform for creating and using other languages.  Java 6 introduced inherent support for hosting dynamic languages (see also Apache's Bsf).  It's interesting to see how people are using or plan to use dynamic languages in their development.  Groovy/Grails are definitely catching people's attention.  I heard less of Rails and more of Grails (hmmm.... it could be because I of my own bias).   While Grails provides a world class web framework, the focus is also on "how to use Groovy as the glue code to quickly integrate the heavier static Java components at the edge layers."&lt;br /&gt;&lt;br /&gt;My JMX Presentation&lt;br /&gt;People are still interested in JMX.  If anything, just out of curiosity to see what JMX is about.  Not suprisingly, more and more people are using JConsole (which is good).  But, not too many folks realize that, they too, can create apps that can expose management components in JConsole.  So, I will continue to talk about Jmx.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-6300037360247180642?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/6300037360247180642'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/6300037360247180642'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2007/10/nfjs-atlanta.html' title='NFJS Atlanta'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-2205171275242577400</id><published>2007-09-23T08:21:00.000-04:00</published><updated>2007-09-23T08:28:37.975-04:00</updated><title type='text'>barCamp Orlando!</title><content type='html'>On Wednesday, after visiting a &lt;a href="http://www.jameswilliams.be/blog/"&gt;James Williams&lt;/a&gt; page (Tampa JUG speaker for September), and seeing a link for &lt;a href="http://www.barcamporlando.org/"&gt;Orlando's barCamp&lt;/a&gt;, I decided to also attend.  I figure it's a good way to spend a Sunday with people talking about technology all day.  The gathering is described as anti-conference, where almost everyone is sort of expected to contribute.  I will talk about Flex (it's been a while since I visited the front-end).&lt;br /&gt;&lt;br /&gt;Anyway, if you are heading to Orlando, see you there!&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.barcamporlando.org/" title="BarCampOrlando"&gt;&lt;img src="http://www.barcamporlando.org/assets/2007/7/26/BarCampOrlando-Black.png" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-2205171275242577400?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/2205171275242577400'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/2205171275242577400'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2007/09/barcamp-orlando.html' title='barCamp Orlando!'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-6828263608302951708</id><published>2007-08-29T07:21:00.000-04:00</published><updated>2007-08-29T07:50:25.995-04:00</updated><title type='text'>BeOS Lives On?</title><content type='html'>Back in the mid 90's (so long ago), BeOS was all the rave.  I bought and used a copy of the OS (yes, my nerdiness extends back awhile) and liked it very much.  However, there were few software and drivers available and eventually the company went under.&lt;br /&gt;&lt;br /&gt;Be Inc got disbanded (I think the intellectual properties went to 3M or Palm, Inc, not sure) and there were little activity on the OS for about 10 years.  I always wondered if anyone else thought BeOS was cool enough to be kept alive...&lt;br /&gt;&lt;br /&gt;Yes!  The guys at Haiku Inc seems to think so and have been supporting a project called Haiku OS for about 6 yrs (who knew).  Now, it seems that Google Inc is interested in the small project.  It's described as a binary-compatible reverse-engineered OS (smells litigious you may say, but I think Google will just buy the remainder of the IP from its owners).&lt;br /&gt;&lt;br /&gt;Among its many aspirations, Google is missing an OS of its own.  It would be nice to see GoogleOS comes out of this effort.  I mean, it only makes sense if Google will compete againstMS and eventually Apple.  As a user and lover of technology, I am all for an OS that will energize the community based on its technical merit (not just overblown hypes).&lt;br /&gt;&lt;br /&gt;Check it out :&lt;br /&gt;&lt;a href="http://haiku-os.org/"&gt;http://haiku-os.org/&lt;/a&gt; - Site link.&lt;br /&gt;&lt;a href="http://video.google.com/videoplay?docid=236331448076587879"&gt;http://video.google.com/videoplay?docid=236331448076587879&lt;/a&gt; - Google Talk: Haiku&lt;br /&gt;&lt;a href="http://haiku-os.org/index.php?q=gallery&amp;g2_itemId=1288"&gt;http://haiku-os.org/index.php?q=gallery&amp;amp;g2_itemId=1288&lt;/a&gt; - Haiku at Google&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-6828263608302951708?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/6828263608302951708'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/6828263608302951708'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2007/08/beos-lives-on.html' title='BeOS Lives On?'/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry><entry><id>tag:blogger.com,1999:blog-17720202.post-2125910620737718572</id><published>2007-06-13T17:16:00.000-04:00</published><updated>2007-08-09T06:44:59.004-04:00</updated><title type='text'></title><content type='html'>&lt;h1 class="western"&gt;Part 2 – Creating an Advanced JBoss 4.x Service Archive (SAR) Components&lt;br /&gt;&lt;/h1&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;In &lt;/span&gt;&lt;/span&gt;&lt;a href="http://docs.google.com/Doc?id=df3qdpw5_11drvpwq"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;u&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;part one&lt;/span&gt;&lt;/span&gt;&lt;/u&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt; of this write up provided an introductory look into JBoss' Service Archive architecture (SAR).  Service archives are components that are deployed on JBoss that can be used to extend the capabilities of JBoss or your deployed applications.  The SAR architecture is the basis for JBoss’ component-based development and allows the deployment of modules that can easily be reused by other deployed modules. &lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;The previous post included an example of a simple service archive that illustrates the ease with which a service archive component can be created and deployed on JBoss.  This write up explores the use of JBoss service API to create more advanced components that can receive life-cycle notifications for a deeper integration with the JBoss container.  We will take a look at how to use the JBoss XMBean descriptor file which is used to create rich set of attributes for describing JMX MBeans.  All concepts covered here, are reinforced through an example that builds on the previous example in part 1 to create a directory monitoring system deployed as SAR in JBoss.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;a href="http://docs.google.com/Doc?id=df3qdpw5_11drvpwq"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;u&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;Click here to read part 1 of this post&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Integrating with JBoss Server&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;The JBoss service API provides different points for deep integration with the JBoss container.  These integration points are event callbacks that are fired during at different stages of the container’s lifecycle.     &lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;b&gt;org.jboss.system.ServiceMBean&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;The core interface that provides access into the container’s service architecture is the &lt;/span&gt;&lt;b&gt;&lt;span style="font-family:Courier New,monospace;"&gt;org.jboss.system.ServiceMBean&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;.  This interface exposes several lifecycle callback methods.  Instead of directly implementing the interface, your SAR component class should extend the convenience class &lt;/span&gt;&lt;b&gt;&lt;span style="font-family:Courier New,monospace;"&gt;org.jboss.system.ServiceMBeanSupport&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family:Arial,sans-serif;"&gt; and override the following methods:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;table style="color: rgb(0, 0, 0);" border="1" cellpadding="8" cellspacing="0" width="616"&gt;  &lt;col width="598"&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td bg="" style="color: rgb(192, 192, 192);" valign="top" width="598"&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;protected    void &lt;b&gt;createService&lt;/b&gt;() throws Exception;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;protected    void &lt;b&gt;destroyService&lt;/b&gt;() throws Exception;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;protected    void &lt;b&gt;startService&lt;/b&gt;() throws Exception;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;protected    void &lt;b&gt;stopService&lt;/b&gt;() throws Exception;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western"&gt;&lt;br /&gt; &lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;As the method names imply, you override the methods that correspond to the phase in the service lifecycle you are interested in.  The &lt;/span&gt;&lt;b&gt;&lt;span style="font-family:Courier New,monospace;"&gt;createService()&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family:Arial,sans-serif;"&gt; is called when the container’s SAR Deployer is about to initialize your service.  Once your service is fully realized, the deployer calls the &lt;/span&gt;&lt;b&gt;&lt;span style="font-family:Courier New,monospace;"&gt;startService()&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family:Arial,sans-serif;"&gt; automatically.   The &lt;/span&gt;&lt;b&gt;&lt;span style="font-family:Courier New,monospace;"&gt;destroyService()&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family:Arial,sans-serif;"&gt; is invoked by the deployer when server is stopping or when your service is about to be deregistered from the MBean container.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;The &lt;b&gt;ServiceMBeanSupport&lt;/b&gt; class also makes available other convenience callback methods that maket it easier for your service to receive a larger set of container events.  These methods include:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;table style="color: rgb(0, 0, 0);" border="1" cellpadding="8" cellspacing="0" width="616"&gt;  &lt;col width="598"&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td bg="" style="color: rgb(192, 192, 192);" valign="top" width="598"&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;public&lt;b&gt;    ObjectName&lt;/b&gt; &lt;b&gt;preRegister&lt;/b&gt;(javax.management.MBeanServer server,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;                          &lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;javax.management.ObjectName name)    throws Exception;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt; &lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;public    &lt;b&gt;void&lt;/b&gt; &lt;b&gt;postRegister&lt;/b&gt;(Boolean registrationDone);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western"&gt;&lt;br /&gt; &lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;The &lt;/span&gt;&lt;b&gt;&lt;span style="font-family:Courier New,monospace;"&gt;preRegister()&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family:Arial,sans-serif;"&gt; method provides access to couple of key JMX objects including the MBean server and reference to the &lt;b&gt;ObjectName&lt;/b&gt; for the component being registered.  These methods are fired right before and right after the component’s registration into the MBean’s server respectively. &lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;table style="color: rgb(0, 0, 0);" border="1" cellpadding="8" cellspacing="0" width="616"&gt;  &lt;col width="598"&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td bg="" style="color: rgb(192, 192, 192);" valign="top" width="598"&gt;    &lt;p class="western"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;u&gt;NOTE&lt;/u&gt;:     Deep integration with the JBoss container means that your code    will introduce dependencies on the JBoss service API.  However,    that’s should not be a problem if your code follows good OO    practices and well-know patterns that lessen architectural    dependencies.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;b&gt;The JBoss XMBean Descriptor File&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;In part one of this write up, I presented a simple SAR example that was implemented using the JMX API's Standard MBean which relies on a prescribed naming pattern.  While this works, it has several drawbacks:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;ul&gt;  &lt;li&gt;&lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;It  forces the undesirable burden of naming your classes using a  management interface naming pattern which may not fit well in your  development.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;The  Standard MBean does not allow you to control which methods /  properties are exposed for management.  JBoss will automatically  expose all management interface properties as JMX attributes and all  methods as management operations.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;Lastly,  the Standard API has no mechanism to expose descriptive metadata  regarding the exposed attributes and operations.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;While the simple Standard MBean approach works well for simple cases, it may prove inefficient for complicated domain models and force you to insert JMX management matters into your business object graphs.  JBoss alleviates this issue by providing the XMBean Deployment Descriptor XML file. XMBean provides the ability to expose any class (POJO) as a JMX MBean and therefore be exposed as a service archive component.  &lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;The XMBean descriptor mechanism also lets you expose your MBeans with richer descriptive metadata.  Using the XMBean, one may specify description for all expose attributes, getters, and setters exposed by your MBean component.  You can also use the XMBean to specify attributes persistence policy, and security interceptors classes supported by JBoss.  For further information, see the JBoss XMBean documentation.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;Using the XMBean Descriptor File&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;ol&gt;  &lt;li&gt;&lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;Declare  your SAR component class in the &lt;b&gt;jboss-service.xml &lt;/b&gt;file (same  as before).  Instead of specifying the attributes and operations in  the service file, as before, point the component to an XMBean file  using the &lt;b&gt;xmbean-dd attribute&lt;/b&gt;.  In the code snippet below,  the component: points to file timer-xmbean.xml to get its  definition:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;/li&gt;&lt;/ol&gt; &lt;table style="color: rgb(0, 0, 0);" border="1" cellpadding="8" cellspacing="0" width="616"&gt;  &lt;col width="598"&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td bg="" style="color: rgb(192, 192, 192);" valign="top" width="598"&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;      &amp;lt;&lt;b&gt;mbean&lt;/b&gt; code="service.SimpleTimer" &lt;/span&gt;&lt;/span&gt;    &lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;             name="service.directory.monitor:service=MonitorTimer"&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;             &lt;b&gt;xmbean-dd&lt;/b&gt;="META-INF/timer-xmbean.xml"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;      &amp;lt;/&lt;b&gt;mbean&lt;/b&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western"&gt;&lt;br /&gt; &lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p class="western" style="margin-left: 0.25in; margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;ol start="2"&gt;  &lt;li&gt;&lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;Create  the XMBean XML descriptor file (with an arbitrary name) that matches  the name specified in step 1.  In it, insert any number of XML  emlements (see JBoss Admin Guide) to describe attributes, methods,  notifications, interceptors, and remote access interfaces.  Here's  an excerpt of the XMBean file for the class service.SimpleTimer:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;/li&gt;&lt;/ol&gt; &lt;p class="western" style="margin-left: 0.25in; margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;table style="color: rgb(0, 0, 0);" border="1" cellpadding="8" cellspacing="0" width="616"&gt;  &lt;col width="598"&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td bg="" style="color: rgb(192, 192, 192);" valign="top" width="598"&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;&lt;b&gt;class&lt;/b&gt;&amp;gt;service.SimpleTimer&amp;lt;/&lt;b&gt;class&lt;/b&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:78%;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;&lt;b&gt;constructor&lt;/b&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;    &lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;description&amp;gt;The    default constructor&amp;lt;/description&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;       &lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;name&amp;gt;SimpleTimer&amp;lt;/name&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;/&lt;b&gt;constructor&lt;/b&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:78%;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:78%;"&gt;&amp;lt;!--    Attributes --&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;&lt;b&gt;attribute&lt;/b&gt;    &lt;b&gt;access&lt;/b&gt;="read-write" &lt;b&gt;getMethod&lt;/b&gt;="getPeriod"    &lt;b&gt;setMethod&lt;/b&gt;="setPeriod"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;    &lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;&lt;b&gt;description&lt;/b&gt;&amp;gt;The    timing period for the timer. Defaults to 1000 mill sec (1    sec)&amp;lt;/&lt;b&gt;description&lt;/b&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;       &lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;&lt;b&gt;name&lt;/b&gt;&amp;gt;Period&amp;lt;/&lt;b&gt;name&lt;/b&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;       &lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;type&amp;gt;long&amp;lt;/type&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;/&lt;b&gt;attribute&lt;/b&gt;&amp;gt;    &lt;/span&gt;&lt;/span&gt;    &lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:78%;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:78%;"&gt;&amp;lt;!--    Operations --&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;&lt;b&gt;operation&lt;/b&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;    &lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;&lt;b&gt;description&lt;/b&gt;&amp;gt;&lt;br /&gt;        This operation starts the timer. Registered listeners will    start receiving timing notifications.&lt;br /&gt; &amp;lt;/&lt;b&gt;description&lt;/b&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;       &lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;name&amp;gt;&lt;b&gt;start&lt;/b&gt;&amp;lt;/name&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;/&lt;b&gt;operation&lt;/b&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt; &lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:78%;"&gt;&lt;b&gt;&amp;lt;operation&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;       &lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;b&gt;&amp;lt;description&amp;gt;&lt;/b&gt;This    operation stops the timer service.&lt;b&gt;&amp;lt;/description&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;       &lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;name&amp;gt;stop&amp;lt;/name&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:78%;"&gt;&lt;b&gt;&amp;lt;/operation&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt; &lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;&lt;b&gt;operation&lt;/b&gt;    impact="ACTION"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;    &lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;b&gt;&amp;lt;description&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;        &lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;When    invoked, it sends a timing notification to registered (connected)    services.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;    &lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;b&gt;&amp;lt;/description&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;       &lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;name&amp;gt;time&amp;lt;/name&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western"&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&amp;lt;&lt;b&gt;/operation&lt;/b&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p class="western" style="margin-left: 0.25in; margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;The XMBean produces the following in the jmx-console:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;img src="http://docs.google.com/File?id=df3qdpw5_43gjhgjmhg" name="graphics1" align="bottom" border="0" height="352" width="606" /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;XMBean extends the service descriptor file to provide features such as dependency injection and descriptive metadata capabilities for the JBoss JMX container. Additionally, &lt;b&gt;&amp;lt;name/&amp;gt;&lt;/b&gt; and &lt;b&gt;&amp;lt;description/&amp;gt;&lt;/b&gt; tags can be used to describe their enclosing constructor, operation, or attributes.  The text will be exposed to the management console for increased usability during management of the component.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;Under the hood, XMBean is JBoss' implementation of the Model MBean.  The JBoss API does the heavy lifting to generate the sizeable amount of code required to dynamically create model MBeans.  You simply specify a POJO and JBoss handles the rest.  This approach lets you create complex domain models independent of any container specific API.  In future write up, we will explore how to accomplish integration using Java-style annotations.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;The Advanced Directory Monitor Example&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;This example demonstrates several concepts in developing service archive components including the ability to receive life cycle notifications from the JBoss SAR Deployer.  Since the service infrastructure is based on JMX, you will inevitably create additional JMX management API dependencies to fully take advantage of the JBoss infrastructure.  &lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;For that reason, great care must be taken to implement management infrastructures in your code that separates management concerns away from your core business concerns.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;b&gt;The Directory Scanner Components&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;The implementation of the scanner is achieved using three distinct components.  The segregation of the code into these components is a purely subjective decision.  However, creating loosely-coupled components promotes good OO practices, increases code re-use, and, above all, makes implementation of management concerns easier since they can be separated out of business concerns.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;img src="http://docs.google.com/File?id=df3qdpw5_44hcr4w3fn" name="graphics2" align="bottom" border="0" height="274" width="465" /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;Timer&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;The Timer component (implemented as &lt;b&gt;SimpleTimer&lt;/b&gt;) provides timing service to other interested components.  It extends the JMX API class &lt;b&gt;NotificationBroadcasterSupport &lt;/b&gt;which allows it notify interested components (registered as listeners).  For each time period t, the Timer sends a JMX notification of type "&lt;b&gt;service.SimpleTimer.time&lt;/b&gt;" to registered listeners.  In our sample code, the component Directory Monitor component will register itself as a listener to the Timer service.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;Directory Monitor &lt;/b&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;This component (implemented as &lt;b&gt;DirectoryMonitor2&lt;/b&gt;) scans a specified directory for files with specified extensions.  When the files with the extension are found in the scanned directory, the monitor sends a notification to registered Directory Monitor Listener.  During a scan sweep, if one or more files with a specified extension is detected in a specified directory, the directory monitor sends a notification of type "&lt;b&gt;service.DirectoryMonitor.scan&lt;/b&gt;."  &lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;The &lt;b&gt;DirectoryMonitor2&lt;/b&gt; class extends the JBoss API class "&lt;b&gt;org.jboss.system.ServiceMBeanSupport&lt;/b&gt;" to receive lifecycle notification from the JBoss container.  When the SAR Deployer is deploying this component, it calls methods &lt;b&gt;create&lt;/b&gt;(), &lt;b&gt;preRegister&lt;/b&gt;(), &lt;b&gt;postRegister&lt;/b&gt;, and &lt;b&gt;start&lt;/b&gt;() respectively.  You can implement any of these methods to take advantage of the callback mechanism to customize the registration sequence.  In our example below, the DirectoryMonitor2 uses these callback method &lt;b&gt;create&lt;/b&gt;() to register itself as a listener of the Timer component:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;table style="color: rgb(0, 0, 0);" border="1" cellpadding="8" cellspacing="0" width="616"&gt;  &lt;col width="598"&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td bg="" style="color: rgb(192, 192, 192);" valign="top" width="598"&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;b&gt;public&lt;/b&gt;    &lt;b&gt;ObjectName&lt;/b&gt; preRegister(MBeanServer svr, ObjectName obj)    &lt;b&gt;throws&lt;/b&gt; &lt;b&gt;Exception&lt;/b&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;super.preRegister(svr,    obj);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt; this.server    = svr;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt; ...&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;b&gt;public&lt;/b&gt;    &lt;b&gt;void&lt;/b&gt; create() throws Exception {&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;super.create();&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt; registerForTimer();&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt; ...&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt; &lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;b&gt;private    void&lt;/b&gt; registerForTimer() {&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;if(server    != null) {&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;      NotificationFilterSupport filter = new    NotificationFilterSupport();&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;      filter.enableType(EVENT_TYPE); &lt;/span&gt;&lt;/span&gt;    &lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;      try {&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;  ObjectName    timerName = new ObjectName(this.getTimerName());&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;  server.addNotificationListener(timerName,    this, filter, null);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;      } catch ( ... ) { ... }&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt; }&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;.    . .&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western"&gt;&lt;span style="font-family:Courier New,monospace;"&gt;&lt;span style="font-size:85%;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;br /&gt;From the code sample, you can see that the create() method is implemented as a callback to programmatically register the DirectoryMonitor as a listener to the timer component.  Review the code for details on these classes.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;MonitorListener &lt;/b&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;As a design decision, the logic that handles the notifications from the directory monitor is placed in a separate component.  Though not necessary, it makes for a cleaner implementation.  The MonitorLister handles notifications broadcasted from the Monitor components of type "&lt;b&gt;service.DirectoryMonitor.scan.&lt;/b&gt;" One advantage of this separation is that the directory monitor code is separated from the code that provides logic on handling the scanned directory resources from the monitor.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;table style="color: rgb(0, 0, 0);" border="1" cellpadding="8" cellspacing="0" width="640"&gt;  &lt;col width="622"&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td bg="" style="color: rgb(192, 192, 192);" valign="top" width="622"&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Running    the Sample Code&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;ol&gt;     &lt;li&gt;&lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;Download     the code (see Resources below)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;     &lt;/li&gt;&lt;li&gt;&lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;The     zipped file contains a project which can be opened in either     Eclipse or NetBeans&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;     &lt;/li&gt;&lt;li&gt;&lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;Edit     file srcMETA-INFjboss-service.xml to uncomment the Advanced     service declaration&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;     &lt;/li&gt;&lt;li&gt;&lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;Compile     into SAR (basically a JAR file or exploded directory with a .SAR     extension)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;     &lt;/li&gt;&lt;li&gt;&lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;Drop     SAR package in your JBoss deployment directory&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;     &lt;/li&gt;&lt;li&gt;&lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;Log     unto your JBoss jmx-console to validate your deployment. &lt;/span&gt;&lt;/span&gt;     &lt;/p&gt;    &lt;/li&gt;&lt;/ol&gt;    &lt;p class="western" style="margin-left: 0.25in; margin-bottom: 0in;"&gt;  &lt;br /&gt; &lt;/p&gt;    &lt;p class="western" style="margin-left: 0.25in; margin-bottom: 0in;"&gt;    &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;Log into your    jmx-console and you should see the following components deployed&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt; &lt;/p&gt;    &lt;p class="western" style="margin-left: 0.25in; margin-bottom: 0in;"&gt;    &lt;img src="http://docs.google.com/File?id=df3qdpw5_45ffw9dthq" name="graphics3" align="bottom" border="0" height="175" width="352" /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt; &lt;/p&gt;    &lt;p class="western" style="margin-left: 0.25in; margin-bottom: 0in;"&gt;    &lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;You can also validate    the deployment of your component by seeing output in the console    similar to the console image shown below.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt; &lt;/p&gt;    &lt;p class="western" style="margin-left: 0.25in; margin-bottom: 0in;"&gt;    &lt;img src="http://docs.google.com/File?id=df3qdpw5_46gsb8zqd5" name="graphics4" align="bottom" border="0" height="159" width="599" /&gt;&lt;/p&gt;    &lt;p class="western"&gt;&lt;br /&gt; &lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;In this post, I looked at how to create SAR components with deep integration with the JBoss container.  SAR’s are JBoss components based on the JBoss container service architecture which itself is based on JMX technology.  &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;u&gt;&lt;a href="http://docs.google.com/View?docID=df3qdpw5_11drvpwq&amp;revision=_latest&amp;amp;spi=1&amp;hgd=1"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;In a previous post&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/u&gt;&lt;/span&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;, we have seen how to create simple SAR components using the JMX standard MBeans.  In this post, we have seen how to create a more advanced example where the SAR components can be deeply integrated with the JBoss container.&lt;br /&gt;&lt;br /&gt;Using the service management interfaces provided by the JBoss service architecture, we’ve seen how you can create SAR components that can listen to container generated lifecycle events including when the components is being created, registered into the container, and destroyed.  By overriding methods in class &lt;b&gt;org.jboss.system.ServiceMBeanSupport&lt;/b&gt;, we have seen how to implement methods that take advantage of the different lifecycle callbacks invoked during the instantiation sequence of the SAR component.  You can download the sample code discussed here using the link found in the resource section.&lt;br /&gt;&lt;br /&gt;In future post, we will explore JBoss’s support for annotated class to easily create SAR components using POJO’s.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;b&gt;Resources&lt;/b&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;1) JBoss Server Documentation - &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;u&gt;&lt;a href="http://docs.jboss.com/jbossas/guides/installguide/r1/en/html_single/"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;http://docs.jboss.com/jbossas/guides/installguide/r1/en/html_single/&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/u&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;br /&gt;2) JMX - &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;u&gt;&lt;a href="http://en.wikipedia.org/wiki/JMX"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;http://en.wikipedia.org/wiki/JMX&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/u&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;&lt;br /&gt;3) Download Example – &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;u&gt;&lt;a href="http://vladimirvivien.com/download/demos/jboss-service.zip"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;http://vladimirvivien.com/download/demos/jboss-service.zip&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/u&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Arial,sans-serif;"&gt; &lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p class="western" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-2125910620737718572?l=vladimirvivien.com%2Fblogs%2Fot'/&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/2125910620737718572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17720202/posts/default/2125910620737718572'/><link rel='alternate' type='text/html' href='http://vladimirvivien.com/blogs/ot/2007/06/part-2-creating-advanced-jboss-4.html' title=''/><author><name>vmatters</name><uri>http://www.blogger.com/profile/15062049812941486249</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16685311502578667011'/></author></entry></feed>