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

alibaba / jetcache / #405

16 Apr 2024 05:58AM UTC coverage: 0.0% (-88.9%) from 88.866%
#405

push

areyouok
add encoding to fix coverage report

0 of 5353 relevant lines covered (0.0%)

0.0 hits per line

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

0.0
/jetcache-anno/src/main/java/com/alicp/jetcache/anno/aop/JetCacheInterceptor.java
1
/**
2
 * Created on  13-09-18 20:33
3
 */
4
package com.alicp.jetcache.anno.aop;
5

6
import com.alicp.jetcache.CacheManager;
7
import com.alicp.jetcache.anno.method.CacheHandler;
8
import com.alicp.jetcache.anno.method.CacheInvokeConfig;
9
import com.alicp.jetcache.anno.method.CacheInvokeContext;
10
import com.alicp.jetcache.anno.support.ConfigMap;
11
import com.alicp.jetcache.anno.support.ConfigProvider;
12
import com.alicp.jetcache.anno.support.GlobalCacheConfig;
13
import org.aopalliance.intercept.MethodInterceptor;
14
import org.aopalliance.intercept.MethodInvocation;
15
import org.slf4j.Logger;
16
import org.slf4j.LoggerFactory;
17
import org.springframework.beans.BeansException;
18
import org.springframework.beans.factory.annotation.Autowired;
19
import org.springframework.context.ApplicationContext;
20
import org.springframework.context.ApplicationContextAware;
21

22
import java.lang.reflect.Method;
23

24
/**
25
 * @author huangli
26
 */
27
public class JetCacheInterceptor implements MethodInterceptor, ApplicationContextAware {
×
28

29
    private static final Logger logger = LoggerFactory.getLogger(JetCacheInterceptor.class);
×
30

31
    @Autowired
32
    private ConfigMap cacheConfigMap;
33
    private ApplicationContext applicationContext;
34
    private GlobalCacheConfig globalCacheConfig;
35
    ConfigProvider configProvider;
36
    CacheManager cacheManager;
37

38
    @Override
39
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
40
        this.applicationContext = applicationContext;
×
41
    }
×
42

43
    @Override
44
    public Object invoke(final MethodInvocation invocation) throws Throwable {
45
        if (configProvider == null) {
×
46
            configProvider = applicationContext.getBean(ConfigProvider.class);
×
47
        }
48
        if (configProvider != null && globalCacheConfig == null) {
×
49
            globalCacheConfig = configProvider.getGlobalCacheConfig();
×
50
        }
51
        if (globalCacheConfig == null || !globalCacheConfig.isEnableMethodCache()) {
×
52
            return invocation.proceed();
×
53
        }
54
        if (cacheManager == null) {
×
55
            cacheManager = applicationContext.getBean(CacheManager.class);
×
56
            if (cacheManager == null) {
×
57
                logger.error("There is no cache manager instance in spring context");
×
58
                return invocation.proceed();
×
59
            }
60
        }
61

62
        Method method = invocation.getMethod();
×
63
        Object obj = invocation.getThis();
×
64
        CacheInvokeConfig cac = null;
×
65
        if (obj != null) {
×
66
            String key = CachePointcut.getKey(method, obj.getClass());
×
67
            cac  = cacheConfigMap.getByMethodInfo(key);
×
68
        }
69

70
        /*
71
        if(logger.isTraceEnabled()){
72
            logger.trace("JetCacheInterceptor invoke. foundJetCacheConfig={}, method={}.{}(), targetClass={}",
73
                    cac != null,
74
                    method.getDeclaringClass().getName(),
75
                    method.getName(),
76
                    invocation.getThis() == null ? null : invocation.getThis().getClass().getName());
77
        }
78
        */
79

80
        if (cac == null || cac == CacheInvokeConfig.getNoCacheInvokeConfigInstance()) {
×
81
            return invocation.proceed();
×
82
        }
83

84
        CacheInvokeContext context = configProvider.newContext(cacheManager).createCacheInvokeContext(cacheConfigMap);
×
85
        context.setTargetObject(invocation.getThis());
×
86
        context.setInvoker(invocation::proceed);
×
87
        context.setMethod(method);
×
88
        context.setArgs(invocation.getArguments());
×
89
        context.setCacheInvokeConfig(cac);
×
90
        context.setHiddenPackages(globalCacheConfig.getHiddenPackages());
×
91
        return CacheHandler.invoke(context);
×
92
    }
93

94
    public void setCacheConfigMap(ConfigMap cacheConfigMap) {
95
        this.cacheConfigMap = cacheConfigMap;
×
96
    }
×
97

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

© 2026 Coveralls, Inc