[jboss-cvs] JBossAS SVN: r82040 - in branches/JBPAPP_4_2_0_GA_CP/ejb3: src/main/org/jboss/ejb3 and 11 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Dec 4 07:18:37 EST 2008
Author: wolfc
Date: 2008-12-04 07:18:37 -0500 (Thu, 04 Dec 2008)
New Revision: 82040
Added:
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/aop/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/aop/AbstractInterceptor.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/aop/AbstractInterceptorFactory.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CCMUtil.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptor.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptorFactory.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/ejbthree1028/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/ejbthree1028/META-INF/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/common/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/common/EJB3TestCase.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/ATM.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/ATMBean.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/Account.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/unit/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/unit/LazyTransactionEnlistmentUnitTestCase.java
Removed:
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptor.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptorFactory.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/ejbthree1028/META-INF/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/ATM.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/ATMBean.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/Account.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/unit/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/unit/LazyTransactionEnlistmentUnitTestCase.java
Modified:
branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/tx/UserTransactionImpl.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/ResourceHandler.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/ejb3-interceptors-aop.xml
Log:
JBPAPP-1453: merged EJBTHREE-1028
Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml 2008-12-04 12:05:02 UTC (rev 82039)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml 2008-12-04 12:18:37 UTC (rev 82040)
@@ -2036,7 +2036,11 @@
<build-simple-jar name="ejbthree1025"/>
</target>
-
+
+ <target name="ejbthree1028" description="Builds a simple jar file.">
+ <build-simple-jar name="ejbthree1028"/>
+ </target>
+
<!--target name="ejbthree1057" depends="compile-classes">
<build-simple-jar name="ejbthree1057"/>
</target-->
@@ -3805,7 +3809,9 @@
ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree724, ejbthree751, ejbthree785, ejbthree832,
ejbthree987,
ejbthree921,
- ejbthree959, ejbthree963, ejbthree994, ejbthree1023, ejbthree1025, ejbthree1062,
+ ejbthree959, ejbthree963, ejbthree994, ejbthree1023, ejbthree1025,
+ ejbthree1028,
+ ejbthree1062,
ejbthree1109,
ejbthree1239,
ejbthree1504,
@@ -4470,6 +4476,9 @@
<param name="test" value="regression/ejbthree290"/>
</antcall>
<antcall target="test" inheritRefs="true">
+ <param name="test" value="ejbthree1028"/>
+ </antcall>
+ <antcall target="test" inheritRefs="true">
<param name="test" value="longlived"/>
</antcall>
<antcall target="test" inheritRefs="true">
Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/EJBContainer.java 2008-12-04 12:05:02 UTC (rev 82039)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/EJBContainer.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -31,6 +31,7 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
@@ -57,12 +58,11 @@
import org.jboss.annotation.ejb.RemoteBindingImpl;
import org.jboss.annotation.ejb.RemoteBindings;
import org.jboss.annotation.ejb.RemoteBindingsImpl;
+import org.jboss.aop.Advisor;
import org.jboss.aop.AspectManager;
import org.jboss.aop.ClassContainer;
import org.jboss.aop.MethodInfo;
-import org.jboss.aop.advice.AspectDefinition;
import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.advice.Scope;
import org.jboss.aop.annotation.AnnotationElement;
import org.jboss.aop.joinpoint.ConstructorInvocation;
import org.jboss.aop.util.MethodHashing;
@@ -91,7 +91,6 @@
import org.jboss.logging.Logger;
import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
import org.jboss.naming.Util;
-//import org.jboss.virtual.VirtualFile;
import org.jboss.util.StringPropertyReplacer;
/**
@@ -158,6 +157,8 @@
private String partitionName;
+ private Set<String> unsharableResources = new HashSet<String>();
+
/**
* @param name Advisor name
* @param manager Domain to get interceptor bindings from
@@ -214,7 +215,23 @@
this.interceptorRepository.addBeanClass(clazz.getName());
}
-
+ public void addUnsharableResource(String jndiName)
+ {
+ assert jndiName != null : "jndiName is null";
+
+ int i = jndiName.indexOf(':');
+ if (jndiName.charAt(i + 1) == '/')
+ {
+ i++;
+ }
+ unsharableResources.add(jndiName.substring(i + 1));
+ }
+
+ public Set<String> getUnsharableResources()
+ {
+ return Collections.unmodifiableSet(unsharableResources);
+ }
+
// public EjbEncFactory getEncFactory()
// {
// return encFactory;
@@ -472,6 +489,19 @@
return objectName;
}
+ @SuppressWarnings("unchecked")
+ public static <C extends EJBContainer> C getEJBContainer(Advisor advisor)
+ {
+ try
+ {
+ return (C) advisor;
+ }
+ catch(ClassCastException e)
+ {
+ throw new ClassCastException(e.getMessage() + " using " + advisor);
+ }
+ }
+
public String getEjbName()
{
return ejbName;
Copied: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/aop/AbstractInterceptor.java (from rev 82000, projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/aop/AbstractInterceptor.java)
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/aop/AbstractInterceptor.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/aop/AbstractInterceptor.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejb3.aop;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.ejb3.EJBContainer;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractInterceptor implements Interceptor
+{
+ @SuppressWarnings("unchecked")
+ public static <C extends EJBContainer> C getEJBContainer(Invocation invocation)
+ {
+ // Because of Sun JDK we must cast it to something, or else there will be
+ // no upper bound.
+ // In AS 4.x the advisor and container are the same.
+ return (C) invocation.getAdvisor();
+ }
+
+ public String getName()
+ {
+ return getClass().getName();
+ }
+}
Copied: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/aop/AbstractInterceptorFactory.java (from rev 82000, projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/AbstractInterceptorFactory.java)
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/aop/AbstractInterceptorFactory.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/aop/AbstractInterceptorFactory.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.ejb3.aop;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.InstanceAdvisor;
+import org.jboss.aop.advice.AspectFactory;
+import org.jboss.aop.joinpoint.Joinpoint;
+
+/**
+ * An aspect factory that can do nothing.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public abstract class AbstractInterceptorFactory implements AspectFactory
+{
+ public Object createPerClass(Advisor advisor)
+ {
+ throw new IllegalStateException("Per class scope not supported");
+ }
+
+ public Object createPerInstance(Advisor advisor, InstanceAdvisor instanceAdvisor)
+ {
+ throw new IllegalStateException("Per instance scope not supported on " + this);
+ }
+
+ public Object createPerJoinpoint(Advisor advisor, Joinpoint jp)
+ {
+ throw new IllegalStateException("Per joinpoint scope not supported on " + this);
+ }
+
+ public Object createPerJoinpoint(Advisor advisor, InstanceAdvisor instanceAdvisor, Joinpoint jp)
+ {
+ throw new IllegalStateException("Per joinpoint instance scope not supported on " + this);
+ }
+
+ public Object createPerVM()
+ {
+ throw new IllegalStateException("Per vm scope not supported");
+ }
+
+ public final String getName()
+ {
+ return getClass().getName();
+ }
+}
Copied: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager (from rev 82000, projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager)
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CCMUtil.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CCMUtil.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CCMUtil.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.connectionmanager;
+
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanServer;
+import javax.management.ReflectionException;
+
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.resource.connectionmanager.CachedConnectionManager;
+import org.jboss.resource.connectionmanager.CachedConnectionManagerMBean;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CCMUtil
+{
+ public static CachedConnectionManager getCachedConnectionManager()
+ {
+ MBeanServer server = MBeanServerLocator.locateJBoss();
+ try
+ {
+ return (CachedConnectionManager) server.getAttribute(CachedConnectionManagerMBean.OBJECT_NAME, "Instance");
+ }
+ catch (AttributeNotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (MBeanException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (ReflectionException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Deleted: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptor.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptor.java 2008-12-03 07:56:10 UTC (rev 82000)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptor.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.ejb3.connectionmanager;
-
-import java.util.Set;
-
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.EJBContainerInvocation;
-import org.jboss.ejb3.aop.AbstractInterceptor;
-import org.jboss.jca.spi.ComponentStack;
-import org.jboss.logging.Logger;
-
-/**
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class CachedConnectionInterceptor extends AbstractInterceptor
-{
- private static final Logger log = Logger.getLogger(CachedConnectionInterceptor.class);
- private final Set<String> unsharableResources;
-
- public CachedConnectionInterceptor(Set<String> unsharableResources)
- {
- this.unsharableResources = unsharableResources;
- }
-
- public Object invoke(Invocation invocation) throws Throwable
- {
- EJBContainerInvocation<EJBContainer, BeanContext<?>> containerInvocation = (EJBContainerInvocation<EJBContainer, BeanContext<?>>) invocation;
- EJBContainer container = getEJBContainer(invocation);
- ComponentStack ccm = container.getCachedConnectionManager();
- if(ccm == null)
- {
- log.warn("EJBTHREE-1028: No ejb3 CachedConnectionManager installed");
- return containerInvocation.invokeNext();
- }
- Object key = containerInvocation.getBeanContext().getInstance();
- ccm.pushMetaAwareObject(key, unsharableResources);
- try
- {
- return containerInvocation.invokeNext();
- }
- finally
- {
- ccm.popMetaAwareObject(unsharableResources);
- }
- }
-}
Copied: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptor.java (from rev 82036, projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptor.java)
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptor.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptor.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.connectionmanager;
+
+import java.util.Set;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.EJBContainerInvocation;
+import org.jboss.ejb3.aop.AbstractInterceptor;
+import org.jboss.logging.Logger;
+import org.jboss.resource.connectionmanager.CachedConnectionManager;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CachedConnectionInterceptor extends AbstractInterceptor
+{
+ private static final Logger log = Logger.getLogger(CachedConnectionInterceptor.class);
+ private final Set<String> unsharableResources;
+ private final CachedConnectionManager ccm;
+
+ public CachedConnectionInterceptor(Set<String> unsharableResources)
+ {
+ this.ccm = CCMUtil.getCachedConnectionManager();
+ this.unsharableResources = unsharableResources;
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ EJBContainerInvocation<EJBContainer, BeanContext> containerInvocation = (EJBContainerInvocation<EJBContainer, BeanContext>) invocation;
+ Object key = containerInvocation.getBeanContext().getInstance();
+ ccm.pushMetaAwareObject(key, unsharableResources);
+ try
+ {
+ return containerInvocation.invokeNext();
+ }
+ finally
+ {
+ ccm.popMetaAwareObject(unsharableResources);
+ }
+ }
+}
Deleted: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptorFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptorFactory.java 2008-12-03 07:56:10 UTC (rev 82000)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptorFactory.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.ejb3.connectionmanager;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.aop.Advisor;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.interceptors.aop.AbstractInterceptorFactory;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
-import org.jboss.metadata.javaee.spec.ResourceReferencesMetaData;
-
-/**
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class CachedConnectionInterceptorFactory extends AbstractInterceptorFactory
-{
- @Override
- public Object createPerClass(Advisor advisor)
- {
- EJBContainer container = EJBContainer.getEJBContainer(advisor);
- Set<String> unsharableResources = new HashSet<String>();
- JBossEnterpriseBeanMetaData metaData = container.getXml();
- ResourceReferencesMetaData resRefs = metaData.getResourceReferences();
- if(resRefs != null)
- {
- for(ResourceReferenceMetaData resRef : resRefs)
- {
- String jndiName = resRef.getJndiName();
- if(jndiName == null)
- jndiName = resRef.getResolvedJndiName();
- // for res-url resources
- if(jndiName == null)
- continue;
- int i = jndiName.indexOf(':');
- if(jndiName.charAt(i + 1) == '/')
- i++;
- unsharableResources.add(jndiName.substring(i + 1));
- }
- }
- return new CachedConnectionInterceptor(unsharableResources);
- }
-}
Copied: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptorFactory.java (from rev 82036, projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptorFactory.java)
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptorFactory.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptorFactory.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.connectionmanager;
+
+import org.jboss.aop.Advisor;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.aop.AbstractInterceptorFactory;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CachedConnectionInterceptorFactory extends AbstractInterceptorFactory
+{
+ @Override
+ public Object createPerClass(Advisor advisor)
+ {
+ EJBContainer container = EJBContainer.getEJBContainer(advisor);
+ return new CachedConnectionInterceptor(container.getUnsharableResources());
+ }
+}
Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/tx/UserTransactionImpl.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/tx/UserTransactionImpl.java 2008-12-04 12:05:02 UTC (rev 82039)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/tx/UserTransactionImpl.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.NotSupportedException;
@@ -32,7 +33,10 @@
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
+
+import org.jboss.ejb3.connectionmanager.CCMUtil;
import org.jboss.logging.Logger;
+import org.jboss.resource.connectionmanager.CachedConnectionManager;
/**
* Comment
@@ -51,12 +55,15 @@
* by this bean instance.
*/
private TransactionManager tm;
+
+ private CachedConnectionManager ccm;
public UserTransactionImpl()
{
if (log.isDebugEnabled())
log.debug("new UserTx: " + this);
this.tm = TxUtil.getTransactionManager();
+ this.ccm = CCMUtil.getCachedConnectionManager();
}
public void begin()
@@ -64,11 +71,13 @@
{
// Start the transaction
tm.begin();
+
+ if(ccm != null)
+ ccm.userTransactionStarted();
Transaction tx = tm.getTransaction();
if (log.isDebugEnabled())
log.debug("UserTx begin: " + tx);
-
}
public void commit()
@@ -125,6 +134,7 @@
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
this.tm = TxUtil.getTransactionManager();
+ this.ccm = CCMUtil.getCachedConnectionManager();
}
}
Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/ResourceHandler.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/ResourceHandler.java 2008-12-04 12:05:02 UTC (rev 82039)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/ResourceHandler.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -21,7 +21,24 @@
*/
package org.jboss.injection;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+import javax.ejb.EJBContext;
+import javax.ejb.EJBException;
+import javax.ejb.TimerService;
+import javax.transaction.UserTransaction;
+import javax.xml.ws.WebServiceContext;
+
import org.jboss.ejb3.Container;
+import org.jboss.ejb3.EJBContainer;
import org.jboss.injection.lang.reflect.BeanProperty;
import org.jboss.injection.lang.reflect.BeanPropertyFactory;
import org.jboss.injection.lang.reflect.FieldBeanProperty;
@@ -32,24 +49,7 @@
import org.jboss.metamodel.descriptor.MessageDestinationRef;
import org.jboss.metamodel.descriptor.ResourceEnvRef;
import org.jboss.metamodel.descriptor.ResourceRef;
-//import org.jboss.reflect.plugins.ValueConvertor;
-import javax.annotation.Resource;
-import javax.annotation.Resources;
-import javax.ejb.EJBContext;
-import javax.ejb.EJBException;
-import javax.ejb.TimerService;
-import javax.transaction.UserTransaction;
-import javax.xml.ws.WebServiceContext;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.Map;
-import java.net.URL;
-import java.net.MalformedURLException;
-
/**
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
@@ -96,6 +96,8 @@
}
else
{
+ if(container instanceof EJBContainer && envRef.isShareable() == false)
+ ((EJBContainer) container).addUnsharableResource(envRef.getMappedName());
container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, envRef.getMappedName(), "<resource-ref>"));
}
InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
@@ -214,6 +216,8 @@
}
else
{
+ if(container instanceof EJBContainer && ref.shareable() == false)
+ ((EJBContainer) container).addUnsharableResource(ref.mappedName());
container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
}
}
@@ -505,6 +509,8 @@
// else
throw new RuntimeException("You did not specify a @Resource.mappedName() on " + accObj + " and there is no binding for enc name " + encName + " in XML");
}
+ if(container instanceof EJBContainer && ref.shareable() == false)
+ ((EJBContainer) container).addUnsharableResource(ref.mappedName());
container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
}
injectors.put(accObj, new JndiPropertyInjector(property, encName, ref.mappedName(), container.getEnc()));
Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/ejb3-interceptors-aop.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/ejb3-interceptors-aop.xml 2008-12-04 12:05:02 UTC (rev 82039)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/ejb3-interceptors-aop.xml 2008-12-04 12:18:37 UTC (rev 82040)
@@ -84,6 +84,7 @@
<interceptor class="org.jboss.ejb3.AllowedOperationsInterceptor" scope="PER_VM"/>
<interceptor factory="org.jboss.ejb3.mdb.CurrentMessageInjectorInterceptorFactory" scope="PER_CLASS"/>
<interceptor class="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor" scope="PER_VM"/>
+ <interceptor factory="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory" scope="PER_CLASS"/>
<domain name="Stateless Bean">
<bind pointcut="execution(public * *->*(..))">
@@ -106,6 +107,7 @@
<interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
</bind>
<annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
@@ -134,6 +136,7 @@
<interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
</bind>
<annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
@@ -178,6 +181,7 @@
</bind>
<bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
</bind>
@@ -237,6 +241,7 @@
<bind pointcut="execution(public * *->*(..))">
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
</bind>
@@ -284,6 +289,7 @@
<interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
</bind>
<annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
@@ -305,6 +311,7 @@
<interceptor-ref name="org.jboss.ejb3.mdb.CurrentMessageInjectorInterceptorFactory"/>
</bind>
<bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
</bind>
<annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
@@ -333,6 +340,7 @@
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
</bind>
<bind pointcut="execution(public * *->*(..)) AND !execution(* *->create()) AND !execution(* *->start())">
+ <interceptor-ref name="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
</bind>
</domain>
@@ -358,6 +366,7 @@
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
</bind>
<bind pointcut="execution(public * *->*(..)) AND !execution(* *->create()) AND !execution(* *->start())">
+ <interceptor-ref name="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
</bind>
</domain>
Copied: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/ejbthree1028 (from rev 82000, projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1028)
Copied: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/ejbthree1028/META-INF (from rev 82036, projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1028/META-INF)
Copied: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/common/EJB3TestCase.java (from rev 82000, projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/common/EJB3TestCase.java)
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/common/EJB3TestCase.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/common/EJB3TestCase.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.test.common;
+
+import org.jboss.test.JBossTestCase;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public abstract class EJB3TestCase extends JBossTestCase
+{
+ protected EJB3TestCase(String name)
+ {
+ super(name);
+ }
+
+ protected <T> T lookup(String name, Class<T> expectedType) throws Exception
+ {
+ return expectedType.cast(getInitialContext().lookup(name));
+ }
+
+ /**
+ * Make sure the deployment is successful.
+ * @throws Exception
+ */
+ public final void testServerFound() throws Exception
+ {
+ // we don't want this done in suite, because then the individual
+ // failure count for this test would go down. (1 failure instead of many)
+ serverFound();
+ }
+}
Copied: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028 (from rev 82000, projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028)
Deleted: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/ATM.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/ATM.java 2008-12-03 07:56:10 UTC (rev 82000)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/ATM.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.ejb3.test.ejbthree1028;
-
-import javax.ejb.Remote;
-
-/**
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
- at Remote
-public interface ATM
-{
- long createAccount(double balance);
-
- double getBalance(long id);
-
- double depositTwiceWithRollback(long id, double a1, double a2);
-
- double withdrawTwiceWithRollback(long id, double a1, double a2);
-}
Copied: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/ATM.java (from rev 82036, projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/ATM.java)
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/ATM.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/ATM.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.test.ejbthree1028;
+
+import javax.ejb.Remote;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Remote
+public interface ATM
+{
+ long createAccount(double balance);
+
+ double getBalance(long id);
+
+ double depositTwiceWithRollback(long id, double a1, double a2);
+
+ double withdrawTwiceWithRollback(long id, double a1, double a2);
+}
Deleted: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/ATMBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/ATMBean.java 2008-12-03 07:56:10 UTC (rev 82000)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/ATMBean.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -1,265 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.ejb3.test.ejbthree1028;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import javax.annotation.Resource;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionManagement;
-import javax.ejb.TransactionManagementType;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.sql.DataSource;
-import javax.transaction.NotSupportedException;
-import javax.transaction.Status;
-import javax.transaction.SystemException;
-import javax.transaction.UserTransaction;
-
-/**
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
- at Stateless
- at TransactionManagement(TransactionManagementType.BEAN)
-public class ATMBean implements ATM
-{
- @PersistenceContext
- private EntityManager em;
-
- @Resource
- private UserTransaction ut;
-
- @Resource(mappedName="java:/DefaultDS")
- private DataSource ds;
-
- private void beginTx()
- {
- try
- {
- ut.begin();
- }
- catch (NotSupportedException e)
- {
- throw new RuntimeException(e);
- }
- catch (SystemException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- private void commitTx()
- {
- try
- {
- ut.commit();
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- // RollbackException, HeuristicMixedException, HeuristicRollbackException, SystemException
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public long createAccount(double balance)
- {
- beginTx();
- try
- {
- Account a = new Account();
- a.setBalance(balance);
- em.persist(a);
- commitTx();
- return a.getId();
- }
- finally
- {
- rollbackTxIfNeeded();
- }
- }
-
- public double getBalance(long id)
- {
- Account a = em.find(Account.class, id);
- return a.getBalance();
- }
-
- private void rollbackTx()
- {
- try
- {
- ut.rollback();
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- // SecurityException, SystemException
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- private void rollbackTxIfNeeded()
- {
- try
- {
- switch(ut.getStatus())
- {
- case Status.STATUS_COMMITTED:
- case Status.STATUS_NO_TRANSACTION:
- break;
- default:
- ut.rollback();
- }
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- // SecurityException, SystemException
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public double depositTwiceWithRollback(long id, double a1, double a2)
- {
- Account a;
- beginTx();
- try
- {
- a = em.find(Account.class, id);
- // unsafe (nolock)
- a.setBalance(a.getBalance() + a1);
- em.flush();
- commitTx();
- }
- finally
- {
- rollbackTxIfNeeded();
- }
-
- beginTx();
- try
- {
- // unsafe
- a.setBalance(a.getBalance() + a2);
- em.flush();
- }
- finally
- {
- rollbackTx();
- }
- return a.getBalance();
- }
-
- /**
- * Do the same, but then raw sql.
- * @param id
- * @param a1
- * @param a2
- */
- public double withdrawTwiceWithRollback(long id, double a1, double a2)
- {
- try
- {
- Connection conn = ds.getConnection();
- try
- {
- double balance;
- PreparedStatement ps = conn.prepareStatement("SELECT balance FROM account WHERE id = ?");
- try
- {
- ps.setLong(1, id);
- ResultSet rs = ps.executeQuery();
- if(!rs.next())
- throw new IllegalArgumentException("can't find account " + id);
- balance = rs.getDouble(1);
- }
- finally
- {
- ps.close();
- }
-
- ps = conn.prepareStatement("UPDATE account SET balance = ? WHERE id = ?");
- try
- {
- beginTx();
- try
- {
- balance -= a1;
- ps.setDouble(1, balance);
- ps.setLong(2, id);
- int rows = ps.executeUpdate();
- if(rows != 1)
- throw new IllegalStateException("first update failed");
-
- commitTx();
- }
- finally
- {
- rollbackTxIfNeeded();
- }
-
- beginTx();
- try
- {
- balance -= a2;
- ps.setDouble(1, balance);
- ps.setLong(2, id);
- int rows = ps.executeUpdate();
- if(rows != 1)
- throw new IllegalStateException("second update failed");
- }
- finally
- {
- rollbackTx();
- }
- }
- finally
- {
- ps.close();
- }
- return balance;
- }
- finally
- {
- conn.close();
- }
- }
- catch(SQLException e)
- {
- throw new RuntimeException(e);
- }
- }
-}
Copied: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/ATMBean.java (from rev 82036, projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/ATMBean.java)
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/ATMBean.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/ATMBean.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -0,0 +1,265 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.test.ejbthree1028;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.sql.DataSource;
+import javax.transaction.NotSupportedException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at TransactionManagement(TransactionManagementType.BEAN)
+public class ATMBean implements ATM
+{
+ @PersistenceContext
+ private EntityManager em;
+
+ @Resource
+ private UserTransaction ut;
+
+ @Resource(mappedName="java:/DefaultDS")
+ private DataSource ds;
+
+ private void beginTx()
+ {
+ try
+ {
+ ut.begin();
+ }
+ catch (NotSupportedException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (SystemException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void commitTx()
+ {
+ try
+ {
+ ut.commit();
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ // RollbackException, HeuristicMixedException, HeuristicRollbackException, SystemException
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public long createAccount(double balance)
+ {
+ beginTx();
+ try
+ {
+ Account a = new Account();
+ a.setBalance(balance);
+ em.persist(a);
+ commitTx();
+ return a.getId();
+ }
+ finally
+ {
+ rollbackTxIfNeeded();
+ }
+ }
+
+ public double getBalance(long id)
+ {
+ Account a = em.find(Account.class, id);
+ return a.getBalance();
+ }
+
+ private void rollbackTx()
+ {
+ try
+ {
+ ut.rollback();
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ // SecurityException, SystemException
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void rollbackTxIfNeeded()
+ {
+ try
+ {
+ switch(ut.getStatus())
+ {
+ case Status.STATUS_COMMITTED:
+ case Status.STATUS_NO_TRANSACTION:
+ break;
+ default:
+ ut.rollback();
+ }
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ // SecurityException, SystemException
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public double depositTwiceWithRollback(long id, double a1, double a2)
+ {
+ Account a;
+ beginTx();
+ try
+ {
+ a = em.find(Account.class, id);
+ // unsafe (nolock)
+ a.setBalance(a.getBalance() + a1);
+ em.flush();
+ commitTx();
+ }
+ finally
+ {
+ rollbackTxIfNeeded();
+ }
+
+ beginTx();
+ try
+ {
+ // unsafe
+ a.setBalance(a.getBalance() + a2);
+ em.flush();
+ }
+ finally
+ {
+ rollbackTx();
+ }
+ return a.getBalance();
+ }
+
+ /**
+ * Do the same, but then raw sql.
+ * @param id
+ * @param a1
+ * @param a2
+ */
+ public double withdrawTwiceWithRollback(long id, double a1, double a2)
+ {
+ try
+ {
+ Connection conn = ds.getConnection();
+ try
+ {
+ double balance;
+ PreparedStatement ps = conn.prepareStatement("SELECT balance FROM account WHERE id = ?");
+ try
+ {
+ ps.setLong(1, id);
+ ResultSet rs = ps.executeQuery();
+ if(!rs.next())
+ throw new IllegalArgumentException("can't find account " + id);
+ balance = rs.getDouble(1);
+ }
+ finally
+ {
+ ps.close();
+ }
+
+ ps = conn.prepareStatement("UPDATE account SET balance = ? WHERE id = ?");
+ try
+ {
+ beginTx();
+ try
+ {
+ balance -= a1;
+ ps.setDouble(1, balance);
+ ps.setLong(2, id);
+ int rows = ps.executeUpdate();
+ if(rows != 1)
+ throw new IllegalStateException("first update failed");
+
+ commitTx();
+ }
+ finally
+ {
+ rollbackTxIfNeeded();
+ }
+
+ beginTx();
+ try
+ {
+ balance -= a2;
+ ps.setDouble(1, balance);
+ ps.setLong(2, id);
+ int rows = ps.executeUpdate();
+ if(rows != 1)
+ throw new IllegalStateException("second update failed");
+ }
+ finally
+ {
+ rollbackTx();
+ }
+ }
+ finally
+ {
+ ps.close();
+ }
+ return balance;
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ catch(SQLException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Deleted: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/Account.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/Account.java 2008-12-03 07:56:10 UTC (rev 82000)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/Account.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.ejb3.test.ejbthree1028;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-
-/**
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
- at Entity
-public class Account
-{
- private long id;
- private double balance; // don't look, not financially save
-
- public double getBalance()
- {
- return balance;
- }
-
- @Id
- @GeneratedValue
- public long getId()
- {
- return id;
- }
-
- public void setBalance(double balance)
- {
- this.balance = balance;
- }
-
- public void setId(long id)
- {
- this.id = id;
- }
-}
Copied: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/Account.java (from rev 82036, projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/Account.java)
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/Account.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/Account.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.test.ejbthree1028;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Entity
+public class Account
+{
+ private long id;
+ private double balance; // don't look, not financially save
+
+ public double getBalance()
+ {
+ return balance;
+ }
+
+ @Id
+ @GeneratedValue
+ public long getId()
+ {
+ return id;
+ }
+
+ public void setBalance(double balance)
+ {
+ this.balance = balance;
+ }
+
+ public void setId(long id)
+ {
+ this.id = id;
+ }
+}
Copied: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/unit (from rev 82036, projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/unit)
Deleted: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/unit/LazyTransactionEnlistmentUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/unit/LazyTransactionEnlistmentUnitTestCase.java 2008-12-04 09:38:45 UTC (rev 82036)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/unit/LazyTransactionEnlistmentUnitTestCase.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -1,80 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.ejb3.test.ejbthree1028.unit;
-
-import junit.framework.Test;
-
-import org.jboss.ejb3.test.common.EJB3TestCase;
-import org.jboss.ejb3.test.ejbthree1028.ATM;
-
-/**
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class LazyTransactionEnlistmentUnitTestCase extends EJB3TestCase
-{
- public LazyTransactionEnlistmentUnitTestCase(String name)
- {
- super(name);
- }
-
- public static Test suite() throws Exception
- {
- return getDeploySetup(LazyTransactionEnlistmentUnitTestCase.class, "ejbthree1028.jar");
- }
-
- public void test1() throws Exception
- {
- ATM atm = lookup("ATMBean/remote", ATM.class);
- // if only
- long id = atm.createAccount(1000000);
- System.out.println("*** id " + id);
- double balance = atm.getBalance(id);
- System.out.println("*** balance " + balance);
- assertEquals(1000000, balance);
-
- balance = atm.depositTwiceWithRollback(id, 125000, 250000);
- System.out.println("*** balance " + balance);
- // the entity state itself won't be rolled back
- assertEquals(1375000, balance);
- balance = atm.getBalance(id);
- System.out.println("*** balance " + balance);
- assertEquals(1125000, balance);
- }
-
- public void testRawSQL() throws Exception
- {
- ATM atm = lookup("ATMBean/remote", ATM.class);
- // if only
- long id = atm.createAccount(1000000);
- System.out.println("*** id " + id);
- double balance = atm.getBalance(id);
- System.out.println("*** balance " + balance);
- assertEquals(1000000, balance);
-
- balance = atm.withdrawTwiceWithRollback(id, 125000, 250000);
- System.out.println("*** balance " + balance);
- balance = atm.getBalance(id);
- System.out.println("*** balance " + balance);
- assertEquals(875000, balance);
- }
-}
Copied: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/unit/LazyTransactionEnlistmentUnitTestCase.java (from rev 82032, projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/unit/LazyTransactionEnlistmentUnitTestCase.java)
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/unit/LazyTransactionEnlistmentUnitTestCase.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1028/unit/LazyTransactionEnlistmentUnitTestCase.java 2008-12-04 12:18:37 UTC (rev 82040)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.test.ejbthree1028.unit;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.common.EJB3TestCase;
+import org.jboss.ejb3.test.ejbthree1028.ATM;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class LazyTransactionEnlistmentUnitTestCase extends EJB3TestCase
+{
+ public LazyTransactionEnlistmentUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(LazyTransactionEnlistmentUnitTestCase.class, "ejbthree1028.jar");
+ }
+
+ public void test1() throws Exception
+ {
+ ATM atm = lookup("ATMBean/remote", ATM.class);
+ // if only
+ long id = atm.createAccount(1000000);
+ System.out.println("*** id " + id);
+ double balance = atm.getBalance(id);
+ System.out.println("*** balance " + balance);
+ assertEquals(1000000.0, balance);
+
+ balance = atm.depositTwiceWithRollback(id, 125000, 250000);
+ System.out.println("*** balance " + balance);
+ // the entity state itself won't be rolled back
+ assertEquals(1375000.0, balance);
+ balance = atm.getBalance(id);
+ System.out.println("*** balance " + balance);
+ assertEquals(1125000.0, balance);
+ }
+
+ public void testRawSQL() throws Exception
+ {
+ ATM atm = lookup("ATMBean/remote", ATM.class);
+ // if only
+ long id = atm.createAccount(1000000);
+ System.out.println("*** id " + id);
+ double balance = atm.getBalance(id);
+ System.out.println("*** balance " + balance);
+ assertEquals(1000000.0, balance);
+
+ balance = atm.withdrawTwiceWithRollback(id, 125000, 250000);
+ System.out.println("*** balance " + balance);
+ balance = atm.getBalance(id);
+ System.out.println("*** balance " + balance);
+ assertEquals(875000.0, balance);
+ }
+}
More information about the jboss-cvs-commits
mailing list