开发者

How can I build a meta model of Java Classes for generating a service graph with code analysis?

开发者 https://www.devze.com 2023-04-12 19:58 出处:网络
we have a SOA system built on top of EJB 3.0. we are manually maintaining a \"service overview map\" which shows which business services call which domain services. this is tedious, error prone and no

we have a SOA system built on top of EJB 3.0. we are manually maintaining a "service overview map" which shows which business services call which domain services. this is tedious, error prone and nobody wants to do it :-/

that's why i am looking for a way to automate the generation of these diagrams. i think code analysis is the way to go.

does anybody know of a tool that does good code analysis for java? i think of some kind of meta model w开发者_如何转开发hich i can query to built the graph.

something like:

  1. parse all files from root dir xyz and built the meta model for each class a) e.g. which other classes does it use b) which classes use this class c) which interfaces does it implement d) what is it's filename e) and so on, i guess you know what i mean
  2. give me a meta model of all the files you found (java/class)
  3. generate the graph (hand made)
  4. output the graph in ".dot" (directed graph) file format
  5. use the "dot" tool to generate the graph as png, pdf, svg...

we already have a simple solution by "grepping" through the files.... but this is not perfect.

any help would be appreciated

cheers marcel


An alternative would be to do the same thing using ASM on the compiled class files or on the source code itself.


Hah. I wrote this exact system not one month ago for our EJB 2.0 behemoth. Here is what I did:

  • downloaded the Java Parser
  • wrote a recursive directory walker
  • wrote a tree-based data structure that allowed me to store dependencies.
  • wrote a .dot file outputter.

It took me about a week and it proved very successful when I updated it to output the files as .svg images via the twopi engine; we can now navigate class diagrams in the browser to quickly identify areas of interest for potential refactoring, and are integrating it into our automated build environment.

Drop me a pm if you need more info.


There is an eclipse framework called MoDisco which corresponds to your need. It includes several meta model (Java, JSP, ...).

You can get a complete picture of your project including config files or deployment descriptors.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号