⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 settings.java

📁 Wicket一个开发Java Web应用程序框架。它使得开发web应用程序变得容易而轻松。 Wicket利用一个POJO data beans组件使得它可以与任何持久层技术相结合。
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 * *      http://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.apache.wicket.settings;import java.lang.ref.WeakReference;import java.util.ArrayList;import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;import org.apache.wicket.Application;import org.apache.wicket.Component;import org.apache.wicket.IPageFactory;import org.apache.wicket.IResourceFactory;import org.apache.wicket.IResponseFilter;import org.apache.wicket.Localizer;import org.apache.wicket.Page;import org.apache.wicket.application.DefaultClassResolver;import org.apache.wicket.application.IClassResolver;import org.apache.wicket.authorization.IAuthorizationStrategy;import org.apache.wicket.authorization.IUnauthorizedComponentInstantiationListener;import org.apache.wicket.authorization.UnauthorizedInstantiationException;import org.apache.wicket.markup.IMarkupCache;import org.apache.wicket.markup.IMarkupParserFactory;import org.apache.wicket.markup.MarkupCache;import org.apache.wicket.markup.MarkupParserFactory;import org.apache.wicket.markup.html.IPackageResourceGuard;import org.apache.wicket.markup.html.PackageResourceGuard;import org.apache.wicket.markup.html.form.persistence.CookieValuePersisterSettings;import org.apache.wicket.markup.html.pages.BrowserInfoPage;import org.apache.wicket.markup.resolver.AutoComponentResolver;import org.apache.wicket.markup.resolver.IComponentResolver;import org.apache.wicket.resource.PropertiesFactory;import org.apache.wicket.resource.loader.ClassStringResourceLoader;import org.apache.wicket.resource.loader.ComponentStringResourceLoader;import org.apache.wicket.resource.loader.IStringResourceLoader;import org.apache.wicket.session.DefaultPageFactory;import org.apache.wicket.session.pagemap.IPageMapEvictionStrategy;import org.apache.wicket.session.pagemap.LeastRecentlyAccessedEvictionStrategy;import org.apache.wicket.util.crypt.CachingSunJceCryptFactory;import org.apache.wicket.util.crypt.ICryptFactory;import org.apache.wicket.util.file.IResourceFinder;import org.apache.wicket.util.file.IResourcePath;import org.apache.wicket.util.file.Path;import org.apache.wicket.util.lang.Bytes;import org.apache.wicket.util.resource.locator.IResourceStreamLocator;import org.apache.wicket.util.resource.locator.ResourceStreamLocator;import org.apache.wicket.util.string.Strings;import org.apache.wicket.util.time.Duration;import org.apache.wicket.util.watch.ModificationWatcher;/** * Contains settings exposed via IXXXSettings interfaces. It is not a good idea to use this class * directly, instead use the provided IXXXSettings interfaces. *  * @author Jonathan Locke * @author Chris Turner * @author Eelco Hillenius * @author Juergen Donnerstag * @author Johan Compagner * @author Igor Vaynberg (ivaynberg) * @author Martijn Dashorst */public final class Settings	implements		IApplicationSettings,		IDebugSettings,		IExceptionSettings,		IMarkupSettings,		IPageSettings,		IRequestCycleSettings,		IResourceSettings,		ISecuritySettings,		ISessionSettings,		IFrameworkSettings,		IRequestLoggerSettings{	/** Class of access denied page. */	private WeakReference/* <Class<? extends Page> */accessDeniedPage;	/** ajax debug mode status */	private boolean ajaxDebugModeEnabled = false;	/** The application */	private final Application application;	/** The authorization strategy. */	private IAuthorizationStrategy authorizationStrategy = IAuthorizationStrategy.ALLOW_ALL;	/** Application default for automatically resolving hrefs */	private boolean automaticLinking = false;	/**	 * Whether Wicket should try to support multiple windows transparently, true by default.	 */	private boolean automaticMultiWindowSupport = true;	/** True if the response should be buffered */	private boolean bufferResponse = true;	/** class resolver to find classes */	private IClassResolver classResolver = new DefaultClassResolver();	/** List of (static) ComponentResolvers */	private final List componentResolvers = new ArrayList();	/** True to check that each component on a page is used */	private boolean componentUseCheck = true;	/** True if multiple tabs/spaces should be compressed to a single space */	private boolean compressWhitespace = false;	/** Default values for persistence of form data (by means of cookies) */	private CookieValuePersisterSettings cookieValuePersisterSettings = new CookieValuePersisterSettings();	/** factory for creating crypt objects */	private ICryptFactory cryptFactory;	/** Default markup for after a disabled link */	private String defaultAfterDisabledLink = "</em>";	/** Default markup for before a disabled link */	private String defaultBeforeDisabledLink = "<em>";	/** Default markup encoding. If null, the OS default will be used */	private String defaultMarkupEncoding;	/**	 * Whether we should disable gzip compression for resources.	 */	private boolean disableGZipCompression = false;	/**	 * Whether mounts should be enforced. If true, requests for mounted targets have to done through	 * the mounted paths. If, for instance, a bookmarkable page is mounted to a path, a request to	 * that same page via the bookmarkablePage parameter will be denied.	 */	private boolean enforceMounts = false;	/**	 * Whether Wicket should try to get extensive client info by redirecting to	 * {@link BrowserInfoPage a page that polls for client capabilities}. False by default.	 */	private boolean gatherExtendedBrowserInfo = false;	/** Class of internal error page. */	private WeakReference/* <Class<? extends Page> */internalErrorPage;	/**	 * whether wicket should track line precise additions of components for error reporting.	 */	private boolean linePreciseReportingOnAddComponentEnabled = false;	/**	 * whether wicket should track line precise instantiations of components for error reporting.	 */	private boolean linePreciseReportingOnNewComponentEnabled = false;	/** I18N support */	private Localizer localizer;	/** Factory for creating markup parsers */	private IMarkupParserFactory markupParserFactory;	/** A markup cache which will load the markup if required. */	private IMarkupCache markupCache;	/** if true than throw an exception if the xml declaration is missing from the markup file */	private boolean throwExceptionOnMissingXmlDeclaration = false;	/** To help prevent denial of service attacks */	private int maxPageMaps = 5;	/** Map to look up resource factories by name */	private final Map nameToResourceFactory = new HashMap();	/** True if string resource loaders have been overridden */	private boolean overriddenStringResourceLoaders = false;	/** The package resource guard. */	private IPackageResourceGuard packageResourceGuard = new PackageResourceGuard();	/** The error page displayed when an expired page is accessed. */	private WeakReference/* <Class<? extends Page> */pageExpiredErrorPage;	/** factory to create new Page objects */	private IPageFactory pageFactory = new DefaultPageFactory();	/** The eviction strategy. */	private IPageMapEvictionStrategy pageMapEvictionStrategy = new LeastRecentlyAccessedEvictionStrategy(		5);	/** The factory to be used for the property files */	private org.apache.wicket.resource.IPropertiesFactory propertiesFactory;	/**	 * The render strategy, defaults to 'REDIRECT_TO_BUFFER'. This property influences the default	 * way in how a logical request that consists of an 'action' and a 'render' part is handled, and	 * is mainly used to have a means to circumvent the 'refresh' problem.	 */	private IRequestCycleSettings.RenderStrategy renderStrategy = REDIRECT_TO_BUFFER;	/** Filesystem Path to search for resources */	private IResourceFinder resourceFinder = new Path();	/** Frequency at which files should be polled */	private Duration resourcePollFrequency = null;	/** resource locator for this application */	private IResourceStreamLocator resourceStreamLocator;	/** ModificationWatcher to watch for changes in markup files */	private ModificationWatcher resourceWatcher;	/** List of {@link IResponseFilter}s. */	private List responseFilters;	/**	 * In order to do proper form parameter decoding it is important that the response and the	 * following request have the same encoding. see	 * http://www.crazysquirrel.com/computing/general/form-encoding.jspx for additional information.	 */	private String responseRequestEncoding = "UTF-8";	/** Chain of string resource loaders to use */	private final List stringResourceLoaders = new ArrayList(4);	/** Should HTML comments be stripped during rendering? */	private boolean stripComments = false;	/**	 * If true, wicket tags ( <wicket: ..>) and wicket:id attributes we be removed from output	 */	private boolean stripWicketTags = false;	/** In order to remove <?xml?> from output as required by IE quirks mode */	private boolean stripXmlDeclarationFromOutput;	/** Flags used to determine how to behave if resources are not found */	private boolean throwExceptionOnMissingResource = true;	/**	 * Whether the generated page id must be unique per session, or it's enough if it is unique per	 * page map;	 */	private boolean pageIdUniquePerSession = false;	/**	 * The time that a request will by default be waiting for the previous request to be handled	 * before giving up. Defaults to one minute.	 */	private Duration timeout = Duration.ONE_MINUTE;	/** Authorizer for component instantiations */	private IUnauthorizedComponentInstantiationListener unauthorizedComponentInstantiationListener = new IUnauthorizedComponentInstantiationListener()	{		/**		 * Called when an unauthorized component instantiation is about to take place (but before it		 * happens).		 * 		 * @param component		 *            The partially constructed component (only the id is guaranteed to be valid).		 */		public void onUnauthorizedInstantiation(final Component component)		{			throw new UnauthorizedInstantiationException(component.getClass());		}	};	/** Type of handling for unexpected exceptions */	private UnexpectedExceptionDisplay unexpectedExceptionDisplay = SHOW_EXCEPTION_PAGE;	/** Determines behavior of string resource loading if string is missing */	private boolean useDefaultOnMissingResource = true;	/** Determines if pages should be managed by a version manager by default */	private boolean versionPagesByDefault = true;	private boolean recordSessionSize = true;	private int requestsWindowSize = 0;	private boolean requestLoggerEnabled;	/**	 * Whether the comments and whitespace will be stripped from javascript resources	 */	private boolean stripJavascriptCommentsAndWhitespace;	/**	 * Whether the container's class name should be printed to response (in a html comment).	 */	private boolean outputMarkupContainerClassName = false;	private boolean addLastModifiedTimeToResourceReferenceUrl = false;	/**	 * Create the application settings, carrying out any necessary initializations.	 * 	 * @param application	 *            The application that these settings are for	 */	public Settings(final Application application)	{		this.application = application;		stringResourceLoaders.add(new ComponentStringResourceLoader());		stringResourceLoaders.add(new ClassStringResourceLoader(this.application.getClass()));	}	/**	 * @see org.apache.wicket.settings.IPageSettings#addComponentResolver(org.apache.wicket.markup.resolver.IComponentResolver)	 */	public void addComponentResolver(IComponentResolver resolver)	{		componentResolvers.add(resolver);	}	/**	 * @see org.apache.wicket.settings.IResourceSettings#addResourceFactory(java.lang.String,	 *      org.apache.wicket.IResourceFactory)	 */	public void addResourceFactory(final String name, IResourceFactory resourceFactory)	{		nameToResourceFactory.put(name, resourceFactory);	}	/**	 * @see org.apache.wicket.settings.IResourceSettings#addResourceFolder(java.lang.String)	 */	public void addResourceFolder(final String resourceFolder)	{		// Get resource finder		final IResourceFinder finder = getResourceFinder();		// Make sure it's a path		if (!(finder instanceof IResourcePath))		{			throw new IllegalArgumentException(				"To add a resource folder, the application's resource finder must be an instance of IResourcePath");		}		// Cast to resource path and add folder		final IResourcePath path = (IResourcePath)finder;		path.add(resourceFolder);	}	/**	 * @see org.apache.wicket.settings.IRequestCycleSettings#addResponseFilter(org.apache.wicket.IResponseFilter)	 */	public void addResponseFilter(IResponseFilter responseFilter)	{		if (responseFilters == null)		{			responseFilters = new ArrayList(3);		}		responseFilters.add(responseFilter);	}	/**	 * @see org.apache.wicket.settings.IResourceSettings#addStringResourceLoader(org.apache.wicket.resource.loader.IStringResourceLoader)	 */	public void addStringResourceLoader(final IStringResourceLoader loader)	{		if (!overriddenStringResourceLoaders)		{			stringResourceLoaders.clear();			overriddenStringResourceLoaders = true;		}		stringResourceLoaders.add(loader);	}	/**	 * @see org.apache.wicket.settings.IApplicationSettings#getAccessDeniedPage()	 */	public Class getAccessDeniedPage()	{		return (Class)accessDeniedPage.get();	}	/**	 * @see org.apache.wicket.settings.ISecuritySettings#getAuthorizationStrategy()	 */	public IAuthorizationStrategy getAuthorizationStrategy()	{		return authorizationStrategy;	}	/**	 * @see org.apache.wicket.settings.IMarkupSettings#getAutomaticLinking()	 */	public boolean getAutomaticLinking()	{		return automaticLinking;	}	/**	 * @see org.apache.wicket.settings.IPageSettings#getAutomaticMultiWindowSupport()	 */	public boolean getAutomaticMultiWindowSupport()	{		return automaticMultiWindowSupport;	}	/**	 * @see org.apache.wicket.settings.IRequestCycleSettings#getBufferResponse()	 */	public boolean getBufferResponse()	{		return bufferResponse;	}	/**	 * @see org.apache.wicket.settings.IApplicationSettings#getClassResolver()	 */	public IClassResolver getClassResolver()	{		return classResolver;	}	/**	 * Get the (modifiable) list of IComponentResolvers.	 * 	 * @see AutoComponentResolver for an example	 * @return List of ComponentResolvers	 */	public List getComponentResolvers()	{		return componentResolvers;	}	/**	 * @see org.apache.wicket.settings.IDebugSettings#getComponentUseCheck()	 */	public boolean getComponentUseCheck()	{		return componentUseCheck;	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -