FrameworkFactory factory = new FrameworkFactory(); Map<String, String> config = new HashMap<>(); Framework framework = factory.newFramework(config); framework.start(); BundleContext context = framework.getBundleContext(); Bundle bundle = context.installBundle("file:/path/to/bundle.jar"); bundle.start(); Manifest-Version: 1.0 Bundle-Name: MyBundle Bundle-SymbolicName: com.example.mybundle Bundle-Version: 1.0.0 Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: com.example.dependency;version="[1.0.0,2.0.0)" public class MyActivator implements BundleActivator { private ServiceRegistration<MyService> registration; public void start(BundleContext context) { MyService service = new MyServiceImpl(); registration = context.registerService(MyService.class, service, null); } public void stop(BundleContext context) { registration.unregister(); } }


上一篇:
下一篇:
切换中文