• 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/method/ProxyUtil.java
1
/**
2
 * Created on  13-09-20 21:36
3
 */
4
package com.alicp.jetcache.anno.method;
5

6
import com.alicp.jetcache.CacheManager;
7
import com.alicp.jetcache.anno.support.ConfigMap;
8
import com.alicp.jetcache.anno.support.ConfigProvider;
9

10
import java.lang.reflect.Method;
11
import java.lang.reflect.Modifier;
12
import java.lang.reflect.Proxy;
13

14
/**
15
 * @author huangli
16
 */
17
public class ProxyUtil {
×
18

19
    public static <T> T getProxyByAnnotation(T target, ConfigProvider configProvider, CacheManager cacheManager) {
20
        final ConfigMap configMap = new ConfigMap();
×
21
        processType(configMap, target.getClass());
×
22
        Class<?>[] its = ClassUtil.getAllInterfaces(target);
×
23
        CacheHandler h = new CacheHandler(target, configMap,
×
24
                () -> configProvider.newContext(cacheManager).createCacheInvokeContext(configMap),
×
25
                configProvider.getGlobalCacheConfig().getHiddenPackages());
×
26
        Object o = Proxy.newProxyInstance(target.getClass().getClassLoader(), its, h);
×
27
        return (T) o;
×
28
    }
29

30
    private static void processType(ConfigMap configMap, Class<?> clazz) {
31
        if (clazz.isAnnotation() || clazz.isArray() || clazz.isEnum() || clazz.isPrimitive()) {
×
32
            throw new IllegalArgumentException(clazz.getName());
×
33
        }
34
        if (clazz.getName().startsWith("java")) {
×
35
            return;
×
36
        }
37
        Method[] methods = clazz.getDeclaredMethods();
×
38
        for (Method m : methods) {
×
39
            if (Modifier.isPublic(m.getModifiers())) {
×
40
                processMethod(configMap, m);
×
41
            }
42
        }
43

44
        Class<?>[] interfaces = clazz.getInterfaces();
×
45
        for (Class<?> it : interfaces) {
×
46
            processType(configMap, it);
×
47
        }
48

49
        if (!clazz.isInterface()) {
×
50
            if (clazz.getSuperclass() != null) {
×
51
                processType(configMap, clazz.getSuperclass());
×
52
            }
53
        }
54
    }
×
55

56
    private static void processMethod(ConfigMap configMap, Method m) {
57
        String sig = ClassUtil.getMethodSig(m);
×
58
        CacheInvokeConfig cac = configMap.getByMethodInfo(sig);
×
59
        if (cac == null) {
×
60
            cac = new CacheInvokeConfig();
×
61
            if (CacheConfigUtil.parse(cac, m)) {
×
62
                configMap.putByMethodInfo(sig, cac);
×
63
            }
64
        } else {
65
            CacheConfigUtil.parse(cac, m);
×
66
        }
67
    }
×
68
}
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

© 2025 Coveralls, Inc