1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19package org.apache.myfaces.renderkit.html.util;
2021import javax.faces.context.FacesContext;
2223/**24 * Represents a single resource that a component in a page needs a25 * browser to fetch. This class helps generate the URI that is emitted26 * into the page, and specifies the class that should be invoked to27 * handle the request for that URI when the browser makes it.28 *29 * @author Mathias Broekelmann30 */31publicinterfaceResourceHandler32 {
33/**34 * Return a Class object whose instance can decode the url generated35 * by this class in the getResourceUri method and use that info to36 * locate the resource data represented by this object. When a37 * browser requests the data in the URL generated by this class38 * and its callers, an instance of the returned class shall be39 * created to decode the remainder of the url and serve the40 * resource.41 * 42 * @return a class which implements43 * org.apache.myfaces.component.html.util.ResourceLoader44 *45 * @see ResourceLoader46 */47public Class getResourceLoaderClass();
4849/**50 * Returns the uri part which is used by the resourceloader to51 * identify the resource to load. This URI will be interpreted52 * by an instance of the class returned by getResourceLoaderClass. 53 * 54 * @see org.apache.myfaces.renderkit.html.util.ResourceLoader#serveResource(javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, String)55 */56public String getResourceUri(FacesContext context);
5758/**59 * Must always be implemented when equals is overridden.60 * 61 * @see java.lang.Object#hashCode()62 */63publicint hashCode();
6465/**66 * Must be implemented to avoid loading the same resource multiple times.67 * <p>68 * When the same component is used multiple times in a page and that69 * component needs an external resource such as a script, multiple calls70 * will be made to the AddResource methods for the same resource. The71 * AddResource class will create an instance of this class for each such72 * call. However if there is already a ResourceHandler instance existing73 * which is "equal" to the newly created one then a duplicate will not74 * be queued for output. 75 * 76 * @see java.lang.Object#equals(java.lang.Object)77 */78publicboolean equals(Object obj);
79 }