1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package nl.hippo.portal.binding;
17
18 import nl.hippo.client.api.event.EventValidity;
19 import nl.hippo.portal.cms.CMSSite;
20 import nl.hippo.portal.cms.cache.EventCacheable;
21 import nl.hippo.portal.cms.cache.ObjectCache;
22 import nl.hippo.portal.cms.cache.PortalCacheKey;
23 import nl.hippo.portal.cms.source.Source;
24 import nl.hippo.portal.cms.source.SourceException;
25
26 /***
27 * @author <a href="mailto:d.dam@hippo.nl">Dennis Dam</a>
28 *
29 * @version $Id: MarshalledObjectManagerImpl.java 8567 2007-10-18 15:32:18Z ddam $
30 */
31 public class MarshalledObjectManagerImpl implements MarshalledObjectManager {
32
33 private CMSSite site;
34
35 public Object createObject(BindingService bindingService, String url, Class clazz) throws BindingException, SourceException {
36 ObjectCache cache = site.getObjectCache();
37 PortalCacheKey cacheKey = cache.getCacheKeyFactory().createKey(new Object[]{"JAXBObject","site="+site.getName(),"url="+url,"class="+clazz.getName()});
38 Object object = cache.get(cacheKey);
39 if (object == null){
40 Source source = site.getSourceResolver().resolve(url);
41 object = bindingService.unmarshal(clazz, source.getInputStream());
42 if (source instanceof EventCacheable){
43 EventValidity[] validities = ((EventCacheable)source).getEventValidities();
44 cache.store(cacheKey, object, validities);
45 }
46 }
47 return object;
48 }
49
50 public void setSite(CMSSite site) {
51 this.site = site;
52 }
53
54 }