Created
August 22, 2012 16:18
-
-
Save gakuzzzz/3427137 to your computer and use it in GitHub Desktop.
EntityContext
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface EntityContext { | |
Object get(); | |
void set(Object entity); | |
void remove(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EntityContextImpl implements EntityContext { | |
private final ThreadLocal<Object> context = new ThreadLocal<Object>(); | |
public Object get() { | |
return context.get(); | |
} | |
public void set(Object entity) { | |
context.set(entity); | |
} | |
public void remove() { | |
context.remove(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment