Jruby Rails on Torquebox calling EJB services - model classes

334 views Asked by At

I'd like to play with Torquebox and have Rails (or e.g. Sinatra) as a frontend, but have all my services and business layer in EJB with CDI and JPA and all that stuff.

1) Can I have it all deployed as one application and use local calls for EJBs

2) If I have Rails, I can use models (no ActiveRecord) just to exchange data with frontend. How can I call EJB services with such models? I mean having:

def create
  user = User.new(params)
  userRepository = inject(Java::com.example.UserRepository)
  userRepository.create(user)  // this is java call
end

How can I pass User (jruby model to EJB call)? Or should I do

user = Java::com.example.User(params)

instead of plain ruby models.

Basically I'd like to have front in Ruby and the rest of machine in Java EE stack.

1

There are 1 answers

0
Toby Crawley On

The TorqueBox integration tests have an app that does something similar, see:

https://github.com/torquebox/torquebox/tree/2x-dev/integration-tests/apps/rails3/twitter

It loads an ApplicationScoped bean from lib/ejb.jar, the source of which can be found at:

https://github.com/goldmann/confitura-2011-torquebox-demo/tree/master/cdi

Hopefully that will get you pointed in the right direction.