private <T> T getByType(CamelContext ctx, Class<T> kls) { Map<String, T> looked = ctx.getRegistry().findByTypeWithName(kls); if (looked.isEmpty()) { return null; } return looked.values().iterator().next(); }
/** * Lookup the dozer {@link Mapper} to be used. */ protected Map<String, Mapper> lookupDozerBeanMappers() { return new HashMap<>(camelContext.getRegistry().findByTypeWithName(Mapper.class)); }
/** * Lookup the dozer {@link DozerBeanMapperConfiguration} to be used. */ protected Map<String, DozerBeanMapperConfiguration> lookupDozerBeanMapperConfigurations() { return new HashMap<>(camelContext.getRegistry().findByTypeWithName(DozerBeanMapperConfiguration.class)); }
public static Map<String, Object> findBeansWithRestOperations(Registry registry) { Map<String, Object> beans = new HashMap<>(); for (Map.Entry<String, Object> bean : registry.findByTypeWithName(Object.class).entrySet()) { if (!findRestOperations(bean.getValue().getClass()).isEmpty()) { beans.put(bean.getKey(), bean.getValue()); } } return beans; }
@Override public <T> Map<String, T> findByTypeWithName(Class<T> type) { for (Registry registry : applicationContextsRegistry.values()) { Map<String, T> result = registry.findByTypeWithName(type); if (!MapUtils.isEmpty(result)) { return result; } } return Collections.emptyMap(); }
private boolean shouldIgnoreBean(Class<?> type) { Map<String, ?> beans = camelContext.getRegistry().findByTypeWithName(type); return !(beans == null || beans.isEmpty()); }
public SpringAMQPComponent(CamelContext context) { super(context); //Attempt to load a connection factory from the registry if(this.connectionFactory == null) { this.connectionFactory = context.getRegistry().findByTypeWithName(ConnectionFactory.class); if(this.connectionFactory != null && !this.connectionFactory.isEmpty()) { for(Map.Entry<String, ConnectionFactory> connection : this.connectionFactory.entrySet()){ LOG.info("Found AMQP ConnectionFactory in registry for {}", connection.getValue().getHost()); } } } if(this.connectionFactory == null) { LOG.error("Cannot find a connection factory!"); } }
public SpringAMQPComponent(CamelContext context) { super(context); //Attempt to load a connection factory from the registry if(this.connectionFactory == null) { this.connectionFactory = context.getRegistry().findByTypeWithName(ConnectionFactory.class); if(this.connectionFactory != null && !this.connectionFactory.isEmpty()) { for(Map.Entry<String, ConnectionFactory> connection : this.connectionFactory.entrySet()){ LOG.info("Found AMQP ConnectionFactory in registry for {}", connection.getValue().getHost()); } } } if(this.connectionFactory == null) { LOG.error("Cannot find a connection factory!"); } }
public Map<String, AmqpTemplate> getAmqpTemplate() { if(this.amqpTemplate == null && getCamelContext() != null && getCamelContext().getRegistry() != null) { //Attempt to load an AMQP template from the registry this.amqpTemplate = new HashMap<String, AmqpTemplate>(); Map<String, AmqpTemplate> templateMap = getCamelContext().getRegistry().findByTypeWithName(AmqpTemplate.class); for(AmqpTemplate template : templateMap.values()){ CachingConnectionFactory adminConnection = (CachingConnectionFactory)((RabbitTemplate) template).getConnectionFactory(); for(Map.Entry<String, ConnectionFactory> connection : this.connectionFactory.entrySet()){ if(identicalConnectionFactories(adminConnection, connection.getValue())){ this.amqpTemplate.put(connection.getKey(), template); break; } } } if(this.amqpTemplate != null && !this.amqpTemplate.isEmpty()){ LOG.info("Found AMQP Template in registry"); } } if(this.amqpTemplate == null || this.amqpTemplate.isEmpty()) { //Attempt to construct an AMQP template this.amqpTemplate = new HashMap<String, AmqpTemplate>(); this.amqpTemplate.put(DEFAULT_CONNECTION, new RabbitTemplate(this.connectionFactory.values().iterator().next())); LOG.info("Created new AMQP Template"); } return this.amqpTemplate; }
Map<String, EntityManagerFactory> map = getCamelContext().getRegistry().findByTypeWithName(EntityManagerFactory.class); if (map != null) { if (map.size() == 1) { Map<String, PlatformTransactionManager> map = getCamelContext().getRegistry().findByTypeWithName(PlatformTransactionManager.class); if (map != null) { if (map.size() == 1) { Map<String, TransactionTemplate> map = getCamelContext().getRegistry().findByTypeWithName(TransactionTemplate.class); if (map != null) { if (map.size() == 1) {
public Map<String, AmqpTemplate> getAmqpTemplate() { if(this.amqpTemplate == null && getCamelContext() != null && getCamelContext().getRegistry() != null) { //Attempt to load an AMQP template from the registry this.amqpTemplate = new HashMap<String, AmqpTemplate>(); Map<String, AmqpTemplate> templateMap = getCamelContext().getRegistry().findByTypeWithName(AmqpTemplate.class); for(AmqpTemplate template : templateMap.values()){ CachingConnectionFactory adminConnection = (CachingConnectionFactory)((RabbitTemplate) template).getConnectionFactory(); for(Map.Entry<String, ConnectionFactory> connection : this.connectionFactory.entrySet()){ if(identicalConnectionFactories(adminConnection, connection.getValue())){ this.amqpTemplate.put(connection.getKey(), template); break; } } } if(this.amqpTemplate != null && !this.amqpTemplate.isEmpty()){ LOG.info("Found AMQP Template in registry"); } } if(this.amqpTemplate == null || this.amqpTemplate.isEmpty()) { //Attempt to construct an AMQP template this.amqpTemplate = new HashMap<String, AmqpTemplate>(); this.amqpTemplate.put(DEFAULT_CONNECTION, new RabbitTemplate(this.connectionFactory.values().iterator().next())); LOG.info("Created new AMQP Template"); } return this.amqpTemplate; }
public Map<String, AmqpAdmin> getAmqpAdministration() { if(this.amqpAdministration == null && getCamelContext() != null && getCamelContext().getRegistry() != null) { //Attempt to load an administration connection from the registry this.amqpAdministration = new HashMap<String, AmqpAdmin>(); Map<String, AmqpAdmin> adminMap = getCamelContext().getRegistry().findByTypeWithName(AmqpAdmin.class); for(AmqpAdmin admin : adminMap.values()){ CachingConnectionFactory adminConnection = (CachingConnectionFactory)((RabbitAdmin)admin).getRabbitTemplate().getConnectionFactory(); for(Map.Entry<String, ConnectionFactory> connection : this.connectionFactory.entrySet()){ if(identicalConnectionFactories(adminConnection, connection.getValue())){ this.amqpAdministration.put(connection.getKey(), admin); break; } } } if(this.amqpAdministration != null && !this.amqpAdministration.isEmpty()){ LOG.info("Found AMQP Administrator in registry"); } } if(this.amqpAdministration == null || this.amqpAdministration.isEmpty()) { //Attempt to construct an AMQP Adminstration instance this.amqpAdministration = new HashMap<String, AmqpAdmin>(); this.amqpAdministration.put(DEFAULT_CONNECTION, new RabbitAdmin(this.connectionFactory.values().iterator().next())); LOG.info("Created new AMQP Administration instance"); } return this.amqpAdministration; }
public Map<String, AmqpAdmin> getAmqpAdministration() { if(this.amqpAdministration == null && getCamelContext() != null && getCamelContext().getRegistry() != null) { //Attempt to load an administration connection from the registry this.amqpAdministration = new HashMap<String, AmqpAdmin>(); Map<String, AmqpAdmin> adminMap = getCamelContext().getRegistry().findByTypeWithName(AmqpAdmin.class); for(AmqpAdmin admin : adminMap.values()){ CachingConnectionFactory adminConnection = (CachingConnectionFactory)((RabbitAdmin)admin).getRabbitTemplate().getConnectionFactory(); for(Map.Entry<String, ConnectionFactory> connection : this.connectionFactory.entrySet()){ if(identicalConnectionFactories(adminConnection, connection.getValue())){ this.amqpAdministration.put(connection.getKey(), admin); break; } } } if(this.amqpAdministration != null && !this.amqpAdministration.isEmpty()){ LOG.info("Found AMQP Administrator in registry"); } } if(this.amqpAdministration == null || this.amqpAdministration.isEmpty()) { //Attempt to construct an AMQP Adminstration instance this.amqpAdministration = new HashMap<String, AmqpAdmin>(); this.amqpAdministration.put(DEFAULT_CONNECTION, new RabbitAdmin(this.connectionFactory.values().iterator().next())); LOG.info("Created new AMQP Administration instance"); } return this.amqpAdministration; }
public WsSecurityInformation getSecurityInformation() { SSLContextParameters sslContextParameters = getSslContextParameters(); if (sslContextParameters == null && secure) { Map<String, SSLContextParameters> sslContextParameterMap = getCamelContext().getRegistry().findByTypeWithName(SSLContextParameters.class); if (sslContextParameterMap.size() == 1) { Map.Entry<String, SSLContextParameters> entry = sslContextParameterMap.entrySet().iterator().next(); sslContextParameters = entry.getValue(); } else if (sslContextParameterMap.size() > 1) { throw new AmbiguousBeanException(SSLContextParameters.class); } } try { SSLContext sslContext = sslContextParameters != null ? sslContextParameters.createSSLContext(getCamelContext()) : null; return new WsSecurityInformation(secure, sslContext, hostnameVerifier, username, password); } catch (Exception e) { throw new RuntimeCamelException(e); } }
Map<String, ConnectionFactory> map = getCamelContext().getRegistry().findByTypeWithName(ConnectionFactory.class); if (map != null && map.size() == 1) { Map.Entry<String, ConnectionFactory> entry = map.entrySet().iterator().next();