Wednesday, September 10, 2008

Effective Java @ Parleys - Presentation

I loved reading Effective Java Second Edition by Joshua Bloch - At Parleys they have a presentation by Joshua Bloch on some of the issues discussed in the book. It is really a great presentation and I can only highly recommended it (e.g. for understanding PECS when dealing with generics (producer extends, consumer super)).

Tuesday, September 9, 2008

jpwgen - Password Generator for Java

If you ever have the requirement to auto-generate passwords that must meet certain security guidelines such as having at least one number, a special character etc. then take a look at jpwgen. It is written in Java and is based on pwgen (unix).

What is nice about it is that you can use it both as a command line program and/or as a library within your applications.

By the way, if you need a GUI tool for Windows to generate passwords, check out pwgen-win

Monday, September 8, 2008

A Life-Changing Event...

On August 27, 2008 our daughter Leah Annarose was born. As I am posting this, she is already almost 2 weeks old.

Time is racing by, to say the least - The last 2 weeks were really amazing and having a child is a truly new experience; a great one.

For the years to come, it's now time to be a dad.

Thursday, August 21, 2008

Adobe Flex in Atlanta

Our yesterday's AJUG meeting has been awesome. James Ward delivered a great presentation on Adobe Flex and the room was packed (100+ attendees). I just hope Sun can still pull off Java FX and make it truly rock solid because Adobe Flex looks cool and very polished to say the least. Also the integration with Java backends also looked very nice (Adobe's BlazeDS or Granite Data Services). One of the demo's James showed can be found here.

Additionally, here in Atlanta there are more and more Flex projects going on...I wonder if it starts reaching a tipping point.

Finally, I think I need to check out the Atlanta Flash and Flex User Group, especially since it is just around the corner from where I live :-)

Wednesday, August 20, 2008

AJUG DevCon 2009 - Planning

At the Atlanta Java User Group, we are in the middle of planing the 2009 Java DevCon conference. As of now the conference will take place from March 10-11 in Atlanta. We are planning for around 400 attendees. Thus, over the coming couple of weeks we need to finalize our list of speakers. If you're interested in presenting at DevCon feel to contact AJUG at info at ajug dot org or you can also contact me directly at gunnar at hillert dot com.

Tuesday, August 5, 2008

Spring does not like IBM's Java Runtime Environment

I had to learn the hard way that Java JVMs from from different vendors may behave slightly differently - As it turn out, one of my little apps was running fine on Sun's JVM but was causing a weird NPE on IBM's Java Runtime Environment (1.6 64bit)

As it turns out, this was already a reported issue in Spring's Jira. Even better - it was already fixed and after updating Spring from 2.5.3 to 2.5.5 everything is running smoothly again.

Saturday, July 26, 2008

Struts2, JFreeChart - Transparent Charts

For my Struts 2 application I needed to create a chart using
JFreechart
that has a transparent background (rendered as png). Well, I thought
this would be trivial to do as Struts 2 ships with a
plugin
for it...

I created a simple action that creates a chart:

     public final String execute() throws Exception {

final DefaultCategoryDataset categorydataset = new DefaultCategoryDataset();

this.chart = ChartFactory.createLineChart("MyTitle",
"categoryLabel", "valueLabel", categorydataset,
PlotOrientation.VERTICAL, true, true, false);
chart.setBackgroundPaint(new Color(255,255,255,0));

return SUCCESS;
}



In my Struts XML file I put this:


<br /><action name="createChart"
class="com.hillert.sandbox.ChartAction"><br /> <result
name="success" type="chart"><br /> <param name="width">200</param><br /> <param
name="height">150</param><br /> </result><br /></action>



Well, the result is that my chart gets generated and rendered but
without transparency.


After asking the internet's oracle for guidance, Google returns a fews
results, e.g
this
one

that indicate that JFreeChart by default does not generate Alpha
Transparency for Pngs.


The solution however lies in customizing the jFreeChart Struts plugin.
In it's shipped version the plugin is calling:

ChartUtilities.writeChartAsPNG(os, chart, width, height);



For transparency you need to use the
extended
method call

. Simply change the method call above to:



ChartUtilities.writeChartAsPNG(os, chart, width, height, true, 0);



As a result aplha transparency is enabled and my chart is generated with
a transparent background.


Just for completeness, here is my action configuration using the
customized jFreeChart plugin:

<package name="chart"
extends="jfreechart-default" namespace="/chart"><br /><result-types><br /><result-type
name="customChart" class="org.jrecruiter.web.CustomChartResult"><br /></result-type><br /><br /><action
name="createChart" class="com.hillert.sandbox.ChartAction"><br /><result
name="success" type="customChart"><br /> <param name="width">200</param><br /> <param
name="height">150</param><br /></result><br /></action></result-types></package>

