Author: buildbot Date: Mon Apr 29 16:20:47 2013 New Revision: 860308 Log: Production update by buildbot for tapestry
Modified: websites/production/tapestry/content/cache/main.pageCache websites/production/tapestry/content/tapestry-inversion-of-control-faq.html Modified: websites/production/tapestry/content/cache/main.pageCache ============================================================================== Binary files - no diff available. Modified: websites/production/tapestry/content/tapestry-inversion-of-control-faq.html ============================================================================== --- websites/production/tapestry/content/tapestry-inversion-of-control-faq.html (original) +++ websites/production/tapestry/content/tapestry-inversion-of-control-faq.html Mon Apr 29 16:20:47 2013 @@ -72,10 +72,6 @@ table.ScrollbarTable td.ScrollbarNextIco <div class="navmenu" style="float:right; background:#eee; margin:3px; padding:3px"><table class="tableview" width="100%"><tr><th colspan="1" rowspan="1" style="padding: 3px 3px 3px 0px">Related Articles</th></tr><tr><td colspan="1" rowspan="1"> <span class="icon icon-page" title="Page">Page:</span> - <a shape="rect" href="tapestry-inversion-of-control-faq.html">Tapestry Inversion of Control FAQ</a> - - </td></tr><tr><td colspan="1" rowspan="1"> - <span class="icon icon-page" title="Page">Page:</span> <a shape="rect" href="ioc.html">IoC</a> </td></tr><tr><td colspan="1" rowspan="1"> @@ -86,6 +82,10 @@ table.ScrollbarTable td.ScrollbarNextIco <span class="icon icon-page" title="Page">Page:</span> <a shape="rect" href="tapestry-ioc-overview.html">Tapestry IoC Overview</a> + </td></tr><tr><td colspan="1" rowspan="1"> + <span class="icon icon-page" title="Page">Page:</span> + <a shape="rect" href="tapestry-inversion-of-control-faq.html">Tapestry Inversion of Control FAQ</a> + </td></tr></table> </div> @@ -107,7 +107,7 @@ table.ScrollbarTable td.ScrollbarNextIco <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent"> <pre class="code-java"> -<span class="code-keyword">public</span> class MyServiceImpl <span class="code-keyword">implements</span> MyService, RegistryShutdownListener +<span class="code-keyword">public</span> class MyServiceImpl <span class="code-keyword">implements</span> MyService { <span class="code-keyword">private</span> <span class="code-object">boolean</span> shuttingDown; @@ -123,15 +123,16 @@ table.ScrollbarTable td.ScrollbarNextIco @PostInjection <span class="code-keyword">public</span> void startupService(RegistryShutdownHub shutdownHub) { - shutdownHub.addRegistryShutdownListener(<span class="code-keyword">this</span>); + shutdownHub.addRegistryShutdownListener(<span class="code-keyword">new</span> <span class="code-object">Runnable</span>() + { + <span class="code-keyword">public</span> void run() + { + shuttingDown = <span class="code-keyword">true</span>; + + workerThread.interrupt(); + } + }); } - - <span class="code-keyword">public</span> void registryDidShutdown() - { - shuttingDown = <span class="code-keyword">true</span>; - - workerThread.interrupt(); - } } </pre> </div></div> @@ -144,6 +145,14 @@ table.ScrollbarTable td.ScrollbarNextIco <div class="panelMacro"><table class="noteMacro"><colgroup span="1"><col span="1" width="24"><col span="1"></colgroup><tr><td colspan="1" rowspan="1" valign="top"><img align="middle" src="/images/confluence/warning.gif" width="16" height="16" alt="" border="0"></td><td colspan="1" rowspan="1">Be careful not to invoke methods on any service proxy objects as they will also be shutting down with the Registry. A RegistryShutdownListener should not be reliant on anything outside of itself.</td></tr></table></div> +<h3><a shape="rect" name="TapestryInversionofControlFAQ-HowdoImakemyservicestartupwiththerestoftheapplication%2Cratherthanlazily%3F"></a>How do I make my service startup with the rest of the application, rather than lazily?</h3> + +<p>Tapestry services are designed to be <em>lazy</em>; they are only fully realized when needed: when the first method on the service interface is invoked.</p> + +<p>Sometimes a service does extra work that is desirable at application startup: examples may be registering message handlers with a JMS implementation, or setting up indexing. Since the service's constructor (or <a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/PostInjection.html">@PostInjection</a> methods) are not invoked until the service is realized.</p> + +<p>The solution is the <a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/EagerLoad.html">@EagerLoad</a> annotation; service implementation classes marked with this annotation are loaded when the Registry is first startup, rather than lazily.</p> + <style type="text/css">/*<![CDATA[*/ table.ScrollbarTable {border: none;padding: 3px;width: 100%;padding: 3px;margin: 0px;background-color: #f0f0f0} table.ScrollbarTable td.ScrollbarPrevIcon {text-align: center;width: 16px;border: none;}