org.springframework.core.MethodClassKey Java Examples

The following examples show how to use org.springframework.core.MethodClassKey. 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: AbstractFallbackJCacheOperationSource.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public JCacheOperation<?> getCacheOperation(Method method, @Nullable Class<?> targetClass) {
	MethodClassKey cacheKey = new MethodClassKey(method, targetClass);
	Object cached = this.cache.get(cacheKey);

	if (cached != null) {
		return (cached != NULL_CACHING_ATTRIBUTE ? (JCacheOperation<?>) cached : null);
	}
	else {
		JCacheOperation<?> operation = computeCacheOperation(method, targetClass);
		if (operation != null) {
			if (logger.isDebugEnabled()) {
				logger.debug("Adding cacheable method '" + method.getName() + "' with operation: " + operation);
			}
			this.cache.put(cacheKey, operation);
		}
		else {
			this.cache.put(cacheKey, NULL_CACHING_ATTRIBUTE);
		}
		return operation;
	}
}
 
Example #2
Source File: AbstractFallbackJCacheOperationSource.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
public JCacheOperation<?> getCacheOperation(Method method, @Nullable Class<?> targetClass) {
	MethodClassKey cacheKey = new MethodClassKey(method, targetClass);
	Object cached = this.cache.get(cacheKey);

	if (cached != null) {
		return (cached != NULL_CACHING_ATTRIBUTE ? (JCacheOperation<?>) cached : null);
	}
	else {
		JCacheOperation<?> operation = computeCacheOperation(method, targetClass);
		if (operation != null) {
			if (logger.isDebugEnabled()) {
				logger.debug("Adding cacheable method '" + method.getName() + "' with operation: " + operation);
			}
			this.cache.put(cacheKey, operation);
		}
		else {
			this.cache.put(cacheKey, NULL_CACHING_ATTRIBUTE);
		}
		return operation;
	}
}
 
Example #3
Source File: DefaultLimitedResourceSource.java    From Limiter with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<LimitedResource> getLimitedResource(Class<?> targetClass, Method method) {
    MethodClassKey key = new MethodClassKey(method, targetClass);
    Collection<LimitedResource> retVal = cache.get(key);
    if (retVal != null) {
        return retVal;
    }
    retVal = computeLimitedResource(method, targetClass);
    if (CollectionUtils.isEmpty(retVal)) {
        cache.put(key, NULL_CACHING_ATTRIBUTE);
        return null;
    } else {
        cache.put(key, retVal);
        return retVal;
    }

}
 
Example #4
Source File: AbstractFallbackJCacheOperationSource.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public JCacheOperation<?> getCacheOperation(Method method, Class<?> targetClass) {
	MethodClassKey cacheKey = new MethodClassKey(method, targetClass);
	Object cached = this.cache.get(cacheKey);

	if (cached != null) {
		return (cached != NULL_CACHING_ATTRIBUTE ? (JCacheOperation<?>) cached : null);
	}
	else {
		JCacheOperation<?> operation = computeCacheOperation(method, targetClass);
		if (operation != null) {
			if (logger.isDebugEnabled()) {
				logger.debug("Adding cacheable method '" + method.getName() + "' with operation: " + operation);
			}
			this.cache.put(cacheKey, operation);
		}
		else {
			this.cache.put(cacheKey, NULL_CACHING_ATTRIBUTE);
		}
		return operation;
	}
}
 
Example #5
Source File: AbstractFallbackCacheOperationSource.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Determine a cache key for the given method and target class.
 * <p>Must not produce same key for overloaded methods.
 * Must produce same key for different instances of the same method.
 * @param method the method (never {@code null})
 * @param targetClass the target class (may be {@code null})
 * @return the cache key (never {@code null})
 */
protected Object getCacheKey(Method method, @Nullable Class<?> targetClass) {
	return new MethodClassKey(method, targetClass);
}
 
Example #6
Source File: AbstractFallbackTransactionAttributeSource.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Determine a cache key for the given method and target class.
 * <p>Must not produce same key for overloaded methods.
 * Must produce same key for different instances of the same method.
 * @param method the method (never {@code null})
 * @param targetClass the target class (may be {@code null})
 * @return the cache key (never {@code null})
 */
protected Object getCacheKey(Method method, @Nullable Class<?> targetClass) {
	return new MethodClassKey(method, targetClass);
}
 
Example #7
Source File: AbstractFallbackCacheOperationSource.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Determine a cache key for the given method and target class.
 * <p>Must not produce same key for overloaded methods.
 * Must produce same key for different instances of the same method.
 * @param method the method (never {@code null})
 * @param targetClass the target class (may be {@code null})
 * @return the cache key (never {@code null})
 */
protected Object getCacheKey(Method method, @Nullable Class<?> targetClass) {
	return new MethodClassKey(method, targetClass);
}
 
Example #8
Source File: AbstractFallbackTransactionAttributeSource.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Determine a cache key for the given method and target class.
 * <p>Must not produce same key for overloaded methods.
 * Must produce same key for different instances of the same method.
 * @param method the method (never {@code null})
 * @param targetClass the target class (may be {@code null})
 * @return the cache key (never {@code null})
 */
protected Object getCacheKey(Method method, @Nullable Class<?> targetClass) {
	return new MethodClassKey(method, targetClass);
}
 
Example #9
Source File: AbstractFallbackTransactionAttributeSource.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determine a cache key for the given method and target class.
 * <p>Must not produce same key for overloaded methods.
 * Must produce same key for different instances of the same method.
 * @param method the method (never {@code null})
 * @param targetClass the target class (may be {@code null})
 * @return the cache key (never {@code null})
 */
protected Object getCacheKey(Method method, Class<?> targetClass) {
	return new MethodClassKey(method, targetClass);
}
 
Example #10
Source File: AbstractFallbackCacheOperationSource.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determine a cache key for the given method and target class.
 * <p>Must not produce same key for overloaded methods.
 * Must produce same key for different instances of the same method.
 * @param method the method (never {@code null})
 * @param targetClass the target class (may be {@code null})
 * @return the cache key (never {@code null})
 */
protected Object getCacheKey(Method method, Class<?> targetClass) {
	return new MethodClassKey(method, targetClass);
}
 
Example #11
Source File: FixUseSupperClassFallbackCacheOperationSource.java    From hsweb-framework with Apache License 2.0 2 votes vote down vote up
/**
 * Determine a cache key for the given method and target class.
 * <p>Must not produce same key for overloaded methods.
 * Must produce same key for different instances of the same method.
 *
 * @param method      the method (never {@code null})
 * @param targetClass the target class (may be {@code null})
 * @return the cache key (never {@code null})
 */
protected Object getCacheKey(Method method, Class<?> targetClass) {
    return new MethodClassKey(method, targetClass);
}