Java/Scala 的简单控制反转框架
我正在寻找一个简单易用的 IoC 容器,用于用 Java/Scala 编写的 GUI 应用程序。
它应该支持约定优于配置、生命周期管理、代码配置(最好根本不需要任何 XML),并尽可能在编译时检查依赖关系。类似于 Autofac 的东西将是完美的。
I am looking for a simple to use IoC container for GUI applications written in Java/Scala.
It should support Convention over Configuration, lifecycle management, configuration in code (preferably without any XML needed at all), and checking dependencies at compile-time as much as possible. Something similar to Autofac would be perfect.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
听起来您需要类似 Google Guice 的东西。
Java 曾经有不少 IoC 容器(例如 PicoContainer),但它们都处于阴影之中春天已经很多年了。不过,Spring 可能有点超出了您的需求。
Guice 重新开始了一些良性竞争。
Sounds like you need something like Google Guice.
There used to quite a few IoC containers for Java (e.g. PicoContainer), but they've all been in the shadow of Spring for years now. Spring is likely a bit over the top for your needs, though.
Guice has restarted some healthy competition.
如果你想要纯 Scala,你可以看看 Sindi:
http://aloiscochard.github.com/sindi
注意:我是 Sindi 项目作者
If you are going pure Scala, you can take a look at Sindi:
http://aloiscochard.github.com/sindi
Note: I'm the Sindi project author
Google Guice 非常好:
http://code.google.com/p/google-guice /
您也没有任何 XML 垃圾,您只需以编程方式创建模块并将内容编写在一起,例如将接口 (TransactionLog) 绑定到实现类 (DatabaseTransactionLog):
Google Guice is pretty good:
http://code.google.com/p/google-guice/
You don't have any XML gunk either, you can just create module programatically and write things together in that, e.g binding an interface (TransactionLog) to an implementation class (DatabaseTransactionLog):
PicoContainer 是一个高度可嵌入、全方位服务的控制反转 (IoC) 容器,用于支持依赖注入的组件图案。该项目于 2003 年启动,开创了构造函数注入自动布线的先河。它也是开源的,因此可以免费使用。许可证是 BSD,因此您可以安全地将其与商业或其他开源软件一起使用。
PicoContainer is a highly embeddable, full-service, Inversion of Control (IoC) container for components honor the Dependency Injection pattern. The project started in 2003 and pioneered Constructor Injection auto-wiring. It is also Open Source and therefore free to use. The license is BSD and thus you can safely use this with commercial or other open source software.