Project

General

Profile

Download (941 Bytes) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.cdm.model.view.context;
2

    
3
import org.springframework.util.Assert;
4

    
5
/**
6
 * Class based heavily on InheritableThreadLocalSecurityContextHolderStrategy, part 
7
 * of spring-security, but instead binding a View object to the 
8
 * context.
9
 * 
10
 * @author ben
11
 * @author Ben Alex
12
 *
13
 */
14
public class InheritableThreadLocalAuditEventContextHolderStrategy implements
15
		AuditEventContextHolderStrategy {
16
	
17
	private static ThreadLocal contextHolder = new InheritableThreadLocal();
18

    
19
	public void clearContext() {
20
		contextHolder.set(null);
21
	}
22

    
23
	public AuditEventContext getContext() {
24
		if (contextHolder.get() == null) {
25
            contextHolder.set(new AuditEventContextImpl());
26
        }
27

    
28
        return (AuditEventContext) contextHolder.get();
29
	}
30

    
31
	public void setContext(AuditEventContext context) {
32
		Assert.notNull(context, "Only non-null AuditEventContext instances are permitted");
33
        contextHolder.set(context);
34
	}
35

    
36
}
(6-6/7)