org.springframework.cache.interceptor.BasicOperation Java Examples

The following examples show how to use org.springframework.cache.interceptor.BasicOperation. 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: JCacheAspectSupport.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private Object execute(CacheOperationInvocationContext<?> context, CacheOperationInvoker invoker) {
	CacheOperationInvoker adapter = new CacheOperationInvokerAdapter(invoker);
	BasicOperation operation = context.getOperation();

	if (operation instanceof CacheResultOperation) {
		return this.cacheResultInterceptor.invoke(
				(CacheOperationInvocationContext<CacheResultOperation>) context, adapter);
	}
	else if (operation instanceof CachePutOperation) {
		return this.cachePutInterceptor.invoke(
				(CacheOperationInvocationContext<CachePutOperation>) context, adapter);
	}
	else if (operation instanceof CacheRemoveOperation) {
		return this.cacheRemoveEntryInterceptor.invoke(
				(CacheOperationInvocationContext<CacheRemoveOperation>) context, adapter);
	}
	else if (operation instanceof CacheRemoveAllOperation) {
		return this.cacheRemoveAllInterceptor.invoke(
				(CacheOperationInvocationContext<CacheRemoveAllOperation>) context, adapter);
	}
	else {
		throw new IllegalArgumentException("Cannot handle " + operation);
	}
}
 
Example #2
Source File: JCacheAspectSupport.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private Object execute(CacheOperationInvocationContext<?> context, CacheOperationInvoker invoker) {
	CacheOperationInvoker adapter = new CacheOperationInvokerAdapter(invoker);
	BasicOperation operation = context.getOperation();

	if (operation instanceof CacheResultOperation) {
		return cacheResultInterceptor.invoke(
				(CacheOperationInvocationContext<CacheResultOperation>) context, adapter);
	}
	else if (operation instanceof CachePutOperation) {
		return cachePutInterceptor.invoke(
				(CacheOperationInvocationContext<CachePutOperation>) context, adapter);
	}
	else if (operation instanceof CacheRemoveOperation) {
		return cacheRemoveEntryInterceptor.invoke(
				(CacheOperationInvocationContext<CacheRemoveOperation>) context, adapter);
	}
	else if (operation instanceof CacheRemoveAllOperation) {
		return cacheRemoveAllInterceptor.invoke(
				(CacheOperationInvocationContext<CacheRemoveAllOperation>) context, adapter);
	}
	else {
		throw new IllegalArgumentException("Could not handle " + operation);
	}
}
 
Example #3
Source File: JCacheAspectSupport.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Nullable
private Object execute(CacheOperationInvocationContext<?> context, CacheOperationInvoker invoker) {
	CacheOperationInvoker adapter = new CacheOperationInvokerAdapter(invoker);
	BasicOperation operation = context.getOperation();

	if (operation instanceof CacheResultOperation) {
		Assert.state(this.cacheResultInterceptor != null, "No CacheResultInterceptor");
		return this.cacheResultInterceptor.invoke(
				(CacheOperationInvocationContext<CacheResultOperation>) context, adapter);
	}
	else if (operation instanceof CachePutOperation) {
		Assert.state(this.cachePutInterceptor != null, "No CachePutInterceptor");
		return this.cachePutInterceptor.invoke(
				(CacheOperationInvocationContext<CachePutOperation>) context, adapter);
	}
	else if (operation instanceof CacheRemoveOperation) {
		Assert.state(this.cacheRemoveEntryInterceptor != null, "No CacheRemoveEntryInterceptor");
		return this.cacheRemoveEntryInterceptor.invoke(
				(CacheOperationInvocationContext<CacheRemoveOperation>) context, adapter);
	}
	else if (operation instanceof CacheRemoveAllOperation) {
		Assert.state(this.cacheRemoveAllInterceptor != null, "No CacheRemoveAllInterceptor");
		return this.cacheRemoveAllInterceptor.invoke(
				(CacheOperationInvocationContext<CacheRemoveAllOperation>) context, adapter);
	}
	else {
		throw new IllegalArgumentException("Cannot handle " + operation);
	}
}
 
