// create a ConfigurationManager
ConfigurationManager configurationManager;
try {
configurationManager = new ConfigurationManager();
} catch (TuboConfigurationException e) {
throw new TuboKernelException("ConfigurationManager can't be created",e);
}
//
// load base configuration
try {
String baseConfig = getBaseConfigLocation();
log.info(".createKernel() - Loading base config url="+baseConfig);
configurationManager.appendResource(baseConfig);
} catch (TuboConfigurationException e) {
throw new TuboKernelException("Base Config Location can't be configured",e);
}
//
// append custom connfiguration
for (Iterator it=configLocations.iterator(); it.hasNext();) {
String resourceLocation = (String)it.next();
log.info(".createKernel() - Appendig config url="+configLocations);
try {
configurationManager.appendResource(resourceLocation);
} catch (TuboConfigurationException e) {
throw new TuboKernelException("Config "+resourceLocation+" has problems to be appened",e);
}
}
//
// create a instance of KernelBuilder based on configuration
String kernelBuilderClassName = configurationManager.getConfiguration().getKernelBuilderClassName();
KernelBuilder kernelBuilder;
try {
kernelBuilder = (KernelBuilder)Class.forName(kernelBuilderClassName).newInstance();
} catch (InstantiationException e) {
throw new TuboKernelException("Error instanciating KernelBuilder ("+kernelBuilderClassName+")",e);
} catch (IllegalAccessException e) {
throw new TuboKernelException("Illegal Access error when try to instanciate KernelBuilder ("+kernelBuilderClassName+")",e);
} catch (ClassNotFoundException e) {
throw new TuboKernelException("Class not found error when try to instanciate KernelBuilder ("+kernelBuilderClassName+")",e);
}
//
// create a Kernel
Kernel kernel;
try {
log.info(".createKernel() - Creating Kernel");
kernel = kernelBuilder.create(configurationManager);
} catch (TuboException e) {
throw new TuboKernelException("Error while creating Kernel",e);
}
//
// return kernel
log.info(".createKernel() - Kernel created");
return kernel;