Package org.springframework.beans.factory.config

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


  /**
   * Resolves the specified interceptor names to Advisor objects.
   * @see #setInterceptorNames
   */
  private Advisor[] resolveInterceptorNames() {
    ConfigurableBeanFactory cbf =
        (this.beanFactory instanceof ConfigurableBeanFactory ? (ConfigurableBeanFactory) this.beanFactory : null);
    List advisors = new ArrayList();
    for (int i = 0; i < this.interceptorNames.length; i++) {
      String beanName = this.interceptorNames[i];
      if (cbf == null || !cbf.isCurrentlyInCreation(beanName)) {
        Object next = this.beanFactory.getBean(beanName);
        advisors.add(this.advisorAdapterRegistry.wrap(next));
      }
    }
    return (Advisor[]) advisors.toArray(new Advisor[advisors.size()]);
View Full Code Here


        if (!(beanFactory instanceof ConfigurableBeanFactory))
        {
            throw new IllegalStateException("Not running in a ConfigurableBeanFactory: " + beanFactory);
        }
        ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;

        ScopedBeanTargetSource scopedTargetSource = new ScopedBeanTargetSource(
                scope, conversationName, targetBeanName, objectFactory, beanFactory);

        ProxyFactory pf = new ProxyFactory();
        pf.setProxyTargetClass(true);
        pf.setTargetSource(scopedTargetSource);

        Class beanType = beanFactory.getType(targetBeanName);
        if (beanType == null)
        {
            throw new IllegalStateException("Cannot create scoped proxy for bean '" + targetBeanName +
                    "': Target type could not be determined at the time of proxy creation.");
        }

        // Add an introduction that implements only the methods on ScopedObject.
        // Not sure if this is useful...
        ScopedObject scopedObject = new DefaultScopedObject(cbf, scopedTargetSource.getTargetBeanName());
        pf.addAdvice(new DelegatingIntroductionInterceptor(scopedObject));

        // Add the AopInfrastructureBean marker to indicate that the scoped proxy
        // itself is not subject to auto-proxying! Only its target bean is.
        // Not sure if this is needed....
        pf.addInterface(AopInfrastructureBean.class);

        return pf.getProxy(cbf.getBeanClassLoader());
    }
View Full Code Here

        }
    }

    protected final void addBeanFactory(ConfigurableBeanFactory bf)
    {
        ConfigurableBeanFactory currentBf = (ConfigurableBeanFactory) context.get(APP_CONTEXT);
        if (currentBf != null)
        {
            bf.setParentBeanFactory(currentBf);
            context.put(APP_CONTEXT, new DefaultListableBeanFactory(bf));
        }
View Full Code Here

        }
    }

    protected final void addBeanFactory(ConfigurableBeanFactory bf)
    {
        ConfigurableBeanFactory currentBf = (ConfigurableBeanFactory) context.get(APP_CONTEXT);
        if (currentBf != null)
        {
            bf.setParentBeanFactory(currentBf);
            context.put(APP_CONTEXT, new DefaultListableBeanFactory(bf));
        }
View Full Code Here

  public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType) {
    Class<?> handlerType = this.beanFactory.getType(beanName);
    A ann = AnnotationUtils.findAnnotation(handlerType, annotationType);
    if (ann == null && this.beanFactory instanceof ConfigurableBeanFactory &&
        this.beanFactory.containsBeanDefinition(beanName)) {
      ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) this.beanFactory;
      BeanDefinition bd = cbf.getMergedBeanDefinition(beanName);
      if (bd instanceof AbstractBeanDefinition) {
        AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
        if (abd.hasBeanClass()) {
          Class<?> beanClass = abd.getBeanClass();
          ann = AnnotationUtils.findAnnotation(beanClass, annotationType);
View Full Code Here

  }

  @Override
  public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
    if (converter == null && beanFactory instanceof ConfigurableBeanFactory) {
      ConfigurableBeanFactory cFB = (ConfigurableBeanFactory) beanFactory;
      ConversionService conversionService = cFB.getConversionService();

      converter = (conversionService != null ? new Converter(conversionService) : new Converter(
          cFB.getTypeConverter()));
    }
  }
View Full Code Here

    public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType) {
        Class<?> handlerType = beanFactory.getType(beanName);
        A ann = AnnotationUtils.findAnnotation(handlerType, annotationType);
        if (ann == null && beanFactory instanceof ConfigurableBeanFactory &&
                beanFactory.containsBeanDefinition(beanName)) {
            ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;
            BeanDefinition bd = cbf.getMergedBeanDefinition(beanName);
            if (bd instanceof AbstractBeanDefinition) {
                AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
                if (abd.hasBeanClass()) {
                    Class<?> beanClass = abd.getBeanClass();
                    ann = AnnotationUtils.findAnnotation(beanClass, annotationType);
View Full Code Here

      super.contextInitialized(sce);
      //get the web context
      applicationContext = (ConfigurableWebApplicationContext) servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
      logger.debug("Root context path: {}", applicationContext.getServletContext().getContextPath());

      ConfigurableBeanFactory factory = applicationContext.getBeanFactory();

      // register default
      factory.registerSingleton("default.context", applicationContext);

      // get the main factory
      parentFactory = (DefaultListableBeanFactory) factory.getParentBeanFactory();

    } catch (Throwable t) {
      logger.error("", t);
    }
View Full Code Here

    appCtx.setParent(applicationContext);
    appCtx.refresh();

    ctx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, appCtx);

    ConfigurableBeanFactory appFactory = appCtx.getBeanFactory();

    logger.debug("About to grab Webcontext bean for {}", webAppKey);
    Context webContext = (Context) appCtx.getBean("web.context");
    webContext.setCoreBeanFactory(parentFactory);
    webContext.setClientRegistry(clientRegistry);
    webContext.setServiceInvoker(globalInvoker);
    webContext.setScopeResolver(globalResolver);
    webContext.setMappingStrategy(globalStrategy);

    WebScope scope = (WebScope) appFactory.getBean("web.scope");
    scope.setServer(server);
    scope.setParent(global);
    scope.register();
    scope.start();
View Full Code Here

        // shutdown spring
        Object attr = ctx.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
        if (attr != null) {
          // get web application context from the servlet context
          ConfigurableWebApplicationContext applicationContext = (ConfigurableWebApplicationContext) attr;
          ConfigurableBeanFactory factory = applicationContext.getBeanFactory();
          // for (String scope : factory.getRegisteredScopeNames()) {
          // logger.debug("Registered scope: " + scope);
          // }
          try {
            for (String singleton : factory.getSingletonNames()) {
              logger.debug("Registered singleton: {}", singleton);
              factory.destroyScopedBean(singleton);
            }
          } catch (RuntimeException e) {
          }
          factory.destroySingletons();
          applicationContext.close();
        }
      } catch (Throwable e) {
        logger.warn("Exception {}", e);
      } finally {
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.config.ConfigurableBeanFactory

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.