use of org.apache.felix.connect.launch.BundleDescriptor in project jackrabbit-oak by apache.
the class SpringBootSupport method processDescriptors.
public static List<BundleDescriptor> processDescriptors(List<BundleDescriptor> descriptors) throws IOException {
List<BundleDescriptor> processed = Lists.newArrayList();
for (BundleDescriptor desc : descriptors) {
if (desc.getRevision() == null) {
URL u = new URL(desc.getUrl());
URLConnection uc = u.openConnection();
if (uc instanceof JarURLConnection && uc.getClass().getName().startsWith(SPRING_BOOT_PACKAGE)) {
Revision rev = new SpringBootJarRevision(((JarURLConnection) uc).getJarFile(), uc.getLastModified());
desc = new BundleDescriptor(desc.getClassLoader(), desc.getUrl(), desc.getHeaders(), rev, desc.getServices());
}
}
processed.add(desc);
}
return processed;
}
use of org.apache.felix.connect.launch.BundleDescriptor in project karaf by apache.
the class EncryptableConfigAdminPropertyPlaceholderTest method setUp.
@Before
public void setUp() throws Exception {
// Configure Jasypt
enc = new StandardPBEStringEncryptor();
env = new EnvironmentStringPBEConfig();
env.setAlgorithm("PBEWithMD5AndDES");
env.setPassword("password");
enc.setConfig(env);
System.setProperty("org.osgi.framework.storage", "target/osgi/" + System.currentTimeMillis());
System.setProperty("karaf.name", "root");
List<BundleDescriptor> bundles = new ClasspathScanner().scanForBundles("(Bundle-SymbolicName=*)");
bundles.add(getBundleDescriptor("target/jasypt2.jar", bundle().add("OSGI-INF/blueprint/karaf-jaas-jasypt.xml", getClass().getResource("/OSGI-INF/blueprint/karaf-jaas-jasypt.xml")).set("Manifest-Version", "2").set("Bundle-ManifestVersion", "2").set("Bundle-SymbolicName", "jasypt").set("Bundle-Version", "0.0.0")));
bundles.add(getBundleDescriptor("target/test2.jar", bundle().add("OSGI-INF/blueprint/configadmin-test.xml", getClass().getResource("configadmin-test.xml")).set("Manifest-Version", "2").set("Bundle-ManifestVersion", "2").set("Bundle-SymbolicName", "configtest").set("Bundle-Version", "0.0.0")));
Map config = new HashMap();
config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);
PojoServiceRegistry reg = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config);
bundleContext = reg.getBundleContext();
}
use of org.apache.felix.connect.launch.BundleDescriptor in project karaf by apache.
the class EncryptableConfigAdminPropertyPlaceholderTest method getBundleDescriptor.
private BundleDescriptor getBundleDescriptor(String path, TinyBundle bundle) throws Exception {
File file = new File(path);
FileOutputStream fos = new FileOutputStream(file);
StreamUtils.copy(bundle.build(), fos);
fos.close();
JarInputStream jis = new JarInputStream(new FileInputStream(file));
Map<String, String> headers = new HashMap<>();
for (Map.Entry entry : jis.getManifest().getMainAttributes().entrySet()) {
headers.put(entry.getKey().toString(), entry.getValue().toString());
}
return new BundleDescriptor(getClass().getClassLoader(), "jar:" + file.toURI().toString() + "!/", headers);
}
use of org.apache.felix.connect.launch.BundleDescriptor in project karaf by apache.
the class EncryptablePropertyPlaceholderTest method getBundleDescriptor.
private BundleDescriptor getBundleDescriptor(String path, TinyBundle bundle) throws Exception {
File file = new File(path);
FileOutputStream fos = new FileOutputStream(file);
StreamUtils.copy(bundle.build(), fos);
fos.close();
JarInputStream jis = new JarInputStream(new FileInputStream(file));
Map<String, String> headers = new HashMap<>();
for (Map.Entry entry : jis.getManifest().getMainAttributes().entrySet()) {
headers.put(entry.getKey().toString(), entry.getValue().toString());
}
return new BundleDescriptor(getClass().getClassLoader(), "jar:" + file.toURI().toString() + "!/", headers);
}
use of org.apache.felix.connect.launch.BundleDescriptor in project camel by apache.
the class CamelBlueprintHelper method getBundleDescriptor.
private static BundleDescriptor getBundleDescriptor(String path, TinyBundle bundle) throws Exception {
File file = new File(path);
// tell the JVM its okay to delete this file on exit as its a temporary file
// the JVM may not successfully delete the file though
file.deleteOnExit();
FileOutputStream fos = new FileOutputStream(file, false);
InputStream is = bundle.build();
try {
IOHelper.copyAndCloseInput(is, fos);
} finally {
IOHelper.close(is, fos);
}
BundleDescriptor answer = null;
FileInputStream fis = null;
JarInputStream jis = null;
try {
fis = new FileInputStream(file);
jis = new JarInputStream(fis);
Map<String, String> headers = new HashMap<String, String>();
for (Map.Entry<Object, Object> entry : jis.getManifest().getMainAttributes().entrySet()) {
headers.put(entry.getKey().toString(), entry.getValue().toString());
}
answer = new BundleDescriptor(bundle.getClass().getClassLoader(), "jar:" + file.toURI().toString() + "!/", headers);
} finally {
IOHelper.close(jis, fis);
}
return answer;
}
Aggregations