001 package org.apache.tapestry.resolver;
002
003 import org.apache.hivemind.Resource;
004 import org.apache.tapestry.IComponent;
005 import org.apache.tapestry.IRequestCycle;
006
007 import java.util.Locale;
008
009 /**
010 * Service responsible for finding resources relative or specific to a {@link org.apache.tapestry.IComponent}.
011 *
012 */
013 public interface IComponentResourceResolver {
014
015 /**
016 * Searches for a resource relative to the specified {@link IComponent}, optionally also attemping to
017 * find a localized version of the resource using the specified {@link Locale}.
018 *
019 * @param component
020 * The component to find the resource relative to.
021 * @param cycle
022 * The current request.
023 * @param name
024 * Optional resource name to search for, the default is to use the component name.
025 * @param extension
026 * Extension name of the resource, such as <ComponentName>.properties for properties
027 * / <ComponentName>.html for templates and so on.
028 * @param locale
029 * Optional localization specifier.
030 *
031 * @return The resolved resource, or null if none could be found. The returned {@link Resource} may
032 * also be not null but still not valid. To ensure validity check {@link org.apache.hivemind.Resource#getResourceURL()} for
033 * a not null value.
034 */
035 Resource findComponentResource(IComponent component, IRequestCycle cycle, String name, String extension, Locale locale);
036 }