February 2006

java.io in EJBs - WTF?!?!

So, the current project I am working on will be running inside of a J2EE container, behind some Message Driven Beans (MDBs). The requirement is that our application must grab some files from various locations… FTP servers, Content Management systems, file system shares, etc…

So, when the team member that is working on these components said that we cannot us the java.io package inside an EJB, my initial reaction was “BS! who says that?!?!”. At which point I was pointed at this:

From page 511, EJB 3.0 Proposed Final Draft - ejbcore:

  • An enterprise bean must not use the java.io package to attempt to access files and directories in the file system.

The file system APIs are not well-suited for business components to access data. Business components
should use a resource manager API, such as JDBC, to store data.

  • An enterprise bean must not attempt to listen on a socket, accept connections on a socket, or use a socket for multicast.

The EJB architecture allows an enterprise bean instance to be a network socket client, but it does not
allow it to be a network server. Allowing the instance to become a network server would conflict with
the basic function of the enterprise bean— to serve the EJB clients.

WTF is up with that!?!?!

I can understand the underlying concepts… managing resources can be hard, and J2EE is all about pushing the management of resources to the container.  Thats fine to an extent, but I have some issues with the above statements:

  1. It is too specific on the technology, but vague on the reason.  I’m sorry, but just because a technology is not “well suited” does not mean I “must not use it”.  There are situations where I may need to use it, but now it is a Taboo.  Doing a quick google indicates that there are a number of potential reasons, most revolving around blocking versus non-blocking operations, where blocking operations, such as reading from/writing to a disk).  I feel that as long as you understand and are prepared for the consequences, this should not be a problem.
  2. It is vague overall.  So, can I use this inside of a component, as long as it is not a “Business Component”?  And what does that really mean?  Can I use System.out?  What about Logging?  They use Java.io… are they OK?
  3. It has not been updated in EJB 3.0.  If this is such a problem, why has it not been updated to take into account java.nio?

I’m confused.  I would love to hear what other people think about this, as it does not make any sense to me.  Can anybody answer these questions?

I know for me, I couldn’t care less that the spec says don’t use java.io.  If you know how to use it, and are aware of what the issues are with using it, than use it.  Unfortunately, there is a political cloud over this.  There are people that believe that the spec cannot possibly be wrong.

If we do use java.io in our system, it will be inside of a component, not an EJB directly.  And if we have to we can always use java.nio :)

In the end, I feel that the spec is just poorly worded, and is in dire need of an update.

General
Java
Just Stupid

Comments (6)

Permalink

Ubuntu it is.

When I got my Dell Inspiron 8600 laptop back in Dec 2004, my intentions have always been to dual boot the machine, and try to make it primarily a Linux box.   I decided to go with old reliable Fedora, which at the time was at Core 2.  Well,  overall I was impressed, it had many great features and I was pretty happy with it.  Except for two things:  I could not get wireless to work (Intel PRO 2100 chipset), and the “media” buttons did not work.   I could live with the media buttons not working, as the only ones I really use are the volume buttons, and barely use those.  Wireless however is a problem.  A big problem.  I have wireless throughout my house, and it really was a pain to not be able to use it.  So, I went back to Windows as my primary system, and promptly forgot I had a linux partition (other than the fact that my 60GB hard-drive looked like a 10GB harddrive to Windows).
Since then, I have tried Fedora Core 3, as well as OpenSuse 10, both of which had the same problems.  Now, I did my tech-geek job and hunted for the right versions of patches and utilities to resolve these issues, and got close a couple of times.  But frankly, I am an application developer, and do not want to be a systems developer right now in my career.  I do not want to spend time trying to learn how to patch the Linux kernel at this time.  I expect my OS to just work and support me in a stable way, which though it may be sad to say, Windows does most of the time.

But, I still want Linux to work.  I want to be able to use it as my OS of choice.  And, as with most techies, want my freedom from the oppression that is the Microsoft EULA.   So, I installed Ubuntu 5.10 earlier this week.  And guess what… it works!  I downloaded the single disk, networked install disc, started it up and it immediately found my network and started to go at it.  I have had no problems with Wireless, and no problems with the media keys.  (My)Eclipse is installed, RadRails is installed, and everything works.  It rocks!  So now I need a VM Ware license so that I can keep a Windows XP “machine” around for testing, but move on over to the Penguin side for good.  At least at home. :(
As for now I have not decided if I will move my ancient desktop over to Ubuntu from OpenSuse 10… it seems to work… slowly.  As for my server (Fedora Core 3) it is stable and I have not needed it too much lately, so it will probably stay where it is.
So, a big “Thank you , you guys rock!” to the people behind Ubuntu.

General
Software Development

Comments (7)

Permalink

Java Performance Monitoring Tools presentation is up

On Thursday I had the opportunity to give a presentation, enititled “Java Performance Monitoring Tools” for my consulting company, Bass & Associates’, open house.  I had a lot of fun doing it, and even saw an old colleague who I had not seen for a while.

It is up on my presentations page (see menu bar at top of page).

General
Java
Software Development

Comments (1)

Permalink

Dynamically displaying pages in Rails

Rails is a great environment, but its conventions can sometimes cause you headaches. I’ve had one such headache for the last week or so now. I am trying load html content out of the database, based on the URI. In most environments this is easy. In rails it is easy too (ridiculously easy).

It is as simple as this:

a table:

the database table

routes.rb:

  1. ActionController::Routing::Routes.draw do |map|
  2. # Add your own custom routes here.
  3. # The priority is based upon order of creation: first created -> highest priority.
  4.  
  5. map.connect ‘:controller/:action/:id’
  6.  
  7. # default catch-all for URLs
  8. map.connect ‘:url’, :controller => ‘page’, :action => ‘view’, :requirements => { :url => /.*/ }
  9.  
  10. end

A model:

creating the Page model

And a controller:

Creating a page controller

  1. class PageController < ApplicationController
  2.  
  3. def view
  4. render :text => view_page(params[‘uri’]), :layout => true
  5. end
  6.  
  7. private
  8. def view_page(page_name = “”)
  9. @pages = Page.find_by_sql [“select * from pages where name=?”, page_name]
  10. if @pages.first
  11. @pages.first.html
  12. else
  13. “Could not find page ‘#{page_name}’”
  14. end
  15. end
  16. end

General
Rails
Ruby

Comments (0)

Permalink

Review: Practices of an Agile Developer

Matthew Bass recently [Link] posted a review of the new Pragmatic Programmer book Practices of an Agile Developer, by Venkat Subramaniam and Andy Hunt . I also had the honor of reviewing the book, and would like to add to what he said.

First off, I completely agree with Matthew’s comments. He has concisely summed up some of the same things that I like about the book, such as the bite-size nuggets of content that allowed me to easily review the book over my lunch break, without losing any of its essence and meaning.

One thing I really liked about the book was that it used metaphors and real-life examples extremely well to help explain the concepts in the book.

If you have ever attended one of Venkat’s NFJS presentations, than you are familiar with the delivery. Venkat is easily the best speaker I have ever had the pleasure of listening to. His clear style and humor are definitely present in the book.
I have been a huge fan of The Pragmatic Programmer since I first read it. This book has the same “this is right” feeling to me.

Agile
Books
General
Software Development

Comments (1)

Permalink