本文整理了Java中javax.enterprise.inject.spi.AnnotatedType.getMethods()
方法的一些代码示例,展示了AnnotatedType.getMethods()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AnnotatedType.getMethods()
方法的具体详情如下:
包路径:javax.enterprise.inject.spi.AnnotatedType
类名称:AnnotatedType
方法名:getMethods
[英]Returns set of bean methods.
[中]返回一组bean方法。
代码示例来源:origin: oracle/helidon
/**
* Collects all FT methods in a set for later processing.
*
* @param event Event information.
*/
void registerFaultToleranceMethods(@Observes ProcessManagedBean<?> event) {
AnnotatedType<?> type = event.getAnnotatedBeanClass();
for (AnnotatedMethod<?> method : type.getMethods()) {
if (isFaultToleranceMethod(type.getJavaClass(), method.getJavaMember())) {
getRegisteredMethods().add(new BeanMethod(type.getJavaClass(), method.getJavaMember()));
}
}
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
private void validateTagLibraryListenerAnnotatedType(AnnotatedType<TagLibraryListener> type) {
assertEquals(type.getBaseType(), TagLibraryListener.class);
assertTrue(typeSetMatches(type.getTypeClosure(), TagLibraryListener.class, ServletContextListener.class,
EventListener.class, Object.class));
assertEquals(type.getFields().size(), 2);
assertEquals(type.getConstructors().size(), 1);
assertTrue(type.getMethods().stream().anyMatch(m -> m.getJavaMember().getName().equals("contextInitialized")));
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
private void validateManagedBean(AnnotatedType<Farm> type) {
assert type.getBaseType().equals(Farm.class);
assert typeSetMatches(type.getTypeClosure(), Farm.class, Object.class);
assert type.getFields().size() == 1;
assert type.getFields().iterator().next().isAnnotationPresent(Produces.class);
assert type.getMethods().size() == 1;
assert type.getMethods().iterator().next().isAnnotationPresent(Produces.class);
}
代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl
private void validateManagedBean(AnnotatedType<Farm> type)
{
assert type.getBaseType().equals(Farm.class);
assert rawTypeSetMatches(type.getTypeClosure(), Farm.class, Object.class);
assert type.getFields().size() == 1;
assert type.getFields().iterator().next().isAnnotationPresent(Produces.class);
assert type.getMethods().size() == 1;
assert type.getMethods().iterator().next().isAnnotationPresent(Produces.class);
}
代码示例来源:origin: hibernate/hibernate-validator
private <T> void determineConstrainedMethods(AnnotatedType<T> type, BeanDescriptor beanDescriptor, Set<AnnotatedCallable<? super T>> callables) {
List<Method> overriddenAndImplementedMethods = InheritedMethodsHelper.getAllMethods( type.getJavaClass() );
for ( AnnotatedMethod<? super T> annotatedMethod : type.getMethods() ) {
Method method = annotatedMethod.getJavaMember();
Optional<String> correspondingProperty = getterPropertySelectionStrategyHelper.getProperty( method );
// obtain @ValidateOnExecution from the top-most method in the hierarchy
Method methodForExecutableTypeRetrieval = replaceWithOverriddenOrInterfaceMethod( method, overriddenAndImplementedMethods );
EnumSet<ExecutableType> classLevelExecutableTypes = executableTypesDefinedOnType( methodForExecutableTypeRetrieval.getDeclaringClass() );
EnumSet<ExecutableType> memberLevelExecutableType = executableTypesDefinedOnMethod( methodForExecutableTypeRetrieval,
correspondingProperty.isPresent() );
ExecutableType currentExecutableType = correspondingProperty.isPresent() ? ExecutableType.GETTER_METHODS : ExecutableType.NON_GETTER_METHODS;
// validation is enabled per default, so explicit configuration can just veto whether
// validation occurs
if ( veto( classLevelExecutableTypes, memberLevelExecutableType, currentExecutableType ) ) {
continue;
}
boolean needsValidation;
if ( correspondingProperty.isPresent() ) {
needsValidation = isGetterConstrained( beanDescriptor, method, correspondingProperty.get() );
}
else {
needsValidation = isNonGetterConstrained( beanDescriptor, method );
}
if ( needsValidation ) {
callables.add( annotatedMethod );
}
}
}
代码示例来源: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.jboss.jsr299.tck/jsr299-tck-impl
private void validateTagLibraryListenerAnnotatedType(AnnotatedType<TagLibraryListener> type) {
assert type.getBaseType().equals(TagLibraryListener.class);
assert rawTypeSetMatches(type.getTypeClosure(), TagLibraryListener.class, ServletContextListener.class, EventListener.class, Object.class);
assert type.getFields().size() == 2;
assert type.getConstructors().size() == 1;
assert type.getMethods().size() == 3;
}
代码示例来源:origin: com.caucho/resin
protected <T> AnnotatedMethod<? super T>
findFirstCreateMethod(AnnotatedType<T> cl)
{
for (AnnotatedMethod<? super T> method : cl.getMethods()) {
if (method.getJavaMember().getName().startsWith("create"))
return method;
}
return null;
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
private void validateServletListenerAnnotatedType(AnnotatedType<TestListener> type) {
assertEquals(type.getBaseType(), TestListener.class);
assertTrue(type.getAnnotations().isEmpty());
assertEquals(type.getFields().size(), 2);
assertTrue(type.getMethods().stream().anyMatch(m -> m.getJavaMember().getName().equals("contextInitialized")));
int initializers = 0;
for (AnnotatedMethod<?> method : type.getMethods()) {
assertEquals(method.getParameters().size(), 1);
assertEquals(method.getBaseType(), void.class);
if (method.isAnnotationPresent(Inject.class)) {
initializers++;
}
}
assertEquals(initializers, 1);
}
代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl
private void validateSessionBeanInterceptor(AnnotatedType<SheepInterceptor> type)
{
assert type.getBaseType().equals(SheepInterceptor.class);
assert rawTypeSetMatches(type.getTypeClosure(), SheepInterceptor.class, Object.class);
assert type.getAnnotations().size() == 0;
assert type.getFields().size() == 0;
assert type.getMethods().size() == 1;
}
代码示例来源:origin: apache/deltaspike
public static AnnotatedMethod<?> findMethod(final AnnotatedType<?> type, final Method method)
{
AnnotatedMethod<?> annotatedMethod = null;
for (final AnnotatedMethod<?> am : type.getMethods())
{
if (am.getJavaMember().equals(method))
{
annotatedMethod = am;
break;
}
}
if (annotatedMethod == null)
{
throw new IllegalStateException("No annotated method for " + method);
}
return annotatedMethod;
}
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@SuppressWarnings("unchecked")
private <X, A extends AnnotatedMember<? super X>> A getAnnotatedMember(Class<X> javaClass, String memberName) {
AnnotatedType<X> type = getCurrentManager().createAnnotatedType(javaClass);
for (AnnotatedField<? super X> field : type.getFields()) {
if (field.getJavaMember().getName().equals(memberName)) {
return (A) field;
}
}
for (AnnotatedMethod<? super X> method : type.getMethods()) {
if (method.getJavaMember().getName().equals(memberName)) {
return (A) method;
}
}
throw new IllegalArgumentException("Member " + memberName + " not found on " + javaClass);
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
private void validateSessionBeanInterceptor(AnnotatedType<SheepInterceptor> type) {
assert type.getBaseType().equals(SheepInterceptor.class);
assert typeSetMatches(type.getTypeClosure(), SheepInterceptor.class, Object.class);
assert type.getAnnotations().size() == 0;
assert type.getFields().size() == 0;
assert type.getMethods().size() == 1;
}
代码示例来源:origin: errai/errai
private <X> AnnotatedMethod<? super X> getMethod(final ProcessAnnotatedType<X> annotatedType, final String name) {
for (final AnnotatedMethod<? super X> annotatedMethod : annotatedType.getAnnotatedType().getMethods()) {
if (name.equals(annotatedMethod.getJavaMember().getName())) {
return annotatedMethod;
}
}
throw new IllegalArgumentException("cannot find method on implementation class that is on the interface");
}
}
代码示例来源:origin: org.jboss.weld.se/weld-se
/**
* Generates a unique signature for an annotated type. Members without
* annotations are omitted to reduce the length of the signature
*
* @param <X>
* @param annotatedType
* @return
*/
public static <X> String createTypeId(AnnotatedType<X> annotatedType) {
return createTypeId(annotatedType.getJavaClass(), annotatedType.getAnnotations(), annotatedType.getMethods(), annotatedType.getFields(), annotatedType.getConstructors());
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
void processAnnotatedType(@Observes ProcessAnnotatedType<FruitObserver> pat) {
peachObserver = pat.getAnnotatedType().getMethods().stream()
.filter(annotatedMethod -> annotatedMethod.getJavaMember().getName().equals("observesPeach")).findAny().get();
}
代码示例来源:origin: weld/core
public AnnotatedTypeConfiguratorImpl(AnnotatedType<T> annotatedType) {
super(annotatedType);
this.constructors = annotatedType.getConstructors().stream().map(c -> AnnotatedConstructorConfiguratorImpl.from(c)).collect(ImmutableSet.collector());
this.methods = annotatedType.getMethods().stream().map(m -> AnnotatedMethodConfiguratorImpl.from(m)).collect(ImmutableSet.collector());
this.fields = annotatedType.getFields().stream().map(f -> AnnotatedFieldConfiguratorImpl.from(f)).collect(ImmutableSet.collector());
}
代码示例来源:origin: org.apache.openwebbeans/openwebbeans-impl
private static List<Method> getBindingCdiAnnotationMethods(AnnotatedType<?> at)
{
List<Method> bindingMethods = new ArrayList<>();
for (AnnotatedMethod<?> method : at.getMethods())
{
if (method.isAnnotationPresent(Nonbinding.class))
{
continue;
}
bindingMethods.add(method.getJavaMember());
}
return bindingMethods;
}
代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl
private void validateServletListenerAnnotatedType(AnnotatedType<TestListener> type) {
assert type.getBaseType().equals(TestListener.class);
assert type.getAnnotations().isEmpty();
assert type.getFields().size() == 2;
assert type.getMethods().size() == 3;
int initializers = 0;
for (AnnotatedMethod<?> method : type.getMethods()) {
assert method.getParameters().size() == 1;
assert method.getBaseType().equals(void.class);
if (method.isAnnotationPresent(Inject.class))
{
initializers++;
}
}
assert initializers == 1;
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertions({ @SpecAssertion(section = PROCESS_BEAN_ATTRIBUTES_EE, id = "bab") })
public void testSessionBeanAnnotated() {
Annotated deltaAnnotated = extension.getAnnotatedMap().get(Delta.class);
assertNotNull(deltaAnnotated);
assertTrue(deltaAnnotated instanceof AnnotatedType);
@SuppressWarnings("unchecked")
AnnotatedType<Delta> deltaAnnotatedType = (AnnotatedType<Delta>) deltaAnnotated;
assertEquals(deltaAnnotatedType.getJavaClass(), Delta.class);
assertEquals(deltaAnnotatedType.getMethods().size(), 1);
assertEquals(deltaAnnotatedType.getMethods().iterator().next().getJavaMember().getName(), "foo");
}
内容来源于网络,如有侵权,请联系作者删除!