Presentation Notes: TriJUG April 18, 2011

Presentation outline and notes/references for my  Traiangle Java User’s Group presentation given on April 18, 2011.  The slides used during the presentation are merely an instrument for me as the presenter; they aren’t available for download.  Below is the rough outline I (kinda) followed and at the bottom are references and helpful links.  Feel free to leave any and all candid feedback in the comments.  Thanks for attending! Continue reading

Environmental Config Files

I came across something disturbing recently and I want to get my two cents on the table because this isn’t the first time it’s come up. Several components in the project I’m assigned to store various configuration attributes in text files. Whether they’re name-value (properties) files or XML data, this is a good choice because it allows the customization of application behavior without code changes or redeployment … if you do it properly.
Continue reading

Too Many Choices?

Thinking about beginning a new JEE project is as unsettling as it is exciting. On the one hand, you’re going to get your hands dirty with some new and challenging business problem to solve, you can use the latest and greatest JVM and of course let’s not forget the choice of many excellent application/persistence/web frameworks. On the other hand, you have … the choice of many excellent application/persistence/web frameworks!

I think we can all agree that choice is good, but is the sheer number of non-trivial frameworks really unifying the java community, or are we breeding segments of the population who know only a subset of what’s out there?

When you’re an ASP guy, you pretty much have you work cut out for you. Same goes for the new kid on the block Ruby [on Rails]. But Java, in its maturity, has brought so many innovations to market that one could make an entire project out of evaluating frameworks for use in any given project!

The days of Struts & JDBC are pretty much over, kids. Do you use Spring at the web tier? How ’bout JSF or Tapestry or WebWork? Do you decorate with SiteMesh, or assemble with Tiles? Maybe you are into JSP includes or writing a lot of custom tags. Do you manage your middle tier with Spring, or opt for the latest appserver’s EJB3 implementation? It might seem like everyone is using Hibernate for persistence, but it aint the only kid on the block. TopLink Essentials is bundled with GlassFish and other EE5 offerings will be supporting JPA as well. This is just the tip of the iceberg.

How do you decide?

Accessing a JBoss EJB3 Session Bean With Spring

Spring and Hibernate have long been my choice of frameworks with which to construct maintainable, scalable middle-tier software. Spring promotes good OO design using loose coupling and provides excellent declarative transaction support. Hibernate is the persistence tool of choice for the open source community. Any sane person who programs this way will have given up on EJB long ago. Coarse-grained entities, tightly coupled service objects and XML deployment descripters a-plenty are enough to bring a guy to his knees.

But no more. The EJB expert group, now composed of some of the very creators of modern persistence framework, has bequeathed upon us something wonderful. The lightweight POJO programming model we have come to love is apparent everywhere in the EJB 3.0 specifiction (JSR-220), which was unanimously accepted by the JCP earlier this year. EJB 3.0 is just one goodie in the larger Java EE 5 (JSR-244) bag – but this post is going to be long enough as it is. Continue reading

Seam, EJB3 and Gavin

This afternoon’s festivities were highlited by a characteristically colorful presentation by Gavin King. For those who don’t know, Gavin is the creator of the Hibernate persistence framework which was aquired eventually by JBoss.

Gavin & crew demonstrated quickly but effectively the lovely synergy that has been brought to EJB3 and JSF by their newest creation, Seam. Seam can hardly be called a web framework — you wouldn’t recognize it as such what with its lack of, well, just about everything that you’ve come to expect from a web framework.

Seam throws away boilerplate code a-la Rails, but does so in a way that leverages a lot of the untapped power of EJB3 and JSF. Seam is all about Don’t Repeat Yourself (DRY). As such, we throw away form beans (a-la Spring MVC) and a whole lot of XML (in favor of annotations).

The most surprising theme that emerges from all of this is the rampant use of Stateful Session beans. You read that right – I said Stateful. Seam begs the question, “why on earth would I represent state in a database (slow is an understatement) or in HTTPSession (with no dirty checking) when I can use this lovely gift called Stateful beans?” He makes a damn good point. By representing web conversations as SFSB’s (which are POJO’s in EJB3, in case you’re wondering) you eliminate many of the headaches associated with web apps. Multiple tabs open in your browser? Piece of cake – each browser tab/session/window has a unique conversation (they’re stateful, remember?). Double submit? Ha! Don’t even try! Want to have a clean client redirect after performing some action, but still pass messages across? No problemo – you’ve got a lightweight stateful conversation behind you.

By logically grouping your flows into SFSB’s, you can leverage more sophisticated failover because the container dirty-checks each instance and replicates automatically. Try that with HTTPSession.

So, I will be doing a sandbox app soon with Seam, and I’ll post more as I know it. Till then, read all you can.

The Future of JBoss AS

You can’t really question the inertia behind enterprise development using POJO’s and lightweight frameworks.  Rod Johnson (of Spring framework fame) wrote the book about this approach, effectively putting the last nail in the heavy framework’s coffin.  This morning’s presentation by JBoss covered their take on this from a 5000-ft level and also described some of the new things afoot in v5 of JBoss AS.

JBoss is mutating their MicroKernel (heavily JMX based) into what they call the MicroContainer.  The MicroContainer architecture could be described by reading the outline of Spring’s core container and subtituting “Spring” for “JBoss”.  Indeed, they are not only building a lightweight DI framework; they are building their entire app server on it.  Cool.

JBoss has always been good about letting the developer/integrater customize the footprint of the server through configuration.  It looks like this is going to be even cleaner and better in v5, since the same DI engine which builds the server innerworkings can also assemble application components — all the way up through the presentation tier using Seam/JSF.

Things I Have Learned Interviewing Java Developers

I have been conducting interviews with Mid/Senior level Java developers, and I have learned some interesting facts about the language that I did not know.

  • If you use “==” to compare two objects such as Strings, your code will not compile.
  • The difference between a checked exception and and unchecked on is that you must handle a checked exception and you cannot handle an unchecked one.
  • Omitting the access control modifier from a method reverts to the default access control which is the same as protected.
  • To pass information from a Struts Action to a JSP, you set it in the response.
  • In an MVC architecture, such as Struts, the JSP’s represent the model.

Guys, if you are going to interview for a programming job, brush up on the fundamentals! May I suggest a certification or two; perhaps a black belt?

Updated 5/32/2006 -CB