Hi,
 
I don't know if this is directly relevant to this mailing list, but I'd like to know if it's something that maybe is being considered by the JBoss team, or whether it has already been done before elsewhere and if so where.
 
I think a lot and maybe most EJB in development at the datamodel level could and should where possible be automated by defining it declaratively in XML and then generating everything else from that. The idea would be that you get all the base datamodel EJB code and tables generated from some XML type datamodel description.
 
Now I realise that at present there is the likes of Castor providing XML Schema to/from Java, and various tools allow you to generate Java/DDL from UML like MagicDraw or Rational Rose, or save it in XMI format and generate from there, but they don't seem to allow you to control what is generated through template files for example. They all seem to generate plain Java classes, whereas it would be nice to generate EJBs and in the format you would like.
 
In addition to the description of the attributes, it would be desirable to express the relationships between EJBs as can be done in XMI for instance.
 
YOu also would probably want to generate dependent objects as normal classes, not EJBs.
 
Once this the tables have been created, EJB base classes created, then the business logic EJBs can inherit from this 'datalevel' EJBs and you can update your model in XML and regenerate all the base classes/tables without worrying about merging regenerated code and your business logic.
 
I'll give a small example to illustrate more precisely what I mean.
 
Lets say we have an entity EJB called Foo.
 
It has 3 attributes X Y Z of type String
 
So you would then get
 
public interface Foo extends javax.ejb.EJBObject
{
    public String getX() throws RemoteException;
    public void setX(String newX) throws RemoteException;
    same for Y and Z......
}
 
public class BaseFooBean implements javax.ejb.EntityBean
{
    private String X,Y,Z;
 
    implementations of methods above
}
 
you would get the DDL to create the Foo table and perhaps stored procedures etc, also maybe a default deployment XML file.
 
and finally
 
public class FooBean extends BaseFooBean
{
    all your business logic methods you write here
}
 
Also probably a .bat or .sh script to run everything as a 'one button' operation.
 
Of course it would get more involved with relationships, and I haven't put in any base methods for finders,
creation, remove, load, store etc, just want to illustrate the simple hierarchy.
 
The generated code would always work first time once it was generated correctly the first time, match the tables, and save a lot of editing, compiling and debugging time.
 
In addition for relationships you could generate lazy navigation of those relationships etc, and your base classes and interfaces with default finder methods, ejbLoad, ejbStore etc etc.
 
Is there anything like that at present and is it something that has ever been considered by JBoss designers?
 
Any opinions on the pros and cons, feasibility or lack thereof of this approach?
 
Paul
 
 

Reply via email to