Skip to main content

Summary of August's Manchester Spring User Group Meeting

The August Spring meeting was held on Tuesday 11th August at the same venue as June's meeting. The location was the the excellent University of Manchester Core Technology Facility which has free parking immediately outside the building, just press the buzzer and mention the Spring User Group and they let you in. The evening was introduced by Guy Remond of Cake Solutions who laid out the agenda.

The first talk was by Cornel Foltea of Cake Solutions entitled:

Hello World! (OSGi debugging in IDEA)

Cornel started out by giving a little overview of OSGi including a walk-through of the layered approach that the Open Service Gateway Initiative takes. He pointed out that it's key objectives were:
  • modularization
  • versioning
  • services
  • access control
The key component of any OSGi system is a 'bundle' which get deployed into an OSGi container. A bundle can then be dynamically installed, started, stopped, updated and uninstalled. They are modular in nature 'assuming nothing' - they are a JAR file, with it's contents protected from access unless it explicitly exports it's services and declares that it needs to import services offered by other bundles. Multiple versions of the same bundle can exist in the application server without conflicting with each other. OSGi also provides a Service Registry so that bundles can register (export) their services for use by other bundles.

Then Cornel went on to talk about what OSGi features IntelliJ's IDEA currently offers (a MANIFEST.MF editor and OSGi facet detection) and how to create a "Hello World!" application OSGi-style. The heart of this is the BundleActivator interface that you need implement to provide start and stop methods called by the OSGi application server (make sure you have downloaded the OSGi framework jar and add it to your classpath first):
package com.cake.dmsd.primer;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class HelloWorldActivator implements BundleActivator {

public void start(BundleContext context) throws Exception {
System.out.println("Hello, World.");
}

public void stop(BundleContext context) throws Exception {
System.out.println("Goodbye World.");
}
}
Then you need to create the jar's MANIFEST.MF file to look like the following:
Manifest-Version: 1.0
Bundle-Name: Helloworld Bundle
Bundle-Activator: com.cake.dmsd.primer.HelloWorldActivator
Import-Package: org.osgi.framework;version="1.4.0"
Bundle-ManifestVersion: 2
Bundle-SymbolicName: helloworld
Bundle-Version: 1.0.0
Next he talked a little about setting up a remote server 'Debug Configuration' to allow IDEA to connect to the debug port of the dmServer (think this picture paints a thousand words!) - note the port number of 5005 and the fact that one of the parameters is -Xdebug:


Then he showed screenshots of shelled out to a console to start up the dmServer in debug mode by running:
./startup.sh -debug 5005
Once that was running the next step was to telnet to the dmServer running on the local machine and install the previously created bundle:
telnet localhost 2401
install
This step gives us a bundle ID (111 in Cornel's example) which refers to the specific instance of the bundle that we have just installed. This ID means that we can start and stop the bundle in the future using start 111 and stop 111 from the dmServer telnet console.

After Cornel's talk there was a little break which contained a mention of the Manchester Spring User Group sponsors: UMIC, Hays IT, Skills Matter, SpringSource & Cake Solutions and the new sponsor of the event: Keith Dauris of FDM Group (and it's associated FDM Academy).

The next talk was by Dave Syer and his talk was:

Spring 3.0 and Spring Batch Quick Tour

The first half of Dave's presentation was on the new features of Spring 3.0 and it was an excellent way to quickly get an idea of the type of stuff that's coming very soon. Spring 3.0 is the first version of Spring to only work on Java 5 and above, meaning that even more annotation support can be included. It's also introducing the Spring Expression Language (influenced by Unified EL++), full REST support and declarative scheduling & background task execution.

The Object <-> XML Mapping (OXM) has been revised to offer better support for REST stateless mappers and SQL XML access. The JDK PropertyEditors are being superceded by a revised binding & type conversion infrastructure. If you don't like writing your Spring bean configuration in XML then you are in luck with Spring 3.0 - you can now write it in Java (although I thought the idea of the config _not_ in Java was that you could change it without recompile? Maybe it would have been better to offer non-XML config via something like Groovy?)

Full REST support is now available (with a custom filter to help support PUT & DELETE) which includes annotations to be able to extract values from within the URL:
@RequestMapping(value="/rewards/{id}", method="GET")
public Reward reward(@PathVariable("id") long id) {
...
}
By using multiple @PathVariable annotations you will be able to offer some pretty 'deep' URLs, meaning that you won't be held back by the normal servlet mappings. Dave mentioned that someone was using some shell scripts consisting of wget/curl and pipes to create some pretty complex business logic. Non-HTML representations are also offered 'out of the box' so it's very easy to offer JSON, XML, ATOM, etc. without using complex URLs or query strings.

Scheduling has been given a complete overhaul in Spring 3.0, with enhanced java.util.concurrent support and a new TaskScheduler with triggers (a little like a simplified Quartz). There is a new @Async annotation (indicating that this method should be run in the background) along with an @Scheduled annotation for CRON-triggered methods.

Commons Attributes has now been removed along with traditional TopLink and Struts 1.x (subclass-style). Traditional MVC controllers are now marked as deprecated along with JUnit 3.8 support (as why would you not want to use JUnit the annotated way?) and several other outdated helper classes.

Expect a GA release of Spring 3.0 sometime after August, and a 3.1 release in Q4 2009.


Dave's second presentation was on Spring Batch, which he has been the project leader on for the past three years (version 2.0 was released back in April). He started with an overview of the architecture, saying that the Batch Infrastructure layer contains reusable low level stuff: flat files, XML, database configuration. The Batch Core layer contains the quality of service (QoS), audibility and management information and the Application is your business logic.

He said that in it's most basic form it was a "glorified state management system" and then proceeded to describe some of the key objects that make up the heart of Spring Batch (item oriented processing, the Step, Job & JobLauncher classes). The Quality of Service features are interesting as they allow you to detect job and item failures and then deal with them in one of three ways: try it again (transient), ignore it and maybe retry it later (Skippable), or mark it as needing manual intervention (Fatal).

Dave then gave a brief overview of a number of different strategies in which you can introduce multi-threaded behaviour to get your jobs done faster, these included:
  • Sequential Execution
  • Multi-threaded Step
  • Parallel Execution
  • Remote Chunking
  • Partitioning
Note: Please refer to Dave's slides for details regarding any of the above points...

Dave then gave us a little teaser with a run through of a rather useful-looking Spring Batch Administration interface, allowing you to view and manage your 'jobs' and the 'executions' of those jobs providing full details all the way down to stacktraces if the execution failed. This really did look like an extremely useful tool and one that will make Spring Batch much easier to 'sell' to management. Here are a few screenshots (kindly provided by Dave himself):




That was the official end to the evening, but SpringSource were buying the first round in the Bowling Green pub afterwards, so the majority of attendees carried on the discussions there (thanks for the beer SpringSource!).

Note: Both Cornel's and Dave's presentations can be found over on the Cake Solutions Blog.

Technorati Tags: , , , , , , , ,

Comments

Another very comprehensive blog, thanks Andrew Cake will be linking to it. Hope to see you in October where it looks like Rick Evans will be presenting. Subject matter and date will be confirmed in the next week or so on the Cake website.
Andrew Beacock said…
Cheers for the kind words Guy!