Scala 可以与服务组件架构一起使用吗?

发布于 2024-10-21 12:07:07 字数 125 浏览 1 评论 0原文

有谁知道Scala是否可以与SCA(服务组件架构)开源实现(例如Fabric3或Apache Tuscany)一起使用?我在网上没有找到这样的信息。我知道 Scala 可以编译为 Java,但我想知道依赖注入是否会让事情变得复杂。谢谢。

Does anyone know if Scala can be used with SCA (Service Component Architecture) open source implementations such as Fabric3 or Apache Tuscany? I found no such information online. I know Scala compiles to Java, but I was wondering if dependency injection would complicate things. Thanks.

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

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

发布评论

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

评论(1

回忆追雨的时光 2024-10-28 12:07:07

FraSCAti 平台已经支持 Scala 作为 SCA 组件的实现语言。您可以查看以下示例:

@Service
trait PrintService {
    def print(msg: String)
}

class Server extends PrintService {    
    println("SERVER created.")

    @Property protected var header = "->"
    @Property private var count = 1

    /** PrintService implementation. */
    def print(msg: String) {
        println("Server: begin printing...")
        for (i <- 0 until count)
            println(header + msg)
        println("Server: print done.")
    }        
}

@Service(classOf[Runnable])
class Client extends Runnable {
    println("CLIENT created")

    @Reference(required = true) private var service: PrintService = _
    def setPrintService(s: PrintService) { service = s }

    // Runnable interface implementation
    def run = service print "hello world"
}

存储库中的示例还说明了如何使用 bean 来实现这些组件。

The FraSCAti platform already supports Scala as an implementation language for SCA components. You can check out the following example:

@Service
trait PrintService {
    def print(msg: String)
}

class Server extends PrintService {    
    println("SERVER created.")

    @Property protected var header = "->"
    @Property private var count = 1

    /** PrintService implementation. */
    def print(msg: String) {
        println("Server: begin printing...")
        for (i <- 0 until count)
            println(header + msg)
        println("Server: print done.")
    }        
}

@Service(classOf[Runnable])
class Client extends Runnable {
    println("CLIENT created")

    @Reference(required = true) private var service: PrintService = _
    def setPrintService(s: PrintService) { service = s }

    // Runnable interface implementation
    def run = service print "hello world"
}

The examples in the repository also illustrates how to use beans to implement these components.

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