ConfigurableApplicationContext configurableApplicationContext = (ConfigurableApplicationContext) applicationContext;
autowireCapableBeanFactory = configurableApplicationContext.getBeanFactory();
} else if (beanFactory instanceof AutowireCapableBeanFactory) {
autowireCapableBeanFactory = (AutowireCapableBeanFactory) beanFactory;
} else if (applicationContext == null && beanFactory == null) {
throw new ValangException("Could not autowire function: no application context or bean factory available", line, column);
} else {
throw new ValangException("Could not autowire function: application context or bean factory does not support autowiring", line, column);
}
}
if (abstractFunction.isAutowireByName()) {
autowireCapableBeanFactory.autowireBeanProperties(function, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
}
if (abstractFunction.isAutowireByType()) {
autowireCapableBeanFactory.autowireBeanProperties(function, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
}
try {
abstractFunction.init();
} catch (Exception e) {
throw new ValangException("Error initializing function", e, line, column);
}
}
return function;
}