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


Java ProcessAnnotatedType.getAnnotatedType方法代碼示例

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


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

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

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

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

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

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

示例7: observeResources

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
/**
 * Discover all classes that implements HealthCheckProcedure
 */
public void observeResources(@Observes @WithAnnotations({Health.class})  ProcessAnnotatedType<? extends HealthCheck> event) {
   AnnotatedType<? extends HealthCheck> annotatedType = event.getAnnotatedType();
   Class<? extends HealthCheck> javaClass = annotatedType.getJavaClass();
   MicroProfileHealthLogger.ROOT_LOGGER.debugf("Discovered health check procedure %s", javaClass);
   delegates.add(annotatedType);
}
 
開發者ID:jmesnil,項目名稱:wildfly-microprofile-health,代碼行數:10,代碼來源:CDIExtension.java

示例8: findServiceInterfaces

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
void findServiceInterfaces(@Observes @WithAnnotations(ProxyGen.class) ProcessAnnotatedType<?> event, BeanManager beanManager) {
    AnnotatedType<?> annotatedType = event.getAnnotatedType();
    if (annotatedType.isAnnotationPresent(ProxyGen.class) && annotatedType.getJavaClass().isInterface()) {
        LOGGER.debug("Service interface {0} discovered", annotatedType.getJavaClass());
        serviceInterfaces.add(annotatedType.getJavaClass());
    }
}
 
開發者ID:weld,項目名稱:weld-vertx,代碼行數:8,代碼來源:ServiceProxyExtension.java

示例9: forEachType

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
/**
 * Pass an AnnotatedType to a consumer if an annotation is present
 *
 * @param <T>
 * @param pat
 * @param annotationType
 * @param c
 */
public static <T> void forEachType( ProcessAnnotatedType<T> pat, Class<? extends Annotation> annotationType,
                                    Consumer<? super AnnotatedType<? extends Object>> c )
{
    AnnotatedType<?> type = pat.getAnnotatedType();
    if( type.isAnnotationPresent( annotationType ) ) {
        c.accept( type );
    }
}
 
開發者ID:peter-mount,項目名稱:opendata-common,代碼行數:17,代碼來源:CDIUtils.java

示例10: forEachMethod

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
/**
 * For each method in a type that has a specific annotation pass the class and method to a consumer
 *
 * @param <T>
 * @param pat
 * @param annotationType
 * @param c
 */
public static <T> void forEachMethod( ProcessAnnotatedType<T> pat, Class<? extends Annotation> annotationType,
                                      BiConsumer<Class<?>, ? super AnnotatedMethod<? extends Object>> c )
{
    AnnotatedType<?> type = pat.getAnnotatedType();
    Class<?> clazz = type.getJavaClass();
    type.getMethods()
            .stream().
            filter( meth -> meth.isAnnotationPresent( annotationType ) ).
            forEach( m -> c.accept( clazz, m ) );
}
 
開發者ID:peter-mount,項目名稱:opendata-common,代碼行數:19,代碼來源:CDIUtils.java

示例11: observeResources

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
public <T> void observeResources(@Observes @WithAnnotations({Health.class}) ProcessAnnotatedType<T> event) {

        AnnotatedType<T> annotatedType = event.getAnnotatedType();
        Class<T> javaClass = annotatedType.getJavaClass();
        for (Class<?> intf : javaClass.getInterfaces()) {
            if (intf.getName().equals(HealthCheck.class.getName())) {
                log.info(">> Discovered health check procedure " + javaClass);
                delegates.add(annotatedType);
            }
        }
    }
 
開發者ID:wildfly-swarm,項目名稱:wildfly-swarm,代碼行數:12,代碼來源:HealthExtension.java

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

示例13: processAggregateRootAnnotatedType

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
<X> void processAggregateRootAnnotatedType(
		@Observes final ProcessAnnotatedType<X> pat, final BeanManager beanManager) {
	AnnotatedType<X> at = pat.getAnnotatedType();
	boolean isAggregateRoot = AxonUtils.isAnnotatedAggregateRoot(at.getJavaClass());
	if (isAggregateRoot) {
		configuration.add(AggregateRootInfo.of(beanManager, at));
		pat.veto();
	}

}
 
開發者ID:kamaladafrica,項目名稱:axon-cdi,代碼行數:11,代碼來源:AxonCdiExtension.java

示例14: processSagaAnnotatedType

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
<X> void processSagaAnnotatedType(
		@Observes final ProcessAnnotatedType<X> pat, final BeanManager beanManager) {
	AnnotatedType<X> at = pat.getAnnotatedType();
	if (AxonUtils.isAnnotatedSaga(at.getJavaClass())) {
		configuration.add(SagaInfo.of(beanManager, at));
		// pat.veto(); // don't veto this bean. Because we need it to discover EventScheduler injected beans
	}
}
 
開發者ID:kamaladafrica,項目名稱:axon-cdi,代碼行數:9,代碼來源:AxonCdiExtension.java

示例15: processCommandsAndEventsHandlerTypes

import javax.enterprise.inject.spi.ProcessAnnotatedType; //導入方法依賴的package包/類
<X> void processCommandsAndEventsHandlerTypes(
		@Observes final ProcessAnnotatedType<X> pat, final BeanManager beanManager) {
	AnnotatedType<X> at = pat.getAnnotatedType();
	boolean isCommandHandler = AxonUtils.isCommandHandler(at.getJavaClass());
	boolean isEventHandler = AxonUtils.isEventHandler(at.getJavaClass());
	Preconditions.checkArgument(!isEventHandler || !isCommandHandler,
			"Provided type cannot be both event and command handler: %s", at);
	if (isCommandHandler) {
		configuration.add(HandlerInfo.commandHandler(beanManager, at));
	} else if (isEventHandler) {
		configuration.add(HandlerInfo.eventHandler(beanManager, at));
	}
}
 
開發者ID:kamaladafrica,項目名稱:axon-cdi,代碼行數:14,代碼來源:AxonCdiExtension.java


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