Skip to content

[proposal] make the jruby gem extension more java like #2987

@mkristian

Description

@mkristian

make the jruby gem extension more java like. I just want to follow the way dropwizard "adds" their services to a jar file https://github.com/dropwizard/dropwizard/blob/master/dropwizard-metrics/src/main/resources/META-INF/services/io.dropwizard.metrics.ReporterFactory

  • a jar with jruby extension has a file META-INF/services/org.jruby.Extension
  • the file contains a list of class files which shall be loaded. assuming the loading of the class does activate the JRuby extension

example lib/ruby/shared/json/ext/parser.jar has the file META-INF/services/org.jruby.Extension with content

json.ext.ParserService

adding a jar to the jruby-classloader (via require or via $CLASSPATH << 'my.jar' will just do something along those lines to load the actual extension

for ( url : runtime.getJRubyClassLoader().getResources( "META-INF/services/org.jruby.Extension" ) ) {
  for (line : loadUrl( url ) {
     runtime.getJRubyClassLoader().loadClass( line );
  }
}

whether to keep a list of already loaded extension may or may not be needed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions