take a look at the top of /WEB-INF/application-context.xml you should see 
default-autowire attribute as in <beans default-autowire="byName">

static field inclusion
if your spring configuration references 
http://www.springframework.org/schema/util/spring-util.xsd

e.g. save this under http://localhost/schema/util/spring-util-eric.xsd
<xsd:element name="constant">
<xsd:annotation>
    <xsd:documentation>
Reference a public, static field on a type and expose its value as a bean. For 
example 
      <code>
        <util:constant static-field="java.lang.Integer.MAX_VALUE"/>
     </code>            
    </xsd:documentation>
</xsd:annotation>
<xsd:annotation>
  <xsd:documentation>
   this is a public static field eric wants to include
   <code>
     <util:constant id="string-static-field" static-field="My dog has fleas"/>
   </code>
  </xsd:documentation>
</xsd:annotation>

you'll need your tweaked version of spring-util.xsd with annotation for your 
static field

web.xml :
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
        xsi:Eric="localhost/schema/util/spring-util-eric.xsd">

    <Eric:constant id="string-static-field" static-field="My dog has fleas"/>

    <bean id="nestedCustomTagBean" class="test.beans.TestBean" 
scope="prototype">
        <property name="someList">
            <list>
                <util:constant static-field="java.lang.Integer.MIN_VALUE"/>
            </list>
        </property>
        <property name="someMap">
            <map>
                <entry>
                    <key><value>0</value></key>
                    <Eric:constant static-field="string-static-field"/>
                </entry>
            </map>
      </property>
    </bean>     

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: Mon, 24 Aug 2009 09:30:49 -0700
> Subject: Re: Struts2SpringObjectFactory autowiring and injecting static       
> property values when
> From: musa...@gmail.com
> To: user@struts.apache.org
> 
> I can't remember for sure but there are few flags in the spring plugin
> to configure autowiring.
> 
> musachy
> 
> On Mon, Aug 24, 2009 at 2:36 AM, Obinna<obi...@gmail.com> wrote:
> > I'm using struts with the spring object factory
> >
> > I'm trying to package some struts configuration such that I can define some
> > commonly reused actions in a base struts configuration file and extend in
> > multiple projects. This means that my struts configuration will be generic
> > but my spring configuration (which I use to inject project-specific
> > properties and other beans in to my action) will be project specific.
> >
> > In this base struts configuration, since I can't predict what the struts
> > action beans will be named in the project-specific spring configuration
> > file, I need to provide the full class name for each action. However, when
> > used in a project (which extends this base struts configuration), I would
> > like to be able to inject properties into this action from my spring
> > configuration. In my spring configuration, I provide a bean entry for the
> > struts action and inject some other bean references and some static
> > properties. Using the default autowiring strategy, upon instantiation of the
> > action (prototype scope), the spring object factory recognizes the spring
> > configuration for the action and "autowires" it to inject ONLY THE OTHER
> > BEAN REFERENCES. ANY STATIC PROPERTIES SET IN CONFIGURATION ARE IGNORED.
> > Looking through the spring code, this is due to the standard implementation
> > of the the autowireByName()  method being called in Spring's
> > AbstractAutowireCapableBeanFactory class.
> >
> > My question: Is there currently some combination of spring wiring
> > strategies/ struts configuration that will allow me to do what I want which
> > is to define my struts action by Class name and yet manage it it fully
> > (including static-property injection) from my spring configuration file? I
> > suspect others will have run in to this same issue before.
> >
> > Thanks,
> > - Eric
> >
> 
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 

_________________________________________________________________
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1

Reply via email to