Reverse Engineering using UML Graph
- 27
- August
- 2008
- By admin
- Java, Uncategorized
- Comments Off on Reverse Engineering using UML Graph
I have been on several teams where we studiously designed UML diagrams at the beginning of the project. As the project progressed, and deadlines approached,
the UML diagrams were left somewhere behind, not to be updated in months. When a new developer joined the team, we showcased the old UML diagrams,
and kept telling “Oh, we never had time to update them, please see the source code to get an idea. And, don’t hesitate to ask if you have any doubt’s”.
I am sure, you all have gone through the same scenario.
However, we don’t have to keep making up stories anymore, since this article shows how easy and simple it is to include UML diagrams
within your Javadoc and also keep them updated with every change in the source code repository. We can do these in less than a few minutes,
and in a few simple steps.
Getting started with UmlGraph takes five steps:
-
Download the source code for UMlGraph.
-
Download and install Graphviz.
-
Make changes to your Ant build file.
-
Run the Ant target.
-
Add this target to your CI job.
Step 1: Download the source code for UMLGraph from here. Unzip the contents. To compile the Java doclet from the source code run
of JDK you are using you get an exception like this:
java.lang.UnsupportedClassVersionError: Bad version number in .class file
Make sure you recompile the UMLGraph source code, and copy the library to your project.
Step2 : Download and install Graphviz from
here. The dot file needs to be post-processed with Graphviz to produce the actual UML diagram.
view plaincopy to clipboardprint?
-
<target name=“javadocs” depends=“build” description=“generates javadoc and also UML Diagram”>
-
<mkdir dir=“${reports.dir}/javadoc”/>
-
<javadoc sourcepath=“${src.dir}” packagenames=“com.stelligent.*” destdir=“${reports.dir}/javadoc”
-
classpathref=“java.classpath” private=“true”>
-
<doclet name=“org.umlgraph.doclet.UmlGraphDoc”
-
path=“lib/UMLGraph.jar”>
-
<param name=“-attributes” />
-
<param name=“-operations” />
-
<param name=“-qualify” />
-
<param name=“-types” />
-
<param name=“-visibility” />
-
</doclet>
-
</javadoc>
-
<apply executable=“dot” dest=“${reports.dir}” parallel=“false”>
-
<arg value=“-Tpng”/>
-
<arg value=“-o”/>
-
<targetfile/>
-
<srcfile/>
-
<fileset dir=“${reports.dir}” includes=“*.dot”/>
-
<mapper type=“glob” from=“*.dot” to=“*.png”/>
-
</apply>
-
</target>
<target name=”javadocs” depends=”build” description=”generates javadoc and also UML Diagram”>
<mkdir dir=”${reports.dir}/javadoc”/>
<javadoc sourcepath=”${src.dir}” packagenames=”com.stelligent.*” destdir=”${reports.dir}/javadoc”
classpathref=”java.classpath” private=”true”>
<doclet name=”org.umlgraph.doclet.UmlGraphDoc”
path=”lib/UMLGraph.jar”>
<param name=”-attributes” />
<param name=”-operations” />
<param name=”-qualify” />
<param name=”-types” />
<param name=”-visibility” />
</doclet>
</javadoc>
<apply executable=”dot” dest=”${reports.dir}” parallel=”false”>
<arg value=”-Tpng”/>
<arg value=”-o”/>
<targetfile/>
<srcfile/>
<fileset dir=”${reports.dir}” includes=”*.dot”/>
<mapper type=”glob” from=”*.dot” to=”*.png”/>
</apply>
</target>
A number of options contol the operation of UMLGraph class diagram generator. These can be specified as parameters within your build file as shown above.
Details about a few options are:
-output
Specify the output file (default graph.dot).
-d
Specify the output directory (defaults to the current directory).
-qualify
Produce fully-qualified class names.
-horizontal
Layout the graph in the horizontal direction.
-attributes
Show class attributes (Java fields)
-operations
Show class operations (Java methods)
-constructors
Show a class’s constructors
-visibility
Adorn class elements according to their visibility (private, public, protected, package)
-types
Add type information to attributes and operations
-enumerations
Show enumarations as separate stereotyped primitive types.
-enumconstants
When showing enumerations, also show the values they can take.
-all
Same as -attributes -operations -visibility -types -enumerations -enumconstants
Take a look here for more options.
meera-subbaraos-macbook-9:webservices-samples meerasubbarao$ ant javadocs
Buildfile: build.xml
BUILD SUCCESSFUL
Total time: 8 seconds
meera-subbaraos-macbook-9:webservices-samples meerasubbarao$
The javadoc generated is pretty neat with UML diagrams on the top:
Step 5: Add this target to your CI Job.
If you already have a CI server like Hudson up and running, which runs commit builds and nightly builds, adding this new target is a one step process.
view plaincopy to clipboardprint?
-
<target name=“all” depends=“cleanAndDeployForCoverage, javadocs” />
<target name=”all” depends=”cleanAndDeployForCoverage, javadocs” />
Next, force a build on the Hudson job, publish the javadocs, and you can see the results on the hudson dashboard.
The Javadoc embedded with UML diagrams displayed from within the Hudson dashboard:
Now that we have UML diagram integrated within our build file, and also our CI job, we can ensure that our code base and the UML diagrams are always in sync.
We saw how to include these ant targets in our commit builds or nightly builds of our CI jobs, and also published these artifacts as part of our post build process.
Resources:
Related
Recent Posts
- 12.1.0.2 RAC Installation – Step by Step installation on VMware
- OSB FTP Poller continuously throwing exception – while no file pending on FTP Location
- Using JMS Transport with OSB
- Installing Spring Tool Suite and configuring Spring for a development PC
- Rest Enabling SOA using OSB in Oracle 12c
Recent Comments
- Nits on Installing Oracle SOA Suite 12c
- Rajesh Krishna on Installing Oracle SOA Suite 12c
- Nits on Installing Oracle SOA Suite 12c
- Rohinii on Installing Oracle SOA Suite 12c
- Mahitha on Oracle Service Bus (OSB) Development Best Practices.
Archives
- December 2015
- May 2015
- November 2014
- September 2014
- August 2014
- July 2014
- April 2014
- March 2014
- February 2014
- January 2014
- December 2013
- November 2013
- October 2013
- September 2013
- July 2013
- June 2013
- May 2013
- March 2013
- February 2013
- November 2012
- October 2012
- September 2012
- May 2012
- March 2012
- February 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- June 2011
- May 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- July 2010
- June 2010
- March 2010
- February 2010
- December 2009
- September 2009
- August 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- November 2008
- October 2008
- August 2008
- June 2008
- May 2008
Categories
- AIA
- AXIS2
- Best Practices
- BPEL
- BPM
- Budget
- Build
- Design Patterns
- ESB
- Hermes
- Hibernate
- Home Owners
- Java
- JMS
- JSR 168
- Maven
- Mediator
- Messaging
- Nitin
- OER
- OESB
- Oracle
- OSB
- OWSM
- Portlets
- SDLC
- Sequencing
- Singleton
- SOA
- SOAP
- Spring
- Struts
- UK
- Uncategorized
- Web Services
- WLST
Meta
To find out more, including how to control cookies, see here: Cookie Policy
Recent Posts
- 12.1.0.2 RAC Installation – Step by Step installation on VMware
- OSB FTP Poller continuously throwing exception – while no file pending on FTP Location
- Using JMS Transport with OSB
- Installing Spring Tool Suite and configuring Spring for a development PC
- Rest Enabling SOA using OSB in Oracle 12c
Recent Comments
- Nits on Installing Oracle SOA Suite 12c
- Rajesh Krishna on Installing Oracle SOA Suite 12c
- Nits on Installing Oracle SOA Suite 12c
- Rohinii on Installing Oracle SOA Suite 12c
- Mahitha on Oracle Service Bus (OSB) Development Best Practices.
Archives
- December 2015
- May 2015
- November 2014
- September 2014
- August 2014
- July 2014
- April 2014
- March 2014
- February 2014
- January 2014
- December 2013
- November 2013
- October 2013
- September 2013
- July 2013
- June 2013
- May 2013
- March 2013
- February 2013
- November 2012
- October 2012
- September 2012
- May 2012
- March 2012
- February 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- June 2011
- May 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- July 2010
- June 2010
- March 2010
- February 2010
- December 2009
- September 2009
- August 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- November 2008
- October 2008
- August 2008
- June 2008
- May 2008
Categories
- AIA
- AXIS2
- Best Practices
- BPEL
- BPM
- Budget
- Build
- Design Patterns
- ESB
- Hermes
- Hibernate
- Home Owners
- Java
- JMS
- JSR 168
- Maven
- Mediator
- Messaging
- Nitin
- OER
- OESB
- Oracle
- OSB
- OWSM
- Portlets
- SDLC
- Sequencing
- Singleton
- SOA
- SOAP
- Spring
- Struts
- UK
- Uncategorized
- Web Services
- WLST