This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 19228584bbb2d59532543d44d81dd73dc0a9821b Author: Guillaume Nodet <[email protected]> AuthorDate: Wed Mar 4 08:59:50 2020 +0100 Use @JdkService for CaffeineLRUCacheFactory --- .../services/org/apache/camel/lru-cache-factory | 2 ++ .../caffeine/lrucache/CaffeineLRUCacheFactory.java | 2 ++ .../services/org/apache/camel/lru-cache-factory | 19 ------------------- .../org/apache/camel/support/LRUCacheFactory.java | 7 ++++++- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/core/camel-caffeine-lrucache/src/generated/resources/META-INF/services/org/apache/camel/lru-cache-factory b/core/camel-caffeine-lrucache/src/generated/resources/META-INF/services/org/apache/camel/lru-cache-factory new file mode 100644 index 0000000..6154219 --- /dev/null +++ b/core/camel-caffeine-lrucache/src/generated/resources/META-INF/services/org/apache/camel/lru-cache-factory @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.caffeine.lrucache.CaffeineLRUCacheFactory diff --git a/core/camel-caffeine-lrucache/src/main/java/org/apache/camel/component/caffeine/lrucache/CaffeineLRUCacheFactory.java b/core/camel-caffeine-lrucache/src/main/java/org/apache/camel/component/caffeine/lrucache/CaffeineLRUCacheFactory.java index 037e6ba..93325b8 100644 --- a/core/camel-caffeine-lrucache/src/main/java/org/apache/camel/component/caffeine/lrucache/CaffeineLRUCacheFactory.java +++ b/core/camel-caffeine-lrucache/src/main/java/org/apache/camel/component/caffeine/lrucache/CaffeineLRUCacheFactory.java @@ -20,6 +20,7 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; +import org.apache.camel.spi.annotations.JdkService; import org.apache.camel.support.LRUCacheFactory; import org.apache.camel.util.StopWatch; import org.apache.camel.util.concurrent.ThreadHelper; @@ -29,6 +30,7 @@ import org.slf4j.LoggerFactory; /** * Factory to create {@link CaffeineLRUCache} instances. */ +@JdkService(LRUCacheFactory.FACTORY) public final class CaffeineLRUCacheFactory extends LRUCacheFactory { private static final Logger LOG = LoggerFactory.getLogger(CaffeineLRUCacheFactory.class); diff --git a/core/camel-caffeine-lrucache/src/main/resources/META-INF/services/org/apache/camel/lru-cache-factory b/core/camel-caffeine-lrucache/src/main/resources/META-INF/services/org/apache/camel/lru-cache-factory deleted file mode 100644 index 07b3807..0000000 --- a/core/camel-caffeine-lrucache/src/main/resources/META-INF/services/org/apache/camel/lru-cache-factory +++ /dev/null @@ -1,19 +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. -# - -class=org.apache.camel.component.caffeine.lrucache.CaffeineLRUCacheFactory - diff --git a/core/camel-support/src/main/java/org/apache/camel/support/LRUCacheFactory.java b/core/camel-support/src/main/java/org/apache/camel/support/LRUCacheFactory.java index 352d75a..2fc70c6 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/LRUCacheFactory.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/LRUCacheFactory.java @@ -30,6 +30,11 @@ import org.slf4j.LoggerFactory; */ public abstract class LRUCacheFactory { + /** + * Factory key + */ + public static final String FACTORY = "lru-cache-factory"; + private static final Logger LOG = LoggerFactory.getLogger(LRUCacheFactory.class); private static volatile LRUCacheFactory instance; @@ -69,7 +74,7 @@ public abstract class LRUCacheFactory { LOG.trace("createLRUCacheFactory"); try { ClassLoader classLoader = LRUCacheFactory.class.getClassLoader(); - URL url = classLoader.getResource("META-INF/services/org/apache/camel/lru-cache-factory"); + URL url = classLoader.getResource("META-INF/services/org/apache/camel/" + FACTORY); if (url != null) { Properties props = new Properties(); try (InputStream is = url.openStream()) {
