List of usage examples for org.springframework.core.annotation AnnotationUtils findAnnotation
@Nullable public static <A extends Annotation> A findAnnotation(Class<?> clazz, @Nullable Class<A> annotationType)
From source file:com.expedia.seiso.domain.meta.ItemMetaImpl.java
private void initFindByKeyMethod() { val methods = itemRepoInterface.getMethods(); for (val method : methods) { val findByKeyAnn = AnnotationUtils.findAnnotation(method, FindByKey.class); if (findByKeyAnn != null) { this.findByKeyMethod = method; return; }/* w w w .j a va 2 s.c o m*/ } }
From source file:org.openmrs.contrib.metadatarepository.dao.hibernate.UserDaoHibernate.java
/** * {@inheritDoc}// ww w . jav a 2 s . c o m */ public String getUserPassword(String username) { SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate( SessionFactoryUtils.getDataSource(getSessionFactory())); Table table = AnnotationUtils.findAnnotation(User.class, Table.class); return jdbcTemplate.queryForObject("select password from " + table.name() + " where username=?", String.class, username); }
From source file:org.impalaframework.extension.mvc.annotation.handler.ServletHandlerMethodInvoker.java
private String getModelAttributeName(Method attributeMethod) { String attributeName = modelAttributeMap.get(attributeMethod); if (attributeName == null) { attributeName = AnnotationUtils.findAnnotation(attributeMethod, ModelAttribute.class).value(); if (!StringUtils.hasText(attributeName)) { modelAttributeMap.put(attributeMethod, UNRESOLVED); }/*from w ww. j av a 2s . c o m*/ modelAttributeMap.put(attributeMethod, attributeName); } return attributeName; }
From source file:com.katsu.springframework.web.servlet.menu.MenuServiceImpl.java
private void createMenuEntry(Method m, Object bean) { //Group// w ww. j av a 2 s .co m MenuEntry me = m.getAnnotation(MenuEntry.class); String[] groups = SEPARATOR.split(me.menuGroup()); MenuEntryBean group = this.getCreateGroup(groups, 0, this.getMenus(), me); //Entry RequestMapping rm = m.getAnnotation(RequestMapping.class); RequestMapping rc = AnnotationUtils.findAnnotation(bean.getClass(), RequestMapping.class); MenuEntryBean aux = new MenuEntryBean(); aux.setIcon(me.icon()); //FIXME Add ContextPath aux.setUrl((rc != null && rc.value().length > 0 ? (rc.value()[0].endsWith("/") ? rc.value()[0] : rc.value()[0] + "/") : "/") + (rm.value().length > 0 ? (rm.value()[0].startsWith("/") ? rm.value()[0].substring(1) : rm.value()[0]) : "")); aux.setOrder(me.order()); aux.setText(me.text()); aux.setDevices(Arrays.asList(me.devices())); RolesAllowed sec = m.getAnnotation(RolesAllowed.class); if (sec != null) { aux.setRoles(Arrays.asList(sec.value())); } group.addChild(aux); }
From source file:org.jm.swagger.SpringMVCAPIReader.java
/** * This method will create the resources from controllers that have * request mappings and pull the base path for {@link DocumentationEndPoint} * from the classess {@link RequestMapping} if it is not contained in the excludeControllers * list.//from w w w . ja va2s. c o m * * @param mapping * @return */ public Documentation createResources(RequestMappingHandlerMapping mapping) { Documentation documentation = new Documentation(this.apiVersion, this.swaggerVersion, this.basePath, this.resourcePath); Map<String, Object> beansWithAnnotation = mapping.getApplicationContext() .getBeansWithAnnotation(Controller.class); for (Entry<String, Object> entry : beansWithAnnotation.entrySet()) { if (!excludeControllers.contains(entry.getValue().getClass())) { RequestMapping classRequestMapping = AnnotationUtils.findAnnotation(entry.getValue().getClass(), RequestMapping.class); if (classRequestMapping != null && classRequestMapping.value().length > 0) { String path = classRequestMapping.value()[0]; DocumentationEndPoint documentationEndPoint = new DocumentationEndPoint(path, entry.getValue().getClass().getSimpleName()); documentation.addApi(documentationEndPoint); } } } return documentation; }
From source file:springfox.documentation.spring.data.rest.EntitySearchRequestHandler.java
@Override public boolean isAnnotatedWith(Class<? extends Annotation> annotation) { return null != AnnotationUtils.findAnnotation(searchResource.getMethod(), annotation); }
From source file:ru.anr.base.services.api.APICommandFactoryImpl.java
/** * Find annotaion of API Strategy command class * /* w w w. j av a 2s. c o m*/ * @param s * API Strategy command * @return Annotation instance */ private ApiStrategy getAnnotation(ApiCommandStrategy s) { return AnnotationUtils.findAnnotation(s.getClass(), ApiStrategy.class); }
From source file:pl.bristleback.server.bristle.conf.resolver.action.client.ClientActionClassesResolver.java
private Map<String, ClientActionInformation> prepareActions(Class<?> actionClass, String actionClassName) { Map<String, ClientActionInformation> actionsMap = new HashMap<String, ClientActionInformation>(); for (Method action : actionClass.getMethods()) { ClientAction actionClassAnnotation = AnnotationUtils.findAnnotation(action, ClientAction.class); if (actionClassAnnotation != null) { ClientActionInformation actionInformation = clientActionResolver .prepareActionInformation(actionClassName, action); actionsMap.put(actionInformation.getName(), actionInformation); }/* ww w.j av a 2s . co m*/ } return actionsMap; }
From source file:de.iteratec.iteraplan.businesslogic.exchange.common.vbb.impl.util.VisualVariableHelper.java
private static VisualVariable getVVAnnotation(PropertyDescriptor vvCandidate) { VisualVariable vvAnnotation = null;//from ww w.j a v a 2 s . c om if (vvCandidate.getReadMethod() != null) { vvAnnotation = AnnotationUtils.findAnnotation(vvCandidate.getReadMethod(), VisualVariable.class); } if (vvAnnotation == null && vvCandidate.getWriteMethod() != null) { vvAnnotation = AnnotationUtils.findAnnotation(vvCandidate.getWriteMethod(), VisualVariable.class); } return vvAnnotation; }