// Use Spring to create all of the beans
Map factories = new HashMap(serviceNameIndex.size());
for (Iterator iterator = serviceNameIndex.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
String beanName = (String) entry.getKey();
ServiceName serviceName = (ServiceName) entry.getValue();
Object bean = applicationContext.getBean(beanName);
StaticServiceFactory serviceFactory = new StaticServiceFactory(bean, classLoader);
factories.put(serviceName, serviceFactory);
}
serviceFactories = Collections.unmodifiableMap(factories);
// register each bean with the kernel
for (Iterator iterator = serviceFactories.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
ServiceName serviceName = (ServiceName) entry.getKey();
StaticServiceFactory serviceFactory = (StaticServiceFactory) entry.getValue();
kernel.registerService(serviceName, serviceFactory);
}
} catch (ServiceAlreadyExistsException e) {