Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.BeanFactory


    {
      return beanFactory.getBeanDefinition(name);
    }
    else
    {
      BeanFactory parent = beanFactory.getParentBeanFactory();
      if ((parent != null) && (parent instanceof ConfigurableListableBeanFactory))
      {
        return getBeanDefinition((ConfigurableListableBeanFactory)parent, name);
      }
      else
View Full Code Here


    {
      return beanFactory.getBeanDefinition(name);
    }
    else
    {
      BeanFactory parent = beanFactory.getParentBeanFactory();
      if ((parent != null) && (parent instanceof ConfigurableListableBeanFactory))
      {
        return getBeanDefinition((ConfigurableListableBeanFactory)parent, name);
      }
      else
View Full Code Here

    public void testDefaultFactory()
    {
        SpringLookupFactory lf = new SpringLookupFactory();

        MockControl control = newControl(BeanFactory.class);
        BeanFactory beanFactory = (BeanFactory) control.getMock();

        MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
        ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters) fpc
                .getMock();

        lf.setDefaultBeanFactory(beanFactory);

        SpringBeanParameter param = buildParameter("fred", null);

        Object fred = new Object();

        beanFactory.getBean("fred", List.class);
        control.setReturnValue(fred);

        fp.getFirstParameter();
        fpc.setReturnValue(param);
View Full Code Here

    public void testBeanSpecificFactory()
    {
        SpringLookupFactory lf = new SpringLookupFactory();

        MockControl control = newControl(BeanFactory.class);
        BeanFactory beanFactory = (BeanFactory) control.getMock();

        MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
        ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters) fpc
                .getMock();

        SpringBeanParameter param = buildParameter("fred", beanFactory);

        Object fred = new Object();

        beanFactory.getBean("fred", List.class);
        control.setReturnValue(fred);

        fp.getFirstParameter();
        fpc.setReturnValue(param);
View Full Code Here

        // Spring setup

        ClassPathResource springBeansResource = new ClassPathResource("SpringBeans.xml",
                TestSpringLookupFactory.class);

        BeanFactory beanFactory = new XmlBeanFactory(springBeansResource);

        Registry r = buildFrameworkRegistry("SpringIntegration.xml");

        SpringBeanFactoryHolder h = (SpringBeanFactoryHolder) r.getService(
                "hivemind.lib.DefaultSpringBeanFactoryHolder",
View Full Code Here

            throw new RuntimeException(
                    "Can't locate resource descriptor in the ClassLoader: "
                            + TEST_RESOURCES_DESCRIPTOR);
        }

        BeanFactory factory = new XmlBeanFactory(new InputStreamResource(in));
        CayenneResources resources = (CayenneResources) factory.getBean(
                "TestResources",
                CayenneResources.class);

        resources.setConnectionKey(System.getProperty(CONNECTION_NAME_KEY));
View Full Code Here

    public AccessStack getAccessStack(String name) {
        return (AccessStack) beanFactory.getBean(name, AccessStack.class);
    }

    public SQLTemplateCustomizer getSQLTemplateCustomizer() {
        BeanFactory child = (BeanFactory) beanFactory.getBean(
                SQL_TEMPLATE_CUSTOMIZER,
                BeanFactory.class);
        return (SQLTemplateCustomizer) child.getBean(
                SQL_TEMPLATE_CUSTOMIZER,
                SQLTemplateCustomizer.class);
    }
View Full Code Here

                                                 String id)
    {
        T bean = null;
        try
        {
            BeanFactory beanFactory = getBeanFactory(context);

            //
            // Look for a match in the bean factory based upon id
            //
            if (id != null)
            {
                String fullID = null;
                if (context != null && context.getControlBean() != null)
                {
                    String parentID = context.getControlBean().getControlID();
                    if (parentID != null)
                        fullID = parentID + ControlBean.IDSeparator + id;
                }

                //
                // Check absolute ID first, then relative ID for a match
                //
                if (fullID != null && beanFactory.containsBean(fullID))
                    bean = (T)beanFactory.getBean(fullID, beanClass);
                else if (beanFactory.containsBean(id))
                    bean = (T)beanFactory.getBean(id, beanClass);
            }

            //
            // Look for a match based upon bean class name
            //
            String beanClassName = beanClass.getName();
            if (bean == null && beanFactory.containsBean(beanClassName))
                bean = (T)beanFactory.getBean(beanClassName, beanClass);

            if (bean != null)
            {
                //
                // Add the bean to the context passed to the constructor
View Full Code Here

     * This is marked 'protected' to enable alternative implementations to overrride the
     * behavior for how a factory will be obtained.
     */
    protected BeanFactory getBeanFactory(ControlBeanContext context)
    {
        BeanFactory beanFactory = null;

        //
        // Currently, the thread contex loader is used as the key for a class loader to
        // bean factory cache.   This mirrors the behavior of ClassPathXmlApplicationContext
        // below, which is used to load the BeanFactory.
View Full Code Here

    public ParentBeanFactoryPostProcessor(Map beans) {
        this.beans = beans;
    }
   
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        BeanFactory parent = new SimpleBeanFactory(beans);
        beanFactory.setParentBeanFactory(parent);
    }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.BeanFactory

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.