Announcement Announcement Module
Collapse
No announcement yet.
Bean factory problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bean factory problem

    In our application,



    we r doing entry in web.xml

    <context class>
    XXX
    </context class>


    In XXX we are extending XmlWebApplicationContext


    and in that... we r doing
    which i dont understand

    @Override
    protected DefaultListableBeanFactory createBeanFactory()
    {

    DefaultListableBeanFactory beanFactory = super.createBeanFactory();
    beanFactory.setAllowRawInjectionDespiteWrapping(tr ue);
    return beanFactory;
    }




    And the most imp.

    we are creating our own bean factory in that we r implementing BeanFactoryAware accessing spring beans


    i understand frm overall ths is

    at application startup XXX is initialized (our own app context) and beans are created and we r accessing these beans using our own bean factory.


    Is ths correct ?

    also


    why we are implenting BeanFactoryAware for our beanfactory is it necessary?

  • #2
    You should really ask people who implemented it this way why did they do it, not us here.

    Anyway, it seems someone had problems with circular references:

    /**
    * Set whether to allow the raw injection of a bean instance into some other
    * bean's property, despite the injected bean eventually getting wrapped
    * (for example, through AOP auto-proxying).
    * <p>This will only be used as a last resort in case of a circular reference
    * that cannot be resolved otherwise: essentially, preferring a raw instance
    * getting injected over a failure of the entire bean wiring process.
    * <p>Default is "false", as of Spring 2.0. Turn this on to allow for non-wrapped
    * raw beans injected into some of your references, which was Spring 1.2's
    * (arguably unclean) default behavior.
    * <p><b>NOTE:</b> It is generally recommended to not rely on circular references
    * between your beans, in particular with auto-proxying involved.
    * @see #setAllowCircularReferences
    */
    public void setAllowRawInjectionDespiteWrapping(boolean allowRawInjectionDespiteWrapping) {
    this.allowRawInjectionDespiteWrapping = allowRawInjectionDespiteWrapping;
    }

    Comment

    Working...
    X