use of org.apache.felix.dm.ComponentExecutorFactory in project felix by apache.
the class TestBase method setUp.
public void setUp() throws Exception {
warn("Setting up test " + getClass().getName());
context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
Hashtable<String, Object> props = new Hashtable<>();
props.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE));
logService = context.registerService(LogService.class.getName(), this, props);
context.addFrameworkListener(this);
m_dm = new DependencyManager(context);
if (m_parallel) {
warn("Using threadpool ...");
m_threadPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
m_componentExecutorFactoryReg = context.registerService(ComponentExecutorFactory.class.getName(), new ComponentExecutorFactory() {
@Override
public Executor getExecutorFor(Component component) {
return m_threadPool;
}
}, null);
}
}
use of org.apache.felix.dm.ComponentExecutorFactory in project felix by apache.
the class TestBase method setUp.
public void setUp() throws Exception {
warn("Setting up test " + getClass().getName());
context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
Hashtable<String, Object> props = new Hashtable<>();
props.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE));
logService = context.registerService(LogService.class, this, props);
context.addFrameworkListener(this);
m_dm = new DependencyManager(context);
if (m_parallel) {
warn("Using threadpool ...");
m_threadPool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
m_componentExecutorFactoryReg = context.registerService(ComponentExecutorFactory.class.getName(), new ComponentExecutorFactory() {
@Override
public Executor getExecutorFor(Component component) {
return m_threadPool;
}
}, null);
}
}
use of org.apache.felix.dm.ComponentExecutorFactory in project felix by apache.
the class TestBase method setUp.
public void setUp() throws Exception {
warn("Setting up test " + getClass().getName());
context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
Hashtable<String, Object> props = new Hashtable<>();
props.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE));
logService = context.registerService(LogService.class.getName(), this, props);
context.addFrameworkListener(this);
m_dm = new DependencyManager(context);
if (m_parallel) {
warn("Using threadpool ...");
m_threadPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
m_componentExecutorFactoryReg = context.registerService(ComponentExecutorFactory.class.getName(), new ComponentExecutorFactory() {
@Override
public Executor getExecutorFor(Component component) {
return m_threadPool;
}
}, null);
}
}
use of org.apache.felix.dm.ComponentExecutorFactory in project felix by apache.
the class ParallelActivator method init.
public void init(BundleContext context, DependencyManager mgr) throws Exception {
context.registerService(ComponentExecutorFactory.class.getName(), new ComponentExecutorFactory() {
@Override
public Executor getExecutorFor(Component component) {
// Return our thread pool shared for all components
return Helper.getThreadPool();
}
}, null);
super.init(context, mgr);
}
use of org.apache.felix.dm.ComponentExecutorFactory in project felix by apache.
the class ComponentScheduler method mayStartNow.
private boolean mayStartNow(Component c) {
ComponentExecutorFactory execFactory = m_componentExecutorFactory;
BundleContext ctx = c.getDependencyManager().getBundleContext();
String parallel = ctx.getProperty(PARALLEL);
if (execFactory == null) {
// prefixes specified in the "parallel" system property.
if (parallel != null && requiresThreadPool(c, parallel)) {
// wait for a threadpool
return false;
} else {
// no threadpool required, start the component now, synchronously
return true;
}
} else {
// classname is starting with one of the prefixes specified in the property.
if (parallel == null || requiresThreadPool(c, parallel)) {
createComponentExecutor(execFactory, c);
}
// start the component now, possibly using the threadpool (see above).
return true;
}
}
Aggregations