org.apache.camel.support.DefaultRegistry Java Examples
The following examples show how to use
org.apache.camel.support.DefaultRegistry.
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: CoreMainResource.java From camel-quarkus with Apache License 2.0 | 5 votes |
@Path("/registry/string/{name}") @GET @Produces(MediaType.TEXT_PLAIN) public String getStringValueFromRegistry(@PathParam("name") String name) { final DefaultRegistry registry = main.getCamelContext().getRegistry(DefaultRegistry.class); return registry.getFallbackRegistry().lookupByNameAndType(name, String.class); }
Example #3
Source File: ExchangeBootstrap.java From vlingo-examples with Mozilla Public License 2.0 | 5 votes |
@SuppressWarnings("resource") public io.vlingo.lattice.exchange.Exchange initExchange() throws Exception { DefaultCamelContext camelContext = new DefaultCamelContext(new DefaultRegistry()); camelContext.start(); DefaultProducerTemplate producerTemplate = new DefaultProducerTemplate(camelContext); DefaultConsumerTemplate consumerTemplate = new DefaultConsumerTemplate(camelContext); producerTemplate.start(); consumerTemplate.start(); final String exchangeUri = "rabbitmq:agile-iddd-product?hostname=localhost&portNumber=5672"; final CamelExchange camelExchange = new CamelExchange(camelContext, "agilepm-exchange", exchangeUri); final ExchangeSender<Exchange> sender = ExchangeSenders.sendingTo(exchangeUri, camelContext); camelExchange.register(CoveyFactory.build(sender, new NoOpReceiver<>(), new DiscussionStartedAdapter(camelContext), DiscussionStarted.class, DiscussionStarted.class)) .register(CoveyFactory.build(sender, new ProductDiscussionRequestedEventReceiver(stage), new ProductDiscussionRequestedEventAdapter(camelContext), ProductDiscussionRequested.class, ProductDiscussionRequested.class)); Runtime.getRuntime().addShutdownHook(new Thread(() -> { producerTemplate.stop(); consumerTemplate.stop(); camelExchange.close(); System.out.println("\n"); System.out.println("======================="); System.out.println("Stopping camel exchange."); System.out.println("======================="); })); return camelExchange; }
Example #4
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 #5
Source File: ExchangeBootstrap.java From vlingo-examples with Mozilla Public License 2.0 | 4 votes |
@SuppressWarnings("resource") public io.vlingo.lattice.exchange.Exchange initExchange() throws Exception { DefaultCamelContext camelContext = new DefaultCamelContext(new DefaultRegistry()); camelContext.start(); DefaultProducerTemplate producerTemplate = new DefaultProducerTemplate(camelContext); DefaultConsumerTemplate consumerTemplate = new DefaultConsumerTemplate(camelContext); producerTemplate.start(); consumerTemplate.start(); final String exchangeUri = "rabbitmq:agile-iddd-product?hostname=localhost&portNumber=5672"; final io.vlingo.lattice.exchange.Exchange camelExchange = new CamelExchange(camelContext, "agilepm-exchange", exchangeUri); final ExchangeSender<Exchange> sender = ExchangeSenders.sendingTo(exchangeUri, camelContext); camelExchange.register(CoveyFactory.build(sender, new NoOpReceiver<>(), new ProductDiscussionRequestedEventAdapter(camelContext), ProductDiscussionRequested.class, ProductDiscussionRequested.class )); camelExchange.register(CoveyFactory.build(sender, new DiscussionStartedReceiver(this.stage), new DiscussionStartedAdapter(camelContext), DiscussionStarted.class, DiscussionStarted.class )); Runtime.getRuntime().addShutdownHook(new Thread(() -> { producerTemplate.stop(); consumerTemplate.stop(); camelExchange.close(); System.out.println("\n"); System.out.println("======================="); System.out.println("Stopping camel exchange."); System.out.println("======================="); })); return camelExchange; }
Example #6
Source File: WildFlyCamelContext.java From wildfly-camel with Apache License 2.0 | 4 votes |
public void setNamingContext(Context namingContext) { this.namingContext = namingContext; setRegistry(new DefaultRegistry(new JndiBeanRepository(namingContext))); }