use of org.springframework.context.ApplicationContext in project grails-core by grails.
the class AbstractGrailsPluginManager method doDynamicMethods.
public void doDynamicMethods() {
checkInitialised();
Class<?>[] allClasses = application.getAllClasses();
if (allClasses != null) {
for (Class<?> c : allClasses) {
ExpandoMetaClass emc = new ExpandoMetaClass(c, true, true);
emc.initialize();
}
ApplicationContext ctx = applicationContext;
for (GrailsPlugin plugin : pluginList) {
if (!plugin.isEnabled(ctx.getEnvironment().getActiveProfiles()))
continue;
plugin.doWithDynamicMethods(ctx);
}
}
}
use of org.springframework.context.ApplicationContext in project grails-core by grails.
the class DefaultRuntimeSpringConfiguration method registerBeansWithConfig.
public void registerBeansWithConfig(RuntimeSpringConfiguration targetSpringConfig) {
if (targetSpringConfig == null) {
return;
}
ApplicationContext ctx = targetSpringConfig.getUnrefreshedApplicationContext();
if (ctx instanceof BeanDefinitionRegistry) {
final BeanDefinitionRegistry registry = (BeanDefinitionRegistry) ctx;
registerUnrefreshedBeansWithRegistry(registry);
registerBeansWithRegistry(registry);
}
for (Map.Entry<String, BeanConfiguration> beanEntry : beanConfigs.entrySet()) {
targetSpringConfig.addBeanConfiguration(beanEntry.getKey(), beanEntry.getValue());
}
}
use of org.springframework.context.ApplicationContext in project camel by apache.
the class RoutesCollector method onApplicationEvent.
// Overridden
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
ApplicationContext applicationContext = event.getApplicationContext();
// only listen to context refresh of "my" applicationContext
if (this.applicationContext.equals(applicationContext)) {
CamelContext camelContext = event.getApplicationContext().getBean(CamelContext.class);
// only add and start Camel if its stopped (initial state)
if (camelContext.getStatus().isStopped()) {
LOG.debug("Post-processing CamelContext bean: {}", camelContext.getName());
for (RoutesBuilder routesBuilder : configuration.routes()) {
// filter out abstract classes
boolean abs = Modifier.isAbstract(routesBuilder.getClass().getModifiers());
if (!abs) {
try {
LOG.debug("Injecting following route into the CamelContext: {}", routesBuilder);
camelContext.addRoutes(routesBuilder);
} catch (Exception e) {
throw new CamelSpringJavaconfigInitializationException(e);
}
}
}
try {
boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"));
if (skip) {
LOG.info("Skipping starting CamelContext(s) as system property skipStartingCamelContext is set to be true.");
} else {
// start camel
camelContext.start();
}
} catch (Exception e) {
throw new CamelSpringJavaconfigInitializationException(e);
}
}
} else {
LOG.debug("Ignore ContextRefreshedEvent: {}", event);
}
}
use of org.springframework.context.ApplicationContext in project camel by apache.
the class MainTest method createCamelContext.
private CamelContext createCamelContext(String[] options) throws Exception {
Main main = new Main();
main.parseArguments(options);
ApplicationContext applicationContext = main.createDefaultApplicationContext();
CamelContext context = SpringCamelContext.springCamelContext(applicationContext);
return context;
}
use of org.springframework.context.ApplicationContext in project camel by apache.
the class PlainSpringCustomPostProcessorOnRouteBuilderTest method testShouldProcessAnnotatedFields.
public void testShouldProcessAnnotatedFields() {
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:/org/apache/camel/spring/postprocessor/plainSpringCustomPostProcessorOnRouteBuilderTest.xml");
assertNotNull("Context not created", context);
assertNotNull("Post processor not registered", context.getBeansOfType(MagicAnnotationPostProcessor.class));
TestPojo pojo = context.getBean("testPojo", TestPojo.class);
assertNotNull("Test pojo not registered", pojo);
assertEquals("Processor has not changed field value", "Changed Value", pojo.getTestValue());
}
Aggregations