当前位置: 首页>>代码示例>>Java>>正文


Java RubyModule.defineClassUnder方法代码示例

本文整理汇总了Java中org.jruby.RubyModule.defineClassUnder方法的典型用法代码示例。如果您正苦于以下问题:Java RubyModule.defineClassUnder方法的具体用法?Java RubyModule.defineClassUnder怎么用?Java RubyModule.defineClassUnder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jruby.RubyModule的用法示例。


在下文中一共展示了RubyModule.defineClassUnder方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: load

import org.jruby.RubyModule; //导入方法依赖的package包/类
public void load(Ruby runtime, boolean wrap) throws IOException {
    RubyModule jo = runtime.defineModule("Jo");
    final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
        public Thread newThread(Runnable r) {
            Thread t = new Thread(r);
            t.setDaemon(true);
            return t;
        }
    });
    jo.setInternalVariable("executor", executor);
    RubyClass joFuture = jo.defineClassUnder("Future", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
    RubyClass joChannel = jo.defineClassUnder("Channel", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
    
    jo.defineAnnotatedMethods(JoMethods.class);
    joFuture.defineAnnotatedMethods(JoFuture.class);
    joChannel.defineAnnotatedMethods(JoChannel.class);
    
    runtime.addFinalizer(new Finalizable() {
        public void finalize() {
            executor.shutdown();
        }
    });
}
 
开发者ID:headius,项目名称:jo,代码行数:24,代码来源:JoLibrary.java

示例2: createRubyOneofBuilderContext

import org.jruby.RubyModule; //导入方法依赖的package包/类
public static void createRubyOneofBuilderContext(Ruby runtime) {
    RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
    RubyModule internal = protobuf.defineModuleUnder("Internal");
    RubyClass cRubyOneofBuidlerContext = internal.defineClassUnder("OneofBuilderContext", runtime.getObject(), new ObjectAllocator() {
        @Override
        public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
            return new RubyOneofBuilderContext(ruby, rubyClass);
        }
    });
    cRubyOneofBuidlerContext.defineAnnotatedMethods(RubyOneofBuilderContext.class);
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:12,代码来源:RubyOneofBuilderContext.java

示例3: createRubyOneofDescriptor

import org.jruby.RubyModule; //导入方法依赖的package包/类
public static void createRubyOneofDescriptor(Ruby runtime) {
    RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
    RubyClass cRubyOneofDescriptor = protobuf.defineClassUnder("OneofDescriptor", runtime.getObject(), new ObjectAllocator() {
        @Override
        public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
            return new RubyOneofDescriptor(ruby, rubyClass);
        }
    });
    cRubyOneofDescriptor.defineAnnotatedMethods(RubyOneofDescriptor.class);
    cRubyOneofDescriptor.includeModule(runtime.getEnumerable());
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:12,代码来源:RubyOneofDescriptor.java

示例4: register

import org.jruby.RubyModule; //导入方法依赖的package包/类
public void register(final Class<? extends Converter> converterClass, String... backends) {
    RubyModule module = rubyRuntime.defineModule(getModuleName(converterClass));
    RubyClass clazz = module.defineClassUnder(
            converterClass.getSimpleName(),
            rubyRuntime.getObject(),
            new ConverterProxy.Allocator(converterClass));
    clazz.defineAnnotatedMethods(ConverterProxy.class);
    if (backends.length > 0) {
        this.asciidoctorModule.register_converter(clazz, backends);
    } else {
        this.asciidoctorModule.register_converter(clazz);
    }
}
 
开发者ID:asciidoctor,项目名称:asciidoctorj,代码行数:14,代码来源:JavaConverterRegistry.java

示例5: createHtmlModule

import org.jruby.RubyModule; //导入方法依赖的package包/类
private void createHtmlModule(Ruby ruby, RubyModule htmlModule) {
    RubyClass htmlElemDesc = htmlModule.defineClassUnder("ElementDescription", ruby.getObject(), HTML_ELEMENT_DESCRIPTION_ALLOCATOR);
    htmlElemDesc.defineAnnotatedMethods(HtmlElementDescription.class);
    
    RubyClass htmlEntityLookup = htmlModule.defineClassUnder("EntityLookup", ruby.getObject(), HTML_ENTITY_LOOKUP_ALLOCATOR);
    htmlEntityLookup.defineAnnotatedMethods(HtmlEntityLookup.class);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:8,代码来源:NokogiriService.java

示例6: createDocuments

import org.jruby.RubyModule; //导入方法依赖的package包/类
private void createDocuments(Ruby ruby, RubyModule xmlModule, RubyModule htmlModule, RubyClass node) {
    RubyClass xmlDocument = xmlModule.defineClassUnder("Document", node, XML_DOCUMENT_ALLOCATOR);
    xmlDocument.defineAnnotatedMethods(XmlDocument.class);
    
    //RubyModule htmlDoc = html.defineOrGetClassUnder("Document", document);
    RubyModule htmlDocument = htmlModule.defineClassUnder("Document", xmlDocument, HTML_DOCUMENT_ALLOCATOR);
    htmlDocument.defineAnnotatedMethods(HtmlDocument.class);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:9,代码来源:NokogiriService.java

示例7: createSaxModule

import org.jruby.RubyModule; //导入方法依赖的package包/类
private void createSaxModule(Ruby ruby, RubyModule xmlSaxModule, RubyModule htmlSaxModule) {
    RubyClass xmlSaxParserContext = xmlSaxModule.defineClassUnder("ParserContext", ruby.getObject(), XML_SAXPARSER_CONTEXT_ALLOCATOR);
    xmlSaxParserContext.defineAnnotatedMethods(XmlSaxParserContext.class);
    
    RubyClass xmlSaxPushParser = xmlSaxModule.defineClassUnder("PushParser", ruby.getObject(), XML_SAXPUSHPARSER_ALLOCATOR);
    xmlSaxPushParser.defineAnnotatedMethods(XmlSaxPushParser.class);
    
    RubyClass htmlSaxPushParser = htmlSaxModule.defineClassUnder("PushParser", ruby.getObject(), HTML_SAXPUSHPARSER_ALLOCATOR);
    htmlSaxPushParser.defineAnnotatedMethods(HtmlSaxPushParser.class);
    
    RubyClass htmlSaxParserContext = htmlSaxModule.defineClassUnder("ParserContext", xmlSaxParserContext, HTML_SAXPARSER_CONTEXT_ALLOCATOR);
    htmlSaxParserContext.defineAnnotatedMethods(HtmlSaxParserContext.class);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:14,代码来源:NokogiriService.java

示例8: getRackInputClass

import org.jruby.RubyModule; //导入方法依赖的package包/类
private static RubyClass getRackInputClass(Ruby runtime) {
  RubyModule module = runtime.getOrCreateModule("RackServlet");
  RubyClass klass = module.getClass("RackInput");
  if (klass == null) {
    klass = module.defineClassUnder("RackInput", runtime.getObject(), ALLOCATOR);
    klass.defineAnnotatedMethods(JRubyRackInput.class);
  }
  return klass;
}
 
开发者ID:square,项目名称:rack-servlet,代码行数:10,代码来源:JRubyRackInput.java

示例9: createNokogiriModule

import org.jruby.RubyModule; //导入方法依赖的package包/类
private void createNokogiriModule(Ruby ruby, RubyModule nokogiri) {;
    RubyClass encHandler = nokogiri.defineClassUnder("EncodingHandler", ruby.getObject(), ENCODING_HANDLER_ALLOCATOR);
    encHandler.defineAnnotatedMethods(EncodingHandler.class);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:5,代码来源:NokogiriService.java

示例10: createSyntaxErrors

import org.jruby.RubyModule; //导入方法依赖的package包/类
private void createSyntaxErrors(Ruby ruby, RubyModule nokogiri, RubyModule xmlModule) {
    RubyClass syntaxError = nokogiri.defineClassUnder("SyntaxError", ruby.getStandardError(), ruby.getStandardError().getAllocator());
    RubyClass xmlSyntaxError = xmlModule.defineClassUnder("SyntaxError", syntaxError, XML_SYNTAXERROR_ALLOCATOR);
    xmlSyntaxError.defineAnnotatedMethods(XmlSyntaxError.class);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:6,代码来源:NokogiriService.java

示例11: createXmlModule

import org.jruby.RubyModule; //导入方法依赖的package包/类
private RubyClass createXmlModule(Ruby ruby, RubyModule xmlModule) {
    RubyClass node = xmlModule.defineClassUnder("Node", ruby.getObject(), XML_NODE_ALLOCATOR);
    node.defineAnnotatedMethods(XmlNode.class);
    
    RubyClass attr = xmlModule.defineClassUnder("Attr", node, XML_ATTR_ALLOCATOR);
    attr.defineAnnotatedMethods(XmlAttr.class);
    
    RubyClass attrDecl = xmlModule.defineClassUnder("AttributeDecl", node, XML_ATTRIBUTE_DECL_ALLOCATOR);
    attrDecl.defineAnnotatedMethods(XmlAttributeDecl.class);
    
    RubyClass characterData = xmlModule.defineClassUnder("CharacterData", node, null);
    
    RubyClass comment = xmlModule.defineClassUnder("Comment", characterData, XML_COMMENT_ALLOCATOR);
    comment.defineAnnotatedMethods(XmlComment.class);
    
    RubyClass text = xmlModule.defineClassUnder("Text", characterData, XML_TEXT_ALLOCATOR);
    text.defineAnnotatedMethods(XmlText.class);
    
    RubyModule cdata = xmlModule.defineClassUnder("CDATA", text, XML_CDATA_ALLOCATOR);
    cdata.defineAnnotatedMethods(XmlCdata.class);
    
    RubyClass dtd = xmlModule.defineClassUnder("DTD", node, XML_DTD_ALLOCATOR);
    dtd.defineAnnotatedMethods(XmlDtd.class);

    RubyClass documentFragment = xmlModule.defineClassUnder("DocumentFragment", node, XML_DOCUMENT_FRAGMENT_ALLOCATOR);
    documentFragment.defineAnnotatedMethods(XmlDocumentFragment.class);
    
    RubyClass element = xmlModule.defineClassUnder("Element", node, XML_ELEMENT_ALLOCATOR);
    element.defineAnnotatedMethods(XmlElement.class);
    
    RubyClass elementContent = xmlModule.defineClassUnder("ElementContent", ruby.getObject(), XML_ELEMENT_CONTENT_ALLOCATOR);
    elementContent.defineAnnotatedMethods(XmlElementContent.class);
    
    RubyClass elementDecl = xmlModule.defineClassUnder("ElementDecl", node, XML_ELEMENT_DECL_ALLOCATOR);
    elementDecl.defineAnnotatedMethods(XmlElementDecl.class);
    
    RubyClass entityDecl = xmlModule.defineClassUnder("EntityDecl", node, XML_ENTITY_DECL_ALLOCATOR);
    entityDecl.defineAnnotatedMethods(XmlEntityDecl.class);
    
    entityDecl.defineConstant("INTERNAL_GENERAL", RubyFixnum.newFixnum(ruby, XmlEntityDecl.INTERNAL_GENERAL));
    entityDecl.defineConstant("EXTERNAL_GENERAL_PARSED", RubyFixnum.newFixnum(ruby, XmlEntityDecl.EXTERNAL_GENERAL_PARSED));
    entityDecl.defineConstant("EXTERNAL_GENERAL_UNPARSED", RubyFixnum.newFixnum(ruby, XmlEntityDecl.EXTERNAL_GENERAL_UNPARSED));
    entityDecl.defineConstant("INTERNAL_PARAMETER", RubyFixnum.newFixnum(ruby, XmlEntityDecl.INTERNAL_PARAMETER));
    entityDecl.defineConstant("EXTERNAL_PARAMETER", RubyFixnum.newFixnum(ruby, XmlEntityDecl.EXTERNAL_PARAMETER));
    entityDecl.defineConstant("INTERNAL_PREDEFINED", RubyFixnum.newFixnum(ruby, XmlEntityDecl.INTERNAL_PREDEFINED));
    
    RubyClass entref = xmlModule.defineClassUnder("EntityReference", node, XML_ENTITY_REFERENCE_ALLOCATOR);
    entref.defineAnnotatedMethods(XmlEntityReference.class);
    
    RubyClass namespace = xmlModule.defineClassUnder("Namespace", ruby.getObject(), XML_NAMESPACE_ALLOCATOR);
    namespace.defineAnnotatedMethods(XmlNamespace.class);
    
    RubyClass nodeSet = xmlModule.defineClassUnder("NodeSet", ruby.getObject(), XML_NODESET_ALLOCATOR);
    nodeSet.defineAnnotatedMethods(XmlNodeSet.class);
    
    RubyClass pi = xmlModule.defineClassUnder("ProcessingInstruction", node, XML_PROCESSING_INSTRUCTION_ALLOCATOR);
    pi.defineAnnotatedMethods(XmlProcessingInstruction.class);
    
    RubyClass reader = xmlModule.defineClassUnder("Reader", ruby.getObject(), XML_READER_ALLOCATOR);
    reader.defineAnnotatedMethods(XmlReader.class);
    
    RubyClass schema = xmlModule.defineClassUnder("Schema", ruby.getObject(), XML_SCHEMA_ALLOCATOR);
    schema.defineAnnotatedMethods(XmlSchema.class);

    RubyClass relaxng = xmlModule.defineClassUnder("RelaxNG", schema, XML_RELAXNG_ALLOCATOR);
    relaxng.defineAnnotatedMethods(XmlRelaxng.class);
    
    RubyClass xpathContext = xmlModule.defineClassUnder("XPathContext", ruby.getObject(), XML_XPATHCONTEXT_ALLOCATOR);
    xpathContext.defineAnnotatedMethods(XmlXpathContext.class);
    
    return node;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:73,代码来源:NokogiriService.java

示例12: createXsltModule

import org.jruby.RubyModule; //导入方法依赖的package包/类
private void createXsltModule(Ruby ruby, RubyModule xsltModule) {
    RubyClass stylesheet = xsltModule.defineClassUnder("Stylesheet", ruby.getObject(), XSLT_STYLESHEET_ALLOCATOR);
    stylesheet.defineAnnotatedMethods(XsltStylesheet.class);
    xsltModule.defineAnnotatedMethod(XsltStylesheet.class, "register");
}
 
开发者ID:gocd,项目名称:gocd,代码行数:6,代码来源:NokogiriService.java


注:本文中的org.jruby.RubyModule.defineClassUnder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。