Package org.springframework.beans.factory.config

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


    try {
      ClassPathXmlApplicationContext parentSpringAppContext =
          new ClassPathXmlApplicationContext();
      parentSpringAppContext.refresh();
      ConfigurableListableBeanFactory factory = parentSpringAppContext.
          getBeanFactory();
      factory.registerSingleton("guiceInjector",
          injector);
      factory.registerSingleton("passwordEncoder",
          injector.getInstance(PasswordEncoder.class));
      factory.registerSingleton("ambariLocalUserService",
          injector.getInstance(AmbariLocalUserDetailsService.class));
      factory.registerSingleton("ambariLdapAuthenticationProvider",
          injector.getInstance(AmbariLdapAuthenticationProvider.class));
      factory.registerSingleton("internalTokenAuthenticationFilter",
          injector.getInstance(InternalTokenAuthenticationFilter.class));
      factory.registerSingleton("ambariInternalAuthenticationProvider",
          injector.getInstance(AmbariInternalAuthenticationProvider.class));

      //Spring Security xml config depends on this Bean

      String[] contextLocations = {SPRING_CONTEXT_LOCATION};
View Full Code Here


    try {
      ClassPathXmlApplicationContext parentSpringAppContext =
          new ClassPathXmlApplicationContext();
      parentSpringAppContext.refresh();
      ConfigurableListableBeanFactory factory = parentSpringAppContext.
          getBeanFactory();
      factory.registerSingleton("guiceInjector",
          injector);
      factory.registerSingleton("passwordEncoder",
          injector.getInstance(PasswordEncoder.class));
      factory.registerSingleton("ambariLocalUserService",
          injector.getInstance(AmbariLocalUserDetailsService.class));
      factory.registerSingleton("ambariLdapAuthenticationProvider",
          injector.getInstance(AmbariLdapAuthenticationProvider.class));
      //Spring Security xml config depends on this Bean

      String[] contextLocations = {SPRING_CONTEXT_LOCATION};
      ClassPathXmlApplicationContext springAppContext = new
View Full Code Here

  public static Map<String, BeanDefinition> getApplicationBeanDefinitions() {
    Map<String, BeanDefinition> map = new HashMap<String, BeanDefinition>();
    XmlWebApplicationContext context = (XmlWebApplicationContext) SpringApplicationContextHolder
        .getWebApplicationContext();
    ConfigurableListableBeanFactory factory = context.getBeanFactory();
    String[] names = factory.getBeanDefinitionNames();
    for (String name : names) {
      map.put(name, factory.getBeanDefinition(name));
    }
    return map;
  }
View Full Code Here

  public static Map<String, BeanDefinition> getDispatcherBeanDefinitions() {
    Map<String, BeanDefinition> map = new HashMap<String, BeanDefinition>();
    XmlWebApplicationContext context = (XmlWebApplicationContext) SpringDispatcherContextHolder
        .getWebApplicationContext();
    ConfigurableListableBeanFactory factory = context.getBeanFactory();
    String[] names = factory.getBeanDefinitionNames();
    for (String name : names) {
      map.put(name, factory.getBeanDefinition(name));
    }
    return map;
  }
View Full Code Here

  public void findsBeanDefinitionInParentBeanFactory() {

    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    beanFactory.registerBeanDefinition("factory", new RootBeanDefinition(LocalContainerEntityManagerFactoryBean.class));

    ConfigurableListableBeanFactory childFactory = new DefaultListableBeanFactory(beanFactory);

    BeanFactoryPostProcessor processor = new EntityManagerBeanDefinitionRegistrarPostProcessor();
    processor.postProcessBeanFactory(childFactory);

    assertThat(beanFactory.getBeanDefinitionCount(), is(2));
View Full Code Here

public class AppInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {

    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {

        ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();

        DataSource dataSource = createDataSource();

        beanFactory.registerSingleton("dataSource", dataSource);

        beanFactory.registerSingleton("myTransactionManager", createPlatformTransactionManager(dataSource));

    }
View Full Code Here

    public static void registerSingletons(AbstractApplicationContext context,ItsNatHttpServlet itsNatServlet)
    {
        ItsNatServletConfig itsNatServletCofig = itsNatServlet.getItsNatServletConfig();
        ItsNatServletContext itsNatServletContext = itsNatServletCofig.getItsNatServletContext();
       
        ConfigurableListableBeanFactory beanFact = context.getBeanFactory();
        beanFact.registerSingleton(itsNatHttpServletBean,itsNatServlet);
        beanFact.registerSingleton(itsNatServletConfigBean,itsNatServletCofig);
        beanFact.registerSingleton(itsNatServletContextBean,itsNatServletContext);
    }
View Full Code Here

    public static <B> void registerBean(ApplicationContext applicationContext,
            B instance) throws BeansException {

        if (applicationContext instanceof GenericApplicationContext) {
            ConfigurableListableBeanFactory beanFactory =
                    ((GenericApplicationContext) applicationContext).getBeanFactory();
            beanFactory.registerSingleton(generateName(beanFactory, createBeanDefinition(instance)), instance);
        } else if (applicationContext instanceof AbstractRefreshableWebApplicationContext) {
            ConfigurableListableBeanFactory beanFactory =
                    ((AbstractRefreshableWebApplicationContext) applicationContext).getBeanFactory();
            beanFactory.registerSingleton(generateName(beanFactory, createBeanDefinition(instance)), instance);
        }
    }
View Full Code Here

    public static <B> void registerBean(ApplicationContext applicationContext,
            B instance) throws BeansException {

        if (applicationContext instanceof GenericApplicationContext) {
            ConfigurableListableBeanFactory beanFactory = ((GenericApplicationContext) applicationContext)
                    .getBeanFactory();
            beanFactory.registerSingleton(generateName(beanFactory, createBeanDefinition(instance)), instance);
        } else if (applicationContext instanceof AbstractRefreshableWebApplicationContext) {
            ConfigurableListableBeanFactory beanFactory = ((AbstractRefreshableWebApplicationContext)
                    applicationContext).getBeanFactory();
            beanFactory.registerSingleton(generateName(beanFactory, createBeanDefinition(instance)), instance);
        }
    }
View Full Code Here

                + ": no view controller name found for view " + viewId);
        }

        // Look up the definition with the specified name.
        ConfigurableApplicationContext appContext = getApplicationContext();
        ConfigurableListableBeanFactory beanFactory = appContext.getBeanFactory();
        BeanDefinition beanDefinition = beanFactory.getBeanDefinition(viewControllerName);

        if (beanDefinition.getBeanClassName().equals(ScopedProxyFactoryBean.class.getName()))
        {
            // The BeanDefinition we found is one that contains a nested aop:scopedProxy tag.
            // In this case, Spring has actually renamed the original BeanDefinition which
            // contains the data we need. So here we need to look up the renamed definition.
            //
            // It would be nice if the fake definition that Spring creates had some way of
            // fetching the definition it wraps, but instead it appears that we need to
            // rely on the magic string prefix...
            beanDefinition = beanFactory.getBeanDefinition("scopedTarget." + viewControllerName);
        }

        String scopeName = beanDefinition.getScope();
       
        if (scopeName == null)
        {
            // should never happen
            throw new OrchestraException(
                "Error while processing bean " + beanName
                + ": view controller " + viewControllerName + " has no scope.");
        }

        Scope registeredScope = beanFactory.getRegisteredScope(scopeName);
        if (registeredScope == null)
        {
            throw new OrchestraException(
                "Error while processing bean " + beanName
                + ": view controller " + viewControllerName
View Full Code Here

TOP

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

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.