Last active
August 29, 2015 14:07
-
-
Save rotty3000/fcd47c42cb0a12141f52 to your computer and use it in GitHub Desktop.
embedded framework example to test fileinstall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.ServiceLoader; | |
import org.osgi.framework.Bundle; | |
import org.osgi.framework.BundleContext; | |
import org.osgi.framework.launch.Framework; | |
import org.osgi.framework.launch.FrameworkFactory; | |
public class FIAndEquinoxTest { | |
public static void main(String[] args) throws Exception { | |
Map<String, String> p = new HashMap<String, String>(); | |
p.put( | |
"org.osgi.framework.storage", | |
System.getProperty("user.home") + File.separator + "osgi"); | |
File deployDir = new File( | |
System.getProperty("user.home") + File.separator + "osgi-deploydir"); | |
deployDir.mkdirs(); | |
p.put( | |
"felix.fileinstall.dir", | |
System.getProperty("user.home") + File.separator + "osgi-deploydir"); | |
ServiceLoader<FrameworkFactory> factories = ServiceLoader.load( | |
FrameworkFactory.class); | |
FrameworkFactory factory = factories.iterator().next(); | |
Framework framework = factory.newFramework(p); | |
framework.init(); | |
BundleContext context = framework.getBundleContext(); | |
Bundle bundle = context.installBundle( | |
"http://archive.apache.org/dist/felix/org.apache.felix.fileinstall-3.4.0.jar"); | |
bundle.start(); | |
framework.start(); | |
framework.waitForStop(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment