本文整理汇总了Java中javax.enterprise.inject.spi.ProcessAnnotatedType类的典型用法代码示例。如果您正苦于以下问题:Java ProcessAnnotatedType类的具体用法?Java ProcessAnnotatedType怎么用?Java ProcessAnnotatedType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProcessAnnotatedType类属于javax.enterprise.inject.spi包,在下文中一共展示了ProcessAnnotatedType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: skipUnusedStepsFromBeanDiscovery
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
@SuppressWarnings("unused")
// will be called automatically by the CDI container for all annotated types
private void skipUnusedStepsFromBeanDiscovery(@Observes ProcessAnnotatedType<?> event, BeanManager beanManager)
throws MojoExecutionException, MojoFailureException {
// https://github.com/shillner/maven-cdi-plugin-utils/issues/14
Class<?> type = event.getAnnotatedType().getJavaClass();
ProcessingStep annotation = type.getAnnotation(ProcessingStep.class);
if (annotation != null) {
// adding the step to the list of all available processing steps
String id = annotation.id();
Preconditions.checkState(!this.allAvailableProcessingSteps.containsKey(id),
"The processing step id '" + id + "' is not unique!");
this.allAvailableProcessingSteps.put(id, annotation);
// vetoing the bean discovery of a step that is not part of the current workflow
// this prevents the issue that data shall be injected that isn't produced anywhere!
ProcessingWorkflow workflow = getWorkflow();
if (!workflow.containsStep(annotation.id())) {
event.veto();
}
}
}
示例2: findJobs
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
<T> void findJobs( @Observes @WithAnnotations({Cron.class}) ProcessAnnotatedType<T> pat, BeanManager beanManager )
{
// Ensure we are named otherwise job won't fire as we can't locate it
AnnotatedType<?> type = pat.getAnnotatedType();
Class<?> clazz = type.getJavaClass();
CDIUtils.addTypeAnnotation( pat, Named.class, () -> new NamedImpl( "Schedule_" + (id++) ) );
if( type.isAnnotationPresent( Cron.class ) ) {
if( Job.class.isAssignableFrom( clazz ) ) {
jobClasses.add( clazz );
}
else {
throw new UnsupportedOperationException( "@Cron on type must implement Job" );
}
}
else {
for( AnnotatedMethod<?> meth: type.getMethods() ) {
if( meth.isAnnotationPresent( Cron.class ) ) {
jobClasses.add( clazz );
}
}
}
}
示例3: addTypeAnnotation
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
/**
* Ensure we have an annotation present
* <p>
* @param <T>
* @param pat
* @param clazz
* @param s
* <p>
* @return
*/
public static <T> AnnotatedType<T> addTypeAnnotation( ProcessAnnotatedType<T> pat, Class<? extends Annotation> clazz, Supplier<Annotation> s )
{
AnnotatedType<T> t = pat.getAnnotatedType();
if( !t.isAnnotationPresent( clazz ) ) {
MutableAnnotatedType<T> mat;
if( t instanceof MutableAnnotatedType ) {
mat = (MutableAnnotatedType<T>) t;
}
else {
mat = new MutableAnnotatedType<>( t );
pat.setAnnotatedType( mat );
}
mat.add( s.get() );
return mat;
}
return t;
}
示例4: processAnnotatedType
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
private void processAnnotatedType(@Observes ProcessAnnotatedType<?> pat) {
if (pat.getAnnotatedType().isAnnotationPresent(Vetoed.class)) {
pat.veto();
}
if (hasAnnotation(pat.getAnnotatedType(), Converter.class)) {
converters.add(pat.getAnnotatedType().getJavaClass());
}
if (hasAnnotation(pat.getAnnotatedType(), BeanInject.class, Consume.class, EndpointInject.class, Produce.class, PropertyInject.class)) {
camelBeans.add(pat.getAnnotatedType());
}
if (hasAnnotation(pat.getAnnotatedType(), Consume.class)) {
eagerBeans.add(pat.getAnnotatedType());
}
if (hasAnnotation(pat.getAnnotatedType(), ImportResource.class)) {
resources.add(pat.getAnnotatedType().getAnnotation(ImportResource.class));
}
}
示例5: camelFactoryProducers
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
private void camelFactoryProducers(@Observes ProcessAnnotatedType<CdiCamelFactory> pat, BeanManager manager) {
pat.setAnnotatedType(
new AnnotatedTypeDelegate<>(
pat.getAnnotatedType(), pat.getAnnotatedType().getMethods().stream()
.filter(am -> am.isAnnotationPresent(Produces.class))
.filter(am -> am.getTypeClosure().stream().noneMatch(isEqual(TypeConverter.class)))
.peek(am -> producerQualifiers.put(am.getJavaMember(), getQualifiers(am, manager)))
.map(am -> new AnnotatedMethodDelegate<>(am, am.getAnnotations().stream()
.filter(annotation -> !manager.isQualifier(annotation.annotationType()))
.collect(collectingAndThen(toSet(), annotations -> {
annotations.add(EXCLUDED); return annotations;
}))))
.collect(toSet())));
}
示例6: alternatives
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
/**
* Activates the alternatives declared with {@code @Beans} globally for the
* application.
* <p/>
* For every types and every methods of every types declared with
* {@link Beans#alternatives()}, the {@code Priority} annotation is added
* so that the corresponding alternatives are selected globally for the
* entire application.
*
* @see Beans
*/
private <T> void alternatives(@Observes @WithAnnotations(Alternative.class) ProcessAnnotatedType<T> pat) {
AnnotatedType<T> type = pat.getAnnotatedType();
if (!Arrays.asList(beans.alternatives()).contains(type.getJavaClass())) {
// Only select globally the alternatives that are declared with @Beans
return;
}
Set<AnnotatedMethod<? super T>> methods = new HashSet<>();
for (AnnotatedMethod<? super T> method : type.getMethods()) {
if (method.isAnnotationPresent(Alternative.class) && !method.isAnnotationPresent(Priority.class)) {
methods.add(new AnnotatedMethodDecorator<>(method, PriorityLiteral.of(APPLICATION)));
}
}
if (type.isAnnotationPresent(Alternative.class) && !type.isAnnotationPresent(Priority.class)) {
pat.setAnnotatedType(new AnnotatedTypeDecorator<>(type, PriorityLiteral.of(APPLICATION), methods));
} else if (!methods.isEmpty()) {
pat.setAnnotatedType(new AnnotatedTypeDecorator<>(type, methods));
}
}
示例7: processPackageAnnotatedType
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
public <T> void processPackageAnnotatedType(@Observes final ProcessAnnotatedType<T> event) {
final Package pkg = event.getAnnotatedType().getJavaClass().getPackage();
if (pkg == null) {
return;
}
final String packageName = pkg.getName();
if (processedPackages.contains(packageName)) {
return; // already processed a class from this package
}
processedPackages.add(packageName);
if (pkg.isAnnotationPresent(FilterParameters.class)) {
addFilterParameters(pkg.getAnnotation(FilterParameters.class));
}
if (pkg.isAnnotationPresent(FilterParameter.class)) {
// TODO addFilterParameter(pkg.getAnnotation(FilterParameter.class));
}
}
示例8: convertJsf2Scopes
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
protected void convertJsf2Scopes(@Observes ProcessAnnotatedType processAnnotatedType)
{
if (!isActivated)
{
return;
}
//TODO
//CodiStartupBroadcaster.broadcastStartup();
Class<? extends Annotation> jsf2ScopeAnnotation = getJsf2ScopeAnnotation(processAnnotatedType);
if (jsf2ScopeAnnotation != null && !isBeanWithManagedBeanAnnotation(processAnnotatedType))
{
processAnnotatedType.setAnnotatedType(
convertBean(processAnnotatedType.getAnnotatedType(), jsf2ScopeAnnotation));
}
}
示例9: buildViewConfigMetaDataTree
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
@SuppressWarnings("UnusedDeclaration")
protected void buildViewConfigMetaDataTree(@Observes final ProcessAnnotatedType pat)
{
if (!isActivated)
{
return;
}
buildViewConfigMetaDataTreeFor(
pat.getAnnotatedType().getJavaClass(), pat.getAnnotatedType().getAnnotations(), new VetoCallback() {
@Override
public void veto()
{
pat.veto();
}
});
}
示例10: ensureNamingConvention
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
public void ensureNamingConvention(@Observes ProcessAnnotatedType processAnnotatedType)
{
Class<?> beanClass = processAnnotatedType.getAnnotatedType().getJavaClass();
Named namedAnnotation = beanClass.getAnnotation(Named.class);
if (namedAnnotation != null &&
namedAnnotation.value().length() > 0 &&
Character.isUpperCase(namedAnnotation.value().charAt(0)))
{
AnnotatedTypeBuilder builder = new AnnotatedTypeBuilder();
builder.readFromType(beanClass);
String beanName = namedAnnotation.value();
String newBeanName = beanName.substring(0, 1).toLowerCase() + beanName.substring(1);
builder.removeFromClass(Named.class)
.addToClass(new NamedLiteral(newBeanName));
processAnnotatedType.setAnnotatedType(builder.create());
}
}
示例11: detectInterfaces
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
@SuppressWarnings("UnusedDeclaration")
protected void detectInterfaces(@Observes ProcessAnnotatedType processAnnotatedType)
{
if (!isActivated)
{
return;
}
AnnotatedType<?> type = processAnnotatedType.getAnnotatedType();
if (type.isAnnotationPresent(MessageBundle.class))
{
if (validateMessageBundle(type.getJavaClass()))
{
messageBundleTypes.add(type);
}
}
}
示例12: evalExcludeInProjectStage
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
private boolean evalExcludeInProjectStage(ProcessAnnotatedType processAnnotatedType, Exclude exclude,
ProjectStage currentlyConfiguredProjectStage)
{
Class<? extends ProjectStage>[] activatedIn = exclude.ifProjectStage();
if (activatedIn.length == 0)
{
return true;
}
if (isInProjectStage(activatedIn, currentlyConfiguredProjectStage))
{
veto(processAnnotatedType, "IfProjectState");
return false;
}
return true;
}
示例13: evalExcludeNotInProjectStage
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
private boolean evalExcludeNotInProjectStage(ProcessAnnotatedType processAnnotatedType, Exclude exclude,
ProjectStage currentlyConfiguredProjectStage)
{
Class<? extends ProjectStage>[] notIn = exclude.exceptIfProjectStage();
if (notIn.length == 0)
{
return true;
}
if (!isInProjectStage(notIn, currentlyConfiguredProjectStage))
{
veto(processAnnotatedType, "ExceptIfProjectState");
return false;
}
return true;
}
示例14: beans
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
public <X> void beans(
final @Observes ProcessAnnotatedType<X> processBean
) {
final MessageDriven annotation = processBean.getAnnotatedType().getAnnotation(MessageDriven.class);
if (annotation != null) {
final Class<X> javaClass = processBean.getAnnotatedType().getJavaClass();
if (!MessageListener.class.isAssignableFrom(javaClass)) {
throw new TestEEfiException("The @MessageDriven bean " + javaClass.getName()
+ " does not implement MessageListener"
);
}
registry.register(annotation, (Class<? extends MessageListener>) javaClass);
}
}
示例15: beans
import javax.enterprise.inject.spi.ProcessAnnotatedType; //导入依赖的package包/类
public <X> void beans(
final @Observes ProcessAnnotatedType<X> processBean
) {
if (!processBean.getAnnotatedType().isAnnotationPresent(Interceptor.class)) {
return;
}
final FilteringAnnotatedTypeWrapper<X> filtered = new FilteringAnnotatedTypeWrapper<>(
processBean.getAnnotatedType(),
it -> it != Priority.class
);
processBean.setAnnotatedType(filtered);
}