[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-3262) Allow entity class component to be assigned stateless scope

Dan Allen (JIRA) jira-events at lists.jboss.org
Sun Aug 17 01:45:58 EDT 2008


    [ https://jira.jboss.org/jira/browse/JBSEAM-3262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12425364#action_12425364 ] 

Dan Allen commented on JBSEAM-3262:
-----------------------------------

Alright! Now we are getting somewhere! Thanks for the great insight Pete.

What wasn't clear to me before, but is clear now, is that the idea of stateless scope is have something that is indeed stateless, but not necessarily transient (something like a pool of objects). In that sense, we would need the notion of a dependent scope to accomplish what I am trying to do.

Okay, so why am I creating a component? Well, because its basically a workaround for not being able to create an inner-bean like in Spring. I have to create a top level object that is resolvable via a value expression so that it can be wired to another component when that component is created. The perfect use case is Home's newInstance property.

So why not a factory? Again, it's certainly possible to use a stateless factory for this, but only if you define the factory method in Java. The component descriptor doesn't support building up a prototype object to seed a factory. I basically found a way to make it happen.

Is it sort of hackish? Yes. Should it be possible? It would be nice. Again, I am going to say that I like my idea and frankly, I don't care if it's consider hackish because the idea works for me. For now, though, I have to live with using event scope and purging that instance from event scope as soon as it is put there (thus emulating what I call unscoped).

> Allow entity class component to be assigned stateless scope
> -----------------------------------------------------------
>
>                 Key: JBSEAM-3262
>                 URL: https://jira.jboss.org/jira/browse/JBSEAM-3262
>             Project: Seam
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.3.CR1, 2.1.0.A1
>            Reporter: Dan Allen
>            Assignee: Pete Muir
>            Priority: Minor
>             Fix For: 2.0.3.GA, 2.1.0.GA
>
>         Attachments: JBSEAM-3262-branch20.txt, JBSEAM-3262-trunk.txt
>
>   Original Estimate: 5 minutes
>  Remaining Estimate: 5 minutes
>
> There is no reason for not allowing an entity class component to be assigned to the stateless context like JavaBean and stateless session bean components. In fact, you could argue that there is no difference between a JavaBean and an entity class based on the fact that they are both vanilla Java classes.
> There is a perfect use case for this feature that comes right from the heart of Seam. When using the Home component, it is perfectly natural to create a component role for an entity class that is wired to the newInstance property to be used as a prototype. For instance, here is an example:
> <component name="roundPrototype" class="org.open18.model.Round" scope="stateless">
>     <property name="golfer">#{currentGolfer}</property>
>     <property name="date">#{currentDate}</property>
> </component>
> <framework:entity-home name="roundHome" class="org.open18.action.RoundHome" new-instance="#{roundPrototype}"/>
> You don't want the roundPrototype to be stored in a scope since it is only used internally to produce the instance managed by the roundHome component. However, with this configuration, Seam throws an exception at startup.

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

        



More information about the seam-issues mailing list