CDI


Knappsack Archetypes are now in the Maven Central Repository

I have finally got around to putting the Mavan Java EE 6 Archetypes into the Maven Central Repository. This means you no longer have to manually download and install the Archetypes, they should be available for you to use out of the box. In some cases, depending on how you are creating your projects, you may need to refresh or update your Repository indexes in the IDE before they are visible.

In Eclipse (with m2Eclipse installed), you open the Maven Repositories view, locate the Central Repository in the global repositories, and right click and select update index to make the archetypes available.

To create a new project from the command line, you can copy the following command into a script or batch file and edit it to setup your own group and archetype values.

mvn archetype:generate -DarchetypeGroupId=org.fluttercode.knappsack -DarchetypeArtifactId=jee6-sandbox-demo-archetype -DinteractiveMode=false -DarchetypeVersion=1.0.4 -DgroupId=org.application -DartifactId=sandboxdemo -Dpackage=org.application

The new version includes the archetypes for creating Java EE 6 applications in servlet containers which lets you play around with CDI, JSF, JPA, validation and other JEE 6 technologies using an embedded servlet container from the command line.

Knappsack Archetypes Part 1

This set of articles will document the contents of the Java EE archetypes for Maven. The archetypes come in four flavors, basic,minimal, sandbox and sandbox demo with each one being based on the previous one. In part 1, we’ll give an overview of the archetypes and the structure and configuration used in all of the archetypes. Read More »

Implementing User Selectable Themes In JSF

Many web applications offer users the option to change the appearance of user interface. One of the easiest ways to implement this is by offering different page color schemes by selecting different css style sheets. This article describes how to implement themes in JSF using CDI backing beans that the user can select as their default theme.
Read More »

Updating Weld in Glassfish V3

(updated : This post refers to Glassfish installations prior to version 3.0.1 which was recently released and includes Weld version 3.0.1. Given the new version, this manual update is not necessary and should not be performed if you have an updated installation of Glassfish 3.0.1+)

Even some of the recent versions of Glassfish include a version of Weld, the reference implementation for CDI (JSR 299), that has some major issues. Since Glassfish uses OSGI, upgrading isn’t as easy as just replacing the jar with a new one. This tutorial shows you how to upgrade Glassfish to Weld 1.0.1.Final as well as including a pre-built distribution of the two files that need re-deploying.

One of the ways to get around the faulty version of Weld currently in Glassfish is to moving up to Glassfish 3.0.1 nightly builds (update : 3.0.1 has been released and should be used) . A less bleeding edge solution would be to upgrade the version of Weld that is deployed on your current version of Glassfish by updating the weld-integration and weld-osgi-bundle jar files. However, one must be careful of the integration jar version as one of the major interfaces changed after the initial release of Weld introducing incompatibilities.

Updating the OSGI bundle is easy since it can be built from the Weld source code. Just download and compile it and locate the osgi-bundle.jar file.

We also need to grab a new version of the weld-integration.jar file. There are all sorts of versions of this file, but the one I found working for Weld 1.0.1.final was version 3.0.1-b11/.

I’ve already built the osgi-bundle and grabbed the integration jar and verified that they work so I’ve renamed and zipped them so you can just download and unzip them into the modules directory of your Glassfish v3 installation.

This is also a necessary step to get the Knappsack Java EE 6 demo project working under Glassfish. You can find more details on the server compatability page

FlutterCode.com released

I’ve been fairly quiet over the last couple of months as I’ve been working on a few items, working on a new site and working on getting two new Open Source projects final and out the door.

I’ve renamed Spigot to DataValve, and moved it to the new site FlutterCode.com which will also host my other project called Knappsack which is a set of Maven archetypes for Java EE 6.

The new site will be home to most of my tutorials, articles and other writings, as well as possibly some screencasts and even podcasts. It will in essence be a pure java development site. This blog will go a bit quieter and contain less development stuff, although most opinion will get put out here instead of over there. I’ll also be copying some of my tutorials over there from this blog.

