Commits

Anonymous committed d275b3d

Now they correctly uses the delegate for the PropertySet

Comments (0)

Files changed (2)

src/java/com/opensymphony/workflow/spi/hibernate3/NewHibernateWorkflowStore.java

  */
 package com.opensymphony.workflow.spi.hibernate3;
 
-import com.opensymphony.module.propertyset.PropertySet;
-import com.opensymphony.module.propertyset.PropertySetManager;
-import com.opensymphony.module.propertyset.hibernate.DefaultHibernateConfigurationProvider;
-
 import com.opensymphony.workflow.StoreException;
-
-import net.sf.hibernate.SessionFactory;
+import com.opensymphony.workflow.util.PropertySetDelegate;
 
 import org.hibernate.HibernateException;
 import org.hibernate.Session;
 
-import java.util.HashMap;
 import java.util.Map;
 
 
     //~ Instance fields ////////////////////////////////////////////////////////
 
     Session session;
-    SessionFactory sessionFactory;
 
     //~ Constructors ///////////////////////////////////////////////////////////
 
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
-    public PropertySet getPropertySet(long entryId) throws StoreException {
-        HashMap args = new HashMap();
-        args.put("entityName", "OSWorkflowEntry");
-        args.put("entityId", new Long(entryId));
-
-        DefaultHibernateConfigurationProvider configurationProvider = new DefaultHibernateConfigurationProvider();
-        configurationProvider.setSessionFactory(sessionFactory);
-
-        args.put("configurationProvider", configurationProvider);
-
-        return PropertySetManager.getInstance("hibernate", args);
-    }
-
     // Now session management is delegated to user
     public void init(Map props) throws StoreException {
-        sessionFactory = (SessionFactory) props.get("sessionFactory");
         session = (Session) props.get("session");
+
+        setPropertySetDelegate((PropertySetDelegate) props.get("propertySetDelegate"));
     }
 
     protected Object execute(InternalCallback action) throws StoreException {

src/java/com/opensymphony/workflow/spi/hibernate3/NewSpringHibernateWorkflowStore.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.workflow.spi.hibernate3;
+
+import com.opensymphony.workflow.StoreException;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+
+import org.springframework.orm.hibernate3.HibernateCallback;
+import org.springframework.orm.hibernate3.HibernateTemplate;
+
+import java.sql.SQLException;
+
+import java.util.Map;
+
+
+/**
+ * @author masini
+ *
+ * New Refactored Spring Managed Hibernate Store.
+ * Look at @link NewSpringHibernateFunctionalWorkflowTestCase for a use case.
+ */
+public class NewSpringHibernateWorkflowStore extends AbstractHibernateWorkflowStore {
+    //~ Instance fields ////////////////////////////////////////////////////////
+
+    private SessionFactory sessionFactory;
+
+    //~ Constructors ///////////////////////////////////////////////////////////
+
+    public NewSpringHibernateWorkflowStore() {
+        super();
+    }
+
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    public void setSessionFactory(SessionFactory sessionFactory) {
+        this.sessionFactory = sessionFactory;
+    }
+
+    public SessionFactory getSessionFactory() {
+        return sessionFactory;
+    }
+
+    public void init(Map props) throws StoreException {
+    }
+
+    protected Object execute(final InternalCallback action) throws StoreException {
+        HibernateTemplate template = new HibernateTemplate(getSessionFactory());
+
+        return template.execute(new HibernateCallback() {
+                public Object doInHibernate(Session session) throws HibernateException, SQLException {
+                    try {
+                        return action.doInHibernate(session);
+                    } catch (StoreException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            });
+    }
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.