Monthly archives "March 2014"

A Visit to JavaLand

posted by Roberto Cortez on

JavaLand

During this week, more precisely between 25 and 26 of March the first edition of JavaLand came to life in a theme park called Phantasialand in Brühl – Germany. I only decided to go very close to the event, even after already discarded my presence. I’m glad that I was able to attend. Unfortunately for me, I was not able to enjoy the fullest of the first day due to a few bugs I had to solve in one of my work projects. Anyway here are my thoughts on some aspects of JavaLand:

Venue

I’m totally biased on the venue since I love theme parks! Thanks to the sponsors, we got to enjoy a few rides available in the park, like roller coasters, simulators and a few others, totally for free and no waiting lines! How cool is that? Take a look into Black Mamba. Phantasialand also have hotels where you can stay, so you got everything in one place. I actually choose to stay in an hotel outside the park to reduce costs, and it was good enough for me. Wi-fi was generally available and conference room sessions were good, you could see and hear the speaker properly.

Community Hall

The Community Hall was just amazing, lots of room, tables and chairs for you to hack, code, work or just hang out with your friends. The organization hit pure gold with the venue choice.

Sessions

Most of the sessions were in German. No surprise here, since the conference was held in Germany. Unfortunately, I don’t know how to speak German but for every schedule you had at least one english session. As I said before, I couldn’t attend many sessions on day 1, but the program seemed interesting enough. Day 2 had better content in my opinion. These are my top 3 sessions:

I did not see any recording cameras around, but maybe the content will be available as an audio format. I’m not sure. Need to confirm.

Food

JavaLand CupcakeIn the last few years I attended JavaOne and Devoxx, which are probably the top Java conferences around the world, but the food there totally sucked! JavaLand did it right! Awesome buffet, with several options during lunch, snack and dinner. They even have small chocolate cupcakes and I couldn’t stop eating them. By far the best food I had at a conference.

Community

The community was awesome! I have spent most of my time in the Community Hall, hanging out, networking and hacking with a lot of people. Several events were being held in the room, like the NightHacking Live Stream with Stephen Chin, the Java EE 7 Hackergarten with Arun Gupta or the Adopt OpenJDK supported by the London JUG. Thanks to Mani Sarkar I was able to checkout, change and build the JDK 8 and try the changes that I introduced myself to the JDK. Pretty awesome! I also won a brand new Raspberry PI courtesy of the DOAG e.V. SIG Java by answering a quiz correctly.

JavaLand Community

In no particular order, a special thanks for the following people that made my event memorable:

And many others…

Final words

JavaLand was well worth it. The general feeling was that the conference is established for many years, but was actually a first timer. The organisation completely nailed it every aspect and I’m definitely returning for a second event. A big thanks to the conference board: Fried Saacke, Markus Eisele, Tobias Frech, Alexander Neumann and the rest of the team for delivering this awesome event! Cya next year! #jatumba

Java EE 7 with Angular JS – Part 1

posted by Roberto Cortez on

Today’s post will show you how to build a very simple application using Java EE 7 and Angular JS. Before going there let me tell you a brief story:

I have to confess that I was never a big fan of Javascript, but I still remember the first time I have used it. I don’t remember the year exactly, but probably around mid 90’s. I had a page with 3 frames (yes frames! remember those? very popular around that time) and I wanted to reload 2 frames when I clicked a link on the 3rd frame. At the time, Javascript was used to do some fancy stuff on webpages, not every browser have Javascript support and some even required you to turn it on. Fast forwarding to today the landscaped changed dramatically. Javascript is a full development stack now and you can develop entire applications written only in Javascript. Unfortunately for me, sometimes I still think I’m back in the 90’s and don’t give enough credit to Javascript, so this is my attempt to get to know Javascript better.

Why Java EE 7?
Well, I like Java and the new Java EE version is pretty good. Less verbose and very fast using Wildfly or Glassfish. It provides you with a large set of specifications to suit your needs and it’s a standard in the Java world.

Why Angular JS?
I’m probably following the big hype around Angular here. Since I don’t have much experience with Javascript I don’t know the offers very well, so I’m just following advice of some friends and I have also noticed a big acceptance of Angular in the last Devoxx. Every room with an Angular talk was full, so I wanted to give it a try and found out for myself.

The Application

For the application, it’s a simple list with pagination and a REST service that feeds the list data. Every time I start a new enterprise project it’s usually the first thing we code: create a table, store some data and list some random data, so I think it’s appropriate.

The Setup

The Code (finally!)

Backend – Java EE 7

Starting with the backend, let’s define a very simple Entity class (some code is omitted for simplicity):

If you’re not familiar with Java EE JPA specification, this will allow to model an object class into a database table by using the annotation @Entity to connect to the database table with the same name and the annotation @Id to identify the table primary key.

Following by a persistence.xml:

Two of my favourite new features on Java EE 7: now you can run sql in a standard way by using the properties javax.persistence.schema-generation.* and it also binds you to a default datasource if you don’t provide one. So for this case, it’s going to use the internal Wildfly H2 database for our application.

Finally, to provide the list data we need to query the database and expose it as a REST service:

The code is exactly as a normal Java POJO, but using the Java EE annotations to enhance the behaviour. @ApplicationPath("/resources") and @Path("persons") will expose the REST service at the url yourdomain/resources/persons, @GET marks the logic to be called by the http GET method and @Produces(MediaType.APPLICATION_JSON) formats the REST response as JSON format. Pretty cool with only a few annotations.

To make it a little easier to exchange the needed information for the paginated list, I have also created the following wrapper class:

And we are done with the backend stuff.

UI – Angular JS

To display the data we are going to use Angular JS. Angular extends the traditional HTML with additional custom tag attributes to bind data represented in Javascript variables by following a MVC approach. So, lets look to our html page:

Apart from the Javascript and CSS declarations there is very little code in there. Very impressive. Angular also have a wide range of ready to use components, so I’m using the ng-grid to display the data and UI Bootstrap that provides a pagination component. The ng-grid also have a pagination component, but I liked the UI Bootstrap pagination component more.

There is something still missing. The Javascript file where everything happens:

The Javascript code is very clean and organised. Notice how everything gets added to an app controller, allowing you to have multiple separation of concerns on your business logic. To implement the required behaviour we just need to add a few functions to refresh the list by calling our REST service and monitor the grid data to refresh the view. This is the end result:

Java EE 7 - Angular - List

Next Steps:

For the following posts related with these series, I’m planning to:

Resources

You can clone a full working copy from my github repository and deploy it to Wildfly. You can find instructions there to deploy it. Should also work on Glassfish.

Java EE – Angular JS Source

Update
In the meanwhile I have updated the original code with the post about Manage Javascript dependencies. Please, download the original source of this post from the release 1.0. You can also clone the repo, and checkout the tag from release 1.0 with the following command: git checkout 1.0.

I hope you enjoyed the post! Let me know if you have any comments about this.