@Override
public synchronized Object createInstance(final Instance instance, final ClassLoader classLoader)
throws KevoreeCoreException {
final DeployUnit du = getJavaDeployUnit(instance);
try {
final String mainClassName = searchMainClassName(instance);
final Class clazz = classLoader.loadClass(mainClassName);
final Object newInstance = clazz.newInstance();
final InstanceContext instanceContext = new InstanceContext(instance.path(), core.getNodeName(), instance.getName());
injector.register(Context.class, instanceContext);
injector.register(ModelService.class, new ContextAwareModelServiceAdapter(core, instance.path()));
injector.register(ChannelContext.class, new ChannelContextImpl(instanceContext));
injector.inject(newInstance);
return newInstance;
} catch (NoClassDefFoundError e) {
throw new KevoreeCoreException("@KevoreeInject failed (is " + du.getName() + ":" + du.getVersion() + ":"+du.getHashcode().substring(0, 6)+" up-to-date?)", e);
} catch (Throwable e) {
throw new KevoreeCoreException("Unable to create instance " + instance.getName(), e);
}
}