Java Code Examples for org.springframework.stereotype.Controller

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project banshun, under directory /banshun/web/src/main/java/com/griddynamics/banshun/web/.

Source file: ContextParentAnnotationHandlerMapping.java

  15 
vote

protected String[] determineUrlsByAnnotations(Object handler){
  Class<? extends Object> handlerType=handler.getClass();
  RequestMapping mapping=AnnotationUtils.findAnnotation(handlerType,RequestMapping.class);
  if (mapping != null) {
    this.cachedMappings.put(handlerType,mapping);
    Set<String> urls=new LinkedHashSet<String>();
    String[] paths=mapping.value();
    if (paths.length > 0) {
      for (      String path : paths) {
        addUrlsForPath(urls,path);
      }
      return StringUtils.toStringArray(urls);
    }
 else {
      return determineUrlsForHandlerMethods(handlerType);
    }
  }
 else   if (AnnotationUtils.findAnnotation(handlerType,Controller.class) != null) {
    return determineUrlsForHandlerMethods(handlerType);
  }
 else {
    return null;
  }
}
 

Example 2

From project spring-framework-issues, under directory /SPR-9638/src/main/java/org/springframework/issues/.

Source file: ControllerAdvisor.java

  15 
vote

public ControllerAdvisor(){
  super(new StaticMethodMatcherPointcut(){
    public boolean matches(    Method method,    Class<?> targetClass){
      return (AnnotationUtils.findAnnotation(targetClass,Controller.class) != null);
    }
  }
,new SimpleTraceInterceptor());
}
 

Example 3

From project spring-js, under directory /src/test/java/org/springframework/context/annotation/.

Source file: ClassPathScanningCandidateComponentProviderTests.java

  15 
vote

@Test public void testWithComponentAnnotationOnly(){
  ClassPathScanningCandidateComponentProvider provider=new ClassPathScanningCandidateComponentProvider(false);
  provider.addIncludeFilter(new AnnotationTypeFilter(Component.class));
  provider.addExcludeFilter(new AnnotationTypeFilter(Repository.class));
  provider.addExcludeFilter(new AnnotationTypeFilter(Service.class));
  provider.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
  Set<BeanDefinition> candidates=provider.findCandidateComponents(TEST_BASE_PACKAGE);
  assertEquals(2,candidates.size());
  assertTrue(containsBeanClass(candidates,NamedComponent.class));
  assertTrue(containsBeanClass(candidates,ServiceInvocationCounter.class));
  assertFalse(containsBeanClass(candidates,FooServiceImpl.class));
  assertFalse(containsBeanClass(candidates,StubFooDao.class));
  assertFalse(containsBeanClass(candidates,NamedStubDao.class));
}