the lifecycle is the same for producer fields, producer methods or standard beans of a given scope.
Just think of it as 'factory rule'. In one case it's a factory by creating the field, calling the producer method or newInstance() on the bean type. The result is the same... LieGrue, strub ----- Original Message ----- > From: Romain Manni-Bucau <[email protected]> > To: [email protected] > Cc: > Sent: Wednesday, May 9, 2012 10:14 AM > Subject: Re: CDI: disposal methods for producer fields > > Not sure about the meaning if your field produces it means the lifecycle is > not managed by you so no need to release it IMO. > Le 9 mai 2012 08:59, "Jean-Louis MONTEIRO" <[email protected]> > a écrit : > >> Thanks for reporting. IMO, that is more a OWB issue. May be Mark could >> help. >> >> Jean-Louis >> >> 2012/5/9 Daniel Siwiec <[email protected]> >> >> > From what I see, we're currently not supporting disposal methods > for >> > producer fields, only for producer methods. >> > >> > The CDI specification does not clearly say if this should be supported > or >> > not (see 3.3.6 in CDI spec: >> > http://download.oracle.com/otndocs/jcp/web_beans-1.0-fr-oth-JSpec/) >> > I found that Jboss had the same discussion ( >> > https://issues.jboss.org/browse/CDI-145?_sscc=t) and it seems that > they >> > decided to include this feature. >> > >> > What is your opinion on it? >> > >> > Currently, when I try to define a disposal method with a producer > field, >> > this is what I get: >> > >> > SEVERE - CDI Beans module deployment failed >> > javax.enterprise.inject.UnsatisfiedResolutionException: Producer > method >> > component of the disposal method : closeLogHandleris not found in > class: >> > org.superbiz.cdi.produces.disposes.LogFactory >> > null >> > at >> > >> > >> > org.apache.webbeans.util.InjectionExceptionUtils.throwUnsatisfiedResolutionException(InjectionExceptionUtils.java:71) >> > at >> > >> > >> > org.apache.webbeans.config.DefinitionUtil.createDisposalMethods(DefinitionUtil.java:861) >> > at >> > >> > >> > org.apache.webbeans.config.DefinitionUtil.defineDisposalMethods(DefinitionUtil.java:840) >> > at >> > >> > >> > org.apache.webbeans.config.DefinitionUtil.defineDisposalMethods(DefinitionUtil.java:831) >> > at >> > >> > >> > org.apache.webbeans.component.creation.AbstractInjectedTargetBeanCreator.defineDisposalMethods(AbstractInjectedTargetBeanCreator.java:59) >> > at >> > >> > >> > org.apache.webbeans.util.WebBeansUtil.defineManagedBean(WebBeansUtil.java:2711) >> > at >> > >> > >> > org.apache.openejb.cdi.BeansDeployer.defineManagedBean(BeansDeployer.java:546) >> > at >> > >> > >> > org.apache.openejb.cdi.OpenEJBLifecycle.deployManagedBeans(OpenEJBLifecycle.java:384) >> > at >> > >> > >> > org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:227) >> > at >> > >> > >> > org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:108) >> > at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:50) >> > at >> > >> > >> > org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:765) >> > at >> > >> > >> > org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:508) >> > at >> > >> > >> > org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:306) >> > at >> > >> javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56) >> > at >> > >> javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:43) >> > at >> org.superbiz.cdi.produces.disposes.LoggerTest.setUp(LoggerTest.java:40) >> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> > at >> > >> > >> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) >> > at >> > >> > >> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >> > at java.lang.reflect.Method.invoke(Method.java:601) >> > at >> > >> > >> > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) >> > at >> > >> > >> > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) >> > at >> > >> > >> > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) >> > at >> > >> > >> > org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) >> > at >> > >> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) >> > at >> > >> > >> > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) >> > at >> > >> > >> > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) >> > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) >> > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) >> > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) >> > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) >> > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) >> > at org.junit.runners.ParentRunner.run(ParentRunner.java:236) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) >> > INFO - Undeploying app: >> > >> /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-disposes >> > org.apache.openejb.OpenEjbContainer$AssembleApplicationException: >> > org.apache.openejb.OpenEJBException: Creating application failed: >> > >> > >> > /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-disposes: >> > couldn't start owb context >> > at >> > >> > >> > org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:310) >> > at >> > >> javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56) >> > at >> > >> javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:43) >> > at >> org.superbiz.cdi.produces.disposes.LoggerTest.setUp(LoggerTest.java:40) >> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> > at >> > >> > >> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) >> > at >> > >> > >> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >> > at java.lang.reflect.Method.invoke(Method.java:601) >> > at >> > >> > >> > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) >> > at >> > >> > >> > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) >> > at >> > >> > >> > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) >> > at >> > >> > >> > org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) >> > at >> > >> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) >> > at >> > >> > >> > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) >> > at >> > >> > >> > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) >> > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) >> > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) >> > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) >> > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) >> > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) >> > at org.junit.runners.ParentRunner.run(ParentRunner.java:236) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) >> > Caused by: org.apache.openejb.OpenEJBException: Creating application >> > failed: >> > >> > >> > /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-disposes: >> > couldn't start owb context >> > at >> > >> > >> > org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:911) >> > at >> > >> > >> > org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:508) >> > at >> > >> > >> > org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:306) >> > ... 26 more >> > Caused by: org.apache.openejb.OpenEJBRuntimeException: couldn't > start owb >> > context >> > at >> > >> > >> > org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:110) >> > at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:50) >> > at >> > >> > >> > org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:765) >> > ... 28 more >> > Caused by: org.apache.openejb.OpenEJBRuntimeException: >> > javax.enterprise.inject.UnsatisfiedResolutionException: Producer > method >> > component of the disposal method : closeLogHandleris not found in > class: >> > org.superbiz.cdi.produces.disposes.LogFactory >> > null >> > at >> > >> > >> > org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:325) >> > at >> > >> > >> > org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:108) >> > ... 30 more >> > Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: >> Producer >> > method component of the disposal method : closeLogHandleris not found > in >> > class: org.superbiz.cdi.produces.disposes.LogFactory >> > null >> > at >> > >> > >> > org.apache.webbeans.util.InjectionExceptionUtils.throwUnsatisfiedResolutionException(InjectionExceptionUtils.java:71) >> > at >> > >> > >> > org.apache.webbeans.config.DefinitionUtil.createDisposalMethods(DefinitionUtil.java:861) >> > at >> > >> > >> > org.apache.webbeans.config.DefinitionUtil.defineDisposalMethods(DefinitionUtil.java:840) >> > at >> > >> > >> > org.apache.webbeans.config.DefinitionUtil.defineDisposalMethods(DefinitionUtil.java:831) >> > at >> > >> > >> > org.apache.webbeans.component.creation.AbstractInjectedTargetBeanCreator.defineDisposalMethods(AbstractInjectedTargetBeanCreator.java:59) >> > at >> > >> > >> > org.apache.webbeans.util.WebBeansUtil.defineManagedBean(WebBeansUtil.java:2711) >> > at >> > >> > >> > org.apache.openejb.cdi.BeansDeployer.defineManagedBean(BeansDeployer.java:546) >> > at >> > >> > >> > org.apache.openejb.cdi.OpenEJBLifecycle.deployManagedBeans(OpenEJBLifecycle.java:384) >> > at >> > >> > >> > org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:227) >> > ... 31 more >> > java.lang.NullPointerException >> > at >> > > org.superbiz.cdi.produces.disposes.LoggerTest.cleanUp(LoggerTest.java:50) >> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> > at >> > >> > >> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) >> > at >> > >> > >> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >> > at java.lang.reflect.Method.invoke(Method.java:601) >> > at >> > >> > >> > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) >> > at >> > >> > >> > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) >> > at >> > >> > >> > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) >> > at >> > >> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:37) >> > at >> > >> > >> > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) >> > at >> > >> > >> > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) >> > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) >> > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) >> > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) >> > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) >> > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) >> > at org.junit.runners.ParentRunner.run(ParentRunner.java:236) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) >> > at >> > >> > >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) >> > >> > Thanks, >> > Daniel >> > >> >
