X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=lib%2Fmcollective%2Fvendor%2Fjson%2Fjava%2Fsrc%2Fjson%2Fext%2FParserService.java;fp=lib%2Fmcollective%2Fvendor%2Fjson%2Fjava%2Fsrc%2Fjson%2Fext%2FParserService.java;h=dde8834791008a5f9f9ab831ee75151a950c10ba;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/lib/mcollective/vendor/json/java/src/json/ext/ParserService.java b/lib/mcollective/vendor/json/java/src/json/ext/ParserService.java new file mode 100644 index 0000000..dde8834 --- /dev/null +++ b/lib/mcollective/vendor/json/java/src/json/ext/ParserService.java @@ -0,0 +1,35 @@ +/* + * This code is copyrighted work by Daniel Luz . + * + * Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files + * for details. + */ +package json.ext; + +import java.io.IOException; +import java.lang.ref.WeakReference; + +import org.jruby.Ruby; +import org.jruby.RubyClass; +import org.jruby.RubyModule; +import org.jruby.runtime.load.BasicLibraryService; + +/** + * The service invoked by JRuby's {@link org.jruby.runtime.load.LoadService LoadService}. + * Defines the JSON::Ext::Parser class. + * @author mernen + */ +public class ParserService implements BasicLibraryService { + public boolean basicLoad(Ruby runtime) throws IOException { + runtime.getLoadService().require("json/common"); + RuntimeInfo info = RuntimeInfo.initRuntime(runtime); + + info.jsonModule = new WeakReference(runtime.defineModule("JSON")); + RubyModule jsonExtModule = info.jsonModule.get().defineModuleUnder("Ext"); + RubyClass parserClass = + jsonExtModule.defineClassUnder("Parser", runtime.getObject(), + Parser.ALLOCATOR); + parserClass.defineAnnotatedMethods(Parser.class); + return true; + } +}