Building Pizza with Lookup | #1

Recently, I announced a blog series on making use of Lookup API along with  some design patterns in RCP Apps. So, I thought why not get started by porting some basic code snippets onto NetBeans Platform and then I shall see how to go about evolving them.

Builder Pattern

I will be beginning with Builder Pattern (a type of Creational Patterns). It does seem obvious with the title of the post- “Building” Pizza with Lookup.


The intention is to abstract steps of construction of object so that different implementations of these steps can construct different representations of objects.

Why Pizza?

Well, I came across a code sample which creates different types of Pizza using Builder Pattern. Hey, I have never made any Pizza on my own, but this seems to be a golden chance and that too through coding 😉

Getting Started

  • Run “NetBeans IDE” (I am using 6.5) which I had installed using JDK 1.5.10.
  • Next, press Ctrl + Shift + N or goto File > New Project…

New Project Wizard opens…

  • Choose NetBeans Modules as Category and NetBeans Platform Application as Project.

Name and Location Wizard opens…

  • Fill relevant information, and you would see project opens up in NetBeans Project Window (Ctrl + 1).

Right-click Project Node and see Project Properties, then select Libraries from visible Categories.

Now, you would see on the right-hand side, only some of the modules of platform9 cluster that are included by default in a RCP Application. Java Platform pointing to JDK 1.5 by default.

Overview of the Code Sample

The existing code sample has 6 classes, out of which 5 fit into Builder Pattern and the remaining class just runs the code sample to construct one of the types of pizza.

Builder (PizzaBuilder)

Abstract interface for creating objects (product).

Concrete Builder (HawaiianPizzaBuilder, SpicyPizzaBuilder)

Provide implementation for Builder. Construct and assemble parts to build the objects.

Director (Cook)

The Director class is responsible for managing the correct sequence of object creation. It receives a Concrete Builder as a parameter and executes the necessary operations on it.

Product (Pizza)

The final object that will be created by the Director using Builder.

The code above could be split into 6 separate “.java” files and stored under single package OR they could be inside a single “.java” file, wherein the filename would be same as that of the Main class.

Porting to NetBeans Platform

I have ported that sample into 4 modules which fits into the class diagram representation of Builder Pattern. The task of porting is simplified because of the Lookup API (Service Provider approach).

Assuming you have followed the guidelines stated in “Getting Started” section and have created a default NetBeans Platform Application (I have named it PizzaBeans) with “No Modules”. Now, we will create 3 modules and finally, move towards creating the 4th module, the one that interacts with the client.

To be continued…


3 thoughts on “Building Pizza with Lookup | #1

  1. Pingback: Project with Kenai and I « N, Varun

  2. Pingback: Building Pizza with Lookup (Part 2) « N, Varun

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s