• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TAKETODAY / today-infrastructure / 18154768944

01 Oct 2025 07:26AM UTC coverage: 81.882% (-0.005%) from 81.887%
18154768944

push

github

web-flow
Merge pull request #290 from TAKETODAY/dev/jspecify

jspecify

59788 of 78013 branches covered (76.64%)

Branch coverage included in aggregate %.

141239 of 167496 relevant lines covered (84.32%)

3.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.18
today-context/src/main/java/infra/cache/concurrent/ConcurrentMapCacheFactoryBean.java
1
/*
2
 * Copyright 2017 - 2025 the original author or authors.
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see [https://www.gnu.org/licenses/]
16
 */
17

18
package infra.cache.concurrent;
19

20
import org.jspecify.annotations.Nullable;
21

22
import java.util.concurrent.ConcurrentMap;
23

24
import infra.beans.factory.BeanNameAware;
25
import infra.beans.factory.FactoryBean;
26
import infra.beans.factory.InitializingBean;
27
import infra.cache.support.SimpleCacheManager;
28
import infra.util.StringUtils;
29

30
/**
31
 * {@link FactoryBean} for easy configuration of a {@link ConcurrentMapCache}
32
 * when used within a Framework container. Can be configured through bean properties;
33
 * uses the assigned Framework bean name as the default cache name.
34
 *
35
 * <p>Useful for testing or simple caching scenarios, typically in combination
36
 * with {@link SimpleCacheManager} or
37
 * dynamically through {@link ConcurrentMapCacheManager}.
38
 *
39
 * @author Costin Leau
40
 * @author Juergen Hoeller
41
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
42
 * @since 4.0
43
 */
44
public class ConcurrentMapCacheFactoryBean
2✔
45
        implements FactoryBean<ConcurrentMapCache>, BeanNameAware, InitializingBean {
46

47
  private String name = "";
3✔
48

49
  @Nullable
50
  private ConcurrentMap<Object, Object> store;
51

52
  private boolean allowNullValues = true;
4✔
53

54
  @Nullable
55
  private ConcurrentMapCache cache;
56

57
  /**
58
   * Specify the name of the cache.
59
   * <p>Default is "" (empty String).
60
   */
61
  public void setName(String name) {
62
    this.name = name;
3✔
63
  }
1✔
64

65
  /**
66
   * Specify the ConcurrentMap to use as an internal store
67
   * (possibly pre-populated).
68
   * <p>Default is a standard {@link java.util.concurrent.ConcurrentHashMap}.
69
   */
70
  public void setStore(ConcurrentMap<Object, Object> store) {
71
    this.store = store;
×
72
  }
×
73

74
  /**
75
   * Set whether to allow {@code null} values
76
   * (adapting them to an internal null holder value).
77
   * <p>Default is "true".
78
   */
79
  public void setAllowNullValues(boolean allowNullValues) {
80
    this.allowNullValues = allowNullValues;
×
81
  }
×
82

83
  @Override
84
  public void setBeanName(String beanName) {
85
    if (StringUtils.isEmpty(this.name)) {
4!
86
      setName(beanName);
×
87
    }
88
  }
1✔
89

90
  @Override
91
  public void afterPropertiesSet() {
92
    this.cache = (this.store != null ? new ConcurrentMapCache(this.name, this.store, this.allowNullValues) :
4!
93
            new ConcurrentMapCache(this.name, this.allowNullValues));
8✔
94
  }
1✔
95

96
  @Override
97
  @Nullable
98
  public ConcurrentMapCache getObject() {
99
    return this.cache;
3✔
100
  }
101

102
  @Override
103
  public Class<?> getObjectType() {
104
    return ConcurrentMapCache.class;
2✔
105
  }
106

107
  @Override
108
  public boolean isSingleton() {
109
    return true;
2✔
110
  }
111

112
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc