Skip to content

Instantly share code, notes, and snippets.

@HDBandit
Created May 24, 2016 10:15
Show Gist options
  • Save HDBandit/98e9e9931a7f6953af4739dbab1545d8 to your computer and use it in GitHub Desktop.
Save HDBandit/98e9e9931a7f6953af4739dbab1545d8 to your computer and use it in GitHub Desktop.
public class RequestContextHolderUtils {
private static final String DEFAULT_TENANT_ID = "tenant_1";
public static final String getCurrentTenantIdentifier() {
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
if (requestAttributes != null) {
String identifier = (String) requestAttributes.getAttribute(CustomRequestAttributes.CURRENT_TENANT_IDENTIFIER,RequestAttributes.SCOPE_REQUEST);
if (identifier != null) {
return identifier;
}
}
return DEFAULT_TENANT_ID;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment