Example usage for org.springframework.core.annotation AnnotationAttributes getNumber

List of usage examples for org.springframework.core.annotation AnnotationAttributes getNumber

Introduction

In this page you can find the example usage for org.springframework.core.annotation AnnotationAttributes getNumber.

Prototype

@SuppressWarnings("unchecked")
public <N extends Number> N getNumber(String attributeName) 

Source Link

Document

Get the value stored under the specified attributeName as a number.

Usage

From source file:us.swcraft.springframework.cache.aerospike.config.annotation.AerospikeCacheConfiguration.java

@Inject
@Bean(name = "aerospikeCacheManager")
public AerospikeCacheManager aerospikeCacheManager(final IAerospikeClient aerospikeClient,
        final IAsyncClient asyncAerospikeClient) {
    final AerospikeCacheManager aerospikeCacheManager = new AerospikeCacheManager(defaultNamespace,
            defaultCacheName, defaultTimeToLiveInSeconds, aerospikeClient, asyncAerospikeClient,
            buildSerializer());/*from   w  w w  . j  av  a 2 s .c  o m*/

    // pre-build configured caches
    for (AnnotationAttributes cacheConfigAttrs : cachesConfiguration) {
        final String name = cacheConfigAttrs.getString("name");
        final int timeToLiveInSeconds = cacheConfigAttrs.getNumber("timeToLiveInSeconds");
        aerospikeCacheManager.createCache(name, timeToLiveInSeconds);
    }
    return aerospikeCacheManager;
}

From source file:us.swcraft.springframework.cache.aerospike.config.annotation.AerospikeCacheConfiguration.java

public void setImportMetadata(AnnotationMetadata importMetadata) {
    Map<String, Object> enableAttrMap = importMetadata
            .getAnnotationAttributes(EnableAerospikeCacheManager.class.getName());
    AnnotationAttributes enableAttrs = AnnotationAttributes.fromMap(enableAttrMap);
    if (enableAttrs == null) {
        // search parent classes
        Class<?> currentClass = ClassUtils.resolveClassName(importMetadata.getClassName(), beanClassLoader);
        for (Class<?> classToInspect = currentClass; classToInspect != null; classToInspect = classToInspect
                .getSuperclass()) {/* ww  w . j a va  2  s . c o m*/
            EnableAerospikeCacheManager enableWebSecurityAnnotation = AnnotationUtils
                    .findAnnotation(classToInspect, EnableAerospikeCacheManager.class);
            if (enableWebSecurityAnnotation == null) {
                continue;
            }
            enableAttrMap = AnnotationUtils.getAnnotationAttributes(enableWebSecurityAnnotation);
            enableAttrs = AnnotationAttributes.fromMap(enableAttrMap);
        }
    }
    defaultTimeToLiveInSeconds = enableAttrs.getNumber("defaultTimeToLiveInSeconds");
    defaultNamespace = enableAttrs.getString("defaultNamespace");
    defaultCacheName = enableAttrs.getString("defaultCacheName");
    compression = enableAttrs.getEnum("compression");
    serializerClass = enableAttrs.getClass("serializerClass");

    cachesConfiguration = enableAttrs.getAnnotationArray("caches");
}

From source file:us.swcraft.springframework.session.aerospike.config.annotation.web.http.AerospikeHttpSessionConfiguration.java

public void setImportMetadata(AnnotationMetadata importMetadata) {
    Map<String, Object> enableAttrMap = importMetadata
            .getAnnotationAttributes(EnableAerospikeHttpSession.class.getName());
    AnnotationAttributes enableAttrs = AnnotationAttributes.fromMap(enableAttrMap);
    if (enableAttrs == null) {
        // search parent classes
        Class<?> currentClass = ClassUtils.resolveClassName(importMetadata.getClassName(), beanClassLoader);
        for (Class<?> classToInspect = currentClass; classToInspect != null; classToInspect = classToInspect
                .getSuperclass()) {//from w w w . j  a va  2  s.  co m
            EnableAerospikeHttpSession enableWebSecurityAnnotation = AnnotationUtils
                    .findAnnotation(classToInspect, EnableAerospikeHttpSession.class);
            if (enableWebSecurityAnnotation == null) {
                continue;
            }
            enableAttrMap = AnnotationUtils.getAnnotationAttributes(enableWebSecurityAnnotation);
            enableAttrs = AnnotationAttributes.fromMap(enableAttrMap);
        }
    }
    maxInactiveIntervalInSeconds = enableAttrs.getNumber("maxInactiveIntervalInSeconds");
    namespace = enableAttrs.getString("namespace");
    setname = enableAttrs.getString("setname");
}

From source file:org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration.java

@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
    Map<String, Object> attributeMap = importMetadata
            .getAnnotationAttributes(EnableRedisHttpSession.class.getName());
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(attributeMap);
    this.maxInactiveIntervalInSeconds = attributes.getNumber("maxInactiveIntervalInSeconds");
    String redisNamespaceValue = attributes.getString("redisNamespace");
    if (StringUtils.hasText(redisNamespaceValue)) {
        this.redisNamespace = this.embeddedValueResolver.resolveStringValue(redisNamespaceValue);
    }/*from ww  w.  j  ava  2 s .co m*/
    this.redisFlushMode = attributes.getEnum("redisFlushMode");
    String cleanupCron = attributes.getString("cleanupCron");
    if (StringUtils.hasText(cleanupCron)) {
        this.cleanupCron = cleanupCron;
    }
}