[weld-issues] [JBoss JIRA] Assigned: (WELD-13) Use the builder pattern to create Bean objects
Stuart Douglas (JIRA)
jira-events at lists.jboss.org
Mon Jan 3 18:54:18 EST 2011
[ https://issues.jboss.org/browse/WELD-13?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stuart Douglas reassigned WELD-13:
----------------------------------
Assignee: Stuart Douglas
> Use the builder pattern to create Bean objects
> ----------------------------------------------
>
> Key: WELD-13
> URL: https://issues.jboss.org/browse/WELD-13
> Project: Weld
> Issue Type: Feature Request
> Components: Class Beans (Managed and Session)
> Reporter: Pete Muir
> Assignee: Stuart Douglas
> Priority: Critical
> Fix For: 1.2.0.Beta1
>
>
> Currently we create the Bean objects using a two phase initialization, partly via the constructor, and partly via an initialize() method, this allows us to create the beans, attach them to the bean manager and then do further work once all bean objects exist. This has a number of problems:
> 1) objects are not fully immutable which means we rely on developers ability to keep them effectively immutable
> 2) the objects are a mess of init methods and getters
> 3) creation logic is convoluted
> It would be far better to create builders (or factories) that can create the beans as needed, this will cleanly split out the creation logic from the bean object, and allow us to create fully immutable objects, thus making it easier to verify the thread-safety of the code.
> A side effect of this will be that we can't use two-phase initialization two set up certain stuff after all beans are present. To overcome this we will need to order the bean creation so that beans required by other beans are created first and thus can be attached as needed.
> The rules I am aware of:
> * producer methods and fields should be created after the class bean that declares them as they need to know that bean in order to be instantiated
> * specialized beans need to be created in the order least specialized to most specialized as a more specialized bean needs to read the metadata of the less specialized bean
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the weld-issues
mailing list