Author: pete.muir(a)jboss.org
Date: 2009-07-25 11:45:57 -0400 (Sat, 25 Jul 2009)
New Revision: 3217
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/DependentContextEjbTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/House.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/HouseLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Room.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/RoomLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Table.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/TableLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/DeploymentTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/addDefinitionError/AddDefinitionErrorTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/addDeploymentProblem/AddDeploymentProblemTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/beanDiscoveryMethodThrowsException/BeforeBeanDiscoveryThrowsExceptionTest.java
Log:
implmenet dependent object destruction for EJBs
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-07-25
14:38:27 UTC (rev 3216)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-07-25
15:45:57 UTC (rev 3217)
@@ -255,6 +255,7 @@
throw new IllegalArgumentException("Cannot destroy session bean instance
not created by the container");
}
EnterpriseBeanInstance enterpiseBeanInstance = (EnterpriseBeanInstance) instance;
+
if (enterpiseBeanInstance.isDestroyed())
{
return;
@@ -263,6 +264,7 @@
{
enterpiseBeanInstance.destroy(this, creationalContext);
}
+ creationalContext.release();
}
/**
@@ -300,20 +302,8 @@
return buffer.toString();
}
- public void postConstruct(T instance)
+ public void postConstruct(T instance, CreationalContext<T> creationalContext)
{
- // TODO Why do we need a special CC for Enterprise beans?
- CreationalContext<T> creationalContext = new CreationalContext<T>()
- {
-
- public void push(T incompleteInstance) {};
-
- public void release()
- {
- // TODO implement this
- }
-
- };
injectBoundFields(instance, creationalContext);
callInitializers(instance, creationalContext);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java 2009-07-25
14:38:27 UTC (rev 3216)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java 2009-07-25
15:45:57 UTC (rev 3217)
@@ -61,7 +61,7 @@
if (creationalContext != null)
{
T instance = contextual.create(creationalContext);
- if (creationalContext instanceof CreationalContextImpl)
+ if (creationalContext instanceof CreationalContextImpl<?>)
{
CreationalContextImpl<T> creationalContextImpl =
(CreationalContextImpl<T>) creationalContext;
ContexutalInstance<T> beanInstance = new
BeanInstanceImpl<T>(contextual, instance, creationalContext);
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java 2009-07-25
14:38:27 UTC (rev 3216)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java 2009-07-25
15:45:57 UTC (rev 3217)
@@ -61,7 +61,7 @@
{
Object target = invocationContext.getTarget();
initBean(target.getClass());
- bean.postConstruct(target);
+ bean.postConstruct(target, creationalContext);
invocationContext.proceed();
}
@@ -107,6 +107,7 @@
{
this.bean = (EnterpriseBean<Object>)
CurrentManager.rootManager().getNewEnterpriseBeanMap().get(beanClass);
this.contextual = false;
+ this.creationalContext =
CurrentManager.rootManager().createCreationalContext(bean);
}
this.beanId =
CurrentManager.rootManager().getServices().get(ContextualIdStore.class).getId(this.bean);
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/DependentContextEjbTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/DependentContextEjbTest.java 2009-07-25
14:38:27 UTC (rev 3216)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/DependentContextEjbTest.java 2009-07-25
15:45:57 UTC (rev 3217)
@@ -37,52 +37,35 @@
public class DependentContextEjbTest extends AbstractJSR299Test
{
- @Test(groups = { "contexts", "ejb3", "integration",
"ri-broken"})
+ @Test(groups = { "contexts", "ejb3", "integration"})
@SpecAssertion(section = "6.4.2", id = "aaaa")
public void testDestroyingEjbDestroysDependents() throws Exception
{
- new RunInDependentContext()
- {
-
- @Override
- protected void execute() throws Exception
- {
- assert getBeans(HouseLocal.class).size() == 1;
- Bean<HouseLocal> bean = getBeans(HouseLocal.class).iterator().next();
- CreationalContext<HouseLocal> creationalContext =
getCurrentManager().createCreationalContext(bean);
- HouseLocal instance = bean.create(creationalContext);
- Room.destroyed = false;
- Table.destroyed = false;
- bean.destroy(instance, creationalContext);
- assert Room.destroyed;
- assert Table.destroyed;
- }
-
- }.run();
+ assert getBeans(HouseLocal.class).size() == 1;
+ Bean<HouseLocal> bean = getBeans(HouseLocal.class).iterator().next();
+ CreationalContext<HouseLocal> creationalContext =
getCurrentManager().createCreationalContext(bean);
+ HouseLocal instance = bean.create(creationalContext);
+ instance.open();
+ Room.destroyed = false;
+ Table.destroyed = false;
+ bean.destroy(instance, creationalContext);
+ assert Room.destroyed;
+ assert Table.destroyed;
}
- @Test(groups = { "contexts", "ejb3",
"integration","ri-broken", "broken" })
+ @Test(groups = { "contexts", "ejb3", "integration"})
@SpecAssertion(section = "6.4.2", id = "aaaa")
public void testDestroyingEjbDestroysDependentSimples() throws Exception
{
- new RunInDependentContext()
- {
+ assert getBeans(FarmLocal.class).size() == 1;
+ Bean<FarmLocal> farmBean = getBeans(FarmLocal.class).iterator().next();
+ CreationalContext<FarmLocal> creationalContext =
getCurrentManager().createCreationalContext(farmBean);
+ FarmLocal farm = farmBean.create(creationalContext);
+ Horse.destroyed = false;
+ Stable.destroyed = false;
+ farmBean.destroy(farm, creationalContext);
+ assert Horse.destroyed;
+ assert Stable.destroyed;
+ }
- @Override
- protected void execute() throws Exception
- {
- assert getBeans(FarmLocal.class).size() == 1;
- Bean<FarmLocal> farmBean =
getBeans(FarmLocal.class).iterator().next();
- CreationalContext<FarmLocal> creationalContext =
getCurrentManager().createCreationalContext(farmBean);
- FarmLocal farm = farmBean.create(creationalContext);
- Horse.destroyed = false;
- Stable.destroyed = false;
- farmBean.destroy(farm, creationalContext);
- assert Horse.destroyed;
- assert Stable.destroyed;
- }
-
- }.run();
- }
-
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/House.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/House.java 2009-07-25
14:38:27 UTC (rev 3216)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/House.java 2009-07-25
15:45:57 UTC (rev 3217)
@@ -10,6 +10,9 @@
@Current RoomLocal room;
- public void open() {};
+ public RoomLocal open()
+ {
+ return room;
+ };
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/HouseLocal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/HouseLocal.java 2009-07-25
14:38:27 UTC (rev 3216)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/HouseLocal.java 2009-07-25
15:45:57 UTC (rev 3217)
@@ -6,6 +6,6 @@
public interface HouseLocal
{
- public void open();
+ public RoomLocal open();
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Room.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Room.java 2009-07-25
14:38:27 UTC (rev 3216)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Room.java 2009-07-25
15:45:57 UTC (rev 3217)
@@ -10,6 +10,11 @@
@Current TableLocal table;
+ public TableLocal getTable()
+ {
+ return table;
+ }
+
public static boolean destroyed;
@PreDestroy
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/RoomLocal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/RoomLocal.java 2009-07-25
14:38:27 UTC (rev 3216)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/RoomLocal.java 2009-07-25
15:45:57 UTC (rev 3217)
@@ -6,4 +6,6 @@
public interface RoomLocal
{
+ public TableLocal getTable();
+
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Table.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Table.java 2009-07-25
14:38:27 UTC (rev 3216)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Table.java 2009-07-25
15:45:57 UTC (rev 3217)
@@ -15,4 +15,9 @@
destroyed = true;
}
+ public void lay()
+ {
+
+ }
+
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/TableLocal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/TableLocal.java 2009-07-25
14:38:27 UTC (rev 3216)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/TableLocal.java 2009-07-25
15:45:57 UTC (rev 3217)
@@ -6,4 +6,6 @@
public interface TableLocal
{
+ public void lay();
+
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/DeploymentTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/DeploymentTest.java 2009-07-25
14:38:27 UTC (rev 3216)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/DeploymentTest.java 2009-07-25
15:45:57 UTC (rev 3217)
@@ -31,6 +31,8 @@
* @author David Allen
*/
@Artifact
+// TODO Add extension stuff
+@Test(groups="broken")
public class DeploymentTest extends AbstractJSR299Test
{
@Test
@@ -56,15 +58,18 @@
assert ManagerObserver.isRequestContextActive();
}
- @Test(groups = { "ri-broken" })
+ @Test(groups = { "ri-broken", "broken" })
@SpecAssertions({
@SpecAssertion(section = "11.1", id = "f")
})
public void testOnlyEnabledBeansDeployed()
{
assert !getBeans(User.class).isEmpty();
+ // I have no idea how this bean is supposed to be disabled PLM
assert getBeans(DisabledBean.class).isEmpty();
+ // Why is this interceptor not a bean? PLM
assert getBeans(Interceptor1.class).isEmpty();
+ // Why is this decorator not a bean? PLM
assert getBeans(DataAccessAuthorizationDecorator.class).isEmpty();
}
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/addDefinitionError/AddDefinitionErrorTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/addDefinitionError/AddDefinitionErrorTest.java 2009-07-25
14:38:27 UTC (rev 3216)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/addDefinitionError/AddDefinitionErrorTest.java 2009-07-25
15:45:57 UTC (rev 3217)
@@ -29,7 +29,7 @@
public class AddDefinitionErrorTest extends AbstractJSR299Test
{
@Test(groups="incontainer-ri-broken")
- //TODO This test is not working in container due to exceptions being unwound on the
server
+ // Not working, needs JBAS-7047
@SpecAssertion(section = "11.5.2", id = "ca")
public void testObserverDefinitionErrorTreatedAsDefinitionError()
{
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/addDeploymentProblem/AddDeploymentProblemTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/addDeploymentProblem/AddDeploymentProblemTest.java 2009-07-25
14:38:27 UTC (rev 3216)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/addDeploymentProblem/AddDeploymentProblemTest.java 2009-07-25
15:45:57 UTC (rev 3217)
@@ -38,7 +38,9 @@
@ExpectedDeploymentException(DeploymentError.class)
public class AddDeploymentProblemTest extends AbstractJSR299Test
{
- @Test(groups="incontainer-ri-broken")
+ @Test(groups={"broken", "incontainer-ri-broken"})
+ // TODO Needs Extension stuff adding
+ // Not working, needs JBAS-7047
@SpecAssertion(section = "11.5.3", id = "b")
public void testObserverDeploymentProblemTreatedAsDeploymentError()
{
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/beanDiscoveryMethodThrowsException/BeforeBeanDiscoveryThrowsExceptionTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/beanDiscoveryMethodThrowsException/BeforeBeanDiscoveryThrowsExceptionTest.java 2009-07-25
14:38:27 UTC (rev 3216)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/beanDiscoveryMethodThrowsException/BeforeBeanDiscoveryThrowsExceptionTest.java 2009-07-25
15:45:57 UTC (rev 3217)
@@ -42,6 +42,7 @@
{
@Test(groups="incontainer-ri-broken")
+ // Not working, needs JBAS-7047
@SpecAssertion(section="11.5.1", id="ag")
public void testThrowsException()
{