---
apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    funktion.fabric8.io/kind: Connector
  name: ehcache
data:
  deployment.yml: |
    ---
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      labels:
        funktion.fabric8.io/kind: Subscription
        connector: ehcache
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            funktion.fabric8.io/kind: Subscription
            connector: ehcache
        spec:
          containers:
          - image: funktion/connector-ehcache:${project.version}
            name: connector
  schema.yml: |
    ---
    component:
      kind: component
      scheme: ehcache
      syntax: ehcache:cacheName
      title: Ehcache
      description: The ehcache component enables you to perform caching operations using Ehcache as cache implementation.
      label: cache,datagrid,clustering
      deprecated: false
      async: false
      javaType: org.apache.camel.component.ehcache.EhcacheComponent
      groupId: org.apache.camel
      artifactId: camel-ehcache
      version: 2.18.3
    componentProperties: {}
    properties:
      cacheName:
        kind: path
        group: common
        required: true
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: the cache name
        order: 0
      bridgeErrorHandler:
        kind: parameter
        group: consumer
        label: consumer
        type: boolean
        javaType: boolean
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: false
        description: 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/ERROR level and ignored.
        order: 1
      exceptionHandler:
        kind: parameter
        group: consumer (advanced)
        label: consumer,advanced
        type: object
        javaType: org.apache.camel.spi.ExceptionHandler
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: 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/ERROR level and ignored.
        order: 2
      exchangePattern:
        kind: parameter
        group: consumer (advanced)
        label: consumer,advanced
        type: string
        javaType: org.apache.camel.ExchangePattern
        enum:
        - InOnly
        - RobustInOnly
        - InOut
        - InOptionalOut
        - OutOnly
        - RobustOutOnly
        - OutIn
        - OutOptionalIn
        deprecated: false
        secret: false
        description: Sets the exchange pattern when the consumer creates an exchange.
        order: 3
      synchronous:
        kind: parameter
        group: advanced
        label: advanced
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
        order: 4
  documentation.adoc: "[[Ehcache-EhcacheComponent]]\nEhcache Component\n~~~~~~~~~~~~~~~~~\n\
    \n*Available as of Camel 2.18.x*\n\nThe *ehcache*\_component enables you to perform\
    \ caching operations using\nEhcache 3 as the Cache Implementation.\n\nThis component\
    \ supports producer and event based consumer endpoints.\n\nThe Cache consumer\
    \ is an event based consumer and can be used to listen\nand respond to specific\
    \ cache activities.\_\n\nMaven users will need to add the following dependency\
    \ to\ntheir\_`pom.xml`\_for this component:\n\n[source,xml]\n------------------------------------------------------------\n\
    <dependency>\n    <groupId>org.apache.camel</groupId>\n    <artifactId>camel-ehcache</artifactId>\n\
    \    <version>x.x.x</version>\n    <!-- use the same version as your Camel core\
    \ version -->\n</dependency>\n------------------------------------------------------------\n\
    \n[[Ehcache-URIformat]]\nURI format\n^^^^^^^^^^\n\n[source,java]\n-----------------------------\n\
    ehcache://cacheName[?options]\n-----------------------------\n\nYou can append\
    \ query options to the URI in the following\nformat,\_`?option=value&option=#beanRef&...`\n\
    \n[[Ehcache-Options]]\nOptions\n^^^^^^^\n\n\n// component options: START\nThe\
    \ Ehcache component has no options.\n// component options: END\n\n\n\n// endpoint\
    \ options: START\nThe Ehcache component supports 5 endpoint options which are\
    \ listed below:\n\n{% raw %}\n[width=\"100%\",cols=\"2,1,1m,1m,5\",options=\"\
    header\"]\n|=======================================================================\n\
    | Name | Group | Default | Java Type | Description\n| cacheName | common |  |\
    \ String | *Required* the cache name\n| bridgeErrorHandler | consumer | false\
    \ | boolean | 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/ERROR level and ignored.\n\
    | exceptionHandler | consumer (advanced) |  | ExceptionHandler | 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/ERROR level and ignored.\n| exchangePattern | consumer\
    \ (advanced) |  | ExchangePattern | Sets the exchange pattern when the consumer\
    \ creates an exchange.\n| synchronous | advanced | false | boolean | Sets whether\
    \ synchronous processing should be strictly used or Camel is allowed to use asynchronous\
    \ processing (if supported).\n|=======================================================================\n\
    {% endraw %}\n// endpoint options: END\n\n\n[[Ehcache-MessageHeadersCamel]]\n\
    Message Headers Camel\_\n++++++++++++++++++++++\n\n\_\n[width=\"100%\",cols=\"\
    10%,10%,80%\",options=\"header\",]\n|=======================================================================\n\
    |Header |Type |Description\n\n|CamelEhcacheAction |`String` |The operation to\
    \ be perfomed on the cache, valid options are:\n\n* CLEAR\n* PUT\n* PUT_ALL\n\
    * PUT_IF_ABSENT\n* GET\n* GET_ALL\n* REMOVE\n* REMOVE_ALL\n* REPLACE\n\n|CamelEhcacheActionHasResult\
    \ |Boolean |Set to true if the action has a result\n\n|CamelEhcacheActionSucceeded\
    \ |`Boolean` |Set to true if the actionsuccedded\n\n|CamelEhcacheKey |Object |The\
    \ cache key used for an action\n\n|CamelEhcacheKeys |Set<Object> |A list of keys,\
    \ used in\n\n* PUT_ALL\n* GET_ALL\n* REMOVE_ALL\n\n|CamelEhcacheValue |Object\
    \ |The value to put in the cache or the result of an operation\n\n|CamelEhcacheOldValue\
    \ |Object |The old value associated to a key for actions like PUT_IF_ABSENT or\
    \ the\nObject used for comparison for actions like REPLACE\n\n|CamelEhcacheEventType\
    \ |EventType |The type of event received\n|=======================================================================\n\
    \n[[Ehcache-Ehcachebasedidempotentrepositoryexample:]]\nEhcache based idempotent\
    \ repository example:\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n[source,java]\n\
    ------------------------------------------------------------------------------------------------\n\
    CacheManager manager = CacheManagerBuilder.newCacheManager(new XmlConfiguration(\"\
    ehcache.xml\"));\nEhcacheIdempotentRepository repo = new EhcacheIdempotentRepository(manager,\
    \ \"idempotent-cache\");\n \nfrom(\"direct:in\")\n    .idempotentConsumer(header(\"\
    messageId\"), idempotentRepo)\n    .to(\"mock:out\");\n------------------------------------------------------------------------------------------------\n\
    \n\_\n\n[[Ehcache-Ehcachebasedaggregationrepositoryexample:]]\nEhcache based aggregation\
    \ repository example:\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n[source,java]\n\
    ---------------------------------------------------------------------------------------------------------------------------------\n\
    public class EhcacheAggregationRepositoryRoutesTest extends CamelTestSupport {\n\
    \    private static final String ENDPOINT_MOCK = \"mock:result\";\n    private\
    \ static final String ENDPOINT_DIRECT = \"direct:one\";\n    private static final\
    \ int[] VALUES = generateRandomArrayOfInt(10, 0, 30);\n    private static final\
    \ int SUM = IntStream.of(VALUES).reduce(0, (a, b) -> a + b);\n    private static\
    \ final String CORRELATOR = \"CORRELATOR\";\n\n    @EndpointInject(uri = ENDPOINT_MOCK)\n\
    \    private MockEndpoint mock;\n\n    @Produce(uri = ENDPOINT_DIRECT)\n    private\
    \ ProducerTemplate producer;\n\n    @Test\n    public void checkAggregationFromOneRoute()\
    \ throws Exception {\n        mock.expectedMessageCount(VALUES.length);\n    \
    \    mock.expectedBodiesReceived(SUM);\n\n        IntStream.of(VALUES).forEach(\n\
    \            i -> producer.sendBodyAndHeader(i, CORRELATOR, CORRELATOR)\n    \
    \    );\n\n        mock.assertIsSatisfied();\n    }\n\n    private Exchange aggregate(Exchange\
    \ oldExchange, Exchange newExchange) {\n        if (oldExchange == null) {\n \
    \           return newExchange;\n        } else {\n            Integer n = newExchange.getIn().getBody(Integer.class);\n\
    \            Integer o = oldExchange.getIn().getBody(Integer.class);\n       \
    \     Integer v = (o == null ? 0 : o) + (n == null ? 0 : n);\n\n            oldExchange.getIn().setBody(v,\
    \ Integer.class);\n\n            return oldExchange;\n        }\n    }\n\n   \
    \ @Override\n    protected RoutesBuilder createRouteBuilder() throws Exception\
    \ {\n        return new RouteBuilder() {\n            @Override\n            public\
    \ void configure() throws Exception {\n                from(ENDPOINT_DIRECT)\n\
    \                    .routeId(\"AggregatingRouteOne\")\n                    .aggregate(header(CORRELATOR))\n\
    \                    .aggregationRepository(createAggregateRepository())\n   \
    \                 .aggregationStrategy(EhcacheAggregationRepositoryRoutesTest.this::aggregate)\n\
    \                    .completionSize(VALUES.length)\n                        .to(\"\
    log:org.apache.camel.component.ehcache.processor.aggregate.level=INFO&showAll=true&mulltiline=true\"\
    )\n                        .to(ENDPOINT_MOCK);\n            }\n        };\n  \
    \  }\n\n    protected EhcacheAggregationRepository createAggregateRepository()\
    \ throws Exception {\n        CacheManager cacheManager = CacheManagerBuilder.newCacheManager(new\
    \ XmlConfiguration(\"ehcache.xml\"));\n        cacheManager.init();\n\n      \
    \  EhcacheAggregationRepository repository = new EhcacheAggregationRepository();\n\
    \        repository.setCacheManager(cacheManager);\n        repository.setCacheName(\"\
    aggregate\");\n\n        return repository;\n    }\n}\n---------------------------------------------------------------------------------------------------------------------------------\n"
