Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.servlet.view;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.context.support.WebApplicationObjectSupport;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;
/**
* Convenient base class for {@link org.springframework.web.servlet.ViewResolver}
* implementations. Caches {@link org.springframework.web.servlet.View} objects
* once resolved: This means that view resolution won't be a performance problem,
* no matter how costly initial view retrieval is.
*
*
Subclasses need to implement the {@link #loadView} template method,
* building the View object for a specific view name and locale.
*
* @author Rod Johnson
* @author Juergen Hoeller
* @see #loadView
*/
public abstract class AbstractCachingViewResolver extends WebApplicationObjectSupport implements ViewResolver {
/** Default maximum number of entries for the view cache: 1024. */
public static final int DEFAULT_CACHE_LIMIT = 1024;
/** Dummy marker object for unresolved views in the cache Maps. */
private static final View UNRESOLVED_VIEW = new View() {
@Override
@Nullable
public String getContentType() {
return null;
}
@Override
public void render(@Nullable Map model, HttpServletRequest request, HttpServletResponse response) {
}
};
/** Default cache filter that always caches. */
private static final CacheFilter DEFAULT_CACHE_FILTER = (view, viewName, locale) -> true;
/** The maximum number of entries in the cache. */
private volatile int cacheLimit = DEFAULT_CACHE_LIMIT;
/** Whether we should refrain from resolving views again if unresolved once. */
private boolean cacheUnresolved = true;
/** Filter function that determines if view should be cached. */
private CacheFilter cacheFilter = DEFAULT_CACHE_FILTER;
/** Fast access cache for Views, returning already cached instances without a global lock. */
private final Map