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

📄 webapplication.java

📁 Wicket一个开发Java Web应用程序框架。它使得开发web应用程序变得容易而轻松。 Wicket利用一个POJO data beans组件使得它可以与任何持久层技术相结合。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * 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.protocol.http;import java.util.HashMap;import java.util.Map;import javax.servlet.ServletContext;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import org.apache.wicket.Application;import org.apache.wicket.IRequestTarget;import org.apache.wicket.Page;import org.apache.wicket.Request;import org.apache.wicket.RequestCycle;import org.apache.wicket.Response;import org.apache.wicket.Session;import org.apache.wicket.ajax.AjaxRequestTarget;import org.apache.wicket.markup.html.pages.AccessDeniedPage;import org.apache.wicket.markup.html.pages.InternalErrorPage;import org.apache.wicket.markup.html.pages.PageExpiredErrorPage;import org.apache.wicket.markup.resolver.AutoLinkResolver;import org.apache.wicket.protocol.http.pagestore.DiskPageStore;import org.apache.wicket.protocol.http.servlet.ServletWebRequest;import org.apache.wicket.request.IRequestCycleProcessor;import org.apache.wicket.request.target.coding.BookmarkablePageRequestTargetUrlCodingStrategy;import org.apache.wicket.request.target.coding.IRequestTargetUrlCodingStrategy;import org.apache.wicket.request.target.coding.PackageRequestTargetUrlCodingStrategy;import org.apache.wicket.request.target.coding.SharedResourceRequestTargetUrlCodingStrategy;import org.apache.wicket.session.ISessionStore;import org.apache.wicket.util.collections.MostRecentlyUsedMap;import org.apache.wicket.util.file.FileCleaner;import org.apache.wicket.util.file.IResourceFinder;import org.apache.wicket.util.file.WebApplicationPath;import org.apache.wicket.util.lang.PackageName;import org.apache.wicket.util.watch.ModificationWatcher;import org.slf4j.Logger;import org.slf4j.LoggerFactory;/** * A web application is a subclass of Application which associates with an instance of WicketServlet * to serve pages over the HTTP protocol. This class is intended to be subclassed by framework * clients to define a web application. * <p> * Application settings are given defaults by the WebApplication() constructor and internalInit * method, such as error page classes appropriate for HTML. WebApplication subclasses can override * these values and/or modify other application settings by overriding the init() method and then by * calling getXXXSettings() to retrieve an interface to a mutable Settings object. Do not do this in * the constructor itself because the defaults will then override your settings. * <p> * If you want to use a filter specific configuration, e.g. using init parameters from the * {@link javax.servlet.FilterConfig} object, you should override the init() method. For example: *  * <pre> *  public void init() { *  String webXMLParameter = getInitParameter(&quot;myWebXMLParameter&quot;); *  URL schedulersConfig = getServletContext().getResource(&quot;/WEB-INF/schedulers.xml&quot;); *  ... * </pre> *  * @see WicketFilter * @see org.apache.wicket.settings.IApplicationSettings * @see org.apache.wicket.settings.IDebugSettings * @see org.apache.wicket.settings.IExceptionSettings * @see org.apache.wicket.settings.IMarkupSettings * @see org.apache.wicket.settings.IPageSettings * @see org.apache.wicket.settings.IRequestCycleSettings * @see org.apache.wicket.settings.IResourceSettings * @see org.apache.wicket.settings.ISecuritySettings * @see org.apache.wicket.settings.ISessionSettings * @see javax.servlet.Filter * @see javax.servlet.FilterConfig * @see javax.servlet.ServletContext *  * @author Jonathan Locke * @author Chris Turner * @author Johan Compagner * @author Eelco Hillenius * @author Juergen Donnerstag */public abstract class WebApplication extends Application{	/** Log. */	private static final Logger log = LoggerFactory.getLogger(WebApplication.class);	/**	 * The cached application key. Will be set in {@link #setWicketFilter(WicketFilter)} based on	 * the filter name.	 */	private String applicationKey;	/**	 * Map of buffered responses that are in progress per session. Buffered responses are	 * temporarily stored	 */	private final Map bufferedResponses = new HashMap();	/** the default request cycle processor implementation. */	private IRequestCycleProcessor requestCycleProcessor;	/**	 * the prefix for storing variables in the actual session (typically {@link HttpSession} for	 * this application instance.	 */	private String sessionAttributePrefix;	/** The WicketFilter that this application is attached to */	private WicketFilter wicketFilter;	/**	 * Constructor. <strong>Use {@link #init()} for any configuration of your application instead of	 * overriding the constructor.</strong>	 */	public WebApplication()	{	}	/**	 * @see org.apache.wicket.Application#getApplicationKey()	 */	public final String getApplicationKey()	{		if (applicationKey == null)		{			throw new IllegalStateException("the application key does not seem to"				+ " be set properly or this method is called before WicketServlet is"				+ " set, which leads to the wrong behavior");		}		return applicationKey;	}	/**	 * Gets an init parameter from the filter's context.	 * 	 * @param key	 *            the key to search for	 * @return the value of the filter init parameter	 */	public final String getInitParameter(String key)	{		if (wicketFilter != null)		{			return wicketFilter.getFilterConfig().getInitParameter(key);		}		throw new IllegalStateException("servletContext is not set yet. Any code in your"			+ " Application object that uses the wicketServlet/Filter instance should be put"			+ " in the init() method instead of your constructor");	}	/**	 * Gets the default request cycle processor (with lazy initialization). This is the	 * {@link IRequestCycleProcessor} that will be used by {@link RequestCycle}s when custom	 * implementations of the request cycle do not provide their own customized versions.	 * 	 * @return the default request cycle processor	 */	public final IRequestCycleProcessor getRequestCycleProcessor()	{		if (requestCycleProcessor == null)		{			requestCycleProcessor = newRequestCycleProcessor();		}		return requestCycleProcessor;	}	/**	 * Gets the servlet context for this application. Use this to get references to absolute paths,	 * global web.xml parameters (<context-param>), etc.	 * 	 * @return The servlet context for this application	 */	public final ServletContext getServletContext()	{		if (wicketFilter != null)		{			return wicketFilter.getFilterConfig().getServletContext();		}		throw new IllegalStateException("servletContext is not set yet. Any code in your"			+ " Application object that uses the wicket filter instance should be put"			+ " in the init() method instead of your constructor");	}	/**	 * Gets the prefix for storing variables in the actual session (typically {@link HttpSession}	 * for this application instance.	 * 	 * @param request	 *            the request	 * 	 * @return the prefix for storing variables in the actual session	 */	public String getSessionAttributePrefix(final WebRequest request)	{		if (sessionAttributePrefix == null)		{			sessionAttributePrefix = "wicket:" +				getWicketFilter().getFilterConfig().getFilterName() + ":";		}		// Namespacing for session attributes is provided by		// adding the servlet path		return sessionAttributePrefix;	}	/**	 * @return The Wicket filter for this application	 */	public final WicketFilter getWicketFilter()	{		return wicketFilter;	}	/**	 * @see org.apache.wicket.Application#logEventTarget(org.apache.wicket.IRequestTarget)	 */	public void logEventTarget(IRequestTarget target)	{		super.logEventTarget(target);		IRequestLogger rl = getRequestLogger();		if (rl != null)		{			rl.logEventTarget(target);		}	}	/**	 * @see org.apache.wicket.Application#logResponseTarget(org.apache.wicket.IRequestTarget)	 */	public void logResponseTarget(IRequestTarget target)	{		super.logResponseTarget(target);		IRequestLogger rl = getRequestLogger();		if (rl != null)		{			rl.logResponseTarget(target);		}	}	/**	 * Mounts an encoder at the given path.	 * 	 * @param encoder	 *            the encoder that will be used for this mount	 */	public final void mount(IRequestTargetUrlCodingStrategy encoder)	{		if (encoder == null)		{			throw new IllegalArgumentException("Encoder must be not null");		}		getRequestCycleProcessor().getRequestCodingStrategy().mount(encoder);	}	/**	 * Mounts all bookmarkable pages at the given path.	 * 	 * @param path	 *            the path to mount the bookmarkable page class on	 * @param packageName	 *            the name of the package for which all bookmarkable pages or sharedresources should	 *            be mounted	 */	public final void mount(final String path, final PackageName packageName)	{		if (packageName == null)		{			throw new IllegalArgumentException("PackageName cannot be null");		}		mount(new PackageRequestTargetUrlCodingStrategy(path, packageName));	}	/**	 * Mounts a bookmarkable page class to the given path.	 * 	 * @param path	 *            the path to mount the bookmarkable page class on	 * @param bookmarkablePageClass	 *            the bookmarkable page class to mount	 */	public final void mountBookmarkablePage(final String path, final Class bookmarkablePageClass)	{		mount(new BookmarkablePageRequestTargetUrlCodingStrategy(path, bookmarkablePageClass, null));	}	/**	 * Mounts a bookmarkable page class to the given pagemap and path.	 * 	 * @param path	 *            the path to mount the bookmarkable page class on	 * @param pageMapName	 *            name of the pagemap this mount is for	 * @param bookmarkablePageClass	 *            the bookmarkable page class to mount	 */	public final void mountBookmarkablePage(final String path, final String pageMapName,		final Class bookmarkablePageClass)	{		mount(new BookmarkablePageRequestTargetUrlCodingStrategy(path, bookmarkablePageClass,			pageMapName));	}	/**	 * Mounts a shared resource class to the given path.	 * 	 * @param path	 *            the path to mount the resource class on	 * @param resourceKey	 *            the shared key of the resource being mounted	 */	public final void mountSharedResource(final String path, final String resourceKey)	{		mount(new SharedResourceRequestTargetUrlCodingStrategy(path, resourceKey));	}	/**	 * @see org.apache.wicket.Application#newRequestCycle(org.apache.wicket.Request,	 *      org.apache.wicket.Response)	 */	public RequestCycle newRequestCycle(final Request request, final Response response)	{		return new WebRequestCycle(this, (WebRequest)request, (WebResponse)response);	}	/**	 * Create new Wicket Session object. Note, this method is not called if you registered your own	 * ISessionFactory with the Application.	 * 	 * @return The created session	 * @deprecated see {@link WebApplication#newSession(Request, Response)}.	 */

⌨️ 快捷键说明

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