org.apache.ibatis.annotations.CacheNamespace Java Examples

The following examples show how to use org.apache.ibatis.annotations.CacheNamespace. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseProcessor.java    From utils with Apache License 2.0 5 votes vote down vote up
protected TypeSpec.Builder makeClass(TypeElement clazzElement, RedisMapperProperties properties) {
    TypeSpec.Builder clazzBuilder = TypeSpec.interfaceBuilder(clazzElement.getSimpleName().toString() + STAFF)
            .addModifiers(Modifier.PUBLIC);

    clazzBuilder.addAnnotation(Mapper.class);

    if (!checkXMLFileExist(clazzElement)) {
        AnnotationSpec cacheAnnotation = AnnotationSpec.builder(CacheNamespace.class)
                .addMember("flushInterval", "$L", properties.getFlushInterval())
                .addMember("implementation", "$L.class", properties.getImplementation())
                .addMember("eviction", "$L.class", properties.getEviction())
                .addMember("size", "$L", properties.getSize())
                .addMember("readWrite", "$L", properties.isReadWrite())
                .addMember("blocking", "$L", properties.isBlocking())
                .build();
        clazzBuilder.addAnnotation(cacheAnnotation);

        for (TypeMirror interfaceClass : clazzElement.getInterfaces()) {
            clazzBuilder.addSuperinterface(TypeName.get(interfaceClass));
        }
        clazzBuilder.addSuperinterface(TypeName.get(clazzElement.asType()));
    } else {
        updateXML(clazzElement, properties);
    }

    return clazzBuilder;
}
 
Example #2
Source File: MapperAnnotationBuilder.java    From mybaties with Apache License 2.0 5 votes vote down vote up
private void parseCache() {
  CacheNamespace cacheDomain = type.getAnnotation(CacheNamespace.class);
  if (cacheDomain != null) {
    Integer size = cacheDomain.size() == 0 ? null : cacheDomain.size();
    Long flushInterval = cacheDomain.flushInterval() == 0 ? null : cacheDomain.flushInterval();
    assistant.useNewCache(cacheDomain.implementation(), cacheDomain.eviction(), flushInterval, size, cacheDomain.readWrite(), cacheDomain.blocking(), null);
  }
}
 
Example #3
Source File: MapperAnnotationBuilder.java    From mybatis with Apache License 2.0 5 votes vote down vote up
private void parseCache() {
  CacheNamespace cacheDomain = type.getAnnotation(CacheNamespace.class);
  if (cacheDomain != null) {
    Integer size = cacheDomain.size() == 0 ? null : cacheDomain.size();
    Long flushInterval = cacheDomain.flushInterval() == 0 ? null : cacheDomain.flushInterval();
    assistant.useNewCache(cacheDomain.implementation(), cacheDomain.eviction(), flushInterval, size, cacheDomain.readWrite(), cacheDomain.blocking(), null);
  }
}