-
Sub-task
-
Resolution: Done
-
Major
-
2.14.0.Final
-
None
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."); } }
- relates to
-
FORGE-2079 Being able to add a new CDI producer field
- Open