aQute.launcher.minifw.Context Maven / Gradle / Ivy
package aQute.launcher.minifw;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
import java.security.cert.X509Certificate;
import java.util.Collection;
import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
import java.util.Vector;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.BundleListener;
import org.osgi.framework.BundleReference;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkListener;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.Version;
public class Context extends URLClassLoader implements Bundle, BundleContext, BundleReference {
long id;
MiniFramework fw;
String location;
int state = Bundle.INSTALLED;
JarFile jar;
Manifest manifest;
private TreeSet paths;
private File jarFile;
class Dict extends Dictionary {
@Override
public Enumeration elements() {
@SuppressWarnings({
"unchecked", "rawtypes"
})
Enumeration enumeration = (Enumeration) Collections.enumeration(manifest.getMainAttributes()
.values());
return enumeration;
}
@Override
public String get(Object key) {
String o = manifest.getMainAttributes()
.getValue((String) key);
return o;
}
@Override
public boolean isEmpty() {
return manifest.getMainAttributes()
.isEmpty();
}
@Override
public Enumeration keys() {
Vector v = new Vector<>();
for (Iterator