001 // Copyright 2006, 2008, 2011 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package org.apache.tapestry5.internal.services;
016
017 import org.apache.tapestry5.internal.parser.ComponentTemplate;
018 import org.apache.tapestry5.ioc.Resource;
019 import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration;
020
021 import java.net.URL;
022 import java.util.Map;
023
024 /**
025 * Parses a resource into a {@link org.apache.tapestry5.internal.parser.ComponentTemplate}. The service's configuration
026 * is used to map common document types to internal copies of the corresponding DTD.
027 *
028 * @see org.apache.tapestry5.internal.services.PageLoader
029 */
030 @UsesMappedConfiguration(URL.class)
031 public interface TemplateParser
032 {
033 /**
034 * Parses the given resource into a component template.
035 *
036 * @param templateResource the path
037 * @return the parsed template contents
038 * @throws RuntimeException if the resource does not exist, or if there is any kind of parse error
039 */
040 ComponentTemplate parseTemplate(Resource templateResource);
041
042 /**
043 * Returns a mapping from URL string to a local equivalent URL, used to avoid attempting to pull
044 * well-known DTDs down over the wire while parsing XML.
045 *
046 * @since 5.3
047 */
048 Map<String, URL> getDTDURLMappings();
049 }
050