Package com.foreach.across.core.filters

Examples of com.foreach.across.core.filters.AnnotationBeanFilter


    }

    @Bean
    public ExposingModule serviceModule() {
      ExposingModule module = new ExposingModule( "service" );
      module.setExposeFilter( new AnnotationBeanFilter( Service.class ) );

      return module;
    }
View Full Code Here


    }

    @Bean
    public ExposingModule controllerModule() {
      ExposingModule module = new ExposingModule( "controller" );
      module.setExposeFilter( new AnnotationBeanFilter( Controller.class ) );

      return module;
    }
View Full Code Here

   * register them with the AcrossEventPublisher.
   */
  public static void autoRegisterEventHandlers( ApplicationContext applicationContext,
                                                AcrossEventPublisher publisher ) {
    BeanFilter eventHandlerFilter =
        new BeanFilterComposite( new AnnotationBeanFilter( true, AcrossEventHandler.class ),
                                 new AnnotationBeanFilter( Controller.class ) );
    Collection<Object> handlers =
        ApplicationContextScanner.findSingletonsMatching( applicationContext, eventHandlerFilter ).values();

    for ( Object handler : handlers ) {
      publisher.subscribe( handler );
View Full Code Here

   * By default all @Service and @Controller beans are exposed, along with any other beans
   * annotated explicitly with @Exposed or created through an @Exposed BeanFactory.
   */
  @SuppressWarnings("unchecked")
  public static BeanFilter defaultExposeFilter() {
    return new BeanFilterComposite( new AnnotationBeanFilter( Service.class ),
                                    new AnnotationBeanFilter( true, Exposed.class ) );
  }
View Full Code Here

   * @return List of beans, never null.
   */
  public static Collection<Object> findBeansWithAnnotation( ApplicationContext context,
                                                            Class<? extends Annotation> annotation ) {

    return findSingletonsMatching( context, new AnnotationBeanFilter( true, annotation ) ).values();
  }
View Full Code Here

    assertEquals( 7, definitions.size() );
  }

  @Test
  public void filterOnServiceAnnotation() {
    BeanFilter filter = new AnnotationBeanFilter( Service.class );

    Map<String, Object> beans = ApplicationContextScanner.findSingletonsMatching( applicationContext, filter );
    assertEquals( 1, beans.size() );
    assertSame( beanWithServiceAnnotation, beans.get( "beanWithServiceAnnotation" ) );
View Full Code Here

    assertTrue( definitions.containsKey( "prototypeExposedBean" ) );
  }

  @Test
  public void filterOnExposedAnnotation() {
    BeanFilter filter = new AnnotationBeanFilter( Exposed.class );

    Map<String, Object> beans = ApplicationContextScanner.findSingletonsMatching( applicationContext, filter );
    assertEquals( 3, beans.size() );
    assertSame( beanWithExposedAnnotation, beans.get( "beanWithExposedAnnotation" ) );
    assertSame( otherBeanWithExposedAnnotation, beans.get( "otherBeanWithExposedAnnotation" ) );
View Full Code Here

    assertTrue( definitions.containsKey( "prototypeExposedBean" ) );
  }

  @Test
  public void filterOnRefreshableAnnotation() {
    BeanFilter filter = new AnnotationBeanFilter( Refreshable.class );

    Map<String, Object> beans = ApplicationContextScanner.findSingletonsMatching( applicationContext, filter );
    assertEquals( 3, beans.size() );
    assertSame( beanWithRefreshableAnnotation, beans.get( "beanWithRefreshableAnnotation" ) );
    assertSame( otherBeanWithExposedAnnotation, beans.get( "otherBeanWithExposedAnnotation" ) );
View Full Code Here

TOP

Related Classes of com.foreach.across.core.filters.AnnotationBeanFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.