2015 and gone…

2015 is coming to end, at least regarding work.

The last things i did in December where preparing system specification for a mobile app (targeting BlackBerry) and learning how to create, communicate and maintain good architecture in Munich with Gernot Starke and Peter Hruschka:


With Gernot Starke and Peter Hruschka

Not only i took home a lot of great books, insides, practical tips and nice CPSA-F certificate but a lot of motivation to apply the stuff i learned. The result went live today: biking2, Architecture and API.

The year started with a great 2nd edition of JavaLand with my colleague Silke:


2015-03-24_big

What changed quite a few things was meeting @LukasEder in person. He’s a really nice guy and very convinced and convincing for his product jOOQ. Though it took me some time to create the “perfect” setting for it in our company, i’m sure it already changed things for the better.

JavaLand 2014 brought also new reasons to play around with the images i’ve collected over ten years now on Daily Fratze. In March i’ve created a JavaFX mosaic generator.

I actually didn’t plan much conferences for 2015 but as i won a ticket to JavaOne in LavaLand: Who am i to let that go to waste?

Stefan Pfeiffer came up in April with the idea of a local JUG (Java User Group), aiming at the Euregio Maas-Rhein. What a great idea! Bert Ertman was our first guest and helped us the get the thing running. I’ve written several recaps about our EuregJUG events, read them here.

Thanks, Stefan. Although it wasn’t too easy between the two of us, I’m gonna miss your input but i know that you’re gonna have a keen eye on the EuregJUG:


2015-07-09_big

In the course of spring i was very proud to be featured with my NetBeans testimonial at Geertjan Wielangas blog at Oracle. Geertjan was also a much appreciated guest at the EuregJUG and provided a lot of his contacts to us so that we have a lot of interesting speakers coming up. Thanks Geertjan, it was a pleasure meeting you, all the times in 2015:


2015-08-25_big

The numbers of visitors at this blog are hard to believe for me. There are an average of ~500 people daily reading articles here. Thanks a lot! I hope they like the new theme i’ve written and installed in August.

Over the year I had so many great conversations on Twitter and via E-Mail with fellow developers from all over the world. For me all those conversations, tweets to articles, different opinions are really valuable and I’ve learned a lot from them, often that really know nothing, or at least not as much as i should. I’m really thankful for that:

Although not able to spell that right 😉

Come October 2015. Thanks to my awesome company ENERKO Informatik i was able to use the JavaOne 2015 ticket i won at JavaLand.

2014 was a lot of first times: First time America, first time JavaOne. JavaOne 2015 was just freaking awesome. I took a week off, flew to Los Angeles instead of San Francisco rented a car and drove to Las Vegas, Grand Canyon, Death Valley, up through the Sierra Nevada and straight through Yosemite Park to San Francisco:

14451707969717903060 14452254218275863085 14453983807893773121 1445226466433913094 14453166371926033103 1445317590185243114 14454000214251593134 14454707616546103143 14454712417139423148 14456430186724243179 14456430187855513183 14456589219351633200

The conference itself was just awesome. Content was great, as last year, but what was different was knowing many people, having dates scheduled and being invited to some parties. Those are just the shots i’ve taken for michael@dailyfratze, but there have been a lot more people i’ve met.

With Mark, Josh and Bruno, Alex and Marcus:
2015-10-25_big 2015-10-26_big 2015-10-27_big

All i can say, the Java community really rocks:


14458788008627263227

My plans for 2016: Keep on learning stuff, work on and with the EuregJUG, go to JavaLand 2016 and maybe one more conference, start teaching myself and my eldest son Scratch and then we’ll see. I’m still convinced i may have something to say in a talk but i’m not quite sure in which direction that should go.

Apart from that: René recently spoke about programmers who have a life separately from a command line interface or an IDE. I have. My life would have been nothing without my wife and family. Thank you, @tinasimons, for always supporting my crazy ideas and enduring my moods when i sleep to little and drink too much in front of the mentioned IDE.

| Comments (0) »

22-Dec-15


Spring 4.2.x, Spring Boot and the Stomp broker relay

If you’re using a StompBrokerRelay on the MessageBrokerRegistry, be careful with your dependencies:

If you’re using Spring Boot 1.2.x, you must have

<dependency>		
    <groupId>org.projectreactor</groupId>		
    <artifactId>reactor-net</artifactId>		
</dependency>

on the classpath, in case of Spring Boot 1.3.x, which depends on Spring 4.2 which depends on Reactor 2, it must be

