Class beanPostProcessorClass = shadowingClassLoader.loadClass(BeanPostProcessor.class.getName());
Method addBeanPostProcessor = beanFactoryClass.getMethod("addBeanPostProcessor", beanPostProcessorClass);
addBeanPostProcessor.invoke(beanFactory, beanPostProcessor);
// Create the GenericApplicationContext.
Class genericApplicationContextClass = shadowingClassLoader.loadClass(GenericApplicationContext.class.getName());
Class defaultListableBeanFactoryClass = shadowingClassLoader.loadClass(DefaultListableBeanFactory.class.getName());
cachedContext = genericApplicationContextClass.getConstructor(defaultListableBeanFactoryClass).newInstance(beanFactory);
// Invoke the context's "refresh" method.
genericApplicationContextClass.getMethod("refresh").invoke(cachedContext);