• Icon: Feature Request Feature Request
    • Resolution: Obsolete
    • Icon: Major Major
    • None
    • None
    • Contexts
    • None

      I would like to activate a set of beans at application start-time. Currently I can use Programmatic lookup in CDI for dynamically injecting the beans. But I believe it'll be easier with better support for this.

      Spring has a nice support for this with the concept of a 'Profile':
      https://spring.io/blog/2011/02/14/spring-3-1-m1-introducing-profile/

      Would be really helpful if CDI has support for this.

            [CDI-539] Support for 'profile' in CDI

            The CDI project is part ofJakarta and uses GitHub issues as it's issue tracking system.
            Therefore, all issues in CDI JIRA project are being bulk-closed as described in this GitHub issue.

            If you feel like this particular issue deserves ongoing discussion, investigation or fixes in CDI/CDI TCK, please create a new issue under GitHub repository and include a link to this JIRA.

            For specification related question/issues, please use - https://github.com/eclipse-ee4j/cdi/issues
            For CDI TCK related questions/issues, please use - https://github.com/eclipse-ee4j/cdi-tck/issues

            Matěj Novotný added a comment - The CDI project is part ofJakarta and uses GitHub issues as it's issue tracking system. Therefore, all issues in CDI JIRA project are being bulk-closed as described in this GitHub issue . If you feel like this particular issue deserves ongoing discussion, investigation or fixes in CDI/CDI TCK, please create a new issue under GitHub repository and include a link to this JIRA. For specification related question/issues, please use - https://github.com/eclipse-ee4j/cdi/issues For CDI TCK related questions/issues, please use - https://github.com/eclipse-ee4j/cdi-tck/issues

            Mark Struberg (Inactive) added a comment - - edited

            > global activation of @Alternative @Stereotypes with @Priority or using an extension.
            In OpenWebBeans they are globally enabled per ee module by default, even without @Priority.

            I think the question was more about WHEN to activate those Alternatives and @Specializes. We did discuss the ProjectStage in the past and the conclusio was that this is nothing which CDI should define but it's an EE umbrella wide topic.

            Similar topic is true for enable it on a config base. This would need a configuration JSR first (kind of DeltaSpikes ConfigResolver but even more generic). But this got turned down so far for JavaEE8 by Oracle.

            Mark Struberg (Inactive) added a comment - - edited > global activation of @Alternative @Stereotypes with @Priority or using an extension. In OpenWebBeans they are globally enabled per ee module by default, even without @Priority. I think the question was more about WHEN to activate those Alternatives and @Specializes. We did discuss the ProjectStage in the past and the conclusio was that this is nothing which CDI should define but it's an EE umbrella wide topic. Similar topic is true for enable it on a config base. This would need a configuration JSR first (kind of DeltaSpikes ConfigResolver but even more generic). But this got turned down so far for JavaEE8 by Oracle.

            Yeah, I was looking at activating them using a System property instead of modifying the xml.

            Dhiraj Dwarapudi (Inactive) added a comment - Yeah, I was looking at activating them using a System property instead of modifying the xml.

            I agree that @Alternatives and @Stereotypes can solve the problem, but I guess the idea here is to activate them using a system property or something like it. Activating alternatives in beans.xml would require changes to the XML, and I suppose that's what this issue is about, or maybe Dhiraj can elaborate a bit more?

            George Gastaldi added a comment - I agree that @Alternatives and @Stereotypes can solve the problem, but I guess the idea here is to activate them using a system property or something like it. Activating alternatives in beans.xml would require changes to the XML, and I suppose that's what this issue is about, or maybe Dhiraj can elaborate a bit more?

            The missing part is global activation of @Alternative @Stereotypes with @Priority or using an extension. The latter is supported by Weld but it is not portable.

            Jozef Hartinger added a comment - The missing part is global activation of @Alternative @Stereotypes with @Priority or using an extension. The latter is supported by Weld but it is not portable.

            Agree with Jozef but I may have missed something. rhn-support-ggastald: What is missing in your opinion in @Alternatives activated via @Stereotypes to provide this feature? rhn-engineering-jharting what do you suggest to improve this in CDI 2.0?

            Antoine Sabot-Durand (Inactive) added a comment - Agree with Jozef but I may have missed something. rhn-support-ggastald : What is missing in your opinion in @Alternatives activated via @Stereotypes to provide this feature? rhn-engineering-jharting what do you suggest to improve this in CDI 2.0?

            This is exactly what @Alternative @Stereotypes are for in CDI. You can create your own "profiles" by introducing a stereotype annotated with @Alternative, e.g. @Mock, @Production etc. You can then activate the stereotypes you want active in beans.xml. This concept should be extended in CDI 2.0 to work with @Priority and CDI extensions.

            Jozef Hartinger added a comment - This is exactly what @Alternative @Stereotypes are for in CDI. You can create your own "profiles" by introducing a stereotype annotated with @Alternative, e.g. @Mock, @Production etc. You can then activate the stereotypes you want active in beans.xml. This concept should be extended in CDI 2.0 to work with @Priority and CDI extensions.

            tzwoenn
            Yeah, something similar to ProjectStage.

            But 'profile' is more usable and covers larger use cases.

            • I can have mutliple profiles active at the same time
            • I would like to boootstrap my application at start-time with different profiles. ProjectStage can be used to accomplish this, but the intent of ProjectStage (as the name suggests) seem to be more for different stages of application development
            • The way 'profile's are implemented in Spring, a custom profile is just another string. So you don't need to write any code to support custom 'profile'. For that matter there are not built-in profiles. They are user-defined.

            Dhiraj Dwarapudi (Inactive) added a comment - tzwoenn Yeah, something similar to ProjectStage. But 'profile' is more usable and covers larger use cases. I can have mutliple profiles active at the same time I would like to boootstrap my application at start-time with different profiles. ProjectStage can be used to accomplish this, but the intent of ProjectStage (as the name suggests) seem to be more for different stages of application development The way 'profile's are implemented in Spring, a custom profile is just another string. So you don't need to write any code to support custom 'profile'. For that matter there are not built-in profiles. They are user-defined.

            Something like Deltaspike's ProjectStage?

            Sven Linstaedt (Inactive) added a comment - Something like Deltaspike's ProjectStage ?

            This is very interesting. I wonder if there is enough room to fit in the CDI 2.0 schedule or should it be postponed to the next spec version? antoinesabot-durand?

            George Gastaldi added a comment - This is very interesting. I wonder if there is enough room to fit in the CDI 2.0 schedule or should it be postponed to the next spec version? antoinesabot-durand ?

              Unassigned Unassigned
              dhiraj.dwarapudi Dhiraj Dwarapudi (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: