/*
 * 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 wicket.examples.customresourceloading;

import java.net.URL;

import wicket.MarkupContainer;
import wicket.examples.WicketExamplePage;
import wicket.markup.IMarkupCacheKeyProvider;
import wicket.markup.IMarkupResourceStreamProvider;
import wicket.util.resource.IResourceStream;
import wicket.util.resource.UrlResourceStream;

/**
 * The markup for this page is loaded by the Page component itself.
 * 
 * @see IMarkupResourceStreamProvider
 * @see IMarkupCacheKeyProvider
 * 
 * @author Eelco Hillenius
 */
public class PageWithCustomLoading extends WicketExamplePage
		implements
			IMarkupResourceStreamProvider,
			IMarkupCacheKeyProvider
{
	/**
	 * Constructor
	 */
	public PageWithCustomLoading()
	{
	}

	/**
	 * This implementation loads from a custom name/ location. While not
	 * advisable as the default way of loading resources, overriding this method
	 * can provide a component specific break out so that you e.g. can load a
	 * template from a database without any other component or the application
	 * having to know about it.
	 * 
	 * @param container
	 *            The MarkupContainer which requests to load the Markup resource
	 *            stream
	 * @param containerClass
	 *            The container the markup should be associated with
	 * @return A IResourceStream if the resource was found
	 */
	public IResourceStream getMarkupResourceStream(final MarkupContainer container,
			final Class containerClass)
	{
		// load a template with a totally different name from this package using
		// this component's class loader
		final URL url = PageWithCustomLoading.class.getResource("CustomLoadedTemplate.html");
		if (url != null)
		{
			return new UrlResourceStream(url);
		}

		// no resource was not found
		return null;
	}

	/**
	 * Prevent the markup from ever be cached. This is optionally - components
	 * that don't implement {@link IMarkupCacheKeyProvider} will just have their
	 * markup cached - but is useful when markup varies. If you don't need such
	 * dynamic loading, it is advisible to not implement
	 * {@link IMarkupCacheKeyProvider}.
	 * 
	 * @see wicket.markup.IMarkupCacheKeyProvider#getCacheKey(wicket.MarkupContainer,
	 *      java.lang.Class)
	 */
	public CharSequence getCacheKey(MarkupContainer container, Class containerClass)
	{
		return null;
	}
}
@@ -100,16 +100,17 @@
 eements.
+ 
  See the
@@ -142,16 +142,16 @@
 with
+%0A *
  this
-%0A *
  wor
@@ -213,16 +213,19 @@
 hip.
+%0A *
  The ASF
 %0A * 
@@ -220,19 +220,16 @@
  The ASF
-%0A *
  license
@@ -288,16 +288,16 @@
  2.0
+%0A *
  (the
-%0A *
  %22Li
@@ -356,16 +356,19 @@
 nce with
+%0A *
  the Lic
@@ -372,19 +372,17 @@
 License.
-%0A *
+ 
  You may
@@ -416,20 +416,24 @@
 se at%0A *
- 
 %0A *
+     
  http://
@@ -470,17 +470,16 @@
 E-2.0%0A *
- 
 %0A * Unle
@@ -614,16 +614,19 @@
 SIS,
+%0A *
  WITHOUT
 %0A * 
@@ -621,19 +621,16 @@
  WITHOUT
-%0A *
  WARRANT
@@ -686,24 +686,27 @@
 implied.
+%0A *
  See the
 %0A * Lice
@@ -697,19 +697,16 @@
  See the
-%0A *
  License
@@ -757,16 +757,19 @@
 ions and
+%0A *
  limitat
@@ -778,19 +778,16 @@
 ns under
-%0A *
  the Lic

Fix license