]
Martin Kouba updated FORGE-2225:
--------------------------------
Status: Pull Request Sent (was: Open)
Git Pull Request:
Being able to add a new CDI producer method to an existing class
----------------------------------------------------------------
Key: FORGE-2225
URL:
https://issues.jboss.org/browse/FORGE-2225
Project: Forge
Issue Type: Sub-task
Components: Java EE
Affects Versions: 2.14.0.Final
Reporter: Antonio Goncalves
Assignee: Martin Kouba
Fix For: 3.x Future
It would be good to have a command to add a CDI producer method to an existing class. A
simple command such as :
{code}
cdi-add-producer-method --named produceLogger --type org.apache.logging.log4j.Logger
--targetClass LoggingProducer
{code}
Would generate :
{code}
public class LoggingProducer
{
@Produces
public Logger produceLogger() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
{code}
The method is by default private, but we could change this :
{code}
cdi-add-producer-method --named produceLogger --type org.apache.logging.log4j.Logger
--targetClass LoggingProducer --accessType private
{code}
We can also have a parameter to add the injection point
{code}
cdi-add-producer-method --named produceLogger --type org.apache.logging.log4j.Logger
--targetClass LoggingProducer --injectionPoint
{code}
Would generate :
{code}
public class LoggingProducer
{
@Produces
public Logger produceLogger(InjectionPoint injectionPoint) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
{code}
Then, we can have more attributes :
{code}
cdi-new-producer-method --named produceLogger --returnType
org.apache.logging.log4j.Logger --accessType private --injectionPoint --qualifier
Production --alternative=true --scoped Request --atNamed=true
{code}
{code}
public class LoggingProducer
{
@Produces
@Production
@Alternative
@RequestScoped
@Named
public Logger produceLogger() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
{code}