Package org.springframework.beans.factory.annotation

Examples of org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor


    assertTrue(bean.destroyCalled);
  }

  public void testPostConstructAndPreDestroyWithManualConfiguration() {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    InitDestroyAnnotationBeanPostProcessor bpp = new InitDestroyAnnotationBeanPostProcessor();
    bpp.setInitAnnotationType(PostConstruct.class);
    bpp.setDestroyAnnotationType(PreDestroy.class);
    bf.addBeanPostProcessor(bpp);
    bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(AnnotatedInitDestroyBean.class));

    AnnotatedInitDestroyBean bean = (AnnotatedInitDestroyBean) bf.getBean("annotatedBean");
    assertTrue(bean.initCalled);
View Full Code Here


    bpp2.postProcessBeforeDestruction(bean, "annotatedBean");
    assertTrue(bean.destroyCalled);
  }

  public void testSerializationWithManualConfiguration() throws Exception {
    InitDestroyAnnotationBeanPostProcessor bpp = new InitDestroyAnnotationBeanPostProcessor();
    bpp.setInitAnnotationType(PostConstruct.class);
    bpp.setDestroyAnnotationType(PreDestroy.class);
    InitDestroyAnnotationBeanPostProcessor bpp2 = (InitDestroyAnnotationBeanPostProcessor)
        SerializationTestUtils.serializeAndDeserialize(bpp);

    AnnotatedInitDestroyBean bean = new AnnotatedInitDestroyBean();
    bpp2.postProcessBeforeDestruction(bean, "annotatedBean");
    assertTrue(bean.destroyCalled);
  }
View Full Code Here

  }

  @Test
  public void testPostConstructAndPreDestroyWithManualConfiguration() {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    InitDestroyAnnotationBeanPostProcessor bpp = new InitDestroyAnnotationBeanPostProcessor();
    bpp.setInitAnnotationType(PostConstruct.class);
    bpp.setDestroyAnnotationType(PreDestroy.class);
    bf.addBeanPostProcessor(bpp);
    bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(AnnotatedInitDestroyBean.class));

    AnnotatedInitDestroyBean bean = (AnnotatedInitDestroyBean) bf.getBean("annotatedBean");
    assertTrue(bean.initCalled);
View Full Code Here

    assertTrue(bean.destroyCalled);
  }

  @Test
  public void testSerializationWithManualConfiguration() throws Exception {
    InitDestroyAnnotationBeanPostProcessor bpp = new InitDestroyAnnotationBeanPostProcessor();
    bpp.setInitAnnotationType(PostConstruct.class);
    bpp.setDestroyAnnotationType(PreDestroy.class);
    InitDestroyAnnotationBeanPostProcessor bpp2 = (InitDestroyAnnotationBeanPostProcessor)
        SerializationTestUtils.serializeAndDeserialize(bpp);

    AnnotatedInitDestroyBean bean = new AnnotatedInitDestroyBean();
    bpp2.postProcessBeforeDestruction(bean, "annotatedBean");
    assertTrue(bean.destroyCalled);
  }
View Full Code Here

        configurationProcessor.setBeanFactory(factory);
        configurationProcessor.setConfigurationProvider(confProvider);
        configurationProcessor.setOrder(2);
        factory.addBeanPostProcessor(configurationProcessor);
       
        InitDestroyAnnotationBeanPostProcessor annotationProcessor = new InitDestroyAnnotationBeanPostProcessor();
        annotationProcessor.setInitAnnotationType(PostConstruct.class);
        annotationProcessor.setDestroyAnnotationType(PreDestroy.class);
        factory.addBeanPostProcessor(annotationProcessor);


    }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor

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.