Skip to content

Commit

Permalink
CXF-8765: Option to remove Ehcache (enhance JCache API and providers …
Browse files Browse the repository at this point in the history
…presence detection in JCacheUtils)
  • Loading branch information
reta committed Jan 21, 2025
1 parent 0623a22 commit b82c4bb
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.cxf.ws.security.utils;

import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.function.Function;
import java.util.logging.Logger;

Expand All @@ -35,10 +37,14 @@ public final class JCacheUtils {
boolean jcacheInstalled = false;
try {
final Class<?> caching = Class.forName("javax.cache.Caching");
final Class<?> cachingProvider = Class.forName("javax.cache.spi.CachingProvider");
if (caching != null) {
jcacheInstalled = true;
jcacheInstalled = MethodHandles
.publicLookup()
.findStatic(caching, "getCachingProvider", MethodType.methodType(cachingProvider))
.invoke() != null;
}
} catch (Exception e) {
} catch (Throwable e) {
LOG.fine("No JCache SPIs detected on classpath: " + e.getMessage());
}
JCACHE_INSTALLED = jcacheInstalled;
Expand Down

0 comments on commit b82c4bb

Please sign in to comment.