-
1. Re: Using XML Bean Config to set default conversation timeout
swd847 Mar 31, 2010 3:41 AM (in response to dan.j.allen)I just investigated this, built in beans such as conversation are not going through BeforeBeanDiscovery and ProcessInjectionTarget, so the XML extension can't veto the old implementation and install it's new one.
-
2. Re: Using XML Bean Config to set default conversation timeout
swd847 Mar 31, 2010 3:44 AM (in response to dan.j.allen)Also you should use the <extends> tag to set values. <override> would clear all annotations from the base class, extends merges them with the annotations on the XML.
-
3. Re: Using XML Bean Config to set default conversation timeout
dan.j.allen Mar 31, 2010 4:48 AM (in response to dan.j.allen)Just to keep everyone up to speed, the issue is that XML Bean Config does not yet support interface configuration. I'm creating a JIRA to track the progress. For now, if you are configuring bean properties, it needs to be a real class.
-
4. Re: Using XML Bean Config to set default conversation timeout
dan.j.allen Mar 31, 2010 4:57 AM (in response to dan.j.allen)To make things clearer, Stuart and I discussed renaming the <extends> tag to <specializes> (or <specialises> for the Australian fans), since this term matches much more closely with the way that bean replacement is done in Java using inheritance and the @Specializes annotation). The semantics will be slightly different, but that's to be expected given that we are talking about XML-based configuration.
proposed:
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="urn:java:seam:core" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> <s:Conversation> <s:specializes/> <s:timeout>5000</s:timeout> </s:Conversation> </beans>
We also discussed that explicitly requiring <specializes> or <override> makes it unmistakably clear that you are replacing (in a sense wrapping) a bean rather than introducing a new one. This was a frequent source of confusion in Seam 2, so we want to fix that experience.
-
6. Re: Using XML Bean Config to set default conversation timeout
swd847 Mar 31, 2010 5:29 AM (in response to dan.j.allen)Should it also be <overrides> rather than <override>?
-
7. Re: Using XML Bean Config to set default conversation timeout
dan.j.allen Mar 31, 2010 5:35 AM (in response to dan.j.allen)
Stuart Douglas wrote on Mar 31, 2010 05:29:
Should it also be <overrides> rather than <override>?Yes, let's follow the pattern of using active verbs. Good plan.
-
8. Re: Using XML Bean Config to set default conversation timeout
swd847 Mar 31, 2010 6:16 AM (in response to dan.j.allen)The tag names have changed in trunk
-
9. Re: Using XML Bean Config to set default conversation timeout
nickarls Mar 31, 2010 8:31 AM (in response to dan.j.allen)I'm not that familiar with the XML init but will it prevent the initializer in ConversationImpl
@Inject public void init(@ConversationInactivityTimeout long timeout) { this.timeout = timeout; _transient = true; }
from running over your settings?
-
10. Re: Using XML Bean Config to set default conversation timeout
swd847 Apr 1, 2010 1:42 AM (in response to dan.j.allen)That will run all over the settings.
I am not sure if I should set the field values before injection/initalizer methods or before the PostConstruct method is called (or both, just for good measure).
Currently they are set before injection, which means they are available to the initalizer methods, however conversely init method can walk all over them (which will probably be a pretty common case).
Internally setting field values is implemented as a wrapper around InjectionTarget, so there are 4 places I can put it:
- before inect()
- after inject()
- before PostConstruct()
- after PostConstruct()
Does anyone have any ideas as to what the correct behavior should be here?
-
11. Re: Using XML Bean Config to set default conversation timeout
dan.j.allen Apr 1, 2010 4:22 AM (in response to dan.j.allen)
Stuart Douglas wrote on Apr 01, 2010 01:42:
That will run all over the settings.I agree that the initializer method of the ConversationImpl in Weld should at least be honoring an already assigned value.
I am not sure if I should set the field values before injection/initalizer methods or before the PostConstruct method is called (or both, just for good measure).What's interesting is that in Seam 2, there was only one post construct method for a bean, whereas in CDI we now have initializers, so there is another
point
in the bean initialization lifecycle.The benefit that CDI initializers have over managed bean @PostConstruct methods is that initializers can accept injected parameters. Therefore, I see developers choosing initializers more often than @PostConstruct (and other times using them interchangeably).
Currently they are set before injection, which means they are available to the initalizer methods, however conversely init method can walk all over them (which will probably be a pretty common case).
Internally setting field values is implemented as a wrapper around InjectionTarget, so there are 4 places I can put it:- before inect()
- after inject()
- before PostConstruct()
- after PostConstruct()
Does anyone have any ideas as to what the correct behavior should be here?Since the strategy in Seam 2 was to make sure initial field values were assigned before the post construct method was called, I think it is safe to say that we should set the initial field values before initializers as well. Users will likely expect that behavior.
Therefore, I'm going to have to go with before inject, or for that matter, any time during inject but before the initializers are called. I'd definitely stand behind this decision. Initial field values can then be
tuned
in the initializer or post construct methods.Setting the field values after the initializer but before post construct is just going to be confusing.
-
12. Re: Using XML Bean Config to set default conversation timeout
swd847 Apr 1, 2010 4:37 AM (in response to dan.j.allen)That is the way it is implemented now. In this case it does not really matter, as I can't touch the conversation object anyway.
-
13. Re: Using XML Bean Config to set default conversation timeout
nickarls Apr 1, 2010 9:15 AM (in response to dan.j.allen)I changed init() so it only applies the param if timeout is currently unset (0). Since it's a long and not a Long I can only hope that noone wants to configure it to 0 in XML ;-)