Creating different Websocket Chat Clients in Java

Having written two articles about different websocket based chat server implementations in Java, I was recently asked how an implementation of the client side would look like in Java. That’s why I added this article to demonstrate how to create a websocket chat client applications within a few steps with the Java API for Websocket. In the following tutorial, we’re going to write a text-based chat client for the console first and afterwards we’re going to program a chat client with a graphical user interface, implemented in JavaFX. ...

November 9, 2014 · 10 min · 1937 words · Micha Kops

Creating a XMPP Chat Bot with Apache Camel

Apache Camel not only is one of my favourite frameworks ever but it also allows the humble developer to create a full blown chat bot within a few lines of code and using the Camel XMPP component. In the following tutorial, we’re going to create a simple chat bot and since Atlassian’s HipChat basic plan is now free for unlimited users, we’re using HipChat as our play- and testing ground for the bot. ...

October 12, 2014 · 4 min · 829 words · Micha Kops

Using jOOQ and Build Helper Plugin to Generate Database Metamodels with Maven

When you need to derive meta-models from existing databases and want to create type-safe queries with an elegant, fluent-API, jOOQ definitely is a tool to consider here. In the following tutorial I’d like to demonstrate how to integrate the jOOQ meta-model generator into a Maven build using the jOOQ Maven Plug-in, the Build Helper Maven Plug-in and Maven profiles to finally create a running application to query an existing RDBMS using such a generated meta-model. ...

June 10, 2014 · 7 min · 1363 words · Micha Kops

Allocating available random Ports in a Maven Build

Recently in a project I encountered the following problem: The development team used Git with a branch-per-feature-like workflow and the integration server, Bamboo in this case, was configured not only to run the integration-tests for the master-branch but also for every change in a feature branch. As the team developed a Java EE web application ports like 8080 occasionally were already bound and builds failed. I knew a plug-in for Jenkins CI I to search for available ports and assign them to a build variable but I wanted to control such information directly within the Maven build life-cycle so I searched and finally found Sonatype’s Port Allocator Plug-in for Maven. ...

May 7, 2014 · 6 min · 1074 words · Micha Kops

Running JavaScript Tests with Maven, Jasmine and PhantomJS

Sometimes in a project there is the need to run tests for your client-side code, written in JavaScript from a Maven build. One reason might be that Maven manages a complex build life-cycle in your project and you need a close integration for your JavaScript tests, another one might be that you’re in an environment where it is complicated to install and manage additional software like an integration- or build-server. ...

May 4, 2014 · 5 min · 938 words · Micha Kops

Using Apache Avro with Java and Maven

Apache Avro is a serialization framework similar to Google’s Protocol Buffers or Apache Thrift and offering features like rich data structures, a compact binary format, simple integration with dynamic languages and more. In the following short five minute tutorial, we’re going to specify a schema to serialize books in a JSON format, we’re using the Avro Maven plugin to generate the stub classes and finally we’re serializing the data into a single file. ...

March 8, 2014 · 3 min · 573 words · Micha Kops

Writing Java Integration Tests for MongoDB

MongoDB is matured, document-oriented, cross-platform NoSQL database system with drivers available for a bunch of different programming languages. In the following short examples I’m going to write some integration tests for MongoDB using the MongoDB Java driver and the Flapdoodle library to create an embedded MongoDB instance for testing. We’re going to write tests for a simple persist-and-query scenarion and for a map-reduce function and in addition I’m going to show how to bind the start and stop of a MongoDB instance to a Maven goal using the embedmongo-maven-plugin. ...

October 16, 2013 · 8 min · 1585 words · Micha Kops

Filtering Source Files using the Templating Maven Plugin

The Templating Maven Plugin looks useful if one needs to copy and to filter source files in a project e.g. to add property values from the build environment to a class. For a short demonstration I’ve added the following short snippet. Dependencies Only one dependency needed .. simply add the following snippet to your pom.xml <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>templating-maven-plugin</artifactId> <version>1.0-alpha-3</version> <executions> <execution> <id>filter-src</id> <goals> <goal>filter-sources</goal> </goals> </execution> </executions> </plugin> </plugins> </build> ...

September 3, 2013 · 2 min · 215 words · Micha Kops

Continuous Deployment using GlassFish, Jenkins, Maven and Git

Recently I needed a quick solution to deploy a Java EE 6 web application on a GlassFish instance automatically and subsequent to a successful build of the project on the integration server. It took only a few steps using Jenkins, Maven and the Cargo plugin and I’d like to share this quick solution with you here. Prerequisites We need the following software installed and configured: Git Jenkins / Hudson + Git Plugin installed Maven 3 GlassFish 3.1 JDK 7 ...

May 29, 2013 · 6 min · 1202 words · Micha Kops

Creating slim Database Projections using JPA2 Constructor Expressions

One common question that you may encounter one day when using object-relational-mapping in your application is how to slim down data that you’re retrieving from the persistence layer down to a specific subset for your use-case in an efficient manner and without using complex additional mapping frameworks. In some situations you might declare lazy loaded fields but another approach that I’d like to share with you here are JPA2 constructor expressions. ...

April 14, 2013 · 9 min · 1744 words · Micha Kops