View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.commons.resourcehandler.resource;
20  
21  import javax.faces.application.ResourceHandler;
22  import javax.faces.context.FacesContext;
23  
24  /**
25   * A utility class to isolate a ResourceHandler implementation from its
26   * underlying implementation
27   * 
28   * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
29   * @version $Revision: 891494 $ $Date: 2009-12-16 19:42:18 -0500 (MiƩ, 16 Dic 2009) $
30   */
31  public abstract class ResourceHandlerSupport
32  {
33  
34      /**
35       * Calculate the resource base path.
36       * 
37       * It should extract a string like:
38       * 
39       * ResourceHandler.RESOURCE_IDENTIFIER + '/' + getResourceName()
40       * 
41       * For example:
42       * 
43       * /javax.faces.resource/image.jpg
44       * 
45       * This is used on ResourceHandler.handleResourceRequest()
46       * 
47       */
48      public abstract String calculateResourceBasePath(FacesContext facesContext);
49  
50      /**
51       * Return an array of resource loaders used to find resources
52       * using the standard. The order of ResourceLoaders define
53       * its precedence. 
54       * 
55       * @return
56       */
57      public abstract ResourceLoader[] getResourceLoaders();
58      
59      /**
60       * Check if the mapping used is done using extensions (.xhtml, .jsf)
61       * or if it is not (/faces/*)
62       * @return
63       */
64      public abstract boolean isExtensionMapping();
65      
66      /**
67       * Get the mapping used as prefix(/faces) or sufix(.jsf)
68       * 
69       * @return
70       */
71      public abstract String getMapping();
72      
73      /**
74       * Return the time when the app started. This is useful to set the
75       * "Last-Modified" header in some specific cases.
76       * 
77       * @return
78       */
79      public abstract long getStartupTime();
80      
81      /**
82       * Return the time that should be set on "Expires" header in a resource.
83       * 
84       * @return
85       */
86      public abstract long getMaxTimeExpires();
87      
88      public String getResourceIdentifier()
89      {
90          return ResourceHandler.RESOURCE_IDENTIFIER;
91      }
92  }