[jboss-cvs] JBossAS SVN: r94614 - in branches/Branch_5_x: server/src/main/org/jboss/ejb/plugins/cmp/jdbc2 and 13 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 9 12:52:58 EDT 2009
Author: alex.loubyansky at jboss.com
Date: 2009-10-09 12:52:58 -0400 (Fri, 09 Oct 2009)
New Revision: 94614
Added:
branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/
branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/
branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/
branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/ABean.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/ALocal.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/ALocalHome.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/BBean.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/BLocal.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/BLocalHome.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/test/
branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/test/JDBC2PmEjbStoreUnitTestCase.java
branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/
branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/
branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/META-INF/
branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/META-INF/ejb-jar.xml
branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/META-INF/jboss.xml
branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/META-INF/jbosscmp-jdbc.xml
branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/b/
branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/b/META-INF/
branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/b/META-INF/ejb-jar.xml
branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/b/META-INF/jboss.xml
branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/b/META-INF/jbosscmp-jdbc.xml
Modified:
branches/Branch_5_x/server/src/main/org/jboss/ejb/GlobalTxEntityMap.java
branches/Branch_5_x/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
branches/Branch_5_x/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
branches/Branch_5_x/testsuite/imports/sections/cmp.xml
Log:
JBAS-7238, JBAS-7313
Modified: branches/Branch_5_x/server/src/main/org/jboss/ejb/GlobalTxEntityMap.java
===================================================================
--- branches/Branch_5_x/server/src/main/org/jboss/ejb/GlobalTxEntityMap.java 2009-10-09 16:38:04 UTC (rev 94613)
+++ branches/Branch_5_x/server/src/main/org/jboss/ejb/GlobalTxEntityMap.java 2009-10-09 16:52:58 UTC (rev 94614)
@@ -31,7 +31,10 @@
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* This class provides a way to find out what entities are contained in
@@ -242,10 +245,7 @@
}
}
- /**
- * associate instance with transaction
- */
- private void associate(Transaction tx, EntityEnterpriseContext entity)
+ public GlobalTxSynchronization getGlobalSynchronization(Transaction tx)
throws RollbackException, SystemException
{
GlobalTxSynchronization globalSync = (GlobalTxSynchronization) txSynch.get(tx);
@@ -255,7 +255,23 @@
txSynch.set(tx, globalSync);
tx.registerSynchronization(globalSync);
}
+ return globalSync;
+ }
+ public Transaction getTransaction()
+ {
+ return txSynch.getTransaction();
+ }
+
+
+ /**
+ * associate instance with transaction
+ */
+ private void associate(Transaction tx, EntityEnterpriseContext entity)
+ throws RollbackException, SystemException
+ {
+ GlobalTxSynchronization globalSync = getGlobalSynchronization(tx);
+
//There should be only one thread associated with this tx at a time.
//Therefore we should not need to synchronize on entityFifoList to ensure exclusive
//access. entityFifoList is correct since it was obtained in a synch block.
@@ -268,17 +284,49 @@
/**
* A list of instances associated with the transaction.
*/
- private class GlobalTxSynchronization implements Synchronization
+ public static class GlobalTxSynchronization implements Synchronization
{
private Transaction tx;
private List instances = new ArrayList();
private boolean synchronizing;
+ private List<Synchronization> otherSync = Collections.emptyList();
+ private Map<Object, Object> txLocals = Collections.emptyMap();
+
public GlobalTxSynchronization(Transaction tx)
{
this.tx = tx;
}
+ public void addSynchronization(Synchronization sync)
+ {
+ if(otherSync.isEmpty())
+ otherSync = Collections.singletonList(sync);
+ else
+ {
+ if(otherSync.size() == 1)
+ otherSync = new ArrayList<Synchronization>(otherSync);
+ otherSync.add(sync);
+ }
+ }
+
+ public void putTxLocal(Object key, Object value)
+ {
+ if(txLocals.isEmpty())
+ txLocals = Collections.singletonMap(key, value);
+ else
+ {
+ if(txLocals.size() == 1)
+ txLocals = new HashMap<Object, Object>(txLocals);
+ txLocals.put(key, value);
+ }
+ }
+
+ public Object getTxLocal(Object key)
+ {
+ return txLocals.get(key);
+ }
+
public void associate(EntityEnterpriseContext ctx)
{
instances.add(ctx);
@@ -376,11 +424,19 @@
// let the runtime exceptions fall out, so the committer can determine
// the root cause of a rollback
synchronize();
+
+ for(Synchronization sync : otherSync)
+ {
+ sync.beforeCompletion();
+ }
}
public void afterCompletion(int status)
{
- //no-op
+ for(Synchronization sync : otherSync)
+ {
+ sync.afterCompletion(status);
+ }
}
}
}
Modified: branches/Branch_5_x/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
===================================================================
--- branches/Branch_5_x/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java 2009-10-09 16:38:04 UTC (rev 94613)
+++ branches/Branch_5_x/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java 2009-10-09 16:52:58 UTC (rev 94614)
@@ -100,7 +100,7 @@
schema = (Schema)getApplicationData(SCHEMA);
if(schema == null)
{
- schema = new Schema();
+ schema = new Schema(container.getEjbModule().getServiceName().getCanonicalName());
putApplicationData(SCHEMA, schema);
}
return schema;
Modified: branches/Branch_5_x/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
===================================================================
--- branches/Branch_5_x/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java 2009-10-09 16:38:04 UTC (rev 94613)
+++ branches/Branch_5_x/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java 2009-10-09 16:52:58 UTC (rev 94614)
@@ -21,6 +21,9 @@
*/
package org.jboss.ejb.plugins.cmp.jdbc2.schema;
+import org.jboss.ejb.EntityContainer;
+import org.jboss.ejb.GlobalTxEntityMap;
+import org.jboss.ejb.GlobalTxEntityMap.GlobalTxSynchronization;
import org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCEntityMetaData;
import org.jboss.ejb.plugins.cmp.jdbc2.bridge.JDBCEntityBridge2;
import org.jboss.ejb.plugins.cmp.jdbc2.bridge.JDBCCMRFieldBridge2;
@@ -41,41 +44,18 @@
*/
public class Schema
{
+ private final String viewsTxLocalKey;
+
private EntityTable[] entityTables;
private RelationTable[] relationTables;
- private TransactionLocal localViews = new TransactionLocal()
+ private GlobalTxEntityMap txLocal = EntityContainer.getGlobalTxEntityMap();
+
+ public Schema(String ejbModuleName)
{
- protected Object initialValue()
- {
- Transaction tx = getTransaction();
+ this.viewsTxLocalKey = ejbModuleName + ".schema.views";
+ }
- if(tx == null)
- {
- throw new IllegalStateException("An operation requires an active transaction!");
- }
-
- Views views = new Views(tx);
- Synchronization sync = new SchemaSynchronization(views);
-
- try
- {
- tx.registerSynchronization(sync);
- }
- catch(RollbackException e)
- {
- throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e);
- }
- catch(SystemException e)
- {
- e.printStackTrace();
- throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage());
- }
-
- return views;
- }
- };
-
public EntityTable createEntityTable(JDBCEntityMetaData metadata, JDBCEntityBridge2 entity)
throws DeploymentException
{
@@ -116,7 +96,7 @@
public Table.View getView(EntityTable table)
{
- Views views = (Views) localViews.get();
+ Views views = getViews();
Table.View view = views.entityViews[table.getTableId()];
if(view == null)
{
@@ -128,7 +108,7 @@
public Table.View getView(RelationTable table)
{
- Views views = (Views) localViews.get();
+ Views views = getViews();
Table.View view = views.relationViews[table.getTableId()];
if(view == null)
{
@@ -140,7 +120,7 @@
public void flush()
{
- Views views = (Views) localViews.get();
+ Views views = getViews();
Table.View[] relationViews = views.relationViews;
if(relationViews != null)
@@ -231,6 +211,36 @@
}
}
+ private Views getViews()
+ {
+ Transaction tx = txLocal.getTransaction();
+ GlobalTxSynchronization globalSync;
+ try
+ {
+ globalSync = txLocal.getGlobalSynchronization(tx);
+ }
+ catch(RollbackException e)
+ {
+ throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e);
+ }
+ catch(SystemException e)
+ {
+ throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage());
+ }
+
+ if(globalSync == null)
+ throw new IllegalStateException("Global transaction synchronization is not available for transaction " + tx);
+
+ Views views = (Views) globalSync.getTxLocal(viewsTxLocalKey);
+ if(views == null)
+ {
+ views = new Views(tx);
+ globalSync.putTxLocal(viewsTxLocalKey, views);
+ globalSync.addSynchronization(new SchemaSynchronization(views));
+ }
+ return views;
+ }
+
// Inner
public class Views
Modified: branches/Branch_5_x/testsuite/imports/sections/cmp.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/sections/cmp.xml 2009-10-09 16:38:04 UTC (rev 94613)
+++ branches/Branch_5_x/testsuite/imports/sections/cmp.xml 2009-10-09 16:52:58 UTC (rev 94614)
@@ -383,6 +383,31 @@
tofile="${build.resources}/cmp2/jbas3541/META-INF/jboss.xml"
overwrite="true"/>
+ <!-- build cmp2-jdbc2pm-ejbstore.jar -->
+ <jar destfile="${build.lib}/cmp2-jdbc2pm-ejbstore.jar">
+ <fileset dir="${build.classes}">
+ <patternset refid="common.test.client.classes"/>
+ <include name="org/jboss/test/cmp2/jdbc2pm/ejbstore/**/A*"/>
+ <include name="org/jboss/test/cmp2/jdbc2pm/ejbstore/test/**"/>
+ </fileset>
+ <fileset dir="${build.resources}/cmp2/jdbc2pm/ejbstore">
+ <include name="META-INF**/*.*"/>
+ </fileset>
+ <zipfileset src="${jboss.test.lib}/jboss-test.jar"
+ includes="org/jboss/**/*.*"/>
+ <zipfileset src="${junit.junit.lib}/junit.jar"
+ includes="junit/**/*.*"/>
+ </jar>
+ <!-- build cmp2-jdbc2pm-ejbstoreb.jar -->
+ <jar destfile="${build.lib}/cmp2-jdbc2pm-ejbstoreb.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/cmp2/jdbc2pm/ejbstore/**/B*"/>
+ </fileset>
+ <fileset dir="${build.resources}/cmp2/jdbc2pm/ejbstore/b">
+ <include name="**/*.*"/>
+ </fileset>
+ </jar>
+
<!-- build cmp2-jbas979.jar -->
<jar destfile="${build.lib}/cmp2-jbas979.jar">
<fileset dir="${build.classes}">
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/ABean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/ABean.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/ABean.java 2009-10-09 16:52:58 UTC (rev 94614)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb;
+
+
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+import javax.ejb.RemoveException;
+import javax.ejb.CreateException;
+
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: $</tt>
+ */
+public abstract class ABean implements EntityBean
+{
+ // CMP accessors --------------------------------------------
+ /**
+ * @ejb.pk-field
+ * @ejb.persistent-field
+ * @ejb.interface-method
+ */
+ public abstract Long getId();
+
+ public abstract void setId(Long id);
+
+ /**
+ * @ejb.persistent-field
+ * @ejb.interface-method
+ */
+ public abstract Integer getIntField();
+
+ /**
+ * @ejb.interface-method
+ */
+ public abstract void setIntField(Integer i);
+
+ /**
+ * @ejb.persistent-field
+ * @ejb.interface-method
+ */
+ public abstract Integer getStoreCount();
+
+ /**
+ * @ejb.interface-method
+ */
+ public abstract void setStoreCount(Integer i);
+
+ /**
+ * @throws javax.ejb.CreateException
+ * @ejb.create-method
+ */
+ public Long ejbCreate(Long id, Integer i)
+ throws CreateException
+ {
+ setId(id);
+ setIntField(i);
+ setStoreCount(new Integer(0));
+ return null;
+ }
+
+ public void ejbPostCreate(Long id, Integer i)
+ {
+ }
+
+ public void setEntityContext(EntityContext ctx)
+ {
+ }
+
+ public void unsetEntityContext()
+ {
+ }
+
+ public void ejbActivate()
+ {
+ }
+
+ public void ejbLoad()
+ {
+ }
+
+ public void ejbPassivate()
+ {
+ }
+
+ public void ejbRemove() throws RemoveException
+ {
+ }
+
+ public void ejbStore()
+ {
+ setStoreCount(new Integer(getStoreCount().intValue() + 1));
+ }
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/ALocal.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/ALocal.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/ALocal.java 2009-10-09 16:52:58 UTC (rev 94614)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: $</tt>
+ */
+public interface ALocal
+ extends javax.ejb.EJBLocalObject
+{
+ public Long getId( ) ;
+
+ public Integer getIntField( ) ;
+
+ public void setIntField( Integer i ) ;
+
+ public Integer getStoreCount();
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/ALocalHome.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/ALocalHome.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/ALocalHome.java 2009-10-09 16:52:58 UTC (rev 94614)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb;
+
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: $</tt>
+ */
+public interface ALocalHome
+ extends javax.ejb.EJBLocalHome
+{
+ public ALocal create(Long id , Integer i)
+ throws javax.ejb.CreateException;
+
+ public ALocal findByPrimaryKey(Long pk)
+ throws javax.ejb.FinderException;
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/BBean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/BBean.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/BBean.java 2009-10-09 16:52:58 UTC (rev 94614)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb;
+
+
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+import javax.ejb.RemoveException;
+import javax.ejb.CreateException;
+
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: $</tt>
+ */
+public abstract class BBean implements EntityBean
+{
+ // CMP accessors --------------------------------------------
+ /**
+ * @ejb.pk-field
+ * @ejb.persistent-field
+ * @ejb.interface-method
+ */
+ public abstract Long getId();
+
+ public abstract void setId(Long id);
+
+ /**
+ * @ejb.persistent-field
+ * @ejb.interface-method
+ */
+ public abstract String getStringField();
+
+ /**
+ * @ejb.interface-method
+ */
+ public abstract void setStringField(String i);
+
+ /**
+ * @ejb.persistent-field
+ * @ejb.interface-method
+ */
+ public abstract Integer getStoreCount();
+
+ /**
+ * @ejb.interface-method
+ */
+ public abstract void setStoreCount(Integer i);
+
+ /**
+ * @throws javax.ejb.CreateException
+ * @ejb.create-method
+ */
+ public Long ejbCreate(Long id, String i)
+ throws CreateException
+ {
+ setId(id);
+ setStringField(i);
+ setStoreCount(new Integer(0));
+ return null;
+ }
+
+ public void ejbPostCreate(Long id, String i)
+ {
+ }
+
+ public void setEntityContext(EntityContext ctx)
+ {
+ }
+
+ public void unsetEntityContext()
+ {
+ }
+
+ public void ejbActivate()
+ {
+ }
+
+ public void ejbLoad()
+ {
+ }
+
+ public void ejbPassivate()
+ {
+ }
+
+ public void ejbRemove() throws RemoveException
+ {
+ }
+
+ public void ejbStore()
+ {
+ setStoreCount(new Integer(getStoreCount().intValue() + 1));
+ }
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/BLocal.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/BLocal.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/BLocal.java 2009-10-09 16:52:58 UTC (rev 94614)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: $</tt>
+ */
+public interface BLocal
+ extends javax.ejb.EJBLocalObject
+{
+ public Long getId( ) ;
+
+ public String getStringField( ) ;
+
+ public void setStringField( String i ) ;
+
+ public Integer getStoreCount();
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/BLocalHome.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/BLocalHome.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/ejb/BLocalHome.java 2009-10-09 16:52:58 UTC (rev 94614)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb;
+
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: $</tt>
+ */
+public interface BLocalHome
+ extends javax.ejb.EJBLocalHome
+{
+ public BLocal create(Long id , String i)
+ throws javax.ejb.CreateException;
+
+ public BLocal findByPrimaryKey(Long pk)
+ throws javax.ejb.FinderException;
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/test/JDBC2PmEjbStoreUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/test/JDBC2PmEjbStoreUnitTestCase.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cmp2/jdbc2pm/ejbstore/test/JDBC2PmEjbStoreUnitTestCase.java 2009-10-09 16:52:58 UTC (rev 94614)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.jdbc2pm.ejbstore.test;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb.ALocal;
+import org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb.ALocalHome;
+import org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb.BLocal;
+import org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb.BLocalHome;
+import org.jboss.test.util.ejb.EJBTestCase;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 44174 $</tt>
+ */
+public class JDBC2PmEjbStoreUnitTestCase
+ extends EJBTestCase
+{
+ public static Test suite() throws Exception
+ {
+ return JBossTestCase.getDeploySetup(JDBC2PmEjbStoreUnitTestCase.class, "cmp2-jdbc2pm-ejbstoreb.jar, cmp2-jdbc2pm-ejbstore.jar");
+ }
+
+ public JDBC2PmEjbStoreUnitTestCase(String methodName)
+ {
+ super(methodName);
+ }
+
+ protected void setUp() throws Exception
+ {
+ getALocalHome().create(new Long(1), new Integer(2));
+ }
+
+ protected void tearDown() throws Exception
+ {
+ getALocalHome().remove(new Long(1));
+ }
+
+ // Tests
+
+ public void testMain() throws Throwable
+ {
+ ALocal a = getALocalHome().findByPrimaryKey(new Long(1));
+ int storeCount = a.getStoreCount().intValue();
+ a.setIntField(new Integer(a.getIntField().intValue() + 1));
+ assertEquals(storeCount + 1, a.getStoreCount().intValue());
+ }
+
+ public void testCorrectView() throws Throwable
+ {
+ BLocal b = getBLocalHome().create(new Long(11), "test");
+ ALocal a = getALocalHome().findByPrimaryKey(new Long(1));
+ }
+
+ // Private
+
+ private ALocalHome getALocalHome()
+ throws NamingException
+ {
+ return (ALocalHome)lookup("ALocal");
+ }
+
+ private BLocalHome getBLocalHome()
+ throws NamingException
+ {
+ return (BLocalHome)lookup("BLocal");
+ }
+
+ private Object lookup(String name) throws NamingException
+ {
+ InitialContext ic = new InitialContext();
+ return ic.lookup(name);
+ }
+}
Added: branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/META-INF/ejb-jar.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/META-INF/ejb-jar.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/META-INF/ejb-jar.xml 2009-10-09 16:52:58 UTC (rev 94614)
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<!DOCTYPE ejb-jar PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+ "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+
+<ejb-jar>
+ <enterprise-beans>
+ <session>
+ <description>JUnit Session Bean Test Runner</description>
+ <ejb-name>EJBTestRunnerEJB</ejb-name>
+ <home>org.jboss.test.util.ejb.EJBTestRunnerHome</home>
+ <remote>org.jboss.test.util.ejb.EJBTestRunner</remote>
+ <ejb-class>org.jboss.test.util.ejb.EJBTestRunnerBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Bean</transaction-type>
+ </session>
+ <entity >
+ <ejb-name>A</ejb-name>
+
+ <local-home>org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb.ALocalHome</local-home>
+ <local>org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb.ALocal</local>
+
+ <ejb-class>org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb.ABean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <prim-key-class>java.lang.Long</prim-key-class>
+ <reentrant>false</reentrant>
+ <cmp-version>2.x</cmp-version>
+ <abstract-schema-name>A</abstract-schema-name>
+ <cmp-field >
+ <description><![CDATA[]]></description>
+ <field-name>id</field-name>
+ </cmp-field>
+ <cmp-field >
+ <description><![CDATA[]]></description>
+ <field-name>intField</field-name>
+ </cmp-field>
+ <cmp-field >
+ <description><![CDATA[]]></description>
+ <field-name>storeCount</field-name>
+ </cmp-field>
+ <primkey-field>id</primkey-field>
+ </entity>
+ </enterprise-beans>
+
+ <assembly-descriptor >
+ <container-transaction >
+ <method >
+ <ejb-name>A</ejb-name>
+ <method-name>getStoreCount</method-name>
+ </method>
+ <trans-attribute>RequiresNew</trans-attribute>
+ </container-transaction>
+ <container-transaction >
+ <method >
+ <ejb-name>A</ejb-name>
+ <method-name>setIntField</method-name>
+ </method>
+ <trans-attribute>RequiresNew</trans-attribute>
+ </container-transaction>
+ </assembly-descriptor>
+
+</ejb-jar>
Added: branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/META-INF/jboss.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/META-INF/jboss.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/META-INF/jboss.xml 2009-10-09 16:52:58 UTC (rev 94614)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
+
+<jboss>
+ <enterprise-beans>
+ <entity>
+ <ejb-name>A</ejb-name>
+ <local-jndi-name>ALocal</local-jndi-name>
+ <configuration-name>custom</configuration-name>
+ </entity>
+ <session>
+ <ejb-name>EJBTestRunnerEJB</ejb-name>
+ <jndi-name>ejb/EJBTestRunner</jndi-name>
+ </session>
+ </enterprise-beans>
+
+ <container-configurations>
+ <container-configuration extends="cmp2.x jdbc2 pm">
+ <container-name>custom</container-name>
+ <call-ejb-store-on-clean>false</call-ejb-store-on-clean>
+ </container-configuration>
+ </container-configurations>
+</jboss>
Added: branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/META-INF/jbosscmp-jdbc.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/META-INF/jbosscmp-jdbc.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/META-INF/jbosscmp-jdbc.xml 2009-10-09 16:52:58 UTC (rev 94614)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jbosscmp-jdbc PUBLIC
+ "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN"
+ "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd">
+<jbosscmp-jdbc>
+ <defaults>
+ <remove-table>true</remove-table>
+ </defaults>
+</jbosscmp-jdbc>
Added: branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/b/META-INF/ejb-jar.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/b/META-INF/ejb-jar.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/b/META-INF/ejb-jar.xml 2009-10-09 16:52:58 UTC (rev 94614)
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<!DOCTYPE ejb-jar PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+ "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+
+<ejb-jar>
+ <enterprise-beans>
+ <entity >
+ <ejb-name>B</ejb-name>
+
+ <local-home>org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb.BLocalHome</local-home>
+ <local>org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb.BLocal</local>
+
+ <ejb-class>org.jboss.test.cmp2.jdbc2pm.ejbstore.ejb.BBean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <prim-key-class>java.lang.Long</prim-key-class>
+ <reentrant>false</reentrant>
+ <cmp-version>2.x</cmp-version>
+ <abstract-schema-name>B</abstract-schema-name>
+ <cmp-field >
+ <description><![CDATA[]]></description>
+ <field-name>id</field-name>
+ </cmp-field>
+ <cmp-field >
+ <description><![CDATA[]]></description>
+ <field-name>stringField</field-name>
+ </cmp-field>
+ <cmp-field >
+ <description><![CDATA[]]></description>
+ <field-name>storeCount</field-name>
+ </cmp-field>
+ <primkey-field>id</primkey-field>
+ </entity>
+ </enterprise-beans>
+
+ <assembly-descriptor >
+ <container-transaction >
+ <method >
+ <ejb-name>B</ejb-name>
+ <method-name>getStoreCount</method-name>
+ </method>
+ <trans-attribute>RequiresNew</trans-attribute>
+ </container-transaction>
+ <container-transaction >
+ <method >
+ <ejb-name>B</ejb-name>
+ <method-name>setStringField</method-name>
+ </method>
+ <trans-attribute>RequiresNew</trans-attribute>
+ </container-transaction>
+ </assembly-descriptor>
+
+</ejb-jar>
Added: branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/b/META-INF/jboss.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/b/META-INF/jboss.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/b/META-INF/jboss.xml 2009-10-09 16:52:58 UTC (rev 94614)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
+
+<jboss>
+ <enterprise-beans>
+ <entity>
+ <ejb-name>B</ejb-name>
+ <local-jndi-name>BLocal</local-jndi-name>
+ <configuration-name>custom</configuration-name>
+ </entity>
+ </enterprise-beans>
+
+ <container-configurations>
+ <container-configuration extends="cmp2.x jdbc2 pm">
+ <container-name>custom</container-name>
+ <call-ejb-store-on-clean>false</call-ejb-store-on-clean>
+ </container-configuration>
+ </container-configurations>
+</jboss>
Added: branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/b/META-INF/jbosscmp-jdbc.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/b/META-INF/jbosscmp-jdbc.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/cmp2/jdbc2pm/ejbstore/b/META-INF/jbosscmp-jdbc.xml 2009-10-09 16:52:58 UTC (rev 94614)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jbosscmp-jdbc PUBLIC
+ "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN"
+ "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd">
+<jbosscmp-jdbc>
+ <defaults>
+ <remove-table>true</remove-table>
+ </defaults>
+</jbosscmp-jdbc>
More information about the jboss-cvs-commits
mailing list