thanks for the links 

struts.objectFactory.spring.autoWire.alwaysRespect
Whether the autowire strategy should always be
used, or if the framework should try to guess the best strategy based
on the situation
false for backwards-compatibility 
t
//code works perfect as long as 
struts.objectFactory.spring.autoWire.alwaysRespect=true
//look at the alternative which nosedives into else guesswork which may return 
a null bean

com.opensymphony.xwork2.spring.SpringObjectFactory
    /*** @param clazz
         * @param extraContext
         * @throws Exception*/
    @Override
    public Object buildBean(Class clazz, Map<String, Object> extraContext) 
throws Exception {
        Object bean;
        try {
//follow autowire strategy or use legacy approach which mixes injection 
strategies
            if (alwaysRespectAutowireStrategy) {
                // Leave the creation up to Spring
                bean = autoWiringFactory.createBean(clazz, autowireStrategy, 
false);
                injectApplicationContext(bean);
                return injectInternalBeans(bean);
            } else {
//wrong if you want type!="name"
//     autoWiringFactory = findAutoWiringBeanFactory(this.appContext); only in 
setContext 
           bean = autoWiringFactory.autowire(clazz, 
AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false);

           bean = 
autoWiringFactory.applyBeanPostProcessorsBeforeInitialization(bean, 
bean.getClass().getName());
//only defined in 
org.springframework.beans.factory.config.AutowireCapableBeanFactory
// Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, 
String beanName)

// We don't need to call the init-method since one won't be registered.
                bean = 
autoWiringFactory.applyBeanPostProcessorsAfterInitialization(bean, 
bean.getClass().getName());
//only defined in 
org.springframework.beans.factory.config.AutowireCapableBeanFactory
//    Object applyBeanPostProcessorsAfterInitialization(Object existingBean, 
String beanName)

                return autoWireBean(bean, autoWiringFactory);
//returns NULL
            }
        } catch (UnsatisfiedDependencyException e) {
            if (LOG.isErrorEnabled())
                LOG.error("Error building bean", e);
            // Fall back
            return autoWireBean(super.buildBean(clazz, extraContext), 
autoWiringFactory);
        }
    }

    public Object autoWireBean(Object bean, AutowireCapableBeanFactory 
autoWiringFactory) {
        if (autoWiringFactory != null) {
            autoWiringFactory.autowireBeanProperties(bean,
                    autowireStrategy, false);
        }
        injectApplicationContext(bean);
        injectInternalBeans(bean);

        return bean;
    }

com.opensymphony.xwork2.ObjectFactory
    /*** Build a generic Java object of the given type.
     * @param clazz the type of Object to build
     * @param extraContext a Map of extra context which uses the same keys as 
the {...@link com.opensymphony.xwork2.ActionContext}
     */
    public Object buildBean(Class clazz, Map extraContext) throws Exception {
        return clazz.newInstance();
    }

   private void injectApplicationContext(Object bean) {
        if (bean instanceof ApplicationContextAware) {
            ((ApplicationContextAware) bean).setApplicationContext(appContext);
        }
    }
    /*** @param obj */
    protected Object injectInternalBeans(Object obj) {
        if (obj != null && container != null) {
            container.inject(obj);
        }
        return obj;
    }

//a very good likelihood that the returned bean will be null in the else 
condition as it is never created

Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




> Date: Tue, 2 Jun 2009 08:47:59 -0700
> From: bphill...@ku.edu
> To: user@struts.apache.org
> Subject: Re: Introducing Spring in Struts2 Project
> 
> 
> I've written a couple of articles on my blog about integrating Spring with
> Struts 2.
> 
> See:
> 
> http://www.brucephillips.name/blog/index.cfm/2008/10/17/Using-Struts-2-and-Spring-Frameworks-Together
> 
> http://www.brucephillips.name/blog/index.cfm/2009/3/7/Using-Spring-In-A-Struts-2-Web-Application
>  
> 
> Also I'd recommend getting the early release of Struts 2 In Practice
> (Manning Publishing),  which has an excellent chapter on using Spring in a
> Struts 2 application:
> 
> http://www.manning.com/wannemacher/
> 
> Bruce
> 
> 
> I have been assigned a task to introduce spring in struts 2 project. I have
> been novice at both technologies. Right now i am going through the project
> to analyze what is actually going and i thought to get some advice from
> experts sitting across the globe.
> 
> What could be the key areas which will get effected if we introduce spring
> in struts 2. What things should i look for.
> 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/Introducing-Spring-in-Struts2-Project-tp23832610p23835401.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 

_________________________________________________________________
Hotmail® has ever-growing storage! Don’t worry about storage limits. 
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009

Reply via email to