<dependency>
    <groupId>io.projectreactor</groupId>
    <artifactId>reactor-net</artifactId>        
</dependency>   
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
    <version>4.0.31.Final</version>
</dependency>

in addition to org.springframework:spring-messaging respectively org.springframework.boot:spring-boot-starter-websocket otherwise you’ll end with a bunch of missing class exceptions: reactor.io.encoding.Codec in case of 1.2 and reactor.o.codec.Codec in case of 1.3.

I find this pretty inconvenient and i wish the web socket starter would include them.

Edit: Andy was so kind opening an issue for that topic: https://github.com/spring-projects/spring-boot/issues/4522. Stomp Starter would be equally useful.

| Comments (0) »

17-Nov-15


Documenting your API with Spring REST Docs

We’ve been using apiDoc.js in a project for a while. While the resulting documentation looks neat, it has several drawbacks in our Java project.

  • It depends on the full blown NPM stack, doesn’t fit well in a Maven build stack. It can be done via the grunt-maven-plugin and a gruntfile.js, but this is very hard to explain to Java only developer
  • Although the comment syntax looks like JavaDoc comments, it isn’t. And that’s a problem for Java 8 JavaDoc compiler: It fails on most of the “special” terms, so we ended up having several resources files next to our controllers, which contain the documentation. That actually defeats the purpose of apiDoc.js.
  • In the end: We are all lazy developers or at least forgetful, so if an API changes, more often then not, we forget to update the documentation

Enter Spring REST Docs. Franz has been tweeting a lot about it lately and after going 1.0, i definitely wanted to check it out.

The head behind Spring REST Docs is Andy Wilkinson and he has done an outstanding job, helping to document existing APIs or prototypes. The documentation alone should answer nearly every question you might have (it would have answered mine if i just had read it better).

I wish i could write a lengthy blog post how hard it was, to an API documentation to my biking Spring Boot demo project, but i can’t.

I basically followed the instruction to add the corresponding maven plugins in the right order as seen in my pom.xml, added an AsciiDoc template for the documentation and then started using my already existing Spring MVC Tests documentation my api:

The result is already online here: Guide and API of biking.michael-simons.eu, the code above creates this part.

I love the beauty of this concept: Leverage existing tests based on Spring MockMvc to generate a tested API documentation: If you add or remove fields, parameters etc. to or from your API, the test will break. Also, documentation and API are in the right place. The toolchain depends on AsciiDoc, but this can easily run with JRuby, so i need no external tooling for generating my application and provide a Maven (or Gradle) based solution for my developers.

One might say Spring REST Docs cannot be used on a whiteboard project or a project designed using WSDL or other tools, but i disagree: Sketching an API using Spring Boot doesn’t take much time and i can always put classes generated from WSDL into a Boot project, use them as parameters or return values and be good.

So if you’re wondering which tool to use to document your api, you should definitively check out Spring REST Docs.

| Comments (1) »

05-Nov-15


Building cloud native apps with Spring Boot in Aachens EuregJUG

This post has been featured on This Week in Spring – October 13, 2015.


euregjug-small

Stéphane Nicoll, working at Pivotal, using Spring since early as 2007 and creating Spring Boot with others since 2014 came over from Liege for the third talk at Aachens EuregJUG this year.

Stéphane had only two slides with him, the rest was live coding / demoing current and upcoming features of Spring Boot. I did take pictures, but neither Stéphane nor Stefan would be happy if upload them i guess, so the picture of the nice banner Stéphane prepared must be enough:


IMG_7621

The idea of the talk was using http://start.spring.io to get a Spring project up and running as fast as possible. The starter is actually the only generation of stuff there is: It generates a Maven or Gradle project configured to use Spring Boot Parent and all starters you selected. Everything after involves no generation.

The starter generator is actually itself a restful Spring Boot application and accessible via CURL, Web and REST endpoints. The REST endpoints are actually used by IntelliJ IDE or STS IDE for nice GUIs generating projects as quick as possible.

What i didn’t know: They’ve also enabled the actuator endpoints, for example the metrics. Nice to see, how the site is being used.

Stéphane showed us how Spring Boot takes opinionated decisions about configuring stuff and how it stays out our your way if you want something else by using security as an example. One cannot stress this enough: Nothing is generated, it’s just configured and for me, thats one of the greatest thing about Spring Boot for since i’m using it as early as version 0.5.

Another important point was the fact that Spring Boot incorporates the Spring IO Platform, a curated list of dependencies that work well with each other. My experiences is that this works really great. Also, you can update or downgrade single libraries if you must by setting just a property in your build file. I wouldn’t recommend it for the Servlet API, but for example changing database drivers etc.

