Skip to content
Snippets Groups Projects
Commit f0c23d62 authored by Ruben Backx's avatar Ruben Backx :coffee:
Browse files

Merge branch 'fix-scoped-cache' into 'development'

Add proxyMode to CacheScope and remove obselete destructionCallback

See merge request !765
parents d1dfed0b 95037d20
No related branches found
No related tags found
2 merge requests!774Deploy,!765Add proxyMode to CacheScope and remove obselete destructionCallback
...@@ -36,9 +36,6 @@ import org.springframework.web.context.request.RequestContextHolder; ...@@ -36,9 +36,6 @@ import org.springframework.web.context.request.RequestContextHolder;
public class CacheManager extends AbstractRequestAttributesScope { public class CacheManager extends AbstractRequestAttributesScope {
private Map<String, Object> scopedObjects = Collections.synchronizedMap(new HashMap<String, Object>()); private Map<String, Object> scopedObjects = Collections.synchronizedMap(new HashMap<String, Object>());
private Map<String, Runnable> destructionCallbacks = Collections
.synchronizedMap(new HashMap<String, Runnable>());
@Override @Override
public Object get(String name, ObjectFactory<?> objectFactory) { public Object get(String name, ObjectFactory<?> objectFactory) {
if (RequestContextHolder.getRequestAttributes() != null) { if (RequestContextHolder.getRequestAttributes() != null) {
...@@ -53,7 +50,6 @@ public class CacheManager extends AbstractRequestAttributesScope { ...@@ -53,7 +50,6 @@ public class CacheManager extends AbstractRequestAttributesScope {
if (RequestContextHolder.getRequestAttributes() != null) { if (RequestContextHolder.getRequestAttributes() != null) {
return super.remove(name); return super.remove(name);
} }
destructionCallbacks.remove(name);
return scopedObjects.remove(name); return scopedObjects.remove(name);
} }
...@@ -62,7 +58,6 @@ public class CacheManager extends AbstractRequestAttributesScope { ...@@ -62,7 +58,6 @@ public class CacheManager extends AbstractRequestAttributesScope {
if (RequestContextHolder.getRequestAttributes() != null) { if (RequestContextHolder.getRequestAttributes() != null) {
super.registerDestructionCallback(name, callback); super.registerDestructionCallback(name, callback);
} }
destructionCallbacks.put(name, callback);
} }
@Override @Override
......
...@@ -17,8 +17,17 @@ ...@@ -17,8 +17,17 @@
*/ */
package nl.tudelft.queue.scope; package nl.tudelft.queue.scope;
import java.lang.annotation.*;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.core.annotation.AliasFor;
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Scope(scopeName = "cacheManager") @Scope(scopeName = "cacheManager")
public @interface CacheScope { public @interface CacheScope {
@AliasFor(annotation = Scope.class)
ScopedProxyMode proxyMode() default ScopedProxyMode.TARGET_CLASS;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment