Monday, September 27, 2010

How to create EMF models from JSP pages ?

The next release of MoDisco (version 0.9) is under development and is planned to be released with Indigo. This release will come with new components for creating EMF models from the source code of JEE applications.

The current version (version 0.8) already provides components for creating EMF models from java source code (see this older post). In next version, new components will be dedicated to JSP reverse-engineering. They have been developped by Fabien Giquel and Nicolas Guyomar of Mia-Software.

They are composed of:
  • a metamodel for describing a JSP
  • a discoverer for creating a model from a set of JSP pages
  • a generator for generating JSP pages from a model
The JSP metamodel (defined with Ecore) is an extention of the XML metamodel (also provided by MoDisco) which contains types such as Page, JSPScriptlet, JSPExpression, JSPTagLib, etc.


The discoverer, is a component which analyzes JSP pages and creates an EMF model conforming to the JSP metamodel.

It can be launched from a project, or directly from JSP pages.

The result is an EMF model which can be opened with the MoDisco Model Browser.


The generator allows regenerating JSP files from an EMF model (conforming to the JSP metamodel). While it still needs to be improved to support a better formatting, yet it can already be used to produce JSP files.

With these new components, you can reverse-enginer JSP files and use EMF APIs in order to control coding norms, detect patterns, document existing pages or refactor them by applying transformation at the model level (and then use the generator to get a new version of your JSPs).

6 comments:

  1. Exciting feature!

    Regards,
    Madhu Samuel
    Eclipse Trainer and Consultant - Bangalore,
    EclipseBible.com

    ReplyDelete
  2. Nice! could be applied the same pattern on html pages ?

    ReplyDelete
  3. Yes, you can launch the discoverer from any HTML file and you will get an EMF model.
    The JSP Ecore definition is an extension of the XML Ecore definition. The EMF model of an HTML page will be an instance of Page containing instances of Element containing instances of Attribute and other instances of Element.

    ReplyDelete
  4. interesting approach.. i'll take a look to it! thx

    Giulio

    ReplyDelete
  5. Could be interesting to create a live render for html models.. based on firefox xulrunner.. in the same manner eclipse4 emf ui renderer works.

    Giulio

    ReplyDelete