Friday, March 26, 2010

I was playing around with Spring 3.0 and the new Spring Expression Language SpEL the last couple of days and ran across a few issues. First the Spring documentation is a little lacking in this area so I am going to share what I have found.

The problem that I was working to solve was that we store our properties files outside of the War file and use a context property to point to the directory where the file is located. In Spring 2.5.6 this was a little complicated but with Spring 3.x it’s much easier when you use SpEL.

With SpEL you can access several types of properties right out of the box. Here is a list of the ones that I know about. (systemProperties, systemEnvironment, contextAttributes, contextParameters)

The key one for my use was finding the contextParameters. What I do is to setup a parameter name in my context xml file for Tomcat.

<Context className="org.apache.catalina.core.StandardContext" cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper" cookies="true" crossContext="true" debug="0"
docBase="C:\Data\etc\eclipse\projectName1\web" mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/projectName1" privileged="false" reloadable="false" swallowOutput="false" useNaming="true"
workDir="work\Standalone\localhost\projectName1" wrapperClass="org.apache.catalina.core.StandardWrapper">
<Parameter name="config.home" override="true" value="C:\Data\etc\eclipse\projectName1\properties"/>

Now in my application context xml file I can access this parameter with the SpEL command.


So to load up my application’s properties file it’s as easy as using the property loader like this…

<util:properties id="appProperties" location="file:#{contextParameters['config.home']}/">

Now the properties can be used anywhere in your application as necessary. This seems fairly simple but I searched the web and the latest Spring docs without success to find this information. I dug into the Spring source last night to location exactly what I needed to make this work like I wanted. I hope that this helps someone else and yes I’m going to put in a Jira to get the Spring docs updated to include the values list above.

Tuesday, January 26, 2010

Book Review: Oracle SQL Recipes - A Problem Solution Approach

Book Review: Oracle SQL Recipes - A Problem Solution Approach
Author: Grant Allen, Bob Bryla, Darl Kuhn
Publisher: Apress Inc
ISBN: 978-1-4302-2509-6

I haven’t been reviewing Oracle SQL books since for the last several years my primary focus has been in the Java realm. However, I still love working directly with databases especially Oracle so I was looking forward to when this book was release and I had high hopes. Luckily the book delivers in fact I wish that I had a book just like this when I started to work with Oracle 12 years ago. It would have made the learning curve much smaller.

As most books about any technical subject they start out with the simple and head toward the more advanced. This book uses the same approach so if you’re already knowledgeable about SQL you can probably skip the first 2-3 chapters. From there the book ramps up the complexity. This is where SQL starts to get really fun. The book covers many aspects of SQL programming that I have encountered over the years. Validating data between tables, dealing with NULLs, manipulating data in and between types, REGEX are just part of what this book covers. In fact I was working today and ran across a problem where I was developing new Java loaders for some large data sets. I need to compare both tables that are located on different databases to make sure that my code is working the same as the old code. I remembered a section from the book (3-9) that shows how to compare two tables and find the differences quickly. This allowed me to implement a check on several tables in just a few minutes. Otherwise I was going to write a Java program to check and compare the data in the objects which would have taken hours to write. This is a good reminder that we should all use the right tool for the job and in many cases dealing with data using SQL is much simpler than other approaches.

I’m not saying that this book has everything that you would ever need in a SQL book but it’s a great place to start. I would highly recommend this book to add to your library of must have SQL books along with about anything from Joe Celko.

Wednesday, December 23, 2009

Book Review: Beginning Groovy And Grails

Book Review: Beginning Groovy And Grails
Author: Christopher M Judd, Joseph Faisal Nusairat and James Shingler
Publisher: Apress Inc
ISBN: 978-1-4302-1045-0

What I was looking for was a good beginning Groovy book. What I found was a good beginning Grails book. I know that the book covers Groovy in the first three chapters but I was wanting a little more. Anyway, the book does cover Grails fairly well over the next 10 chapters albeit a little dated. The Groovy chapters covers just enough to get someone setup and starting to program in Groovy. But what I want to use Groovy for initially testing and mocking my Java code. Unfortunately this book really didn’t cover any advanced Groovy based topics. Oh, well I’m sure that it’s available in other books.

The Grails sections are far more complete. This book really takes you from creating a web app from scratch using Grails. From the initial configuration to security, restful web services and implementing a reporting system the book covers many of the important areas of creating a web application with Grails. It takes a good approach at explaining the basics and gives enough information in most cases to get to on the right track in more advanced development. You will probably want to reference other texts after this one to bring you more up to date with the latest versions of Groovy and Grails and to cover specialized issues.

I liked the book but in the few areas where it was lacking like more Groovy support it made it a harder read than I expected. In all fairness I cannot really recommend this book as there are others that may be better suited for a beginning Groovy and Grails introduction. It’s not that this book is terrible it just that others are better and this one is a little dated.

Tuesday, December 8, 2009

Book Review: Spring Persistence: A Running Start

Book Review: Spring Persistence: A Running Start
Author: Paul Tepper Fisher and Solomon Duskis
Publisher: Apress Inc
ISBN: 978-1-4302-1878-4

