List processors = new ArrayList();
processors.add(new ClassLoaderXmlPreprocessor(new File(".")));
System.out.println("Loading Apache ServiceMix from file: " + file);
context = new FileSystemXmlApplicationContext(file, processors);
}
SpringJBIContainer container = (SpringJBIContainer) context.getBean("jbi");
container.onShutDown(new Runnable() {
public void run() {
if (context instanceof DisposableBean) {
try {
((DisposableBean) context).destroy();
} catch (Exception e) {
System.out.println("Caught: " + e);
e.printStackTrace();
}
}
}
});
//this is for classworlds 1.1 launcher which use System.exit()
//explicitly after lauch Main. To avoid System.exit() being invoked
//during servicemix runing, we need keep ServiceMix main thread alive.
container.block();
} catch (Exception e) {
System.out.println("Caught: " + e);
e.printStackTrace();
}