<?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' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4831432806087932521</id><updated>2011-11-14T07:00:55.592-05:00</updated><category term='AOP'/><category term='Advise'/><category term='Efflex'/><category term='Struts2'/><category term='XSD'/><category term='Swiz'/><category term='MVC'/><category term='WTP'/><category term='Annotations'/><category term='Closure'/><category term='java'/><category term='ODP'/><category term='Flexmojos'/><category term='Hibernate'/><category term='OSGI'/><category term='Generics'/><category term='JSR-303'/><category term='HQL'/><category term='jvisualvm'/><category term='JDBC'/><category term='Reflex'/><category term='Validator'/><category term='Robotlegs'/><category term='PHP'/><category term='EJB'/><category term='AspectJ'/><category term='Spring-Roo'/><category term='Tiles2'/><category term='Charts'/><category term='STS'/><category term='Git'/><category term='Maven'/><category term='Struts1'/><category term='Spring-AOP'/><category term='Pointcut'/><category term='ORM'/><category term='Spring-MVC'/><category term='Eclipse'/><category term='RoR'/><category term='RabbitMQ'/><category term='Flex'/><category term='AMQP'/><category term='jps'/><category term='Persistence'/><category term='Spring'/><category term='JEE'/><category term='.NET'/><category term='DAO'/><title type='text'>Enterprise Applications and Development</title><subtitle type='html'>Notes on different technologies available for building Enterprise Applications.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>31</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-585613021733448991</id><published>2010-08-31T08:53:00.001-04:00</published><updated>2010-08-31T08:56:57.064-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JDBC'/><title type='text'>Oracle JDBC Logging</title><content type='html'>During a database upgrade (oracle 10g to 11g) I had to debug a series of JDBC calls. I suspected a performance bottleneck in a database query and decided to look for the offending SQL statement.&amp;nbsp; This is when I started to find how much information there is about JDBC logging. Most places I researched pointed me to &lt;a href="http://www.p6spy.com/"&gt;p6spy&lt;/a&gt;, a nice tool which according to the documentation "&lt;i&gt;intercepts and optionally modifies database statements&lt;/i&gt;". This was helpful to determine that the bottleneck was not a SQL statement from our application, but instead a library (open source) which needed metadata information.&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;P6spy is very useful to determine time and statistics only on &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Statement&lt;/span&gt;&lt;/span&gt; calls (and its subclasses). This is done by wrapping these types of objects and gathering statistics around each call. This is possible because of the abstraction provided by JDBC over SQL statements can be replicated by p6spy and then delegated back to the driver of choice. As we installed and run p6spy, we proved it was helpful to confirm what we suspected: Our application was just fine, the new database (11g) was having problems. Furthermore, we were able to detect that the offending API call was the following:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: java"&gt;DatabaseMetadata md = connection.getMetadata();&lt;br /&gt;md.getTables();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This type of JDBC call was not something we have control over. Now, most DBAs will demand to know the SQL query causing the slow performance in order to debug it and see what kind of improvements can be done to it. This is something very peculiar because no developer has a chance to change the query generated by the snippet above (this is part of the JDBC driver, specific to oracle). In fact, p6spy will not help either as this is not even a wrapper over &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Statement&lt;/span&gt;&lt;/span&gt; calls (well, it really is as you may learn later, but that's beyond the point of this subject). We decided to look into JDBC logging.&lt;br /&gt;&lt;br /&gt;Enabling logging in JDBC is a very subtle feature of JDBC, yet a powerful one. There is the ability to add a &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;PrintWriter&lt;/span&gt;&lt;/span&gt; to your &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;DriverManager&lt;/span&gt;&lt;/span&gt;. This partially helps and really is of no use if you are trying to look into the internals of the JDBC API. With a bit more of research, we learned about the debugging version of the JDBC driver. It contained logging using the &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;java.util.logging&lt;/span&gt;&lt;/span&gt; framework. As I worked with this Oracle driver, the following worked only with the proper ojdbc version.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Ensure that you use jdbc5_g.jar (java 5) or jdbc6_g.jar (java 6). This is very important as these drivers contain debugging (and logging) information.&lt;/li&gt;&lt;li&gt;Ensure no other JDBC driver is used.&lt;/li&gt;&lt;li&gt;Add the following system properties: &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;-Doracle.jdbc.Trace=true&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Have a properties file with the logging configuration. A sample of this file can be found in the demo download of the jdbc driver distribution.&amp;nbsp;&lt;/li&gt;&lt;/ol&gt;I also recommend adding a custom logging configuration location using the following:&lt;br /&gt;&lt;pre&gt;-Djava.util.logging.config.file&lt;/pre&gt;This will allow you to add your own location for the configuration file. The resulting logging file will log even the calls made within the JDBC API which allowed us to discover an internal SQL query to retrieve the name of the tables (from the &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;getTables()&lt;/span&gt;&lt;/span&gt; method mentioned above). This query was indeed a &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Statement&lt;/span&gt;&lt;/span&gt;, but a different one, thus p6spy could not possibly detect.&lt;br /&gt;&lt;br /&gt;Hope this helps!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-585613021733448991?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/585613021733448991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=585613021733448991' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/585613021733448991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/585613021733448991'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/08/oracle-jdbc-logging.html' title='Oracle JDBC Logging'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-3436422318769647643</id><published>2010-07-19T14:15:00.001-04:00</published><updated>2010-07-19T14:16:06.876-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Closure'/><category scheme='http://www.blogger.com/atom/ns#' term='Flex'/><title type='text'>Useful Closures use-cases in Flex</title><content type='html'>As flex is based on Actionscripts 3, it is possible to leverage some of the features of an ECMA-based language not readily available in strongly-typed languages. &amp;nbsp;Most Java developers will probably ignore the ability to use powerful features such as closures when the use-case simply makes sense. Consider the following:&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;b&gt;Function Handlers&lt;/b&gt;&lt;br /&gt;In most cases where a function handler is needed, this tip may be very useful, particularly when you don't want to maintain "any" state within the object you create. For example consider the case of an &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;HTTPService &lt;/span&gt;&lt;/span&gt;call.&lt;br /&gt;&lt;pre class="brush: as3"&gt;var svc:HTTPService = new HTTPService();&lt;br /&gt;  svc.url = "http://yourdomain/rest"; &lt;br /&gt;  svc.addEventListener(ResultEvent.RESULT, &lt;br /&gt;                       successHandler);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;In this plain vanilla example, you need to have a &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;successHandler&lt;/span&gt;&lt;/span&gt; method with the following signature:&lt;br /&gt;&lt;pre class="brush: as3"&gt;public function successHandler(event:Result):void {&lt;br /&gt;    // your implementation here&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;What if you needed to add a handler with additional parameters. Then you can leverage the dynamic nature of actionscript and write a closure like:&lt;br /&gt;&lt;pre class="brush: as3"&gt;svc.addEventListener(ResultEvent.RESULT, &lt;br /&gt;                       function (event:ResultEvent):void {&lt;br /&gt;       handleResult(event, foo);&lt;br /&gt;  });&lt;br /&gt;&lt;/pre&gt;and your new method to handle the result event will be:&lt;br /&gt;&lt;pre class="brush: as3"&gt;public function handleResult(event:Result, &lt;br /&gt;                               foo:Object):void {&lt;br /&gt;    // your implementation here&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;ResourceManager use in ActionScript&lt;/b&gt;&lt;br /&gt;Most tutorials I read were about the ability to do localization in Flex using the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;ResourceManager.getString()&lt;/span&gt;&lt;/span&gt; operation. In the case of binding to changes in the locale (as in the case of English to Spanish change), the recommended way to change is the following:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: xml"&gt;&lt;mx:label text="{resourceManager.getString('mybundle',&lt;br /&gt;                                    'property')}"&gt;&lt;br /&gt;&lt;/mx:label&gt;&lt;/pre&gt;&lt;br /&gt;This way, the app if completely localized. Notice that binding to the value of the returning string is fulfilled by the use of the curly bracket notation. &amp;nbsp;I found few discussion of what happens when the Label is created programatically (in actionscript). BindingUtils is a nice component from the Flex API that is aimed to solve the problem as you write a closure for the chain parameter (destination to be bound to). Here is an example:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;BindingUtils.bindProperty(this, &lt;br /&gt;     "mylocalProperty", &lt;br /&gt;     ResourceManager.getInstance(),&lt;br /&gt;     {  name:"getString",&lt;br /&gt;        getter: function (rm:IResourceManager):String {&lt;br /&gt;             return rm.getString('mybundle', 'property');&lt;br /&gt;             }&lt;br /&gt;     });&lt;br /&gt;&lt;/pre&gt;According to the API, the 3rd parameter can be an object of the form {name:"property", getter:"function(host)..." which means that the getter can now be a closure of your choice.&lt;br /&gt;&lt;br /&gt;Hope this helps!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-3436422318769647643?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/3436422318769647643/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=3436422318769647643' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/3436422318769647643'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/3436422318769647643'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/07/useful-closures-use-cases-in-flex.html' title='Useful Closures use-cases in Flex'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-8241735544702599270</id><published>2010-06-08T13:49:00.000-04:00</published><updated>2010-06-08T13:49:10.693-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Flex'/><title type='text'>Localizing Flex Applications</title><content type='html'>In my attempt to localize my flex application, it quickly became evident how simple it is to do basic localization in flex. As soon as I tried to implement more complex features, I realized how complicated it can become (e.g. add special characters, support multiple locales, flex builder problems, etc). In the interest of sharing the wealth, I'll describe the steps I took, so I don't have to keep on repeating some of these in future development efforts. These steps are:&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Trade-offs between &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@Resource&lt;/span&gt;&lt;/span&gt; and &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;ResourceManager&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Configuration of resource bundles following the flex convention.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Adding it to the source path (not necessarily overlapping).&lt;/li&gt;&lt;li&gt;Flex Framework compilation (usage of copylocale)&lt;/li&gt;&lt;li&gt;Problems with FlexBuilder proper compilation of multiple&amp;nbsp;&lt;/li&gt;&lt;li&gt;Special characters within resource bundles (ISO-8859-1 vs UTF-8)&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Understanding the Tradeoffs &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@Resource&lt;/span&gt;&lt;/span&gt; and &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;ResourceManager&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;@Resource&lt;/span&gt;&lt;/span&gt; and &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ResourceManager&lt;/span&gt;&lt;/span&gt; and basically the two ways to retrieve localized messages. The choice of either of these depends on the design and requirements of your application. I would imagine that if I have to do a "&lt;i&gt;quick&lt;/i&gt;" prototype, the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@Resource&lt;/span&gt;&lt;/span&gt;&amp;nbsp;component is the way to go (although one can argue the need of localization during early prototyping). &amp;nbsp;In constrast, the &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ResourceManager&lt;/span&gt;&lt;/span&gt;&amp;nbsp;component provides a far more flexible way to configure the resolution of your bundles as well as the locale to be used to fetch all messages. One other caveat is that if you need to localize a &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;.as&lt;/span&gt;&lt;/span&gt; file, then you are pretty much stucked with the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;ResourceManager&lt;/span&gt;&lt;/span&gt; object. Nothing bad, simply more configuration to add to your source code (with the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;ResourceBundle&lt;/span&gt;&lt;/span&gt; metadata tag). I have found that &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;ResourceManager&lt;/span&gt;&lt;/span&gt; provides a far better approach to localization and will have to have a very good reason to use &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@Resource&lt;/span&gt;&lt;/span&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Configuring all resource bundles&lt;/b&gt;&lt;/div&gt;&lt;div&gt;All resource bundles (for those of you who are Java Developers) would be of &amp;nbsp;the form &lt;bundle-name&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.properties&lt;/span&gt;&lt;/span&gt;. The flex convention is that it should be in a directory named after the locale name. This is different than traditional Java conventions where the locale is part of the bundle name. The compiler flags can then use the token &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{locale&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt; anywhere to denote the locale directory of choice.&lt;/bundle-name&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Dealing with the source path&lt;/b&gt;&lt;/div&gt;&lt;div&gt;In most configurations I've seen, there's a need to have the compiler flag:&lt;/div&gt;&lt;div&gt;&lt;pre style="background-color: #f0f7fe; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: #333333; font-family: 'Courier New', Courier, monospace; font-size: 13px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 500px;"&gt;-allow-source-path-overlap=true&lt;/pre&gt;This is not&amp;nbsp;necessarily&amp;nbsp;true. This should be done if the directory containing the folder with the locale exists in the same directory where the source code to be compiled resides. FlexBuilder (as well as FlexMojos) provides the ability to add additional source paths which will allow you to compile just fine.&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Flex Framework localization&lt;/b&gt;&lt;/div&gt;&lt;div&gt;In case this is your first time localizing an application in your development environment, you will need to do an extra step to properly run your application locally. There is a nifty tool called &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;copylocale &lt;/span&gt;&lt;/span&gt;which basically allows you to generate a locale for the flex framework in the language of your choice (as long as its supported by the tool). The syntax is something like:&lt;br /&gt;&lt;pre style="background-color: #f0f7fe; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: #333333; font-family: 'Courier New', Courier, monospace; font-size: 13px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 500px;"&gt;copylocale en_US destination_locale_name&lt;/pre&gt;So, in order to prepare your flex environment to use Spanish (Spain), you would have to do:&lt;br /&gt;&lt;pre style="background-color: #f0f7fe; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: #333333; font-family: 'Courier New', Courier, monospace; font-size: 13px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 500px;"&gt;copylocale en_US es_ES&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;Upon successful execution, you should see a new directory in the frameworks/locale directory with the name &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;es_ES&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Problems with Flex Builder&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Everywhere in the documentation it suggested to do the following (including FlexBuilder)&lt;br /&gt;&lt;pre style="background-color: #f0f7fe; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: #333333; font-family: 'Courier New', Courier, monospace; font-size: 13px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 500px;"&gt;-locale=en_US,es_ES&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;This didn't work for me in FlexBuilder. I tried the following:&lt;br /&gt;&lt;pre style="background-color: #f0f7fe; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: #333333; font-family: 'Courier New', Courier, monospace; font-size: 13px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 500px;"&gt;-locale=en_US es_ES&lt;/pre&gt;(notice the white space instead of the comma between locale names) and it worked fine. Flexmojos had a different configuration.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Special Characters&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Regarding special characters, my main problem was to ensure that all file encoding to be &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;UTF-8&lt;/span&gt;&lt;/span&gt; (the default is &amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;ISO-8859-1&lt;/span&gt;&lt;/span&gt;). This is bad if you try to use the escape sequence characters in flex to add special characters. Once you configure file encoding in FlexBuilder (Preferences &amp;gt; General &amp;gt; Workspace), you are good to go. I copied and pasted the proper translation from Google translate. It worked very well (at least for me).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hope this helps!&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-8241735544702599270?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/8241735544702599270/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=8241735544702599270' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/8241735544702599270'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/8241735544702599270'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/06/localizing-flex-applications.html' title='Localizing Flex Applications'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-5053986864382526720</id><published>2010-05-17T22:48:00.000-04:00</published><updated>2010-05-17T22:48:19.283-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='RabbitMQ'/><category scheme='http://www.blogger.com/atom/ns#' term='AMQP'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>My thoughts on RabbitMQ</title><content type='html'>&lt;div&gt;It is no mystery that I have been following the Spring Portfolio for sometime now. &amp;nbsp;As I continue to observe the business decisions they are making, its exciting to see how SpringSource is positioning itself to be a powerful player in the Enterprise Development arena. &amp;nbsp;Some months ago, SpringSource announced their acquisition of RabbitMQ and I thought I should get familiar with their choice for messaging solution.&lt;/div&gt;&lt;div&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I'm not going to discuss the associated need for a messaging system as a solution to integration of systems (Message Oriented Middleware). Instead I will mention a couple of observations about RabbitMQ.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First, the idea behing &lt;a href="http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol"&gt;AMQP&lt;/a&gt; (Advanced Messaging Queuing Protocol) seems to emphasize the idea of interoperability. &amp;nbsp;I have worked in environments where .NET integration was always a requirement, hence WS-* was always a compelling solution in so many ways. The idea of having a standard to establish a messaging contract (as opposed to an API such as JMS) seems a very powerful one. Of course, this makes even more sense when you think that a messaging system in the cloud ought to support a heterogenous environment.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In addition to this, there is already a trend about understanding comparisons between AMQP and XMPP (a favorite choice). &amp;nbsp;I was very pleased to find these&amp;nbsp;&lt;a href="http://www.opensourcery.co.za/2009/04/19/to-amqp-or-to-xmpp-that-is-the-question/"&gt;remarks&lt;/a&gt;&amp;nbsp;favoring AMQP for many good reasons, which I'm yet digesting myself. And today I came across this &lt;a href="http://highscalability.com/blog/2010/5/17/7-lessons-learned-while-building-reddit-to-270-million-page.html"&gt;article&lt;/a&gt; explaining High Availability lessons learned in &lt;a href="http://www.reddit.com/"&gt;Reddit&lt;/a&gt; and how RabbitMQ was a "&lt;i&gt;key&lt;/i&gt;" component in their architecture. I have a personal project I have been working on which I can disclose just yet, however I can't wait to start playing with more features from RabbitMQ client and server to implement some of my business requirements.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So far, I just finished installing it in MacOSX (using macports):&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; sudo port install rabbitmq-server&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And the install happened fairly fast. I'll try to post some of my findings as I go. Exciting times ahead!&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/4831432806087932521-5053986864382526720?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/5053986864382526720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=5053986864382526720' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/5053986864382526720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/5053986864382526720'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/05/my-thoughts-on-rabbitmq.html' title='My thoughts on RabbitMQ'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-1420062102487199506</id><published>2010-04-28T00:28:00.002-04:00</published><updated>2010-04-28T00:30:48.230-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Git'/><title type='text'>My Git Configuration</title><content type='html'>I have configured Git locally in many places now and I thought of placing a copy of my personal choice (my &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.gitconfig&lt;/span&gt;&lt;/span&gt; file). &amp;nbsp;Perhaps this will help me setup my personal environment everywhere I'm using it. I should put this on &lt;a href="https://github.com/"&gt;github&lt;/a&gt; at some point. A few things to notice:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;I prefer &lt;a href="http://www.perforce.com/perforce/products/merge.html"&gt;p4merge&lt;/a&gt; for merge tool. It's simply awesome, worth to try if you haven't yet.&lt;/li&gt;&lt;li&gt;Vim as my editor. Yes, I don't use emacs.&lt;/li&gt;&lt;li&gt;Yes, I code on a Mac!&lt;/li&gt;&lt;/ol&gt;My &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.gitconfig&lt;/span&gt;&lt;/span&gt; as follows:&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[user]&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;name = Alberto A. Flores&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;email = aaflores@gmail.com&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[core]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;editor = vim&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[mergetool "p4merge"]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cmd=/Applications/p4merge.app/Contents/Resources/launchp4merge "$PWD/$BASE" "$PWD/$REMOTE" "$PWD/$LOCAL" "$PWD/$MERGED"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;keepTemporaries = false&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;trustExitCode = false&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;keepBackup = false&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[color]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;status = auto&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;diff = auto&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;branch = auto&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[color "branch"]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;current = yellow reverse&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;local = yellow&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;remote = green&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[color "diff"]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;meta = yellow bold&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;frag = magenta bold&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;old = red bold&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;new = green bold&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[color "status"]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;added = yellow&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;changed = green&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;untracked = cyan&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[apply]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;whitespace = nowarn&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-1420062102487199506?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/1420062102487199506/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=1420062102487199506' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/1420062102487199506'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/1420062102487199506'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/04/my-git-config.html' title='My Git Configuration'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-6055502756015867875</id><published>2010-04-28T00:16:00.001-04:00</published><updated>2010-04-28T00:18:47.484-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Git'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring-Roo'/><title type='text'>Spring Roo: Persistence Setup</title><content type='html'>I've found Spring Roo to be a great way to learn how to setup configuration properly. &amp;nbsp;As I continue to spend time in configuring my home project, I continue to be amazed at the powerful features that &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Roo&lt;/span&gt; brings to the table. I had written a small application for tracking family chores. I spent about 25 minutes drawing the entities in a napkin, then spent 10 minutes writing a &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Roo&lt;/span&gt; script (file with extension "&lt;i&gt;roo&lt;/i&gt;"). Then, I opened a &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Roo&lt;/span&gt; shell and run "&lt;i&gt;script myscript.roo&lt;/i&gt;". This created my project, including all the scaffolding for my entities. &amp;nbsp;I had my project running in minutes. After a while, I detected a problem with my entities relationship and wanted to see the persisted data. Of course, I had the the "IN MEMORY" choice, which brought all sort of problems when trying to see the data within. &lt;br /&gt;&lt;div&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you have used&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Roo&lt;/span&gt; for a few minutes only (as it tends to encourage you, to due to its simplicity), you have probably used the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;HYPERSONIC_IN_MEMORY&lt;/span&gt; database configuration. This is good for a first prototype, however once you start adding data, you want to start using &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;HYPERSONIC_PERSISTENT&lt;/span&gt; or simply another available database as described with the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;--database&lt;/span&gt; parameters. &amp;nbsp;Roo makes this change a very pleasant experience. I chose &lt;i&gt;MYSQL&lt;/i&gt;&amp;nbsp;(since it was already installed). What a pleasant surprised that all I had to do was to write the following:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;persistence setup --provider HIBERNATE --database MYSQL --userName &lt;myuser&gt; --password &lt;mypassword&gt; --databaseName &lt;myproject&gt;&lt;/myproject&gt;&lt;/mypassword&gt;&lt;/myuser&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;At this point, all appropriate files were updated. Since I was using &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;git&lt;/span&gt; for version control, I was able to see the files updated. &amp;nbsp;Not only was the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;pom.xml&lt;/span&gt; updated, but also the database.properties touched with the new configuration for the jdbc connection. I also noticed that the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;persistence.xml&lt;/span&gt; file was changed from "&lt;i&gt;update&lt;/i&gt;" to "&lt;i&gt;create&lt;/i&gt;" (I have to change this back to "&lt;i&gt;update&lt;/i&gt;" if I want to continue seeing my data after reloads). This was nice as it makes sense to create the schema when it doesn't exist. I opened &lt;a href="http://www.dbvis.com/"&gt;DbVisualizer&lt;/a&gt;&amp;nbsp;and was happily browsing my newly created tables without problems.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In a few words: &lt;i&gt;Bravo Roo!&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-6055502756015867875?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/6055502756015867875/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=6055502756015867875' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/6055502756015867875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/6055502756015867875'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/04/spring-roo-persistence-setup.html' title='Spring Roo: Persistence Setup'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-6362619480078662280</id><published>2010-04-02T00:15:00.001-04:00</published><updated>2010-04-02T00:16:26.978-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Flexmojos'/><category scheme='http://www.blogger.com/atom/ns#' term='Maven'/><category scheme='http://www.blogger.com/atom/ns#' term='Flex'/><title type='text'>Mavenizing a Flex Project with multiple artifacts</title><content type='html'>&amp;nbsp;&amp;nbsp;I was asked to include a Flex project within the current build process in place (maven2 based). Now, I like maven for many reasons which I'm not going to explain in this entry, however I would like to say a bit about my experience with such a "&lt;i&gt;mavenization&lt;/i&gt;" if you will. Most Flex projects I've been involved are developed either directly in Flex Builder (Fb3) and/or compile using an Ant task. Nothing wrong with this approach, however Maven encourages a convention that may not necessarily be embraced in a traditional Flex Application. I hope to explain what I mean by this in the next paragraphs.&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;In Flex, a project typically is composed of a default application (an MXML file) and possibly &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Module&lt;/span&gt; components, stylesheets (compiled to SWF files), configuration files, etc. If some of these are within the same project, Fb3 will compile each of them and generate their SWF files properly. The "export" release feature of Fb3 is also a nice feature to do deployments from the IDE. Granted, this feature is nice to have, however following the "&lt;i&gt;maven way&lt;/i&gt;", I quickly realized that this "&lt;i&gt;mavenization&lt;/i&gt;" process will take longer. This was mostly due to the convention that each maven project aims to build ONE artifact and only one. The project I had was building 15 SWF files (some modules, some css files) as well as 17 XML files. This was simply not acceptable for maven standards.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;As a first pass, I decided to make the project generate a zip file containing each artifact. This would at least ensure one artifact for this project and ensure users to have a corresponding unzip process where each SWF/XML file can be used in a deployment. &amp;nbsp;Now, the next iteration, I moved from a one maven project style (zip file) to a multiple project (nested) style where each module compiles to and becomes a dependency of the main application project (yet another SWF file). &amp;nbsp;All this setup was nicely done using &lt;span class="Apple-style-span" style="font-family: inherit;"&gt;Flexmojos&lt;/span&gt; integration with Maven. Flexmojos is a nice tool for using Flex within a maven setup, however it has bugs of it own (e.g. depending on the packaging style, Flexmojos may do weird things such as compile Modules to non-swf extensions, or compiling flex code twice, etc). When properly configured, using Flexmojos can be a pleasant experience for most maven setup.&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-6362619480078662280?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/6362619480078662280/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=6362619480078662280' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/6362619480078662280'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/6362619480078662280'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/04/mavenizing-flex-project-with-multiple.html' title='Mavenizing a Flex Project with multiple artifacts'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-8482106087431311401</id><published>2010-03-25T00:54:00.001-04:00</published><updated>2010-03-25T21:46:37.242-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Flex'/><category scheme='http://www.blogger.com/atom/ns#' term='Efflex'/><title type='text'>My Journey into using efflex</title><content type='html'>As I tried to introduce powerful animations to personal RIA project, I came across this project called &lt;a href="http://www.efflex.org/"&gt;Efflex&lt;/a&gt;. The&amp;nbsp;&lt;a href="http://www.efflex.org/EfflexExplorer.html"&gt;demos&lt;/a&gt;&amp;nbsp;showed a lot of potential. I was very impressed with some of the nice features to improve &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ViewStack&lt;/span&gt; selection (particularly the Flip3D and Cube3D demos). As my excitement drove me to use it, I found so many problems integrating to it, particularly with the following:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;There were no SWC files to use (the 2 provided never worked).&amp;nbsp;&lt;/li&gt;&lt;li&gt;Building the source required FlexBuilder as well as to understand the project layout.&lt;/li&gt;&lt;li&gt;Some of the code was not committed, hence the compilation failed in so many ways.&lt;/li&gt;&lt;li&gt;There were dependencies that were not documented.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;I took this as a personal challenge and I can happily report that I made it work. I'd like to describe what I had to do to make it happen in case others go through this problem (as I suspect it's the case based on some of the postings I read on the site).&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;As of the writing of this entry, all what I'm about to describe remains true. I have found some postings with instructions for a old revision of the efflex project. Things have changed a bit, particularly with flex4 and Fb4 (now out). For the purposes of this writing, it's important to point out that all these problems occurred in trying to use the&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;CubeAway3&lt;span class="Apple-style-span" style="font-family: Times;"&gt;&amp;nbsp;effect.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Attempt 1&lt;/b&gt;: I tried the obvious: using the SWC files found on their site. Of course, this didn't work at first. &amp;nbsp;I was trying to use the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;CubeAway3D&lt;/span&gt; effect. &amp;nbsp;Fb3 kept on reporting compilation errors (primarily on a missing type). &amp;nbsp;As Tink (the author of the library) suggested to use the source code and build it yourself (post found in the &lt;i&gt;efflex&lt;/i&gt; site), I tried checking out the source code and importing it into Fb3.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Attempt 2&lt;/b&gt;: The import was somewhat troublesome as the source code (from svn) was not complete. I mean, there were missing classes (apparently never committed). Also, I found some classes that required some dependencies that were not documented anywhere. These were &lt;i&gt;away3d&lt;/i&gt;, &lt;i&gt;papervision3d&lt;/i&gt; and &lt;i&gt;tink&lt;/i&gt; (the last one was simply a utility project).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Attempt 3&lt;/b&gt;: I imported the source code of &lt;i&gt;away3d&lt;/i&gt;. This didn't take much time to fix, other than to ensure that I was compiling for flash player 10. Once that was fixed, I generated a SWC. &amp;nbsp;Success!&lt;br /&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;Attempt 4&lt;/b&gt;: I imported the source code of &lt;i&gt;papervision3d&lt;/i&gt;. &amp;nbsp;Luckily this didn't cause much problem either. It was pretty straight forwar, however any documentation on this would have helped (in lieu of a SWC).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Attempt 5&lt;/b&gt;: I checked out the source code for &lt;i&gt;tink&lt;/i&gt;. This was apparently another utility project developed by the author of &lt;i&gt;efflex&lt;/i&gt;. &amp;nbsp;Fine, I accepted his philosophy, so I moved on. Luckily it compiled fine.&lt;br /&gt;&lt;br /&gt;After doing all these, I decided to remove the non compiling classes (from the &lt;i&gt;efflex&lt;/i&gt; project). I decided that as I checked this out from svn, I can recover them later (when their needed classes are committed). This helped compile and generate a SWC file which I was now able to use. &amp;nbsp;As I tried it, my &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;CubeAway3D&lt;/span&gt; effect worked like a charm. It was very rewarding to see my ViewStack more vividly, nonetheless, I think we need to evaluate better how we can improve some of these projects.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-8482106087431311401?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/8482106087431311401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=8482106087431311401' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/8482106087431311401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/8482106087431311401'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/03/my-journey-into-using-efflex.html' title='My Journey into using efflex'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-6905480649101997121</id><published>2010-03-23T12:02:00.000-04:00</published><updated>2010-03-23T12:02:34.893-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Flex'/><title type='text'>Alternate Tooltip for &lt;mx:List /&gt; items</title><content type='html'>I spent sometime trying to understand ways to add tooltips for items within a &amp;lt;mx:List ..&amp;gt; component. As I naively used the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;dataTipFunction()&lt;/span&gt;, it was pretty evident (at least in my case) that I needed something whereby I can have more control, a more robust solution than the out-of-the-box solution. This is when I decided to use the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;itemRollOver&lt;/span&gt; and &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;itemRollOut&lt;/span&gt; events and corresponding handlers.&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;According to the Flex 3.5 SDK, the List control:&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px;"&gt;".&lt;i&gt;..displays a vertical list of items. Its functionality is very similar to that of the SELECT form element in HTML...&lt;/i&gt;"&lt;/span&gt;&amp;nbsp;&lt;/blockquote&gt;As with most things in Flex,&amp;nbsp;the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;List&lt;/span&gt; control extends a base class where a lot of functionality is already defined. In this case, it's the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ListBase&lt;/span&gt; control. This control, has a property that can point to a &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Function&lt;/span&gt;. This is the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;dataTipFunction()&lt;/span&gt; which enables the tooltip feature of each item in the list. The fundamental problem with this approach is that the generated &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;IToolTip&lt;/span&gt; containing the text can not be properly manipulated (say to modify it's location, color, rendering component, etc). In my particular case, I went for a different approach.&lt;br /&gt;&lt;br /&gt;Instead, I used the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;itemRollOver &lt;/span&gt;and &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;itemRollOut &lt;/span&gt;events to properly operate on a customed &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;IToolTip&lt;/span&gt;. Using the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ToolTipManager.createToolTip()&lt;/span&gt; I was able to not only create my custom tool tip, but also put a position to it so it will not block what I'm mousing over. &amp;nbsp;Now, yes, this was more work as I had to manage the livecycle of the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;IToolTip &lt;/span&gt;instance (only a few lines of code), but I was able to do so much with it (e.g. delay the showing of the tooltip).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-6905480649101997121?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/6905480649101997121/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=6905480649101997121' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/6905480649101997121'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/6905480649101997121'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/03/alternate-tooltip-for-items.html' title='Alternate Tooltip for &amp;lt;mx:List /&amp;gt; items'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-6886500197476911802</id><published>2010-03-13T23:25:00.000-05:00</published><updated>2010-03-13T23:25:06.908-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring-Roo'/><title type='text'>My Review on Spring-Roo</title><content type='html'>So I gave a presentation about Spring Roo recently. Hopefully this means I'll get a kangaroo. &amp;nbsp;I felt it went pretty well. I decided to share some of my remarks as I think I learned more by presenting than by trying it. As I can not put a presentation on my document (yet), I'll show the text of my slides and will explain some of the things I discussed while presenting.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;b&gt;Describing Roo&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Rapid Prototype tool for the Java Platform.&lt;/li&gt;&lt;li&gt;Non-Invasive approach to development.&lt;/li&gt;&lt;li&gt;Proper use of open source frameworks.&lt;/li&gt;&lt;li&gt;Handles Infrastructure configuration&lt;/li&gt;&lt;li&gt;Intelligent Code Generator (Active vs. Passive Generators)&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;I basically defined Roo as a tool that can help you learn (if you are new), refresh (if you are Spring savvy), or simply complement your current skills. &amp;nbsp;Although Spring has made a tremendous job in keeping us away from traditional J2EE development (EJB, xDoclet, Ant, etc), managing Spring configuration is extremely easy with Roo. No need to understand a complete Transaction Strategy in the beginning. No need to understand how to setup i18n configuration, nor how to setup a JPA provider. I also took time to explain about Roo's powerful shell and how it synchronizes with changes you can make with the IDE (managed asset).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;b&gt;Installing Roo&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;JDK 5.0 or greater&lt;/li&gt;&lt;li&gt;Maven 2.0.9 or greater&lt;/li&gt;&lt;li&gt;Spring Roo Binaries&lt;/li&gt;&lt;/ul&gt;In this slide (very short) I essentially emphasized how wonderful I managed to work with Roo at home in a machine where I didn't have admin privileges. This opened some eyes as I sensed some of my audience had the same problem. Furthermore, the idea of the shell was very compelling to some folks. Also, I noticed that hitting the "Tab" for hints was a nice feature to have. I could immediately tell most of the folks in attendance would prefer command prompt whenever possible.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Roo Concepts&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Under the covers, Roo uses AspectJ and Java&lt;/li&gt;&lt;li&gt;Changes are done at the byte-code level&lt;/li&gt;&lt;li&gt;Strong use of Inter-Type Declarations (ITD)&lt;/li&gt;&lt;li&gt;Leverage the power of Privileged Aspects&lt;/li&gt;&lt;li&gt;Annotations are defined with Source-Only Retention Policy&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;I felt that this is where I spent most of my time (aside from the Demo I gave). I explained the concept of ITD as it was fairly new to some of the audience. Also, I had to explained a bit about Privileged Aspects. I had sensed (from the previous presenter) that the audience was not well versed in AspectJ (nor AOP), so I took my time here to help the audience understand that a "cross-cutting" concern does not necessarily apply to business logic. It was a good discussion. After answering some of the questions I had, I turned to build an application which some of us have been talking about building, of course this time it was a lot faster.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Value Proposition&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;No vendor Lock-In&lt;/li&gt;&lt;li&gt;Zero performance/memory overhead&lt;/li&gt;&lt;li&gt;Zero deployment footprint&lt;/li&gt;&lt;li&gt;Consistent applications across teams&lt;/li&gt;&lt;li&gt;Leverages investment in the Java Ecosystem&lt;/li&gt;&lt;li&gt;Small learning curve, great to learn proper usage of Spring.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;I felt I needed to present why is the "Roo" proposition a good one. As a convert to Roo, I liked the lack of vendor lock-in. I also appreciate the great "use-case" for AspectJ in the context of this tool. It makes complete sense. I also stressed the point of how to help "entry" level Engineers to learn powerful concepts which could take days to read on their own.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Further Topics&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Dynamic Finders&lt;/li&gt;&lt;li&gt;Integration with JMS and Email&lt;/li&gt;&lt;li&gt;Integration with Webflow&lt;/li&gt;&lt;li&gt;Integration with Spring Security&lt;/li&gt;&lt;li&gt;Custom Add-on's&lt;/li&gt;&lt;li&gt;Roo Architecture Patterns&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;As my presentation took longer than anticipated, I didn't have the chance to discuss these, however I had purposely left it in case I would have finished early. I suggested a future discussion of this topics, particularly about "Dynamic Finders" and some of the architectural choices which Roo encourages (e.g. No DAOs, Optional Service Layers, etc).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I sensed good feedback, and once again I learned the obvious: One learns more by sharing than by reading.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-6886500197476911802?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/6886500197476911802/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=6886500197476911802' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/6886500197476911802'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/6886500197476911802'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/03/my-review-on-spring-roo.html' title='My Review on Spring-Roo'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-3164637021092637167</id><published>2010-03-11T22:34:00.000-05:00</published><updated>2010-03-11T22:34:48.991-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Swiz'/><category scheme='http://www.blogger.com/atom/ns#' term='Reflex'/><category scheme='http://www.blogger.com/atom/ns#' term='Robotlegs'/><category scheme='http://www.blogger.com/atom/ns#' term='Flex'/><title type='text'>Lessons learned at 360Flex</title><content type='html'>It's time to reflect a bit about the latest 360Flex. This was a good time to learn about Hardware integration with the Flash Platform. Here we have integration with Arduino boards (via &lt;a href="http://code.google.com/p/as3glue/"&gt;as3glue&lt;/a&gt;&amp;nbsp;or &lt;a href="http://www.merapiproject.net/"&gt;merapi&lt;/a&gt;). &amp;nbsp;Also, I learned a bit about JComm as well as how these sensors can send &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Event&lt;/span&gt;&amp;nbsp;objects whereby one can react and listen (think credit card readers, robots, etc). Nice possibilities that make so much sense for thick client applications using Adobe Air... Very exciting.&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;I also learned about &lt;b&gt;Reflex&lt;/b&gt;, a new open source project aimed at building lightweight components for the Flash Platform. &amp;nbsp;Unlike Flex, &lt;b&gt;Reflex&lt;/b&gt; components do not extend &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;UIComponent&lt;/span&gt;, thus allowing components to have less clutter. &amp;nbsp;Most of these is achieved by virtue of Sprite objects This means that custom UI components simply do what they need to do without all the properties (that are hardly used yet consume space in the Flash Virtual Machine when loaded). &amp;nbsp;With the much heated debate between HTML5 and Flash, it is certainly possible that &lt;b&gt;Reflex&lt;/b&gt; can make companies in the mobile device industry (e.g. Apple) believers in the Flash Platform (again) since lightweight components really means less SWF file sizes and, potentially, less energy consumption. Very compelling value proposition!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I also learned about the Swiz Framework, Robotlegs and the Mate framework. So far, I had a chance to play with Swiz and I'm liking it very much. I've been suggested to also try Robotlegs, so I'll give it a try in the next few weeks. &amp;nbsp;Very cool days coming ahead for me. Can't wait to try these!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Last, but not least, I was very impressed by some of the changes in Flex 4 (that is not Spark). I heard a presentation from Deepa Sabramanian (now a Product Manager of the Flex sdk) presenting these changes. I was very happy to see some of the compiler optimization, the Text Engine framework as well as some of the integration with Pixel Bender. Very nice demo showing possibilities. Very exciting!&lt;br /&gt;&lt;br /&gt;In summary, I'm looking forward to experiment with the some of the frameworks shortly.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-3164637021092637167?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/3164637021092637167/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=3164637021092637167' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/3164637021092637167'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/3164637021092637167'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/03/lessons-learned-at-360flex.html' title='Lessons learned at 360Flex'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-3038968322607348165</id><published>2010-03-10T15:23:00.001-05:00</published><updated>2010-03-10T15:55:49.862-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Reflex'/><category scheme='http://www.blogger.com/atom/ns#' term='Flex'/><title type='text'>Monkey Patching in Flex</title><content type='html'>I recently attended 360Flex. It was an excellent conference. I thought I knew some Flex, but I was certainly not aware of how much others are doing with Flex, Actionscript and the Flash Platform in general. Very interesting concepts. One of the nice concepts I recently learned while at San Jose was "&lt;i&gt;Monkey-Patching&lt;/i&gt;". &amp;nbsp;Fortunately, I had the chance to practice how to use it after the conference and learned so much about the internals of some Flex components. &amp;nbsp;Here is what I did.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;First, let me explain the obvious. "&lt;i&gt;Monkey-Patching&lt;/i&gt;" is the concept where one can extend or modify runtime code (&lt;span class="Apple-style-span" style="font-size: small;"&gt;for a further explanation, please refer to &lt;/span&gt;&lt;a href="http://en.wikipedia.org/wiki/Monkey_patch"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;wikipedia&lt;/span&gt;&lt;/a&gt;). In this case, we are leveraging the dynamic nature of the ActionScript so as to learn some of the internal operations that occur in the Flash Platform, particularly as pertaining to our Flex code.&lt;br /&gt;&lt;br /&gt;As I've been working on Module loading using the ModuleManager class, I decided to try to "&lt;i&gt;Monkey-Patch&lt;/i&gt;" the ModuleManager.as found in the mx.modules folder. I quickly learned more than I knew about the code. &amp;nbsp;I decided to add &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;trace()&lt;/span&gt; calls before each method. Then my code revealed a lot nice goodies about the Module loading mechanism provided. I won't deprive you from the thrill of looking for these, but enough to say that there's some caching (internal) that happens should you try to load the same module twice. &amp;nbsp;Needless to say, I was very excited to see what else can I do with this.&lt;br /&gt;&lt;br /&gt;Among other things worth mentioning (where I heard the term&amp;nbsp;&amp;nbsp;"&lt;i&gt;Monkey-Patch&lt;/i&gt;"), I learned about this project &lt;b&gt;Reflex&lt;/b&gt;. It's a framework that it's all about using the Flash Platform (not flex). It's an action-script framework that is meant to reduce the overhead generated (or introduced) with Flex and make component&amp;nbsp;lightweight, thus making faster downloads of SWF files, possibly reducing power energy (so essential in this mobile revolution), etc. The possibilities are endless. I'm very excited to see where this project goes and will try to watch it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-3038968322607348165?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/3038968322607348165/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=3038968322607348165' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/3038968322607348165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/3038968322607348165'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/03/monkey-patching-in-flex.html' title='Monkey Patching in Flex'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-6418206721564568578</id><published>2010-02-16T22:11:00.010-05:00</published><updated>2010-02-16T22:18:02.137-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AspectJ'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><category scheme='http://www.blogger.com/atom/ns#' term='AOP'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring-Roo'/><title type='text'>Understading some of Roo's magic</title><content type='html'>&amp;nbsp; I must admit that I was among the many developers I know who are very skeptical about Aspect Oriented Programming (AOP).&amp;nbsp; I've written many aspects myself, some which I now define as "&lt;i&gt;entry-level&lt;/i&gt;".&amp;nbsp; I had not seen a clear &lt;i&gt;use-case&lt;/i&gt; for aspects other than the basic "&lt;i&gt;auditing&lt;/i&gt;", "&lt;i&gt;logging&lt;/i&gt;" or "&lt;i&gt;security&lt;/i&gt;" use cases.&amp;nbsp; So, a few months ago I started to play with one of the latest tools from SpringSource, namely &lt;i&gt;Spring-Roo&lt;/i&gt;. To my surprise, &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Roo&lt;/span&gt; was not only meeting my expectations, but also made me a believer on yet another good use case for AOP.&amp;nbsp; The use case of tooling support.&amp;nbsp; I'll try to explain some of the magic which &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Roo&lt;/span&gt; brings to software development using AspectJ.&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;Consider for a moment the following entity:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: java"&gt;public class MyPojo {&lt;br /&gt;  private String name;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This entity can easily be coded using any IDE, however &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Roo&lt;/span&gt; allows you to create it with a command line shell. Once this is done, the average developer will rely on source generation features (from an IDE) to generate Setter/Getters (so as to conform with standard JavaBean conventions). This is where the concept of &lt;i&gt;Inter-Type Declarations &lt;/i&gt;(&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ITD&lt;/span&gt;) in AspectJ can be of great help.&amp;nbsp; Consider the following aspect:&lt;br /&gt;&lt;pre class="brush: java"&gt;public aspect MyPojo_Entity {&lt;br /&gt;  private Long id;&lt;br /&gt;  private static int sequence = 0;&lt;br /&gt;  &lt;br /&gt;  /** &lt;br /&gt;   * Constructor with arguments&lt;br /&gt;   */&lt;br /&gt;  public MyPojo.new(String name) {&lt;br /&gt;    super();&lt;br /&gt;    id = new Long(sequence++);&lt;br /&gt;  }&lt;br /&gt;   &lt;br /&gt;  /**&lt;br /&gt;   * ToString method.&lt;br /&gt;   */&lt;br /&gt;  public String MyPojo.toString() {&lt;br /&gt;    return "Sequence: " + id;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can see that this aspect is now introducing&amp;nbsp; a new constructor as well as a &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;toString()&lt;/span&gt; method for the entity &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;MyPojo&lt;/span&gt;. The resulting bytecode will now have a &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;toString()&lt;/span&gt; method which can be called anywhere. Also, it will enforce the constructor to be called with an argument. This notion of &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ITD&lt;/span&gt; can be used to introduce new methods as well as private properties. Now, let's finish this aspect:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: java"&gt;public privileged aspect MyPojo_Entity {&lt;br /&gt;  private Long MyPojo.id; &lt;br /&gt;  private static int sequence = 0;&lt;br /&gt;&lt;br /&gt;  /**&lt;br /&gt;   * Constructor&lt;br /&gt;   */ &lt;br /&gt;  public MyPojo.new(String name) {&lt;br /&gt;    super();&lt;br /&gt;    this.name = name;&lt;br /&gt;    this.id = new Long(sequence++);&lt;br /&gt;  }&lt;br /&gt; &lt;br /&gt;  /**&lt;br /&gt;   * Retrieves the id of this pojo&lt;br /&gt;   */ &lt;br /&gt;  public Long MyPojo.getId() {&lt;br /&gt;    return id;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  /**&lt;br /&gt;   * Retrieves the name of this pojo&lt;br /&gt;   * @return the name of this pojo.&lt;br /&gt;   */ &lt;br /&gt;  public String MyPojo.getName() {&lt;br /&gt;    return this.name;&lt;br /&gt;  }&lt;br /&gt; &lt;br /&gt;  /**&lt;br /&gt;   * Sets the name of this pojo.&lt;br /&gt;   * @param name the name to set.&lt;br /&gt;   */ &lt;br /&gt;  public void MyPojo.setName(String name) {&lt;br /&gt;    this.name = name;&lt;br /&gt;  }&lt;br /&gt; &lt;br /&gt;  /**&lt;br /&gt;   * Default toString() method.&lt;br /&gt;   */ &lt;br /&gt;  public String MyPojo.toString() {&lt;br /&gt;    return "Pojo [id="+this.id+"]: " &lt;br /&gt;          + this.name;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;As you can see,&amp;nbsp; we not only introduced the methods needed to make &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;MyPojo&lt;/span&gt; compliant with JavaBean standards, but also added more attributes and methods (e.g. to help persisting it). Furthermore, if you look closer, the aspect definition now uses the &lt;b style="color: #660000;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;privileged&lt;/span&gt;&lt;/b&gt; keyword. A &lt;b style="color: #660000;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;privileged&lt;/span&gt;&lt;/b&gt; aspect basically grants access to private attributes and methods of the class in question, thus we can use the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;this.name&lt;/span&gt; for this purposes without problems.&lt;br /&gt;&lt;br /&gt;If you look at the generated code from &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Roo&lt;/span&gt;, this is exactly how &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Roo&lt;/span&gt; makes magic happen. In fact, &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Roo&lt;/span&gt; also injects an &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;EntityManager&lt;/span&gt; as well as &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;hashCode()&lt;/span&gt;, &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;equals()&lt;/span&gt;, as well as other methods based on the&lt;i&gt; cross-cutting&lt;/i&gt; concern. It's defitenetly worth checking out &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Roo&lt;/span&gt; for a good test-drive, not only of the tool, but how to use AspectJ effectively.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-6418206721564568578?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/6418206721564568578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=6418206721564568578' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/6418206721564568578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/6418206721564568578'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/02/understading-some-roos-magic.html' title='Understading some of Roo&apos;s magic'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-1134282238805675439</id><published>2010-02-11T11:41:00.002-05:00</published><updated>2010-02-11T11:44:23.157-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='STS'/><category scheme='http://www.blogger.com/atom/ns#' term='Eclipse'/><title type='text'>Removing Unused Workspaces from Eclipse</title><content type='html'>Workspaces in Eclipse is one of those features that are often unused or not used enough.&amp;nbsp; Personally, I find it extremely helpful to use them, particularly when working on different branches. There are times when you need/want to delete some of these workspaces from your workspace list. Here is how you can do this:&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;ol&gt;&lt;li&gt;Go to the Eclipse directory where you installed Eclipse (I'll refer to it as &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ECLIPSE_HOME&lt;/span&gt; from here on).&lt;/li&gt;&lt;li&gt;Open the file &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ECLIPSE_HOME/configuration/.settings/org.eclipse.ui.ide.prefs &lt;/span&gt;with your favorite editor (obviously not Eclipse).&lt;/li&gt;&lt;li&gt;The key &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;RECENT_WORKSPACES&lt;/span&gt; should have a comma separated list of all previous workspaces your IDE has used. Remove them as needed/wanted.&lt;/li&gt;&lt;/ol&gt;Needless to say, this should be done while Eclipse is not running. At this point, you can safely remove the directory where the workspace resided. BTW, these instructions work well on the SpringSource Tool Suite (STS).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-1134282238805675439?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/1134282238805675439/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=1134282238805675439' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/1134282238805675439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/1134282238805675439'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/02/removing-unused-workspaces-from-eclipse.html' title='Removing Unused Workspaces from Eclipse'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-3433638286793097077</id><published>2010-01-30T00:38:00.002-05:00</published><updated>2010-01-31T10:45:16.581-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spring-AOP'/><category scheme='http://www.blogger.com/atom/ns#' term='STS'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><category scheme='http://www.blogger.com/atom/ns#' term='AOP'/><title type='text'>Spring: @Autowired Constructors</title><content type='html'>Since the introduction of Spring 2.0, I have seen a trend where developers use the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Autowired&lt;/span&gt; annotation very often. I must admit, I like a combination of annotations with some XML declaration, however I'm still debating whether making a decision of using &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Autowired&lt;/span&gt; scales well in the long run. I would like to show how this feature can seem unintuitive.&amp;nbsp; Furthermore, even tools like SpringSource Tool Suite can get confused at times.&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;Consider the following two POJOs:&lt;br /&gt;&lt;pre class="brush: java"&gt;public class FirstPojo implements Pojo {&lt;br /&gt;  /**&lt;br /&gt;   * Default constructor, no argument&lt;br /&gt;   */&lt;br /&gt;  public FirstPojo() {&lt;br /&gt;  }&lt;br /&gt;  // Other methods and logic here&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class SecondPojo implements Pojo {&lt;br /&gt;  /**&lt;br /&gt;   * Default constructor, with one argument&lt;br /&gt;   */&lt;br /&gt;  @Autowired&lt;br /&gt;  public SecondPojo(Pojo firstPojo) {&lt;br /&gt;  }&lt;br /&gt;  // Other methods and logic here&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Notice that one contains a constructor which is annotated with &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Autowired.&lt;/span&gt; What this means is that you can potentially have the container define such a bean as follows:&lt;br /&gt;&lt;script class="brush: html" type="syntaxhighlighter"&gt;&lt;![CDATA[...&lt;bean id="pojo2"    class="SecondPojo"/&gt;...]]&gt;&lt;/script&gt;&lt;br /&gt;Can you see the problem there? Now our declared XML claims that the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;SecondPojo&lt;/span&gt; has a constructor with no parameters, even though we can clearly see that such is not the case. It's hard to explain the average user that such behavior is possible due to &lt;i&gt;Spring-AOP&lt;/i&gt; and how these kind of beans are really proxy objects.&amp;nbsp; When the container detects an &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Autowired&lt;/span&gt; constructor, the &lt;i&gt;Spring-AOP&lt;/i&gt; infrastructure ensures that such constructor exists (so as to execute whatever logic is within that constructor). Also note that all dependencies are also &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Required&lt;/span&gt; (as per the &lt;a href="http://static.springsource.org/spring/docs/2.5.6/api/org/springframework/beans/factory/annotation/Autowired.html"&gt;docs&lt;/a&gt;).&amp;nbsp; Furthermore, it looks like the &lt;i&gt;SpringSource Tool Suite&lt;/i&gt; (as of the writing of this entry) also has problems detecting this "feature" as normal behavior.&amp;nbsp; See JIRA issue &lt;a href="http://jira.springframework.org/browse/IDE-1042"&gt;IDE-1042&lt;/a&gt; for more information (looks like it's planned to be fixed on the soon to be 2.3.1 release).&lt;br /&gt;&lt;br /&gt;Now, my personal feeling is that this &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Autowired&lt;/span&gt; behavior is due to the mixing of declarative XML with annotations. Not necessarily a bad design from SpringSource, but simply a consequence of Spring's goal of helping with simplicity. &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Autowired&lt;/span&gt; is really simple to use, but without full understanding of what's really happening, it can be confusing in the long term, particularly when a project grows in the number of managed beans. A good strategy (mostly maintained through the discipline of code reviews) is to choose this &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Autowired&lt;/span&gt; constructors to also be detected with yet another annotation (e.g. &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Component&lt;/span&gt;, &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Service&lt;/span&gt;, &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Repository&lt;/span&gt;, etc).&amp;nbsp; If a bean already has an &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Autowired&lt;/span&gt; constructor, it only makes sense to continue annotating the class (at the class level of course) with one of these stereotypes annotations so as to make it very clear how this beans is to work and how it's dependencies be injected. Interestingly enough, &lt;i&gt;SpringSource Tool Suite&lt;/i&gt; seems to like this approach and can even graph it nicely.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-3433638286793097077?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/3433638286793097077/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=3433638286793097077' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/3433638286793097077'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/3433638286793097077'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/01/spring-autowired-constructors.html' title='Spring: @Autowired Constructors'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-4284141344028238653</id><published>2010-01-28T00:46:00.008-05:00</published><updated>2010-01-30T00:32:49.682-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JSR-303'/><category scheme='http://www.blogger.com/atom/ns#' term='Annotations'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring-MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>Spring 3.0 and &lt;mvc:annotation-driven /&gt;</title><content type='html'>I have used &lt;i&gt;Struts1&lt;/i&gt; and&lt;i&gt; Struts2&lt;/i&gt; extensively for years.&amp;nbsp; With that background, I can appreciate some of the things that &lt;i&gt;Spring-MVC&lt;/i&gt; brings to the table such as Dependency Injection, clean integration with Bean Validator (JSR-303), smooth Integration with different View Technologies, among others. Furthermore,&amp;nbsp; &lt;i&gt;Spring-MVC&lt;/i&gt; has been making improvements through out each release that has made it a more robust framework, including the latest REST support. Like every framework, there is always a "gotcha" in a feature and such is the case for &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;mvc:annotation-driven /&amp;gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;mvc:annotation-driven&gt;&lt;/mvc:annotation-driven&gt;&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;mvc:annotation-driven&gt;&lt;/mvc:annotation-driven&gt;&lt;/span&gt; &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;mvc:annotation-driven /&amp;gt;&lt;/span&gt; is a nice feature, however depending on how you are used to organize your &lt;i&gt;Spring-MVC&lt;/i&gt; files, it can prove to be confusing. I'll try to explain my findings as clear as I can.&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;As you know, &lt;i&gt;Spring-MVC&lt;/i&gt; will expect a&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; &amp;lt;&lt;servlet-name&gt;servlet-name&amp;gt;-servlet.xml&lt;/servlet-name&gt;&lt;/span&gt; Spring configuration in the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;WEB-INF&lt;/span&gt; (unless configured otherwise in &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;web.xml&lt;/span&gt;). If you also load an application context via Spring's &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;RequestContextListener&lt;/span&gt; (hereto known as the &lt;i&gt;root&lt;/i&gt; WebApplicationContext), the servlet XML (&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;WebApplicationContext&lt;/span&gt;) will &lt;i&gt;inherit&lt;/i&gt; the beans from the &lt;i&gt;root&lt;/i&gt; context.&amp;nbsp; Although this is a known fact, the problem comes when the servlet XML is not able to read any &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@RequestMapping&lt;/span&gt; metadata from beans (&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Controller&lt;/span&gt; objects) detected in the &lt;i&gt;root&lt;/i&gt; WebApplication Context. The logs clearly show that the beans are detected, but not the metadata.&lt;br /&gt;&lt;br /&gt;This means that in order to use &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;mvc:annotation-driven /&amp;gt;&lt;/span&gt; &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;mvc:annotation-driven&gt;&lt;/mvc:annotation-driven&gt;&lt;/span&gt; you have two choices:&lt;br /&gt;&lt;ol&gt;&lt;li&gt; The servlet XML now needs to contain &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;mvc:annotation-driven /&amp;gt;&lt;/span&gt; &lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;mvc:annotation-driven&gt;&lt;/mvc:annotation-driven&gt;&lt;/span&gt; and&lt;/b&gt; be able to detect the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Controller&lt;/span&gt; objects so it can refer to the metadata in those controllers to use (e.g. via &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;context:component-scan /&amp;gt;&lt;/span&gt; &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;context:classpath-scan&gt;)&lt;/context:classpath-scan&gt;&lt;/span&gt;. All these within the same XML file or via imports.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The root XML needs to have the declarations as mentioned above (&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;mvc:annotation-driven /&amp;gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;mvc:annotation-driven&gt; &lt;/mvc:annotation-driven&gt;&lt;/span&gt;and&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; &lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;context:component-scan /&amp;gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;context:classpath-scan&gt;)&lt;/context:classpath-scan&gt;&lt;/span&gt;.&lt;/li&gt;&lt;/ol&gt;I prefer to use the first one, and make my &lt;i&gt;scan&lt;/i&gt; reach only the packages that are specific to the design of your servlet, however I can see how option 2 may be a more compelling option for small applications. Interestingly enough, that's how all sample applications using &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;mvc:annotation-driven /&amp;gt;&lt;/span&gt; &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;mvc:annotation-driven&gt;&lt;/mvc:annotation-driven&gt;&lt;/span&gt; are configured.&lt;br /&gt;&lt;br /&gt;For further reading of this new features, take a look at JIRA issue &lt;a href="http://jira.springframework.org/browse/SPR-6524"&gt;SPR-6524&lt;/a&gt; where Jurgen Hoeller and Keith Donald explain their thoughts on why &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;mvc:annotation-driven /&amp;gt;&lt;/span&gt; is supposed to behave like this.&lt;br /&gt;&lt;br /&gt;Hopefully this helps some!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-4284141344028238653?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/4284141344028238653/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=4284141344028238653' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/4284141344028238653'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/4284141344028238653'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/01/spring-30-and.html' title='Spring 3.0 and &amp;lt;mvc:annotation-driven /&amp;gt;'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-4556608971783024282</id><published>2010-01-26T11:15:00.001-05:00</published><updated>2010-01-26T11:16:44.999-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='STS'/><category scheme='http://www.blogger.com/atom/ns#' term='XSD'/><category scheme='http://www.blogger.com/atom/ns#' term='Eclipse'/><title type='text'>XML Validation within Eclipse</title><content type='html'>&amp;nbsp;&amp;nbsp;Working with XML can be a wonderful experience. Most people I know (in the industry) don't consider XSD/DTD validation a task that is challenging enough so as to spend time and/or effort to either learning it or writing to it. This feeling changes rapidly as tooling support (e.g. IDEs) produces hiccups when XML validation generates errors that can not be understood by the same engineering staff. &amp;nbsp;For example, have you ever had the infamous problem reported through Eclipse's console:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666; font-weight: bold; line-height: 14px;"&gt;&lt;span style="font-family: inherit;"&gt;cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'custom-filter'.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="line-height: 14px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;By default Eclipse has XML validation on. This means that it will look for a DTD of XSD to validate your XML file. The message above indicates that there's an XML element named &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;custom-filter&lt;/span&gt;&amp;nbsp;that can not be resolved with any of the XSD that Eclipse is aware within it's catalog registry.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;Now, most people I know turn off XML validation so as to not to deal with this problem. This is simply a terrible idea and bad practice. XSD definitions provide much richer ways to describe XML constructs, including comments. When the setup is properly configured, it can be a very handy tool (even for learning purposes). Craig Walls wrote a blog with instructions in how to add a new Catalog entry in Eclipse. The post can be found&amp;nbsp;&lt;a href="http://www.jroller.com/habuma/entry/fixing_spring_modules_xsd_errors"&gt;here&lt;/a&gt;.&amp;nbsp;&amp;nbsp;Note that you may find the same problem if you have an older version of Spring Source Tool Suite (STS) and are upgrading via the update site. &amp;nbsp;The way I dealt with this is typically a full rebuild of my project so that STS (or Eclipse) can allow XML tooling to magically occur.&lt;br /&gt;&lt;br /&gt;Hope this helps!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-4556608971783024282?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/4556608971783024282/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=4556608971783024282' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/4556608971783024282'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/4556608971783024282'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/01/xml-validation-within-eclipse.html' title='XML Validation within Eclipse'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-1050350788086096121</id><published>2010-01-25T23:22:00.002-05:00</published><updated>2010-01-25T23:31:48.938-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JEE'/><category scheme='http://www.blogger.com/atom/ns#' term='STS'/><category scheme='http://www.blogger.com/atom/ns#' term='Eclipse'/><category scheme='http://www.blogger.com/atom/ns#' term='WTP'/><title type='text'>Dynamic Web Projects in Eclipse</title><content type='html'>As I fixed a maven war project to more effectively use the &lt;span style="font-family: inherit;"&gt;Web Tools Project &lt;/span&gt;(WTP), I realized I could share the configuration I used with the hope to help others get some light as needed.&amp;nbsp; I'll be assuming you are familiar with the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.classpath&lt;/span&gt; file as well as the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.project&lt;/span&gt; file (which Eclipse uses heavily) to setup the dynamic web project.&amp;nbsp; Furthermore, I'll assume you are familiar with the notion of a "&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;nature&lt;/span&gt;" within the Eclipse environment.&amp;nbsp; Lastly, I would like to refer readers to the official Eclipse &lt;a href="http://wiki.eclipse.org/The_Official_Eclipse_FAQs"&gt;FAQ&lt;/a&gt;.&amp;nbsp; In particular, I would like to refer you to the section where the sharing of the &lt;a href="http://wiki.eclipse.org/FAQ_What_is_the_advantage_of_sharing_the_project_file_in_a_repository%3F"&gt;.project&lt;/a&gt; and .&lt;a href="http://wiki.eclipse.org/FAQ_How_do_I_set_up_a_Java_project_to_share_in_a_repository%3F"&gt;classpath&lt;/a&gt; files in version control (e.g. subversion, git, etc) is considered a good practice. Note that these tips will also work with the Springsource Tool Suite (STS)&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;The first thing you need to worry about is to make sure you have all bundles installed from the Java Enterprise Update Site.&amp;nbsp; Notice that this is different that the standard Eclipse distribution. If you successfully installed it, you should have the ability to create a new "&lt;i&gt;Dynamic Web Project&lt;/i&gt;" from the new Project menu. Once that is in place and you created a new "&lt;i&gt;Dynamic Web Project&lt;/i&gt;" take a look at the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.classpath&lt;/span&gt; file. It has some entries of type "&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;classpathentry&lt;/span&gt;". It should look something like:&lt;br /&gt;&lt;script class="brush: xml" type="syntaxhighlighter"&gt;&lt;![CDATA[  ...  &lt;classpathentry kind="con"    path="org.eclipse.jst.j2ee.internal.web.container"/&gt;  &lt;classpathentry kind="con"    path="org.eclipse.jst.j2ee.internal.module.container"/&gt;  ...]]&gt;&lt;/script&gt;&lt;br /&gt;The kind of &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;classpathentry&lt;/span&gt; "&lt;i&gt;con&lt;/i&gt;" means "&lt;i&gt;classpath container&lt;/i&gt;". It's the way &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;WTP&lt;/span&gt; will resolve classpath entries as you deploy your &lt;i&gt;Dynamic Web Project &lt;/i&gt;via Eclipse. Now, take a look at your .&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;project&lt;/span&gt; file. It should look something like:&lt;br /&gt;&lt;script class="brush: xml" type="syntaxhighlighter"&gt;&lt;![CDATA[...&lt;buildcommand&gt;  &lt;name&gt;   org.eclipse.wst.common.project.facet.core.builder  &lt;/name&gt;  &lt;arguments&gt;&lt;/arguments&gt;&lt;/buildCommand&gt;...&lt;natures&gt;  ...  &lt;nature&gt;    org.eclipse.wst.common.project.facet.core.nature  &lt;/nature&gt;  ...&lt;/natures&gt;...]]&gt;&lt;/script&gt;&lt;br /&gt;There could be other &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;buildcommand&lt;/span&gt; entries or other &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;nature&lt;/span&gt; entries, however these are very important to have in order to enable all tooling support for a &lt;i&gt;"Dynamic Web Project"&lt;/i&gt;. Now, the one file that has some more information is found within the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.settings&lt;/span&gt; folder. This file is named &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;org.eclipse.wst.common.component&lt;/span&gt;. This file is very interesting. It shows how Eclipse (or STS) will deploy the project to the Server of your choice (e.g. Tomcat).  It should look something like: &lt;br /&gt;&lt;script class="brush: xml" type="syntaxhighlighter"&gt;&lt;![CDATA[&lt;project-modules id="moduleCoreId"     project-version="1.5.0"&gt;  &lt;wb-module deploy-name="myWebApp"&gt;    &lt;wb-resource deploy-path="/"             source-path="/src/main/webapp"/&gt;    &lt;wb-resource deploy-path="/WEB-INF/classes"            source-path="/src/main/java"/&gt;    &lt;wb-resource deploy-path="/WEB-INF/classes"             source-path="/src/main/resources"/&gt;    &lt;property name="context-root"             value="myCoolWebapp"/&gt;    &lt;property name="java-output-path"/&gt;  &lt;/wb-module&gt;&lt;/project-modules&gt;]]&gt;&lt;/script&gt;&lt;br /&gt;Hopefully, this file speaks for itself (as far as to understand how &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;WTP&lt;/span&gt; deploys this project as an "exploded" war).&amp;nbsp; Notice that I'm using a traditional maven directory structure for defining a webapp. As these files are in place, you should be able to execute the "&lt;i&gt;Run In Server&lt;/i&gt;" command (from the &lt;i&gt;"Run"&lt;/i&gt; menu) and, assuming you have a server configured, you should be able to see your web application running via Eclipse. Of course, this means you could not only "&lt;i&gt;Run&lt;/i&gt;" but also "&lt;i&gt;Debug&lt;/i&gt;" whereby all your breakpoints and other debugging tools would work seemlessly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-1050350788086096121?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/1050350788086096121/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=1050350788086096121' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/1050350788086096121'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/1050350788086096121'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/01/dynamic-web-projects-in-eclipse.html' title='Dynamic Web Projects in Eclipse'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-6253687809695720953</id><published>2010-01-20T20:00:00.001-05:00</published><updated>2010-01-20T20:01:19.256-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='jvisualvm'/><category scheme='http://www.blogger.com/atom/ns#' term='jps'/><title type='text'>Developing on Windows and jps</title><content type='html'>&amp;nbsp; In the last few months, I have been forced to develop using a Windows environment. I must admit I miss most of my linux/unix command prompt usage, among which is the "&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;jps&lt;/span&gt;" tool.&amp;nbsp; For those of you not familiar with it, &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;jps&lt;/span&gt; is a "process status" tool and is part of the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;jdk&lt;/span&gt;.&amp;nbsp;  According to the documentation, this is an unsupported tool and comes with no guarantee, however I've found it to be a simple tool that can come in handy in certain situations as the one I'm about to describe.&lt;br /&gt;&lt;br /&gt;&amp;nbsp; During my initial &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;maven&lt;/span&gt; build, the test phase was throwing exceptions due an incorrect configuration.&amp;nbsp; As I tried to delete the target directory, windows reported the folder was in use.&amp;nbsp; Cygwin's "&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ps&lt;/span&gt;" command didn't reveal much.&amp;nbsp; Window's "Task Manager" wasn't really saying much either.&amp;nbsp; This is where "&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;jps&lt;/span&gt;" brought light.&amp;nbsp; &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Jps&lt;/span&gt; reported the SurefireBoot.jar still hanging in there (apparently due to some unrelease resource). Unfortunately, the problem became even more serious as the reported PID was not that simple to &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;kill&lt;/span&gt; (using Cygwin's &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;kill&lt;/span&gt; command).&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; As I researched some more on this, I came accross the following &lt;a href="https://visualvm.dev.java.net/troubleshooting.html"&gt;post&lt;/a&gt; where the issue of the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;TMP&lt;/span&gt; environment variable fixed some problems. As soon as I did this (setting the environment variable), I was able to resolve my problem (in my case, it was an issue with proper security in the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;TMP&lt;/span&gt; folder and its subfolders). This was not a "&lt;i&gt;show-stopper",&lt;/i&gt; but certainly a nice to know as this &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;TMP&lt;/span&gt; folder is not only used with &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;jps&lt;/span&gt;, but also with &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;jvisualvm&lt;/span&gt;, another nice free tool from the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;jdk&lt;/span&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-6253687809695720953?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/6253687809695720953/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=6253687809695720953' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/6253687809695720953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/6253687809695720953'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2010/01/developing-on-windows-and-jps.html' title='Developing on Windows and jps'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-469547270357968556</id><published>2009-12-31T07:25:00.027-05:00</published><updated>2010-01-19T07:51:09.662-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Charts'/><category scheme='http://www.blogger.com/atom/ns#' term='Flex'/><title type='text'>Flex: DateTimeAxis and ColumnChart components</title><content type='html'>I love flex. It is a framework where you can do great things, however there are a number of "gotchas" as with every framework. Not necessarily a bad thing, so long as it is documented properly.  This is what I found when using the &lt;span style="font-style: italic; font-weight: bold;"&gt;ColumnChart&lt;/span&gt; component within the &lt;span style="font-style: italic;"&gt;data-visualization&lt;/span&gt; framework of flex in combination with the DateTimeAxis for the xField. I had an object using the following structure:&lt;br /&gt;&lt;pre class="brush: java"&gt;public class MyChartItem {&lt;br /&gt;    public var time:Number;&lt;br /&gt;    public var amount:int;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Notice that one of the properties represents the current time.  It's represented by a numeric field (&lt;span style="font-family: courier new;"&gt;Number&lt;/span&gt; type). This model should allow for an exact representations of time when serializing a remote object back to its counterpart in ActionScript. &lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt; Of course, I choose to use a &lt;span style="font-family: courier new;"&gt;DateTimeAxis&lt;/span&gt; to let me render this numeric "&lt;span style="font-family: courier new;"&gt;xField&lt;/span&gt;" within the &lt;span style="font-family: courier new;"&gt;ColumnSeries&lt;/span&gt;. It was configured like this:&lt;br /&gt;&lt;script class="brush: html" type="syntaxhighlighter"&gt;&lt;![CDATA[&lt;mx:DateTimeAxis dataUnits="milliseconds"                  labelUnits="seconds" /&gt;]]&gt;&lt;/script&gt;&lt;br /&gt;I wanted to display data every second however the time property would be in milliseconds (epoch time). My surprise was that as the bound &lt;span style="font-family: courier new;"&gt;dataProvider&lt;/span&gt; object was updated, no chart was being displayed. I struggled with this for some time until I placed the mouse over the graph. Flex was showing the data points summary of the chart, but no graph!&lt;br /&gt;&lt;br /&gt;Upon further research, I found this piece of documentation which brought a lot of light to my development. From the Flex documentation.&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;"Some series use the value of the dataUnits property to affect their rendering. Specifically, most columnar series (such as Column, Bar, Candlestick, and HLOC controls) use the value of dataUnits to determine how wide to render their columns. If, for example, the ColumnChart control's horizontal axis has its labels set to weeks and dataUnits set to days, the ColumnChart control renders each column at one-seventh the distance between labels."&lt;/span&gt; &lt;span style="font-size: 85%;"&gt;&lt;a href="http://livedocs.adobe.com/flex/3/html/help.html?content=charts_intro_7.html"&gt;(Flex Docs)&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Ah! So it was a problem with the way the flash player was computing how to render the chart control. In particular, flash was thinking that each Column in the chart should be of one-thousandth distance. So I continued looking and found the "&lt;span style="font-family: courier new;"&gt;dataInterval&lt;/span&gt;" property in the "&lt;span style="font-family: courier new;"&gt;DateTimeAxis&lt;/span&gt;" API:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;"&lt;span style="font-style: italic;"&gt;If, for example, the dataUnits property is set to "hours", and dataInterval property is set to 4, the chart assumes your data occurs every four hours. This affects how some series (such as ColumnSeries and CandlestickSeries) render their data. It also affects how labels are automatically chosen.&lt;/span&gt;" &lt;span style="font-size: 85%;"&gt;&lt;a href="http://www.adobe.com/livedocs/flex/3/langref/index.html?mx/charts/chartClasses/package-detail.html&amp;amp;mx/charts/chartClasses/class-list.html"&gt;(Flex API)&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;After setting my "&lt;span style="font-family: courier new;"&gt;dataInterval&lt;/span&gt;" to 1000, I was back in business and my graph displaying properly again.  Lesson learned: never boast that I know Flex.  I can only say I can use flex and have found some tricks to make User Interfaces look fun.&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-469547270357968556?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/469547270357968556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=469547270357968556' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/469547270357968556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/469547270357968556'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2009/12/flex-datetimeaxis-and-columnchart.html' title='Flex: DateTimeAxis and ColumnChart components'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-7224626138055420217</id><published>2008-10-27T12:27:00.005-04:00</published><updated>2010-01-07T08:53:57.190-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tiles2'/><category scheme='http://www.blogger.com/atom/ns#' term='Struts2'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>Tiles2 with Spring without Spring MVC</title><content type='html'>In the process of making my application OSGI enabled, I came to the conclusion that it would help me better to have Tiles2 to be managed by Spring. This is so as to have more control of the Tiles2 configuration instead of the configuration needed in web.xml. This is when I found the &lt;code&gt;TilesConfigurer&lt;/code&gt; class from Spring. Here is a snippet of for my configuration. &lt;br /&gt;&lt;script class="brush: html" type="syntaxhighlighter"&gt;&lt;![CDATA[&lt;bean id="tilesConfigurer"    class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"&gt;  &lt;property name="useMutableTilesContainer"            value="true"/&gt;  &lt;property name="definitionsFactoryClass"            value="myPackage.MyTileDefinitionsFactory"/&gt;  &lt;property name="preparerFactoryClass"           value="org.springframework.web.servlet.view.tiles2.SpringBeanPreparerFactory"/&gt;  &lt;property name="definitions"&gt;    &lt;list&gt;      &lt;value&gt;/WEB-INF/tiles/tiles.xml&lt;/value&gt;    &lt;/list&gt;;  &lt;/property&gt;&lt;/bean&gt;]]&gt;&lt;/script&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;Now, this means that web.xml no longer needs the Tiles2 listener but simply let Spring's Servlet configuration do the initializing for you. If you are using Spring MVC, this is already done, if you are not, you may need to use &lt;code&gt;RequestContextListener&lt;/code&gt; or the &lt;code&gt;ContextLoaderListener&lt;/code&gt; so that this &lt;code&gt;tilesConfigurer&lt;/code&gt; bean is placed in application scope similar to what the Tiles2 configurer does out of the box.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Warning&lt;/b&gt;: leaving the Tiles2 listener (along with the configuration above) will still try to load the tiles.xml from the default location (WEB-INF folder) so you may be overriding the work already done by Spring's &lt;code&gt;SpringBeanPreparerFactory&lt;/code&gt;. Take a look at the generated logs for further detail. Once you have this, now you have control (in Spring) over Tiles2. I wanted to add a custom &lt;code&gt;TilesDefinitionsFactory&lt;/code&gt; so I created my own as follows:&lt;br /&gt;&lt;pre class="brush: java"&gt;package myPackage.MyTileDefinitionsFactory;&lt;br /&gt;&lt;br /&gt;public class MyTileDefinitionsFactory extends UrlDefinitionsFactory {&lt;br /&gt;  public Definition getDefinition(String name, &lt;br /&gt;                     TilesRequestContext ctx)&lt;br /&gt;    throws DefinitionsFactoryException {&lt;br /&gt;    Definition tileDefinition = super.getDefinition(name, ctx);&lt;br /&gt;&lt;br /&gt;    // add you own logic to modify/update template and/or tile&lt;br /&gt;&lt;br /&gt;    return tileDefinition;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;With this new factory, now we were able to introduce custom menus, tabs, and other widgets to screens based on roles and/or other business ruls (e.g. workflows). Furthermore, we were even able to change the backing template (eventhough the Tiles2 documentation says you can not change the template of a tile dynamically, this did the trick). There are many other possibilities opened with this approach that I'm sure some will find useful.&lt;br /&gt;&lt;br /&gt;One more thing to keep in mind, you need to setup the property &lt;i&gt;useMutableTilesContainer&lt;/i&gt; to true so as to be able to great dynamic tiles.  As you read the Tiles API, you can potentially create your own tiles dynamically as well as simply modify existing ones. I found this approach to be a very powerful one when integrating Tiles2 with Struts2.&lt;br /&gt;&lt;br /&gt;Hope this helps!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-7224626138055420217?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/7224626138055420217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=7224626138055420217' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/7224626138055420217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/7224626138055420217'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2008/10/mixing-tiles2-with-spring.html' title='Tiles2 with Spring without Spring MVC'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-6951793317370516301</id><published>2008-10-09T10:30:00.010-04:00</published><updated>2010-01-07T08:54:52.204-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DAO'/><category scheme='http://www.blogger.com/atom/ns#' term='Generics'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate'/><title type='text'>Generics and DAOs</title><content type='html'>&lt;div align="justify"&gt;Since the coming of Hibernate 3, I have started to refactor a lot of code that I simply didn't need anymore. Among these, my data access objects have always seemed repetitive. Repetition (in my opinion) calls for code refactoring. The hibernate tools project aims at fixing this problem by providing a "Dao Code Generator" which can certainly help. Additionally, other tools out there offer similar solutions, however one must understand how much the JVM will have to use in working with our "dao-centric" application. Can we do better? &lt;br /&gt;&lt;br /&gt;With the introduction of Generics in Java 5, I found a good way to make good use of this generic approach to DAO's without breaking my application logic. Consider the following code:&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: java"&gt;package sample;&lt;br /&gt;&lt;br /&gt;public interface GenericDao&lt;br /&gt;&amp;lt;T, PK extends Serializable&amp;gt; {&lt;br /&gt;/**&lt;br /&gt;* Persists the new instance object into the&lt;br /&gt;* persistent store.&lt;br /&gt;* @param newInstance - the instance object&lt;br /&gt;* to persist.&lt;br /&gt;* @return the primary key of the T object.&lt;br /&gt;*/&lt;br /&gt;PK createEntity(T newInstance);&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Retrieve the an object that was previously&lt;br /&gt;* persisted to the persistent store using the&lt;br /&gt;* primary key passed in the parameter.&lt;br /&gt;* @param recnum - the primary key of the&lt;br /&gt;* persisted object.&lt;br /&gt;* @return the object instance.&lt;br /&gt;*/&lt;br /&gt;T getByRecnum(PK recnum);&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Deletes an entity from the persistent store.&lt;br /&gt;* Note that all cascades associated in the&lt;br /&gt;* persistent object (JPA) are applied. If&lt;br /&gt;* orphans are needed, you must brake the&lt;br /&gt;* association first before deleting this&lt;br /&gt;* entity.&lt;br /&gt;* @param recnum - the primary key of the&lt;br /&gt;* entry to delete.&lt;br /&gt;*/&lt;br /&gt;void deleteEntity(PK recnum);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This interface defines a generic contract for data access to an object of type &lt;span style="font-family:courier new;"&gt;T&lt;/span&gt; with a primary identifier (primary key, if you will) named &lt;span style="font-family:courier new;"&gt;PK&lt;/span&gt; that is of type &lt;span style="font-family:courier new;"&gt;Serializable&lt;/span&gt; (more on this on some other post). Now, consider the following hibernate implementation:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: java" code="foo"&gt;package sample; &lt;br /&gt;&lt;br /&gt;public class HibernateGenericDaoImpl&amp;lt;T, PK extends Serializable&amp;gt;&lt;br /&gt;      implements GenericDao&amp;lt;T, PK&amp;gt; {&lt;br /&gt;  private HibernateTemplate m_hTemplate;&lt;br /&gt;  private Class&amp;lt;t&amp;gt; m_type;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Default Constructor for this implementation.&lt;br /&gt;* @param type - the type of DAO to generate&lt;br /&gt;* @param hibernateTemplate - the template to&lt;br /&gt;* use.&lt;br /&gt;*/&lt;br /&gt;public HibernateGenericDaoImpl (Class&amp;lt;T&amp;gt; type,&lt;br /&gt;         HibernateTemplate hibernateTemplate) {&lt;br /&gt;  m_type = type;&lt;br /&gt;  m_hTemplate = hibernateTemplate;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* {@inheritDoc}&lt;br /&gt;*/&lt;br /&gt;@Override&lt;br /&gt;public PK createEntity(T newInstance) { &lt;br /&gt;  return (PK) m_hTemplate.save(newInstance);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* {@inheritDoc}&lt;br /&gt;*/&lt;br /&gt;@Override&lt;br /&gt;public T getByRecnum(PK recnum) { &lt;br /&gt;  return (T) m_hTemplate.get(m_type, recnum);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* {@inheritDoc}&lt;br /&gt;*/&lt;br /&gt;@Override&lt;br /&gt;public void deleteEntity(PK recnum) {&lt;br /&gt;  T entity = getByRecnum(recnum);&lt;br /&gt;  if (entity != null) {&lt;br /&gt;    m_hTemplate.delete(entity);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This implementation of the &lt;span style="font-family:courier new;"&gt;GenericDao&lt;/span&gt; contract uses Spring's &lt;span style="font-family:courier new;"&gt;HibernateTemplate&lt;/span&gt; which is a thin layer on top of Hibernate. It basically uses the template to perform operations on object model &lt;span style="font-family:courier new;"&gt;T&lt;/span&gt;.  Of course, you can add more generic methods as needed, but the idea is the same. Possibilities are endless.  Now, with the following Spring's configuration:&lt;br /&gt;&lt;script class="brush: html" type="syntaxhighlighter"&gt;&lt;![CDATA[&lt;beans&gt;  &lt;bean name="fooDao"        class="sample.HibernateGenericDaoImpl"&gt;    &lt;constructor-arg value="sample.Foo"/&gt;&lt;constructor-arg ref="hTemplate"/&gt;  &lt;/bean&gt;  &lt;bean name="barService" class="sample.BarService"&gt;    &lt;constructor-arg ref="fooDao"/&gt;  &lt;/bean&gt;&lt;/beans&gt;]]&gt;&lt;/script&gt;&lt;br /&gt;And the following service code: &lt;br /&gt;&lt;br /&gt;&lt;pre  class="brush: java"&gt;package sample;&lt;br /&gt;&lt;br /&gt;public class BarService {&lt;br /&gt;private GenericDao&amp;lt;Foo, Long&amp;gt; m_fooDao;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Default constructor with injected dao&lt;br /&gt;* @param fooDao - the dao to inject.&lt;br /&gt;*/&lt;br /&gt;public BarService(GenericDao&amp;lt;Foo, Long&amp;gt; fooDao) {&lt;br /&gt;m_fooDao = fooDao;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;This means that the Service code can now have an injected dao that is generic. With these generic approach to DAOs, you now avoid writing custom code for each model object (in our case, of type sample.Foo). Now, my strategy for ensuring that my application will not turn into a critical state was to make sure that all our unit-test passed after the code refactoring process had finished. My code coverage percentage certainly decreased as I removed custom implementations of unneded DAO and encourage the use of the generic Dao&lt;br /&gt;&lt;br /&gt;Keep in mind that Generics are supported in other languages as well, so this approach can certainly be re-used (if at all).&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/4831432806087932521-6951793317370516301?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/6951793317370516301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=6951793317370516301' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/6951793317370516301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/6951793317370516301'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2008/09/java-generics-and-dao-pattern.html' title='Generics and DAOs'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-5278779412984167373</id><published>2008-09-30T12:10:00.008-04:00</published><updated>2008-10-02T09:39:42.981-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Validator'/><category scheme='http://www.blogger.com/atom/ns#' term='Struts2'/><title type='text'>Struts 2 Validator on Forwards</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;As I had to add some complex features to our working Struts 2 application, I had to deal with already built in validator functionality in Struts2 that could be complex. Specifically, when dealing with conversations-like scenarios, this problem can really be a big one if the validation associated with the forward request is applied via annotations, xml or the validate method. I thought to share some snippets that hopefully will someone. Consider the following:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;package sample;&lt;br /&gt;&lt;br /&gt;public class MyValidatorInterceptor1 &lt;br /&gt;     extends AnnotationValidationInterceptor {&lt;br /&gt; /**&lt;br /&gt;  * Method that is triggered in prior to calling&lt;br /&gt;  * the intercept() method. This method allows&lt;br /&gt;  * to control whether the intercept is disabled&lt;br /&gt;  * in certain condition.&lt;br /&gt;  */&lt;br /&gt; @Override&lt;br /&gt; protected boolean applyInterceptor&lt;br /&gt;            (ActionInvocation invocation) {&lt;br /&gt;  boolean certainCondition = true&lt;br /&gt;  if (certainCondition) {&lt;br /&gt;    return false;&lt;br /&gt;  }&lt;br /&gt;  return super.applyInterceptor(invocation);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This interceptor implementation as described above enhances the provided &lt;code&gt;AnnotationValidationInterceptor&lt;/code&gt; from Struts 2 to disable the interceptor on demand (based on some condition). It's important to mention that the code above extends the class &lt;code&gt;AnnotationValidationInterceptor&lt;/code&gt; as base class so as to not take away current functionality offered in Struts 2 (validation annotation). Additionally, the &lt;code&gt;doIntercept()&lt;/code&gt; method may be overridable to perform additional validation that can be applied per class. Consider the scenario where you define your want to add validation complex validation per method and disable all required validations in XML. This certainly introduces many possibilities. Now, it will be worth to mention that struts.xml will need to have this as well to be useful.&lt;br /&gt;&lt;pre class="xml" name="code"&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;struts&amp;gt;&lt;br /&gt;  &amp;lt;interceptors&amp;gt;&lt;br /&gt;    &amp;lt;interceptor name="dynamicValidator"&lt;br /&gt;                    class="sample.MyValidatorInterceptor1"/&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;interceptor-stack name="myInteceptorStack"&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="exception"/&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="alias"/&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="params"/&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="servletConfig"/&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="prepare"/&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="i18n"/&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="chain"/&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="modelDriven"/&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="fileUpload"/&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="checkbox"/&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="staticParams"/&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="params"/&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="conversionError"/&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="dynamicValidator"&amp;gt;&lt;br /&gt;        &amp;lt;param name="excludeMethods"&amp;gt;&lt;br /&gt;          input,back,cancel&lt;br /&gt;        &amp;lt;/param&amp;gt;&lt;br /&gt;      &amp;lt;/interceptor-ref&amp;gt;&lt;br /&gt;      &amp;lt;interceptor-ref name="workflow"&amp;gt;&lt;br /&gt;        &amp;lt;param name="excludeMethods"&amp;gt;&lt;br /&gt;          input,back,cancel&lt;br /&gt;        &amp;lt;/param&amp;gt;&lt;br /&gt;      &amp;lt;/interceptor-ref&amp;gt;&lt;br /&gt;    &amp;lt;/interceptor-stack&amp;gt;&lt;br /&gt;  &amp;lt;/interceptors&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;default-interceptor-ref name="myInteceptorStack"/&amp;gt;&lt;br /&gt;&amp;lt;/struts&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Note that the configuration now uses almost all interceptors defined in the &lt;code&gt;paramsPrepareParamsStack&lt;/code&gt; except the validator one. This is one architectural part of Struts 2 which I find it very compelling. You can grab any part of the interceptors, swapped with your custom ones and provide meaningful processing according to your needs.&lt;br /&gt;&lt;br /&gt;Now, the validator code above deserves further explanation. Consider the case when an action forwards control (with the result type &lt;code&gt;redirect-action&lt;/code&gt;). The forwarder action may not necessarily know whether the forwarded action is really validated or not, and hence the validation process will still be applied. In such case, one may need to allow some processing to decline validation on the subsequent action handling (such as placing a token on request/session/valueStack for starters).&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-5278779412984167373?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/5278779412984167373/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=5278779412984167373' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/5278779412984167373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/5278779412984167373'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2008/08/struts-2-validator-on-forwards.html' title='Struts 2 Validator on Forwards'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-3575916792532970432</id><published>2008-09-26T12:15:00.001-04:00</published><updated>2008-09-26T12:25:16.681-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='Struts2'/><title type='text'>The Domain Model and Struts 2.x</title><content type='html'>A couple of months ago I had a new requirement where I had to display the look (ui) of only a few of my components in my Struts 2.x application. Specifically, I had to display some dates as date-time while others had to remain the same. I started to hold down for a minute and decided to think how best to tackle the problem. I hate to touch a lot of code for no reason and as many know, changing the domain model code is typically not a good idea.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Struts2 MVC and Converters&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In the good old days of Struts 1.x, one would have to register a special &lt;span style="font-family:courier new;"&gt;Converter&lt;/span&gt; object and register it so that &lt;span style="font-family:courier new;"&gt;BeanUtils&lt;/span&gt; can use it when ActionForms are populate via the ActionServlet (wao, I can't believe I had to learn all that). This was a good way to provide good conversion across all your application, however this approach forces the &lt;span style="font-family:courier new;"&gt;Converter&lt;/span&gt; to be applied in all objects of the same type.&lt;br /&gt;&lt;br /&gt;As an MVC implementation, the controller should be able to have a way to know what conversion process to use in each action mapping processing session. Struts 2.x provides a way to do this in a clean way with the use of the &lt;span style="font-family:courier new;"&gt;StrutsTypeConverter &lt;/span&gt;class. After creating your own converter class, you can register your converter globally (in a file that must be named &lt;em&gt;xwork-conversion.properties&lt;/em&gt;). Alternatively, you can create a &lt;em&gt;&lt;model&gt;-conversion.properties &lt;/em&gt;file at the same package level where your model object resides and now you can have custom conversion per property. The latter approach is a powerful feature as it allows you to define a properties file with key,value pair listings. Each key represents the name of the java property of the model object and its value is the fully qualified converter class name. This approach for conversion is very appealing for the following reasons:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Does not mix Struts2 code with Domain Object model code (not even annotations), thus offering a non-intrusive approach to the rendering of the object.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;It encourages a development environment where this file can be generated, overriden or even replaced at build time. This scenario is very appealing for companies that do customizations of a product thus encouraging a "configuration management" approach in the presentation tier.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;It allows you to provide a different converter per property, leaving the model type unchanged.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;I was able to successfully display each property as needed and progressively move each component that was required. &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-3575916792532970432?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/3575916792532970432/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=3575916792532970432' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/3575916792532970432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/3575916792532970432'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2008/09/domain-model-and-struts-2x.html' title='The Domain Model and Struts 2.x'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-1928986551564089482</id><published>2008-09-24T12:45:00.010-04:00</published><updated>2008-09-25T11:00:17.997-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='OSGI'/><category scheme='http://www.blogger.com/atom/ns#' term='Struts2'/><title type='text'>Powered by Struts 2.x</title><content type='html'>&lt;div align="justify"&gt;After working with Struts 2.x for some months now, I feel more comfortable in commenting on some of the features that I feel have been helping me as well as some others that I feel needs some attention. In writing these, I hope that I may be able to learn some from those who may wish to attempt correcting me. &lt;/div&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;Overall Configuration&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;The basic file needed is one named "struts.xml". Properties (constants) can be overridden using a struts.properties files. This file takes priority and this is an interesting approach and this seems to mixed well with Maven environments (as well as Ant, of course). You can modularize your application including files of the same type (same DTD) as struts.xml. The one thing I don't understand is the use of DTD over XSD. Not exactly sure why they haven't adopted XSD as the latter are simply more powerful.&lt;/div&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;Rendering Engine&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;The fact that you don't need to JSP for your views has been a significant change for me. I know that you can avoid using JSPs using Struts 1.x but the amount of code (and configuration) could be very tedious. With Struts 2.x support for Velocity and Freemarker are already built-in. I've been using the latter for sometime now and I simply love it. &lt;/div&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;Now, if you consider the &lt;em&gt;"hype" &lt;/em&gt;that OSGI is bringing to the JEE world, a templating engine technology (e.g. Velocity, Freemarker) over JSP technology is more appealing as this will allow OSGI environments to resolve proper templates based on the OSGI headers (within each jar). Struts 2.x comes with bundled with a set of predefined templates that the classloader picks from, thus encouraging this pattern (but not demanding it). I see this as a strategic architectural choice which ought to be observed when considering OSGI powered applications.&lt;/div&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;Servlet Technology and Controllers&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;Struts 2.x uses Servlet filters (instead of Servlets) as the driving force of the application. This can be good and bad for several reasons. I have found it to be good thus far. Filters can give you the feeling that "intercepting" a controller is simpler (filtering the request). Struts 2.x has default interceptors for different things such as those that parses the parameters and placed them into the value stack, double token submissions, etc. You can always implement your own.&lt;/div&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;You have a clear option of which interceptors to use and their ordering. This is a powerful feature that if misused can prove a big problem. I recently found a bug on the way I had configured our interceptors. You can do nesting of interceptors so I was repeating the same interceptor multiple times thus doubling my round-trips to the database. Implementing your own is very trivial. &lt;/div&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;Additionally, Struts 2.x advertise thread-safety POJOs as your actions (Struts 1.x should remember that this issue can make you rely heavily on request/session attributes). I have found that the nature of making this action objects thread-safe are by virtue of having a "request" scope. Since you have an option to use Spring for dependency injection, you configure/annotated your POJOs with scope "session" and block this behavior. I've found this a problem in some cases. I'm still investigating this issue, but does bring something to the table. You can effectively perform IoC in the way Action (controllers) are used as part of your MVC. &lt;/div&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;IDE Tooling - The good, the bad and the ugly!&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;As most fairly new frameworks tooling is what helps the adoption of a framework. Struts 2.x lacks this component very much as there are not that many IDEs with out-of-the-box support for Struts 2.x. As of the today, there are few who show some promise, none of which I would recommend investing (yet!). I am a fan of Eclipse, and I have to say that the WTP project works just fine with Struts 2.x and developing with it has been a breeze. Configuring struts 2.x within eclipse is somewhat trivial and I expect IDE plugins to simply help with XML editing. &lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;I have spent a lot of time reading the struts-core source code and I simply like it. I think its a good practice for any developer trying to understand the framework and I'm sure you'll find it very readable, well commented with few problems (although I'm sure there are some). Overall, my experience with Struts 2.x has been very pleasant and I have good reasons to recommend it as a choice for development of new enterprise applications.&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-1928986551564089482?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/1928986551564089482/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=1928986551564089482' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/1928986551564089482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/1928986551564089482'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2008/09/powered-by-struts-2x.html' title='Powered by Struts 2.x'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-3368558978734715147</id><published>2007-10-11T22:35:00.002-04:00</published><updated>2008-03-25T12:02:47.198-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Struts1'/><category scheme='http://www.blogger.com/atom/ns#' term='Struts2'/><title type='text'>Introduction to Struts 2.x</title><content type='html'>&lt;div class="snap_preview"&gt; &lt;p align="justify"&gt;&lt;span style="font-family: arial;"&gt;I finally had the chance to  work on a project using Struts 2.x. As I wrote code my code from scratch, I had  to admit that my background from Struts 1.x worked against me in some cases  where in others it helped understand basic concepts. All in all, I was very  pleased with my experience with Struts 2.x. Granted, documentation is still  under progress, however I found the email list to be a great tool to be informed  and to receive answers to my specific questions. Although I don’t think I can  possibly write about every feature I used in Struts 2.x, I can certainly write  an introduction for those who are either new to MVC or trying to move from  Struts 1.x to Struts 2.x&lt;/span&gt;&lt;span id="more-8"&gt;&lt;/span&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial;"&gt;Reasons to  Migrate&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family: arial;"&gt;First I need to emphasize that  unless you strictly have a good reason (and budget) to change your current MVC  architecture, then I would recommend to switch to it. The migration is not as  trivial and depending on what kind of code in your presentation view (JSP,  Velocity, Freemarker, JSTL, etc) your migration may or may not be that  transparent. One thing is for sure, Struts 2.x migration is not meant to be a  “&lt;em&gt;drop-in&lt;/em&gt;” replacement, so expect several gotchas as you move along.  Also, note that regardless of your background, Struts 2.x can also be an  appropriate MVC choice for a new application (depending on your needs, of  course). If your moving from Struts 1.x, know that both can coexist during your  migration, so you don’t need to break your existing code, however the process  can become very confusing and unless absolutely necessary would I recommend  it.&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family: arial;"&gt;No Struts 1.x is required to  start, in my opinion, however decent understanding of MVC (as with most  frameworks) is always a plus. You want to also understand EL expressions (and  now UEL as well). Understanding of additional concepts such as JEE Filters,  Dependency Injection, Servlet Specification are going to help to get you going  really fast, however note that if you have done any JSP work before, you’ll  learn that with the Value Stack (Struts 2.x), now you have to account for a new  “scope”. It’s not hard to understand or use, however one must understand where  the values are coming from.&lt;/span&gt;&lt;strong&gt;&lt;span style="font-family: arial;"&gt;  &lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial;"&gt;Using Struts 2.x&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family: arial;"&gt;At a minimum, you are going to  need the following jar files within your lib directory. These come as part of  the struts2 distribution:&lt;/span&gt;&lt;/p&gt; &lt;ol&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;struts-core-xxx.jar&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;xwork-xxx.jar&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;ognl-xxx.jar&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;freemarker-xxx.jar&lt;/span&gt; &lt;/li&gt;&lt;/ol&gt; &lt;p align="justify"&gt;&lt;span style="font-family: arial;"&gt;Of course there are other  libraries needed. These are dependencies to the struts 2 framework (e.g.  Collections, BeanUtils, Digester, etc). Although these are not part of the  Struts2 project, these are reusable components that are part of the Jakarta  Commons project. If you are not familiar with it, I highly recommend spending  time on them. All required jar files come as part of the distribution. Of course  if you are using maven, you don’t need to worry about any of these (maven places  all needed dependencies within the lib directory).&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family: arial;"&gt;Now you need to setup the  &lt;code&gt;org.apache.struts2.dispatcher.FilterDispatcher&lt;/code&gt; filter in web.xml.  This filter should go primarily mapped to all “/*” (web.xml filter mapping). Now  to your struts.xml file. This file &lt;strong&gt;needs&lt;/strong&gt; to be in your  classpath. Even if you try to put it somewhere else using a  &lt;code&gt;context-param&lt;/code&gt; in web.xml, other things will break. To be on the  safe side, just put it in your WEB-INF/classes directory. As for “struts.xml”,  I’m going to let you read some more on it in the official documentation since  it’s pretty self explanatory, however a good thing to know is that the concept  of “package” inheritance is widely used (similar to the one used in the tiles  framework). This hierarchy allows you to have pre-configured elements in your  configuration (e.g. validation, interceptors, etc) that are ready for you to use  (thus the convention over configuration). You can change, modify, reuse any  file. A good practice to learn is to checkout the source code and see how files  are read. Warning, the source code uses maven, so unless you are familiar with  how maven uses resources, this may be a bit unusual. Looking at the source code  has helped me tremendously in picking up Struts 2 fast.&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family: arial;"&gt;If you come from a Struts 1.x  background, you may want to be aware that type conversion is done for you  automatically. So there is no need to play around with custom converters  (registered in BeanUtils, or custom processing to process conversions), however  this conversion may/may not affect the way your validation occurs. This means  that errors detected in the conversion process are managed as “fieldErrors”  which in turn can be displayed using the appropriate tag. This may/may not be  the desired behavior, but it a much better approach to Struts 1.x where strong  typing properties in Form objects didn’t work well with certain validator types.  &lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family: arial;"&gt;I hope to write very soon a  lot more about specifics features within Struts2 as I find them, specially about  the migration process which I’m sure it would be a lot more interesting. In the  mean time, checkout Struts 2 and start playing with it. According to the goals  of the project, you are supposed to be able to write a web application a lot  faster (which I tested to be true) as well as to make it coexist with a Struts 1  application (also tested to be true). Have fun!&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-3368558978734715147?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/3368558978734715147/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=3368558978734715147' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/3368558978734715147'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/3368558978734715147'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2007/10/introduction-to-struts-2x.html' title='Introduction to Struts 2.x'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-2737654975946120600</id><published>2007-10-07T22:40:00.000-04:00</published><updated>2007-11-27T21:10:51.218-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AspectJ'/><category scheme='http://www.blogger.com/atom/ns#' term='Pointcut'/><category scheme='http://www.blogger.com/atom/ns#' term='Advise'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><category scheme='http://www.blogger.com/atom/ns#' term='AOP'/><title type='text'>Learning about AOP</title><content type='html'>&lt;div&gt;&lt;div style="text-align: justify;"&gt;&lt;strong&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-weight: normal;"&gt;I was told that once I start writing code in AspectJ and learn in depth Aspect Oriented Programming (AOP), it will be difficult to look at Java source code again in the same way as before. And now, the more I get into it, the more I realize how important it is to have this knowledge as part of your skill set. Until now,  &lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-weight: normal;"&gt;I had heard a lot about AOP and, just as anyone else who has used the Spring Framework, I thought I knew all I would ever need from AOP. Then, I was presented with a challenge where Spring support was not enough so I was faced with the opportunity to learn AspectJ's language constructs to address my client's concerns. I was very impressed with the things I was able to accomplish with this extension to the language and in general I highly recommend everyone to take the time to learn it and use it often.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div style="text-align: justify;"&gt;&lt;strong&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-weight: normal;"&gt;One of biggest goals and hopes of every Software Architect is to design and lead a software development effort that can scale well. This means that maintenance should be more than technically feasible, but rather simple enough within budget. Experience proves that despite every effort of preparing for every change, it is difficult to address every potential concern that will rise in the future. Specifically, when these concerns appears spread out  through the code base. This separation of concerns is what is referred to as "&lt;span style="font-style: italic;"&gt;cross cutting concerns&lt;/span&gt;". AOP provides an API that allows you to write code to address these "concerns" in a desirable manner.&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:arial;" &gt;Aspect Oriented Programming (AOP)&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family:arial;"&gt;Cross cutting concerns are address by way of, what is referred to as, "&lt;span style="font-style: italic;"&gt;Aspects&lt;/span&gt;".  Just as much as an Object models an Entity, an Aspect models a "Cross Cutting Concern". Getting familiar with these concepts takes some time, however as you take the time to write your own Aspects, it will become very easy to follow.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family:arial;"&gt;Every Aspect contains an entry point, a &lt;span style="font-weight: bold; font-style: italic;"&gt;Pointcut&lt;/span&gt;. This basically describes how is the crossing concern identified.  For example, the concern may be "&lt;span style="font-style: italic;"&gt;all Constructors calls (from a specified package) must passed through an Authentication process prior to instantiation&lt;/span&gt;". So, the &lt;span style="font-style: italic;"&gt;Pointcut &lt;/span&gt;will be all "&lt;span style="font-style: italic;"&gt;calls to the Constructor within the package in question&lt;/span&gt;". This &lt;span style="font-style: italic;"&gt;Pointcut&lt;/span&gt; description,  interestingly enough,  is one of the reasons where Spring AOP couldn't help me (Spring can not manage objects that are created somewhere else - e.g. Hibernate's Proxy objects). These &lt;span style="font-style: italic;"&gt;Pointcuts &lt;/span&gt;delegate processing to a handler called &lt;span style="font-weight: bold; font-style: italic;"&gt;Advise&lt;/span&gt; which is where most of the logic occurs. An &lt;span style="font-style: italic;"&gt;Advise&lt;/span&gt; reflects the concern that is trying to be addressed. Continuing with our previous example, &lt;span style="font-style: italic;"&gt;&lt;/span&gt;the &lt;span style="font-style: italic;"&gt;Advise&lt;/span&gt; will be "&lt;span style="font-style: italic;"&gt;before calling the constructor call check authenticating roles&lt;/span&gt; else throw an exception".  Additionally,  an &lt;span style="font-style: italic;"&gt;Aspect&lt;/span&gt; may have multiple Pointcuts and each &lt;span style="font-style: italic;"&gt;Pointcut&lt;/span&gt; will have a minimum of one &lt;span style="font-style: italic;"&gt;Advise.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;strong&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;AspectJ&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div style="text-align: justify;"&gt;&lt;strong&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-weight: normal;"&gt;In the Java Programming language, AspectJ provides the ability to use these concepts in terms of objects. In general, AspectJ is an extension to the language. Originally developed by Xerox-PARC, it is now maintained by the Eclipse Foundation. The following code in AspectJ reflects the sample we have discussed thus far (for an object class name Foo):&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;font-size:100%;"&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;public&lt;/span&gt; &lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;aspect &lt;/span&gt;AuthenticatedConstructorAspect&lt;/span&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;font-size:100%;"&gt;{&lt;/span&gt;&lt;span style="font-family:courier new;font-size:100%;"&gt; &lt;blockquote&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;pointcut&lt;/span&gt; constructorCheck() : &lt;span style="color: rgb(153, 0, 0); font-weight: bold;"&gt;call&lt;/span&gt;(* *.Foo());&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;before()&lt;/span&gt; : constructorCheck() {&lt;br /&gt;     &lt;span style="font-style: italic; color: rgb(0, 153, 0);"&gt;// Do some coding (e.g. throw an Exception, etc)&lt;/span&gt;&lt;br /&gt;} &lt;br /&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:100%;"&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family:Arial;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;In general, aspect oriented programming provides a great strength to your development efforts if used appropriately. It can become a strong part of your development efforts if used properly and can scale well since it can be plugged in as a requirement is enforced.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:arial;" &gt;References&lt;/span&gt; &lt;ol style="font-family: arial;"&gt;&lt;li&gt;&lt;a href="http://www.ubookcase.com/book/Addison.Wesley/Eclipse.AspectJ/"&gt;http://www.ubookcase.com/book/Addison.Wesley/Eclipse.AspectJ/&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.sable.mcgill.ca/%7Ehendren/AspectJ.html"&gt;http://www.sable.mcgill.ca/~hendren/AspectJ.html&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.stepwise.com/Articles/AspectJ/index.html"&gt;http://www.stepwise.com/Articles/AspectJ/index.html&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://www.eclipse.org/aspectj/doc/released/progguide/language-joinPoints.html"&gt;http://www.eclipse.org/aspectj/doc/released/progguide/language-joinPoints.html&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://www.javaworld.com/javaworld/jw-04-2002/jw-0412-aspect3.html"&gt;http://www.javaworld.com/javaworld/jw-04-2002/jw-0412-aspect3.html&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-2737654975946120600?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/2737654975946120600/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=2737654975946120600' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/2737654975946120600'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/2737654975946120600'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2007/10/learning-about-aop.html' title='Learning about AOP'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-2969441022531590784</id><published>2007-10-04T16:40:00.000-04:00</published><updated>2007-11-20T00:29:54.167-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JEE'/><category scheme='http://www.blogger.com/atom/ns#' term='RoR'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='EJB'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ODP'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>Rethinking the Enterprise</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;Some years ago, I took a "Data Structures" class in college where I felt I received more than what I had signed up for. During my lectures, my professor challenged us to think outside the box constantly. On one &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_0"&gt;occasion&lt;/span&gt;, a midterm exam was promising to be hard for the whole class. I was particularly puzzled with a bonus question (worth a lot more than the usual). Although I felt prepared for the exam, I was somewhat troubled, even upset at the question. If I recall correctly, the question was something like:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-style: italic;font-family:courier new;" &gt;&lt;span style="font-family:arial;"&gt;(x-99)(x-98)(x-97)... (x-2)(x-1)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;And we were asked to calculate the product when "&lt;span style="font-style: italic;"&gt;X&lt;/span&gt;" was 15. This puzzled me for a second since my first reaction was "&lt;span style="font-style: italic;"&gt;why do I need to solve this in a Data Structures exam?&lt;/span&gt;". To my despair, I made the decision that I would spend 1 minute in trying to solve this question, since these midterms were known for being extremely long and difficult to finish. A few days later, during our next lecture, one of my classmates took the courage to ask the reasoning behind these "&lt;span style="font-style: italic;"&gt;absurd&lt;/span&gt;" question. Our professor kindly explained that such question was to help us understand a principle that we had to remember if we were to &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_0"&gt;succeed&lt;/span&gt; as Engineers. Thinking outside the box is not as simple as you may think and often times it requires a great determination to just do &lt;span style="font-weight: bold;"&gt;simple&lt;/span&gt; things. Although the answer may be simple, too much knowledge can lead us to add complexity to a simple problem, thus our skills are poorly used. By the way, the answer to question above mentioned was zero (&lt;span style="font-size:85%;"&gt;if your need a detail explanation, please send me an email&lt;/span&gt;).&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-weight: bold;"&gt;Simple and Plain concepts&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;Similarly to the incident I had in college, I attended a seminar not that long ago where the speaker spoke about this same exact principle.  The approach he took was probably more eloquent than what I would like to be, but I feel he made a good point. This had to do with Enterprise Applications development. If you have noticed, the first word "&lt;span style="font-style: italic;"&gt;Enterprise&lt;/span&gt;" is a simple word, yet as soon as one adds the second (&lt;span style="font-style: italic;"&gt;Applications&lt;/span&gt;), a developer can start associating different technology concepts (EJB, Spring, .NET, Ruby, PHP). Normally, one is biased about a familiar technology, yet no one has even discussed anything about requirements. I met once an Engineer who had already designed (or at least he thought he had) an Application using &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;EJBs&lt;/span&gt; without understanding the problem domain and/or requirements. This made me think in how we, as Engineers, are using the knowledge we have to develop simple solutions and avoid adding complexity to a business problem. I really stress this point because there seems to be an untold fear to learn/use different technologies and we seem to prefer to add more complexity over using the appropriate approach to solve a problem.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-weight: bold;"&gt;Facing our Engineering Fear&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;So why should you use &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;EJBs&lt;/span&gt;? Do you fully understand what are the benefits of using these? Is .NET perhaps a better approach to the company's goals? Would you recommend building an application in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;RoR&lt;/span&gt; (Ruby on Rails) over J2&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;EE&lt;/span&gt; (or .NET)? If not, could you number such reasoning?  What is our real bias about the technology we choose to use when solving a problem?. Interestingly enough, I've found Engineers using a set of technologies that are known well, not necessarily because they are the best, but because is convenient. Engineering staff must understand the tool set available to them when solving problems, and unless required, not "&lt;span style="font-style: italic;"&gt;re-inventing the wheel&lt;/span&gt;".&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;From the management perspective, there are very few cases when a developer may start working off a clean repository. This means that there is an existing asset to be maintained and/or extend. Management is skeptical about investing in such a change. In fact, it will take a lot of convincing to help management realize what is the really added value to a product in a potential "re-architecture" phase. Although this is understandable in most cases, an Enterprise Application can certainly benefit from a fresh new code base when situations allow them. This however should not make us believe that such architecture is the only and true way of solving every Enterprise Business need. A simple example is the case when Hibernate may not be the solution to every persistence problem. There are valid cases when JDBC is a perfect example. Or in the case of .NET, is the MS Oracle Client better than the ODP (Oracle Data Provider) for connections to an Oracle database?&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-weight: bold;"&gt;The Hope of the Enterprise&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;To have a broader view of different technologies can certainly help us see an Enterprise Application from different perspectives. Being willing to learn new technologies can only help us and the Enterprise, but ultimately is up to us to drive the effort. So, when thinking about the Enterprise, one must think about the problem domain, and not only the tools available within our domain knowledge, but also what other alternatives available to solve the problem effectively. As scientists, we have a responsibility not only to solve technical problems, but to also use the most effective methods to do so. So read on documentations, download and test many frameworks and prepare yourself for we are the true hope of the Enterprise.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-2969441022531590784?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/2969441022531590784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=2969441022531590784' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/2969441022531590784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/2969441022531590784'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2007/10/rethinking-enterprise.html' title='Rethinking the Enterprise'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-2573604811458527157</id><published>2007-10-01T15:14:00.000-04:00</published><updated>2007-11-12T19:03:51.246-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Annotations'/><category scheme='http://www.blogger.com/atom/ns#' term='Persistence'/><category scheme='http://www.blogger.com/atom/ns#' term='JDBC'/><category scheme='http://www.blogger.com/atom/ns#' term='HQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='ORM'/><title type='text'>Leveraging Persistence with Hibernate</title><content type='html'>&lt;div  style="text-align: justify;font-family:arial;"&gt;&lt;span style="font-family:arial;"&gt;Most Applications today depend on some sort of persistence layer to maintain state. When developing applications using JEE, the Java Database Connectivity specification (JDBC) empowers developers to use a database as the persistence repository of choice. With the JDBC API, most development efforts become technically feasible as it provides standard CRUD operations to a relational database. Unfortunately, programming with this API can also become cumbersome and repetitive in most cases. The question that remains is "&lt;/span&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;Can we do better?&lt;/span&gt;&lt;span style="font-family:arial;"&gt;" - It turns out that the answer to this question is "&lt;/span&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;of course!&lt;/span&gt;&lt;span style="font-family:arial;"&gt;". In fact, there are many other things we could do that is "&lt;/span&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;better&lt;/span&gt;&lt;span style="font-family:arial;"&gt;", however, for purposes of this entry, I'd like to discuss role and concept of Relational Mappers (ORMs) in the enterprise, and more specifically, Hibernate.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Object Relational Mappers with Java&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div  style="text-align: justify;font-family:arial;"&gt;&lt;span style="font-family:arial;"&gt;Although Java is an Object Oriented programming language, the JDBC API lacks the ability to relate to a relational model in a database in a complete object oriented way. This is where Object-Relational Mappers (ORMs) help. Generally speaking, ORMs help model a relational database in terms of Objects that represent a business phenomena. This mapping is maintained in some configuration file (e.g. XML file, annotation, etc). In addition to this kind of mapping, ORMs also provide additional features such as caching, query language support, RDBMS independence (&lt;/span&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;more on this below&lt;/span&gt;&lt;span style="font-family:arial;"&gt;) and what I like the most, tools to build and monitor this layer among others. Now, having said these, an ORM is not the answer to all solutions. There are times when straight JDBC programming may be more effective, however I've found easier to maintain code written using an ORM than without. Not to mention how elegant the code looks.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Learning Hibernate&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify; font-family: arial;"&gt;Hibernate is an Open Source ORM framework, now part of the JBOSS family of products. As of the time of this writing, Hibernate 3 is the latest release with improved features and nice tools for automatic configuration file generation, code generation, code/table verification, reverse engineering, etc. The documentation is very clear and easy to follow and they now use JIRA to maintain all bug reports. One important thing about Hibernate that I consider strongly is its large number of support for other RDBMs. This means that as long as the code reference Hibernate's API for persistence, an application can be migrated to different databases. This also improves scalability and promotes loose coupling to database specific code. Starting Hibernate for the first time is very simple, but just as much as every other framework, it can become cumbersome if configuration is not designed properly. So, besides being open-source and "&lt;span style="font-style: italic;"&gt;elegant&lt;/span&gt;", what are some of the reasons when I would suggest to use Hibernate?&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family:arial;"&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt;Advantages of using Hibernate&lt;/span&gt;&lt;br /&gt;Hibernate is a very mature ORM framework, widely used in Enterprise applications. This is not by accident but because it adds value to an application from different perspectives. Here are some of the reasons I would recommend Hibernate:&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;ul  style="font-family:arial;"&gt;&lt;li  style="text-align: justify;font-family:arial;"&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;Object Orientation&lt;/span&gt;&lt;span style="font-family:arial;"&gt; - Hibernate allows development using object oriented constructs when dealing with persistent objects. This means, you can take advantage (programmatically) of associations, polymorphism and inheritance. Depending on your current data model, there may not be a big difference in how a database is represented in terms of objects, thus using Hibernate is a great improvement in your code. I understand that with EJB3, this may not be a unique advantange to Hibernate, however for legacy applications (EJB2, JDBC), this is a clear option&lt;/span&gt;.&lt;br /&gt;&lt;/li&gt;&lt;li  style="text-align: justify;font-family:arial;"&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;Transparent Persistence&lt;/span&gt; - &lt;span style="font-family:arial;"&gt;Hibernate maintains all mappings between database tables and objects. This means that all interactions with the database can be done with objects instead of the JDBC API. This level of abstraction adds no more overhead than the average JDBC code. The ability to now write code to objects, without writing SQL code to read/write/delete to a database makes persistence transparent. This means that the persistence layer is now  delegated (at least significantly) to Hibernate.&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li  style="text-align: justify;font-family:arial;"&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;Support for polymorphic queries&lt;/span&gt; - &lt;span style="font-family:arial;"&gt;JDBC supports native SQL when building queries. This can become difficult to maintain and cumbersome to extend. Hibernate's polymorphism support for object mappings allows developers to write queries using the Hibernate Query Language (HQL) using polymorphic objects which can improve the level of abstraction used for modeling data in your queries. Additionally, Hibernate's API promotes object orientation when dealing with queries. (&lt;/span&gt;&lt;span style="font-style: italic;font-family:arial;font-size:85%;"  &gt;See note below for disadvantages to consider about this feature&lt;/span&gt;&lt;span style="font-family:arial;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li  style="font-family:arial;"&gt;&lt;div align="justify"&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;Database independence &lt;/span&gt;- &lt;span style="font-family:arial;"&gt;depending on your business model, an Enterprise Application may need to be deployed in different RDBMs. This is typically dependent upon a business requirement, or a client customization. For this scenario, Hibernate adds value to your application due to the level of abstraction added over the database. This reduced dependency means increased portability of your application. In constrast, nothing in JDBC promotes code to be database neutral and it's up to the developer/architect to ensure portability.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-style: italic;"&gt;Optimized Performance&lt;/span&gt; - &lt;span style="font-family:arial;"&gt;Hibernate has a powerful caching architecture that allows developers to write code with fewer trips to the database. This is done by virtue of the cached mapped objects as these are "&lt;/span&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;hydrated&lt;/span&gt;&lt;span style="font-family:arial;"&gt;" from the database and reused when others needed. This kind of caching is difficult to accomplish using straight JDBC.&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt; &lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style="font-family: arial;" align="justify"&gt;As an Engineer, one must remember that Hibernate is a tool and not a solution for every problem. Once you used it once, it is very tempting to use it again in every scenario, however one must understand the disadvantages associated with every framework.&lt;br /&gt;&lt;/p&gt;&lt;p  style="font-family:arial;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:arial;" &gt;Disadvantages in using Hibernate&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Depending on your needs, Hibernate may or may not be what you really need. This all depends on different factors (e.g. budget, deadlines, current assets, etc). One must consider all factors before deciding to use Hibernate (just as much as with any other framework).&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul style="font-family: arial;"&gt;&lt;li style="text-align: justify;" face="arial"&gt;&lt;em&gt;Learning curve -&lt;/em&gt; Depending on your current staff, learning Hibernate may be difficult, specially if the application in question is heavily dependant in persistence using already another ORM solution, JDBC or even EJB. Mainly because Hibernate has a lot of publicity does not mean one has to spend budget on it. Although the documentation is very clean, there are many concepts to understand in Hibernate (e.g. dirty checking, caching, lazy-loading, get vs load, etc).&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;&lt;em&gt;Mappings to the Database&lt;/em&gt; - The main assumption that all ORMs do is that every table can be modeled to an Object. This is, for the most part true, however you can certainly find cases when representing tables in objects is not necessarily simpler, specially if the database model is not normalized, or poorly designed. Additionally, some DBAs would prefer to use database specific constructs (e.g. triggers, stored procedures) to handle some business logic which may contradict with your intentions in decoupling business logic from persistence.  In general, you should not assume that a database can always be represented in terms of objects without understanding all requirements. I recommend getting familiar with the &lt;a href="http://en.wikipedia.org/wiki/Object-Relational_impedance_mismatch"&gt;object-relational impedance mismatch&lt;/a&gt; for further reference.&lt;a href="http://en.wikipedia.org/wiki/Object-Relational_impedance_mismatch"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/a&gt;&lt;/li&gt; &lt;li style="text-align: justify;"&gt;&lt;span style="font-style: italic;"&gt;Performance Bottlenecks&lt;/span&gt; - Complex database model may prove to add performance bottlenecks to certain queries (specially if they are polymorphic in nature). Hibernate does an excellent job at building joins for you automatically, but is not able to improve the performance of those queries as a database would do (e.g. analyze the execution plan). This is the kind of optimization that is expected to be done manually. If an Application demands this type of queries in most cases, I would probably consider JDBC instead of Hibernate. It is true that you can also run SQL queries with Hibernate, but if most of the application is doing straight SQL, then we are not using the tool properly (thus defeating the purpose of the ORM).&lt;br /&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;&lt;span style="font-style: italic;"&gt;Complex queries&lt;/span&gt; - Hibernate provides the "Hibernate Query Language" (HQL) which allows developers to write queries very similar to SQL with object orientation (polymorphism). Depending on the type of inheritance chosen to persist certain schemas, queries can grow in complexity, thus adding complexity to the nature of the query. One could write native SQL queries and make them more efficient than HQL (a DBA should be able to help you here). Once again, this all depends on the type of application that we are dealing with.&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;font-family:arial;" &gt;Conclusion&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family:arial;"&gt;Hibernate is a very mature and powerful ORM that in most cases, adds value to your application. Depending on your requirements, Hibernate can reduce the complexity of code maintenance as related to persistence. When dealing with complex data models, one must carefully consider the advantages of using Hibernate (just as much as with any other framework).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-2573604811458527157?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/2573604811458527157/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=2573604811458527157' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/2573604811458527157'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/2573604811458527157'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2007/10/t-hibernate.html' title='Leveraging Persistence with Hibernate'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-5189620233962091103</id><published>2007-09-26T08:55:00.004-04:00</published><updated>2008-09-24T12:00:11.481-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><title type='text'>A Review of the MVC pattern</title><content type='html'>&lt;span style="font-family:arial;"&gt;Tight coupling among software components is one of the common problems in large enterprise applications. This is due to the large amount of data and the way in which this data is represented to users of the application. In practice, it's very easy to fall into the problem of writing unorganized code that, although it delivers a product, it does not maintain any known convention or standard. This only contributes to the problem of extending application functionality (scalability) which is almost certain to happen. Many design patterns are used in the industry to solve different business problems. Among these, the Model-View-Controller (MVC) pattern is one that if often misquoted and misused. In using the Struts Framework for building web-based applications, it is crucial that every developer understand this pattern.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="TEXT-ALIGN: justify"&gt;&lt;span style="font-family:arial;"&gt;In the MVC patterns, a clear distinction is made between three different components. These are the Controller, the View and the Model. Each of this components help segregate and centralize certain functionality of our code away from each other (loose coupling), thus scalability and re-usability is feasible. The following figure provides a small representation of how this components are meant to interact:&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="TEXT-ALIGN: center"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_q1JiMjLM_1c/Rx5XYaJo9WI/AAAAAAAAAIE/5Bg6x5Rj-4g/s1600-h/mvc.bmp"&gt;&lt;img id="BLOGGER_PHOTO_ID_5124629502842434914" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: pointer; TEXT-ALIGN: center" alt="" src="http://bp1.blogger.com/_q1JiMjLM_1c/Rx5XYaJo9WI/AAAAAAAAAIE/5Bg6x5Rj-4g/s320/mvc.bmp" border="0" /&gt;&lt;/a&gt;&lt;span style="font-family:arial;font-size:78%;"&gt;&lt;span style="FONT-STYLE: italic"&gt;Figure 1&lt;/span&gt; - Diagram of the Model-View-Controller Pattern&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="TEXT-ALIGN: justify"&gt;&lt;span style="font-family:arial;"&gt;In this pattern, the &lt;span style="FONT-WEIGHT: bold; FONT-STYLE: italic"&gt;Model&lt;/span&gt; component is a representation of some business data. This is also known as "&lt;span style="FONT-STYLE: italic"&gt;domain model&lt;/span&gt;" and is specific to a business. It can also serve as a representation of a "&lt;span style="FONT-STYLE: italic"&gt;real-world&lt;/span&gt;" process that the application is identifying or hold the state of a business entity. The &lt;span style="FONT-WEIGHT: bold"&gt;&lt;span style="FONT-STYLE: italic"&gt;View&lt;/span&gt;&lt;/span&gt; component is a specific display of the model component in the user interface (UI). This is also known as the "&lt;span style="FONT-STYLE: italic"&gt;presentation layer&lt;/span&gt;" of the application. Thus, if the &lt;span style="FONT-STYLE: italic"&gt;model&lt;/span&gt; component is a &lt;code&gt;BankAccount&lt;/code&gt; object, the &lt;span style="FONT-STYLE: italic"&gt;view&lt;/span&gt; component may be an HTML page containing account balance and transactions, or a frame of UI widgets representing the account holder personal information. Note that for both of this examples, the &lt;span style="FONT-STYLE: italic"&gt;model&lt;/span&gt; knows nothing about the &lt;span style="FONT-STYLE: italic"&gt;view&lt;/span&gt;, however the &lt;span style="FONT-STYLE: italic"&gt;view&lt;/span&gt; needs to know some about the &lt;span style="FONT-STYLE: italic"&gt;model&lt;/span&gt; component in order to display it. This direction in dependency is an important concept in this paradigm which encourages loose coupling among components: Developers programming in the &lt;span style="FONT-STYLE: italic"&gt;model &lt;/span&gt;component do not depend on the presentation layer.&lt;br /&gt;&lt;br /&gt;Changes to the &lt;span style="FONT-STYLE: italic"&gt;model&lt;/span&gt; component (information holding business data) are handled through the &lt;span style="FONT-WEIGHT: bold"&gt;&lt;span style="FONT-STYLE: italic"&gt;Controller&lt;/span&gt;&lt;/span&gt; of the application. This means that if the &lt;span style="FONT-STYLE: italic"&gt;view&lt;/span&gt; component has a function (e.g a button, or a drop-down) that needs to be triggered in order to execute an update on the &lt;span style="FONT-STYLE: italic"&gt;model &lt;/span&gt;component, the &lt;span style="FONT-STYLE: italic"&gt;view&lt;/span&gt; communicates this event to the &lt;span style="FONT-STYLE: italic"&gt;controller&lt;/span&gt; component who executes this change and updates the &lt;span style="FONT-STYLE: italic"&gt;model&lt;/span&gt; component. This level of redirection ensures the controller to handle the proper action per view according to business needs. For example, a bank account number may need to be "read-only" to customers but to staff members, this may be an editable field. In this case, it is up to the controller to decide whether the action of updating the account number should trigger an update operation on the &lt;span style="FONT-STYLE: italic"&gt;model&lt;/span&gt; component and is up to the &lt;span style="FONT-STYLE: italic"&gt;view&lt;/span&gt; component to determine if this functionality is even displayed to the user.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;In the context of the Struts Framework, the MVC pattern can be represented using the following diagram. Note that the three components of this pattern appear in the same order as in Figure 1: &lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-size:78%;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5249617193508015682" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_q1JiMjLM_1c/SNpjBhnUDkI/AAAAAAAAAis/0R_OgJIQYuE/s320/mvc-struts.bmp" border="0" /&gt;Figure 2 - Struts implementation of the MVC pattern.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="TEXT-ALIGN: justify"&gt;&lt;span style="font-family:arial;"&gt;Struts is focused on web-based Enterprise Applications and is heavily based on Servlet Technology. At the core of the &lt;span style="FONT-STYLE: italic"&gt;controller&lt;/span&gt; component is the &lt;code&gt;ActionServlet&lt;/code&gt; object. In general, this servlet forwards control to &lt;code&gt;Action&lt;/code&gt; objects (to perform CRUD operations on the &lt;span style="FONT-STYLE: italic"&gt;model&lt;/span&gt; component) or to another &lt;span style="FONT-STYLE: italic"&gt;view &lt;/span&gt;component. This &lt;code&gt;ActionServlet&lt;/code&gt; knows how to associate &lt;span style="FONT-STYLE: italic"&gt;view&lt;/span&gt; components with specific &lt;span style="FONT-STYLE: italic"&gt;&lt;code&gt;Action&lt;/code&gt;&lt;/span&gt; objects through one or more XML files loaded during the servlet initialization process - init() method. Thus changes to this XML file typically represent a reload of this &lt;code&gt;ActionServlet&lt;/code&gt;. In this approach, developers are left to insert code in the &lt;code&gt;Action&lt;/code&gt; objects of their choice in order to perform changes in the component. When objects need to be placed in the&lt;span style="FONT-STYLE: italic"&gt;&lt;span style="FONT-STYLE: italic"&gt;&lt;span style="FONT-STYLE: italic"&gt;&lt;span style="FONT-STYLE: italic"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;presentation layer, the &lt;span style="FONT-STYLE: italic"&gt;controller&lt;/span&gt; also uses this &lt;code&gt;Action&lt;/code&gt; objects to place this &lt;span style="FONT-STYLE: italic"&gt;model&lt;/span&gt; in proper scope (page, request, session, etc).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Struts also provides different tag libraries to help in the rendering of the &lt;span style="FONT-STYLE: italic"&gt;model&lt;/span&gt; components in the presentation layer (&lt;span style="FONT-STYLE: italic"&gt;view)&lt;/span&gt;, however, it is left to the developers to decide how to display the data by virtue of the MVC pattern. This means that JSP, velocity or any other rendering engine can be used as part of the presentation layer. As for the &lt;span style="FONT-STYLE: italic"&gt;model&lt;/span&gt; this can be any representation of the domain model of the application such as an entity bean EJB, a Java Bean using Hibernate (Session in View) or Data transfer objects to partially represent a domain model object. Other components can also be plugged to &lt;span style="FONT-STYLE: italic"&gt;controller&lt;/span&gt; component such as resource bundle configuration, menu capabilities, tiles, etc. This pluggable architecture mixed with other configurable features (e.g. validation) has made Struts a preferable option when choosing to use the MVC pattern as part of the architecture of a Java Enterprise Application.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family:arial;"&gt;Loose coupling between components is the key concept. Different frameworks are available in the open source community, among which some offer an MVC architecture for Java Enterprise applications, however keep in mind that, as quoted in &lt;/span&gt;&lt;span style="font-family:arial;"&gt;Martin Fowler's &lt;span style="FONT-STYLE: italic"&gt;"Patterns of Enterprise Application Architecture":&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="FONT-STYLE: italic"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;em&gt;"The value of MVC lies in its two separation. Of these the separation of&lt;br /&gt;presentation and model is one of the most important design principles in&lt;br /&gt;software, and the only time you shouldn't follow it is in very simple&lt;br /&gt;systems..."&lt;/em&gt; &lt;span style="font-size:78%;"&gt;(page 332)&lt;/span&gt; &lt;/blockquote&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="TEXT-ALIGN: justify"&gt;&lt;span style="font-family:arial;"&gt;So, keep these in mind when using Struts. Additional features offered by the framework should not be confused with the objective for which Struts was designed. Overuse and/or additional design without careful planning can prove to reduce scalability thus reducing the value of the product in the long run.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="FONT-STYLE: italic"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-5189620233962091103?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/5189620233962091103/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=5189620233962091103' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/5189620233962091103'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/5189620233962091103'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2007/09/review-of-mvc-pattern.html' title='A Review of the MVC pattern'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp1.blogger.com/_q1JiMjLM_1c/Rx5XYaJo9WI/AAAAAAAAAIE/5Bg6x5Rj-4g/s72-c/mvc.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4831432806087932521.post-1152964027031422392</id><published>2007-09-15T08:53:00.000-04:00</published><updated>2007-11-05T23:12:40.497-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='Struts1'/><title type='text'>Introduction to Struts 1.x</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;Some years ago, I was asked to add a new feature to an existing struts-based application. The feature would include some form validation, form pre-population as well as some embedded logic depending on the authenticated user. Double submissions were also a big concern and had to be detected and avoided. These, among others, are many of the tasks where Struts can be extremely helpful. Sure, there are many things that experienced developers will find as shortcomings (just as any other tool has weaknesses), yet Struts continues to grow from these and is now a well-defined Java Framework for building Enterprise Applications using a Model-View-Controller (MVC) architecture.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;One thing to remember is that Struts is not the only solution, is only one of the many. Specifically, it's one commercially popular in the Java programming language. There are other solutions available such as WebWork (now merged with Struts to make Struts2), Spring MVC, Swing, JSF (which is now the official MVC specification from Sun MicroSystems), Stripes, JFace, OpenBravo, etc. Alternatively, other programming languages (such as Ruby on &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;&lt;a href="http://www.rubyonrails.org/"&gt;Rails&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;) have an MVC approach of their own. In general, it is the pattern (MVC), not the tool (Struts), that we must remember brings success to an Enterprise Application.&lt;br /&gt;&lt;br /&gt;If you are a newbie, be aware that Struts is now branched in two different projects: Struts1 and Struts2. The first one aims to continue development on the original Struts Framework. Struts2 is the new approach for MVC development as developers from the Struts and WebWork2 (&lt;a href="http://www.opensymphony.com/"&gt;OpenSymphony&lt;/a&gt;) communities joined forces to provide a cleaner (and simpler) way of developing web-based applications. You may want to consider choosing one first (as suggested on their official site) if you have never used either version as both bring to the table fundamental differences. Unfortunately, as a newbie you are going to need to have some understanding of basic technologies. Although the Struts documentation suggests some of these, I would list the following as the key technologies to understand:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul  style="font-family:arial;"&gt;&lt;li  style="font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;HTTP Request/Response Cycles&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li  style="font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;Properties Files and Resource Bundles&lt;/span&gt;&lt;/li&gt;&lt;li  style="font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;Servlets, Filters, and Web Containers (e.g. Tomcat, Resin, Weblogic, WebSphere)&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li  style="font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;Java Server Pages Technology (JSPs, Tags)&lt;/span&gt;&lt;/li&gt;&lt;li  style="font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;XML&lt;/span&gt;&lt;/li&gt;&lt;li  style="font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;Model-View-Controller Pattern&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt; Reading about these shouldn't be difficult for the average developer. The challenge will come later when a developer uses Struts in a real case scenario. It is fundamentally important to remember that Struts is a tool and not the "only" tool to generate Enterprise Applications. Often times, I've found source code where developers have misused Struts by forcing their many features to address a business problem already solved by other technologies (e.g. JSP, Filters, etc). Start with small sample projects and work your way up. For the curious newbie, I've found the JAD decompiler (while developing using Eclipse) &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;to be a great tool for development of Struts Application using your favorite IDE (so you can look at the needed source). This source code is available anyway, but with this tool &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;you can view only what you need, when you need it. Tracing the &lt;code&gt;ActionServlet&lt;/code&gt; Servlet object in the &lt;code&gt;org.apache.struts.action&lt;/code&gt; package can prove to be a very insightful experience... Enjoy!&lt;br /&gt;&lt;br /&gt;Before Struts, your would have to extract each parameter of a request using a "getParameter()" method of the &lt;code&gt;ServletRequest&lt;/code&gt; object. Struts encapsulates this with their &lt;code&gt;ActionForm&lt;/code&gt; object, thus learning the life cycle of this class is essential when dealing with incoming HTTP requests. Also, prior to Struts, you would also have to write certain logic to learn how to forward a request to another Servlet for further processing. Struts solves this with their &lt;code&gt;ActionServlet&lt;/code&gt; and one or more XML configuration files that drive the application flow. Double submissions of HTML Forms were handled by some hack in between Servlet calls. Struts solves this problem by using a "token-per-request" approach and the methods isTokenValid(), resetToken() and saveToken(). In general, Struts provides an Object Oriented API which helps visualize these problems and many more as objects.&lt;br /&gt;&lt;br /&gt;In my experience, learning about the Model-View-Controller pattern is the key to using Struts successfully. This understanding, coupled with adherence to good and useful programming practices (which I plan to address in a different blog entry) will help you appreciate Struts better. So read about this and other practices and use this framework to do what is meant to do: "...&lt;span style="font-style: italic;"&gt;to create/help web applications utilize an MVC architecture&lt;/span&gt;" &lt;span style="font-size:85%;"&gt;(&lt;a href="http://struts.apache.org/index.html"&gt;Reference&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4831432806087932521-1152964027031422392?l=alberto-flores.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alberto-flores.blogspot.com/feeds/1152964027031422392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4831432806087932521&amp;postID=1152964027031422392' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/1152964027031422392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4831432806087932521/posts/default/1152964027031422392'/><link rel='alternate' type='text/html' href='http://alberto-flores.blogspot.com/2007/09/introduction-to-struts-1x.html' title='Introduction to Struts 1.x'/><author><name>Alberto A. Flores</name><uri>http://www.blogger.com/profile/15920599956418699745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_q1JiMjLM_1c/R-kheREoagI/AAAAAAAAARE/UoiklIQfiO0/S220/alberto.jpg'/></author><thr:total>2</thr:total></entry></feed>
