-
1. Re: Can I write a method producer method without knowing the type until runtime? (framework for making @Produces on annotated types)
jharting Aug 19, 2012 4:22 PM (in response to sboscarine)Steven,
take a look at the Bean interface - which your framework should implement and then register with the container. The interface contains metadata about the bean as well as callbacks that are called when an instance of your bean is requested / being destroyed.
-
2. Re: Can I write a method producer method without knowing the type until runtime? (framework for making @Produces on annotated types)
starksm64 Aug 21, 2012 2:46 PM (in response to sboscarine)1 of 1 people found this helpfulI mocked up a related solution as I'm trying to figure out how deeply one needs to integrate into Weld to achieve various customizations. See the approach here:
https://community.jboss.org/blogs/scott.stark/2012/08/21/a-generic-producer-method
-
3. Re: Can I write a method producer method without knowing the type until runtime? (framework for making @Produces on annotated types)
sboscarine Aug 27, 2012 3:13 PM (in response to starksm64)Hello Scott.
Thank you for writing such a detailed answer. I have been mulling it over for days now.
My concerns is that in order to inject, they need to do a lot of extra steps, like in config user.:
public class ConfigUser { @Inject @ConfigType private IStoreSettings<MyDataStoreSettings> settings; @Inject @ConfigType private IStoreSettings<AnotherDataStoreSettings> settings2;
If they want to test ConfigUser, they need to know about IStoreSettings. If possible, I'd like for this to be a very invisible "automagical" framework that no one will know about unless they are writing config bindings. I assumed I could arrange it so that the consuming code is indistinguishable from regular CDI code.
I did get your classes working, but I think I may be asking the wrong question. What I'd like is to have a user run:
public class MyConsumer{ @Inject private MyDataStoreSettings settings;
...and have the contents modified by my code. In my case, properties will be looked up from various sources and injected into the bean. I am still thinking like a Spring programmer and forgetting that CDI doesn't require any magic to inject. I am happy w/ letting CDI construct the bean in a default manner. I just want to transform it after contruction.
I'll repost, but I think what I should have asked is:
How do I loop through all the beans registered to CDI and transform them? Is there an interceptor binding to run around object creation? I posted the question at https://community.jboss.org/thread/204596?tstart=0Thanks for your help!!!
Steven