private synchronized void initComponentContexts() throws CoreRuntimeException {
if (contexts == null) {
contexts = new ConcurrentHashMap<String, Context>();
destroyQueue = new ArrayList<Context>();
for (ContextFactory<Context> config : contextFactories.values()) {
Context context = config.createContext();
context.start();
contexts.put(context.getName(), context);
}
// Initialize eager contexts. Note this cannot be done when we initially create each context since a component may
// contain a forward reference to a component which has not been instantiated
for (Context context : contexts.values()) {
if (context instanceof AtomicContext) {
AtomicContext atomic = (AtomicContext) context;
if (atomic.isEagerInit()) {
// perform silent creation and manual shutdown registration
atomic.init();
destroyQueue.add(context);
}
}
context.addListener(this);
}
}
}