List of usage examples for org.springframework.core.type MethodMetadata getAnnotationAttributes
@Nullable
default Map<String, Object> getAnnotationAttributes(String annotationName)
From source file:io.neba.core.selftests.SelftestReference.java
public SelftestReference(BeanFactory factory, String beanName, MethodMetadata methodMetadata, Bundle bundle) { super(beanName, factory, bundle); Map<String, Object> annotationAttributes = methodMetadata.getAnnotationAttributes(SelfTest.class.getName()); this.success = (String) annotationAttributes.get("success"); this.failure = (String) annotationAttributes.get("failure"); this.description = (String) annotationAttributes.get("value"); this.methodName = methodMetadata.getMethodName(); this.hashCode = new HashCodeBuilder().append(beanName).append(bundle.getBundleId()).append(this.methodName) .toHashCode();/* ww w . ja va 2 s . c o m*/ }
From source file:org.duracloud.account.db.util.security.impl.AnnotationParserImpl.java
private Map<String, Object[]> doGetMethodAnnotationsForClass(Class annotationClass, Class targetClass) { Map<String, Object[]> methodAnnotations = new HashMap<String, Object[]>(); // Find class/interface in stack that has the annotation Class iface = getAnnotatedInterface(annotationClass, targetClass); // Read the annotation metadata from the found class/interface MetadataReader metadataReader = getMetadataReader(iface); AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata(); Set<MethodMetadata> annotatedMethods = getAnnotatedMethods(annotationMetadata, annotationClass); Iterator itr = getAnnotatedMethodsIterator(annotatedMethods); while (itr.hasNext()) { MethodMetadata methodMetadata = (MethodMetadata) itr.next(); Map<String, Object> annotationAtts = methodMetadata.getAnnotationAttributes(annotationClass.getName()); Object[] values = getValues(annotationAtts); methodAnnotations.put(methodMetadata.getMethodName(), values); }//from w ww .j av a 2s.c o m return methodAnnotations; }
From source file:ar.com.zauber.commons.web.uri.factory.AnnotationExpressionMapUriFactoryFactoryBean.java
/** @see FactoryBean#getObject() */ public final ExpressionMapUriFactory getObject() throws IOException { final Map<String, ExpressionMapUriFactory.UriExpression> uris = new HashMap<String, ExpressionMapUriFactory.UriExpression>(); if (extraUris != null) { for (final Entry<String, String> entry : extraUris.entrySet()) { uris.put(entry.getKey(), new ExpressionMapUriFactory.UriExpression( expressionTemplateFactory.create(entry.getValue()))); }//w w w . ja va 2s . c om } for (final String basePackage : packages) { final String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resolveBasePackage(basePackage) + "/" + this.resourcePattern; final Resource[] resources = resourcePatternResolver.getResources(packageSearchPath); for (final Resource resource : resources) { final MetadataReader reader = metadataReaderFactory.getMetadataReader(resource); final Set<MethodMetadata> metas = reader.getAnnotationMetadata().getAnnotatedMethods(TYPE); for (final MethodMetadata meta : metas) { final Map<String, Object> attrs = meta.getAnnotationAttributes(TYPE); final String description = (String) attrs.get("description"); uris.put(attrs.get("name").toString(), new ExpressionMapUriFactory.UriExpression( expressionTemplateFactory.create(attrs.get("value").toString()), description)); } } } return new ExpressionMapUriFactory(uris); }