[weld-issues] [JBoss JIRA] Commented: (WELD-311) Producer field behavior differs from producer method

Pete Muir (JIRA) jira-events at lists.jboss.org
Sat Sep 18 11:40:28 EDT 2010


    [ https://jira.jboss.org/browse/WELD-311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12551699#action_12551699 ] 

Pete Muir commented on WELD-311:
--------------------------------

I mean, yes it was correct. The producer method creates a new object each time it is called (once per request). The producer field creates a new object once per instantiation (once per session). Therefore, you would expect the field across requests (as the reference is session scoped).

> Producer field behavior differs from producer method
> ----------------------------------------------------
>
>                 Key: WELD-311
>                 URL: https://jira.jboss.org/browse/WELD-311
>             Project: Weld
>          Issue Type: Bug
>          Components: Producers (Methods, Fields and Disposers)
>    Affects Versions: 1.0.0.CR1
>         Environment: Ubuntu 9.10, Java 6.
>            Reporter: alberto Gori
>            Assignee: Pete Muir
>            Priority: Critical
>             Fix For: 1.0.1.CR1
>
>
> This producer field inject a Temp object into the request scope, corretly.
> @Named @SessionScoped
> public class HelloWorld implements Serializable {
> 	
> 	@Produces @RequestScoped @TenTemp 
> 	public Temp getTemp() {
> 		return new Temp(10);
> 	}
> }	
> The same producer written as a field create a session scoped object (note that the main bean is session scoped too) instead of request scoped.
> @Named @SessionScoped
> public class HelloWorld implements Serializable {
> 	
> 	@Produces @RequestScoped @TenTemp Temp t = new Temp(10);
> }	

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the weld-issues mailing list