de.smartics.properties.impl.config.domain.key.rtaware
Class ThreadLocalRuntimeAdapter

Package class diagram package ThreadLocalRuntimeAdapter
java.lang.Object
  extended by de.smartics.properties.impl.config.domain.key.rtaware.ThreadLocalRuntimeAdapter
All Implemented Interfaces:
RuntimeAdapter

public final class ThreadLocalRuntimeAdapter
     
     
extends Object
implements RuntimeAdapter

Accesses tenant and runtime information stored in thread local.


Constructor Summary
ThreadLocalRuntimeAdapter()
          Default constructor.
 
Method Summary
static RuntimeAdapter getInstance()
          Returns the thread-locally stored instance.
 TenantId getTenantId()
          Returns the current tenant in action.
 UserId getUserId()
          Returns the current user in action.
static void remove()
          Delegates to ThreadLocal.remove().
static void setTenantId(String tenantId)
          Sets the tenant string identifier to the thread-local context.
static void setTenantId(TenantId tenantId)
          Sets the tenant identifier to the thread-local context.
static void setUserId(String userId)
          Sets the user string identifier to the thread-local context.
static void setUserId(UserId userId)
          Sets the user identifier to the thread-local context.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreadLocalRuntimeAdapter

public ThreadLocalRuntimeAdapter()
Default constructor.

Method Detail

getTenantId

public TenantId getTenantId()
Returns the current tenant in action.

Specified by:
getTenantId in interface RuntimeAdapter
Returns:
the identifier of the current tenant in action. Never null.

getUserId

public UserId getUserId()
Returns the current user in action.

Specified by:
getUserId in interface RuntimeAdapter
Returns:
the identifier of the current user in action. Never null.

getInstance

public static RuntimeAdapter getInstance()
Returns the thread-locally stored instance.

Returns:
the thread-locally stored instance.

setTenantId

public static void setTenantId(String tenantId)
                        throws IllegalArgumentException
Sets the tenant string identifier to the thread-local context.

Parameters:
tenantId - the identifier of the current tenant in action. May be null, but must not be blank.
Throws:
IllegalArgumentException - if tenantId is blank.

setTenantId

public static void setTenantId(TenantId tenantId)
                        throws NullPointerException
Sets the tenant identifier to the thread-local context.

Parameters:
tenantId - the identifier of the current tenant in action.
Throws:
NullPointerException - if tenantId is null.

setUserId

public static void setUserId(String userId)
                      throws IllegalArgumentException
Sets the user string identifier to the thread-local context.

Parameters:
userId - the identifier of the current user in action.
Throws:
IllegalArgumentException - if userId is blank.

setUserId

public static void setUserId(UserId userId)
                      throws NullPointerException
Sets the user identifier to the thread-local context.

Parameters:
userId - the identifier of the current user in action.
Throws:
NullPointerException - if userId is null.

remove

public static void remove()
Delegates to ThreadLocal.remove().


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.