public void init()

in wicket-core/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java [379:476]


	public void init(final boolean isServlet, final FilterConfig filterConfig)
		throws ServletException
	{
		this.filterConfig = filterConfig;
		this.isServlet = isServlet;
		initIgnorePaths(filterConfig);

		final ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader();
		final ClassLoader newClassLoader = getClassLoader();
		try
		{
			if (previousClassLoader != newClassLoader)
			{
				Thread.currentThread().setContextClassLoader(newClassLoader);
			}

			// locate application instance unless it was already specified during construction
			if (application == null)
			{
				applicationFactory = getApplicationFactory();
				application = applicationFactory.createApplication(this);
			}

			if (application.getName() == null)
			{
				application.setName(filterConfig.getFilterName());
			}
			application.setWicketFilter(this);

			// Allow the filterPath to be preset via setFilterPath()
			String configureFilterPath = getFilterPath();

			if (configureFilterPath == null)
			{
				configureFilterPath = getFilterPathFromConfig(filterConfig);

				if (configureFilterPath == null)
				{
					configureFilterPath = getFilterPathFromWebXml(isServlet, filterConfig);

					if (configureFilterPath == null)
					{
						configureFilterPath = getFilterPathFromAnnotation(isServlet);
					}
				}

				if (configureFilterPath != null)
				{
					setFilterPath(configureFilterPath);
				}
			}

			if (getFilterPath() == null)
			{
				log.warn("Unable to determine filter path from filter init-param, web.xml, "
					+ "or servlet 3.0 annotations. Assuming user will set filter path "
					+ "manually by calling setFilterPath(String)");
			}

			ThreadContext.setApplication(application);
			try
			{
				application.initApplication();

				// Give the application the option to log that it is started
				application.logStarted();
			}
			finally
			{
				ThreadContext.detach();
			}
		}
		catch (Exception e)
		{
			// #destroy() might not be called by the web container when #init() fails,
			// so destroy now
			log.error(String.format("The initialization of an application with name '%s' has failed.",
					filterConfig.getFilterName()), e);

			try
			{
				destroy();
			}
			catch (Exception destroyException)
			{
				log.error("Unable to destroy after initialization failure", destroyException);
			}

			throw new ServletException(e);
		}
		finally
		{
			if (newClassLoader != previousClassLoader)
			{
				Thread.currentThread().setContextClassLoader(previousClassLoader);
			}
		}
	}