Bean Builder I: Requirements

I use and build Java Beans all the time. Call it POJOs if you want. With Spring, JSF, Swing or NetBeans RCP programming, for instance, I have to use and build Java Beans again and again. And then I have to maintain them, which is even worse.

Things get worse if I want to use a binding library, because most of those expect the properties of my Java Beans to be bound properties, and I have to use PropertyChangeSupport (or SwingPropertyChangeSuport) so that listeners are notified of changes in my properties.

And, you know what? Enough is enough: I won't write a single Java Beans anymore. I'm tired of writing them.

And this is the reason why I've just created the BeanBuilder project at Kenai, a project for generating JavaBeans automatically from a specification.

Requirements

Before I write any code let me clarify my requirements (new requirements are greatly welcome, of course). Here we go:

Requirements for BeanBuilder itself

  1. BeanBuilder will have as little dependencies on other things as possible. I don't want tons of libraries around.
  2. BeanBuilder will be integrated with Ant, of course, so that I can quickly regenerate my JavaBeans at will.
  3. BeanBuilder will be integrated with NetBeans, my IDE of choice, so that I can quickly regenerate my JavaBeans at will from the specification. Integration with NetBeans will be transparent, and I'll be able to use generated JavaBeans directly in my code, with autocompletion and all.
  4. Integration with NetBeans will be so transparent that the JavaBeans will be regenerated automatically for me whenever the specification file changes. I don't want to manually do it.

Requirements for the generated JavaBeans

  1. BeanBuilder will generate code with no dependencies at all, but for the JDK6 classes. I don't want tons of libraries around when using the generated Java Beans.
  2. Generated JavaBeans will implement java.io.Serializable.
  3. Generated JavaBeans will optionally have bound properties, either with PropertyChangeSupport or with SwingPropertyChangeSupport.
  4. BeanBuilder will not be able to generate IndexedPropertyChangeEvents, because I think these are just plain wrong. Instead it will be able to fire property events when the contents of any collection are changed.

Requirements for the specification file

I think I will specify JavaBeans properties using XML Schema files. These are my reasonings:

  1. If I generate JavaBeans with JAXB then I could serialize a tree of JavaBeans to XML very easily!
  2. JAXB annotations are included in JDK6, so I'm safe with dependencies.
  3. I know XML Schema.
  4. XML Schema is more versatile than, say, Relax-NG. WSDL files use XML Schema, for instance. So I could even generate JavaBeans from WSDL files.

Anymore, anyone?

If you have suggestions for new requeriments talk now! Either leave a comment or add a new feature request at the BeanBuilder Issue Tracker.

Happy Bean-Building, Antonio

blog comments powered by Disqus