Welcome NONE ! 18 Members Online
Messages  
Advanced Search     
Groups > Expresso User discussions > Eclipse, DPTK and automatic code generation Start New Topic
  Post New Message
eForum Reload

Discussion Thread:   Thread Rank (Vote)


Eclipse, DPTK and automatic code generation Posted by  rdavidovich  at 2004-07-01 06:51:46 Reply
Hello,

I recently found a plugin for Eclipse made by IBM alphaworks called: "design pattern toolkit".

It implements MVC for automatic code generation. The model is a xml-like file describing anything (a DB schema for instance), the view is a set of templates (quite similar to a mix between XSL and velocity) and the controller is a file saying what to do (order of file generation, what files to generate, where to do it, etc).

I started working on it for generating the CRUD part of an application from an XML DB schema (schema, dbobjects, controllers, struts-config.xml, validation.xml, JSPs and unit tests).
Once the templates and the controller are ready, it generates the whole app in seconds (and it actually works).

I've already done the schema, schema test and DBObjects. I'm currently working on the controllers.

If someone has good test cases for DBObjects and Controllers, and can post them, it would greatly help.

If someone wants to contribute I'll be glad to coordinate the project.

here is a sample on how looks a template file (for the schema in this case)

package <attr node="/app/xml" name="pkg"/>;


import com.jcorporate.expresso.core.db.*;
import com.jcorporate.expresso.core.dbobj.*;

/**
* <p>Title: <attr node="/app/xml" name="name"/>Schema</p>
* <p>Description: <attr node="/app/xml" name="description"/></p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: <attr node="/app/xml" name="company"/></p>
* <p>Date: <attr node="/app/xml" name="date"/></p>
* @author <attr node="/app/xml" name="author"/>
* @version <attr node="/app/xml" name="version"/>
*/

public class <attr node="/app/xml" name="name"/>Schema extends Schema{

private static String currentVersion = "<attr node="/app/xml" name="version"/>";
private String thisClass = getClass().getName() + ".";
private static String requiredExpressoVersion = "<attr node="/app/xml" name="requiredexpressoversion"/>";

/**
  * Constructor for <attr node="/app/xml" name="name"/>Schema.
  */
public <attr node="/app/xml" name="name"/>Schema() throws DBException{
super();
requiresVersion(requiredExpressoVersion, "com.jcorporate.expresso.core.ExpressoSchema");
//register the DBObjects for this application
      <iterate nodes="/app/xml/beans/bean" name="bean">
        addDBObject(<attr node="/app/xml" name="pkg"/>.dbObject.<attr node="bean" name="class"/>DBObject.class.getName());
      </iterate>
//register the controllers for this application
      <iterate nodes="/app/xml/beans/bean" name="bean">
        addController(<attr node="/app/xml" name="pkg"/>.controller.<attr node="bean" name="class"/>Controller.class);
      </iterate>
}


public String getDefaultComponentCode() {
return new String("<attr node="/app/xml" name="componentcode"/>");
}
/**
* Returns the default description for this schema. Useful for automated
* component testing/installation
*/
public String getDefaultDescription() {
return new String("<attr node="/app/xml" name="description"/>");
}
/**
* Return the path to this application's message bundle file(s)
* for local language support
*/
public String getMessageBundlePath() {
return "<attr node="/app/xml" name="messagebundlepath"/>";
} /* getMessageBundlePath() */


public String getVersion() {
return currentVersion;
}

}package <attr node="/app/xml" name="pkg"/>;


import com.jcorporate.expresso.core.db.*;
import com.jcorporate.expresso.core.dbobj.*;

/**
* <p>Title: <attr node="/app/xml" name="name"/>Schema</p>
* <p>Description: <attr node="/app/xml" name="description"/></p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: <attr node="/app/xml" name="company"/></p>
* <p>Date: <attr node="/app/xml" name="date"/></p>
* @author <attr node="/app/xml" name="author"/>
* @version <attr node="/app/xml" name="version"/>
*/

