Package com.foreach.across.core.filters

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


  private void exposeBeans( ConfigurableAcrossModuleInfo acrossModuleInfo,
                            BeanFilter exposeFilter,
                            ExposedBeanDefinitionTransformer exposeTransformer,
                            AbstractApplicationContext parentContext ) {
    BeanFilter exposeFilterToApply = exposeFilter;

    AcrossListableBeanFactory moduleBeanFactory = AcrossContextUtils.getBeanFactory(
        acrossModuleInfo );

    String[] exposedBeanNames = moduleBeanFactory.getExposedBeanNames();
View Full Code Here


   *
   * @param exposeFilters One or more filters that beans should match to be exposed to other modules.
   */
  public void addExposeFilter( BeanFilter... exposeFilters ) {
    BeanFilter[] members = exposeFilters;
    BeanFilter current = getExposeFilter();

    if ( current != null ) {
      members = new BeanFilter[members.length + 1];
      members[0] = current;
      System.arraycopy( exposeFilters, 0, members, 1, exposeFilters.length );
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

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

  @Test
  public void filterOnServiceAndExposedAnnotation() {
    BeanFilter filter = AcrossModule.defaultExposeFilter();

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

   * Scans for all AcrossEventHandler instances inside the context specified, and will
   * 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();

View Full Code Here

  @Autowired
  private BeanWithRefreshableAnnotation otherBeanWithExposedAnnotation;

  @Test
  public void filterByClass() {
    BeanFilter filter = new ClassBeanFilter( BeanWithServiceAnnotation.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 filterByInterface() {
    BeanFilter filter = new ClassBeanFilter( Marker.class );

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

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

  @Test
  public void filterByPackage() {
    BeanFilter filter = new PackageBeanFilter( "com.foreach.across.test.filters" );

    // The @Configuration class also matches as a singleton
    Map<String, Object> beans = ApplicationContextScanner.findSingletonsMatching( applicationContext, filter );
    assertEquals( 6, beans.size() );
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

TOP

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

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.