Life Codecs @ NamingCrisis.net

Ruminations. Reflections. Refractions. Code.

May 3, 2009 - arts

“Visions”, an album by Ade ISHS

Disclaimer: I know Ade personally. Though I can’t handle crappy/mediocre music, from friends or foes!

“Visions” is Ade’s first solo album. Ade’s an independent musician based in Melbourne, Australia. The album is a collection of 9 beautifully composed piano pieces. My personal favourites are “Birth of Love”, “Sky” especially the second half of the composition, and “Rain 1”. The pieces are pleasant, relaxing, ambient but non-intrusive, and at times very inspiring (for one thing it digs out my wish to learn a musical instrument every now and then!). On average, each piece runs for about 7 minutes, and it is easy to sense the effort and love that has gone into the album’s creation. Note that although this is his first solo, Ade is by no means new to the music scene, having been involved in various events previously.

I highly recommend “Visions” if you like instrumental music. You can find out more about Ade and “Visions” at Ade’s website. In the spirit of fair use, trust, and freedom of platform choice (yay!) – Ade’s made sure the music is DRM-free.

Finally, only peripheral to this – but nevertheless quite interesting to geekoids and musicians alike – is that Ade’s Computer Science PhD is on Music Information Retrieval – so yeah, he likes his music :-).

Apr 27, 2009 - poetry

Bad Browser Haiku

Yes, I have nothing better to do. Enjoy the following haiku, which is potentially a pseudo-ku (not to be confused with Sudoku – gosh I am funny :P!), though I tried to stick to the rules and spirit of it.

1
2
3
Fox on fire, why, how.
Script gone rogue, Face... book, so cold.
Kill... the tab. Okay.

Yes, poetry is like code, and vice versa ;-).

Apr 25, 2009 - software dev

Spring 2.5 + EJB 3 Integration

Yes, yet another post on the topic so talked about on the Web (like a year ago or so anyway!). This is mostly for my benefit and summary though – haven’t even written code to test it myself, but here goes. Spent a few hours exploring integration alternatives just now, basically EJB 3 DI is great, but a glaring thing that’s missing is injecting POJOs into it, which Spring does quite well – sure in both cases the “POJOs” are managed by containers, but hey, nothing’s perfect, yet. To summarise, here are the 2 major integration scenarios and solutions:

  1. To inject Spring Beans into EJBs (and bootstrap Spring app context(s) from within EJBs!) is simple enough, we use:

    Spring Docs, Chapter 18, EJB 3 Integration

    This actually handles bootstrapping (read up the doc on how it does it), which is tricky in EJB modules, since there’s no standard EJB context listener mechanism as there is for web containers. Many app server vendors do have EJB module lifecycle hooks/interfaces you can implement – but obviously they’re proprietary and make your app less portable, so I’d rather avoid them if I can, I still don’t see why this feature isn’t part of the spec… clearly there are use cases, and clearly since there are non-standard implementations, it’s feasible to do and define behavior for.

    • The other way around is a bit tricky, i.e. we now need EJB container-managed objects (e.g. entity managers, EBJs, resources, etc.) injected into Spring Beans in the XML file. In this case those resources need to be registered in the JNDI ENC (still figuring out EJB context vs. global) and in the Spring XML a JNDI lookup is done for the name it was registered with, and then injected to the relevant bean via a bean-ref. A ‘lookup-then-inject’ Spring XML config example can be seen here (note dataSource JNDI look-up and inject):

      Spring and JNDI (Tomcat or Jetty)

      Registering the container-managed objects in the JNDI can be done via EJB 3 interceptors, for example, a use case is having Spring-managed DAO beans, but EJB-managed Entities/Persistence Units: let the interceptor have an annotation

      @PersistenceUnit(unitName="bar", name=”barEntityManagerFactory”)

      – which receives the container-injected persistence unit and then registers it into the JNDI registry keyed by the name “barEntityManagerFactory”. The Spring XML config will need a bean created through a JNDI look-up of “barEntityManager”, and inject that in to the DAO Spring-managed bean.

      Lots of repetition up there! (Note I said it was for my benefit :P).

Now I can finally watch some Naruto!

Apr 24, 2009 - software dev

JBoss 5.0.x (and 5.1 Beta?) and JPA Persistence Units

After much messing around, I finally have my sample EJB 3 app working, but on Glassfish!! I started off with JBoss, and may still go back to it once they decide on better handling of persistence units, and not reload/load it regardless! Too complicated for me to explain, check out these links which summarise it in depth (they speak about Seam, but refer to the same issue I’m babbling about):

http://relation.to/Bloggers/JBossAS5AndGlassFishSupportAddedToSeamgen

http://code.google.com/p/seaminaction/wiki/DeployingToJBossAS5

Basically I have a common domain-model jar which I wish to treat as a persistence unit used by both my EJB and WAR in the same EAR.

And after hours of tweaking and messing, this is my successful test output:

1
2
3
4
5
6
7
8
9
10
Creating...
Data Value=JustCreated!!

Retrieving...
Data Value=JustCreated!!

Updating...
Updated Data Value=JustUpdated!!

Deleting...

Ah, the joys of development. Actually that’s a pretty decent test case, it’s a servlet that’s got an EJB3 instance injected, which in turn has an EntityManager instance obtained via the JNDI name of a configured JTA XA MySQL datasource injected. What a mouthful!