Persistence is a necessary evil in creating applications that enable user interaction. Using Spring makes dealing with persistence much easier but there is the configurations that get everything starting which confuses some new to the framework. The book Spring Persistence: A Running Start is a quick overview on how to get the most common persistence types setup and running with a minimal effort. I liked the breakout by chapter for each persistence style. The book covers the basics of why to separate your application into layers to break the dependencies, JDBC, Hibernate and JPA, IBatis then some transaction and testing. Lastly it covers a little of Groovy and Grails. This book which is aptly named gives a person with little or no experience integrating persistence into a Spring application a Running Start with good examples of configurations to get the basics going. From there the user needs to work on their own, or consult with a more advanced reference or find the information on the web. I would have liked to see a more in depth coverage about the various types of persistence technologies and more advanced examples. Not all the time do we get to deal with easy database scenarios as in the provided examples. Many times we need to work with legacy databases that were not built with ORM friendly tables. This book does what it comes to do but I feel that there is an audience for more advanced but just as focused books on the Spring layers. I come away from reading this book with a since of knowing more about some of the persistence types that I have not dealt with yet but I feel that I want more. I recommend this book for anyone new to Spring or someone that needs to start using another ORM type like Hibernate or IBatis.

Monday, November 23, 2009

Eclipse Plugins that I use.

I’ve been using the Spring Source Tool Suite (STS) every since they released it to open source. STS is a very good version of Eclipse with many cool Spring tools rolled into it. However, there are some plugins that I like to add to make my development a little easier.

The first one that I load is the Infinitest plugin ( . This plugin used to be free but they made it free for only non-commercial development however, it is the single biggest development booster when it comes to TDD development. I could argue for a while about the pricing model that they adopted for commercial development but if you can get your company to flip for the high cost it is a great plugin.

Next I usually load in a few bug detectors. Findbugs ( and checkstyle ( . Eventually I’ll end up using just one of these type of detectors but both are good for certain type of issues. Checkstyle is highly configurable and can enforce a coding style and findbugs can locate more issues than the internal Java code checker. STS already has PMD loaded by default which I also use at times. Now if I could just get my co-workers to start using them…

Now I load up some persistence plugins. IBator ( is nice sometimes when working with IBatis development to generate some code and Hibernate Tools ( I sometimes use for some hibernate development. However, I think that Spring Roo will take over for most of the work that I do with Hibernate Tool very soon. If you haven’t really looked at Spring Roo yet you should. In fact stop reading this right now and go do it! But don’t forget to come back and finish reading my blog… :)

Lastly, I usually load up Subeclipse ( I like Subeclipse for SVN maintenance more than Subversion so far. They both look good but I started out using Subeclipse and haven’t had any problems so far.

Well that’s about it. Any plugins that you load that I don’t? Let me know why you use them.

Friday, October 9, 2009

New FTC Guidlines for posting reviews or products

The FTC posted new guidelines about doing reviews of products in blogging posts as I read on the PC Mag post by Editor Dan Costa today. I agree with Dan that the way this is wording is not enforceable being that there are thousands or millions of blog posts each day. I post reviews of books at times. Most of the time I get the book for free for writing up the review and posting to my blog and to Amazon reviews. However, some of the time I post the review for a book that I purchased. I assure you ALL of the time it is a fair review and will not be swayed by any fact about how or where I got the book. This is how I see the book and or product that I’m reviewing. I don’t hold any punches; if the book is crap I’m going to say its crap. If the book is great and the best thing since the dawn of mankind, I’ll say so.
Read my reviews and post any comments of your own. I’m open to any debate on any book or product that I post a review. However, I don’t see the need to add a disclaimer on each posting that I did or did not receive the product for free. I’m not a lawyer but this should be challenged by the freedom of speech act or something.
What do you think?

Monday, September 28, 2009

Book Review: The Definitive Guide to Spring Web Flow

Book Review: The Definitive Guide to Spring Web Flow
Author: Erwin Vervaet
Publisher: Apress Inc
ISBN: 978-1-4302-1624-7

The first thing about The Definitive Guide to Spring Web Flow that I noticed, and the book was very up front about, it only covers Spring Web Flow v1.0. In the introduction it states that this book only intends to cover the core concepts about Spring Web Flow and the details about v1.0. It states that v2.0 is dramatically different and is a subject for another book. If you’re starting out in Spring Web Flow then you might want to pass on this book and look for another book that specifically focuses on the Web Flow v2.0. However, if you have a need to learn v1.0 this may be a book for you.

The book starts out with an introduction to what Web Flow is and how to get it setup. It then proceeds to explain the basics of web flow and how to get the jars and setup an IDE. I think that this part is a little overkill since anyone with enough Java knowledge should know how to add the dependencies through Maven, Ivy or to manually copy of few jars and add them to your classpath. From there it takes you through the background of what is a web flow and how to plan a web flow in the code. From entry points to exceptions it covers the necessary points to get going with Spring Web Flow v1.0. Chapter 8 gets into the testing of a web flow and how to mock out the flow objects. This takes the unit testing to a new level in my case since in our traditional web applications that I have worked on we have not come close to testing the flows of a page with unit tests. At best we have only tested the individual pages in isolation. The next chapter walks you through an example application. Where other chapters may have left you wondering how to do something with minimal examples this is a full detailed application to get you started with Spring Web Flow. I wish more books would take this concept of using one full chapter and go through a application from start to finish like this.

The book continues on with some real world use cases and a short piece about how to extend web flow to meet any special needs that you may have. The real world cases was nice but I didn’t get much from that as I know where web flow will fit into the tools that I need it to and where I’m going to use it. The extending web flow chapter was a good quick coverage of how to manipulate the web flow for you unique cases. Maybe I read this part too quick, too late at night or the editors got to it and remove too much but I thought that it was lacking some of the good detail that was presented in the other chapters.

Overall, I do recommend this book with the caveats that you understand that this is about Spring Web Flow v1.0.