import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class SimpleExecutor implements Executor {
private final ExecutorService executorService;
public SimpleExecutor() {
executorService = Executors.newCachedThreadPool();
}
public void execute(Runnable task) {
executorService.execute(task);
}
}
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
public class ExecutorActivator implements BundleActivator {
private ServiceRegistration executorServiceRegistration;
public void start(BundleContext context) throws Exception {
SimpleExecutor executor = new SimpleExecutor();
executorServiceRegistration = context.registerService(Executor.class.getName(), executor, null);
}
public void stop(BundleContext context) throws Exception {
executorServiceRegistration.unregister();
}
}
Bundle-SymbolicName: com.example.executor
Bundle-Version: 1.0.0
Import-Package: org.osgi.framework
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Bundle-Activator: com.example.executor.ExecutorActivator