如何使用 Spring.NET IoC 获得依赖关系的图形表示?

发布于 2024-12-05 05:49:58 字数 262 浏览 4 评论 0原文

我正在使用 Spring.NET 的 IoC 容器,一切都工作得很好......直到现在。不知何故,在我们之前的版本之一中,我们引入了循环依赖。由于我们使用基于 setter 的注入而不是基于构造函数的注入,Spring.NET 一直运行良好,但我们应用程序的行为发生了变化。

现在我有一个包含大约一百个组件的解决方案,并且在那堆组件中的某个地方存在循环依赖项,我现在需要找到它。

是否有任何工具可以获取我的 Spring.NET 配置文件并为我提供组件及其依赖项的图形化图片?

I'm using Spring.NET's IoC container and everything has been working just fine....until now. Somehow, in one of our previous releases, we introduced a circular dependency. Since we use setter based injection as opposed to constructor based injection, Spring.NET just kept humming along fine, but the behavior of our app changed.

Now I have a solution with a hundred or so components, and somewhere in that pile of components exists a circular dependency, which I now need to find.

Are there any tools that can take my Spring.NET config files and give me a graphical picture of my components and their dependencies?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梨涡 2024-12-12 05:49:58

AFAIK 没有这样一个可用的工具,尽管有一个适用于 Java 的 spring 的工具。
spring.net 论坛上的帖子
讨论该问题并提出解决方案。
我根据 Thomas Darimont 的方法,使用
QuickGraph 进行了快速而简单的概念证明。

对于以下配置文件:

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">

  <object id="a1" type="q7446068.ClassA, q7446068" >
    <property name="MyOtherA" ref="a2" />
  </object>

  <object id="a2" type="q7446068.ClassA, q7446068" >
    <property name="MyOtherA" ref="a1" />
  </object>

  <object id="a3" type="q7446068.ClassA, q7446068" />

</objects>

我能够创建以下点文件:

digraph G {
    0 [label="a1"];
    1 [label="a2"];
    2 [label="a3"];
    0 -> 1 [];
    1 -> 0 [];
}

using graphviz to make a trivial picture

其中显示循环依赖。

该代码作为要点提供。

AFAIK there isn't such a tool available, although there is one for spring for Java.
This thread on the spring.net forum
discusses the issue and proposes a solution.
I made a quick-and-dirty proof of concept based on Thomas Darimont's approach using QuickGraph.

For the following configuration file:

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">

  <object id="a1" type="q7446068.ClassA, q7446068" >
    <property name="MyOtherA" ref="a2" />
  </object>

  <object id="a2" type="q7446068.ClassA, q7446068" >
    <property name="MyOtherA" ref="a1" />
  </object>

  <object id="a3" type="q7446068.ClassA, q7446068" />

</objects>

I was able to create the following dot file:

digraph G {
    0 [label="a1"];
    1 [label="a2"];
    2 [label="a3"];
    0 -> 1 [];
    1 -> 0 [];
}

using graphviz to make a trivial picture

Which shows the circular dependency.

The code is available as a gist.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文