deltaspike-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Moulliard <>
Subject BeanProvider.InjectFields(this) limitation with static field
Date Wed, 04 Jul 2012 07:38:59 GMT

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)
    public static <T> T injectFields(T instance) 

Here is an example

public class BootStrap {

    final private static Logger logger =

    @Inject @CamelRouteCategory(Category.SIMPLE)
    public static BootCamel bc;

    public static void main(String[] args) throws Exception {

        CdiContainer cc = CdiContainerLoader.getCdiContainer();
        cc.getContextControl().startContexts();">> CDI container started");

        BootStrap bs = new BootStrap();

        // Call init method to start camel route
        bc.init(); // NPE is generated here

public class BootCamelFactory {

    public static BootCamel simple() throws Exception {
        return (BootCamel) new SimpleCamelRoute();


Apache Committer / Sr. Pr. Consultant at
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog :
View this message in context:
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at

View raw message