Beispiel #1
0
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
  */
 @Override
 public void setApplicationContext(ApplicationContext ac) throws BeansException {
   appContexts = new CopyOnWriteArraySet<ApplicationContext>();
   addApplicationContext(ac);
   this.beanFactory = ac.getAutowireCapableBeanFactory();
   super.setBeanFactory(this.beanFactory);
 }
  @Override
  protected Serializable extractSerializableFromMessage(ObjectMessage message) throws JMSException {
    Serializable bean = super.extractSerializableFromMessage(message);
    System.out.println("-------------KKOTA----------" + bean.getClass());
    beanConfigurerSupport.configureBean(bean);

    return bean;
  }
Beispiel #3
0
  public synchronized void configureBean(String bn, Object beanInstance, boolean checkWildcards) {

    if (null == appContexts) {
      return;
    }

    if (null == bn) {
      bn = getBeanName(beanInstance);
    }

    if (null == bn) {
      return;
    }
    // configure bean with * pattern style.
    if (checkWildcards) {
      configureWithWildCard(bn, beanInstance);
    }

    final String beanName = bn;
    setBeanWiringInfoResolver(
        new BeanWiringInfoResolver() {
          @Override
          public BeanWiringInfo resolveWiringInfo(Object instance) {
            if (!"".equals(beanName)) {
              return new BeanWiringInfo(beanName);
            }
            return null;
          }
        });

    for (ApplicationContext appContext : appContexts) {
      if (appContext.containsBean(bn)) {
        this.setBeanFactory(appContext.getAutowireCapableBeanFactory());
      }
    }

    try {
      // this will prevent a call into the AbstractBeanFactory.markBeanAsCreated(...)
      // which saves ALL the names into a HashSet.  For URL based configuration,
      // this can leak memory
      if (beanFactory instanceof AbstractBeanFactory) {
        ((AbstractBeanFactory) beanFactory).getMergedBeanDefinition(bn);
      }
      super.configureBean(beanInstance);
      if (LOG.isTraceEnabled()) {
        LOG.trace("Successfully performed injection,used beanName:{}", beanName);
      }
    } catch (NoSuchBeanDefinitionException ex) {
      // users often wonder why the settings in their configuration files seem
      // to have no effect - the most common cause is that they have been using
      // incorrect bean ids
      if (LOG.isDebugEnabled()) {
        LOG.debug("No matching bean {}", beanName);
      }
    }
  }
 public void afterPropertiesSet() throws Exception {
   beanConfigurerSupport.setBeanFactory(beanFactory);
   beanConfigurerSupport.setBeanWiringInfoResolver(new AnnotationBeanWiringInfoResolver());
   beanConfigurerSupport.afterPropertiesSet();
 }
Beispiel #5
0
 @Override
 public void setBeanFactory(BeanFactory beanFactory) {
   this.beanFactory = beanFactory;
   super.setBeanFactory(beanFactory);
 }
Beispiel #6
0
 @Override
 public void destroy() {
   super.destroy();
   appContexts.clear();
 }