use of grails.spring.BeanBuilder in project grails-core by grails.
the class DefaultGrailsPlugin method doWithRuntimeConfiguration.
public void doWithRuntimeConfiguration(RuntimeSpringConfiguration springConfig) {
Binding b = new Binding();
b.setVariable("application", grailsApplication);
b.setVariable(GrailsApplication.APPLICATION_ID, grailsApplication);
b.setVariable("manager", getManager());
b.setVariable("plugin", this);
b.setVariable("parentCtx", getParentCtx());
b.setVariable("resolver", getResolver());
if (plugin instanceof Plugin) {
Closure c = ((Plugin) plugin).doWithSpring();
if (c != null) {
BeanBuilder bb = new BeanBuilder(getParentCtx(), springConfig, grailsApplication.getClassLoader());
bb.setBinding(b);
bb.invokeMethod("beans", new Object[] { c });
}
} else {
if (!pluginBean.isReadableProperty(DO_WITH_SPRING)) {
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Plugin " + this + " is participating in Spring configuration...");
}
Closure c = (Closure) plugin.getProperty(DO_WITH_SPRING);
BeanBuilder bb = new BeanBuilder(getParentCtx(), springConfig, grailsApplication.getClassLoader());
bb.setBinding(b);
c.setDelegate(bb);
bb.invokeMethod("beans", new Object[] { c });
}
}
use of grails.spring.BeanBuilder in project grails-core by grails.
the class GrailsWebApplicationContext method prepareBeanFactory.
@Override
protected void prepareBeanFactory(ConfigurableListableBeanFactory beanFactory) {
if (configLocations.length > 0) {
for (String configLocation : configLocations) {
BeanBuilder beanBuilder = new BeanBuilder(getParent(), getClassLoader());
final ServletContextResource resource = new ServletContextResource(getServletContext(), configLocation);
beanBuilder.loadBeans(resource);
beanBuilder.registerBeans(this);
}
}
super.prepareBeanFactory(beanFactory);
}
use of grails.spring.BeanBuilder in project grails-core by grails.
the class RuntimeSpringConfigUtilities method reloadSpringResourcesConfig.
public static BeanBuilder reloadSpringResourcesConfig(RuntimeSpringConfiguration config, GrailsApplication application, Class<?> groovySpringResourcesClass) throws InstantiationException, IllegalAccessException {
springGroovyResourcesBeanBuilder = new BeanBuilder(null, config, Thread.currentThread().getContextClassLoader());
springGroovyResourcesBeanBuilder.setBinding(new Binding(CollectionUtils.newMap("application", application, "grailsApplication", // GRAILS-7550
application)));
Script script = (Script) groovySpringResourcesClass.newInstance();
script.run();
Object beans = script.getProperty("beans");
springGroovyResourcesBeanBuilder.beans((Closure<?>) beans);
return springGroovyResourcesBeanBuilder;
}
use of grails.spring.BeanBuilder in project grails-core by grails.
the class DefaultGrailsPlugin method beans.
public BeanBuilder beans(Closure closure) {
BeanBuilder bb = new BeanBuilder(getParentCtx(), new GroovyClassLoader(grailsApplication.getClassLoader()));
bb.invokeMethod("beans", new Object[] { closure });
return bb;
}
Aggregations