I’m aiming to create a fairly cohesive tutorial site, aided in part by the Maven Archetypes which will give me a firm base onto which I can build tutorials without having to start from scratch, but one archetype is a sandbox Java EE 6 app with project configuration, a demo model and some test data. The sandbox app will let developers create a new skeleton java EE 6 application they can play with. Building on that, there is a sandbox-demo application which as an archetype that creates a full working demo CRUD application using Java EE 6 so developers can see how all the different pieces of Java EE 6 go together. It includes features such as conversations, JPA CRUD, page parameters, CDI injection and events.

Again, I have to say it, but Open Source is Hard. In the past couple of months, I have been working on a whole new site, getting 2 projects ready to roll with documentation and site content to boot as well as working a job, and having some kind of life.

Now it’s out, I can start to focus a little more on getting some more Java EE 6 tutorials and articles out.

A Guide to Spigot For Seam Developers

Note : Spigot has been renamed to DataValve.

(Edit : I renamed this post so it doesn’t seem like Spigot is just for Seam, Spigot can be used with different frameworks or without any at all. However, I wrote this post since Spigot is so familiar to the Seam EntityQuery that it should be easy for Seam users to get the idea)

Seam developers should become familiar with Spigot concepts fairly quickly since they are very similar to those found in the Seam EntityQuery which was one of the main inspirations for the framework. If you imagine taking the entity query class and splitting it in two, one part to keep hold of state and the other to actually fetch the data. The stateful part is the Paginator that keeps track of what the current ordering of the data is, what is the current page and how big the pages are. The stateless part takes the Ejbql and the pagination information and returns a subset of the data. Now imaging that the data provider has the JPA pieces taken out and replaced with an abstract fetchResults method. This method is implemented in subclasses for specific data providers for text files, sql queries, jpa queries, native jpa queries, xml files, comma delimited or just an in memory dataset.
Read More »

Spigot 0.9.CR1 released

Note : Spigot has been renamed to DataValve and is hosted over on FlutterCode.com.

It’s been a while since I’ve posted anything new as I’ve been busy with a new Open Source software project called Spigot. It’s a java library that sits between your application code and your data sources (Hibernate, JPA, JDBC or any arbitrary source of data) and helps with things like pagination and sorting using a common interface so you can switch out data providers and use alternatives.

For query language data providers, Spigot also facilitates excluding restrictions from WHERE clauses when parameters are resolved to null. Parameters are handled using parameter resolvers so there is more than one way to parameterize the query including EL expressions, reflection or a value map on the data provider.

Spigot also provides a few other add-ins like converting any dataset into an in-memory dataset that can itself be paginated and sorted and shared across an application (such as commonly used data in a web application). The IndexedDataProviderCache can give you random access into a dataset with caching and look ahead loading. This lets you hook a dataset with thousands of rows up to a Swing JTable with an instant response and a very small memory footprint since it doesn’t need to load all the objects at once as the provider will load the records as needed and cache the results. This is demonstrated in the Swing Demo in the download. There are also demos for Wicket and CDI with JSF.

You can ready about why I created Spigot in the documentation

Spigot is currently hosted on Project Kenai, where you can download the release, view documentation online or read about 10 ways Spigot helps developers.

Weld 1.0.1-CR2 is available

Dan Allen posted that the latest CR version of Weld is available. This should contain a number of bug fixes from the initial release of Weld, including the two problems I had with the request scope being available in EJB timeouts and problems with the ability to proxy stateless beans. This last bug was for me rather crucial since there was no easy way to implement DAO (just data management) type components with transactional annotations that could be injected into business logic beans. Without that, you end up having to write your own transaction handling code.

Also in the comments of the announcement, Max Anderson notes that the nightly builds of JBoss Tools 3.1 now supports CDI auto completion and JSF 2.0. I had a very quick look at it yesterday and it looks promising. I also tried it out with the latest JBoss 6 snapshot and am very pleased to say that the redeployment times on JBoss 6 are much faster and more in line with the performance on Glassfish which is something I have raved about.

I’ll be looking at it some more and probably write up a couple of tutorial posts.