Created
October 15, 2011 08:10
-
-
Save jcalvert/1289254 to your computer and use it in GitHub Desktop.
JRuby + CXF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.vetstreet; | |
| import org.springframework.beans.factory.BeanFactory; | |
| import org.springframework.context.support.ClassPathXmlApplicationContext; | |
| /** | |
| * If we pull this JAR in via JRuby, we don't get the sexy OSGI Blueprint magic, so let's | |
| * boot the context and provide accessors. Make it a singleton so we don't go blasting out contexts. | |
| * @author jcalvert | |
| * | |
| */ | |
| public class Context { | |
| private static Context context; | |
| private BeanFactory factory; | |
| private Context() | |
| { | |
| ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(new String[] {"META-INF/spring/beans.xml"}); | |
| this.factory = (BeanFactory) appContext; | |
| } | |
| public static Context getInstance() | |
| { | |
| if(context == null) | |
| { | |
| context = new Context(); | |
| } | |
| return context; | |
| } | |
| //Hide the fact that it's spring... | |
| public Object getBean(String beanName) | |
| { | |
| return factory.getBean(beanName); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'java' | |
| require './lib/my-deps.jar' | |
| require './lib/my.jar' | |
| context = com.vetstreet.Context.instance #Takes a moment as it loads up everything | |
| => Java::ComVetstreet::Context | |
| registration_dao = context.get_bean "registrationDao" | |
| => #<Java::ComVetstreetDao::RegistrationDao:0x16315e08> | |
| reg_hash = {'first_name' => "Foo", 'last_name' => "bar" ... } | |
| registration_dao.register_user_with_map reg_hash | |
| => "my external system key" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment