title: Hazelcast cache implementation using Apache camel blueprint
body: <p>I am trying to implement Hazelcast caching with Camel blueprint. But I couldn't accomplish.I am able to create a hazelcast instance through java code (not through hazelcast XML config file). Instance has been craeted, but the cache loader class is not called during the instance creation (even though initialization method is EAGER). Attached some of the code snippets. </p>
  
  <p>Let me know, if anyone come across this.</p>
  
  <p>Code: </p>
  
  <h2>Hazelcast config</h2>
  
  <pre><code>public class ConfigHack extends Config {
  
  public ConfigHack(String instanceName ){
      super(instanceName);
      System.out.println("Going to create Hazelcast instance 
  ................"+instanceName);
  
      TcpIpConfig tcpIpConfig = new TcpIpConfig();
      List membersList = new ArrayList&lt;String&gt;();
      membersList.add("localhost");
      tcpIpConfig.setMembers(membersList);
  
      MulticastConfig multicastConfig = new MulticastConfig();
      multicastConfig.setEnabled(true);
  
      JoinConfig join = new JoinConfig();
      join.setTcpIpConfig(tcpIpConfig);
      join.setMulticastConfig(multicastConfig);
  
      NetworkConfig networkConfig =  new NetworkConfig();
      networkConfig.setPort(5701);
      networkConfig.setPortAutoIncrement(true);
      networkConfig.setJoin(join);
  
      GroupConfig groupConfig = new GroupConfig();
      groupConfig.setName("devuser");
      groupConfig.setPassword("devpassword"); 
  
      MapStoreConfig mapStoreConfig = new MapStoreConfig();
      //Absolute path in class name field below
      mapStoreConfig.setClassName("VehicleCacheLoader");
      mapStoreConfig.setImplementation(new VehicleCacheLoader());
      mapStoreConfig.setEnabled(true);
      mapStoreConfig.setInitialLoadMode(InitialLoadMode.EAGER);
      mapStoreConfig.setWriteDelaySeconds(500);
  
      MapConfig mapConfig = new MapConfig();
      mapConfig.setName("vehicleMap");
      mapConfig.setBackupCount(2);
      mapConfig.setMaxIdleSeconds(1000000);
      mapConfig.setEvictionPercentage(30);
      mapConfig.setEvictionPolicy(EvictionPolicy.LFU);
      mapConfig.setMapStoreConfig(mapStoreConfig);
  
      Map&lt;String,MapConfig&gt; mapConfigs = new HashMap&lt;String,MapConfig&gt;();
      mapConfigs.put("vehicleMap", mapConfig);
  
      //config.setMapConfigs(mapConfigs);
      addMapConfig(mapConfig);
      setGroupConfig(groupConfig);
      setNetworkConfig(networkConfig);        
  }
  }
  </code></pre>
  
  <h2>Cache loader class:</h2>
  
  <pre><code>public class VehicleCacheLoader implements MapLoader&lt;String, VehicleVO&gt; {
  
  @Override
  public VehicleVO load(String paramK) {
      System.out.println("Calling load method for Key " + paramK);
      VehicleVO vehicleVO = new VehicleVO();
      vehicleVO.setCustId("XXX");
      vehicleVO.setVehicleHeader("XXX");
      vehicleVO.setVehicleInitial("001");
      vehicleVO.setVehicleNumber("1234");
      vehicleVO.setVehicleObjId(paramK);
      return vehicleVO;
  }
  
  @Override
  public Map&lt;String, VehicleVO&gt; loadAll(Collection&lt;String&gt; paramCollection) {
      System.out.println("Calling Load all values() " + "Got key = ");
      VehicleVO vehicleVO = null;
      Map&lt;String, VehicleVO&gt; vehicleDataMap = new HashMap&lt;String, VehicleVO&gt;();
      for (String paramKey : paramCollection) {
          System.out.println("Calling ...." + paramKey);
          vehicleVO = new VehicleVO();
          vehicleVO.setCustId("XXX");
          vehicleVO.setVehicleHeader("XXX");
          vehicleVO.setVehicleInitial("001");
          vehicleVO.setVehicleNumber("1234");
          vehicleVO.setVehicleObjId(paramKey);
          vehicleDataMap.put(paramKey, vehicleVO);
      }   
      return vehicleDataMap;
  }
  
  @Override
  public Set&lt;String&gt; loadAllKeys() {
      System.out.println("Calling Load all keys() ");
      Set&lt;String&gt; vehicleKeys = new HashSet&lt;String&gt;();
      vehicleKeys.add("XXX001");
      vehicleKeys.add("XXX002");
      vehicleKeys.add("XXX003");
      vehicleKeys.add("XXX004");
      return vehicleKeys;
  }
  }
  Blueprint config:
  -----------------
  &lt;bean id="hazelcastInstance" class="com.hazelcast.core.Hazelcast"
      factory-method="newHazelcastInstance" destroy-method="shutdown"&gt;
      &lt;argument ref="hazelcastConfig"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="hazelcastConfig" class="xx.yy.zz.ss.tt.cache.ConfigHack"&gt;
      &lt;argument value="TestInstance" /&gt;
  &lt;/bean&gt;
  </code></pre>