/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.camel.component.infinispan;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.impl.DefaultConsumer;
import org.infinispan.Cache;
import org.infinispan.manager.DefaultCacheManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class InfinispanConsumer extends DefaultConsumer {
    private static final transient Logger LOGGER = LoggerFactory.getLogger(InfinispanProducer.class);
    private final InfinispanConfiguration configuration;
    private final InfinispanSyncEventListener listener;
    private DefaultCacheManager defaultCacheManager;

    public InfinispanConsumer(InfinispanEndpoint endpoint, Processor processor, InfinispanConfiguration configuration) {
        super(endpoint, processor);
        this.configuration = configuration;
        if (configuration.isSync()) {
            listener = new InfinispanSyncEventListener(this, configuration.getEventTypes());
        } else {
            listener = new InfinispanAsyncEventListener(this, configuration.getEventTypes());
        }
    }

    public void processEvent(String eventType, boolean isPre, String cacheName, Object key) {
        Exchange exchange = getEndpoint().createExchange();
        exchange.getOut().setHeader(InfinispanConstants.EVENT_TYPE, eventType);
        exchange.getOut().setHeader(InfinispanConstants.IS_PRE, isPre);
        exchange.getOut().setHeader(InfinispanConstants.CACHE_NAME, cacheName);
        exchange.getOut().setHeader(InfinispanConstants.KEY, key);

        try {
            getProcessor().process(exchange);
        } catch (Exception e) {
            LOGGER.error("Error processing event ", e);
        }
    }

    @Override
    protected void doStart() throws Exception {
        if (configuration.getCacheContainer() instanceof DefaultCacheManager) {
            defaultCacheManager = (DefaultCacheManager) configuration.getCacheContainer();
            Cache<Object, Object> cache;
            if (configuration.getCacheName() != null) {
                cache = defaultCacheManager.getCache(configuration.getCacheName());
            } else {
                cache = defaultCacheManager.getCache();
            }
            cache.addListener(listener);
        } else {
            throw new UnsupportedOperationException("Consumer not support for CacheContainer: " + configuration.getCacheContainer());
        }
        super.doStart();
    }

    @Override
    protected void doStop() throws Exception {
        if (defaultCacheManager != null) {
            defaultCacheManager.removeListener(listener);
        }
        super.doStop();
    }
}

@@ -1019,23 +1019,24 @@
 manager.
-Default
+Embedded
 CacheMan
@@ -1384,23 +1384,24 @@
 private 
-Default
+Embedded
 CacheMan
@@ -1405,24 +1405,17 @@
 Manager 
-defaultC
+c
 acheMana
@@ -2618,23 +2618,24 @@
 tanceof 
-Default
+Embedded
 CacheMan
@@ -2650,32 +2650,25 @@
             
-defaultC
+c
 acheManager 
@@ -2670,23 +2670,24 @@
 ager = (
-Default
+Embedded
 CacheMan
@@ -2844,32 +2844,25 @@
     cache = 
-defaultC
+c
 acheManager.
@@ -2946,24 +2946,17 @@
 cache = 
-defaultC
+c
 acheMana
@@ -3292,24 +3292,17 @@
     if (
-defaultC
+c
 acheMana
@@ -3332,16 +3332,9 @@
     
-defaultC
+c
 ache

Use interface rather than concrete class during casting