Example #4
Source File: SimpleExceptionCacheResolver.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
	BasicOperation operation = context.getOperation();
	if (!(operation instanceof CacheResultOperation)) {
		throw new IllegalStateException("Could not extract exception cache name from " + operation);
	}
	CacheResultOperation cacheResultOperation = (CacheResultOperation) operation;
	String exceptionCacheName = cacheResultOperation.getExceptionCacheName();
	if (exceptionCacheName != null) {
		return Collections.singleton(exceptionCacheName);
	}
	return null;
}
 
Example #5
Source File: JCacheAspectSupport.java    From java-technology-stack with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Nullable
private Object execute(CacheOperationInvocationContext<?> context, CacheOperationInvoker invoker) {
	CacheOperationInvoker adapter = new CacheOperationInvokerAdapter(invoker);
	BasicOperation operation = context.getOperation();

	if (operation instanceof CacheResultOperation) {
		Assert.state(this.cacheResultInterceptor != null, "No CacheResultInterceptor");
		return this.cacheResultInterceptor.invoke(
				(CacheOperationInvocationContext<CacheResultOperation>) context, adapter);
	}
	else if (operation instanceof CachePutOperation) {
		Assert.state(this.cachePutInterceptor != null, "No CachePutInterceptor");
		return this.cachePutInterceptor.invoke(
				(CacheOperationInvocationContext<CachePutOperation>) context, adapter);
	}
	else if (operation instanceof CacheRemoveOperation) {
		Assert.state(this.cacheRemoveEntryInterceptor != null, "No CacheRemoveEntryInterceptor");
		return this.cacheRemoveEntryInterceptor.invoke(
				(CacheOperationInvocationContext<CacheRemoveOperation>) context, adapter);
	}
	else if (operation instanceof CacheRemoveAllOperation) {
		Assert.state(this.cacheRemoveAllInterceptor != null, "No CacheRemoveAllInterceptor");
		return this.cacheRemoveAllInterceptor.invoke(
				(CacheOperationInvocationContext<CacheRemoveAllOperation>) context, adapter);
	}
	else {
		throw new IllegalArgumentException("Cannot handle " + operation);
	}
}
 
Example #6
Source File: SimpleExceptionCacheResolver.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
	BasicOperation operation = context.getOperation();
	if (!(operation instanceof CacheResultOperation)) {
		throw new IllegalStateException("Could not extract exception cache name from " + operation);
	}
	CacheResultOperation cacheResultOperation = (CacheResultOperation) operation;
	String exceptionCacheName = cacheResultOperation.getExceptionCacheName();
	if (exceptionCacheName != null) {
		return Collections.singleton(exceptionCacheName);
	}
	return null;
}
 
Example #7
Source File: SimpleExceptionCacheResolver.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
	BasicOperation operation = context.getOperation();
	if (!(operation instanceof CacheResultOperation)) {
		throw new IllegalStateException("Could not extract exception cache name from " + operation);
	}
	CacheResultOperation cacheResultOperation = (CacheResultOperation) operation;
	String exceptionCacheName = cacheResultOperation.getExceptionCacheName();
	if (exceptionCacheName != null) {
		return Collections.singleton(exceptionCacheName);
	}
	return null;
}
 
Example #8
Source File: SimpleExceptionCacheResolver.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
	BasicOperation operation = context.getOperation();
	if (!(operation instanceof CacheResultOperation)) {
		throw new IllegalStateException("Could not extract exception cache name from " + operation);
	}
	CacheResultOperation cacheResultOperation = (CacheResultOperation) operation;
	String exceptionCacheName = cacheResultOperation.getExceptionCacheName();
	if (exceptionCacheName != null) {
		return Collections.singleton(exceptionCacheName);
	}
	return null;
}