Permalink
Browse files

MPS-11365 Method BundleClassLoader.findResoucres(name) is not defined

  • Loading branch information...
1 parent d1189ed commit c2a36e15ed34bbda5c511699173f78e9f8a85893 @ashatalin ashatalin committed Jan 21, 2011
Showing with 34 additions and 2 deletions.
  1. +34 −2 core/runtime/source/jetbrains/mps/runtime/BundleClassLoader.java
View
36 core/runtime/source/jetbrains/mps/runtime/BundleClassLoader.java
@@ -17,9 +17,9 @@
import jetbrains.mps.util.InternUtil;
+import java.io.IOException;
import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
public class BundleClassLoader<T> extends BaseClassLoader {
private Map<String, Class> myClassesCache = new HashMap<String, Class>();
@@ -102,6 +102,19 @@ protected URL findResource(String name) {
return null;
}
+ @Override
+ protected Enumeration<URL> findResources(String name) throws IOException {
+ ArrayList<URL> result = new ArrayList<URL>();
+ RuntimeEnvironment<T> re = myBundle.getRuntimeEnvironment();
+ for (T dep : re.getAllDependencies(myBundle)) {
+ if (re.get(dep).hasResource(name)) {
+ result.add(re.get(dep).getResource(name));
+ }
+ }
+
+ return new IterableToEnumWrapper<URL>(result);
+ }
+
public void dispose() {
super.dispose ();
myClassesCache.clear();
@@ -126,4 +139,23 @@ public RBundle getBundle() {
public String toString() {
return myBundle.getId() + "'s class loader";
}
+
+ private static class IterableToEnumWrapper<E> implements Enumeration<E> {
+
+ private Iterator<E> myIterator;
+
+ public IterableToEnumWrapper(Iterable<E> iterable) {
+ myIterator = iterable.iterator();
+ }
+
+ @Override
+ public boolean hasMoreElements() {
+ return myIterator.hasNext();
+ }
+
+ @Override
+ public E nextElement() {
+ return myIterator.next();
+ }
+ }
}

0 comments on commit c2a36e1

Please sign in to comment.