if (DeploymentUtils.isUnitRootless( unit )) {
return;
}
RubyAppMetaData rubyAppMetaData = unit.getAttachment( RubyAppMetaData.ATTACHMENT_KEY );
RubyRuntimeMetaData runtimeMetaData = unit.getAttachment( RubyRuntimeMetaData.ATTACHMENT_KEY );
if (rubyAppMetaData != null && runtimeMetaData != null) {
RubyRuntimeFactory factory = new RubyRuntimeFactory( runtimeMetaData.getRuntimeInitializer(),
runtimeMetaData.getRuntimePreparer() );
List<String> loadPaths = new ArrayList<String>();
for (RubyLoadPathMetaData loadPath : runtimeMetaData.getLoadPaths()) {
loadPaths.add( loadPath.getPath().getAbsolutePath() );
}
Module module = unit.getAttachment( Attachments.MODULE );
if (module != null) {
factory.setClassLoader( module.getClassLoader() );
}
factory.setServiceRegistry( phaseContext.getServiceRegistry() );
factory.setLoadPaths( loadPaths );
factory.setApplicationName( rubyAppMetaData.getApplicationName() );
factory.setUseJRubyHomeEnvVar( this.useJRubyHomeEnvVar );
factory.setApplicationEnvironment( rubyAppMetaData.getEnvironmentVariables() );
factory.setDebug( runtimeMetaData.isDebug() );
factory.setInteractive( runtimeMetaData.isInteractive() );
factory.setProfileApi( runtimeMetaData.isProfileApi() );
if (runtimeMetaData.getVersion() == RubyRuntimeMetaData.Version.V1_9) {
factory.setRubyVersion( CompatVersion.RUBY1_9 );
} else if (runtimeMetaData.getVersion() == RubyRuntimeMetaData.Version.V1_8) {
factory.setRubyVersion( CompatVersion.RUBY1_8 );
} else if (runtimeMetaData.getVersion() == RubyRuntimeMetaData.Version.V2_0) {
factory.setRubyVersion( CompatVersion.RUBY2_0 );
}
RubyRuntimeMetaData.CompileMode compileMode = runtimeMetaData.getCompileMode();
if (compileMode == RubyRuntimeMetaData.CompileMode.JIT) {
factory.setCompileMode( CompileMode.JIT );
} else if (compileMode == RubyRuntimeMetaData.CompileMode.OFF) {
factory.setCompileMode( CompileMode.OFF );