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


Java ProcessAnnotatedType.setAnnotatedType方法代碼示例

本文整理匯總了Java中javax.enterprise.inject.spi.ProcessAnnotatedType.setAnnotatedType方法的典型用法代碼示例。如果您正苦於以下問題:Java ProcessAnnotatedType.setAnnotatedType方法的具體用法?Java ProcessAnnotatedType.setAnnotatedType怎麽用?Java ProcessAnnotatedType.setAnnotatedType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.enterprise.inject.spi.ProcessAnnotatedType的用法示例。


在下文中一共展示了ProcessAnnotatedType.setAnnotatedType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: processAnnotatedType

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
public <T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> event, BeanManager manager) {
    boolean hasPersistenceField = false;
    for (AnnotatedField<? super T> field : event.getAnnotatedType().getFields()) {
        if (field.isAnnotationPresent(PersistenceContext.class)
                || field.isAnnotationPresent(PersistenceUnit.class)) {
            hasPersistenceField = true;
            break;
        }
    }
    if (hasPersistenceField) {
        PersistenceAnnotatedType<T> pat = new PersistenceAnnotatedType<T>(manager, event.getAnnotatedType());
        beans.addAll(pat.getProducers());
        event.setAnnotatedType(pat);
    }
}
 
開發者ID:apache,項目名稱:aries-jpa,代碼行數:16,代碼來源:JpaExtension.java

示例8: processAnnotatedType

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
<T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat) {
	if (pat.getAnnotatedType().isAnnotationPresent(Configuration.class)) {
		final AnnotatedType<T> type = pat.getAnnotatedType();
		AnnotatedType<T> wrapped = new SpringConfigurationWrapper<>(type);
		pat.setAnnotatedType(wrapped);
		logger.debug("Configuration is added as CDIBean with Annotation: {} : {}", OcelotSpringConfiguration.class, wrapped);
	}
}
 
開發者ID:ocelotds,項目名稱:ocelot,代碼行數:9,代碼來源:CDIExtension.java

示例9: annotates

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
@SuppressWarnings({ "unchecked", "rawtypes" })
public void annotates(@Observes ProcessAnnotatedType pat) {
	AnnotatedType annotatedType = pat.getAnnotatedType();
	Class type = annotatedType.getJavaClass();
	
	// verify if it has Controller in its name
	if(type.getSimpleName().endsWith("Controller")) {
		pat.setAnnotatedType(new AnnotatedTypeControllerWrapper(annotatedType));
		System.out.println("[CDI Extension] Controller found: " + type.getSimpleName());
	}
}
 
開發者ID:wesleyegberto,項目名稱:javaee_projects,代碼行數:12,代碼來源:ControllerAnnotator.java

示例10: modifiyAnnotatedTypeMetadata

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
/**
 * Adds {@link Transactional} and {@link RequestScoped} to the given annotated type and converts
 * its EJB injection points into CDI injection points (i.e. it adds the {@link Inject})
 * @param <X> the type of the annotated type
 * @param pat the process annotated type.
 */
private <X> void modifiyAnnotatedTypeMetadata(ProcessAnnotatedType<X> pat) {
    AnnotatedType at = pat.getAnnotatedType();
    
    AnnotatedTypeBuilder<X> builder = new AnnotatedTypeBuilder<X>().readFromType(at);
    builder.addToClass(AnnotationInstances.TRANSACTIONAL).addToClass(AnnotationInstances.REQUEST_SCOPED);

    InjectionHelper.addInjectAnnotation(at, builder);
    //Set the wrapper instead the actual annotated type
    pat.setAnnotatedType(builder.create());

}
 
開發者ID:NovaTecConsulting,項目名稱:BeanTest,代碼行數:18,代碼來源:BeanTestExtension.java

