Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-1926 Adding more commands to Forge and improve existing ones
  3. FORGE-2225

Being able to add a new CDI producer method to an existing class

    XMLWordPrintable

Details

    • Sub-task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Done
    • 2.14.0.Final
    • 3.8.0.Final
    • Java EE
    • None

    Description

      It would be good to have a command to add a CDI producer method to an existing class. A simple command such as :

      cdi-add-producer-method --named produceLogger --type org.apache.logging.log4j.Logger --targetClass LoggingProducer
      

      Would generate :

      public class LoggingProducer
      {
         @Produces
         public Logger produceLogger() {
            throw new UnsupportedOperationException("Not supported yet.");
         }
      }
      

      The method is by default private, but we could change this :

      cdi-add-producer-method --named produceLogger --type org.apache.logging.log4j.Logger --targetClass LoggingProducer --accessType private
      

      We can also have a parameter to add the injection point

      cdi-add-producer-method --named produceLogger --type org.apache.logging.log4j.Logger --targetClass LoggingProducer --injectionPoint
      

      Would generate :

      public class LoggingProducer
      {
         @Produces
         public Logger produceLogger(InjectionPoint injectionPoint) {
            throw new UnsupportedOperationException("Not supported yet.");
         }
      }
      

      Then, we can have more attributes :

      cdi-new-producer-method --named produceLogger --returnType org.apache.logging.log4j.Logger --accessType private --injectionPoint --qualifier Production --alternative=true  --scoped Request --atNamed=true
      
      public class LoggingProducer
      {
         @Produces 
         @Production
         @Alternative
         @RequestScoped
         @Named
         public Logger produceLogger() {
            throw new UnsupportedOperationException("Not supported yet.");
         }
      }
      

      Attachments

        Issue Links

          Activity

            People

              mkouba@redhat.com Martin Kouba
              agoncal Antonio Goncalves (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: