當前位置: 首頁>>代碼示例>>Java>>正文


Java ProcessAnnotatedType類代碼示例

本文整理匯總了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();
    }
  }
}
 
開發者ID:shillner,項目名稱:maven-cdi-plugin-utils,代碼行數:23,代碼來源:AbstractCDIMojo.java

示例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 );
            }
        }
    }
}
 
開發者ID:peter-mount,項目名稱:opendata-common,代碼行數:24,代碼來源:SchedulerExtension.java

示例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;
}
 
開發者ID:peter-mount,項目名稱:opendata-common,代碼行數:28,代碼來源:CDIUtils.java

示例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));
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:18,代碼來源:CdiCamelExtension.java

示例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())));
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:15,代碼來源:CdiCamelExtension.java

示例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));
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:33,代碼來源:CamelCdiTestExtension.java

示例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));
    }
}
 
開發者ID:cbensemann,項目名稱:SimplePersistence,代碼行數:22,代碼來源:HibernateFilterExtension.java

示例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));
    }
}
 
開發者ID:apache,項目名稱:deltaspike,代碼行數:19,代碼來源:MappedJsf2ScopeExtension.java

示例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();
                }
            });
}
 
開發者ID:apache,項目名稱:deltaspike,代碼行數:18,代碼來源:ViewConfigExtension.java

示例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());
    }
}
 
開發者ID:apache,項目名稱:deltaspike,代碼行數:22,代碼來源:NamingConventionAwareMetadataFilter.java

示例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);
        }
    }
}
 
開發者ID:apache,項目名稱:deltaspike,代碼行數:19,代碼來源:MessageBundleExtension.java

示例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;
}
 
開發者ID:apache,項目名稱:deltaspike,代碼行數:18,代碼來源:ExcludeExtension.java

示例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;
}
 
開發者ID:apache,項目名稱:deltaspike,代碼行數:18,代碼來源:ExcludeExtension.java

示例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);
    }
}
 
開發者ID:dajudge,項目名稱:testee.fi,代碼行數:15,代碼來源:JmsExtension.java

示例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);
}
 
開發者ID:dajudge,項目名稱:testee.fi,代碼行數:13,代碼來源:MockingExtension.java


注:本文中的javax.enterprise.inject.spi.ProcessAnnotatedType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。