Skip to content

Commit

Permalink
Showing 2 changed files with 7 additions and 18 deletions.
20 changes: 7 additions & 13 deletions core/src/main/java/org/jruby/embed/IsolatedScriptingContainer.java
Original file line number Diff line number Diff line change
@@ -5,11 +5,6 @@
import java.util.HashMap;
import java.util.Map;

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.wiring.BundleWiring;

/**
* the IsolatedScriptingContainer does set GEM_HOME and GEM_PATH and JARS_HOME
* in such a way that it uses only resources which can be reached with classloader.
@@ -75,10 +70,10 @@ public void setEnvironment(Map environment) {
}
}

private Bundle toBundle(String symbolicName) {
BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
Bundle bundle = null;
for (Bundle b : context.getBundles()) {
private org.osgi.framework.Bundle toBundle(String symbolicName) {
org.osgi.framework.BundleContext context = org.osgi.framework.FrameworkUtil.getBundle(getClass()).getBundleContext();
org.osgi.framework.Bundle bundle = null;
for (org.osgi.framework.Bundle b : context.getBundles()) {
if (b.getSymbolicName().equals(symbolicName)) {
bundle = b;
break;
@@ -90,22 +85,21 @@ private Bundle toBundle(String symbolicName) {
return bundle;
}

private String createUri(Bundle cl, String ref) {
private String createUri(org.osgi.framework.Bundle cl, String ref) {
URL url = cl.getResource( ref );
if ( url == null && ref.startsWith( "/" ) ) {
url = cl.getResource( ref.substring( 1 ) );
}
if ( url == null ) {
throw new RuntimeException( "reference " + ref + " not found on classloader " + cl );
}
System.err.println("=---" + url.toString().replaceFirst( ref + "$", "" ));
return "uri:" + url.toString().replaceFirst( ref + "$", "" );
}
/**
* add the classloader from the given bundle to the LOAD_PATH
* @param bundle
*/
public void addBundleToLoadPath(Bundle bundle) {
public void addBundleToLoadPath(org.osgi.framework.Bundle bundle) {
addLoadPath(createUri(bundle, "/.jrubydir"));
}

@@ -123,7 +117,7 @@ public void addBundleToLoadPath(String symbolicName) {
* add the classloader from the given bundle to the GEM_PATH
* @param bundle
*/
public void addBundleToGemPath(Bundle bundle) {
public void addBundleToGemPath(org.osgi.framework.Bundle bundle) {
addGemPath(createUri(bundle, "/specifications/.jrubydir"));
}

Original file line number Diff line number Diff line change
@@ -1552,13 +1552,8 @@ public void testGetLoadPaths() {
instance.setErrorWriter(writer);
List<String> result = instance.getLoadPaths();
assertTrue(result != null);
<<<<<<< HEAD
assertTrue(result.size() == 0);

=======
assertTrue(result.size() > 0);

>>>>>>> jruby-1_7
instance = null;
}

0 comments on commit 9d64c6d

Please sign in to comment.