Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
-none-

-none-

2007-08-14       - By Laurie Harper

 Back
Adam Hardy wrote:
> Um? It's not obvious what the rationale is, I assure you. Of course the
> Spring object factory is feature rich, but which particular features was
> it? Or perhaps the lack of obviousness is just an artifact of the way I
> have learnt the ropes of Struts2.

I don't think it's a case of any specific feature of Spring being the
reason for making this functionality available; the point is that it
allows you to leverage any and all of the Spring richness in the
instantiation of your action instances. If you don't want any of it, you
don't need to use it.

> It seems like struts2 says:
>
> 1: here's struts.xml where you configure your actions
> 2: here's an autowiring interceptor and it uses Spring to grab
> dependencies for your actions
> 3: by the way, if you want to list all your actions in Spring as well as
> in struts.xml, it's kind of cool.
>
> Of course at point 3 I immediately think, why would I want to do that
> again? Can't I save myself the effort of doing it twice? I guess I'm
> expecting an attribute on the action node that would define an object
> factory reference where the action bean would be found, instead of a class.

Isn't that what you get when you use the Spring plugin? Instead of your
action mappings specifying fully qualified class names, they specify a
logical name which is defined by your Spring configuration. With that
done you have all the advantages of Spring, such as dependency
injection, the ability to substitute alternative implementations of your
actions (or their dependencies) by swapping out configurations, etc.

Again, the Spring plugin is entirely optional. If you don't want or need
any of the facilities Spring provides to help manage instances of your
actions, you don't need to use the Spring plugin. If you *do* want to
take advantage of any of Spring's features at this layer, the plugin
makes that facility available to you.

L.

> Laurie Harper on 13/08/07 22:11, wrote:
>> Um, to allow all the capabilities of Spring (dependency injection, AOP
>> or whatever) to be applied to action instances?
>>
>> L.
>>
>> Adam Hardy wrote:
>>> Thanks for the explanation. What would you say the main rationale is
>>> then for using Spring as a factory for the actions instead of the
>>> struts objectfactory?
>>>
>>> Regards
>>> Adam
>>>
>>> MLENEVEUT@(protected) on 13/08/07 08:13, wrote:
>>>> Did you set this in your struts.xml ?
>>>>
>>>> <constant name="struts.objectFactory" value="spring" />
>>>>
>>>> or
>>>>
>>>> <constant name="struts.objectFactory" value>>>> "org.myorg
.mySpringContextFactory" />
>>>>
>>>> For Autowiring, it's enable by default. But you can customise it :
>>>> http://struts.apache.org/2.0.9/docs/spring-plugin.html
>>>>
>>>> The framework enables "autowiring" by default. (Autowiring means to
>>>> look for objects defined in Spring with the same name as your object
>>>> property). To change the wiring mode, modify the spring.autowire
>>>> property.
>>>> Wiring Mode
>>>> struts.objectFactory.spring.autoWire = type
>>>> The autowire property can be set to several options.
>>>> name Auto-wire by matching the name of the bean in Spring with the
>>>> name of the property in your action. This is the default type
>>>> Auto-wire by looking for a bean registered with Spring of the same
>>>> type as the property in your action. This requires you to have only
>>>> one bean of this type registered with Spring auto Spring will
>>>> attempt to auto-detect the best method for auto-wiring your action
>>>> constructor Spring will auto-wire the parameters of the bean's
>>>> constructor
>>>> By default, the framework will at least try to use Spring to create
>>>> all its objects. If the object cannot be created by Spring, then the
>>>> framework will create the object itself.
>>>>
>>>>
>>>> Adam Hardy <ahardy.struts@(protected)> 12/08/2007 11:25
>>>> Veuillez r?pondre ?
>>>> "Struts Users Mailing List" <user@(protected)>
>>>>
>>>> A
>>>> Struts Users Mailing List <user@(protected)>
>>>> cc
>>>>
>>>> Objet
>>>> [S2] autowiring with hand rolled factory
>>>>
>>>> I'm sure I saw some references to this in the documentation before
>>>> but I can't find it again now that I need it.
>>>>
>>>> I have my own context factory for Spring which I want to plug into
>>>> the struts framework, but I can't work out how to set up the
>>>> autowiring interceptor .
>>>>
>>>> It seems I must replace ActionAutoWiringInterceptor and configure it
>>>> as 'anotherAutowiring' or similar. Would that be correct?
>>>>
>>>> While I'm on the subject, I'm not planning on setting up my actions in
>>>> Spring, so I assume that struts2 will use its own ObjectFactory to do
>>>> this. What is the reasoning behind the functionality that allows me to
>>>> set up my actions in Spring? Is it just the rich configuration
>>>> possibilities that Spring offers which struts wants to harness?



-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.