Tuesday, July 1, 2008

Book Review: Effective Java, Second Edition

Effective Java, Second Edition by Joshua Bloch is certainly the best Java book I have read in a long time. As a disclaimer, I never read the first edition and I am thus unable to compare the two editions. Effective Java, Second Edition is a mostly easy and fun read providing you with many insights and best practices on how to use Java effectively. It certainly is not a book for the beginner just starting out learning Java. For that purpose you may want to take a look at Thinking in Java by Bruce Eckel instead. Nevertheless, Effective Java would serve as an excellent follow-up.

In Effective Java, Joshua Bloch does a great job describing best practices that you as developer will find useful on a daily basis. For example, I really found his description of the builder pattern (Item 2, page 11) quite interesting. Another Item that fascinated me, was Item 15 (page 73) - "Minimize mutability". Both items are part of a broader theme throughout the book that promotes creating code that is as immutable as possible. In that regard, reading the book will enable you to simply write better and safer code. The book also leads the way towards promoting functional programming techniques which will come in quite handily when developing multithreaded applications. Therefore, as a next book I may recommend reading Java Concurrency in Practice by Brian Goetz.

Even for the experienced Java developer, Effective Java contains quite a few little eye openers. I for example was previously unaware of how static factory methods can simplify the creation of parameterized type instances using "type inference". This example is described on page 9 (Item 1). In the past I had always used something like this:

List users = new ArrayList();

But by using a static factory method you can do:

List users = Helper.newArrayList();

I thought that this was a pretty nifty example that may help making code a bit cleaner. What I also very much liked about Effective Java was that Joshua points out certain short-comings of the Java language itself and its APIs whenever applicable. For example, page 64 describes the inconsistent behavior between BigDecimal's 'equals' method and its 'compareTo' method, and in item 41 (page 194) Joshua details the shortcomings of the List interface when using Autoboxing.

While the vast majority of the book was very easy to read and to understand, I found that the chapter about bounded wildcards using generics (item 28) was a little difficult to grasp and I wished it were a bit more extensive. On the other side, the provided mnemonic is quite helpful: PECS - Producer-extends, Consumer-super.

Overall, I highly recommend Effective Java, Second Edition which will continue to serve me, and likely you too, as an excellent reference resource.

Wednesday, June 18, 2008

TED - Ideas and Inspirations

On the Java Posse they mentioned a presentation by Jill Bolte, a brain researcher, about her experiences having suffered a stroke - It was an amazing presentation! I also have to explore more of TED. There seems to be a ton of good stuff...

Wednesday, June 4, 2008

NFJS Atlanta 2008 Report

I just realized that I started writing a blog entry about attending the No Fluff Just Stuff conference here in Atlanta (May 16-18) - but never finished it...Oh well - Anyway, it was a great conference and the provided backpack will certainly serve me well :-)

Here are the sessions I attended:

Friday
  1. Developing Rich Internet Applications by Richard Monson-Haefel
  2. Java Memory, Performance and the Garbage Collector by Ken Sipe
  3. Architecture and Scaling by Ken Sipe
Saturday
  1. Tactical Continuous Integration with Hudson by Andrew Glover
  2. SOA's Challenges by Ken Sipe
  3. Dojo: Getting Started by Nathaniel Schutta
  4. Configuring Spring with Annotations by Mark Fisher
Sunday
  1. Enterprise Integration Patterns with Spring by Mark Fisher Part I
  2. Enterprise Integration Patterns with Spring by Mark Fisher Part II
  3. Introduction to Tapestry 5 by Howard Lewis Ship
  4. Pragmatic Patterns with Tapestry 5 IoC by Howard Lewis Ship
For me the best presentation was the second part of the Enterprise Integration Patterns talk by Mark Fisher. It was basically all about Spring Integration - This project looks way cool! It basically allows to componentize your application, similar to how you work with JMS. But Spring Integration is working on a lower level. It also has features that are typically found in ESBs such as adapters for mail, JMS, FTP etc. Mark Fisher hinted that in the future Spring Integration may also evolve into a workflow solution.

In terms of speakers - Ken Sipe was simply terrific. I did not expect an overly exciting presentation when listening to "Java Memory, Performance and the Garbage Collector" but I was very impressed. Great talk and very informative.

Lastly it is always nice to listen to Howard Lewis Ship - Tapestry looks good and I really need to play with it at some point - if only the day had 48 hours...

Can't wait for the next conference - Jay, job well done.