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.loader;
018
019import java.io.IOException;
020
021import org.apache.wicket.MarkupContainer;
022import org.apache.wicket.markup.Markup;
023import org.apache.wicket.markup.MarkupCache;
024import org.apache.wicket.markup.MarkupFactory;
025import org.apache.wicket.markup.MarkupParser;
026import org.apache.wicket.markup.MarkupResourceStream;
027import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
028
029/**
030 * IMarkupLoader are loading the markup for a specific Wicket container and resource stream. By
031 * default that is a file. But e.g. in case of markup inheritance it means that 2+ markup files must
032 * be read and merged. In order to be flexible the interface has been designed in a way that
033 * multiple IMarkupLoader can be chained to easily build up more complex loaders.
034 * <p>
035 * As a Wicket user you should not need to use any markup loader directly. Instead use
036 * {@link MarkupFactory#getMarkup(MarkupContainer, boolean)}.
037 * 
038 * @see MarkupCache
039 * @see MarkupParser
040 * @see MarkupFactory
041 * 
042 * @author Juergen Donnerstag
043 */
044public interface IMarkupLoader
045{
046        /**
047         * Loads markup from a resource stream.
048         * 
049         * @param container
050         *            The original requesting markup container
051         * @param markupResourceStream
052         *            The markup resource stream to load
053         * @param baseLoader
054         *            This parameter can be use to chain IMarkupLoaders
055         * @param enforceReload
056         *            The cache will be ignored and all, including inherited markup files, will be
057         *            reloaded. Whatever is in the cache, it will be ignored
058         * @return The markup
059         * @throws IOException
060         * @throws ResourceStreamNotFoundException
061         */
062        Markup loadMarkup(final MarkupContainer container, MarkupResourceStream markupResourceStream,
063                IMarkupLoader baseLoader, boolean enforceReload) throws IOException,
064                ResourceStreamNotFoundException;
065}