View Javadoc

1   /*
2    * Copyright 2007 Hippo
3    *
4    * Licensed under the Apache License, Version 2.0 (the  "License"); 
5    * you may not use this file except in compliance with the License. 
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" 
12   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License.
15   */
16  package nl.hippo.portal.cms.source;
17  
18  import java.io.InputStream;
19  
20  import nl.hippo.client.api.content.DocumentPath;
21  import nl.hippo.portal.cms.CMSSite;
22  import nl.hippo.portal.cms.cache.CacheKeyFactory;
23  import nl.hippo.portal.cms.cache.EventValidityFactory;
24  import nl.hippo.portal.cms.cache.ObjectCache;
25  
26  /***
27   * @author <a href="mailto:d.dam@hippo.nl">Dennis Dam</a>
28   *
29   * @version $Id: AbstractEventCacheableSourceFactory.java 10568 2008-02-19 21:20:00Z ddam $
30   */
31  public abstract class AbstractEventCacheableSourceFactory extends AbstractSourceFactory {
32  
33      private CMSSite site;
34  
35      public EventCacheableSource getEventCacheableSource(CMSSite site, InputStream is, DocumentPath[] paths){
36          ObjectCache cache = site.getObjectCache();
37          CacheKeyFactory keyFactory = cache.getCacheKeyFactory();
38          EventValidityFactory validityFactory = cache.getEventValidityFactory();
39          return new EventCacheableSource(is,keyFactory.createKey(new Object[]{"factory="+getName(),paths}),validityFactory.createValidities(paths));
40      }
41      
42      public EventCacheableSource getEventCacheableSource(CMSSite site, InputStream is, DocumentPath path){
43          return this.getEventCacheableSource(site, is, new DocumentPath[]{path});
44      }
45      
46  
47      public void setSite(CMSSite site) {
48          this.site = site;
49      }
50      
51      protected CMSSite getSite() {
52          return this.site;
53      }
54     
55  }