View Javadoc

1   package org.apache.velocity.site.doxia.velocity;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.InputStream;
23  
24  import org.apache.commons.collections.ExtendedProperties;
25  import org.apache.velocity.exception.ResourceNotFoundException;
26  import org.apache.velocity.runtime.resource.Resource;
27  import org.apache.velocity.runtime.resource.loader.ResourceLoader;
28  
29  /**
30   * This is the base for Doxia-related Velocity {@link ResourceLoader}. It short
31   * cuts the caching mechanism and makes sure that Resource loaders deriving from
32   * this base class never cache templates.
33   *
34   * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
35   * @version $Revision: 526751 $
36   */
37  public abstract class AbstractDoxiaResourceLoader extends ResourceLoader
38  {
39  
40      /**
41       * Creates a new AbstractDoxiaResourceLoader object.
42       */
43      protected AbstractDoxiaResourceLoader()
44      {
45          super.setCachingOn(false);
46      }
47  
48      /**
49       * @see ResourceLoader#init(ExtendedProperties)
50       */
51      public void init(final ExtendedProperties properties)
52      {
53      }
54  
55      /**
56       * @see ResourceLoader#setCachingOn(boolean)
57       */
58      public void setCachingOn(final boolean caching)
59      {
60          // Does nothing. We never want to be cached!
61      }
62  
63      /**
64       * @see ResourceLoader#isCachingOn()
65       */
66      public boolean isCachingOn()
67      {
68          return false;
69      }
70  
71      /**
72       * @see ResourceLoader#getLastModified(Resource)
73       */
74      public long getLastModified(final Resource resource)
75      {
76          return 0;
77      }
78  
79      /**
80       * @see ResourceLoader#isSourceModified(Resource)
81       */
82      public boolean isSourceModified(final Resource resource)
83      {
84          return false;
85      }
86  
87      /**
88       * @see ResourceLoader#getResourceStream(String)
89       */
90      public abstract InputStream getResourceStream(final String templateName) throws ResourceNotFoundException;
91  }