Skip to main content

Posts

Showing posts from February, 2013

Model View Presenter pattern

Model View Presenter (MVP) is a software design pattern that brings a lot of benefits developing web applications having GWT as frontend framework. I am going to do a brief description of this pattern. I am currently applying it on a project I am working on and I have noticed that for people coming from MVC (Model View Controller) sometimes it's hard to understand the benefits of MVP (and how to implement it): so I decided to share my experience explaining this pattern from scratch. MVP is a derivative of the MVC pattern and it's used mainly for building user interfaces. As well as the MVC pattern, MVP decouples the model from the views and the views from the logic that controls them. This way you really have the separation of concerns for the presentation logic. The three actors of this pattern are: Model: an interface defining the data to be displayed. View: a passive interface that displays the data of a model and routes user commands (typically events) to the presente...

jOOQ: code generation in Eclipse

jOOQ allows code generation from a database schema through ANT tasks, Maven and shell command tools. But if you're working with Eclipse it's easier to create a new Run Configuration to perform this operation. First of all you have to write the usual XML configuration file for the code generation starting from the database: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd">   <jdbc>     <driver>oracle.jdbc.driver.OracleDriver</driver>     <url>jdbc:oracle:thin:@dbhost:1700:DBSID</url>     <user>DB_FTRS</user>     <password>password</password>   </jdbc>   <generator>     <name>org.jooq.util.DefaultGenerator</name>     <database>       <name>org.jooq.util.oracle.OracleDatabase</name>     ...

SuggestBox in GWT UiBuinder

I am currently working also on a project hosted on Google App Engine ( http://appspot.com ) and I want to share some tips about some of the frameworks offered by the GAE environment. Today I want to talk about a problem we had using the GWT SuggestBox component while making UiBinder layouts. The class  com.google.gwt.user.client.ui.SuggestBox is  a text box or text area which displays a pre-configured set of selections that match the user's input.  Each SuggestBox  is associated with a single  com.google.gwt.user.client.ui.SuggestOracle . The SuggestOracle  is used to provide a set of selections given a specific query string. Our application provides a method to retrieve suggestions from the backend while a user writes into the SuggestBox. This worked fine with a GWT Java layout, but moving to UiBinder layout we faced the following problem. We added a SuggestBox to a view through the GWT designer. The code generated was the following: View.ui.xml: ...

Apache Camel rocks!

Yesterday I attended a meeting of the JBoss User Group @ Red Hat in Rome. One of the two topics of this meeting was an introduction to Apache Camel ( http://camel.apache.org/ ). Last summer Red Hat acquired Fuse Source and now they are promoting Apache Camel. It is a powerful Open Source integration framework based on the most used Enterprise Integration Patterns (EIPs,  http://www.eaipatterns.com/toc.html ).  Camel allows you to define routing and mediation rules in a lot of domain-specific languages, including Java, Spring, XML and Scala DSL. It provides more than 120 components and so it's possible to work directly with any kind of  transport or messaging model. The following image taken from the official website shows the Camel architecture: Camel brings a lot of benefits. How many times it would have been useful in some past projects! But it's never too late to start with it.

Using jOOQ with Spring

Today a brief tutorial on how to integrate jOOQ ( http://www.jooq.org/ ) with Spring. It covers the basic integration that could be easily applied to any web application. For this tutorial I am referring to Spring 3.2.0 and jOOQ 2.6.1. I'm referring to Oracle because the applications I am working on use this database, but all the considerations done here are valid for each database vendor supported by jOOQ. Suppose you have a web application Spring based and want to integrate jOOQ with the most popular Inversion of Control container. First of all you have to put the jOOQ libraries in the WEB-INF/lib folder of  your application. The required jOOQ libraries are the following: jooq-2.6.1.jar jooq-codegen-2.6.1.jar jooq-meta-2.6.1.jar If you use the jOOQ code generation feature you need to add to the classpath also the jooq-codegen-2.6.1.jar library. Then you have to put in the WEB-INF/lib folder also the jOOQ dependencies: log4j-1.2.16.jar persistence-api-1...

jOOQ

jOOQ (Java Object Oriented Querying,  http://www.jooq.org/ ) is an Open Source library that provides a DSL to use SQL as it were natively supported by Java and treated in a object oriented way.  A SQL statement like this: SELECT * FROM BOOK WHERE PUBLISHED_IN = 2011 ORDER BY TITLE in jOOQ DSL becomes: create . selectFrom ( BOOK ) . where ( PUBLISHED_IN . equal ( 2011 )) . orderBy ( TITLE ) But jOOQ isn't just a DSL. It provides also other important features: Code Generation Active records Typesafe SQL SQL standard Vendor-specific feature support and supports the latest versions of the major database vendors.  jOOQ could be a powerful option to Hibernate or JPA. Tomorrow I am going to publish a post about the integration between Spring and jOOQ. Stay tuned!

Foundation 3 POC

Currently working on a POC of Foundation 3 ( http://foundation.zurb.com/ ) and its possible integration with another frontend framework. The official website of Foundation 3 declares:"Foundation: the most advanced responsive front-end framework in the world." Is this true? My first impressions are positive, but I could be more accurate in the next weeks.

Axon framework

It's on line now the February issue of Mokabyte magazine ( www.mokabyte.it ). It contains an article ( http://www2.mokabyte.it/cms/article.run?articleId=F79-K2B-PYN-G2N_7f000001_26089272_9f04d42c ) wrote by me about the Axon framework ( http://www.axonframework.org/ ). This article is the second of four. The column on the right shows you the links to read my other articles about Axon and the CQRS pattern. The article is in Italian language only, but please feel free to ask me any kind of info in English about it.

First post here!

Dear all, I am moving here from my previous blog location ( http://wicketeer.myblog.it/ ), but keeping the same spirit. The old blog is still online and it's still possible to read the older posts. If you want to make a comment on them please refer to this new blog. Stay tuned! Cheers :)