// Path: spring-best-practice-hibernate-search-multi-tenancy/src/main/java/practice/support/CurrentTenantIdentifierResolverImpl.java
// @Component
// public class CurrentTenantIdentifierResolverImpl implements CurrentTenantIdentifierResolver {
// 
// 	public static final String IDENTIFIER_ATTRIBUTE = CurrentTenantIdentifierResolverImpl.class.getName() + ".IDENTIFIER";
// 
// 	public static final String TENANT_1_IDENTIFIER = "tenant1";
// 	public static final String TENANT_2_IDENTIFIER = "tenant2";
// 
// 	@Override
// 	public String resolveCurrentTenantIdentifier() {
// 		RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
// 		if (requestAttributes != null) {
// 			String identifier = (String) requestAttributes.getAttribute(IDENTIFIER_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
// 			if (identifier != null) {
// 				return identifier;
// 			}
// 		}
// 		return TENANT_1_IDENTIFIER;
// 	}
// 
// 	@Override
// 	public boolean validateExistingCurrentSessions() {
// 		return true;
// 	}
// }


import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import practice.support.CurrentTenantIdentifierResolverImpl;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
package practice.mvc;



public class CurrentTenantIdentifierChangeInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		Map<String, Object> pathVariables = (Map<String, Object>) request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
		if (pathVariables.containsKey("tenant")) {
// Path: spring-best-practice-hibernate-search-multi-tenancy/src/main/java/practice/support/CurrentTenantIdentifierResolverImpl.java
// @Component
// public class CurrentTenantIdentifierResolverImpl implements CurrentTenantIdentifierResolver {
// 
// 	public static final String IDENTIFIER_ATTRIBUTE = CurrentTenantIdentifierResolverImpl.class.getName() + ".IDENTIFIER";
// 
// 	public static final String TENANT_1_IDENTIFIER = "tenant1";
// 	public static final String TENANT_2_IDENTIFIER = "tenant2";
// 
// 	@Override
// 	public String resolveCurrentTenantIdentifier() {
// 		RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
// 		if (requestAttributes != null) {
// 			String identifier = (String) requestAttributes.getAttribute(IDENTIFIER_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
// 			if (identifier != null) {
// 				return identifier;
// 			}
// 		}
// 		return TENANT_1_IDENTIFIER;
// 	}
// 
// 	@Override
// 	public boolean validateExistingCurrentSessions() {
// 		return true;
// 	}
// }


// Path: spring-best-practice-hibernate-search-multi-tenancy/src/main/java/practice/mvc/CurrentTenantIdentifierChangeInterceptor.java
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import practice.support.CurrentTenantIdentifierResolverImpl;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

package practice.mvc;



public class CurrentTenantIdentifierChangeInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		Map<String, Object> pathVariables = (Map<String, Object>) request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
		if (pathVariables.containsKey("tenant")) {
			request.setAttribute(CurrentTenantIdentifierResolverImpl.IDENTIFIER_ATTRIBUTE, pathVariables.get("tenant"));