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