Examples of CacheResult


Examples of com.ciaranwood.tapestry.cache.services.annotations.CacheResult

        AspectInterceptorBuilder<T> builder = decorator.createBuilder(serviceInterface, delegate,
                String.format("<Cache interceptor for %s(%s)", serviceId, serviceInterface.getName()));

        for(Method method : implementation.getDeclaredMethods()) {

            CacheResult annotation = method.getAnnotation(CacheResult.class);

            if(annotation != null) {
                try {
                    Method interfaceMethod = serviceInterface.getMethod(method.getName(), method.getParameterTypes());
View Full Code Here

Examples of com.ciaranwood.tapestry.cache.services.annotations.CacheResult

        AspectInterceptorBuilder<T> builder = decorator.createBuilder(serviceInterface, delegate,
                String.format("<Cache interceptor for %s(%s)", serviceId, serviceInterface.getName()));

        for(Method method : delegate.getClass().getDeclaredMethods()) {

            CacheResult annotation = method.getAnnotation(CacheResult.class);

            if(annotation != null) {
                checkInterfaceDefinesMethod(method, serviceInterface);
                String cacheName = determineCacheName(annotation, serviceId);
                int cacheKeyIndex = getCacheKeyParameterIndex(method);
View Full Code Here

Examples of com.m3.methodcache.annotation.CacheResult

        isPoolInitialized = true;
    }

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        CacheResult annotation = getCacheResultAnnotation(invocation);
        if (annotation != null) {
            if (!isPoolInitialized) {
                initializePool();
            }
            MemcachedClient memcached = pool.getClient();
            String cacheKey = annotation.cacheKey().equals("") ? getCacheKey(invocation, isUsingRawKey()) : annotation.cacheKey();
            Object cachedObject = null;
            try {
                cachedObject = memcached.get(cacheKey);
            } catch (Throwable t) {
                if (log.isDebugEnabled()) {
                    log.debug("Failed to get a value from memcached servers. (" + cacheKey + ")", t);
                }
            }
            if (cachedObject != null) {
                return cachedObject;
            } else {
                Object value = invocation.proceed();
                try {
                    memcached.set(cacheKey, annotation.secondsToExpire(), value);
                } catch (Throwable t) {
                    if (log.isDebugEnabled()) {
                        log.debug("Failed to set a value to memcached servers. (" + cacheKey + " -> " + value + ")", t);
                    }
                }
View Full Code Here

Examples of com.skyline.energy.cache.CacheResult

    if (!cacheDefinitionCollection.needCacheOpration()) {
      return dataAccessExecutor.execute(obj, args);
    }

    try {
      CacheResult cacheResult = beforeDataAccess(args);

      Object retVal = dataAccessExecutor.execute(obj, args);
      cacheResult.setRetVal(retVal);
     
      afterDataAccess(cacheResult, args);
     
      return retVal;
    } catch (CacheUnreachableException e) {
View Full Code Here

Examples of com.skyline.energy.cache.CacheResult

    }
   
  }

  private CacheResult beforeDataAccess(Object[] args) throws CacheUnreachableException {
    CacheResult cacheResult = new CacheResult(false);

    CacheDefinition cacheDefinition = cacheDefinitionCollection.getCacheDefinition();

    if (cacheDefinition == null) {
      return cacheResult;
    }

    String key = cacheDefinition.generateCacheKey(args);
    if (StringUtils.isEmpty(key)) {
      LOGGER.debug("创建缓存KEY失败,不进行缓存!");
      return cacheResult;
    }
    cacheResult.setKey(key);

    Cache cache = cacheManager.getCache(cacheDefinition.getPool());
    cacheResult.setCache(cache);

    CacheObject oldItem = (CacheObject) cache.get(key);
    LOGGER.debug("从" + key + "获取缓存对象:" + oldItem);
    if (oldItem != null) {
      return compareVersionKey(cacheDefinition, cacheResult, oldItem, args);
View Full Code Here

Examples of javax.cache.annotation.CacheResult

         log.tracef("Interception of method named '%s'", invocationContext.getMethod().getName());
      }

      final CacheKeyInvocationContext<CacheResult> cacheKeyInvocationContext = contextFactory.getCacheKeyInvocationContext(invocationContext);
      final CacheKeyGenerator cacheKeyGenerator = cacheKeyInvocationContext.unwrap(CacheKeyInvocationContextImpl.class).getCacheKeyGenerator();
      final CacheResult cacheResult = cacheKeyInvocationContext.getCacheAnnotation();
      final GeneratedCacheKey cacheKey = cacheKeyGenerator.generateCacheKey(cacheKeyInvocationContext);
      final Cache<GeneratedCacheKey, Object> cache = cacheResolver.resolveCache(cacheKeyInvocationContext);

      Object result = null;

      if (!cacheResult.skipGet()) {
         result = cache.get(cacheKey);
         if (log.isTraceEnabled()) {
            log.tracef("Entry with value '%s' has been found in cache '%s' with key '%s'", result, cache.getName(), cacheKey);
         }
      }
View Full Code Here

Examples of javax.cache.annotation.CacheResult

         final AggregatedParameterMetaData aggregatedParameterMetaData;
         final CacheKeyGenerator cacheKeyGenerator;
         final CacheDefaults cacheDefaultsAnnotation = method.getDeclaringClass().getAnnotation(CacheDefaults.class);

         if (method.isAnnotationPresent(CacheResult.class)) {
            final CacheResult cacheResultAnnotation = method.getAnnotation(CacheResult.class);
            cacheKeyGenerator = getCacheKeyGenerator(beanManager, cacheResultAnnotation.cacheKeyGenerator(), cacheDefaultsAnnotation);
            cacheName = getCacheName(method, cacheResultAnnotation.cacheName(), cacheDefaultsAnnotation, true);
            aggregatedParameterMetaData = getAggregatedParameterMetaData(method, false);
            cacheAnnotation = cacheResultAnnotation;

         } else if (method.isAnnotationPresent(CacheRemoveEntry.class)) {
            final CacheRemoveEntry cacheRemoveEntryAnnotation = method.getAnnotation(CacheRemoveEntry.class);
View Full Code Here

Examples of javax.cache.annotation.CacheResult

*/
public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJCacheOperationSource {

  @Override
  protected JCacheOperation<?> findCacheOperation(Method method, Class<?> targetType) {
    CacheResult cacheResult = method.getAnnotation(CacheResult.class);
    CachePut cachePut = method.getAnnotation(CachePut.class);
    CacheRemove cacheRemove = method.getAnnotation(CacheRemove.class);
    CacheRemoveAll cacheRemoveAll = method.getAnnotation(CacheRemoveAll.class);

    int found = countNonNull(cacheResult, cachePut, cacheRemove, cacheRemoveAll);
View Full Code Here

Examples of javax.cache.annotation.CacheResult

  public CacheResultOperation(CacheMethodDetails<CacheResult> methodDetails, CacheResolver cacheResolver,
      KeyGenerator keyGenerator, CacheResolver exceptionCacheResolver) {

    super(methodDetails, cacheResolver, keyGenerator);
    CacheResult ann = methodDetails.getCacheAnnotation();
    this.exceptionTypeFilter = createExceptionTypeFilter(ann.cachedExceptions(), ann.nonCachedExceptions());
    this.exceptionCacheResolver = exceptionCacheResolver;
    this.exceptionCacheName = (StringUtils.hasText(ann.exceptionCacheName()) ? ann.exceptionCacheName() : null);
  }
View Full Code Here

Examples of javax.cache.annotation.CacheResult

         getLog().tracef("Interception of method named '%s'", invocationContext.getMethod().getName());
      }

      final CacheKeyInvocationContext<CacheResult> cacheKeyInvocationContext = contextFactory.getCacheKeyInvocationContext(invocationContext);
      final CacheKeyGenerator cacheKeyGenerator = cacheKeyInvocationContext.unwrap(CacheKeyInvocationContextImpl.class).getCacheKeyGenerator();
      final CacheResult cacheResult = cacheKeyInvocationContext.getCacheAnnotation();
      final GeneratedCacheKey cacheKey = cacheKeyGenerator.generateCacheKey(cacheKeyInvocationContext);
      final Cache<GeneratedCacheKey, Object> cache = cacheResolver.resolveCache(cacheKeyInvocationContext);

      Object result = null;

      if (!cacheResult.skipGet()) {
         result = cache.get(cacheKey);
         if (getLog().isTraceEnabled()) {
            getLog().tracef("Entry with value '%s' has been found in cache '%s' with key '%s'", result, cache.getName(), cacheKey);
         }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.