1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
From: Markus Koschany <apo@debian.org>
Date: Sun, 13 Nov 2022 14:44:36 +0100
Subject: no-EhCache3-support
Requires new build dependency
Forwarded: not-needed
---
.../cache/ehcache/EhcacheHttpCacheStorage.java | 150 ---------------------
1 file changed, 150 deletions(-)
delete mode 100644 httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ehcache/EhcacheHttpCacheStorage.java
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ehcache/EhcacheHttpCacheStorage.java
+++ /dev/null
@@ -1,150 +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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-package org.apache.hc.client5.http.impl.cache.ehcache;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.hc.client5.http.cache.HttpCacheEntrySerializer;
-import org.apache.hc.client5.http.cache.HttpCacheStorageEntry;
-import org.apache.hc.client5.http.cache.ResourceIOException;
-import org.apache.hc.client5.http.impl.cache.AbstractSerializingCacheStorage;
-import org.apache.hc.client5.http.impl.cache.CacheConfig;
-import org.apache.hc.client5.http.impl.cache.HttpByteArrayCacheEntrySerializer;
-import org.apache.hc.client5.http.impl.cache.NoopCacheEntrySerializer;
-import org.apache.hc.core5.util.Args;
-import org.ehcache.Cache;
-
-/**
- * <p>This class is a storage backend for cache entries that uses the
- * popular <a href="http://ehcache.org">Ehcache</a> cache implementation.
- * In particular, this backend allows for spillover to disk, where the
- * cache can be effectively larger than memory, and cached responses are
- * paged into and out of memory from disk as needed.</p>
- *
- * <p><b>N.B.</b> Since the Ehcache is configured ahead of time with a
- * maximum number of cache entries, this effectively ignores the
- * {@link CacheConfig#getMaxCacheEntries()} maximum cache entries}
- * specified by a provided {@link CacheConfig}.</p>
- *
- * <p>Please refer to the <a href="http://ehcache.org/documentation/index.html">
- * Ehcache documentation</a> for details on how to configure the Ehcache
- * itself.</p>
- * @since 4.1
- */
-public class EhcacheHttpCacheStorage<T> extends AbstractSerializingCacheStorage<T, T> {
-
- /**
- * Creates cache that stores {@link HttpCacheStorageEntry}s without direct serialization.
- *
- * @since 5.0
- */
- public static EhcacheHttpCacheStorage<HttpCacheStorageEntry> createObjectCache(
- final Cache<String, HttpCacheStorageEntry> cache, final CacheConfig config) {
- return new EhcacheHttpCacheStorage<>(cache, config, NoopCacheEntrySerializer.INSTANCE);
- }
-
- /**
- * Creates cache that stores serialized {@link HttpCacheStorageEntry}s.
- *
- * @since 5.0
- */
- public static EhcacheHttpCacheStorage<byte[]> createSerializedCache(
- final Cache<String, byte[]> cache, final CacheConfig config) {
- return new EhcacheHttpCacheStorage<>(cache, config, HttpByteArrayCacheEntrySerializer.INSTANCE);
- }
-
- private final Cache<String, T> cache;
-
- /**
- * Constructs a storage backend using the provided Ehcache
- * with the given configuration options, but using an alternative
- * cache entry serialization strategy.
- * @param cache where to store cached origin responses
- * @param config cache storage configuration options - note that
- * the setting for max object size <b>will be ignored</b> and
- * should be configured in the Ehcache instead.
- * @param serializer alternative serialization mechanism
- */
- public EhcacheHttpCacheStorage(
- final Cache<String, T> cache,
- final CacheConfig config,
- final HttpCacheEntrySerializer<T> serializer) {
- super((config != null ? config : CacheConfig.DEFAULT).getMaxUpdateRetries(), serializer);
- this.cache = Args.notNull(cache, "Ehcache");
- }
-
- @Override
- protected String digestToStorageKey(final String key) {
- return key;
- }
-
- @Override
- protected void store(final String storageKey, final T storageObject) throws ResourceIOException {
- cache.put(storageKey, storageObject);
- }
-
- @Override
- protected T restore(final String storageKey) throws ResourceIOException {
- return cache.get(storageKey);
- }
-
- @Override
- protected T getForUpdateCAS(final String storageKey) throws ResourceIOException {
- return cache.get(storageKey);
- }
-
- @Override
- protected T getStorageObject(final T element) throws ResourceIOException {
- return element;
- }
-
- @Override
- protected boolean updateCAS(
- final String storageKey, final T oldStorageObject, final T storageObject) throws ResourceIOException {
- return cache.replace(storageKey, oldStorageObject, storageObject);
- }
-
- @Override
- protected void delete(final String storageKey) throws ResourceIOException {
- cache.remove(storageKey);
- }
-
- @Override
- protected Map<String, T> bulkRestore(final Collection<String> storageKeys) throws ResourceIOException {
- final Map<String, T> resultMap = new HashMap<>();
- for (final String storageKey: storageKeys) {
- final T storageObject = cache.get(storageKey);
- if (storageObject != null) {
- resultMap.put(storageKey, storageObject);
- }
- }
- return resultMap;
- }
-
-}
|