Project

General

Profile

Download (895 Bytes) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/ 
9

    
10
package eu.etaxonomy.cdm.database;
11

    
12
import org.springframework.util.Assert;
13

    
14
public class NamedContextHolder{
15

    
16
	private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
17

    
18
	public static void setContextKey(Object contextKey) {
19
		Assert.notNull(contextKey, "contextKey cannot be null");
20
		Assert.isInstanceOf(String.class, contextKey, "contextKey is not a String instance");
21
		contextHolder.set((String)contextKey);
22
	}
23

    
24
	public static String getContextKey() {
25
		return (String) contextHolder.get();
26
	}
27

    
28
	public static void clearContextKey() {
29
		contextHolder.remove();
30
	}
31

    
32
}
(16-16/20)