001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.markup;
018
019import org.apache.wicket.MarkupContainer;
020import org.apache.wicket.util.resource.IResourceStream;
021
022/**
023 * To be implemented by MarkupContainer which wish to implement their own algorithms for loading the
024 * markup resource stream.
025 * <p>
026 * Since 1.5 you may also use Component.setMarkup() or getMarkup() to attach Markup to your
027 * component.
028 * <p>
029 * Note: IResourceStreamLocators should be used in case the strategy to find a markup resource is
030 * meant to be applied to ALL components of your application.
031 * <p>
032 * Note: See IMarkupCacheKeyProvider if you wish to implement your own cache key algorithm, which
033 * sometimes is useful when the MarkupContainer implements its own IMarkupResourceStreamProvider as
034 * well.
035 * 
036 * @see IMarkupCacheKeyProvider
037 * 
038 * @author Juergen Donnerstag
039 */
040public interface IMarkupResourceStreamProvider
041{
042        /**
043         * Create a new markup resource stream for the container.
044         * <p>
045         * Note: usually it will only called once, as the IResourceStream will be cached by MarkupCache.
046         * 
047         * @param container
048         *            The MarkupContainer which requests to load the Markup resource stream
049         * @param containerClass
050         *            The container the markup should be associated with
051         * @return A IResourceStream if the resource was found
052         */
053        IResourceStream getMarkupResourceStream(final MarkupContainer container, Class<?> containerClass);
054}