Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for 
change notification.

The following page has been changed by ErikVullings:
http://wiki.apache.org/tapestry/Tapestry4Spring

------------------------------------------------------------------------------
  = Combining Tapestry 4 and Spring =
  
  How can you reference Spring beans from Tapestry 4? In earlier versions of 
Tapestry, the most common method was to extend the BaseEngine class. However, 
in Tapestry 4 the BaseEngine class is deprecated, and we now need to extend 
SpringBeanFactoryHolder.
+ 
+ Add an entry in your hivemodule.xml:
+ {{{
+ <implementation service-id="hivemind.lib.DefaultSpringBeanFactoryHolder">
+   <invoke-factory>
+     <construct autowire-services="false" 
class="engine.PersonalSpringBeanFactoryHolder">
+       <event-listener service-id="hivemind.ShutdownCoordinator" />
+       <set-object property="context" 
value="service:tapestry.globals.WebContext" />
+     </construct>
+   </invoke-factory>
+ </implementation>
+ }}}
+ Consult 
[http://jakarta.apache.org/hivemind/hivemind-lib/SpringLookupFactory.html] for 
more information.
+ 
+ == Injecting Spring Beans ==
+ 
+ You may inject beans managed by Spring into pages and components just like 
you inject anything else as described by 
[http://tapestry.apache.org/tapestry4/UsersGuide/injection.html]. You can 
describe the injection in the .page/.jwc file or using an @InjectObject 
annotation. Just use the 'spring:' prefix like:
+ {{{
+ @InjectObject("spring:name.from.applicationContext.xml")
+ }}}
+ 
+ You may also wire Spring managed beans in HiveMind services such as IEngine 
services.
+ {{{
+ <service-point id="MyService" 
interface="org.apache.tapestry.engine.IEngineService">
+   <invoke-factory>
+     <construct class="engine.MyService">
+     <set-object property="springBean" value="spring:name.of.spring.bean"/>
+     </construct>
+   </invoke-factory>
+ </service-point>
+ }}}
  
  (''Basic knowledge of Java, Tapestry, and Spring assumed.'')
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to