This is clearly feasible.  I have been working on it for my company for the
last 8 months or so.  We generate an entire wire frame application from a
high level UML class diagram using XMI & XSLT.  We generate EJBs, dependent
objects, database scripts, session facades, proxies (Sun Service Locator or
Business Delegate - can't remember their patterns), simple command line
clients and a full MVC CRUD implementation using JSP on top of Struts.  The
output of the build process right now is a .war and a .jar which we just
deploy and we're on our way.  We're just wrapping up a parallel effort to
generate .NET code in C# using the same technologies.

At this point I would say XSLT probably isn't the way I would do it again.
There is a new book on Java, XML and Program Generators and the author has
put a template engine which uses XPath for navigation of the input XML, but
I think the language is better than XSLT.  I don't have the url as somebody
is borrowing my copy of the book right now.  Other people have also made
open source template engines available.

We started off using all open source tools last summer, jboss when entity
beans didn't work.  Argo/UML when it crashed half the time.  Struts when it
was evolving rapidly.  Things have come a long way.  We've also added
support for several COTS modelling tools, app servers and databases to our
project.

I've written an article on some of what we did for Java Report, but I don't
know when they'll publish it.   I'd be happy to share more directly if
you're interested.

We have been working management to try and open source the work we have done
to date, with little luck.  Perhaps we should give another go as most of our
developers have been pulled off the development of our framework and onto
paying gigs.

Cheers
Jay

-----Original Message-----
From: Paul Hammond
To: [EMAIL PROTECTED]
Sent: 5/17/01 1:04 AM
Subject: [JBoss-dev] EJB generation

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
 
 

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to