Package org.springframework.beans.factory.config

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


      applicationContext = (ConfigurableWebApplicationContext) contextLoader
          .initWebApplicationContext(servletContext);
      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


    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();
          ctx.removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
          applicationContext.close();
        }
        getContextLoader().closeWebApplicationContext(ctx);
//        org.apache.commons.logging.LogFactory.releaseAll();
View Full Code Here

      applicationContext = (ConfigurableWebApplicationContext) loader
          .initWebApplicationContext(servletContext);
      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();

      // create a wrapper around our primary context
      BeanFactoryReference beanfactoryRef = new ContextBeanFactoryReference(
          applicationContext);

      // set it in the root servlet context
      servletContext.setAttribute("bean.factory.ref", beanfactoryRef);

      // set a remoting codec factory for AMF use
      servletContext.setAttribute("remoting.codec.factory", parentFactory
          .getBean("remotingCodecFactory"));

      server = (Server) parentFactory.getBean("red5.server");

      clientRegistry = (ClientRegistry) factory
          .getBean("global.clientRegistry");

      globalInvoker = (ServiceInvoker) factory
          .getBean("global.serviceInvoker");

      globalStrategy = (MappingStrategy) factory
          .getBean("global.mappingStrategy");

      global = (GlobalScope) factory.getBean("global.scope");
      logger.debug("GlobalScope: " + global);
      global.setServer(server);
      global.register();
      global.start();

      globalResolver = new ScopeResolver();
      globalResolver.setGlobalScope(global);

      logger.debug("About to grab Webcontext bean for Global");
      Context globalContext = (Context) factory.getBean("global.context");
      globalContext.setCoreBeanFactory(parentFactory);
      globalContext.setClientRegistry(clientRegistry);
      globalContext.setServiceInvoker(globalInvoker);
      globalContext.setScopeResolver(globalResolver);
      globalContext.setMappingStrategy(globalStrategy);

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

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

    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

        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();

          ctx
              .removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
          applicationContext.close();
        }
View Full Code Here

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


  @Override
  public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
    if (beanFactory instanceof ConfigurableBeanFactory) {
      ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;
      cbf.setBeanExpressionResolver(new StandardBeanExpressionResolver() {
        @Override
        protected void customizeEvaluationContext(StandardEvaluationContext evalContext) {
          evalContext.addMethodResolver(new CabConfigurationReflectiveMethodResolver());
        }
      });
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

    return string.getBytes(charset);
  }

  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

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.