camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lburgazz...@apache.org
Subject camel git commit: CAMEL-11108: camel-infinispan : change the uri syntax from infinispan:hostName to infinispan:cacheName
Date Wed, 12 Apr 2017 07:44:03 GMT
Repository: camel
Updated Branches:
  refs/heads/master 07b53e108 -> 49f2bb517


CAMEL-11108: camel-infinispan : change the uri syntax from infinispan:hostName to infinispan:cacheName


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/49f2bb51
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/49f2bb51
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/49f2bb51

Branch: refs/heads/master
Commit: 49f2bb51710a17e1506262d9d58ca1543a747156
Parents: 07b53e1
Author: lburgazzoli <lburgazzoli@gmail.com>
Authored: Thu Apr 6 15:11:54 2017 +0200
Committer: lburgazzoli <lburgazzoli@gmail.com>
Committed: Wed Apr 12 09:43:19 2017 +0200

----------------------------------------------------------------------
 .../src/main/docs/infinispan-component.adoc     |  27 ++-
 .../infinispan/InfinispanComponent.java         |  55 +++++-
 .../infinispan/InfinispanConfiguration.java     |  58 ++++---
 .../infinispan/InfinispanConsumer.java          |   6 +-
 .../infinispan/InfinispanEndpoint.java          |  28 ++-
 .../component/infinispan/InfinispanManager.java | 106 ++++++++----
 .../infinispan/InfinispanProducer.java          |   6 +-
 .../component/infinispan/InfinispanUtil.java    |  27 ++-
 .../InfinispanIdempotentRepository.java         |   3 +-
 .../infinispan/InfinispanAsyncConsumerTest.java |  19 +--
 .../InfinispanClusteredConsumerTest.java        |   4 +-
 .../infinispan/InfinispanComponentTest.java     |  29 ++--
 .../InfinispanConfigurationTestIT.java          |  15 +-
 .../InfinispanConsumerEntryCreatedTest.java     |   2 +-
 .../InfinispanConsumerEntryRemovedTest.java     |   2 +-
 .../InfinispanConsumerEntryUpdatedTest.java     |   2 +-
 .../InfinispanConsumerEntryVisitedTest.java     |   2 +-
 .../infinispan/InfinispanContinuousQueryIT.java |   6 +-
 ...InfinispanLocalConsumerCustomListenerIT.java |   5 +-
 .../infinispan/InfinispanLocalConsumerTest.java |   4 +-
 .../infinispan/InfinispanProducerTest.java      |  34 ++--
 .../InfinispanRemoteProducerTest.java           |   2 +-
 .../InfinispanRemoteQueryProducerIT.java        |  28 ++-
 .../infinispan/InfinispanSyncConsumerTest.java  |   2 +-
 .../InfinispanComponentAutoConfiguration.java   |  33 +++-
 .../InfinispanComponentConfiguration.java       | 169 +++++++++++++++++++
 26 files changed, 483 insertions(+), 191 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/main/docs/infinispan-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/docs/infinispan-component.adoc b/components/camel-infinispan/src/main/docs/infinispan-component.adoc
index 85f2615..c7821bf 100644
--- a/components/camel-infinispan/src/main/docs/infinispan-component.adoc
+++ b/components/camel-infinispan/src/main/docs/infinispan-component.adoc
@@ -26,7 +26,7 @@ for this component:
 
 [source,java]
 -------------------------------
-infinispan://hostName?[options]
+infinispan://cacheName?[options]
 -------------------------------
 
 ### URI Options
@@ -38,7 +38,17 @@ accessible from the registry.
 
 
 // component options: START
-The Infinispan component has no options.
+The Infinispan component supports 3 options which are listed below.
+
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|=======================================================================
+| Name | Description | Default | Type
+| **configuration** (common) | The default configuration shared among endpoints. |  | InfinispanConfiguration
+| **cacheContainer** (common) | The default cache container. |  | BasicCacheContainer
+| **resolveProperty Placeholders** (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
+|=======================================================================
 // component options: END
 
 
@@ -47,16 +57,17 @@ The Infinispan component has no options.
 // endpoint options: START
 The Infinispan endpoint is configured using URI syntax:
 
-    infinispan:host
+    infinispan:cacheName
 
 with the following path and query parameters:
 
-#### Path Parameters (1 parameters):
+#### Path Parameters (2 parameters):
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |=======================================================================
 | Name | Description | Default | Type
-| **host** | *Required* Specifies the host of the cache on Infinispan instance |  | String
+| **cacheName** | *Required* The cache to use |  | String
+| **hosts** | Specifies the host of the cache on Infinispan instance |  | String
 |=======================================================================
 
 #### Query Parameters (15 parameters):
@@ -64,8 +75,6 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |=======================================================================
 | Name | Description | Default | Type
-| **cacheContainer** (common) | Specifies the cache Container to connect |  | BasicCacheContainer
-| **cacheName** (common) | Specifies the cache name |  | String
 | **queryBuilder** (common) | Specifies the query builder. |  | InfinispanQueryBuilder
 | **bridgeErrorHandler** (consumer) | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN or ERROR level and ignored. | false | boolean
 | **clusteredListener** (consumer) | If true the listener will be installed for the entire cluster | false | boolean
@@ -75,7 +84,9 @@ with the following path and query parameters:
 | **exceptionHandler** (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | **exchangePattern** (consumer) | Sets the exchange pattern when the consumer creates an exchange. |  | ExchangePattern
 | **command** (producer) | The operation to perform. | put | String
-| **configurationProperties** (advanced) | Infinispan configuration properties. |  | Map
+| **cacheContainer** (advanced) | Specifies the cache Container to connect |  | BasicCacheContainer
+| **cacheContainerConfiguration** (advanced) | The CacheContainer configuration |  | Object
+| **configurationProperties** (advanced) | Implementation specific properties for the CacheManager |  | Map
 | **configurationUri** (advanced) | An implementation specific URI for the CacheManager |  | String
 | **flags** (advanced) | A comma separated list of Flag to be applied by default on each cache invocation not applicable to remote caches. |  | String
 | **synchronous** (advanced) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java
index 7547836..4d7c669 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java
@@ -18,20 +18,61 @@ package org.apache.camel.component.infinispan;
 
 import java.util.Map;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
-import org.apache.camel.impl.UriEndpointComponent;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.spi.Metadata;
+import org.infinispan.commons.api.BasicCacheContainer;
 
-public class InfinispanComponent extends UriEndpointComponent {
+public class InfinispanComponent extends DefaultComponent {
+    @Metadata(description = "Default configuration")
+    private InfinispanConfiguration configuration;
+    @Metadata(description = "Default Cache container")
+    private BasicCacheContainer cacheContainer;
 
     public InfinispanComponent() {
-        super(InfinispanEndpoint.class);
+    }
+
+    public InfinispanComponent(CamelContext camelContext) {
+        super(camelContext);
+    }
+
+    public InfinispanConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    /**
+     * The default configuration shared among endpoints.
+     */
+    public void setConfiguration(InfinispanConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    public BasicCacheContainer getCacheContainer() {
+        return cacheContainer;
+    }
+
+    /**
+     * The default cache container.
+     */
+    public void setCacheContainer(BasicCacheContainer cacheContainer) {
+        this.cacheContainer = cacheContainer;
     }
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        InfinispanConfiguration configuration = new InfinispanConfiguration();
-        configuration.setHost(remaining);
-        setProperties(configuration, parameters);
-        return new InfinispanEndpoint(uri, this, configuration);
+
+        InfinispanConfiguration conf;
+        if (configuration != null) {
+            conf = configuration.copy();
+        } else {
+            conf = new InfinispanConfiguration();
+        }
+
+        conf.setCacheContainer(cacheContainer);
+
+        setProperties(conf, parameters);
+
+        return new InfinispanEndpoint(uri, remaining, this, conf);
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
index 0835974..837c805 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
@@ -22,7 +22,7 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.camel.spi.Metadata;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 import org.apache.camel.spi.UriPath;
@@ -31,13 +31,9 @@ import org.infinispan.commons.api.BasicCacheContainer;
 import org.infinispan.context.Flag;
 
 @UriParams
-public class InfinispanConfiguration {
-    @UriPath @Metadata(required = "true")
-    private String host;
-    @UriParam
-    private BasicCacheContainer cacheContainer;
-    @UriParam
-    private String cacheName;
+public class InfinispanConfiguration implements Cloneable {
+    @UriPath
+    private String hosts;
     @UriParam(label = "producer", defaultValue = "put", enums =
              "put,putAll,putIfAbsent,putAsync,putAllAsync,putIfAbsentAsync,"
            + "get,"
@@ -64,6 +60,10 @@ public class InfinispanConfiguration {
     private String configurationUri;
     @UriParam(label = "advanced")
     private Map<String, String> configurationProperties;
+    @UriParam(label = "advanced")
+    private BasicCacheContainer cacheContainer;
+    @UriParam(label = "advanced")
+    private Object cacheContainerConfiguration;
 
 
     public String getCommand() {
@@ -84,12 +84,12 @@ public class InfinispanConfiguration {
     /**
      * Specifies the host of the cache on Infinispan instance
      */
-    public String getHost() {
-        return host;
+    public String getHosts() {
+        return hosts;
     }
 
-    public void setHost(String host) {
-        this.host = host;
+    public void setHosts(String hosts) {
+        this.hosts = hosts;
     }
 
     /**
@@ -104,17 +104,6 @@ public class InfinispanConfiguration {
     }
 
     /**
-     * Specifies the cache name
-     */
-    public String getCacheName() {
-        return cacheName;
-    }
-
-    public void setCacheName(String cacheName) {
-        this.cacheName = cacheName;
-    }
-
-    /**
     * If true, the consumer will receive notifications synchronously
     */
     public boolean isSync() {
@@ -233,14 +222,14 @@ public class InfinispanConfiguration {
     }
 
     /**
-     * Infinispan configuration properties.
+     * Implementation specific properties for the CacheManager
      */
     public void setConfigurationProperties(Map<String, String> configurationProperties) {
         this.configurationProperties = configurationProperties;
     }
 
     /**
-     * Add configuration
+     * Adds an implementation specific property for the CacheManager
      */
     public void addConfigurationProperty(String key, String value) {
         if (this.configurationProperties == null) {
@@ -249,4 +238,23 @@ public class InfinispanConfiguration {
 
         this.configurationProperties.put(key, value);
     }
+
+    public Object getCacheContainerConfiguration() {
+        return cacheContainerConfiguration;
+    }
+
+    /**
+     * The CacheContainer configuration
+     */
+    public void setCacheContainerConfiguration(Object cacheContainerConfiguration) {
+        this.cacheContainerConfiguration = cacheContainerConfiguration;
+    }
+
+    public InfinispanConfiguration copy() {
+        try {
+            return (InfinispanConfiguration)super.clone();
+        } catch (CloneNotSupportedException e) {
+            throw new RuntimeCamelException(e);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConsumer.java b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConsumer.java
index 34463fb..d847ae4 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConsumer.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConsumer.java
@@ -35,13 +35,15 @@ public class InfinispanConsumer extends DefaultConsumer {
     private static final transient Logger LOGGER = LoggerFactory.getLogger(InfinispanProducer.class);
     private final InfinispanConfiguration configuration;
     private final InfinispanManager manager;
+    private final String cacheName;
     private InfinispanEventListener listener;
     private InfinispanConsumerHandler consumerHandler;
     private BasicCache<Object, Object> cache;
     private ContinuousQuery<Object, Object> continuousQuery;
 
-    public InfinispanConsumer(InfinispanEndpoint endpoint, Processor processor, InfinispanConfiguration configuration) {
+    public InfinispanConsumer(InfinispanEndpoint endpoint, Processor processor, String cacheName, InfinispanConfiguration configuration) {
         super(endpoint, processor);
+        this.cacheName = cacheName;
         this.configuration = configuration;
         this.manager = new InfinispanManager(endpoint.getCamelContext(), configuration);
     }
@@ -72,7 +74,7 @@ public class InfinispanConsumer extends DefaultConsumer {
         super.doStart();
         manager.start();
 
-        cache = manager.getCache();
+        cache = manager.getCache(cacheName);
         if (configuration.hasQueryBuilder()) {
             if (InfinispanUtil.isRemote(cache)) {
                 RemoteCache<Object, Object> remoteCache = InfinispanUtil.asRemote(cache);

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
index 624ce1c..2a315fe 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
@@ -20,33 +20,38 @@ import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
 
 /**
  * For reading/writing from/to Infinispan distributed key/value store and data grid.
  */
-@UriEndpoint(firstVersion = "2.13.0", scheme = "infinispan", title = "Infinispan", syntax = "infinispan:host", consumerClass = InfinispanConsumer.class, label = "cache,datagrid,clustering")
+@UriEndpoint(firstVersion = "2.13.0", scheme = "infinispan", title = "Infinispan", syntax = "infinispan:cacheName", consumerClass = InfinispanConsumer.class, label = "cache,datagrid,clustering")
 public class InfinispanEndpoint extends DefaultEndpoint {
-    @UriParam
-    private InfinispanConfiguration configuration;
 
-    public InfinispanEndpoint() {
-    }
+    @UriPath(description = "The cache to use")
+    @Metadata(required = "true")
+    private final String cacheName;
+
+    @UriParam
+    private final InfinispanConfiguration configuration;
 
-    public InfinispanEndpoint(String uri, InfinispanComponent component, InfinispanConfiguration configuration) {
+    public InfinispanEndpoint(String uri, String cacheName, InfinispanComponent component, InfinispanConfiguration configuration) {
         super(uri, component);
+        this.cacheName = cacheName;
         this.configuration = configuration;
     }
 
     @Override
     public Producer createProducer() throws Exception {
-        return new InfinispanProducer(this, configuration);
+        return new InfinispanProducer(this, cacheName, configuration);
     }
 
     @Override
     public Consumer createConsumer(Processor processor) throws Exception {
-        return new InfinispanConsumer(this, processor, configuration);
+        return new InfinispanConsumer(this, processor, cacheName, configuration);
     }
 
     @Override
@@ -54,4 +59,11 @@ public class InfinispanEndpoint extends DefaultEndpoint {
         return true;
     }
 
+    public String getCacheName() {
+        return cacheName;
+    }
+
+    public InfinispanConfiguration getConfiguration() {
+        return configuration;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanManager.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanManager.java b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanManager.java
index 8b739bb..24ad853 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanManager.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanManager.java
@@ -16,12 +16,13 @@
  */
 package org.apache.camel.component.infinispan;
 
-
+import java.io.InputStream;
 import java.util.Properties;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Service;
+import org.apache.camel.util.ObjectHelper;
 import org.infinispan.cache.impl.DecoratedCache;
 import org.infinispan.client.hotrod.RemoteCacheManager;
 import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
@@ -57,35 +58,71 @@ public class InfinispanManager implements Service {
     @Override
     public void start() throws Exception {
         cacheContainer = configuration.getCacheContainer();
-        if (cacheContainer == null) {
-            ConfigurationBuilder builder = new ConfigurationBuilder();
-            builder.classLoader(Thread.currentThread().getContextClassLoader());
-
-            Properties properties = new Properties();
-
-            String uri = configuration.getConfigurationUri();
-            if (uri != null && camelContext != null) {
-                uri = camelContext.resolvePropertyPlaceholders(uri);
-            }
 
-            if (uri != null) {
-                properties.putAll(InfinispanUtil.loadProperties(camelContext, uri));
-            }
-            if (configuration.getConfigurationProperties() != null) {
-                properties.putAll(configuration.getConfigurationProperties());
+        if (cacheContainer == null) {
+            // Check if a container configuration object has been provided so use
+            // it and discard any other additional configuration.
+            if (configuration.getCacheContainerConfiguration() != null) {
+                final Object containerConf = configuration.getCacheContainerConfiguration();
+                if (containerConf instanceof org.infinispan.client.hotrod.configuration.Configuration) {
+                    cacheContainer = new RemoteCacheManager(
+                        (org.infinispan.client.hotrod.configuration.Configuration)containerConf,
+                        true
+                    );
+                } else if (containerConf instanceof org.infinispan.configuration.cache.Configuration) {
+                    cacheContainer = new DefaultCacheManager(
+                        (org.infinispan.configuration.cache.Configuration)containerConf,
+                        true
+                    );
+                } else {
+                    throw new IllegalArgumentException("Unsupported CacheContainer Configuration type: " + containerConf.getClass());
+                }
             }
 
-            if (!properties.isEmpty()) {
-                builder.withProperties(properties);
+            // If the hosts properties has been configured, it means we want to
+            // connect to a remote cache so set-up a RemoteCacheManager
+            if (cacheContainer == null && configuration.getHosts() != null) {
+                ConfigurationBuilder builder = new ConfigurationBuilder();
+                builder.addServers(configuration.getHosts());
+
+                if (camelContext != null && camelContext.getApplicationContextClassLoader() != null) {
+                    builder.classLoader(camelContext.getApplicationContextClassLoader());
+                } else {
+                    builder.classLoader(Thread.currentThread().getContextClassLoader());
+                }
+
+                Properties properties = new Properties();
+
+                // Properties can be set either via a properties file or via
+                // properties on configuration, if you set both they are merged
+                // with properties defined on configuration overriding those from
+                // file.
+                if (ObjectHelper.isNotEmpty(configuration.getConfigurationUri())) {
+                    properties.putAll(InfinispanUtil.loadProperties(camelContext, configuration.getConfigurationUri()));
+                }
+                if (ObjectHelper.isNotEmpty(configuration.getConfigurationProperties())) {
+                    properties.putAll(configuration.getConfigurationProperties());
+                }
+                if (!properties.isEmpty()) {
+                    builder.withProperties(properties);
+                }
+
+                cacheContainer = new RemoteCacheManager(builder.build(), true);
             }
 
-            if (configuration.getHost() != null) {
-                builder.addServers(configuration.getHost());
+            // Finally we can set-up a DefaultCacheManager if none of the methods
+            // above was triggered. You can configure the cache using a configuration
+            // file.
+            if (cacheContainer == null) {
+                if (ObjectHelper.isNotEmpty(configuration.getConfigurationUri())) {
+                    try (InputStream is = InfinispanUtil.openInputStream(camelContext, configuration.getConfigurationUri())) {
+                        cacheContainer = new DefaultCacheManager(is, true);
+                    }
+                } else {
+                    cacheContainer = new DefaultCacheManager(true);
+                }
             }
 
-
-
-            cacheContainer = new RemoteCacheManager(builder.build(), true);
             isManagedCacheContainer = true;
         }
     }
@@ -109,26 +146,25 @@ public class InfinispanManager implements Service {
         return InfinispanUtil.isRemote(cacheContainer);
     }
 
-    public <K, V > BasicCache<K, V> getCache() {
-        return getCache(configuration.getCacheName());
-    }
-
-    public <K, V > BasicCache<K, V> getCache(Exchange exchange) {
-        return getCache(exchange.getIn().getHeader(InfinispanConstants.CACHE_NAME, String.class));
-    }
-
-    public <K, V > BasicCache<K, V> getCache(String cacheName) {
-        if (cacheName == null) {
-            cacheName = configuration.getCacheName();
+    public <K, V> BasicCache<K, V> getCache(String cacheName) {
+        BasicCache<K, V> cache;
+        if (ObjectHelper.isEmpty(cacheName)) {
+            cache = cacheContainer.getCache();
+            cacheName = cache.getName();
+        } else {
+            cache = cacheContainer.getCache(cacheName);
         }
 
         LOGGER.trace("Cache[{}]", cacheName);
 
-        BasicCache<K, V> cache = InfinispanUtil.getCache(cacheContainer, cacheName);
         if (configuration.hasFlags() && InfinispanUtil.isEmbedded(cache)) {
             cache = new DecoratedCache(InfinispanUtil.asAdvanced(cache), configuration.getFlags());
         }
 
         return cache;
     }
+
+    public <K, V> BasicCache<K, V> getCache(Exchange exchange, String defaultCache) {
+        return getCache(exchange.getIn().getHeader(InfinispanConstants.CACHE_NAME, defaultCache, String.class));
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanProducer.java b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanProducer.java
index 6fbd1c1..7c770a9 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanProducer.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanProducer.java
@@ -20,18 +20,20 @@ import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultProducer;
 
 public class InfinispanProducer extends DefaultProducer {
+    private final String cacheName;
     private final InfinispanConfiguration configuration;
     private final InfinispanManager manager;
 
-    public InfinispanProducer(InfinispanEndpoint endpoint, InfinispanConfiguration configuration) {
+    public InfinispanProducer(InfinispanEndpoint endpoint, String cacheName, InfinispanConfiguration configuration) {
         super(endpoint);
+        this.cacheName = cacheName;
         this.configuration = configuration;
         this.manager = new InfinispanManager(endpoint.getCamelContext(), configuration);
     }
 
     @Override
     public void process(Exchange exchange) throws Exception {
-        InfinispanOperation.process(exchange, configuration, manager.getCache(exchange));
+        InfinispanOperation.process(exchange, configuration, manager.getCache(exchange, this.cacheName));
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanUtil.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanUtil.java b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanUtil.java
index 4de6319..282f997 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanUtil.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanUtil.java
@@ -106,22 +106,8 @@ public final class InfinispanUtil {
         return ObjectHelper.isEmpty(message.getHeader(header));
     }
 
-    public static <K, V> BasicCache<K, V> getCache(BasicCacheContainer cacheContainer, String cacheName) {
-        return ObjectHelper.isEmpty(cacheName) ? cacheContainer.getCache() : cacheContainer.getCache(cacheName);
-    }
-
-    public static Properties loadProperties(CamelContext camelContext, String uri) throws IOException {
-        if (camelContext != null) {
-            try (InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, uri)) {
-                Properties properties = new Properties();
-                properties.load(is);
-
-                return properties;
-            } catch (IOException e) {
-            }
-        }
-
-        try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(uri)) {
+    public static Properties loadProperties(CamelContext camelContext, String uri) throws Exception {
+        try (InputStream is = openInputStream(camelContext, uri)) {
             Properties properties = new Properties();
             properties.load(is);
 
@@ -131,4 +117,13 @@ public final class InfinispanUtil {
 
         throw new FileNotFoundException("Cannot find resource: " + uri);
     }
+
+    public static InputStream openInputStream(CamelContext camelContext, String uri) throws Exception {
+        if (camelContext != null) {
+            uri = camelContext.resolvePropertyPlaceholders(uri);
+            return ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, uri);
+        }
+
+        return Thread.currentThread().getContextClassLoader().getResourceAsStream(uri);
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
index 6f33693..4d605a8 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
@@ -50,8 +50,7 @@ public class InfinispanIdempotentRepository extends ServiceSupport implements Id
         this(null);
     }
 
-    public static InfinispanIdempotentRepository infinispanIdempotentRepository(
-            BasicCacheContainer cacheContainer, String processorName) {
+    public static InfinispanIdempotentRepository infinispanIdempotentRepository(BasicCacheContainer cacheContainer, String processorName) {
         return new InfinispanIdempotentRepository(cacheContainer, processorName);
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanAsyncConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanAsyncConsumerTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanAsyncConsumerTest.java
index dc44483..59112cd 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanAsyncConsumerTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanAsyncConsumerTest.java
@@ -16,23 +16,20 @@
  */
 package org.apache.camel.component.infinispan;
 
-import org.apache.camel.EndpointInject;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.Test;
 
 public class InfinispanAsyncConsumerTest extends InfinispanTestSupport {
-
-    @EndpointInject(uri = "mock:result")
-    private MockEndpoint mockResult;
-
     @Test
     public void consumerReceivedPreAndPostEntryCreatedEventNotifications() throws Exception {
-        mockResult.expectedMessageCount(2);
-        mockResult.setResultMinimumWaitTime(900);
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(2);
+        mock.setResultMinimumWaitTime(900);
 
         currentCache().put(KEY_ONE, VALUE_ONE);
-        mockResult.assertIsSatisfied();
+
+        mock.assertIsSatisfied();
     }
 
     @Override
@@ -40,9 +37,9 @@ public class InfinispanAsyncConsumerTest extends InfinispanTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("infinispan://localhost?cacheContainer=#cacheContainer&sync=false&eventTypes=CACHE_ENTRY_CREATED")
-                        .delayer(500)
-                        .to("mock:result");
+                from("infinispan?cacheContainer=#cacheContainer&sync=false&eventTypes=CACHE_ENTRY_CREATED")
+                    .delayer(500)
+                    .to("mock:result");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanClusteredConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanClusteredConsumerTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanClusteredConsumerTest.java
index 85879f1..a773b5a 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanClusteredConsumerTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanClusteredConsumerTest.java
@@ -95,9 +95,9 @@ public class InfinispanClusteredConsumerTest extends InfinispanClusterTestSuppor
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("infinispan://localhost?cacheContainer=#cacheContainer&clusteredListener=true&eventTypes=CACHE_ENTRY_CREATED")
+                from("infinispan?cacheContainer=#cacheContainer&clusteredListener=true&eventTypes=CACHE_ENTRY_CREATED")
                         .to("mock:resultCreated");
-                from("infinispan://localhost?cacheContainer=#cacheContainer&clusteredListener=true&eventTypes=CACHE_ENTRY_EXPIRED")
+                from("infinispan?cacheContainer=#cacheContainer&clusteredListener=true&eventTypes=CACHE_ENTRY_EXPIRED")
                         .to("mock:resultExpired");
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentTest.java
index 576155c..2ea1860 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentTest.java
@@ -16,8 +16,8 @@
  */
 package org.apache.camel.component.infinispan;
 
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
+import java.util.UUID;
+
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.Test;
@@ -25,28 +25,26 @@ import org.junit.Test;
 import static org.hamcrest.core.Is.is;
 
 public class InfinispanComponentTest extends InfinispanTestSupport {
+    private final String cacheName = UUID.randomUUID().toString();
 
     @Test
     public void consumerReceivedEntryCreatedEventNotifications() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMinimumMessageCount(2);
 
-        currentCache().put(KEY_ONE, VALUE_ONE);
+        namedCache(cacheName).put(KEY_ONE, VALUE_ONE);
         assertMockEndpointsSatisfied();
     }
 
     @Test
     public void producerPublishesKeyAndValue() throws Exception {
-        template.send("direct:start", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(InfinispanConstants.KEY, KEY_ONE);
-                exchange.getIn().setHeader(InfinispanConstants.VALUE, VALUE_ONE);
-            }
-        });
+        fluentTemplate()
+            .to("direct:start")
+            .withHeader(InfinispanConstants.KEY, KEY_ONE)
+            .withHeader(InfinispanConstants.VALUE, VALUE_ONE)
+            .send();
 
-        Object value = currentCache().get(KEY_ONE);
-        assertThat(value.toString(), is(VALUE_ONE));
+        assertThat(namedCache(cacheName).get(KEY_ONE).toString(), is(VALUE_ONE));
     }
 
     @Override
@@ -54,11 +52,10 @@ public class InfinispanComponentTest extends InfinispanTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("infinispan://localhost?cacheContainer=#cacheContainer&eventTypes=CACHE_ENTRY_CREATED")
-                        .to("mock:result");
-
+                fromF("infinispan:%s?cacheContainer=#cacheContainer&eventTypes=CACHE_ENTRY_CREATED", cacheName)
+                    .to("mock:result");
                 from("direct:start")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer");
+                    .toF("infinispan:%s?cacheContainer=#cacheContainer", cacheName);
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConfigurationTestIT.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConfigurationTestIT.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConfigurationTestIT.java
index 48c7772..88d8ceb 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConfigurationTestIT.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConfigurationTestIT.java
@@ -32,8 +32,7 @@ public class InfinispanConfigurationTestIT {
     @Test
     public void embeddedCacheWithFlagsTest() throws Exception {
         InfinispanConfiguration configuration = new InfinispanConfiguration();
-        configuration.setHost("localhost");
-        configuration.setCacheName("misc_cache");
+        configuration.setHosts("localhost");
         configuration.setCacheContainer(new DefaultCacheManager(true));
         configuration.setFlags(
             org.infinispan.context.Flag.SKIP_CACHE_LOAD,
@@ -43,7 +42,7 @@ public class InfinispanConfigurationTestIT {
         InfinispanManager manager = new InfinispanManager(configuration);
         manager.start();
 
-        BasicCache<Object, Object> cache = manager.getCache();
+        BasicCache<Object, Object> cache = manager.getCache("misc_cache");
         assertNotNull(cache);
         assertTrue(cache instanceof DecoratedCache);
 
@@ -58,13 +57,12 @@ public class InfinispanConfigurationTestIT {
     @Test
     public void remoteCacheWithoutProperties() throws Exception {
         InfinispanConfiguration configuration = new InfinispanConfiguration();
-        configuration.setHost("localhost");
-        configuration.setCacheName("misc_cache");
+        configuration.setHosts("localhost");
 
         InfinispanManager manager = new InfinispanManager(configuration);
         manager.start();
 
-        BasicCache<Object, Object> cache = manager.getCache();
+        BasicCache<Object, Object> cache = manager.getCache("misc_cache");
         assertNotNull(cache);
         assertTrue(cache instanceof RemoteCache);
 
@@ -80,14 +78,13 @@ public class InfinispanConfigurationTestIT {
     @Test
     public void remoteCacheWithPropertiesTest() throws Exception {
         InfinispanConfiguration configuration = new InfinispanConfiguration();
-        configuration.setHost("localhost");
-        configuration.setCacheName("misc_cache");
+        configuration.setHosts("localhost");
         configuration.setConfigurationUri("infinispan/client.properties");
 
         InfinispanManager manager = new InfinispanManager(configuration);
         manager.start();
 
-        BasicCache<Object, Object> cache = manager.getCache();
+        BasicCache<Object, Object> cache = manager.getCache("misc_cache");
         assertNotNull(cache);
         assertTrue(cache instanceof RemoteCache);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryCreatedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryCreatedTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryCreatedTest.java
index a4e910f..1940abd 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryCreatedTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryCreatedTest.java
@@ -49,7 +49,7 @@ public class InfinispanConsumerEntryCreatedTest extends InfinispanTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("infinispan://localhost?cacheContainer=#cacheContainer&sync=false&eventTypes=CACHE_ENTRY_CREATED")
+                from("infinispan?cacheContainer=#cacheContainer&sync=false&eventTypes=CACHE_ENTRY_CREATED")
                         .to("mock:result");
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryRemovedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryRemovedTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryRemovedTest.java
index ed1b023..791c5ff 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryRemovedTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryRemovedTest.java
@@ -51,7 +51,7 @@ public class InfinispanConsumerEntryRemovedTest extends InfinispanTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("infinispan://localhost?cacheContainer=#cacheContainer&sync=false&eventTypes=CACHE_ENTRY_REMOVED")
+                from("infinispan?cacheContainer=#cacheContainer&sync=false&eventTypes=CACHE_ENTRY_REMOVED")
                         .to("mock:result");
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryUpdatedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryUpdatedTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryUpdatedTest.java
index cb3adcf..16d0d65 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryUpdatedTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryUpdatedTest.java
@@ -51,7 +51,7 @@ public class InfinispanConsumerEntryUpdatedTest extends InfinispanTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("infinispan://localhost?cacheContainer=#cacheContainer&sync=false&eventTypes=CACHE_ENTRY_MODIFIED")
+                from("infinispan?cacheContainer=#cacheContainer&sync=false&eventTypes=CACHE_ENTRY_MODIFIED")
                         .to("mock:result");
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryVisitedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryVisitedTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryVisitedTest.java
index 106f3b2..4c2f87b 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryVisitedTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanConsumerEntryVisitedTest.java
@@ -51,7 +51,7 @@ public class InfinispanConsumerEntryVisitedTest extends InfinispanTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("infinispan://localhost?cacheContainer=#cacheContainer&sync=false&eventTypes=CACHE_ENTRY_VISITED")
+                from("infinispan?cacheContainer=#cacheContainer&sync=false&eventTypes=CACHE_ENTRY_VISITED")
                         .to("mock:result");
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanContinuousQueryIT.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanContinuousQueryIT.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanContinuousQueryIT.java
index 82888b0..6386b36 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanContinuousQueryIT.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanContinuousQueryIT.java
@@ -159,11 +159,11 @@ public class InfinispanContinuousQueryIT extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("infinispan://?cacheContainer=#myCustomContainer&cacheName=remote_query&queryBuilder=#continuousQueryBuilder")
+                from("infinispan:remote_query?cacheContainer=#myCustomContainer&queryBuilder=#continuousQueryBuilder")
                     .to("mock:continuousQuery");
-                from("infinispan://?cacheContainer=#myCustomContainer&cacheName=remote_query&queryBuilder=#continuousQueryBuilderNoMatch")
+                from("infinispan:remote_query?cacheContainer=#myCustomContainer&queryBuilder=#continuousQueryBuilderNoMatch")
                     .to("mock:continuousQueryNoMatch");
-                from("infinispan://?cacheContainer=#myCustomContainer&cacheName=remote_query&queryBuilder=#continuousQueryBuilderAll")
+                from("infinispan:remote_query?cacheContainer=#myCustomContainer&queryBuilder=#continuousQueryBuilderAll")
                     .to("mock:continuousQueryAll");
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanLocalConsumerCustomListenerIT.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanLocalConsumerCustomListenerIT.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanLocalConsumerCustomListenerIT.java
index 40015e9..877357c 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanLocalConsumerCustomListenerIT.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanLocalConsumerCustomListenerIT.java
@@ -23,7 +23,6 @@ import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
 public class InfinispanLocalConsumerCustomListenerIT extends InfinispanTestSupport {
-
     private static final String CUSTOM_CACHE_NAME = "customCacheName";
 
     @EndpointInject(uri = "mock:result")
@@ -41,8 +40,8 @@ public class InfinispanLocalConsumerCustomListenerIT extends InfinispanTestSuppo
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("infinispan://?cacheContainer=#cacheContainer&cacheName=" + CUSTOM_CACHE_NAME + "&customListener=#myCustomListener")
-                        .to("mock:result");
+                fromF("infinispan:%s?cacheContainer=#cacheContainer&customListener=#myCustomListener", CUSTOM_CACHE_NAME)
+                    .to("mock:result");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanLocalConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanLocalConsumerTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanLocalConsumerTest.java
index 2b0e881..7d218f9 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanLocalConsumerTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanLocalConsumerTest.java
@@ -70,9 +70,9 @@ public class InfinispanLocalConsumerTest extends InfinispanTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("infinispan://localhost?cacheContainer=#cacheContainer&eventTypes=CACHE_ENTRY_CREATED")
+                from("infinispan?cacheContainer=#cacheContainer&eventTypes=CACHE_ENTRY_CREATED")
                         .to("mock:result");
-                from("infinispan://localhost?cacheContainer=#cacheContainer&eventTypes=CACHE_ENTRY_EXPIRED")
+                from("infinispan?cacheContainer=#cacheContainer&eventTypes=CACHE_ENTRY_EXPIRED")
                         .to("mock:result2");
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanProducerTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanProducerTest.java
index 10cdc83..259e773 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanProducerTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanProducerTest.java
@@ -976,39 +976,39 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
             @Override
             public void configure() {
                 from("direct:start")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer");
+                    .to("infinispan?cacheContainer=#cacheContainer");
                 from("direct:put")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=PUT");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=PUT");
                 from("direct:putifabsent")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=PUTIFABSENT");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=PUTIFABSENT");
                 from("direct:get")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=GET");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=GET");
                 from("direct:remove")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=REMOVE");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=REMOVE");
                 from("direct:clear")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=CLEAR");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=CLEAR");
                 from("direct:replace")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=REPLACE");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=REPLACE");
                 from("direct:containskey")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=CONTAINSKEY");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=CONTAINSKEY");
                 from("direct:containsvalue")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=CONTAINSVALUE");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=CONTAINSVALUE");
                 from("direct:size")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=SIZE");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=SIZE");
                 from("direct:putasync")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=PUTASYNC");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=PUTASYNC");
                 from("direct:putallasync")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=PUTALLASYNC");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=PUTALLASYNC");
                 from("direct:putifabsentasync")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=PUTIFABSENTASYNC");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=PUTIFABSENTASYNC");
                 from("direct:replaceasync")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=REPLACEASYNC");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=REPLACEASYNC");
                 from("direct:removeasync")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=REMOVEASYNC");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=REMOVEASYNC");
                 from("direct:clearasync")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=CLEARASYNC");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=CLEARASYNC");
                 from("direct:stats")
-                        .to("infinispan://localhost?cacheContainer=#cacheContainer&command=STATS");
+                    .to("infinispan?cacheContainer=#cacheContainer&command=STATS");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanRemoteProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanRemoteProducerTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanRemoteProducerTest.java
index 941ad52..15b60c6 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanRemoteProducerTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanRemoteProducerTest.java
@@ -45,7 +45,7 @@ public class InfinispanRemoteProducerTest extends CamelTestSupport {
             @Override
             public void configure() {
                 from("direct:start")
-                        .to("infinispan://localhost");
+                        .to("infinispan://my-cache?hosts=localhost");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanRemoteQueryProducerIT.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanRemoteQueryProducerIT.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanRemoteQueryProducerIT.java
index 442c66a..79ac9a0 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanRemoteQueryProducerIT.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanRemoteQueryProducerIT.java
@@ -86,11 +86,11 @@ public class InfinispanRemoteQueryProducerIT extends CamelTestSupport {
             @Override
             public void configure() {
                 from("direct:start")
-                    .to("infinispan://?cacheContainer=#myCustomContainer&cacheName=remote_query");
+                    .to("infinispan:remote_query?cacheContainer=#myCustomContainer");
                 from("direct:noQueryResults")
-                    .to("infinispan://?cacheContainer=#myCustomContainer&cacheName=remote_query&queryBuilder=#noResultQueryBuilder");
+                    .to("infinispan:remote_query?cacheContainer=#myCustomContainer&queryBuilder=#noResultQueryBuilder");
                 from("direct:queryWithResults")
-                    .to("infinispan://?cacheContainer=#myCustomContainer&cacheName=remote_query&queryBuilder=#withResultQueryBuilder");
+                    .to("infinispan:remote_query?cacheContainer=#myCustomContainer&queryBuilder=#withResultQueryBuilder");
             }
         };
     }
@@ -105,19 +105,15 @@ public class InfinispanRemoteQueryProducerIT extends CamelTestSupport {
 
         manager = new RemoteCacheManager(builder.build());
 
-        RemoteCache<String, String> metadataCache = manager
-                .getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
-        metadataCache
-                .put("sample_bank_account/bank.proto",
-                        Util.read(InfinispanRemoteQueryProducerIT.class
-                                .getResourceAsStream("/sample_bank_account/bank.proto")));
-        MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller
-                .getSerializationContext(manager));
-
-        SerializationContext serCtx = ProtoStreamMarshaller
-                .getSerializationContext(manager);
-        serCtx.registerProtoFiles(FileDescriptorSource
-                .fromResources("/sample_bank_account/bank.proto"));
+        RemoteCache<String, String> metadataCache = manager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
+        metadataCache.put(
+            "sample_bank_account/bank.proto",
+            Util.read(InfinispanRemoteQueryProducerIT.class.getResourceAsStream("/sample_bank_account/bank.proto"))
+        );
+
+        MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext(manager));
+        SerializationContext serCtx = ProtoStreamMarshaller.getSerializationContext(manager);
+        serCtx.registerProtoFiles(FileDescriptorSource.fromResources("/sample_bank_account/bank.proto"));
         serCtx.registerMarshaller(new UserMarshaller());
         serCtx.registerMarshaller(new GenderMarshaller());
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanSyncConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanSyncConsumerTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanSyncConsumerTest.java
index f34618c..35bc86b 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanSyncConsumerTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanSyncConsumerTest.java
@@ -40,7 +40,7 @@ public class InfinispanSyncConsumerTest extends InfinispanTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("infinispan://localhost?cacheContainer=#cacheContainer&sync=false&eventTypes=CACHE_ENTRY_CREATED")
+                from("infinispan?cacheContainer=#cacheContainer&sync=false&eventTypes=CACHE_ENTRY_CREATED")
                         .delayer(500)
                         .to("mock:result");
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/platforms/spring-boot/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/springboot/InfinispanComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/springboot/InfinispanComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/springboot/InfinispanComponentAutoConfiguration.java
index d306bcf..144791c 100644
--- a/platforms/spring-boot/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/springboot/InfinispanComponentAutoConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/springboot/InfinispanComponentAutoConfiguration.java
@@ -16,8 +16,11 @@
  */
 package org.apache.camel.component.infinispan.springboot;
 
+import java.util.HashMap;
+import java.util.Map;
 import org.apache.camel.CamelContext;
 import org.apache.camel.component.infinispan.InfinispanComponent;
+import org.apache.camel.util.IntrospectionSupport;
 import org.springframework.boot.autoconfigure.AutoConfigureAfter;
 import org.springframework.boot.autoconfigure.condition.ConditionMessage;
 import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
@@ -26,6 +29,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
 import org.springframework.boot.bind.RelaxedPropertyResolver;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ConditionContext;
 import org.springframework.context.annotation.Conditional;
@@ -40,6 +44,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
 @ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
 @Conditional(InfinispanComponentAutoConfiguration.Condition.class)
 @AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
+@EnableConfigurationProperties(InfinispanComponentConfiguration.class)
 public class InfinispanComponentAutoConfiguration {
 
     @Lazy
@@ -47,9 +52,35 @@ public class InfinispanComponentAutoConfiguration {
     @ConditionalOnClass(CamelContext.class)
     @ConditionalOnMissingBean(InfinispanComponent.class)
     public InfinispanComponent configureInfinispanComponent(
-            CamelContext camelContext) throws Exception {
+            CamelContext camelContext,
+            InfinispanComponentConfiguration configuration) throws Exception {
         InfinispanComponent component = new InfinispanComponent();
         component.setCamelContext(camelContext);
+        Map<String, Object> parameters = new HashMap<>();
+        IntrospectionSupport.getProperties(configuration, parameters, null,
+                false);
+        for (Map.Entry<String, Object> entry : parameters.entrySet()) {
+            Object value = entry.getValue();
+            Class<?> paramClass = value.getClass();
+            if (paramClass.getName().endsWith("NestedConfiguration")) {
+                Class nestedClass = null;
+                try {
+                    nestedClass = (Class) paramClass.getDeclaredField(
+                            "CAMEL_NESTED_CLASS").get(null);
+                    HashMap<String, Object> nestedParameters = new HashMap<>();
+                    IntrospectionSupport.getProperties(value, nestedParameters,
+                            null, false);
+                    Object nestedProperty = nestedClass.newInstance();
+                    IntrospectionSupport.setProperties(camelContext,
+                            camelContext.getTypeConverter(), nestedProperty,
+                            nestedParameters);
+                    entry.setValue(nestedProperty);
+                } catch (NoSuchFieldException e) {
+                }
+            }
+        }
+        IntrospectionSupport.setProperties(camelContext,
+                camelContext.getTypeConverter(), component, parameters);
         return component;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/49f2bb51/platforms/spring-boot/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/springboot/InfinispanComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/springboot/InfinispanComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/springboot/InfinispanComponentConfiguration.java
index d15a081..c4afece 100644
--- a/platforms/spring-boot/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/springboot/InfinispanComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/springboot/InfinispanComponentConfiguration.java
@@ -16,7 +16,14 @@
  */
 package org.apache.camel.component.infinispan.springboot;
 
+import java.util.Map;
+import java.util.Set;
+import org.apache.camel.component.infinispan.InfinispanCustomListener;
+import org.apache.camel.component.infinispan.InfinispanQueryBuilder;
+import org.infinispan.commons.api.BasicCacheContainer;
+import org.infinispan.context.Flag;
 import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.NestedConfigurationProperty;
 
 /**
  * For reading/writing from/to Infinispan distributed key/value store and data
@@ -28,12 +35,38 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
 public class InfinispanComponentConfiguration {
 
     /**
+     * The default configuration shared among endpoints.
+     */
+    private InfinispanConfigurationNestedConfiguration configuration;
+    /**
+     * The default cache container.
+     */
+    @NestedConfigurationProperty
+    private BasicCacheContainer cacheContainer;
+    /**
      * Whether the component should resolve property placeholders on itself when
      * starting. Only properties which are of String type can use property
      * placeholders.
      */
     private Boolean resolvePropertyPlaceholders = true;
 
+    public InfinispanConfigurationNestedConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    public void setConfiguration(
+            InfinispanConfigurationNestedConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    public BasicCacheContainer getCacheContainer() {
+        return cacheContainer;
+    }
+
+    public void setCacheContainer(BasicCacheContainer cacheContainer) {
+        this.cacheContainer = cacheContainer;
+    }
+
     public Boolean getResolvePropertyPlaceholders() {
         return resolvePropertyPlaceholders;
     }
@@ -42,4 +75,140 @@ public class InfinispanComponentConfiguration {
             Boolean resolvePropertyPlaceholders) {
         this.resolvePropertyPlaceholders = resolvePropertyPlaceholders;
     }
+
+    public static class InfinispanConfigurationNestedConfiguration {
+        public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.infinispan.InfinispanConfiguration.class;
+        /**
+         * The operation to perform.
+         */
+        private String command = "put";
+        private String hosts;
+        private BasicCacheContainer cacheContainer;
+        private Boolean sync = true;
+        private Boolean clusteredListener = false;
+        /**
+         * Specifies the set of event types to register by the consumer.
+         * Multiple event can be separated by comma.
+         * <p/>
+         * The possible event types are: CACHE_ENTRY_ACTIVATED,
+         * CACHE_ENTRY_PASSIVATED, CACHE_ENTRY_VISITED, CACHE_ENTRY_LOADED,
+         * CACHE_ENTRY_EVICTED, CACHE_ENTRY_CREATED, CACHE_ENTRY_REMOVED,
+         * CACHE_ENTRY_MODIFIED, TRANSACTION_COMPLETED, TRANSACTION_REGISTERED,
+         * CACHE_ENTRY_INVALIDATED, DATA_REHASHED, TOPOLOGY_CHANGED,
+         * PARTITION_STATUS_CHANGED
+         */
+        private Set eventTypes;
+        private InfinispanCustomListener customListener;
+        /**
+         * Specifies the query builder.
+         */
+        private InfinispanQueryBuilder queryBuilder;
+        private Flag[] flags;
+        private String configurationUri;
+        /**
+         * Implementation specific properties for the CacheManager
+         */
+        private Map configurationProperties;
+        /**
+         * The CacheContainer configuration
+         */
+        private Object cacheContainerConfiguration;
+
+        public String getCommand() {
+            return command;
+        }
+
+        public void setCommand(String command) {
+            this.command = command;
+        }
+
+        public String getHosts() {
+            return hosts;
+        }
+
+        public void setHosts(String hosts) {
+            this.hosts = hosts;
+        }
+
+        public BasicCacheContainer getCacheContainer() {
+            return cacheContainer;
+        }
+
+        public void setCacheContainer(BasicCacheContainer cacheContainer) {
+            this.cacheContainer = cacheContainer;
+        }
+
+        public Boolean getSync() {
+            return sync;
+        }
+
+        public void setSync(Boolean sync) {
+            this.sync = sync;
+        }
+
+        public Boolean getClusteredListener() {
+            return clusteredListener;
+        }
+
+        public void setClusteredListener(Boolean clusteredListener) {
+            this.clusteredListener = clusteredListener;
+        }
+
+        public Set getEventTypes() {
+            return eventTypes;
+        }
+
+        public void setEventTypes(Set eventTypes) {
+            this.eventTypes = eventTypes;
+        }
+
+        public InfinispanCustomListener getCustomListener() {
+            return customListener;
+        }
+
+        public void setCustomListener(InfinispanCustomListener customListener) {
+            this.customListener = customListener;
+        }
+
+        public InfinispanQueryBuilder getQueryBuilder() {
+            return queryBuilder;
+        }
+
+        public void setQueryBuilder(InfinispanQueryBuilder queryBuilder) {
+            this.queryBuilder = queryBuilder;
+        }
+
+        public Flag[] getFlags() {
+            return flags;
+        }
+
+        public void setFlags(Flag[] flags) {
+            this.flags = flags;
+        }
+
+        public String getConfigurationUri() {
+            return configurationUri;
+        }
+
+        public void setConfigurationUri(String configurationUri) {
+            this.configurationUri = configurationUri;
+        }
+
+        public Map getConfigurationProperties() {
+            return configurationProperties;
+        }
+
+        public void setConfigurationProperties(Map configurationProperties) {
+            this.configurationProperties = configurationProperties;
+        }
+
+        public Object getCacheContainerConfiguration() {
+            return cacheContainerConfiguration;
+        }
+
+        public void setCacheContainerConfiguration(
+                Object cacheContainerConfiguration) {
+            this.cacheContainerConfiguration = cacheContainerConfiguration;
+        }
+    }
 }
\ No newline at end of file


Mime
View raw message