changeset 170:18b234ef3733

New interface for data manager and generic implementation of a data manager.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 24 Jun 2013 14:11:48 +0200
parents 1613ab50d6d0
children 8bf3054109ba
files src/main/java/de/intevation/lada/manage/DataManager.java src/main/java/de/intevation/lada/manage/Manager.java
diffstat 2 files changed, 76 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/manage/DataManager.java	Mon Jun 24 14:11:48 2013 +0200
@@ -0,0 +1,47 @@
+package de.intevation.lada.manage;
+
+import javax.ejb.EJBTransactionRolledbackException;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.persistence.EntityExistsException;
+import javax.persistence.EntityManager;
+import javax.persistence.TransactionRequiredException;
+
+
+@Stateless
+@Named("datamanager")
+public class DataManager
+implements Manager
+{
+    @Inject
+    private EntityManager em;
+
+    @Override
+    @TransactionAttribute(TransactionAttributeType.REQUIRED)
+    public void create(Object object)
+    throws EntityExistsException,
+        IllegalArgumentException,
+        EJBTransactionRolledbackException,
+        TransactionRequiredException {
+        em.persist(object);
+    }
+
+    @Override
+    @TransactionAttribute(TransactionAttributeType.REQUIRED)
+    public void update(Object object)
+    throws EntityExistsException,
+        IllegalArgumentException,
+        EJBTransactionRolledbackException,
+        TransactionRequiredException {
+        em.merge(object);
+    }
+
+    @Override
+    @TransactionAttribute(TransactionAttributeType.REQUIRED)
+    public <T> void delete(String id, Class<T> clazz) throws Exception {
+        
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/manage/Manager.java	Mon Jun 24 14:11:48 2013 +0200
@@ -0,0 +1,29 @@
+package de.intevation.lada.manage;
+
+import javax.ejb.EJBTransactionRolledbackException;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityExistsException;
+import javax.persistence.TransactionRequiredException;
+
+@Stateless
+public interface Manager
+{
+    @TransactionAttribute(TransactionAttributeType.REQUIRED)
+    public void create(Object object)
+    throws EntityExistsException,
+        IllegalArgumentException,
+        EJBTransactionRolledbackException,
+        TransactionRequiredException;
+
+    @TransactionAttribute(TransactionAttributeType.REQUIRED)
+    public void update(Object object)
+    throws EntityExistsException,
+        IllegalArgumentException,
+        EJBTransactionRolledbackException,
+        TransactionRequiredException;
+
+    @TransactionAttribute(TransactionAttributeType.REQUIRED)
+    public <T> void delete(String id, Class<T> clazz) throws Exception;
+}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)