org.apache.camel.spi.BeanRepository Java Examples
The following examples show how to use
org.apache.camel.spi.BeanRepository.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CoreMainResource.java From camel-quarkus with Apache License 2.0 | 5 votes |
@Path("/registry/component/{name}") @GET @Produces(MediaType.APPLICATION_JSON) public JsonObject describeRegistryComponent(@PathParam("name") String name) { final Map<String, Object> properties = new HashMap<>(); final DefaultRegistry registry = main.getCamelContext().getRegistry(DefaultRegistry.class); final JsonObjectBuilder builder = Json.createObjectBuilder(); Component component = registry.getFallbackRegistry().lookupByNameAndType(name, Component.class); if (component != null) { builder.add("type", component.getClass().getName()); builder.add("registry", "fallback"); builder.add("registry-type", registry.getFallbackRegistry().getClass().getName()); } else { for (BeanRepository repository : registry.getRepositories()) { component = repository.lookupByNameAndType(name, Component.class); if (component != null) { builder.add("type", component.getClass().getName()); builder.add("registry", "repository"); builder.add("registry-type", repository.getClass().getName()); break; } } } if (component != null) { main.getCamelContext().adapt(ExtendedCamelContext.class).getBeanIntrospection().getProperties(component, properties, null); properties.forEach((k, v) -> { if (v != null) { builder.add(k, Objects.toString(v)); } }); } return builder.build(); }
Example #2
Source File: CamelAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 4 votes |
static CamelContext doConfigureCamelContext(ApplicationContext applicationContext, CamelContext camelContext, CamelConfigurationProperties config) throws Exception { camelContext.build(); // initialize properties component eager PropertiesComponent pc = applicationContext.getBeanProvider(PropertiesComponent.class).getIfAvailable(); if (pc != null) { pc.setCamelContext(camelContext); camelContext.setPropertiesComponent(pc); } final Map<String, BeanRepository> repositories = applicationContext.getBeansOfType(BeanRepository.class); if (!repositories.isEmpty()) { List<BeanRepository> reps = new ArrayList<>(); // include default bean repository as well reps.add(new ApplicationContextBeanRepository(applicationContext)); // and then any custom reps.addAll(repositories.values()); // sort by ordered OrderComparator.sort(reps); // and plugin as new registry camelContext.adapt(ExtendedCamelContext.class).setRegistry(new DefaultRegistry(reps)); } if (ObjectHelper.isNotEmpty(config.getFileConfigurations())) { Environment env = applicationContext.getEnvironment(); if (env instanceof ConfigurableEnvironment) { MutablePropertySources sources = ((ConfigurableEnvironment) env).getPropertySources(); if (sources != null) { if (!sources.contains("camel-file-configuration")) { sources.addFirst(new FilePropertySource("camel-file-configuration", applicationContext, config.getFileConfigurations())); } } } } camelContext.adapt(ExtendedCamelContext.class).setPackageScanClassResolver(new FatJarPackageScanClassResolver()); if (config.getRouteFilterIncludePattern() != null || config.getRouteFilterExcludePattern() != null) { LOG.info("Route filtering pattern: include={}, exclude={}", config.getRouteFilterIncludePattern(), config.getRouteFilterExcludePattern()); camelContext.getExtension(Model.class).setRouteFilterPattern(config.getRouteFilterIncludePattern(), config.getRouteFilterExcludePattern()); } // configure the common/default options DefaultConfigurationConfigurer.configure(camelContext, config); // lookup and configure SPI beans DefaultConfigurationConfigurer.afterConfigure(camelContext); // and call after all properties are set DefaultConfigurationConfigurer.afterPropertiesSet(camelContext); return camelContext; }
Example #3
Source File: CamelAutoConfigurationTest.java From camel-spring-boot with Apache License 2.0 | 4 votes |
@Bean BeanRepository customRegistry1() { return mockBeanRepositoryWithBeanValueAndOrder(Ordered.LOWEST_PRECEDENCE); }
Example #4
Source File: CamelAutoConfigurationTest.java From camel-spring-boot with Apache License 2.0 | 4 votes |
@Bean BeanRepository customRegistry2() { return mockBeanRepositoryWithBeanValueAndOrder(Ordered.HIGHEST_PRECEDENCE); }
Example #5
Source File: CamelAutoConfigurationTest.java From camel-spring-boot with Apache License 2.0 | 4 votes |
private BeanRepository mockBeanRepositoryWithBeanValueAndOrder(int value) { final BeanRepository repo = mock(BeanRepository.class, withSettings().extraInterfaces(Ordered.class)); when(repo.lookupByName("bean")).thenReturn(value); when(((Ordered) repo).getOrder()).thenReturn(value); return repo; }
Example #6
Source File: TikaIntegrationTest.java From wildfly-camel with Apache License 2.0 | 4 votes |
private static BeanRepository createRegistryWithEmptyConfig() throws Exception { Context jndiContext = createJndiContext(); jndiContext.bind("testConfig", new TikaConfig(new File("src/test/resources/tika/tika-empty.xml"))); JndiBeanRepository repository = new JndiBeanRepository(jndiContext); return repository; }