本文整理匯總了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 );
}
}
}
}
示例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;
}
示例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));
}
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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());
}
}
示例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 );
}
}
示例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 ) );
}
示例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);
}
}
}
示例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);
}
}
示例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();
}
}
示例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
}
}
示例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));
}
}