»
S
I
D
E
B
A
R
«
Building Objects with a Generic Builder
Sep 16th, 2009 by Vitamin C

For my first post here at the prestigious sourJuice I thought I’d serve a little writeup on a generic builder pattern implementation. I hope you enjoy.

Overview

The Builder pattern is often used as a nice fluent way of constructing objects with varying parameters. The drawback is that implementing a builder requires tedious boilerplate code.

An an alternative, several people have proposed utilizing a Proxy to handle builder method invocations against a builder interface. One such implementation I came across recently was by Robbie Vanbrabant.

While I like the idea of using a Proxy to create a generic builder, the implementations I’ve found so far aren’t quite what I’m after. I want a generic builder that can produce objects by invoking setters against my object or by utilizing field reflection, with as little code required as possible. Here is what I came up with.

Implementation

First we’ll define a Builder interface that all specific Builder interfaces must extend.

public interface Builder<T> {
 enum BuilderType { FieldBuilder, SetterBuilder };
 T build();
}

Next we’ll create our BuilderFactory that produces dynamically created Builder instances based on a provided Builder interface.
Read the rest of this entry »

PDFExporter for IceFaces
Sep 15th, 2009 by sourj

I noticed in the IceFaces forum a lot of people were having issues trying create an OutputTypeHandler for PDF Exporting.  Although I could of used Jasper reports to render the PDF, I decided to go with something fast that would not need dynamic report compiling.

Requirements:
IceFaces 1.8+
iText 2+

Since this is a handler and not a custom component you do not need to register any tags or renderers. The only requirement is a reference to the handler in your controller/managing bean and setting the tag to against IceFaces DataExporter component.

.jspx / .xhtml Syntax


Read the rest of this entry »

Welcome to sourJuice
Sep 15th, 2009 by sourj

Welcome to my blog.  I’ve always wanted to give back my findings, research and more to the development community and so I decided to finally do something about it by starting sourJuice.   My name is Jeremy Unruh and I’m originally from Vancouver Canada but now reside in California working for a software company.

Over the past 15 years I’ve learned a great deal about multi-platform, languages and more and as I get time I want to contribute by posting howto’s, research findings, cool projects and or just plain gab.  I welcome anyone else who may want to join my cause and participate in this blog.   Consider it open source, open community :)

Most of my post’s will probably be around JSF, Java, Objective-C and C# as I am currently using them in a lot in existing projects.

© 2009 sourJuice.com