private Object getPropertyValue(String name, Object obj) throws HystrixCacheKeyGenerationException { try { return new PropertyDescriptor(name, obj.getClass()) .getReadMethod().invoke(obj); } catch (IllegalAccessException e) { throw new HystrixCacheKeyGenerationException(e); } catch (IntrospectionException e) { throw new HystrixCacheKeyGenerationException(e); } catch (InvocationTargetException e) { throw new HystrixCacheKeyGenerationException(e); } }
public HystrixGeneratedCacheKey generateCacheKey(CacheInvocationContext<? extends Annotation> cacheInvocationContext) throws HystrixCacheKeyGenerationException { MethodExecutionAction cacheKeyMethod = cacheInvocationContext.getCacheKeyMethod(); if (cacheKeyMethod != null) { try { return new DefaultHystrixGeneratedCacheKey((String) cacheKeyMethod.execute(cacheInvocationContext.getExecutionType())); } catch (Throwable throwable) { throw new HystrixCacheKeyGenerationException(throwable); } } else { if (cacheInvocationContext.hasKeyParameters()) { StringBuilder cacheKeyBuilder = new StringBuilder(); for (CacheInvocationParameter parameter : cacheInvocationContext.getKeyParameters()) { CacheKey cacheKey = parameter.getCacheKeyAnnotation(); if (cacheKey != null && StringUtils.isNotBlank(cacheKey.value())) { appendPropertyValue(cacheKeyBuilder, Arrays.asList(StringUtils.split(cacheKey.value(), ".")), parameter.getValue()); } else { cacheKeyBuilder.append(parameter.getValue()); } } return new DefaultHystrixGeneratedCacheKey(cacheKeyBuilder.toString()); } else { return DefaultHystrixGeneratedCacheKey.EMPTY; } } }
private Object getPropertyValue(String name, Object obj) throws HystrixCacheKeyGenerationException { try { return new PropertyDescriptor(name, obj.getClass()) .getReadMethod().invoke(obj); } catch (IllegalAccessException e) { throw new HystrixCacheKeyGenerationException(e); } catch (IntrospectionException e) { throw new HystrixCacheKeyGenerationException(e); } catch (InvocationTargetException e) { throw new HystrixCacheKeyGenerationException(e); } }
public HystrixGeneratedCacheKey generateCacheKey(CacheInvocationContext<? extends Annotation> cacheInvocationContext) throws HystrixCacheKeyGenerationException { MethodExecutionAction cacheKeyMethod = cacheInvocationContext.getCacheKeyMethod(); if (cacheKeyMethod != null) { try { return new DefaultHystrixGeneratedCacheKey((String) cacheKeyMethod.execute(cacheInvocationContext.getExecutionType())); } catch (Throwable throwable) { throw new HystrixCacheKeyGenerationException(throwable); } } else { if (cacheInvocationContext.hasKeyParameters()) { StringBuilder cacheKeyBuilder = new StringBuilder(); for (CacheInvocationParameter parameter : cacheInvocationContext.getKeyParameters()) { CacheKey cacheKey = parameter.getCacheKeyAnnotation(); if (cacheKey != null && StringUtils.isNotBlank(cacheKey.value())) { appendPropertyValue(cacheKeyBuilder, Arrays.asList(StringUtils.split(cacheKey.value(), ".")), parameter.getValue()); } else { cacheKeyBuilder.append(parameter.getValue()); } } return new DefaultHystrixGeneratedCacheKey(cacheKeyBuilder.toString()); } else { return DefaultHystrixGeneratedCacheKey.EMPTY; } } }