• 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/support/DefaultSpringEncoderParser.java
1
/**
2
 * Created on 2019/6/7.
3
 */
4
package com.alicp.jetcache.anno.support;
5

6
import com.alicp.jetcache.CacheConfigException;
7
import com.alicp.jetcache.anno.SerialPolicy;
8
import com.alicp.jetcache.support.*;
9
import org.springframework.beans.BeansException;
10
import org.springframework.context.ApplicationContext;
11
import org.springframework.context.ApplicationContextAware;
12

13
import java.net.URI;
14
import java.util.HashMap;
15
import java.util.Map;
16
import java.util.function.Function;
17

18
/**
19
 * @author huangli
20
 */
21
public class DefaultSpringEncoderParser extends DefaultEncoderParser implements ApplicationContextAware {
×
22
    private ApplicationContext applicationContext;
23

24
    static String parseBeanName(String str) {
25
        final String beanPrefix = "bean:";
×
26
        int len = beanPrefix.length();
×
27
        if (str != null && str.startsWith(beanPrefix) && str.length() > len) {
×
28
            return str.substring(len);
×
29
        } else {
30
            return null;
×
31
        }
32
    }
33

34
    @Override
35
    public Function<Object, byte[]> parseEncoder(String valueEncoder) {
36
        String beanName = parseBeanName(valueEncoder);
×
37
        if (beanName == null) {
×
38
            return super.parseEncoder(valueEncoder);
×
39
        } else {
40
            Object bean = applicationContext.getBean(beanName);
×
41
            if (bean instanceof Function) {
×
42
                return (Function<Object, byte[]>) bean;
×
43
            } else {
44
                return ((SerialPolicy) bean).encoder();
×
45
            }
46
        }
47
    }
48

49
    @Override
50
    public Function<byte[], Object> parseDecoder(String valueDecoder) {
51
        String beanName = parseBeanName(valueDecoder);
×
52
        if (beanName == null) {
×
53
            return super.parseDecoder(valueDecoder);
×
54
        } else {
55
            Object bean = applicationContext.getBean(beanName);
×
56
            if (bean instanceof Function) {
×
57
                return (Function<byte[], Object>) bean;
×
58
            } else {
59
                return ((SerialPolicy)bean).decoder();
×
60
            }
61
        }
62
    }
63

64
    @Override
65
    JavaValueDecoder javaValueDecoder(boolean useIdentityNumber) {
66
        return new SpringJavaValueDecoder(useIdentityNumber);
×
67
    }
68

69
    @Override
70
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
71
        this.applicationContext = applicationContext;
×
72
    }
×
73
}
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