You are currently browsing the archives for the java category


Die! Singletons Die!

Enough is sayed here at Pure Danger Tech. Please let those singletons die, however there is no real singleton with java anyway.

Where is inversion of control in JSR 296 (Swing Application Framework)?

JSR-296 will provide us with nice ressource management. You can get property settings like label texts, colors and other properties from ressource files easily:

ApplicationContext ctxt = ApplicationContext.getInstance();  
ResourceManager mgr = ctxt.getResourceManager();
resource = mgr.getResourceMap(HelloWorld.class);
String helloText = (String) resource.getObject("helloLabel", String.class);

But… what is this ApplicationContext.getInstance() static method call? Where is dependency injection? Look into the API documentation of ApplicationContext: it’s a global service locator. That means it provides a fixed bunch of services which are accessible by a singleton instance. You can of course use aggregation, sub-classing and delegation to extend it’s abilities but dependency injection is the train everyone jumps onto, ain’t it?

There is another issue that puzzles me: where are the interfaces? A framework whithout any interface? It’s even worse, ApplicationContext returns instances of concrete classes, not even abstract classes. So you’ll always get an instance of class RessourceManager. I you like to provide your own, you can only sub-class it, at least, RessourceManager is not final.

Can I have some dependeny injection, please? Picocontainer, Guice or Spring, perhaps? Yes, I can but it would be more nice, if RessourceManager, ActionManager and all other services provided by the framework would be interfaces and I could use any implemention I wish.

By the way, there is some dependency injection in the framework: you can inject property values into any awt component with RessourceManager.injectComponent. I hope the method name is not final yet, because I expected an component to be injected into some other instance, not something to be injected into a component.

Generate application.xml from ivy.xml for packaging an ear

After a lot of trouble with maven 2 I tried ant with ivy as a build and dependency resolving system. For multi-project builds with ivy you’ll have to dig into the documentation and ivy samples a little deeper but finaly I must say I like it. One show stopper for me was that maven 2 generated an application.xml from the pom. I use now a xslt stylesheet to make an application.xml from an ivy resolution report:

<target name="appxml" depends="resolve">
<property name="meta.dir" value="${basedir}/src/main/resources/META-INF/"/>
<property name="appxml.filename" value="application.xml"/>
<property name="appxml.file" value="${build.dir}/${appxml.filename}"/>
<ivy:report todir="${build.dir}"
<xslt in="${build.dir}/ivy.xml" style="ivy2appxml.xslt" out="${appxml.file}"/>

The stylsheet I use currently is simple but does it job. No support for web archvies and connectors yet, or any configuration but it’s doing it’s job:

<xsl:stylesheet xmlns:xsl="" version="1.0"
<xsl:template match="ivy-report">
<xsl:value-of select="info/module"/>
<xsl:template match="dependencies">
<xsl:template match="artifact[@type='jar']">
<xsl:value-of select="concat(@name, '.', @ext)"/>
<xsl:template match="artifact[@type='ejb']">
<xsl:value-of select="concat(@name, '.', @ext)"/>
<xsl:template match="artifact[@type='sar']">
<xsl:value-of select="concat(@name, '.', @ext)"/>


EJB 3.0 Annotations Cheat Sheet – Reference 1.2.2

The sheet got it’s own url here.

Minor update: added @AssociationOverride from Java EE 5 API documentation. Thanks to Jonathan O’Connor for catching this one.

Just download it from here as pdf or OpenOffice Document.


EJB 3.0 Annotations Cheat Sheet – Reference 1.2.1

The sheet got it’s own url here.

Updates to the EJB 3.0 Annotations Cheat Sheet.


  • Title changed to EJB 2.1 and Ealier Client View
  • Update @RemoteHome and @LocalHome according to the latest spec.
  • Fixed spelling and typos (NamesQueries / SINGLE_TABLE)

Thanks to Jonathan O’Connor for pointing out this errors.

Just download it from here as pdf or OpenOffice Document.

Preview of (old) cheat sheet.