Home > java_side

java_side

Java_side is a project mainly written in Ruby, based on the MIT license.

帮助rails项目利用旧的java资源,支持 maven、spring 整合

JavaSide

Add java support for jruby on rails.

  • maven support: third party jar dependency management, java class
  • spring support: springframework added, xml load......
  • warbler compatible: you can use "warble" command to build your war

Installation

rails plugin install git://github.com/fsword/java_side.git

Maven Support

If you want to add a third-party java library, you just modify the pom file:

$ vim $RAILS_ROOT/java/pom.xml

Then run the task: rake java_side:jars

The jar files will be put to the $RAILS_ROOT/java/jars and will be loaded when rails booting automatically. It also be packaged when you execute the warbler task

Springframework Support

  • Add support

1.modify config/application.rb, and add a line like that:

class Application < Rails::Application ... config.spring = true ... end

2.check java/pom.xml to make sure it has springframework's dependency(it has added by default pom.xml). 3.run the task: rake java_side:jars

  • Usage

You can use get_bean function on your model, like this:

class User < ActiveRecord::Base def doSth get_bean('your_bean_id').invokeTheService ... end end

If you want to use your bean on other place, just include JavaSide::Spring:

Loading development environment (Rails 3.0.6) jruby-1.5.6 :001 > include JavaSide::Spring => Object jruby-1.5.6 :002 > x = get_bean 'your_bean_id' => # jruby-1.5.6 :003 > x.invokeTheService => ......

Ignoration

You can ignore this plugin by set environment -

$ IGNORE_JAVA_SIDE=true rails c java_side is ignored Loading development environment (Rails 3.0.6) jruby-1.5.6 :001 >

Copyright (c) 2010 fsword, released under the MIT license

Previous:cars