User: fleury
Date: 00/07/14 12:11:28
Modified: src/main/org/jboss/ejb/plugins/jaws
JAWSPersistenceManager.java
Log:
We factor the ctx management. The plugin returns the Object id on create now.
Revision Changes Path
1.19 +19 -38
jboss/src/main/org/jboss/ejb/plugins/jaws/JAWSPersistenceManager.java
Index: JAWSPersistenceManager.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jaws/JAWSPersistenceManager.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- JAWSPersistenceManager.java 2000/07/07 23:07:25 1.18
+++ JAWSPersistenceManager.java 2000/07/14 19:11:27 1.19
@@ -39,7 +39,7 @@
import org.jboss.ejb.Container;
import org.jboss.ejb.EntityContainer;
-import org.jboss.ejb.EntityPersistenceManager;
+import org.jboss.ejb.EntityPersistenceStore;
import org.jboss.ejb.EntityEnterpriseContext;
import org.jboss.logging.Log;
@@ -67,22 +67,23 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Joe Shevland</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Justin Forder</a>
- * @version $Revision: 1.18 $
+ * @version $Revision: 1.19 $
*/
public class JAWSPersistenceManager
- implements EntityPersistenceManager
+ implements EntityPersistenceStore
{
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
EntityContainer container;
+/*
Method ejbStore;
Method ejbLoad;
Method ejbActivate;
Method ejbPassivate;
Method ejbRemove;
-
+*/
// Pre-calculated fields to speed things up
ArrayList pkFields = new ArrayList(); // Field's in entity class
ArrayList pkClassFields = new ArrayList(); // Field's in pk class
@@ -226,11 +227,14 @@
makeSql();
// Find EJB-methods
+ // All the EJB method calls are moved to the CMPPersistenceManager
+ /*
ejbStore = EntityBean.class.getMethod("ejbStore", new Class[0]);
ejbLoad = EntityBean.class.getMethod("ejbLoad", new Class[0]);
ejbActivate = EntityBean.class.getMethod("ejbActivate", new Class[0]);
ejbPassivate = EntityBean.class.getMethod("ejbPassivate", new Class[0]);
ejbRemove = EntityBean.class.getMethod("ejbRemove", new Class[0]);
+ */
}
public void start()
@@ -300,8 +304,9 @@
}
}
}
+
- public void createEntity(Method m, Object[] args, EntityEnterpriseContext ctx)
+ public Object createEntity(Method m, Object[] args, EntityEnterpriseContext
ctx)
throws RemoteException, CreateException
{
@@ -337,11 +342,7 @@
// it exists, we need the DuplicateKey thingy
throw new DuplicateKeyException("Entity with key
"+id+" already exists");
}
-
- // We know we are OK and can proceed with the insert
- // Set id
- ctx.setId(id);
-
+
// Insert in db
log.debug("Insert");
Connection con = null;
@@ -391,11 +392,14 @@
ctx.setPersistenceContext(pCtx);
+
+ return id;
} catch (IllegalAccessException e) {
log.exception(e);
throw new CreateException("Could not create entity:"+e);
}
+
}
@@ -661,16 +665,7 @@
public void activateEntity(EntityEnterpriseContext ctx)
throws RemoteException
- {
- // Call bean
- try
- {
- ejbActivate.invoke(ctx.getInstance(), new Object[0]);
- } catch (Exception e)
- {
- throw new ServerException("Activation failed", e);
- }
-
+ {
// Set new persistence context
ctx.setPersistenceContext(new PersistenceContext());
}
@@ -792,10 +787,7 @@
// Store state to be able to do tuned updates
PersistenceContext pCtx = (PersistenceContext)ctx.getPersistenceContext();
if (readOnly) pCtx.lastRead = System.currentTimeMillis();
-
- // Call ejbLoad on bean instance
- ejbLoad.invoke(ctx.getInstance(), new Object[0]);
-
+
// Done
} catch (Exception e)
{
@@ -829,8 +821,6 @@
PreparedStatement stmt = null;
try
{
- // Call bean
- ejbStore.invoke(ctx.getInstance(), new Object[0]);
// Create tuned update
String updateSql = "UPDATE "+tableName+" SET ";
@@ -959,15 +949,8 @@
public void passivateEntity(EntityEnterpriseContext ctx)
throws RemoteException
- {
- // Call bean
- try
- {
- ejbPassivate.invoke(ctx.getInstance(), new Object[0]);
- } catch (Exception e)
- {
- throw new ServerException("Passivation failed", e);
- }
+ {
+ // There is nothing to do here
}
public void removeEntity(EntityEnterpriseContext ctx)
@@ -978,9 +961,7 @@
try
{
- // Call ejbRemove
- ejbRemove.invoke(ctx.getInstance(), new Object[0]);
-
+
// Remove from DB
con = getConnection();
stmt = con.prepareStatement(removeSql);