public class <attr node="/app/xml" name="name"/>Schema extends Schema{

private static String currentVersion = "<attr node="/app/xml" name="version"/>";
private String thisClass = getClass().getName() + ".";
private static String requiredExpressoVersion = "<attr node="/app/xml" name="requiredexpressoversion"/>";

/**
  * Constructor for <attr node="/app/xml" name="name"/>Schema.
  */
public <attr node="/app/xml" name="name"/>Schema() throws DBException{
super();
requiresVersion(requiredExpressoVersion, "com.jcorporate.expresso.core.ExpressoSchema");
//register the DBObjects for this application
      <iterate nodes="/app/xml/beans/bean" name="bean">
        addDBObject(<attr node="/app/xml" name="pkg"/>.dbObject.<attr node="bean" name="class"/>DBObject.class.getName());
      </iterate>
//register the controllers for this application
      <iterate nodes="/app/xml/beans/bean" name="bean">
        addController(<attr node="/app/xml" name="pkg"/>.controller.<attr node="bean" name="class"/>Controller.class);
      </iterate>
}


public String getDefaultComponentCode() {
return new String("<attr node="/app/xml" name="componentcode"/>");
}
/**
* Returns the default description for this schema. Useful for automated
* component testing/installation
*/
public String getDefaultDescription() {
return new String("<attr node="/app/xml" name="description"/>");
}
/**
* Return the path to this application's message bundle file(s)
* for local language support
*/
public String getMessageBundlePath() {
return "<attr node="/app/xml" name="messagebundlepath"/>";
} /* getMessageBundlePath() */


public String getVersion() {
return currentVersion;
}

}


and here is how the controller looks like:

*** Generate the schema

<start template="schema.java.pat" resource="%/app/xml(dir)%/%/app/xml(name)%Schema.java"/>

*** Generate the schema test

<start template="schema_test.java.pat" resource="%/app/xml(dir)%/test/SchemaTests.java"/>

*** Generate the DBObjects

<iterate nodes="/app/xml/beans/bean" name="bean">

<start template="dbobject.java.pat" resource="%/app/xml(dir)%/dbobj/%bean(class)%.java"/>

</iterate>


the model is a plain xml file. I think it could be interesting to depure it so it contains all the requied information.


Regards,

Raul Davidovich

 
RE:Eclipse, DPTK and automatic code generation by scann at 2004-07-07 12:20:58 Reply
On 2004-07-01 06:51:46 a user 'rdavidovich' wrote:
snip
>
> I recently found a plugin for Eclipse made by IBM alphaworks called: "design pattern toolkit".
>
> I started working on it for generating the CRUD part of an application from an XML DB schema (schema, dbobjects, controllers, struts-config.xml, validation.xml, JSPs and unit tests).
> Once the templates and the controller are ready, it generates the whole app in seconds (and it actually works).
>
> I've already done the schema, schema test and DBObjects. I'm currently working on the controllers.
>
> If someone has good test cases for DBObjects and Controllers, and can post them, it would greatly help.

+--------------------------------------+
+ PLEASE Type Your Message Here! +
+--------------------------------------+

Raul

Sounds awesome. What you are doing by leveraging the design pattern toolkit is accomplishing in large part of what we wanted to accomplish with the Expresso Wizards project. (Projects link (in header) > Expresso Wizards > Documentation).

Perhaps you might be willing to lead this project and bring it to a first release state? Sounds like you are a good ways there. If so I guess the first thing we'd want to do is update the documentation there to reflect using design pattern toolkit and what you are doing. Let us know.

Sandra

   
RE:Eclipse, DPTK and automatic code generation by rdavidovich at 2004-07-07 12:41:21 Reply
I'd love to..
a first release could be just the pattern plus the xml shema definition.
a second version could add a wizard-like interface.
a third version could be a customized version of eclipse for developing expresso applications..

thoughts?


Regards

Raul

1 Pages [ 1 ] Post New Message
   
  Moderators:
       Sandra Cann