-
1. Re: Passing properties via components.xml
junkie Mar 12, 2008 8:30 PM (in response to tomstrummer.tomstrummer.gmail.com)
I want to externalize some configurationIf you run inside an appserver then injections via ejb-jar.xml should be used.
-
2. Re: Passing properties via components.xml
tomstrummer.tomstrummer.gmail.com Mar 12, 2008 8:59 PM (in response to tomstrummer.tomstrummer.gmail.com)Thanks for the response. Can you give an example?
-
3. Re: Passing properties via components.xml
luke.maurer Mar 12, 2008 9:45 PM (in response to tomstrummer.tomstrummer.gmail.com)
Tom Nichols wrote on Mar 12, 2008 08:23 PM:
I was hoping Seam would auto-create based on the Name annotation and thenmerge
the configuration from components.xml given the matching name. However this doesn't seem to work. Do I have to choose either annotations or XML configuration?Oh, heck no - what do you think this is, Hibernate? *ducks* >:-D
Seriously though, I've successfully followed section 4.2 of the manual before; so long as your component has a setter method for the property (in your case, setRequestURL(String url)), it should work precisely as you describe. It has to be a method, though (not just a field) - have you got one?
(OTOH, I'd like to know how Thomas's ejb-jar.xml idea would work too ...)
-
4. Re: Passing properties via components.xml
tomstrummer.tomstrummer.gmail.com Mar 14, 2008 2:39 PM (in response to tomstrummer.tomstrummer.gmail.com)
Luke Maurer wrote on Mar 12, 2008 09:45 PM:
Seriously though, I've successfully followed section 4.2 of the manual before; so long as your component has a setter method for the property (in your case, setRequestURL(String url)), it should work precisely as you describe. It has to be a method, though (not just a field) - have you got one?Yes, weatherBean has a setRequestURL(String) method.
Ok, it seems like it is working now, I'm not sure why I wasn't seeing the desired behavior before... I went through section 4.2 several times and there are only a couple examples of a <component> definition without a class attribute. So it was a bit ambiguous. There's no real example of combining both annotations and XML definition.
Conversely, if I define a component in components.xml, can that class use annotations like @Logger?
Thanks.
-
5. Re: Passing properties via components.xml
luke.maurer Mar 18, 2008 2:56 AM (in response to tomstrummer.tomstrummer.gmail.com)AFAICT, there isn't a separate processing engine in Seam for annotations vs. XML (as there is in Hibernate, where annotations and XML don't (yet) play as nicely together). components.xml just augments the annotations and externalizes properties. So a component without a @Name should still have any annotations like @In, @Out, @Logger, @DataModel, etc. work just fine.
-
6. Re: Passing properties via components.xml
tomstrummer.tomstrummer.gmail.com Mar 18, 2008 12:45 PM (in response to tomstrummer.tomstrummer.gmail.com)Grrr-eat. That's good to hear. Thanks for the clarification Luke.