@Override public void start() throws Exception { ObjectHelper.notNull(getCamelContext(), "CamelContext", this); if (getCamelContext() instanceof SpringCamelContext) { ApplicationContext applicationContext = ((SpringCamelContext) getCamelContext()).getApplicationContext(); beanResolver = new BeanFactoryResolver(applicationContext); } else { beanResolver = new RegistryBeanResolver(getCamelContext().getRegistry()); } }
endpoint = camelContext.getRegistry().lookupByNameAndType(getServiceRef(), Endpoint.class); } else { endpoint = camelContext.getEndpoint(getServiceUrl());
private EvaluationContext createEvaluationContext(Exchange exchange) { StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new RootObject(exchange)); if (beanResolver != null) { evaluationContext.setBeanResolver(beanResolver); } else if (exchange.getContext() instanceof SpringCamelContext) { // Support references (like @foo) in expressions to beans defined in the Registry/ApplicationContext ApplicationContext applicationContext = ((SpringCamelContext) exchange.getContext()).getApplicationContext(); evaluationContext.setBeanResolver(new BeanFactoryResolver(applicationContext)); } else { evaluationContext.setBeanResolver(new RegistryBeanResolver(exchange.getContext().getRegistry())); } return evaluationContext; }
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 <T extends Registry> T getRegistry(CamelContext context, Class<T> type) throws Exception { T result = context.getRegistry(type); if (result == null) { throw new Exception(type.getName() + " not available in " + context.getName()); } return result; }
@SuppressWarnings("PMD.EmptyCatchBlock") private static Map<String, Object> jsonStringAsMap(String body, Exchange exchange) { ObjectMapper mapper = resolveObjectMapper(exchange.getContext().getRegistry()); // convert JSON string to Map try { return mapper.readValue(body, new TypeReference<Map<String, Object>>(){}); } catch (IOException e) { // ignore because we are attempting to convert, but its not a JSON document } return null; }
private Map jsonStringAsMap(String body, Exchange exchange) { ObjectMapper mapper = resolveObjectMapper(exchange.getContext().getRegistry()); // convert JSON string to Map try { return mapper.readValue(body, new TypeReference<Map<String, Object>>(){}); } catch (IOException e) { // ignore because we are attempting to convert, but its not a JSON document } return null; }
protected CloudService lookupCloudService() { if (this.cloudService == null) { this.cloudService = retrieveService(CloudService.class, getCamelContext().getRegistry()); } return this.cloudService; } }
public PullRequestFilesProducer(GitHubEndpoint endpoint) throws Exception { super(endpoint); Registry registry = endpoint.getCamelContext().getRegistry(); Object service = registry.lookupByName(GitHubConstants.GITHUB_PULL_REQUEST_SERVICE); if (service != null) { LOG.debug("Using PullRequestService found in registry {}", service.getClass().getCanonicalName()); pullRequestService = (PullRequestService) service; } else { pullRequestService = new PullRequestService(); } initService(pullRequestService); }
@Override public DataFormat createDataFormat(String name, CamelContext context) { DataFormatFactory factory = context.getRegistry().lookupByNameAndType(".camelBlueprint.dataformatFactory." + name, DataFormatFactory.class); if (factory != null) { LOG.debug("Found dataformat factory: {} in registry: {}", name, factory); return factory.newInstance(); } return super.createDataFormat(name, context); } }
@Override protected void afterStart() throws Exception { BookOrderExample example = getCamelContexts().get(0).getRegistry().lookupByNameAndType("bookOrderExample", BookOrderExample.class); example.orderSomeBooks(); } }
public void start() throws Exception { final SmooksFactory smooksFactory = (SmooksFactory) camelContext.getRegistry().lookupByName(SmooksFactory.class.getName()); if (smooksFactory != null) { smooks = smooksFactory.createInstance(smooksConfig); } else { smooks = new Smooks(smooksConfig); } }
public void start() throws Exception { final SmooksFactory smooksFactory = (SmooksFactory) camelContext.getRegistry().lookupByName(SmooksFactory.class.getName()); if (smooksFactory != null) { smooks = smooksFactory.createInstance(smooksConfig); } else { smooks = new Smooks(smooksConfig); } }
DataSource getDataSource(Map<String, Object> parameters) { String dataSourceReference = (String) parameters.remove("dataSource"); Assert.notEmpty(dataSourceReference, "the dataSource parameter must be provided when using the " + "liquibase component"); return getCamelContext().getRegistry().lookup(dataSourceReference, DataSource.class); }
/** * Get the LdapConnection. Since the object is a factory, we'll just call * that. A future enhancement is to use the ApacheDS LdapConnectionPool * object to keep a pool of working connections that avoids the connection * pause. * * @return The created LDAP connection. */ protected LdapConnection getLdapConnection() throws CamelException { return (LdapConnection)getEndpoint().getCamelContext().getRegistry().lookupByName(ldapConnectionName); }
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { String dataSourceKey = getAndRemoveParameter(parameters, "dataSource", String.class); Assert.notNull(dataSourceKey, "the variable 'dataSource' must be set on the sqlplus endpoint"); DataSource dataSource = getCamelContext().getRegistry().lookup(dataSourceKey, DataSource.class); remaining = remaining.trim(); if (remaining.endsWith(".sql")) { return createFileEndpoint(uri, remaining, parameters, dataSource); } else { return createSqlPlusEndpoint(uri, remaining, parameters, dataSource); } }
protected void setupSecurity(CamelContext camelContext) { SimpleRegistry simpleRegistry = new SimpleRegistry(); simpleRegistry.put(settings.getSslContextParametersBeanName(), CamelUtils.createSslContextParameters(settings.getSslConfiguration())); // TODO Handle many invocations of this method that cause growing of the registry list. ((DefaultCamelContext) camelContext).setRegistry(new CompositeRegistry(Arrays.asList(simpleRegistry, camelContext.getRegistry()))); }
protected void setupSecurity(CamelContext camelContext) { SimpleRegistry simpleRegistry = new SimpleRegistry(); simpleRegistry.put(settings.getSslContextParametersBeanName(), CamelUtils.createSslContextParameters(settings.getSslConfiguration())); // TODO Handle many invocations of this method resulting in a growing registry list. ((DefaultCamelContext) camelContext).setRegistry(new CompositeRegistry(Arrays.asList(simpleRegistry, camelContext.getRegistry()))); }