本文整理了Java中javax.enterprise.inject.spi.AnnotatedConstructor
类的一些代码示例,展示了AnnotatedConstructor
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AnnotatedConstructor
类的具体详情如下:
包路径:javax.enterprise.inject.spi.AnnotatedConstructor
类名称:AnnotatedConstructor
[英]Represents a constructor of a Java class.
[中]表示Java类的构造函数。
代码示例来源:origin: oracle/helidon
Interceptor annot = type.getAnnotation(Interceptor.class);
if (annot != null) {
return;
LOGGER.log(Level.FINE, () -> "### Processing annotations for " + pat.getAnnotatedType().getJavaClass().getName());
Class<?> clazz = configurator.getAnnotated().getJavaClass();
configurator.filterMethods(method -> !Modifier.isPrivate(method.getJavaMember().getModifiers()))
.forEach(method -> {
METRIC_ANNOTATIONS.forEach(annotation -> {
LookupResult<? extends Annotation> lookupResult
= lookupAnnotation(method.getAnnotated().getJavaMember(), annotation, clazz);
if (lookupResult != null) {
registerMetric(method.getAnnotated().getJavaMember(), clazz, lookupResult);
configurator.filterConstructors(constructor -> !Modifier.isPrivate(constructor.getJavaMember().getModifiers()))
.forEach(constructor -> {
METRIC_ANNOTATIONS.forEach(annotation -> {
LookupResult<? extends Annotation> lookupResult
= lookupAnnotation(constructor.getAnnotated().getJavaMember(), annotation, clazz);
if (lookupResult != null) {
registerMetric(constructor.getAnnotated().getJavaMember(), clazz, lookupResult);
代码示例来源:origin: jersey/jersey
@Override
public List<AnnotatedParameter> getParameters() {
final List<AnnotatedParameter> parameters = new ArrayList<>(ctor.getParameters().size());
for (final AnnotatedParameter<?> ap : ctor.getParameters()) {
parameters.add(new AnnotatedParameter() {
代码示例来源:origin: jersey/jersey
@Override
public Set<Annotation> getAnnotations() {
return ctor.getAnnotations();
}
代码示例来源:origin: org.infinispan/infinispan-cdi
this.javaClass = type.getJavaClass();
for (AnnotatedField<? super X> field : type.getFields()) {
if (fields.get(field.getJavaMember()) == null) {
fields.put(field.getJavaMember(), new AnnotationBuilder());
mergeAnnotationsOnElement(field, overwrite, fields.get(field.getJavaMember()));
if (methodParameters.get(method.getJavaMember()).get(p.getPosition()) == null) {
methodParameters.get(method.getJavaMember()).put(p.getPosition(), new AnnotationBuilder());
mergeAnnotationsOnElement(p, overwrite, methodParameters.get(method.getJavaMember()).get(p.getPosition()));
for (AnnotatedConstructor<? super X> constructor : type.getConstructors()) {
if (constructors.get(constructor.getJavaMember()) == null) {
constructors.put(constructor.getJavaMember(), new AnnotationBuilder());
mergeAnnotationsOnElement(constructor, overwrite, constructors.get(constructor.getJavaMember()));
for (AnnotatedParameter<? super X> p : constructor.getParameters()) {
if (constructorParameters.get(constructor.getJavaMember()) == null) {
constructorParameters.put(constructor.getJavaMember(), new HashMap<Integer, AnnotationBuilder>());
if (constructorParameters.get(constructor.getJavaMember()).get(p.getPosition()) == null) {
constructorParameters.get(constructor.getJavaMember()).put(p.getPosition(), new AnnotationBuilder());
mergeAnnotationsOnElement(p, overwrite, constructorParameters.get(constructor.getJavaMember()).get(p.getPosition()));
代码示例来源:origin: org.jboss.weld.se/weld-se
if (!t1.getJavaClass().equals(t2.getJavaClass())) {
return false;
if (!compareAnnotated(t1, t2)) {
return false;
if (t1.getFields().size() != t2.getFields().size()) {
return false;
for (AnnotatedField<?> f : t2.getFields()) {
fields.put(f.getJavaMember(), f);
for (AnnotatedField<?> f : t1.getFields()) {
if (fields.containsKey(f.getJavaMember())) {
if (!compareAnnotatedField(f, fields.get(f.getJavaMember()))) {
return false;
for (AnnotatedMethod<?> f : t2.getMethods()) {
methods.put(f.getJavaMember(), f);
for (AnnotatedConstructor<?> f : t2.getConstructors()) {
constructors.put(f.getJavaMember(), f);
for (AnnotatedConstructor<?> f : t1.getConstructors()) {
if (constructors.containsKey(f.getJavaMember())) {
if (!compareAnnotatedCallable(f, constructors.get(f.getJavaMember()))) {
return false;
代码示例来源:origin: weld/core
protected static void validateParameterCount(AnnotatedCallable<?> callable) {
if (callable instanceof BackedAnnotatedMember) {
return; // do not validate backed implementation
}
Class<?>[] parameterTypes = null;
if (callable instanceof AnnotatedConstructor<?>) {
parameterTypes = AnnotatedConstructor.class.cast(callable).getJavaMember().getParameterTypes();
} else {
parameterTypes = AnnotatedMethod.class.cast(callable).getJavaMember().getParameterTypes();
}
if (callable.getParameters().size() != parameterTypes.length) {
// For enums, BackedAnnotatedConstructor sets parameters to an empty list, so we shouldn't throw the DefinitionException
Class<?> declaringClass = callable.getDeclaringType().getJavaClass();
if (!declaringClass.isEnum() && !declaringClass.isMemberClass()) {
throw ReflectionLogger.LOG.incorrectNumberOfAnnotatedParametersMethod(callable.getParameters().size(), callable, callable.getParameters(), Arrays.asList(parameterTypes));
}
}
}
}
代码示例来源:origin: weld/core
public static String formatAnnotatedConstructor(AnnotatedConstructor<?> constructor) {
return Formats.formatSimpleClassName(constructor) + " " + Formats.addSpaceIfNeeded(Formats.formatAnnotations(constructor.getAnnotations()))
+ Formats.addSpaceIfNeeded(Formats.formatModifiers(constructor.getJavaMember().getModifiers())) + constructor.getDeclaringType().getJavaClass().getName()
+ Formats.formatAsFormalParameterList(constructor.getParameters());
}
代码示例来源:origin: org.jboss.weld.se/weld-se
private <T> UnbackedAnnotatedMember<T> findMatchingMember(UnbackedAnnotatedType<T> type, String id) {
for (AnnotatedField<? super T> field : type.getFields()) {
if (id.equals(AnnotatedTypes.createFieldId(field))) {
return cast(field);
}
}
for (AnnotatedMethod<? super T> method : type.getMethods()) {
if (id.equals(AnnotatedTypes.createMethodId(method.getJavaMember(), method.getAnnotations(), method.getParameters()))) {
return Reflections.cast(method);
}
}
for (AnnotatedConstructor<T> constructor : type.getConstructors()) {
if (id.equals(AnnotatedTypes.createConstructorId(constructor.getJavaMember(), constructor.getAnnotations(), constructor.getParameters()))) {
return cast(constructor);
}
}
throw BeanLogger.LOG.unableToLoadMember(id);
}
}
代码示例来源:origin: org.jboss.as/jboss-as-weld
for (AnnotatedConstructor<?> constructor : type.getConstructors()) {
if (constructor.isAnnotationPresent(Inject.class)) {
if (injectConstructor != null) {
throw WeldMessages.MESSAGES.moreThanOneBeanConstructor(componentClass);
for (AnnotatedField<?> field : type.getFields()) {
if (field.isAnnotationPresent(Inject.class)) {
if (InjectionPoint.class.isAssignableFrom(field.getJavaMember().getType())) {
throw WeldMessages.MESSAGES.attemptingToInjectInjectionPointIntoField(componentClass, field.getJavaMember());
for (AnnotatedMethod<?> method : type.getMethods()) {
if (method.isAnnotationPresent(Inject.class)) {
final List<Bean<?>> parameterBeans = new ArrayList<Bean<?>>();
final List<InjectionPoint> ips = new ArrayList<InjectionPoint>();
for (AnnotatedParameter<?> param : method.getParameters()) {
final Set<Annotation> qualifiers = new HashSet<Annotation>();
for (Annotation annotation : param.getAnnotations()) {
if (beanManager.isQualifier(annotation.annotationType())) {
qualifiers.add(annotation);
final Class<?> parameterType = method.getJavaMember().getParameterTypes()[param.getPosition()];
if (InjectionPoint.class.isAssignableFrom(parameterType)) {
throw WeldMessages.MESSAGES.attemptingToInjectInjectionPointIntoNonBean(componentClass, method.getJavaMember());
代码示例来源:origin: org.jboss.forge/forge-shell
for (AnnotatedConstructor<T> c : event.getAnnotatedType().getConstructors())
if (c.isAnnotationPresent(Current.class))
for (AnnotatedParameter<?> p : c.getParameters())
if (p.getTypeClosure().contains(Resource.class))
builderHolder.getBuilder().overrideConstructorParameterType(c.getJavaMember(), p.getPosition(),
Resource.class);
modifiedType = true;
for (AnnotatedField<?> f : event.getAnnotatedType().getFields())
if (f.isAnnotationPresent(Current.class))
builderHolder.getBuilder().overrideFieldType(f.getJavaMember(), Resource.class);
modifiedType = true;
typeOverrides.put(replacement.getJavaClass(), replacement);
event.setAnnotatedType(replacement);
代码示例来源:origin: org.apache.openwebbeans/openwebbeans-impl
private boolean annotatedTypeHasAnnotations(AnnotatedType annotatedType, Class<? extends Annotation>[] withAnnotations)
if (hasAnnotation(annotatedType.getAnnotations(), withAnnotations))
Set<AnnotatedField> fields = annotatedType.getFields();
for (AnnotatedField annotatedField : fields)
if (hasAnnotation(annotatedField.getAnnotations(), withAnnotations))
Set<AnnotatedMethod> annotatedMethods = annotatedType.getMethods();
for (AnnotatedMethod annotatedMethod : annotatedMethods)
if (hasAnnotation(annotatedMethod.getAnnotations(), withAnnotations))
for (AnnotatedParameter annotatedParameter : (List<AnnotatedParameter>) annotatedMethod.getParameters())
if (hasAnnotation(annotatedParameter.getAnnotations(), withAnnotations))
for (AnnotatedConstructor<?> annotatedConstructor : annotatedConstructors)
if (hasAnnotation(annotatedConstructor.getAnnotations(), withAnnotations))
for (AnnotatedParameter annotatedParameter : annotatedConstructor.getParameters())
if (hasAnnotation(annotatedParameter.getAnnotations(), withAnnotations))
代码示例来源:origin: weld/core
for (Annotation annotation : annotatedType.getAnnotations()) {
if (isEqualOrAnnotated(requiredAnnotation, annotation)) {
return true;
for (AnnotatedField<?> field : annotatedType.getFields()) {
for (Annotation annotation : field.getAnnotations()) {
if (isEqualOrAnnotated(requiredAnnotation, annotation)) {
return true;
for (AnnotatedConstructor<?> constructor : annotatedType.getConstructors()) {
for (Annotation annotation : constructor.getAnnotations()) {
if (isEqualOrAnnotated(requiredAnnotation, annotation)) {
return true;
for (AnnotatedParameter<?> parameter : constructor.getParameters()) {
for (Annotation annotation : parameter.getAnnotations()) {
if (isEqualOrAnnotated(requiredAnnotation, annotation)) {
return true;
for (AnnotatedMethod<?> method : annotatedType.getMethods()) {
for (Annotation annotation : method.getAnnotations()) {
if (isEqualOrAnnotated(requiredAnnotation, annotation)) {
return true;
for (AnnotatedParameter<?> parameter : method.getParameters()) {
for (Annotation annotation : parameter.getAnnotations()) {
if (isEqualOrAnnotated(requiredAnnotation, annotation)) {
return true;
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
private void validateFilterAnnotatedType(AnnotatedType<TestFilter> type) {
assertEquals(type.getBaseType(), TestFilter.class);
assertTrue(typeSetMatches(type.getTypeClosure(), TestFilter.class, Filter.class, Object.class));
assertEquals(type.getFields().size(), 12);
assertEquals(type.getConstructors().size(), 1);
assertTrue(type.getConstructors().iterator().next().getParameters().isEmpty());
assertTrue(type.getMethods().stream().anyMatch(m -> m.getJavaMember().getName().equals("doFilter")));
}
代码示例来源:origin: org.apache.camel/camel-cdi
static boolean hasAnnotation(AnnotatedType<?> type, Class<? extends Annotation> annotation) {
if (type.isAnnotationPresent(annotation)) {
return true;
}
for (AnnotatedMethod<?> method : type.getMethods()) {
if (method.isAnnotationPresent(annotation)) {
return true;
}
}
for (AnnotatedConstructor<?> constructor : type.getConstructors()) {
if (constructor.isAnnotationPresent(annotation)) {
return true;
}
}
for (AnnotatedField<?> field : type.getFields()) {
if (field.isAnnotationPresent(annotation)) {
return true;
}
}
return false;
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
AnnotatedMethod<? super AnimalShelter> annotatedMethod = methodConfigurator.getAnnotated();
annotatedMethodEqual.set(AnnotatedTypes.compareAnnotatedCallable(
event.getAnnotatedType().getMethods().stream().filter(m -> m.getJavaMember().getName().equals("observesRoomInShelter")).findAny().get(),
annotatedMethod));
.filterConstructors(ac -> ac.isAnnotationPresent(Inject.class))
.findFirst().get();
AnnotatedConstructor<AnimalShelter> originalAnnotatedConstructor = event.getAnnotatedType().getConstructors().stream()
.filter(m -> m.isAnnotationPresent(Inject.class)).findAny().get();
.set(AnnotatedTypes.compareAnnotatedParameters(originalAnnotatedConstructor.getParameters(), configuratorAnnotatedConstructor.getParameters()));
return annotatedField.getJavaMember().getName().equals("cat");
}).findFirst().get();
.compareAnnotatedField(event.getAnnotatedType().getFields().stream().filter(af -> af.getJavaMember().getName().equals("cat")).findAny().get(),
annotatedField));
代码示例来源:origin: org.apache.openwebbeans/openwebbeans-impl
for (AnnotatedConstructor<X> constructor: annotatedType.getConstructors())
if (constructor.isAnnotationPresent(Inject.class))
for (AnnotatedField<? super X> field: annotatedType.getFields())
if (owner != null && Modifier.isPublic(field.getJavaMember().getModifiers()) && !field.isStatic())
if (field.isAnnotationPresent(Inject.class))
if (method.isAnnotationPresent(Inject.class) && !Modifier.isStatic(method.getJavaMember().getModifiers()))
代码示例来源:origin: agorava/agorava-core
void applyQualifier(Annotation qual, AnnotatedTypeBuilder<?> atb) {
AnnotatedType<?> at = atb.create();
//do a loop on all field to replace annotation mark by CDI annotations
for (AnnotatedField af : at.getFields())
if (af.isAnnotationPresent(InjectWithQualifier.class)) {
atb.addToField(af, InjectLiteral.instance);
atb.addToField(af, qual);
}
//loop on constructors to do the same
for (AnnotatedConstructor ac : at.getConstructors()) {
Annotation[][] pa = ac.getJavaMember().getParameterAnnotations();
//loop on args to detect marked param
for (int i = 0; i < pa.length; i++)
for (int j = 0; j < pa[i].length; j++)
if (pa[i][j].equals(InjectWithQualifierLiteral.instance)) {
atb.addToConstructor(ac, InjectLiteral.instance);
atb.addToConstructorParameter(ac.getJavaMember(), i, qual);
}
}
//loop on other methods (setters)
for (AnnotatedMethod am : at.getMethods())
if (am.isAnnotationPresent(InjectWithQualifierLiteral.class)) {
atb.addToMethod(am, InjectLiteral.instance);
atb.addToMethod(am, qual);
}
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
public AnnotatedTypeWrapper(AnnotatedType<X> delegate, boolean keepOriginalAnnotations, Annotation... annotations) {
super(delegate, keepOriginalAnnotations, annotations);
this.delegate = delegate;
this.constructors = new HashSet<AnnotatedConstructor<X>>();
for (AnnotatedConstructor<X> constructor : delegate.getConstructors()) {
constructors.add(new AnnotatedConstructorWrapper<X>(constructor, this, true, constructor.getAnnotations().toArray(
new Annotation[] { })));
}
this.fields = new HashSet<AnnotatedField<? super X>>();
for (AnnotatedField<? super X> field : delegate.getFields()) {
fields.add(new AnnotatedFieldWrapper(field, this, true, field.getAnnotations().toArray(new Annotation[] { })));
}
this.methods = new HashSet<AnnotatedMethod<? super X>>();
for (AnnotatedMethod<? super X> method : delegate.getMethods()) {
methods.add(new AnnotatedMethodWrapper(method, this, true, method.getAnnotations().toArray(new Annotation[] { })));
}
}
代码示例来源:origin: hibernate/hibernate-validator
private <T> void determineConstrainedConstructors(AnnotatedType<T> type, BeanDescriptor beanDescriptor, Set<AnnotatedCallable<? super T>> callables) {
Class<?> clazz = type.getJavaClass();
EnumSet<ExecutableType> classLevelExecutableTypes = executableTypesDefinedOnType( clazz );
for ( AnnotatedConstructor<T> annotatedConstructor : type.getConstructors() ) {
Constructor<?> constructor = annotatedConstructor.getJavaMember();
EnumSet<ExecutableType> memberLevelExecutableType = executableTypesDefinedOnConstructor( constructor );
if ( veto( classLevelExecutableTypes, memberLevelExecutableType, ExecutableType.CONSTRUCTORS ) ) {
continue;
}
if ( beanDescriptor.getConstraintsForConstructor( constructor.getParameterTypes() ) != null ) {
callables.add( annotatedConstructor );
}
}
}
代码示例来源:origin: weld/core
public static boolean hasSimpleCdiConstructor(AnnotatedType<?> type) {
for (AnnotatedConstructor<?> constructor : type.getConstructors()) {
if (constructor.getParameters().isEmpty()) {
return true;
}
if (constructor.isAnnotationPresent(Inject.class)) {
return true;
}
}
return false;
}
内容来源于网络,如有侵权,请联系作者删除!