Examples of BeanPostProcessor


Examples of org.springframework.beans.factory.config.BeanPostProcessor

    private void addListenerAutodetectBeanPostProcessor() {
        if (!(applicationContext instanceof ConfigurableApplicationContext)) {
            log.warn("Cannot autodetect WorkingMemoryListeners; beanFactory is not instanceof ConfigurableApplicationContext: beanFactory.class=" + applicationContext.getClass());
        } else {
            ConfigurableListableBeanFactory beanFactory = ((ConfigurableApplicationContext)applicationContext).getBeanFactory();
            beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
                public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
                    return bean;
                }
                public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
                    if (bean == WorkingMemoryFactoryBean.this) {
View Full Code Here

Examples of org.springframework.beans.factory.config.BeanPostProcessor

    XmlBeanDefinitionReader xbdr=new XmlBeanDefinitionReader(_factory);
    xbdr.setBeanClassLoader(_appClassLoader);
    xbdr.loadBeanDefinitions(new ClassPathResource(_configPath.toString(), _appClassLoader));

    // install aspects around Spring Bean initialisation...
    _factory.addBeanPostProcessor(new BeanPostProcessor() {
       public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException {
         return beforeInitialization(bean, name);
       }

  public Object postProcessAfterInitialization(Object bean, String name) throws BeansException {
View Full Code Here

Examples of org.springframework.beans.factory.config.BeanPostProcessor

    internalBeanFactory.copyConfigurationFrom(containingFactory);

    // Filter out BeanPostProcessors that are part of the AOP infrastructure,
    // since those are only meant to apply to beans defined in the original factory.
    for (Iterator it = internalBeanFactory.getBeanPostProcessors().iterator(); it.hasNext();) {
      BeanPostProcessor postProcessor = (BeanPostProcessor) it.next();
      if (postProcessor instanceof AopInfrastructureBean) {
        it.remove();
      }
    }
View Full Code Here

Examples of org.springframework.beans.factory.config.BeanPostProcessor

  public void testBeanPostProcessorWithWrappedObjectAndDisposableBean() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    RootBeanDefinition bd = new RootBeanDefinition(BeanWithDisposableBean.class);
    lbf.registerBeanDefinition("test", bd);
    lbf.addBeanPostProcessor(new BeanPostProcessor() {
      public Object postProcessBeforeInitialization(Object bean, String beanName) {
        return new TestBean();
      }

      public Object postProcessAfterInitialization(Object bean, String beanName) {
View Full Code Here

Examples of org.springframework.beans.factory.config.BeanPostProcessor

  public void testBeanPostProcessorWithWrappedObjectAndDestroyMethod() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    RootBeanDefinition bd = new RootBeanDefinition(BeanWithDestroyMethod.class);
    bd.setDestroyMethodName("close");
    lbf.registerBeanDefinition("test", bd);
    lbf.addBeanPostProcessor(new BeanPostProcessor() {
      public Object postProcessBeforeInitialization(Object bean, String beanName) {
        return new TestBean();
      }

      public Object postProcessAfterInitialization(Object bean, String beanName) {
View Full Code Here

Examples of org.springframework.beans.factory.config.BeanPostProcessor

    m.put("name", "Roderick");
    parent.registerBeanDefinition("rod",
      new RootBeanDefinition(TestBean.class, new MutablePropertyValues(m)));

    this.factory = new XmlBeanFactory(new ClassPathResource("test.xml", getClass()), parent);
    this.factory.addBeanPostProcessor(new BeanPostProcessor() {
      public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException {
        if (bean instanceof TestBean) {
          ((TestBean) bean).setPostProcessed(true);
        }
        if (bean instanceof DummyFactory) {
View Full Code Here

Examples of org.springframework.beans.factory.config.BeanPostProcessor

      // Register the (JDK 1.5 specific) LoadTimeWeaverAwareProcessor.
      try {
        Class ltwapClass = ClassUtils.forName(
            "org.springframework.context.weaving.LoadTimeWeaverAwareProcessor",
            AbstractApplicationContext.class.getClassLoader());
        BeanPostProcessor ltwap = (BeanPostProcessor) BeanUtils.instantiateClass(ltwapClass);
        ((BeanFactoryAware) ltwap).setBeanFactory(beanFactory);
        beanFactory.addBeanPostProcessor(ltwap);
      }
      catch (ClassNotFoundException ex) {
        throw new IllegalStateException("Spring's LoadTimeWeaverAwareProcessor class is not available");
View Full Code Here

Examples of org.springframework.beans.factory.config.BeanPostProcessor

  /**
   * Register the given BeanPostProcessor beans.
   */
  private void registerBeanPostProcessors(ConfigurableListableBeanFactory beanFactory, List postProcessors) {
    for (Iterator it = postProcessors.iterator(); it.hasNext();) {
      BeanPostProcessor postProcessor = (BeanPostProcessor) it.next();
      beanFactory.addBeanPostProcessor(postProcessor);
    }
  }
View Full Code Here

Examples of org.springframework.beans.factory.config.BeanPostProcessor

  public Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName)
      throws BeansException {

    Object result = existingBean;
    for (Iterator it = getBeanPostProcessors().iterator(); it.hasNext();) {
      BeanPostProcessor beanProcessor = (BeanPostProcessor) it.next();
      result = beanProcessor.postProcessBeforeInitialization(result, beanName);
    }
    return result;
  }
View Full Code Here

Examples of org.springframework.beans.factory.config.BeanPostProcessor

  public Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName)
      throws BeansException {

    Object result = existingBean;
    for (Iterator it = getBeanPostProcessors().iterator(); it.hasNext();) {
      BeanPostProcessor beanProcessor = (BeanPostProcessor) it.next();
      result = beanProcessor.postProcessAfterInitialization(result, beanName);
    }
    return result;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.