1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.logging.log4j.core.util;
19
20 import java.io.IOException;
21 import java.net.URL;
22 import java.util.Enumeration;
23
24 import org.osgi.framework.Bundle;
25
26
27
28
29 public final class BundleResourceLoader implements ResourceLoader {
30
31 private final Bundle bundle;
32
33 public BundleResourceLoader(final Bundle bundle) {
34 this.bundle = bundle;
35 }
36
37 @Override
38 public Class<?> loadClass(final String name) throws ClassNotFoundException {
39 return bundle.loadClass(name);
40 }
41
42 @Override
43 public URL getResource(final String name) {
44 return bundle.getResource(name);
45 }
46
47 @Override
48 public Enumeration<URL> getResources(final String name) throws IOException {
49 @SuppressWarnings("unchecked")
50 final Enumeration<URL> enumeration = bundle.getResources(name);
51 return enumeration;
52 }
53
54 @Override
55 public String toString() {
56 return this.getClass().getCanonicalName() + ": " + bundle.getSymbolicName();
57 }
58 }