2 * This code is copyrighted work by Daniel Luz <dev at mernen dot com>.
4 * Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files
9 import java.io.IOException;
10 import java.lang.ref.WeakReference;
12 import org.jruby.Ruby;
13 import org.jruby.RubyClass;
14 import org.jruby.RubyModule;
15 import org.jruby.runtime.load.BasicLibraryService;
18 * The service invoked by JRuby's {@link org.jruby.runtime.load.LoadService LoadService}.
19 * Defines the <code>JSON::Ext::Parser</code> class.
22 public class ParserService implements BasicLibraryService {
23 public boolean basicLoad(Ruby runtime) throws IOException {
24 runtime.getLoadService().require("json/common");
25 RuntimeInfo info = RuntimeInfo.initRuntime(runtime);
27 info.jsonModule = new WeakReference<RubyModule>(runtime.defineModule("JSON"));
28 RubyModule jsonExtModule = info.jsonModule.get().defineModuleUnder("Ext");
29 RubyClass parserClass =
30 jsonExtModule.defineClassUnder("Parser", runtime.getObject(),
32 parserClass.defineAnnotatedMethods(Parser.class);