org.apache.camel.spi.Registry.findByTypeWithName()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.apache.camel.spi.Registry.findByTypeWithName方法的一些代码示例,展示了Registry.findByTypeWithName的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Registry.findByTypeWithName方法的具体详情如下:
包路径:org.apache.camel.spi.Registry
类名称:Registry
方法名:findByTypeWithName

Registry.findByTypeWithName介绍

暂无

代码示例

代码示例来源:origin: org.flowable/flowable-camel

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();
}

代码示例来源:origin: org.apache.camel/camel-dozer

/**
 * Lookup the dozer {@link Mapper} to be used.
 */
protected Map<String, Mapper> lookupDozerBeanMappers() {
  return new HashMap<>(camelContext.getRegistry().findByTypeWithName(Mapper.class));
}

代码示例来源:origin: org.apache.camel/camel-dozer

/**
 * Lookup the dozer {@link DozerBeanMapperConfiguration} to be used.
 */
protected Map<String, DozerBeanMapperConfiguration> lookupDozerBeanMapperConfigurations() {
  return new HashMap<>(camelContext.getRegistry().findByTypeWithName(DozerBeanMapperConfiguration.class));
}

代码示例来源:origin: com.github.zed-platform/zed-camel

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;
}

代码示例来源:origin: OpenWiseSolutions/openhub-framework

@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();
}

代码示例来源:origin: org.apache.camel/camel-cdi

private boolean shouldIgnoreBean(Class<?> type) {
  Map<String, ?> beans = camelContext.getRegistry().findByTypeWithName(type);
  return !(beans == null || beans.isEmpty());
}

代码示例来源:origin: com.bluelock/camel-spring-amqp

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!");
  }
}

代码示例来源:origin: Bluelock/camel-spring-amqp

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!");
  }
}

代码示例来源:origin: Bluelock/camel-spring-amqp

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;
}

代码示例来源:origin: org.apache.camel/camel-jpa

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) {

代码示例来源:origin: com.bluelock/camel-spring-amqp

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;
}

代码示例来源:origin: com.bluelock/camel-spring-amqp

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;
}

代码示例来源:origin: Bluelock/camel-spring-amqp

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;
}

代码示例来源:origin: org.openehealth.ipf.platform-camel/ipf-platform-camel-ihe-ws

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);
  }
}

代码示例来源:origin: org.apache.camel/camel-rabbitmq

Map<String, ConnectionFactory> map = getCamelContext().getRegistry().findByTypeWithName(ConnectionFactory.class);
if (map != null && map.size() == 1) {
  Map.Entry<String, ConnectionFactory> entry = map.entrySet().iterator().next();

相关文章