A nice wow effect are the new devtools in upcoming Spring Boot 1.3. They provide a simple but powerful class swapping mechanism and an implementation of the LiveReload protocol. Cannot wait to try them out (as it happens, I’ve upgrade a new application of mine to 1.3.M5 to test the new jOOQ integration). The DevTools will go out of the way if you’re using a JRebel license or Spring Loaded, which is great.

At the end of the nice tour de force, Stéphane pushed the app to Pivotals Cloud Foundry without any changes to the build or code.

If you never used Spring, the talk had a lot of things to show. If you’re long time Spring user, you would be impressed how easy it has become since 5 years ago to deploy a Spring application. And for me, a long time Spring user and early Spring Boot adopter, it was nice seeing a concise presentation of what is possible.

One thought i had during the talk: Spring Boot has a curated list of dependencies, an embedded servlet container (Tomcat, Jetty or Undertow), one of the best dependency injection frameworks their is (Spring Core), for me the best way to interact with JPA (Spring Data JPA) and an actually working MVC framework (Spring MVC): It would be more than justified to call this a Spring Application Server instead of Spring Boot, but I was assured, that’s not gonna happen anytime soon 😉

As with the last time, i didn’t count the visitors, but Stefans picture give you an impression:

And here are some links and tools discussed in the Q&A:

How to support the EuregJUG

If you like those talks in your area: Speak about it, blog about it. Invite colleagues. Maybe leaf an Euro or two in the tip jar, so that we can provide you with a nice experience (drinks etc.).

Come to the monthly meet up in Bar Elementa in Aachen, meet fellow developers.

Don’t be afraid: Even if we blog in English and announce the talks in English, most of us speak German. But we strive to be open for all people in the Euregio and also want foreign speakers to have a clue what’s going on here.

Here are some more information about the EuregJUG Maas-Rhine. The date of our next talk will be announced soon, Bert Jan Schrijver from the NLJUG will speak about “Swimming upstream in the container revolution: Containerless Continuous Delivery”

| Comments (2) »

09-Oct-15


Super simple Java bean tester

This is not about bean testing is effective, right or whatever. Just assume you want your Java beans tested, for example to achieve full code coverage.

There are some solutions out there and I used to use the BeanLikeTester but the library and i have different opinions about the hashCode/equals contract so i decided to run my own in a new project.

This one conveniently tests all setters and getters:

import java.util.Locale;
import java.util.function.BiConsumer;
import org.joor.Reflect;
// If you have jOOQ on the path instead of jOOR
// import org.jooq.tools.reflect.Reflect; 
import org.junit.Assert;
 
public class BeanTester implements BiConsumer<String, Object> {
 
    private final Reflect r;
 
    public BeanTester(Class<?> clazz) {
	this.r = Reflect.on(clazz).create();
    }
 
    @Override
    public void accept(String p, Object v) {
	final String property = p.substring(0, 1).toUpperCase(Locale.ENGLISH) + p.substring(1);
	final String verbSet = "set";
	final String verbGet = v instanceof Boolean ? "is" : "get";
	try {
	    Assert.assertEquals(v, r.call(verbSet + property, v).call(verbGet + property).get());
	} catch(Exception e) {
	    e.printStackTrace();
	    Assert.fail(e.getMessage());
	}
    }
}

You’ll need jOOR to make this work. jOOR is a small but highly functional reflection API.

This is how i use it at the moment:

import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
 
public class BeanTesterDemo {
    static class Demo {
	private String attr1;
 
	private boolean attr2;
 
	private LocalDate attr3;
 
	public String getAttr1() {
	    return attr1;
	}
 
	public void setAttr1(String attr1) {
	    this.attr1 = attr1;
	}
 
	public boolean isAttr2() {
	    return attr2;
	}
 
	public void setAttr2(boolean attr2) {
	    this.attr2 = attr2;
	}
 
	public LocalDate getAttr3() {
	    return attr3;
	}
 
	public void setAttr3(LocalDate attr3) {
	    this.attr3 = attr3;
	}	
    }
 
    @Test
    public void beanShouldWorkAsExpected() {
	final Map<String, Object> values = new HashMap<>();
	values.put("attr1", "foobar");
	values.put("attr2", true);
	values.put("attr3", LocalDate.now());
 
	values.forEach(new BeanTester(Demo.class));
    }
}

| Comments (0) »

01-Oct-15