Friday, January 30, 2009

Goodbye to the old...

When I first started using Geronimo (the Apache JEE server), it was on version 'point something'. And, I needed to parse XML messages being sent from a browser to servlets.

So, I used JDOM. It was fairly simple to use and the JDOM libraries were included with Geronimo.

That made things very simple. All I needed to do to parse the XML messages was put something like this in the doPost method:

Reader reader = request.getReader();

try {
SAXBuilder builder = new SAXBuilder(false);
Document doc = builder.build(reader);
Element root = doc.getRootElement();


Then, to get values out of the document, I wrote a number of wrapper functions like getString, getLong, getX - to convert the values in the XML document into something useful (something other than strings).

But, when Geronimo went from version 1.x to 2.x, they dropped the JDOM library from the assembly - And I started to have to include it myself.

Recently, I finally got tired of having to add the library myself and started to look for alternatives to using JDOM.

Enter W3C...

So, now I get to change a bunch of servlets from the code above to this new version:

Document document = getXML(request, dbf);

Ok, so that wasn't quite all that I did. That 'getXML' function isn't included with the W3C's DOM classes. I had to write it myself. And, here it is:

protected Document getXML(HttpServletRequest request, DocumentBuilderFactory dbf) {
Document document = null;

try {
DocumentBuilder db = dbf.newDocumentBuilder();

BufferedReader in = request.getReader();

String input = "";
String xmlText = "";

while((input = in.readLine()) != null) {
xmlText = xmlText + input;
}

System.out.println("Received: " + xmlText);

InputSource source = new InputSource();
source.setCharacterStream(new StringReader(xmlText));

document = db.parse(source);
} catch (Exception e) {
System.out.println("Exception: " + e.getMessage());

e.printStackTrace();
}

return document;
}

Now, that is much bigger (as far as lines of code) than the old way. But, by putting it into a function - you can't tell. And, once I am done with all of the change over, I will be able to get rid of that extra JDOM dependency.

Plus, along with finding how to change over to use the W3C's DOM, I also found the XPath libraries. So, I was able to change all of my XML to use real, properly formed documents. What I had been doing before was storing all of the real information in attributes of a single element.

Bonus!

Take a deep breath...

Well - I have been slowly trying to get myself accustomed to the idea of social networking over the internet.

This blog was my first tentative step.

Then, I let myself get a twitter account - I don't plan on posting anything just yet. That may change.

But, I finally got around to reading other people's blogs.

And I realized something.

I have a long way to go to get my blog to be what I want it to be.

So hopefully this is a changing point. I hope that from now on, this will become a blog that someone else would actually follow.

Wish me luck.

Wednesday, January 28, 2009

Tools holding you back...

I have gotten too used to working with tools and skipped over learning how to build java artifacts by hand.
And now, I am starting from scratch on my new project.

Which isn't such a big deal. Using Eclipse, I started creating my WAR file - no problem.

But, I want to use Maven to manage the project parts. Including creating the database pools.

So, I finally -have- to learn how to use Maven my self.

Yay!

(No, really - Yay. Seriously).

Monday, January 26, 2009

Wait, I think I saw it move...

There actually has been (a very small) step forward.

I have one web service and one entity written.

(One down and how many to go?)

Now I have to put it into a maven project and start setting up unit testing.

And then write the rest of the General Ledger.

Piece of cake.

(Maybe pie - pie is a little trickier to make than cake).

Sunday, January 11, 2009

Nothing like starting small...

I had nearly forgotten what it was like to start from scratch.

Actually, I think that I did forget what it was like to start from scratch.

I have been programming professionally for twenty years now. And except for toy projects - only about three years of that time was spent working on projects that started in my head. Everything else has been upgrades and changes to significant code bases started by someone else.

And even the current focus of my professional work (which started in my own head) is two years since its start. Even it feels like working on an established code base. Many of the decisions that were made on design/implementation choices were just the farthest reach of what I knew how to do.

Now, I know a lot more than I did then - And that makes things more complicated when deciding which approaches I should use for AccSys.

Well, the going is slower than I thought it would be -

But it is going!

Finally (geeze).

It's time to start...

Well, I haven't really had a chance to do the kind of design that I hoped on my G/L - But, time keeps slipping by.

So, I'm going to go ahead and start work (using the semi-congealed design that is floating around in my head). And, as I have time, I'll continue working on the formal design.

(Note to self: I should really use this new beginning as an opportunity to do test driven coding - rather than trying to do all of my testing by hand after the work is finished).