tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Tapestry > IoC - startup
Date Sun, 03 Oct 2010 06:44:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/12/_/styles/combined.css?spaceKey=TAPESTRY&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/TAPESTRY/IoC+-+startup">IoC
- startup</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~ccordenier">Christophe
Cordenier</a>
    </h4>
        <br/>
                         <h4>Changes (2)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h2. Startup Methods <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{info:title=Since
5.2}{info} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{since:since=5.2}{since}
<br></td></tr>
            <tr><td class="diff-unchanged" > <br>Instead of making contributions
to the RegistryStartup service configuration you can provide startup methods inside your modules.
A startup method is a static or instance method of a module annotated with [Startup|../apidocs/org/apache/tapestry5/ioc/annotations/Startup.html]
annotation. Each module is allowed to contain several startup methods. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="IoC-startup-RegistryStartup"></a>Registry Startup</h2>

<p>It is possible to provide extra logic to be executed at Registry startup, by making
contributions to the RegistryStartup service configuration.</p>

<p>The values contributed are Runnable objects. The configuration is ordered, so it
is possible to control in what order the objects are executed.</p>

<p>RegistryStartup occurs after eager loaded services are instantiated.</p>

<p>Here's an example of a module that makes a contribution.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">public</span> class MyModule
{
  <span class="code-keyword">public</span> <span class="code-keyword">static</span>
void contributeRegistryStartup(OrderedConfiguration&lt;<span class="code-object">Runnable</span>&gt;
configuration)
  {
    configuration.add(<span class="code-quote">"MyContributionName"</span>, <span
class="code-keyword">new</span> <span class="code-object">Runnable</span>()
{ ... });
  }
}</pre>
</div></div>

<p>Generally, these contributions are in the form of inner classes; if they were services,
they could just be eagerly loaded.</p>

<h2><a name="IoC-startup-StartupMethods"></a>Startup Methods</h2>



<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Added in
5.2</b><br /></td></tr></table></div>
<div style="border-right: 20px solid #E0EFFF;border-left: 20px solid #E0EFFF;"></div>

<p>Instead of making contributions to the RegistryStartup service configuration you
can provide startup methods inside your modules. A startup method is a static or instance
method of a module annotated with <span class="error">&#91;Startup|../apidocs/org/apache/tapestry5/ioc/annotations/Startup.html&#93;</span>
annotation. Each module is allowed to contain several startup methods.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">public</span> class MyModule
{

  @Startup
  <span class="code-keyword">public</span> <span class="code-keyword">static</span>
void initMyApplication(Logger logger, MyService service)
  {
    logger.info(<span class="code-quote">"Starting up..."</span>);

    service.init();
  }
}
</pre>
</div></div>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/TAPESTRY/IoC+-+startup">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=23338494&revisedVersion=4&originalVersion=3">View
Changes</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message