1 package org.infoglue.cms.util.workflow.hibernate; 2 3 import java.util.HashMap ; 4 import java.util.Map ; 5 6 import org.infoglue.cms.applications.workflowtool.util.InfogluePropertySet; 7 import org.infoglue.deliver.util.CacheController; 8 9 import net.sf.hibernate.SessionFactory; 10 11 import com.opensymphony.module.propertyset.PropertySet; 12 import com.opensymphony.module.propertyset.PropertySetManager; 13 import com.opensymphony.module.propertyset.cached.CachingPropertySet; 14 import com.opensymphony.workflow.StoreException; 15 import com.opensymphony.workflow.spi.hibernate.HibernateWorkflowStore; 16 17 18 21 public class InfoglueHibernateWorkflowStore extends HibernateWorkflowStore { 22 25 private SessionFactory sessionFactory; 26 27 30 public InfoglueHibernateWorkflowStore() {} 31 32 35 public InfoglueHibernateWorkflowStore(SessionFactory sessionFactory) throws StoreException { 36 super(sessionFactory); 37 this.sessionFactory = sessionFactory; 38 } 39 40 41 42 45 public void init(Map props) throws StoreException { 46 sessionFactory = (SessionFactory) props.get("sessionFactory"); 47 super.init(props); 48 } 49 50 53 public PropertySet getPropertySet(long entryId) { 54 55 String key = "psCache_" + entryId; 56 PropertySet ps = (PropertySet)CacheController.getCachedObject("propertySetCache", key); 57 58 if(ps == null) 59 { 60 HashMap args = new HashMap (); 61 args.put("entityName", "OSWorkflowEntry"); 62 args.put("entityId", new Long (entryId)); 63 64 InfoglueDefaultHibernateConfigurationProvider configurationProvider = new InfoglueDefaultHibernateConfigurationProvider(); 65 configurationProvider.setSessionFactory(sessionFactory); 66 67 args.put("configurationProvider", configurationProvider); 68 69 70 ps = new CachingPropertySet(); 71 72 Map args2 = new HashMap (); 73 args2.put("PropertySet", PropertySetManager.getInstance("hibernate", args)); 74 args2.put("bulkload", new Boolean (true)); 75 76 ps.init(new HashMap (), args2); 77 78 CacheController.cacheObject("propertySetCache", key, ps); 79 81 ps = PropertySetManager.getInstance("hibernate", args); 82 83 } 84 85 return ps; 86 } 87 } 88 | Popular Tags |