SpringSource – proving once again Java doesn’t get the web

I just read an article in a java trade mag entitled: SpringSource CEO: “The Future of Enterprise Java is Clear and Bright”

The premise sounds positive.  Basically they took OSGI, Spring and threw it on Tomcat as a web server.  The idea of being able to deploy OSGI bundles with the bag of beans development style of Spring is really compelling.

What this negative post is about is how they still don’t get the ‘web’.  My biggest issue with Java web development is that not enough attention is paid to modern web basics.  The very first thing that I noticed on the SpringSource website was the 15 year old style url.

http://www.springsource.com/web/guest/home

what is with the /web/guest/home for the homepage?  That is really bad SEO mojo

The idea of bundles that you can drop in for added functionality is fantastic, but you hit an ugly query string laden url like:

http://www.springsource.com/repository/app/library/version/detail?name=org.apache.myfaces&version=1.2.2

as opposed to the far more buzzword complient library of plugins for something like django:

http://djangoplugables.com/projects/django-compress/

While the Java page shows you the really easy lines of Maven xml to paste into your pom, the python based django system talks about the usefulness of the actual bundle you are looking at.

And compare the old school search page of:

http://www.springsource.com/repository/app/search

to the happiness of a large input box with realtime results on:

http://djangoplugables.com/repositories/

At least this is better then the time I read the Jython website and was greeted by a ‘blink’ tag

Rest as a boring servlet

A coworker whipped up a generic REST interface for any Ruby on Rails activerecord (data model).  What he described (in 5 minutes) was a nice implementation.  I wanted see how the generic django REST interface was coded.

http://code.google.com/p/django-rest-interface/

I was pleasantly surprised to realize that they Python developers simply used the normal form processing to handle rest and didn’t invent a new paradigm.

On an early project we tried to implement RESTlet for a java based REST application.  Under load we saw some strange problems and the code was reverted to normal servlets without too much pain.

The beauty of REST is its simplicity, yet there is so much energy being expended to ‘simplify’ it.

The real magic is to standardize on sending XML or JSON rather then url encoded data of an http form POST.

Motocycles and Python turn toil into joy

So today started out great.

Temperatures in the 80′s, so I took the kiddies outside. I put my cellphone on the trunk of my sisters’s car, put the kids on their bikes, put skates on my feet and rolled out to enjoy the day.

Things were going well with my littlest one making turns at each end of the block. My sister pulled up and shouted some encouragement as she drove past. I waved and noticed my black cell phone on the white trunk of her car!

I started to skate hard, but I couldn’t leave my girl in the street. I shuffled the girls back into the house and summoned the boy to watch them and tore off after my sister. I searched all the likely routes she would have taken but could not find it.

I called her and found out where she went and was determined to look again.

At this point I was pretty upset about this and feeling down.

So I got on my motorcycle and started looking for it. I rode a block at a time and dismounted to look. After about 15 minutes I realized it was looking pretty grim. I also realized I was out on my bike on a beautiful day, and any day you ride simply isn’t that bad.

I had a similar occurrence with python the other day. I had to scrape some data out of a nasty, IE only, webapp. It was pretty ugly but I got into writing the app as a pyunit test case and using assertions to ensure I got all the data. The difficult nature of the data coming in made me appreciate just how much you can do with test cases. The scraping task was about as pleasurable as looking for my cellphone across town.

But at least I got to do it in python and enjoy the ride!

csv to xml via python

Today at work our main Flash developer asked me about expanding his skills and learning either Ruby or Python. My personal preference is towards python but ruby has its place. Flash is really doing well in the Java/Enterprise space lately so I went that way.

Most of the Flash backend in our work is xml based so XML was on my mind anyway. Recently we needed to mock up a xml data data file for a project while the real APIs are being completed. We had the data in a csv file so we asked some developers to whip up a xml file.

As I started writing up the ticket I started thinking it would be easier to just do it myself.

Given the speed of python development I was right!.

#!/usr/bin/env python
"""
cvs2xml.py

Created by Aaron Held on 2008-04-11.
Make the xml from the csv using dom and other three letter acronyms
"""import sys,os
import unittes
import csv

from pprint import pprint
import xml.etree.ElementTree as ET

class Cvs2xml:
    def loadCSV(self):
        """Load the data and return a list of maps"""
reader = csv.DictReader(open(r"input.csv",'r'))
        rows = []
for row in reader:
            rows.append(row)
return rows

def mappings(self):
        """
        Map csv file to xml field names
        """
mapping = { 'id':"store_number"
        return mapping

def createXML(self,listofrows):
"""Turn lists into xml
"""
root = ET.Element("stores")
for row in listofrows:
store = ET.SubElement(root, "store")
for xml_field in row.keys():
csv_field = self.mappings().get(xml_field,xml_field)
ET.SubElement(store, xml_field).text = row.get(csv_field,"")
print(ET.tostring(root))
#tree = ET.ElementTree(root)
#tree.write("output.xml")

class Cvs2xmlTests(unittest.TestCase):
def setUp(self):
pass

def testRun(self):
'''Lazy way of main()'''
cvs2xml = Cvs2xml()
rows = cvs2xml.loadCSV()
cvs2xml.createXML(rows)

if __name__ == '__main__':
unittest.main()