a few considerations:
using convention plugin to create/determine action name
http://struts.apache.org/2.x/docs/convention-plugin.html
1)
Action name overrides using annotations as in the example @Action("FOO-BAR")
"FOO-BAR" is action name
2)
struts.convention.action.name.lowercase=false "foo-bar" is action name
action locational characteristics:
By default, the Convention plugin will find all action classes
-that implement com.opensymphony.xwork2.Action or
-whose name ends with the word Action in specific packages.
so these Action classes will be 'found'
com.example.actions.MainAction
com.example.actions.products.Display (implements com.opensymphony.xwork2.Action)
com.example.struts.company.details.ShowCompanyDetailsActionso we now know how
the action name is created and found
SPRING:
http://struts.apache.org/2.x/docs/spring-plugin.html
first we need to define StrutsSpringObjectFactory via Struts.properties
struts.objectFactory = org.apache.struts2.spring.StrutsSpringObjectFactory
struts.xml
<struts>
<constant name="struts.objectFactory"
value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
</struts>
//you configured your action-name as defined above with annotation and /or
lowercase
struts.objectFactory.spring.autoWire = name
//you can use Spring to auto-create actions or beans
if you are using context in your xml for params you will need the
ContextLoaderListener defined in web.xml e.g.
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
//application-context.xml contains the name and the class for the 'wired' bean
as defined here
<?xml version="1.0" encoding="UTF-8<!DOCTYPE beans PUBLIC "-//SPRING//DTD
BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="autodetect">
<bean id="personManager" class="com.acme.PersonManager"/>
</beans>
//be aware that name assignment will be 'personManager'
//USING context other then applicationContext you can specify so here
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>
</context-param>
<!-- struts.xml association of Action objects to Spring (personManager)
configuration -->
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-default.xml"/>
<package name="secure" namespace="/secure" extends="default">
<action name="PersonNameAction" class="personManager">
<result>bar.ftl</result>
</action>
</package>
</struts><!-- class is defined as PersonManager (NOTE personManager was
assigned by the spring configuration) -->
<!-- if you prefer thread safe implementations you can configure your bean to
specify singleton false -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="autodetect">
<bean id="bar" class="com.my.BarClass" singleton="false"/>
</beans>
additional considerations
struts.objectFactory.spring.autoWire.alwaysRespect=true
(currently alwaysRespect false has a bug assigned)
//choosing autowire type is a safe choice as Action name might be changed
modified by convention-plugin mods
struts.objectFactory.spring.autoWire=type
I hope this makes the topic clearer to you
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: Wed, 3 Jun 2009 04:31:15 -0700
> From: [email protected]
> To: [email protected]
> Subject: Re: Introducing Spring in Struts2 Project
>
>
> Alee:
>
> I just checked the link to the PDFs and they are working fine. If you
> still
> cannot get them to open, email me at phillips1021 at hotmail dot com and I
> will send the PDFs
> to you. The PDFs have the link to the source code and explain how to
> build the projects.
>
> Struts 2 has a plug-in that enables the Struts framework to communicate
> with the Spring framework.
>
> Check out the references for my blog articles for much more information.
>
> Bruce
>
> @ philips
> i have downloaded the pdf's from your site. thanks. i am going through it
> and i guess those are pretty helpful. still have not started implementing
> those
>
> Quick Question:
> integrating spring in struts through spring plugin, does not mean that you
> have struts as your base framework and then adding spring as one part of it?
> in my knowledge, spring is the base framework and other are added on top of
> it.
>
> ..alee
> http://techboard.wordpress.com
>
>
>
> On Wed, Jun 3, 2009 at 10:18 AM, Wes Wannemacher <[email protected]> wrote:
>
> > I don't know about Bruce's blog, but I know the source samples for the
> > book
> > he
> > mentioned are available here -
> >
> > struts2inpractice.googlecode.com
> >
> > (btw, thanks for the plug Bruce)
> >
> > -Wes
> >
> >
> --
> View this message in context:
> http://www.nabble.com/Introducing-Spring-in-Struts2-Project-tp23832610p23849807.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
_________________________________________________________________
Insert movie times and more without leaving Hotmail®.
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009