3 Replies Latest reply on Mar 18, 2009 8:20 AM by Ales Justin

    Programatically create a Inject fromContext

    jaikiran pai Master

      What is the API to create an @Inject which is equivalent to this:

      public class MyBean
       @Inject (dependentState="DESCRIBED", fromContext = FromContext.CONTEXT)
       KernelControllerContext context;

      I was able to get a minimal @Inject working using this API:

      public class MyBean
       @Inject (dependentState = "DESCRIBED")
       OtherBean otherBean;

      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(someName, someClass.getClass().getName());
      // Create @Inject
      ValueMetaData inject = builder.createInject(weDependOnThisMCBeanName, null, null, ControllerState.DESCRIBED);
      // add this @Inject to our MC bean
      builder.addPropertyMetaData("otherBean", inject);

      I couldn't find any API where i can pass more information for creating the @Inject "fromContext".