示例11: promoteInterceptors

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
protected void promoteInterceptors(@Observes ProcessAnnotatedType pat)
{
    if (priorityAnnotationInstance == null) //not CDI 1.1 or the extension is deactivated
    {
        return;
    }

    String beanClassName = pat.getAnnotatedType().getJavaClass().getName();
    if (beanClassName.startsWith(DS_PACKAGE_NAME))
    {
        if (pat.getAnnotatedType().isAnnotationPresent(Interceptor.class))
        {
            //noinspection unchecked
            pat.setAnnotatedType(new GlobalInterceptorWrapper(pat.getAnnotatedType(), priorityAnnotationInstance));
        }
        //currently not needed, because we don't use our interceptors internally -> check for the future
        else if (!beanClassName.contains(".test."))
        {
            for (Annotation annotation : pat.getAnnotatedType().getAnnotations())
            {
                if (beanManager.isInterceptorBinding(annotation.annotationType()))
                {
                    //once we see this warning we need to introduce double-call prevention logic due to WELD-1780
                    LOG.warning(beanClassName + " is an bean from DeltaSpike which is intercepted.");
                }
            }
        }
    }
}
 
開發者ID:apache,項目名稱:deltaspike,代碼行數:30,代碼來源:GlobalInterceptorExtension.java

示例12: metricsAnnotations

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
private <X> void metricsAnnotations(@Observes @WithAnnotations({ Counted.class, Gauge.class, Metered.class, Timed.class }) ProcessAnnotatedType<X> pat) {
    AnnotatedTypeDecorator newPAT = new AnnotatedTypeDecorator<>(pat.getAnnotatedType(), METRICS_BINDING);
    LOGGER.debugf("annotations: %s", newPAT.getAnnotations());
    LOGGER.debugf("methods: %s", newPAT.getMethods());
    pat.setAnnotatedType(newPAT);
}
 
開發者ID:wildfly-swarm,項目名稱:wildfly-swarm,代碼行數:7,代碼來源:MetricCdiInjectionExtension.java

示例13: replaceAnnotations

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
public <T> void replaceAnnotations(@Observes ProcessAnnotatedType<T> pat) {
    LOG.log(FINE, "processing type %s", pat);
    pat.setAnnotatedType(new AnnotationReplacementBuilder<>(pat.getAnnotatedType()).invoke());
    updateDecoratedTypes(pat);
}
 
開發者ID:guhilling,項目名稱:cdi-test,代碼行數:6,代碼來源:TestScopeExtension.java

示例14: metricsAnnotations

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
private <X> void metricsAnnotations(@Observes @WithAnnotations({CachedGauge.class, Counted.class, ExceptionMetered.class, Gauge.class, Metered.class, Timed.class}) ProcessAnnotatedType<X> pat) {
    pat.setAnnotatedType(new AnnotatedTypeDecorator<>(pat.getAnnotatedType(), METRICS_BINDING));
}
 
開發者ID:astefanutti,項目名稱:metrics-cdi,代碼行數:4,代碼來源:MetricsExtension.java

示例15: addApplicationScopedAndTransactionalToSingleton

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
/**
 * Adds {@link Transactional} and {@link ApplicationScoped} to the given annotated type and converts
 * its EJB injection points into CDI injection points (i.e. it adds the {@link Inject})
 * @param <X> the type of the annotated type.
 * @param pat the process annotated type.
 */
private <X> void addApplicationScopedAndTransactionalToSingleton(ProcessAnnotatedType<X> pat) {
    AnnotatedType at = pat.getAnnotatedType();
    
    AnnotatedTypeBuilder<X> builder = new AnnotatedTypeBuilder<X>().readFromType(at);
    
    builder.addToClass(AnnotationInstances.APPLICATION_SCOPED).addToClass(AnnotationInstances.TRANSACTIONAL);
    
    InjectionHelper.addInjectAnnotation(at, builder);
    
    pat.setAnnotatedType(builder.create());
}
 
開發者ID:NovaTecConsulting,項目名稱:BeanTest,代碼行數:18,代碼來源:BeanTestExtension.java


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