You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2022/06/27 05:01:24 UTC
[camel-k] branch main updated: migrate and improve caffeine example
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/main by this push:
new cf6c96ee2 migrate and improve caffeine example
cf6c96ee2 is described below
commit cf6c96ee291f279dfc8f474f183d584fb7b0b8e5
Author: Kuthumi Pepple <ku...@gmail.com>
AuthorDate: Fri Jun 24 14:52:32 2022 +0100
migrate and improve caffeine example
---
examples/caffeine/CaffeineCacheSample.java | 44 ----------------------
examples/caffeine/README.md | 3 --
examples/caffeine/camel-caffeine.groovy | 59 ------------------------------
3 files changed, 106 deletions(-)
diff --git a/examples/caffeine/CaffeineCacheSample.java b/examples/caffeine/CaffeineCacheSample.java
deleted file mode 100644
index fce7241d2..000000000
--- a/examples/caffeine/CaffeineCacheSample.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.
- */
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class CaffeineCacheSample extends RouteBuilder {
- @Override
- public void configure() throws Exception {
- from("timer:tick")
- .setBody(constant("Hello"))
- .setHeader("CamelCaffeineAction", constant("PUT"))
- .setHeader("CamelCaffeineKey", constant("1"))
- .toF("caffeine-cache://%s", "test")
- .log("Result of Action ${header.CamelCaffeineAction} with key ${header.CamelCaffeineKey} is: ${body}")
- .setBody(constant(null))
- .setHeader("CamelCaffeineAction", constant("GET"))
- .setHeader("CamelCaffeineKey", constant("1"))
- .toF("caffeine-cache://%s", "test")
- .log("Result of Action ${header.CamelCaffeineAction} with key ${header.CamelCaffeineKey} is: ${body}")
- .setBody(constant(null))
- .setHeader("CamelCaffeineAction", constant("INVALIDATE"))
- .setHeader("CamelCaffeineKey", constant("1"))
- .log("Invalidating entry with key ${header.CamelCaffeineKey}")
- .toF("caffeine-cache://%s", "test")
- .setHeader("CamelCaffeineAction", constant("GET"))
- .setHeader("CamelCaffeineKey", constant("1"))
- .toF("caffeine-cache://%s", "test")
- .log("The Action ${header.CamelCaffeineAction} with key ${header.CamelCaffeineKey} has result? ${header.CamelCaffeineActionHasResult}");
- }
-}
diff --git a/examples/caffeine/README.md b/examples/caffeine/README.md
deleted file mode 100644
index 0be603fa1..000000000
--- a/examples/caffeine/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Caffeine Camel K examples
-
-Find useful examples about how to use Caffeine in a Camel K integration.
\ No newline at end of file
diff --git a/examples/caffeine/camel-caffeine.groovy b/examples/caffeine/camel-caffeine.groovy
deleted file mode 100644
index fb09740fa..000000000
--- a/examples/caffeine/camel-caffeine.groovy
+++ /dev/null
@@ -1,59 +0,0 @@
-// camel-k: language=groovy
-/*
- * 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.
- */
-
-//
-// To run this integration use:
-//
-// kamel run groovy examples/camel-caffeine.groovy
-//
-
-import com.github.benmanes.caffeine.cache.Caffeine
-
-beans {
- caffeineCache = Caffeine.newBuilder().recordStats().build()
-}
-
-from('timer:tick')
- .setBody().constant('Hello')
- .process {
- it.in.headers['CamelCaffeineAction'] = 'PUT'
- it.in.headers['CamelCaffeineKey'] = 1
- }
- .toF('caffeine-cache://%s?cache=#caffeineCache', 'test')
- .log('Result of Action ${header.CamelCaffeineAction} with key ${header.CamelCaffeineKey} is: ${body}')
- .setBody().constant(null)
- .process {
- it.in.headers['CamelCaffeineAction'] = 'GET'
- it.in.headers['CamelCaffeineKey'] = 1
- }
- .toF('caffeine-cache://%s?cache=#caffeineCache', 'test')
- .log('Result of Action ${header.CamelCaffeineAction} with key ${header.CamelCaffeineKey} is: ${body}')
- .setBody().constant(null)
- .process {
- it.in.headers['CamelCaffeineAction'] = 'INVALIDATE'
- it.in.headers['CamelCaffeineKey'] = 1
- }
- .toF('caffeine-cache://%s?cache=#caffeineCache', 'test')
- .log('Invalidating entry with key ${header.CamelCaffeineKey}')
- .setBody().constant(null)
- .process {
- it.in.headers['CamelCaffeineAction'] = 'GET'
- it.in.headers['CamelCaffeineKey'] = 1
- }
- .toF('caffeine-cache://%s?cache=#caffeineCache', 'test')
- .log('The Action ${header.CamelCaffeineAction} with key ${header.CamelCaffeineKey} has result? ${header.CamelCaffeineActionHasResult}');