public void setCamelContext(CamelContext c) { super.setCamelContext(c); if (this.properties != null) { try { EndpointHelper.setReferenceProperties(getCamelContext(), this, this.properties); EndpointHelper.setProperties(getCamelContext(), this, this.properties); } catch (Throwable e) { // TODO: Why dont't we rethrown this exception LOG.warn("Error setting CamelContext. This exception will be ignored.", e); } } }
protected C setConfigurationProperties(C configuration, Map<String, Object> parameters) throws Exception { // Resolve config for named maps Map<String, Object> configs = IntrospectionSupport.extractProperties(parameters, "resource.config."); for (Map.Entry<String, Object> entry : configs.entrySet()) { String ref = (String)entry.getValue(); if (!EndpointHelper.isReferenceParameter(ref)) { throw new IllegalArgumentException("The option resource.config." + ref + " should be a reference"); } configuration.addResourceConfig( entry.getKey(), EndpointHelper.resolveReferenceParameter(getCamelContext(), ref, Properties.class)); } // Resolve options for named maps Map<String, Object> options = IntrospectionSupport.extractProperties(parameters, "resource.options."); for (Map.Entry<String, Object> entry : options.entrySet()) { String ref = (String)entry.getValue(); if (!EndpointHelper.isReferenceParameter(ref)) { throw new IllegalArgumentException("The option resource.options." + ref + " should be a reference"); } configuration.addResourceOption( entry.getKey(), EndpointHelper.resolveReferenceParameter(getCamelContext(), ref, Properties.class)); } setProperties(configuration, parameters); return configuration; }
/** * Does the pattern match the endpoint? * * @param uri the uri * @param endpoint the endpoint * @param pattern the pattern * @return <tt>true</tt> to match and therefore intercept, <tt>false</tt> if not matched and should not intercept */ protected boolean matchPattern(String uri, Endpoint endpoint, String pattern) { return uri == null || pattern == null || EndpointHelper.matchEndpoint(endpoint.getCamelContext(), uri, pattern); }
@Override public Consumer createConsumer(Processor processor) throws Exception { Consumer ret = null; initDriver(I2CConsumer.class); device = bus.getDevice(deviceId); Constructor constructor = driverClass.getConstructor(I2CEndpoint.class, Processor.class, I2CDevice.class); ret = (Consumer) constructor.newInstance(this, processor, device); // Inject last parameter to i2c derived consumer EndpointHelper.setProperties(this.getCamelContext(), ret, parameters); if (!parameters.isEmpty()) { for (String param : parameters.keySet()) { LOG.warn( "There are parameters that couldn't be set on the endpoint Consumer. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint." + " Unknown Consumer parameters=[" + param + "]"); } } return ret; }
if (EndpointHelper.matchEndpoint(exchange.getContext(), url, pattern)) { return null; if (EndpointHelper.matchEndpoint(exchange.getContext(), url, pattern)) { answer = entry.getValue(); break; if (EndpointHelper.matchPattern(id, pattern)) { return null; if (EndpointHelper.matchPattern(id, pattern)) { answer = entry.getValue(); break; if (EndpointHelper.matchPattern(id, pattern)) { return null; if (EndpointHelper.matchPattern(id, pattern)) { answer = entry.getValue(); break; if (EndpointHelper.matchPattern(key, pattern)) { return null;
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> properties) throws Exception { AS400ConnectionPool connectionPool; if (properties.containsKey(CONNECTION_POOL)) { LOG.trace("AS400ConnectionPool instance specified in the URI - will look it up."); // We have chosen to handle the connectionPool option ourselves, so // we must remove it from the given parameter list (see // http://camel.apache.org/writing-components.html) String poolId = properties.remove(CONNECTION_POOL).toString(); connectionPool = EndpointHelper.resolveReferenceParameter(getCamelContext(), poolId, AS400ConnectionPool.class, true); } else { LOG.trace("No AS400ConnectionPool instance specified in the URI - one will be provided."); connectionPool = getConnectionPool(); } String type = remaining.substring(remaining.lastIndexOf(".") + 1).toUpperCase(); Jt400Endpoint endpoint = new Jt400Endpoint(uri, this, connectionPool); setProperties(endpoint, properties); endpoint.setType(Jt400Type.valueOf(type)); return endpoint; }
private boolean excludedUrl(String url) { if (exclusions != null && !exclusions.isEmpty()) { for (String constraint : exclusions) { if (EndpointHelper.matchPattern(url, constraint)) { // force not matches if this was an exclusion return true; } } } return false; }
String stringValue = value != null ? value.toString() : null; boolean hit = false; if (stringValue != null && isReferenceParameter(stringValue)) {
String repeatString = (String) triggerParameters.get("repeatCount"); if (repeatString != null) { repeat = EndpointHelper.resolveParameter(getCamelContext(), repeatString, Integer.class); String intervalString = (String) triggerParameters.get("repeatInterval"); if (intervalString != null) { interval = EndpointHelper.resolveParameter(getCamelContext(), intervalString, Long.class);
@Override public Producer createProducer() throws Exception { Producer ret = null; initDriver(I2CProducer.class); device = bus.getDevice(deviceId); Constructor constructor = driverClass.getConstructor(I2CEndpoint.class, I2CDevice.class); ret = (Producer) constructor.newInstance(this, device); // Inject last parameter to i2c derived producer EndpointHelper.setProperties(this.getCamelContext(), ret, parameters); if (!parameters.isEmpty()) { for (String param : parameters.keySet()) { LOG.warn( "There are parameters that couldn't be set on the endpoint Producer. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint." + " Unknown Producer parameters=[" + param + "]"); } } return ret; }
String[] names = providersRef.split(","); for (String name : names) { Object provider = EndpointHelper.resolveReferenceParameter(getCamelContext(), name, Object.class, true); setProvider(provider);
private boolean allowCreate(Class type) { String name = type.getName(); // deny takes precedence if (denyClasses != null) { String[] arr = denyClasses.split(","); for (String key : arr) { if (EndpointHelper.matchPattern(name, key)) { return false; } } } // deny takes precedence if (allowClasses != null) { String[] arr = allowClasses.split(","); for (String key : arr) { if (EndpointHelper.matchPattern(name, key)) { return true; } } } // deny by default return false; } }
if (EndpointHelper.isReferenceParameter(value)) { String name = value.substring(1); Object o = CamelContextHelper.mandatoryLookup(camelContext, name);
String intervalString = (String) triggerParameters.get("repeatInterval"); if (intervalString != null) { long interval = EndpointHelper.resolveParameter(getCamelContext(), intervalString, Long.class); answer.getJobDetail().getJobDataMap().put(QuartzConstants.QUARTZ_TRIGGER_TYPE, "cron"); answer.getJobDetail().getJobDataMap().put(QuartzConstants.QUARTZ_TRIGGER_CRON_EXPRESSION, cron); String timeZone = EndpointHelper.resolveParameter(getCamelContext(), (String)triggerParameters.get("timeZone"), String.class); if (timeZone != null) { answer.getJobDetail().getJobDataMap().put(QuartzConstants.QUARTZ_TRIGGER_CRON_TIMEZONE, timeZone); Long interval = EndpointHelper.resolveParameter(getCamelContext(), (String)triggerParameters.get("repeatInterval"), Long.class); if (interval != null) { triggerParameters.put("repeatInterval", interval); answer.getJobDetail().getJobDataMap().put(QuartzConstants.QUARTZ_TRIGGER_SIMPLE_REPEAT_INTERVAL, interval); Integer counter = EndpointHelper.resolveParameter(getCamelContext(), (String)triggerParameters.get("repeatCount"), Integer.class); if (counter != null) { triggerParameters.put("repeatCount", counter);
@Deprecated public IgniteQueueEndpoint(String endpointUri, URI remainingUri, Map<String, Object> parameters, IgniteComponent igniteComponent) throws Exception { super(endpointUri, igniteComponent); name = remainingUri.getHost(); ObjectHelper.notNull(name, "Queue name"); // Set the configuration values. if (!parameters.containsKey("configuration")) { Map<String, Object> configProps = IntrospectionSupport.extractProperties(parameters, "config."); EndpointHelper.setReferenceProperties(this.getCamelContext(), configProps, parameters); EndpointHelper.setProperties(this.getCamelContext(), configProps, parameters); } }
@Override protected void doStart() throws Exception { super.doStart(); Processor target; if (EndpointHelper.isReferenceParameter(contentHandlerClass)) { ContentHandler handler = EndpointHelper.resolveReferenceParameter(getCamelContext(), contentHandlerClass.substring(1), ContentHandler.class, true); target = new StAXProcessor(handler); } else { Class<ContentHandler> clazz = getCamelContext().getClassResolver().resolveMandatoryClass(contentHandlerClass, ContentHandler.class); target = new StAXProcessor(clazz); } setProcessor(target); }
/** * Configures the messageFilter's factory. The factory is looked up in the endpoint's URI and then in the Spring's context. * The bean search mechanism looks for a bean with the name messageFilter. * The endpoint's URI search mechanism looks for the URI's key parameter name messageFilter, for instance like this: * spring-ws:http://yourdomain.com?messageFilter=<beanName> */ private void configureMessageFilter(SpringWebserviceConfiguration configuration) { if (configuration.getMessageFilter() == null) { // try to lookup a global filter to use final MessageFilter globalMessageFilter = EndpointHelper.resolveReferenceParameter(getCamelContext(), "messageFilter", MessageFilter.class, false); if (globalMessageFilter != null) { configuration.setMessageFilter(globalMessageFilter); } else { // use basic as fallback configuration.setMessageFilter(new BasicMessageFilter()); } } }
private String includedUrl(String url) { String candidate = null; if (inclusions != null && !inclusions.isEmpty()) { for (String constraint : inclusions.keySet()) { if (EndpointHelper.matchPattern(url, constraint)) { if (candidate == null) { candidate = constraint; } else if (constraint.length() > candidate.length()) { // we want the constraint that has the longest context-path matching as its // the most explicit for the target url candidate = constraint; } } } return candidate; } // by default if no included has been configured then everything is restricted return "*"; }
/** * Does the pattern match the endpoint? * * @param uri the uri * @param endpoint the endpoint * @param pattern the pattern * @return <tt>true</tt> to match and therefore intercept, <tt>false</tt> if not matched and should not intercept */ protected boolean matchPattern(String uri, Endpoint endpoint, String pattern) { return uri == null || pattern == null || EndpointHelper.matchEndpoint(endpoint.getCamelContext(), uri, pattern); }
if (EndpointHelper.isReferenceParameter(value)) { String name = value.substring(1); Object o = CamelContextHelper.mandatoryLookup(camelContext, name);