简体   繁体   English

Java / Scala的简单反转控制框架

[英]Simple Inversion of Control framework for Java/Scala

I am looking for a simple to use IoC container for GUI applications written in Java/Scala. 我正在寻找一个简单易用的IoC容器,用于用Java / Scala编写的GUI应用程序。

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. 它应支持约定优于配置,生命周期管理,代码配置(最好不需要任何XML),并尽可能在编译时检查依赖性。 Something similar to Autofac would be perfect. Autofac类似的东西将是完美的。

Sounds like you need something like Google Guice . 听起来你需要像Google Guice这样的东西。

There used to quite a few IoC containers for Java (eg PicoContainer ), but they've all been in the shadow of Spring for years now. 曾经有相当多的IoC容器用于Java(例如PicoContainer ),但它们已经在Spring的阴影中存在多年了。 Spring is likely a bit over the top for your needs, though. 尽管如此,Spring可能有点超过您的需求。

Guice has restarted some healthy competition. Guice重新开始了一些健康的比赛。

If you are going pure Scala, you can take a look at Sindi: http://aloiscochard.github.com/sindi 如果您要使用纯Scala,可以查看Sindi: http//aloiscochard.github.com/sindi

Note: I'm the Sindi project author 注意:我是Sindi项目作者

Google Guice is pretty good: Google Guice相当不错:

http://code.google.com/p/google-guice/ 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, eg binding an interface (TransactionLog) to an implementation class (DatabaseTransactionLog): 你也没有任何XML gunk,你可以以编程方式创建模块并在其中一起编写内容,例如将接口(TransactionLog)绑定到实现类(DatabaseTransactionLog):

public class BillingModule extends AbstractModule {
  @Override 
  protected void configure() {
    bind(TransactionLog.class).to(DatabaseTransactionLog.class);
  }
}

PicoContainer is a highly embeddable, full-service, Inversion of Control (IoC) container for components honor the Dependency Injection pattern. PicoContainer是一个高度可嵌入的,全方位服务的控制反转控制(IoC)容器,用于组件遵循依赖注入模式。 The project started in 2003 and pioneered Constructor Injection auto-wiring. 该项目始于2003年,是建设者注入自动布线的先驱。 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. 许可证是BSD,因此您可以安全地将其用于商业或其他开源软件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM