JDriven Blog

Day two of the SpringOne 2GX in Washington.

Posted on by  
Richard Rijnberk

It was a full day starting with breakfast and 5 one and a half hour long presentations followed by dinner and a keynote delivered by Adrian Colyer, CTO of SpringSource. The keynote was on how application architecture has evolved over the last 10 years towards what it has become today. We started out with a static frontend client that communicated with a service layer, which in turn persisted to a database. Nowadays we have rich clients, multiple services in our service tier that in turn connect to services, websockets and/or other data sources. He proceeded to show his application, slowly scaling it up from one isolated environment into a cloud solution and from there into a multi cloud solution using brokers for each cloud region. From this he explained the use of auto scaling workers in a message queue and the advantages this mechanism has in relation to bandwith, throughput and latency. During his presentation he used scriptIt, which is a new browser based javascript editor that was released recently. He was enthusiastic about it due to its ability to follow declarations and support for auto completion. Another tool he was adamant about was a REST service console that allows reading and the exercise of calls that alter the state of the service. It is a great tool for seeing what goes on under the hood. For the code featured in this keynote see: github

Continue reading →

Keynote SpringOne 2GX

Posted on by  
Richard Rijnberk

Juergen Hoeller Hoeller begint zijn presentatie met de originele driehoek van spring. Zijn verhaal beschrijft vervolgens de transitie die het framework heeft gemaakt sinds dat model naar een annotation framework. Hij legt de nadruk vooral ook bij de beschrijvende namen van de annotaties, en hoe ze zorgvuldig zijn gekozen om de code leesbaarder te maken. Hierbij gaat hij dieper in op een aantalannotaties zoals stereotypes, injections en ook parameter annotaties. Hierbij geeft hij aan het gevoel te hebben dat de kracht van deze annotaties nog steeds wel onderschat wordt. Hoeller verteld hierna hoe er in de laatste tijd is gewerkt aan de WebApplicationInitialiser om xml configuraties zoals de web.xml iets van het verleden te maken. Hij gaat vervolgens in op de @configuration annotation en de manier waarop in deze configuratie classes gescanned kan worden op het classpath om filters en beans te injecten in de app. Dit soort Java based configuratie zorgt er voor dat xml configuraties zoals de persistance XML niet meer nodig zijn.

Continue reading →

Grassroots Groovy: Parse XML with XmlSlurper from Java

Posted on by  
Hubert Klein Ikkink

We can introduce Groovy into our Java projects at grassroots level. Even if we aren't allowed to run the Groovy compiler we can use other ways to run Groovy code. As long as we can include the Groovy libraries as a compile dependency than we can already use Groovy from Java. In this post we see how we can use the power of XmlSlurper to parse XML from our Java code.

To execute a Groovy script from we can use a GroovyShell object and invoke the evaluate() method. The evaluate() method can parse a Groovy script as File or Reader object. We can also use a String value to be evaluated. The last statement of the script that is evaluated can be assigned to a Java variable. To pass variables to the script we use the Binding object. This is a map of variables and their values. We assign values to the variables in the Java code and in the Groovy script we can use the variable values.

Continue reading →

JAXB class generation using Maven

Posted on by  
Albert van Veen

There is a useful maven plugin to generate all our JAXB classes for us. This plugin can be executed during the generate-sources phase of our maven build. It can be very useful, especially in the first stages of our project when the design of our XSD may change frequently. We can just add the plugin configuration to the pom.xml of our project.

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>

    <configuration>
        <extension>true</extension>
        <args>
            <arg>-Xfluent-api</arg>
        </args>
        <plugins>
            <plugin>
                <groupId>net.java.dev.jaxb2-commons</groupId>
                <artifactId>jaxb-fluent-api</artifactId>
                <version>2.1.8</version>
            </plugin>
        </plugins>
        <bindingDirectory>src/main/resources/</bindingDirectory>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Continue reading →

Groovy Goodness: Create a List with Default Values

Posted on by  
Hubert Klein Ikkink

Since Groovy 1.8.7 we can create a list and use the withDefault() method to define a default value for elements that are not yet in the list. We use a closure as argument of the method, which returns the default value. We can even access the index of the element in the closure as an argument.

Besides the withDefault() method we can use the withLazyDefault() which is just another name for the same functionality. If we request a value for an index that is greater or equal to the size of the list, the list will automatically grow up to the specified index. Any gaps are filled with the value null.

Continue reading →

The Lean-Agile Connection

Posted on by  
Arthur Arts

Most people working in professional IT-driven companies, have heard about Agile, most people in professional companies have heard about Lean. Those who are interested in the subject, have found out that these two very popular phrases are actually closely related. So what is the relation between lean and agile? I'll try to briefly answer this question and will start with a little history.

Contrary to popular belief, the origins of Lean aren't in Japan, but derive from the Ford company in America and the work of the American statistician W. Edwards Deming. The following excerpt states the heart of his philosophy:

Continue reading →

Groovy Goodness: Getting the First and Last Element of an Iterable

Posted on by  
Hubert Klein Ikkink

Since Groovy 1.8.7 we can use the first() and last() methods on Iterable objects. With the first() method we get the first element and with the last() method we get the last element:

def list = 0..100

assert list.first() == 0
assert list.last() == 100

def abc = 'abc' as Character[]

assert abc.first() == 'a'
assert abc.last() == 'c'

def s = ['Groovy', 'Gradle', 'Grails', 'Rocks'] as Set

assert s.first() == 'Groovy'
assert s.last() == 'Rocks'

Continue reading →

Groovy Goodness: Using Groovy for Git Hooks

Posted on by  
Hubert Klein Ikkink

Git supports hooks, which are scripts that are fired when certain events happens. The scripts are simply shell scripts and we can use Groovy to run those scripts. We must make Groovy the script language with the hash-bang (#!) header in the Git hook script file. And then we are ready to go and use Groovy as the script language for the Git hooks.

Git hooks are placed in the .git/hooks directory of our project. We create an example script that will use growlnotify to create a notification message with information from the Git commit action. growlnotify is a command-line tool for Mac OSX to send out messages to Growl. Other operating systems also have tools to create notification message from the command-line.

Continue reading →

Gradle Goodness: Getting Announcements from Gradle Build

Posted on by  
Hubert Klein Ikkink

We can use the Gradle announce plugin to send announcements from the build process. We can send data to Twitter (I don't know if our followers are waiting for this, but if you want to you can), but also to notification applications on our local computers. For Mac OSX Growl is supported, for Linux notify-send and for Windows Snarl.

The plugin adds an announce object with the announce() method. The method accepts two arguments. The first argument is the message and the second argument is either twitter or local to indicate where to send the announcement.

Continue reading →

AngularJS made me stop hiding from JavaScript

Posted on by  
Emil van Galen

Like most Java developers I used to have a serious aversion to JavaScript. I was quite happy to delegate any 'scripting' stuff to fellow developers. At my current project, we initially decided to use the Vaadin web framework. It seemed the perfect choice for creating Rich Internet Application (RIA) user-interfaces without writing a single line of JavaScript. However what originally seemed to be a sensible choice, turned out to be a dead-end:

  • Vaadin is highly dependent on http sessions and as it turns out doesn't play well when being clustered.
  • No default support for server push; also the 'most stable' Vaadin add-on turned out to be quite unstable and incompatible with clustering.
  • No wrapper existed for v3 of Google Maps; as an alternative we used the OpenLayers Add-on instead. However this add-on turned out to be not so stable either and lacked the user experience of Google Maps to which users are accustomed to (like dragging the 'pegman' on the map in order to show street view).

Continue reading →

shadow-left