Rails 和 Jruby 有什么关系? [英] How do Rails and Jruby relate?

查看:24
本文介绍了Rails 和 Jruby 有什么关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我有一个可供许多开发人员访问的 Java 库 - 通常通过 java.lang.但是,一些开发人员希望通过 Ruby API 访问它.为了实现 Java-Ruby API,我倾向于 Jruby 的方向.

Background: I have a java library that is accessed by many developers - usually via java. However, a few devs hope to access this via a Ruby API. I am gravitating in the direction of Jruby in order to implement a Java-Ruby API.

问题:

  1. 我主要担心的是,这些开发人员将无法在他们当前的 Ruby on Rails 开发框架中使用 API;但必须在 Jruby 的 rails 环境中运行.会是这样吗?

  1. My main concern is that these developers will not be able to utilize the API in their current, Ruby on Rails development framework; but instead will have to operate within Jruby's rails environment. Is this going to be the case?

也许我错过了 Jruby 和 Ruby on Rails 之间的连接.但似乎你既可以在 Rails 中工作,也可以在 Jruby 的 rails 中工作——这在技术上是两种不同的开发环境吗?

Perhaps I'm missing a connection between Jruby and Ruby on Rails. But it seems that you can either work in Rails, or work in Jruby's rails - are these technically two different development environments?

我真的很感激有人能对此有所了解..

I would really appreciate any light someone could shed on this..

编辑:强迫开发人员(实际上是客户更具体)对其项目进行大量更改以适应此 API 并不是一个真正的选择.因此,如果他们的 Rails 应用程序必须转换为 Jruby on Rails 应用程序,那么也许有人可以为我提供另一种选择(Jruby 除外)?

Edit: Forcing developers (actually clients to be more specific) to make large changes to their projects in order to accomodate for this API is not really an option. So, if their Rails apps would have to be converted to Jruby on Rails apps, then perhaps someone could offer yet another alternative for me (other than Jruby)?

推荐答案

首先,我要提一下,Ruby on Rails 只是简单的 Ruby 代码,同样的代码可以在 JRuby 环境(在 JVM 上)或 MRI(用 C) 运行时编写.

First, I should mention that Ruby on Rails is simply Ruby code, and the same code can run in the JRuby environment (on the JVM) or the MRI (written in C) runtime.

但是,只有 JRuby 可以加载 Java 类并使用 Java API.要求您的客户将他们的部署环境切换到 JRuby 可能不可行,但如果您可以在 Java 中设置一个支持 XML 或 JSON 的服务,那么他们将能够轻松地从 Rails 使用它.

However, only JRuby can load Java classes and use a Java API. Asking your clients to switch their deployment environment to JRuby may not be feasible, but if you can set up a service in Java that speaks XML or JSON then they will be able to easily use it from Rails.

这篇关于Rails 和 Jruby 有什么关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