Results 1 to 8 of 8

Thread: Visualising object relationships

  1. #1
    Join Date
    Jan 2008
    Posts
    6

    Default Visualising object relationships

    Hi

    the Spring IDE in java produces some excellent diagrams of object/bean relationships defined in the application context. Has anyone seen an equivalent tool for Spring.NET ?

    regards
    Jon

  2. #2
    Mark Pollack is offline Spring.NET Co-Lead Spring TeamSpring User
    Join Date
    Sep 2004
    Location
    New York, NY
    Posts
    1,683

    Default

    Hi,

    Short answer, nothing available.

    Long answer, there was a port of 'beandoc' a while ago, the website with that code is gone, though I think i have it laying around on my old laptop somewhere. It probably isn't worthwhile to pursue as that version didn't understand namespaces and couldn't handle autowiring.

    I've been in discussion with the Spring-IDE team, so I know more or less how it works now but haven't looked into it more on the .NET. I suspect that if you want to iterate overall the object definitions at runtime, it might be easier to hack something at that point using a graphing library, any suggestions (maybe GLEE?) though exploring the DSL toolkit, for the purposes of rendering, might also be worth a shot.

    Cheers,
    Mark

  3. #3
    Join Date
    Dec 2006
    Location
    Saarbrücken / Saarland / Germany
    Posts
    24

    Default

    Hello,

    GLEE looks very nice indeed, but it seems that it is not available for free any more...
    Microsoft Automatic Graph Layout (MSAGL), formerly known as GLEE, is a .NET tool for laying out and visualizing directed graphs. MSAGL is now available for purchase at Windows Marketplace.
    Now you have to pay for it :-(
    http://research.microsoft.com/users/...LEEWebPage.htm

    Does someone know another freely available .net graph-library which could be used to draw "fancy" object dependency graphs?

    Best regards,
    Tom

  4. #4
    Mark Pollack is offline Spring.NET Co-Lead Spring TeamSpring User
    Join Date
    Sep 2004
    Location
    New York, NY
    Posts
    1,683

    Default

    Hi,

    I remember this one from some old adds in Dr. Dobbs. GoDiagram Not free or open source, but looks good. The classic in this space is graphviz, but it doesn't seem to have any .NET based rendering engine. I found a COM based one, wingraphviz, perhaps porting it? Maybe I didn't google well enough

    Cheers,
    Mark

  5. #5
    Mark Pollack is offline Spring.NET Co-Lead Spring TeamSpring User
    Join Date
    Sep 2004
    Location
    New York, NY
    Posts
    1,683

  6. #6
    Join Date
    Dec 2006
    Location
    Saarbrücken / Saarland / Germany
    Posts
    24

    Default

    Hello,

    it seems to be quite easy to generate a Graphical Dependency Visualization from one or more spring configuration files.

    One option would be to use XSLT to transform a spring configuration file to a graph-Format which can
    be displayed by e.g. yEd - Java™ Graph Editor ( http://www.yworks.com/en/products_yed_about.html ).
    For instance .graphml ( http://graphml.graphdrawing.org/ )

    If you want to do this programatically then you would need to do the following (at least that's how I did it):
    1) Create a Custom implementation of IObjectDefinitionRegistry which simply delegates to an Dictionary.
    2) Create a XmlObjectDefinitionReader which uses the custom ObjectDefinitionRegistry in order to read the ObjectDefinitions found within the given config locations
    3) Loop over all ObjectDefinitions in your ObjectDefinitionRegistry
    4) For each ObjectDefinition you have to analyze it's dependencies ( -> objectDefinition.PropertyValues.PropertyValues)
    If you encounter a RuntimeObjectReference (then you found an entry like <property name="SessionFactory" ref="sessionFactory"/> )

    An ObjectDefinition is a Node and a Dependency (e.g. via ref="..." or inline ObjectDefinition) is an Edge.


    With this approach I generated a simple graph from this Spring Configuration as you can see in the attached image.
    Code:
    <objects xmlns="http://www.springframework.net" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd">
    			<object name="personService" 
    					type="De.Tutorials.Training.Spring.Services.Internal.PersonService,SpringTraining">
    				<property name="personDAO" ref="personDAO"/>
    			</object>
    
    			<object name="personDAO" 
    					type="De.Tutorials.Training.Spring.DAO.Internal.PersonDAO,SpringTraining">
    				<property name="SessionFactory" ref="sessionFactory"/>
    			</object>
    
    			<!-- object type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
    				<property name="ConfigSections" value="databaseSettings"/>
    			</object -->
    
    			<object id="dbProvider" type="Spring.Data.Support.SqlProvider, Spring.Data">
    				<property name="ConnectionString" value="Data Source=localhost;Initial Catalog=test;User Id=root;Password=tutorials"/>
    			</object>
    			
    			<object id="sessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate">
    				<property name="dbProvider" ref="dbProvider"/>
    				<property name="HibernateProperties">
    					<dictionary>
    						<entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
    						<entry key="hibernate.dialect" value="NHibernate.Dialect.MySQLDialect"/>
    						<entry key="hibernate.connection.driver_class" value="NHibernate.Driver.MySqlDataDriver"/>
    						<!-- entry key="hibernate.connection.connection_string" value="Data Source=localhost;Initial Catalog=test;User Id=root;Password=tutorials"/ -->
    					</dictionary>
    				</property>
    				<property name="MappingAssemblies">
    					<list>
    						<value>SpringTraining</value>
    					</list>
    				</property>
    			</object>
    
    			<object id="hibernateTransactionManager" type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate">
    				<property name="dbProvider" ref="dbProvider"/>
    				<property name="sessionFactory" ref="sessionFactory"/>
    			</object>
    		</objects>

    Best regards,
    Thomas
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Thomas.Darimont; 01-25-2008 at 02:10 PM.

  7. #7
    Mark Pollack is offline Spring.NET Co-Lead Spring TeamSpring User
    Join Date
    Sep 2004
    Location
    New York, NY
    Posts
    1,683

    Default

    Hi,

    You are quite the savvy hacker .

    What Spring.Java IDE uses a slighlty different mechanism and it is one that isn't available yet in Spring.NET. It will be as part of the 1.2 release as that is in large part all about syncing up the core container features. There is an interface, ReaderEventListener, which has callback methods that are called by XmlObjectDefinitionReader for each object definitoin registered. Actually it is a ComponentDefinition, which is purpose built for this visualization task, see the javadoc link for details. Last bit of high level summary of what is in Spring-IDE is an additional model of the configuration information, this was done I believe because the object metadata model in Spring itself didn't handle some things well, I believe navigating around through the heirarchy but I should check with Christian again. In anycase, the basic starting point (and i don't know much more than this) is BeansConfig.

    Thanks again for breaking some new ground!

    Mark

  8. #8
    Join Date
    Mar 2011
    Posts
    25

    Default

    A couple of days ago, I came across this similar question on StackOverflow and I used the information in this thread to cook up a quick & dirty solution using QuickGraph, which you can find as a gist here. It uses Thomas' approach.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •