Hi,
As BeanProvider.InjectFields(this) does not work with static field, I would
like to suggest that we change the javadoc of the field
/**
* Allows to perform dependency injection for instances which aren't
managed by CDI
* <p/>
* Attention:<br/>
* * The resulting instance isn't managed by CDI, only non static fields
annotated with @Inject get initialized.*
*
* @param instance current instance
* @param <T> current type
* @return instance with injected fields (if possible - or null if the
given instance is null)
*/
@SuppressWarnings("unchecked")
public static <T> T injectFields(T instance)
Here is an example
public class BootStrap {
final private static Logger logger =
LoggerFactory.getLogger(BootStrap.class);
@Inject @CamelRouteCategory(Category.SIMPLE)
public static BootCamel bc;
public static void main(String[] args) throws Exception {
CdiContainer cc = CdiContainerLoader.getCdiContainer();
cc.boot();
cc.getContextControl().startContexts();
logger.info(">> CDI container started");
BootStrap bs = new BootStrap();
BeanProvider.injectFields(bs);
// Call init method to start camel route
bc.init(); // NPE is generated here
....
public class BootCamelFactory {
@Produces
@CamelRouteCategory(Category.SIMPLE)
public static BootCamel simple() throws Exception {
return (BootCamel) new SimpleCamelRoute();
}
Regards,
-----
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
--
View this message in context:
http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/BeanProvider-InjectFields-this-limitation-with-static-field-tp4652980.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at
Nabble.com.