com.itemis.maven.plugins.cdi.internal.beans.CdiBeanWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cdi-plugin-utils Show documentation
Show all versions of cdi-plugin-utils Show documentation
Provides an abstract Mojo that enables CDI-based dependency injection for Maven Plugins.
package com.itemis.maven.plugins.cdi.internal.beans;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.Set;
import javax.enterprise.context.Dependent;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
public class CdiBeanWrapper implements Bean {
private T instance;
private Set qualifiers;
private Type type;
private Class> instanceClass;
public CdiBeanWrapper(T instance, Type type, Class> instanceClass, Set qualifiers) {
this.instance = instance;
this.type = type;
this.instanceClass = instanceClass;
this.qualifiers = qualifiers;
}
@Override
public T create(CreationalContext creationalContext) {
return this.instance;
}
@Override
public void destroy(T instance, CreationalContext creationalContext) {
}
@Override
public Set getTypes() {
return Collections.singleton(this.type);
}
@Override
public Set getQualifiers() {
return this.qualifiers;
}
@Override
public Class extends Annotation> getScope() {
return Dependent.class;
}
@Override
public String getName() {
return null;
}
@Override
public Set> getStereotypes() {
return Collections.emptySet();
}
@Override
public boolean isAlternative() {
return false;
}
@Override
public Class> getBeanClass() {
return this.instanceClass;
}
@Override
public Set getInjectionPoints() {
return Collections.emptySet();
}
@Override
public boolean isNullable() {
return true;
}
}