Modified: websites/production/tapestry/content/integration-testing.html
==============================================================================
--- websites/production/tapestry/content/integration-testing.html (original)
+++ websites/production/tapestry/content/integration-testing.html Wed Sep 20
12:29:16 2017
@@ -27,6 +27,15 @@
</title>
<link type="text/css" rel="stylesheet" href="/resources/space.css" />
+ <link href='/resources/highlighter/styles/shCoreCXF.css'
rel='stylesheet' type='text/css' />
+ <link href='/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet'
type='text/css' />
+ <script src='/resources/highlighter/scripts/shCore.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushXml.js'
type='text/javascript'></script>
+ <script>
+ SyntaxHighlighter.defaults['toolbar'] = false;
+ SyntaxHighlighter.all();
+ </script>
<link href="/styles/style.css" rel="stylesheet" type="text/css"/>
@@ -36,26 +45,13 @@
<div class="wrapper bs">
- <div id="navigation"><div class="nav"><ul class="alternate"><li><a
href="index.html">Home</a></li><li><a href="getting-started.html">Getting
Started</a></li><li><a href="documentation.html">Documentation</a></li><li><a
href="download.html">Download</a></li><li><a
href="about.html">About</a></li><li><a class="external-link"
href="http://www.apache.org/licenses/LICENSE-2.0">License</a></li><li><a
href="community.html">Community</a></li><li><a class="external-link"
href="http://www.apache.org/security/">Security</a></li><li><a
class="external-link" href="http://www.apache.org/">Apache</a></li><li><a
class="external-link"
href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a
class="external-link"
href="http://www.apache.org/foundation/thanks.html">Thanks</a></li></ul></div>
-
-</div>
+ <div id="navigation"><div class="nav"><ul class="alternate"><li><a
href="index.html">Home</a></li><li><a href="getting-started.html">Getting
Started</a></li><li><a href="documentation.html">Documentation</a></li><li><a
href="download.html">Download</a></li><li><a
href="about.html">About</a></li><li><a class="external-link"
href="http://www.apache.org/licenses/LICENSE-2.0">License</a></li><li><a
href="community.html">Community</a></li><li><a class="external-link"
href="http://www.apache.org/security/">Security</a></li><li><a
class="external-link" href="http://www.apache.org/">Apache</a></li><li><a
class="external-link"
href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a
class="external-link"
href="http://www.apache.org/foundation/thanks.html">Thanks</a></li></ul></div></div>
<div id="top">
- <div id="smallbanner"><div class="searchbox"
style="float:right;margin: .3em 1em .1em 1em"><span style="color: #999;
font-size: 90%">Tapestry docs, issues, wikis & blogs:</span>
-<form enctype="application/x-www-form-urlencoded" method="get"
action="http://tapestry.apache.org/search.html">
- <input type="text" name="q">
- <input type="submit" value="Search">
-</form>
-
-</div>
-
-
-<div class="emblem" style="float:left"><p><a href="index.html"><span
class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image
confluence-external-resource"
src="http://tapestry.apache.org/images/tapestry_small.png"
data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></span></a></p></div>
-
-
-<div class="title" style="float:left; margin: 0 0 0 3em"><h1
id="SmallBanner-PageTitle">Integration Testing</h1></div>
-
-</div>
+ <div id="smallbanner"><div class="searchbox"
style="float:right;margin: .3em 1em .1em 1em"><span style="color: #999;
font-size: 90%">Tapestry docs, issues, wikis & blogs:</span><form
enctype="application/x-www-form-urlencoded" method="get"
action="http://tapestry.apache.org/search.html">
+ <input type="text" name="q">
+ <input type="submit" value="Search">
+</form></div><div class="emblem" style="float:left"><p><a
href="index.html"><span class="confluence-embedded-file-wrapper"><img
class="confluence-embedded-image confluence-external-resource"
src="http://tapestry.apache.org/images/tapestry_small.png"
data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></span></a></p></div><div
class="title" style="float:left; margin: 0 0 0 3em"><h1
id="SmallBanner-PageTitle">Integration Testing</h1></div></div>
<div class="clearer"></div>
</div>
@@ -67,7 +63,20 @@
</div>
<div id="content">
- <div id="ConfluenceContent"><p><strong>Integration
testing</strong> involves the testing of larger segments of your Tapestry
module or web application, typically including the user
interface.</p><parameter ac:name="style">float:right</parameter><parameter
ac:name="title">Related Articles</parameter><parameter
ac:name="class">aui-label</parameter><rich-text-body><parameter
ac:name="showLabels">false</parameter><parameter
ac:name="showSpace">false</parameter><parameter ac:name="title">Related
Articles</parameter><parameter ac:name="cql">label = "testing" and space =
currentSpace()</parameter></rich-text-body><p>The Tapestry Test Utilities is a
small library to make it easier to build integration test suites around <a
class="external-link" href="http://www.openqa.org/selenium/"
rel="nofollow">Selenium</a> version 2.14.0.</p><p>The strategy is to start,
in-process, a Selenimum Server (which, in turn, starts and manages a web
browser), a Jetty instance (for the web brows
er to talk to), and a Selenium client (which talks to the server).</p><p>The
client is able to request URLs, fill in form data, click links, and make
assertions about output and behavior.</p><h1
id="IntegrationTesting-Usage">Usage</h1><p>The core part of this library is a
base class for you to extend your tests classes : <a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/test/SeleniumTestCase.html">SeleniumTestCase</a>.</p><p>This
class is responsible for starting an instance of Jetty to server your web
application, as well as a copy of Selenium Server. It also implements the <a
class="external-link"
href="http://release.openqa.org/selenium-remote-control/0.9.0/doc/java/"
rel="nofollow">Selenium</a> interface.</p><rich-text-body><p>Before Tapestry
5.2, your class should extend <a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/test/AbstractIntegrationTestSuite.html">AbstractIntegrationTestSuit
e</a></p></rich-text-body><p>Here's an example from one of the Tapestry
modules:</p><parameter ac:name="language">java</parameter><parameter
ac:name="title">Your Integration Test Class :
SinglePersistenceUnitIntegrationTest.java</parameter><plain-text-body>package
org.apache.tapestry5.jpa.integration.app2;
+ <div id="ConfluenceContent"><p><strong>Integration
testing</strong> involves the testing of larger segments of your Tapestry
module or web application, typically including the user interface.</p><div
class="aui-label" style="float:right" title="Related Articles"><h3>Related
Articles</h3><ul class="content-by-label"><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small aui-iconfont-page-default"
title="Page">Page:</span>
+ </div>
+ <div class="details">
+ <a href="integration-testing.html">Integration Testing</a>
+ </div> </li><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small aui-iconfont-page-default"
title="Page">Page:</span>
+ </div>
+ <div class="details">
+ <a href="unit-testing-pages-or-components.html">Unit testing pages or
components</a>
+ </div> </li></ul></div><p>The Tapestry Test Utilities is a small library to
make it easier to build integration test suites around <a
class="external-link" href="http://www.openqa.org/selenium/"
rel="nofollow">Selenium</a> version 2.14.0.</p><p>The strategy is to start,
in-process, a Selenimum Server (which, in turn, starts and manages a web
browser), a Jetty instance (for the web browser to talk to), and a Selenium
client (which talks to the server).</p><p>The client is able to request URLs,
fill in form data, click links, and make assertions about output and
behavior.</p><h1 id="IntegrationTesting-Usage">Usage</h1><p>The core part of
this library is a base class for you to extend your tests classes : <a
class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/test/SeleniumTestCase.html">SeleniumTestCase</a>.</p><p>This
class is responsible for starting an instance of Jetty to server your web
application, as well as a copy of Selenium Server.
It also implements the <a class="external-link"
href="http://release.openqa.org/selenium-remote-control/0.9.0/doc/java/"
rel="nofollow">Selenium</a> interface.</p><div
class="confluence-information-macro confluence-information-macro-note"><span
class="aui-icon aui-icon-small aui-iconfont-warning
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>Before Tapestry 5.2, your class
should extend <a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/test/AbstractIntegrationTestSuite.html">AbstractIntegrationTestSuite</a></p></div></div><p>Here's
an example from one of the Tapestry modules:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>Your Integration Test Class :
SinglePersistenceUnitIntegrationTest.java</b></div><div class="codeContent
panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package org.apache.tapestry5.jpa.integration.app2;
import org.apache.tapestry5.test.SeleniumTestCase;
import org.testng.annotations.Test;
@@ -85,7 +94,9 @@ public class SinglePersistenceUnitIntegr
assertText("//span[@id='name']", "name");
}
}
-</plain-text-body><p>With the SeleniumTestCase class, you can use basic
Selenium methods (such as open() and type()) and methods added by the
SeleniumTestCase base class (clickAndWait() and assertFieldValue()).</p><p>In
addition, the SeleniumTestCase base class extends the normal exception
reporting provided by Selenium; when a failure occurs inside Selenium server, a
more detailed message, including the current page's HTML source, is reported to
System.err.</p><h1
id="IntegrationTesting-Configuration">Configuration</h1><p>All the
configuration of your Integration Tests should be in your testng.xml file.
Tapestry provides some parameters, in order to have the right environment for
your tests.</p><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Parameter</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Value</p></th></tr><tr><td col
span="1" rowspan="1"
class="confluenceTd"><p>tapestry.web-app-folder</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>src/main/webapp</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The path to a web app</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p>tapestry.servlet-container</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>jetty7</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>the server container to use for the integration tests
(jetty7 or tomcat6)</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>tapestry.context-path</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>The context path</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p>tapestry.port</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>9090</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>The web server port</p></td></
tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>tapestry.ssl-port</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>8443</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>The web server ssl port</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p>tapestry.browser-start-command</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>*firefox</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The browser command to pass to
Selenium</p></td></tr></tbody></table></div><p>Here's an example
:</p><parameter ac:name="language">xml</parameter><parameter
ac:name="title">testng.xml</parameter><plain-text-body><suite name="Selenium
Tests Suite" annotations="1.5">
+</pre>
+</div></div><p>With the SeleniumTestCase class, you can use basic Selenium
methods (such as open() and type()) and methods added by the SeleniumTestCase
base class (clickAndWait() and assertFieldValue()).</p><p>In addition, the
SeleniumTestCase base class extends the normal exception reporting provided by
Selenium; when a failure occurs inside Selenium server, a more detailed
message, including the current page's HTML source, is reported to
System.err.</p><h1
id="IntegrationTesting-Configuration">Configuration</h1><p>All the
configuration of your Integration Tests should be in your testng.xml file.
Tapestry provides some parameters, in order to have the right environment for
your tests.</p><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Parameter</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Value</p></th></tr><tr><td colspan="
1" rowspan="1" class="confluenceTd"><p>tapestry.web-app-folder</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>src/main/webapp</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>The path to a web
app</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>tapestry.servlet-container</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>jetty7</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>the server container to use for the integration tests
(jetty7 or tomcat6)</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>tapestry.context-path</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>The context path</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p>tapestry.port</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>9090</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>The web server port</p></td></tr><tr
><td colspan="1" rowspan="1"
>class="confluenceTd"><p>tapestry.ssl-port</p></td><td colspan="1" rowspan="1"
>class="confluenceTd"><p>8443</p></td><td colspan="1" rowspan="1"
>class="confluenceTd"><p>The web server ssl port</p></td></tr><tr><td
>colspan="1" rowspan="1"
>class="confluenceTd"><p>tapestry.browser-start-command</p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p>*firefox</p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p>The browser command to pass
>to Selenium</p></td></tr></tbody></table></div><p>Here's an example :</p><div
>class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
>panelHeader pdl" style="border-bottom-width:
>1px;"><b>testng.xml</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"><suite name="Selenium Tests Suite"
annotations="1.5">
<test name="Integration Tests" enabled="true">
<parameter name="tapestry.browser-start-command" value="*googlechrome"
/>
<parameter name="tapestry.port" value="9091" />
@@ -95,7 +106,8 @@ public class SinglePersistenceUnitIntegr
</classes>
</test>
</suite>
-</plain-text-body><h1 id="IntegrationTesting-SomeInterestingTools">Some
Interesting Tools</h1><p>Here are some interesting plugins you can use to write
your integration tests.</p><ul><li>Google Chrome : <a class="external-link"
href="https://chrome.google.com/webstore/detail/ikbfbhbdjpjnalaooidkdbgjknhghhbo"
rel="nofollow">xpathOnClick</a></li><li>FireFox : <a class="external-link"
href="http://seleniumhq.org/projects/ide/" rel="nofollow">Selenium
IDE</a></li></ul></div>
+</pre>
+</div></div><h1 id="IntegrationTesting-SomeInterestingTools">Some Interesting
Tools</h1><p>Here are some interesting plugins you can use to write your
integration tests.</p><ul><li>Google Chrome : <a class="external-link"
href="https://chrome.google.com/webstore/detail/ikbfbhbdjpjnalaooidkdbgjknhghhbo"
rel="nofollow">xpathOnClick</a></li><li>FireFox : <a class="external-link"
href="http://seleniumhq.org/projects/ide/" rel="nofollow">Selenium
IDE</a></li></ul></div>
</div>
<div class="clearer"></div>
Modified:
websites/production/tapestry/content/integration-with-existing-applications.html
==============================================================================
---
websites/production/tapestry/content/integration-with-existing-applications.html
(original)
+++
websites/production/tapestry/content/integration-with-existing-applications.html
Wed Sep 20 12:29:16 2017
@@ -27,6 +27,16 @@
</title>
<link type="text/css" rel="stylesheet" href="/resources/space.css" />
+ <link href='/resources/highlighter/styles/shCoreCXF.css'
rel='stylesheet' type='text/css' />
+ <link href='/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet'
type='text/css' />
+ <script src='/resources/highlighter/scripts/shCore.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushXml.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushPlain.js'
type='text/javascript'></script>
+ <script>
+ SyntaxHighlighter.defaults['toolbar'] = false;
+ SyntaxHighlighter.all();
+ </script>
<link href="/styles/style.css" rel="stylesheet" type="text/css"/>
@@ -67,7 +77,8 @@
</div>
<div id="content">
- <div
id="ConfluenceContent"><plain-text-body>{scrollbar}</plain-text-body><h2
id="Integrationwithexistingapplications-Integrationwithexistingapplications">Integration
with existing applications</h2><p>You may have an existing JSP (or Struts,
Spring MVC, etc.) application that you want to migrate to Tapestry. It's quite
common to do this in stages, moving some functionality into Tapestry and
leaving other parts, initially, in the other system. <a
href="request-processing-faq.html">You may need to prevent Tapestry from
handling certain requests</a>.</p><h3
id="Integrationwithexistingapplications-HowdoImakeaformonaJSPsubmitintoTapestry?">How
do I make a form on a JSP submit into Tapestry?</h3><p>Tapestry's Form
component does a lot of work while an HTML form is rendering to store all the
information needed to handle the form submission in a later request; this is
all very specific to Tapestry and the particular construction of your pages and
forms; it can't be reproduc
ed from a JSP.</p><p>Fortunately, that isn't necessary: you can have a
standard HTML Form submit to a Tapestry page, you just don't get to use all of
Tapestry's built in conversion and validation logic.</p><p>All you need to know
is how Tapestry converts page class names to page names (that appear in the
URL). It's basically a matter of stripping off the
<em>root-package</em>.<code>pages</code> prefix from the fully qualified class
name. So, for example, if you are building a login screen as a JSP, you might
want to have a Tapestry page to receive the user name and password. Let's
assume the Tapestry page class is
<code>com.example.myapp.pages.LoginForm</code>; the page name will be
<code>loginform (although, since </code><span style="line-height:
1.4285715;">Tapestry is case insensitive, LoginForm would work just as
well)</span><span style="line-height: 1.4285715;">, and the URL will be
</span><code style="line-height: 1.4285715;">/loginform</code><span
style="line-height: 1.4
285715;">.</span></p><p> </p><parameter
ac:name="controls">true</parameter><parameter
ac:name="linenumbers">true</parameter><plain-text-body><form method="post"
action="/loginform">
+ <div id="ConfluenceContent"><h2
id="Integrationwithexistingapplications-Integrationwithexistingapplications">Integration
with existing applications</h2><p>You may have an existing JSP (or Struts,
Spring MVC, etc.) application that you want to migrate to Tapestry. It's quite
common to do this in stages, moving some functionality into Tapestry and
leaving other parts, initially, in the other system. <a
href="request-processing-faq.html">You may need to prevent Tapestry from
handling certain requests</a>.</p><h3
id="Integrationwithexistingapplications-HowdoImakeaformonaJSPsubmitintoTapestry?">How
do I make a form on a JSP submit into Tapestry?</h3><p>Tapestry's Form
component does a lot of work while an HTML form is rendering to store all the
information needed to handle the form submission in a later request; this is
all very specific to Tapestry and the particular construction of your pages and
forms; it can't be reproduced from a JSP.</p><p>Fortunately, that isn't n
ecessary: you can have a standard HTML Form submit to a Tapestry page, you
just don't get to use all of Tapestry's built in conversion and validation
logic.</p><p>All you need to know is how Tapestry converts page class names to
page names (that appear in the URL). It's basically a matter of stripping off
the <em>root-package</em>.<code>pages</code> prefix from the fully qualified
class name. So, for example, if you are building a login screen as a JSP, you
might want to have a Tapestry page to receive the user name and password. Let's
assume the Tapestry page class is
<code>com.example.myapp.pages.LoginForm</code>; the page name will be
<code>loginform (although, since </code><span style="line-height:
1.4285715;">Tapestry is case insensitive, LoginForm would work just as
well)</span><span style="line-height: 1.4285715;">, and the URL will be
</span><code style="line-height: 1.4285715;">/loginform</code><span
style="line-height: 1.4285715;">.</span></p><p> </p><div class="
code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<pre class="brush: java; gutter: true; theme: Default"
style="font-size:12px;"><form method="post" action="/loginform">
<input type="text" value="userName"/>
<br/>
@@ -76,19 +87,24 @@
<input type="submit" value="Login"/>
</form>
-</plain-text-body><p>On the Tapestry side, we can expect that the LoginForm
page will be activated; this means that its activate event handler will be
invoked. We can leverage this, and Tapestry's RequestParameter
annotation:</p><parameter ac:name="controls">true</parameter><parameter
ac:name="linenumbers">true</parameter><plain-text-body>public class LoginForm
+</pre>
+</div></div><p>On the Tapestry side, we can expect that the LoginForm page
will be activated; this means that its activate event handler will be invoked.
We can leverage this, and Tapestry's RequestParameter annotation:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<pre class="brush: java; gutter: true; theme: Default"
style="font-size:12px;">public class LoginForm
{
void onActivate(@RequestParameter("userName") String userName,
@RequestParameter("password") String password)
{
// Validate and store credentials, etc.
}
}
-</plain-text-body><p>The RequestParameter annotation extracts the named query
parameter from the request, coerces its type from String to the parameter type
(here, also String) and passes it into the method.</p><h3
id="Integrationwithexistingapplications-HowdoIshareinformationbetweenaJSPapplicationandtheTapestryapplication?">How
do I share information between a JSP application and the Tapestry
application?</h3><p>From the servlet container's point of view, there's no
difference between a servlet, a JSP, and an entire Tapestry application. They
all share the same ServletContext, and (once created), the same
HttpSession.</p><p>On the Tapestry side, it is very easy to read and write
session attributes:</p><parameter ac:name="controls">true</parameter><parameter
ac:name="linenumbers">true</parameter><plain-text-body>public class
ShowSearchResults
+</pre>
+</div></div><p>The RequestParameter annotation extracts the named query
parameter from the request, coerces its type from String to the parameter type
(here, also String) and passes it into the method.</p><h3
id="Integrationwithexistingapplications-HowdoIshareinformationbetweenaJSPapplicationandtheTapestryapplication?">How
do I share information between a JSP application and the Tapestry
application?</h3><p>From the servlet container's point of view, there's no
difference between a servlet, a JSP, and an entire Tapestry application. They
all share the same ServletContext, and (once created), the same
HttpSession.</p><p>On the Tapestry side, it is very easy to read and write
session attributes:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: true; theme: Default"
style="font-size:12px;">public class ShowSearchResults
{
@SessionAttribute
private SearchResults searchResults;
}
-</plain-text-body><p>Reading the instance variable <code>searchResults</code>
is instrumented to instead read the corresponding HttpSession attribute named
"searchResults". You can also specify the <code>value</code> attribute of the
SessionAttribute annotation to override the default attribute
name.</p><p>Writing to the field causes the corresponding HttpSession attribute
to be modified.</p><p>The session is automatically created as needed.</p><h3
id="Integrationwithexistingapplications-HowdoIputtheTapestryapplicationinsideafolder,toavoidconflicts?">How
do I put the Tapestry application inside a folder, to avoid
conflicts?</h3><p>Support for this was added in 5.3; see the notes on the <a
href="configuration.html">configuration
page</a>.</p><plain-text-body>{scrollbar}</plain-text-body><p> </p><p> </p><p> </p></div>
+</pre>
+</div></div><p>Reading the instance variable <code>searchResults</code> is
instrumented to instead read the corresponding HttpSession attribute named
"searchResults". You can also specify the <code>value</code> attribute of the
SessionAttribute annotation to override the default attribute
name.</p><p>Writing to the field causes the corresponding HttpSession attribute
to be modified.</p><p>The session is automatically created as needed.</p><h3
id="Integrationwithexistingapplications-HowdoIputtheTapestryapplicationinsideafolder,toavoidconflicts?">How
do I put the Tapestry application inside a folder, to avoid
conflicts?</h3><p>Support for this was added in 5.3; see the notes on the <a
href="configuration.html">configuration
page</a>.</p><p> </p><p> </p><p> </p></div>
</div>
<div class="clearer"></div>
Modified: websites/production/tapestry/content/introduction.html
==============================================================================
--- websites/production/tapestry/content/introduction.html (original)
+++ websites/production/tapestry/content/introduction.html Wed Sep 20 12:29:16
2017
@@ -36,26 +36,13 @@
<div class="wrapper bs">
- <div id="navigation"><div class="nav"><ul class="alternate"><li><a
href="index.html">Home</a></li><li><a href="getting-started.html">Getting
Started</a></li><li><a href="documentation.html">Documentation</a></li><li><a
href="download.html">Download</a></li><li><a
href="about.html">About</a></li><li><a class="external-link"
href="http://www.apache.org/licenses/LICENSE-2.0">License</a></li><li><a
href="community.html">Community</a></li><li><a class="external-link"
href="http://www.apache.org/security/">Security</a></li><li><a
class="external-link" href="http://www.apache.org/">Apache</a></li><li><a
class="external-link"
href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a
class="external-link"
href="http://www.apache.org/foundation/thanks.html">Thanks</a></li></ul></div>
-
-</div>
+ <div id="navigation"><div class="nav"><ul class="alternate"><li><a
href="index.html">Home</a></li><li><a href="getting-started.html">Getting
Started</a></li><li><a href="documentation.html">Documentation</a></li><li><a
href="download.html">Download</a></li><li><a
href="about.html">About</a></li><li><a class="external-link"
href="http://www.apache.org/licenses/LICENSE-2.0">License</a></li><li><a
href="community.html">Community</a></li><li><a class="external-link"
href="http://www.apache.org/security/">Security</a></li><li><a
class="external-link" href="http://www.apache.org/">Apache</a></li><li><a
class="external-link"
href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a
class="external-link"
href="http://www.apache.org/foundation/thanks.html">Thanks</a></li></ul></div></div>
<div id="top">
- <div id="smallbanner"><div class="searchbox"
style="float:right;margin: .3em 1em .1em 1em"><span style="color: #999;
font-size: 90%">Tapestry docs, issues, wikis & blogs:</span>
-<form enctype="application/x-www-form-urlencoded" method="get"
action="http://tapestry.apache.org/search.html">
- <input type="text" name="q">
- <input type="submit" value="Search">
-</form>
-
-</div>
-
-
-<div class="emblem" style="float:left"><p><a href="index.html"><span
class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image
confluence-external-resource"
src="http://tapestry.apache.org/images/tapestry_small.png"
data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></span></a></p></div>
-
-
-<div class="title" style="float:left; margin: 0 0 0 3em"><h1
id="SmallBanner-PageTitle">Introduction</h1></div>
-
-</div>
+ <div id="smallbanner"><div class="searchbox"
style="float:right;margin: .3em 1em .1em 1em"><span style="color: #999;
font-size: 90%">Tapestry docs, issues, wikis & blogs:</span><form
enctype="application/x-www-form-urlencoded" method="get"
action="http://tapestry.apache.org/search.html">
+ <input type="text" name="q">
+ <input type="submit" value="Search">
+</form></div><div class="emblem" style="float:left"><p><a
href="index.html"><span class="confluence-embedded-file-wrapper"><img
class="confluence-embedded-image confluence-external-resource"
src="http://tapestry.apache.org/images/tapestry_small.png"
data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></span></a></p></div><div
class="title" style="float:left; margin: 0 0 0 3em"><h1
id="SmallBanner-PageTitle">Introduction</h1></div></div>
<div class="clearer"></div>
</div>
@@ -67,7 +54,37 @@
</div>
<div id="content">
- <div id="ConfluenceContent"><parameter
ac:name="style">float:right</parameter><parameter ac:name="title">Related
Articles</parameter><parameter
ac:name="class">aui-label</parameter><rich-text-body><parameter
ac:name="showLabels">false</parameter><parameter
ac:name="showSpace">false</parameter><parameter ac:name="title">Related
Articles</parameter><parameter ac:name="cql">label = "new-users" and space =
currentSpace()</parameter></rich-text-body><h2
id="Introduction-WhatisApacheTapestry?">What is Apache Tapestry?</h2><p>Apache
Tapestry is an open-source framework for creating dynamic, robust, highly
scalable web applications in Java. Tapestry complements and builds upon the
standard Java Servlet API, and so it works in any servlet container or
application server.</p><p>Tapestry divides a web application into a set of
pages, each constructed from components. This provides a consistent structure,
allowing the Tapestry framework to assume responsibility for key concerns
such as URL construction and dispatch, persistent state storage on the client
or on the server, user input validation, localization/internationalization, and
exception reporting. Developing Tapestry applications involves creating HTML
templates using plain HTML, and adding a small java class for each. In
Tapestry, you create your application in terms of objects, and the methods and
properties of those objects – and specifically not in terms of URLs and
query parameters. Tapestry brings true object oriented development to Java web
applications.</p><p>Tapestry is specifically designed to make creating new
components very easy, as this is a routine approach when building
applications.</p><p>Tapestry is architected to scale from tiny, single-page
applications all the way up to massive applications consisting of hundreds of
individual pages, developed by large, diverse teams. Tapestry easily integrates
with any kind of backend, including JEE, Spring and Hibernate.</p><p>It's more t
han what you can do with Tapestry ... it's also how you do it! Tapestry is a
vastly productive environment. Java developers love it because they can make
Java code changes and see them immediately ... no redeploy, no restart! And
it's blazingly fast to boot (even when files have changed). Designers love it
because Tapestry templates are so close to ordinary HTML, without all the cruft
and confusion seen in <a href="tapestry-for-jsf-users.html">JavaServer
Pages</a>. Managers love it because it makes it easy for large teams to work
together productively, and because they know important features (including
localization) are baked right in. Once you work in Tapestry there's no going
back!</p><p>Tapestry is released under the Apache Software License 2.0.</p><h2
id="Introduction-ThirdPartyLibraries,TutorialsandResources">Third Party
Libraries, Tutorials and Resources</h2><p>A number of third party libraries,
tutorials and resources are listed on the <a href="modules.html">Modules</a> pa
ge.</p><h2 id="Introduction-AboutReleasesandSnapshots">About Releases and
Snapshots</h2><p>Most users will want to use the latest stable release of
Tapestry, and for that your best bet for new projects is to use the Quickstart
Maven archetype to create your initial Tapestry project, as described on the <a
href="getting-started.html">Getting Started</a> page. The Quickstart archetype
generates a full, working project directory. For upgrading existing projects,
just use the Maven dependency listed on the <a
href="download.html">Download</a> page.</p><p>You can also pull down Tapestry
modules in the form of binary and source JARs from the <a
class="external-link" href="http://search.maven.org/#browse" rel="nofollow"
title="1738327132">Maven Central repository</a>.</p><p>Tapestry itself is built
using Gradle, which makes it really easy to download the source and build it
yourself, either the whole project, or just one single module.</p><p>The use of
Maven and Gradle has let us move w
ith great speed, providing preview releases and snapshots.</p><p>Snapshots are
intermediate versions of releases, with "-SNAPSHOT" at the end of the version
number. Maven notices that -SNAPSHOT suffix and handles the dependency
specially. It knows that snapshot releases can change frequently, so it will
keep checking (at least once a day, maybe more often) to see if there's an
updated version of the snapshot.</p><p>A nightly build process on Tapestry's
continuous integration server creates new snapshots every
night.</p><p>Snapshots don't go in the Maven central repository (that's
reserved for full releases). Instead, they go into the Tapestry snapshots
repository at <a class="external-link"
href="https://repository.apache.org/content/groups/snapshots/org/apache/tapestry/">https://repository.apache.org/content/groups/snapshots/org/apache/tapestry/</a>.</p><p>To
access the snapshot repository, just add <code>-DremoteRepositories=<span
class="nolink">http://repository.apache.org/snaps
hots/</span></code> to the command line when running
Maven.</p><p>Documentation on this site sometimes refers to the latest snapshot
... that is, it is often ahead of the last official release, with
version-specific differences clearly marked. In some cases, it is written as if
the snapshot release is stable. For example, if documentation refers to version
5.4.x and that hasn't been released yet, you can try 5.4.x-SNAPSHOT.</p></div>
+ <div id="ConfluenceContent"><div class="aui-label"
style="float:right" title="Related Articles"><h3>Related Articles</h3><ul
class="content-by-label"><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small aui-iconfont-page-default"
title="Page">Page:</span>
+ </div>
+ <div class="details">
+ <a href="tapestry-for-jsf-users.html">Tapestry for JSF Users</a>
+ </div> </li><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small aui-iconfont-page-default"
title="Page">Page:</span>
+ </div>
+ <div class="details">
+ <a href="tapestry-tutorial.html">Tapestry Tutorial</a>
+ </div> </li><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small aui-iconfont-page-default"
title="Page">Page:</span>
+ </div>
+ <div class="details">
+ <a href="principles.html">Principles</a>
+ </div> </li><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small aui-iconfont-page-default"
title="Page">Page:</span>
+ </div>
+ <div class="details">
+ <a href="getting-started.html">Getting Started</a>
+ </div> </li><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small aui-iconfont-page-default"
title="Page">Page:</span>
+ </div>
+ <div class="details">
+ <a href="introduction.html">Introduction</a>
+ </div> </li></ul></div><h2 id="Introduction-WhatisApacheTapestry?">What is
Apache Tapestry?</h2><p>Apache Tapestry is an open-source framework for
creating dynamic, robust, highly scalable web applications in Java. Tapestry
complements and builds upon the standard Java Servlet API, and so it works in
any servlet container or application server.</p><p>Tapestry divides a web
application into a set of pages, each constructed from components. This
provides a consistent structure, allowing the Tapestry framework to assume
responsibility for key concerns such as URL construction and dispatch,
persistent state storage on the client or on the server, user input validation,
localization/internationalization, and exception reporting. Developing Tapestry
applications involves creating HTML templates using plain HTML, and adding a
small java class for each. In Tapestry, you create your application in terms of
objects, and the methods and properties of those objects – and
specifically no
t in terms of URLs and query parameters. Tapestry brings true object oriented
development to Java web applications.</p><p>Tapestry is specifically designed
to make creating new components very easy, as this is a routine approach when
building applications.</p><p>Tapestry is architected to scale from tiny,
single-page applications all the way up to massive applications consisting of
hundreds of individual pages, developed by large, diverse teams. Tapestry
easily integrates with any kind of backend, including JEE, Spring and
Hibernate.</p><p>It's more than what you can do with Tapestry ... it's also how
you do it! Tapestry is a vastly productive environment. Java developers love it
because they can make Java code changes and see them immediately ... no
redeploy, no restart! And it's blazingly fast to boot (even when files have
changed). Designers love it because Tapestry templates are so close to ordinary
HTML, without all the cruft and confusion seen in <a href="tapestry-for-jsf-use
rs.html">JavaServer Pages</a>. Managers love it because it makes it easy for
large teams to work together productively, and because they know important
features (including localization) are baked right in. Once you work in Tapestry
there's no going back!</p><p>Tapestry is released under the Apache Software
License 2.0.</p><h2
id="Introduction-ThirdPartyLibraries,TutorialsandResources">Third Party
Libraries, Tutorials and Resources</h2><p>A number of third party libraries,
tutorials and resources are listed on the <a href="modules.html">Modules</a>
page.</p><h2 id="Introduction-AboutReleasesandSnapshots">About Releases and
Snapshots</h2><p>Most users will want to use the latest stable release of
Tapestry, and for that your best bet for new projects is to use the Quickstart
Maven archetype to create your initial Tapestry project, as described on the <a
href="getting-started.html">Getting Started</a> page. The Quickstart archetype
generates a full, working project directory. For upgr
ading existing projects, just use the Maven dependency listed on the <a
href="download.html">Download</a> page.</p><p>You can also pull down Tapestry
modules in the form of binary and source JARs from the <a
class="external-link" href="http://search.maven.org/#browse" title="1738327132"
rel="nofollow">Maven Central repository</a>.</p><p>Tapestry itself is built
using Gradle, which makes it really easy to download the source and build it
yourself, either the whole project, or just one single module.</p><p>The use of
Maven and Gradle has let us move with great speed, providing preview releases
and snapshots.</p><p>Snapshots are intermediate versions of releases, with
"-SNAPSHOT" at the end of the version number. Maven notices that -SNAPSHOT
suffix and handles the dependency specially. It knows that snapshot releases
can change frequently, so it will keep checking (at least once a day, maybe
more often) to see if there's an updated version of the snapshot.</p><p>A
nightly build proce
ss on Tapestry's continuous integration server creates new snapshots every
night.</p><p>Snapshots don't go in the Maven central repository (that's
reserved for full releases). Instead, they go into the Tapestry snapshots
repository at <a class="external-link"
href="https://repository.apache.org/content/groups/snapshots/org/apache/tapestry/">https://repository.apache.org/content/groups/snapshots/org/apache/tapestry/</a>.</p><p>To
access the snapshot repository, just add <code>-DremoteRepositories=<span
class="nolink">http://repository.apache.org/snapshots/</span></code> to the
command line when running Maven.</p><p>Documentation on this site sometimes
refers to the latest snapshot ... that is, it is often ahead of the last
official release, with version-specific differences clearly marked. In some
cases, it is written as if the snapshot release is stable. For example, if
documentation refers to version 5.4.x and that hasn't been released yet, you
can try 5.4.x-SNAPSHOT.</p></div>
</div>
<div class="clearer"></div>
Modified:
websites/production/tapestry/content/ioc-cookbook-basic-services-and-injection.html
==============================================================================
---
websites/production/tapestry/content/ioc-cookbook-basic-services-and-injection.html
(original)
+++
websites/production/tapestry/content/ioc-cookbook-basic-services-and-injection.html
Wed Sep 20 12:29:16 2017
@@ -27,6 +27,16 @@
</title>
<link type="text/css" rel="stylesheet" href="/resources/space.css" />
+ <link href='/resources/highlighter/styles/shCoreCXF.css'
rel='stylesheet' type='text/css' />
+ <link href='/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet'
type='text/css' />
+ <script src='/resources/highlighter/scripts/shCore.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushXml.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushPlain.js'
type='text/javascript'></script>
+ <script>
+ SyntaxHighlighter.defaults['toolbar'] = false;
+ SyntaxHighlighter.all();
+ </script>
<link href="/styles/style.css" rel="stylesheet" type="text/css"/>
@@ -67,7 +77,7 @@
</div>
<div id="content">
- <div
id="ConfluenceContent"><plain-text-body>{scrollbar}</plain-text-body>
+ <div id="ConfluenceContent">
<p>The starting point for Tapestry IOC services and injection is knowing a few
conventions: what to name your classes, what packages to put them in and so
forth.</p>
@@ -89,18 +99,21 @@
<p>The PropertyAccess service is defined inside TapestryIOCModule's bind()
method:</p>
-<plain-text-body>
+<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
public static void bind(ServiceBinder binder)
{
. . .
binder.bind(PropertyAccess.class, PropertyAccessImpl.class);
binder.bind(ExceptionAnalyzer.class, ExceptionAnalyzerImpl.class);
. . .
- }</plain-text-body>
+ }</pre>
+</div></div>
<p>This example includes <a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/services/ExceptionAnalyzer.html">ExceptionAnalyzer</a>,
because it has a dependency on PropertyAccess:</p>
-<plain-text-body>
+<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
public class ExceptionAnalyzerImpl implements ExceptionAnalyzer
{
private final PropertyAccess propertyAccess;
@@ -110,7 +123,8 @@ public class ExceptionAnalyzerImpl imple
}
. . .
-}</plain-text-body>
+}</pre>
+</div></div>
<p>And that's the essence of Tapestry IoC right there; the bind() plus the
constructor is <em>all</em> that's necessary.</p>
@@ -132,7 +146,8 @@ public class ExceptionAnalyzerImpl imple
<p>Tapestry defines two such services, in the <a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/TapestryModule.html">TapestryModule</a>.</p>
-<plain-text-body>
+<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
@Marker(ClasspathProvider.class)
public AssetFactory buildClasspathAssetFactory(ResourceCache resourceCache,
@@ -149,7 +164,8 @@ public class ExceptionAnalyzerImpl imple
public AssetFactory buildContextAssetFactory(ApplicationGlobals globals)
{
return new ContextAssetFactory(request, globals.getContext());
- }</plain-text-body>
+ }</pre>
+</div></div>
<p>Service builder methods are used here for two purposes: For the
ClasspathAssetFactory, we are registering the new service as a listener of
events from another service. For the ContextAssetFactory, we are extracting a
value from an injected service and passing <em>that</em> to the constructor.</p>
@@ -159,7 +175,8 @@ public class ExceptionAnalyzerImpl imple
<p>Here's an example. Again, we've jumped the gun with this <em>service
contributor method</em> (we'll get into the why and how of these later), but
you can see how Tapestry is figuring out which service to inject based on the
presence of those annotations:</p>
-<plain-text-body>
+<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
public void contributeAssetSource(MappedConfiguration<String,
AssetFactory> configuration,
@ContextProvider
AssetFactory contextAssetFactory,
@@ -169,11 +186,11 @@ public class ExceptionAnalyzerImpl imple
{
configuration.add("context", contextAssetFactory);
configuration.add("classpath", classpathAssetFactory);
- }</plain-text-body>
+ }</pre>
+</div></div>
<p>This is far from the final word on injection and disambiguation; we'll be
coming back to this concept repeatedly. And in later chapters of the cookbook,
we'll also go into more detail about the many other concepts present in this
example. The important part is that Tapestry <em>primarily</em> works off the
parameter type (at the point of injection), but when that is insufficient
(you'll know ... there will be an error) you can provide additional
information, in the form of annotations, to straighten things out.</p>
-
-<plain-text-body>{scrollbar}</plain-text-body></div>
+</div>
</div>
<div class="clearer"></div>
Modified:
websites/production/tapestry/content/ioc-cookbook-overriding-ioc-services.html
==============================================================================
---
websites/production/tapestry/content/ioc-cookbook-overriding-ioc-services.html
(original)
+++
websites/production/tapestry/content/ioc-cookbook-overriding-ioc-services.html
Wed Sep 20 12:29:16 2017
@@ -27,6 +27,16 @@
</title>
<link type="text/css" rel="stylesheet" href="/resources/space.css" />
+ <link href='/resources/highlighter/styles/shCoreCXF.css'
rel='stylesheet' type='text/css' />
+ <link href='/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet'
type='text/css' />
+ <script src='/resources/highlighter/scripts/shCore.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushXml.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushPlain.js'
type='text/javascript'></script>
+ <script>
+ SyntaxHighlighter.defaults['toolbar'] = false;
+ SyntaxHighlighter.all();
+ </script>
<link href="/styles/style.css" rel="stylesheet" type="text/css"/>
@@ -67,12 +77,15 @@
</div>
<div id="content">
- <div
id="ConfluenceContent"><plain-text-body>{scrollbar}</plain-text-body><h1
id="IoCCookbook-OverridingIoCServices-OverridingTapestryIoCServices">Overriding
Tapestry IoC Services</h1><p>Tapestry is designed to be easy to customize, and
the IoC container is the key to that customizability.</p><p>One of Tapestry's
most important activities is resolving injected objects; that is, when Tapestry
is building an object or service and sees a constructor parameter or a field,
it must decide what value to plug in. Most of the time, the injected object is
a service defined elsewhere within the Tapestry IoC container.</p><p>However,
there are cases where you might want to override how Tapestry operates in some
specific way.</p><p>The strategy used to determine what object gets injected is
<a href="injection-in-detail.html">defined inside Tapestry IoC itself</a>;
thus we can take advantage of several features of the Tapestry IoC container in
order to take control over specific
injections.</p><h2
id="IoCCookbook-OverridingIoCServices-ContributingaServiceOverride">Contributing
a Service Override</h2><p>In most cases, services are injected by matching
just the type; there is no @<a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/InjectService.html">InjectService</a>
annotation, just a method or constructor parameter whose type matches the
service's interface.</p><p>In this case, it is very easy to supply your own
alternate implementation of a service, by <em>contributing</em><em> a Service
Override</em> in your module class (usually AppModule.java), like
this:</p><parameter ac:name="title">AppModule.java
(partial)</parameter><parameter
ac:name="lang">java</parameter><plain-text-body>
@Contribute(ServiceOverride.class)
+ <div id="ConfluenceContent"><h1
id="IoCCookbook-OverridingIoCServices-OverridingTapestryIoCServices">Overriding
Tapestry IoC Services</h1><p>Tapestry is designed to be easy to customize, and
the IoC container is the key to that customizability.</p><p>One of Tapestry's
most important activities is resolving injected objects; that is, when Tapestry
is building an object or service and sees a constructor parameter or a field,
it must decide what value to plug in. Most of the time, the injected object is
a service defined elsewhere within the Tapestry IoC container.</p><p>However,
there are cases where you might want to override how Tapestry operates in some
specific way.</p><p>The strategy used to determine what object gets injected is
<a href="injection-in-detail.html">defined inside Tapestry IoC itself</a>;
thus we can take advantage of several features of the Tapestry IoC container in
order to take control over specific injections.</p><h2
id="IoCCookbook-OverridingI
oCServices-ContributingaServiceOverride">Contributing a Service
Override</h2><p>In most cases, services are injected by matching just the type;
there is no @<a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/InjectService.html">InjectService</a>
annotation, just a method or constructor parameter whose type matches the
service's interface.</p><p>In this case, it is very easy to supply your own
alternate implementation of a service, by <em>contributing</em><em> a Service
Override</em> in your module class (usually AppModule.java), like this:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>AppModule.java
(partial)</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"> @Contribute(ServiceOverride.class)
public static void
setupApplicationServiceOverrides(MappedConfiguration<Class,Object>
configuration)
{
configuration.addInstance(SomeServiceType.class,
SomeServiceTypeOverrideImpl.class);
}
-</plain-text-body><p>The name of the method is not important, as long as the
@<a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Contribute.html">Contribute</a>
annotation is present on the method.</p><p>In this example, we are using
<code>addInstance()</code> which will instantiate the indicated class and
handle dependency resolution. (Be careful with this, because in some cases,
resolving dependencies of the override class can require checking against the
ServiceOverrides service, and you'll get a runtime exception about
ServiceOverrides requiring itself!).</p><p>Sometimes you'll want to define the
override as a service of its own. This is useful if you want to inject a Logger
specific to the service, or if the overriding implementation needs a <a
href="tapestry-ioc-configuration.html">service configuration</a>:</p><parameter
ac:name="title">AppModule.java (partial)</parameter><parameter
ac:name="lang">java</parameter><
plain-text-body> public static void bind(ServiceBinder binder)
+</pre>
+</div></div><p>The name of the method is not important, as long as the @<a
class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Contribute.html">Contribute</a>
annotation is present on the method.</p><p>In this example, we are using
<code>addInstance()</code> which will instantiate the indicated class and
handle dependency resolution. (Be careful with this, because in some cases,
resolving dependencies of the override class can require checking against the
ServiceOverrides service, and you'll get a runtime exception about
ServiceOverrides requiring itself!).</p><p>Sometimes you'll want to define the
override as a service of its own. This is useful if you want to inject a Logger
specific to the service, or if the overriding implementation needs a <a
href="tapestry-ioc-configuration.html">service configuration</a>:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bot
tom-width: 1px;"><b>AppModule.java (partial)</b></div><div class="codeContent
panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"> public static void bind(ServiceBinder binder)
{
binder.bind(SomeServiceType.class,
SomeServiceTypeOverrideImpl.class).withId("SomeServiceTypeOverride");
}
@@ -82,11 +95,14 @@
{
configuration.add(SomeServiceType.class, override);
}
-</plain-text-body><p>Here we're defining a service using the module's
<code>bind()</code> method.</p><p>Every service in the IoC container must have
a unique id, that's why we used the <code>withId()</code> method; if we we
hadn't, the default service id would have been "SomeServiceType" which is a
likely conflict with the very service we're trying to override.</p><p>We can
inject our overriding implementation of SomeServiceType using the special @<a
class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Local.html">Local</a>
annotation, which indicates that a service within the same module only should
be injected (that is, services of the indicated type in other modules are
ignored). Without @Local, there would be a problem because the override
parameter would need to be resolved using the MasterObjectProvider and,
ultimately, the ServiceOverride service; this would cause Tapestry to throw an
exception indicating that ServiceOverrid
e depends on itself. We defuse that situation by using @Local, which prevents
the MasterObjectProvider service from being used to resolve the override
parameter.</p><h2
id="IoCCookbook-OverridingIoCServices-DecoratingServices">Decorating
Services</h2><p>Another option is to <a
href="tapestry-ioc-decorators.html">decorate</a> the existing service. Perhaps
you want to extend some of the behavior of the service but keep the
rest.</p><p>Alternately, this approach is useful to override a service that is
matched using marker annotations.</p><parameter ac:name="title">AppModule.java
(partial)</parameter><parameter
ac:name="lang">java</parameter><plain-text-body> public SomeServiceType
decorateSomeServiceType(final SomeServiceType delegate)
+</pre>
+</div></div><p>Here we're defining a service using the module's
<code>bind()</code> method.</p><p>Every service in the IoC container must have
a unique id, that's why we used the <code>withId()</code> method; if we we
hadn't, the default service id would have been "SomeServiceType" which is a
likely conflict with the very service we're trying to override.</p><p>We can
inject our overriding implementation of SomeServiceType using the special @<a
class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Local.html">Local</a>
annotation, which indicates that a service within the same module only should
be injected (that is, services of the indicated type in other modules are
ignored). Without @Local, there would be a problem because the override
parameter would need to be resolved using the MasterObjectProvider and,
ultimately, the ServiceOverride service; this would cause Tapestry to throw an
exception indicating that ServiceOverride depe
nds on itself. We defuse that situation by using @Local, which prevents the
MasterObjectProvider service from being used to resolve the override
parameter.</p><h2
id="IoCCookbook-OverridingIoCServices-DecoratingServices">Decorating
Services</h2><p>Another option is to <a
href="tapestry-ioc-decorators.html">decorate</a> the existing service. Perhaps
you want to extend some of the behavior of the service but keep the
rest.</p><p>Alternately, this approach is useful to override a service that is
matched using marker annotations.</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>AppModule.java (partial)</b></div><div
class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"> public SomeServiceType decorateSomeServiceType(final
SomeServiceType delegate)
{
return new SomeServiceType() { . . . };
}
-</plain-text-body><p>This decorate method is invoked because its name matches
the service id of the original service, "SomeServiceType" (you have to adjust
the name to match the service id).</p><p>The method is passed the original
service and its job it to return an <em>interceptor</em>, an object that
implements the same interface, wrapping around the original service. In many
cases, your code will simply re-invoke methods on the delegate, passing the
same parameters. However, an interceptor can decide to not invoke methods, or
it can change parameters, or change return values, or catch or throw
exceptions.</p><p>Note that the object passed in as <code>delegate</code> may
be the core service implementation, or it may be some other interceptor from
some other decorator for the same
service.</p><hr><p> </p><p> </p><plain-text-body>{scrollbar}</plain-text-body></div>
+</pre>
+</div></div><p>This decorate method is invoked because its name matches the
service id of the original service, "SomeServiceType" (you have to adjust the
name to match the service id).</p><p>The method is passed the original service
and its job it to return an <em>interceptor</em>, an object that implements the
same interface, wrapping around the original service. In many cases, your code
will simply re-invoke methods on the delegate, passing the same parameters.
However, an interceptor can decide to not invoke methods, or it can change
parameters, or change return values, or catch or throw exceptions.</p><p>Note
that the object passed in as <code>delegate</code> may be the core service
implementation, or it may be some other interceptor from some other decorator
for the same service.</p><hr><p> </p><p> </p></div>
</div>
<div class="clearer"></div>
Modified: websites/production/tapestry/content/ioc-cookbook-patterns.html
==============================================================================
--- websites/production/tapestry/content/ioc-cookbook-patterns.html (original)
+++ websites/production/tapestry/content/ioc-cookbook-patterns.html Wed Sep 20
12:29:16 2017
@@ -27,6 +27,16 @@
</title>
<link type="text/css" rel="stylesheet" href="/resources/space.css" />
+ <link href='/resources/highlighter/styles/shCoreCXF.css'
rel='stylesheet' type='text/css' />
+ <link href='/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet'
type='text/css' />
+ <script src='/resources/highlighter/scripts/shCore.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushXml.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushPlain.js'
type='text/javascript'></script>
+ <script>
+ SyntaxHighlighter.defaults['toolbar'] = false;
+ SyntaxHighlighter.all();
+ </script>
<link href="/styles/style.css" rel="stylesheet" type="text/css"/>
@@ -67,11 +77,65 @@
</div>
<div id="content">
- <div
id="ConfluenceContent"><p><plain-text-body>{scrollbar}</plain-text-body>Tapestry
IoC has support for implementing several of the <a class="external-link"
href="http://en.wikipedia.org/wiki/Design_pattern_(computer_science)"
rel="nofollow">Gang Of Four Design Patterns</a>. In fact, the IoC container
itself is a pumped up version of the Factory pattern.</p><parameter
ac:name="style">float:right</parameter><parameter ac:name="title">Related
Articles</parameter><parameter
ac:name="class">aui-label</parameter><rich-text-body><parameter
ac:name="showLabels">false</parameter><parameter
ac:name="showSpace">false</parameter><parameter ac:name="title">Related
Articles</parameter><parameter ac:name="cql">label = "patterns" and space =
currentSpace()</parameter></rich-text-body><p>The basis for these patterns is
often the use of <em>service builder methods</em>, where a <a
href="ioc-cookbook-service-configurations.html">configuration</a> for the
service is combined with a
factory to produce the service implementation on the fly.</p><p><parameter
ac:name="">chainofcommand</parameter></p><h1
id="IoCCookbook-Patterns-ChainofCommandPattern">Chain of Command
Pattern</h1><p>Main Article: <a href="chainbuilder-service.html">Chain of
Command</a></p><p>Let's look at another example, again from the Tapestry code
base. The <a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/InjectionProvider.html">InjectProvider</a>
interface is used to process the @Inject annotation on the fields of a
Tapestry page or component. Many different instances are combined together to
form a <em>chain of command</em>.</p><p>The interface has only a single method
(this is far from uncommon):</p><parameter
ac:name="language">java</parameter><plain-text-body>public interface
InjectionProvider
+ <div id="ConfluenceContent"><p>Tapestry IoC has support for
implementing several of the <a class="external-link"
href="http://en.wikipedia.org/wiki/Design_pattern_(computer_science)"
rel="nofollow">Gang Of Four Design Patterns</a>. In fact, the IoC container
itself is a pumped up version of the Factory pattern.</p><div class="aui-label"
style="float:right" title="Related Articles">
+
+
+
+
+
+
+
+
+<h3>Related Articles</h3>
+
+<ul class="content-by-label"><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small
aui-iconfont-page-default" title="Page">Page:</span> </div>
+
+ <div class="details">
+ <a href="ioc-cookbook-patterns.html">IoC Cookbook -
Patterns</a>
+
+
+ </div>
+ </li><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small
aui-iconfont-page-default" title="Page">Page:</span> </div>
+
+ <div class="details">
+ <a
href="strategybuilder-service.html">StrategyBuilder Service</a>
+
+
+ </div>
+ </li><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small
aui-iconfont-page-default" title="Page">Page:</span> </div>
+
+ <div class="details">
+ <a
href="pipelinebuilder-service.html">PipelineBuilder Service</a>
+
+
+ </div>
+ </li><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small
aui-iconfont-page-default" title="Page">Page:</span> </div>
+
+ <div class="details">
+ <a href="chainbuilder-service.html">ChainBuilder
Service</a>
+
+
+ </div>
+ </li></ul>
+</div>
+
+
+<p>The basis for these patterns is often the use of <em>service builder
methods</em>, where a <a
href="ioc-cookbook-service-configurations.html">configuration</a> for the
service is combined with a factory to produce the service implementation on the
fly.</p><p><span class="confluence-anchor-link"
id="IoCCookbook-Patterns-chainofcommand"></span></p><h1
id="IoCCookbook-Patterns-ChainofCommandPattern">Chain of Command
Pattern</h1><p>Main Article: <a href="chainbuilder-service.html">Chain of
Command</a></p><p>Let's look at another example, again from the Tapestry code
base. The <a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/InjectionProvider.html">InjectProvider</a>
interface is used to process the @Inject annotation on the fields of a
Tapestry page or component. Many different instances are combined together to
form a <em>chain of command</em>.</p><p>The interface has only a single method
(this is far from uncommon):</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public interface InjectionProvider
{
boolean provideInjection(String fieldName, Class fieldType, ObjectLocator
locator,
ClassTransformation transformation, MutableComponentModel
componentModel);
-}</plain-text-body><p>The return type indicates whether the provider was able
to do something. For example, the AssetInjectionProvider checks to see if
there's an @Path annotation on the field, and if so, converts the path to an
asset, works with the ClassTransformation object to implement injection, and
returns true to indicate success. Returning true terminates the chain early,
and that true value is ultimately returned to the caller.</p><p>In other cases,
it returns false and the chain of command continues down to the next provider.
If no provider is capable of handling the injection, then the value false is
ultimately returned.</p><p>The InjectionProvider service is built up via
contributions. These are the contributions from the
TapestryModule:</p><parameter
ac:name="language">java</parameter><plain-text-body>public static void
contributeInjectionProvider(
+}</pre>
+</div></div><p>The return type indicates whether the provider was able to do
something. For example, the AssetInjectionProvider checks to see if there's an
@Path annotation on the field, and if so, converts the path to an asset, works
with the ClassTransformation object to implement injection, and returns true to
indicate success. Returning true terminates the chain early, and that true
value is ultimately returned to the caller.</p><p>In other cases, it returns
false and the chain of command continues down to the next provider. If no
provider is capable of handling the injection, then the value false is
ultimately returned.</p><p>The InjectionProvider service is built up via
contributions. These are the contributions from the TapestryModule:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public static void contributeInjectionProvider(
OrderedConfiguration<InjectionProvider> configuration,
MasterObjectProvider masterObjectProvider,
ObjectLocator locator,
@@ -88,10 +152,14 @@
configuration.add("Block", new BlockInjectionProvider(), "before:Default");
configuration.add("Service", new ServiceInjectionProvider(locator),
"after:*");
-}</plain-text-body><p>And, of course, other contributions could be made in
other modules ... if you wanted to add in your own form of injection.</p><p>The
configuration is converted into a service via a service builder
method:</p><parameter ac:name="language">java</parameter><plain-text-body>
public InjectionProvider build(List<InjectionProvider> configuration,
ChainBuilder chainBuilder)
+}</pre>
+</div></div><p>And, of course, other contributions could be made in other
modules ... if you wanted to add in your own form of injection.</p><p>The
configuration is converted into a service via a service builder method:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"> public InjectionProvider
build(List<InjectionProvider> configuration, ChainBuilder chainBuilder)
{
return chainBuilder.build(InjectionProvider.class, configuration);
- }</plain-text-body><p>Now, let's see how this is used. The InjectWorker
class looks for fields with the InjectAnnotation, and uses the chain of command
to inject the appropriate value. However, to InjectWorker, there is no chain
... just a <em>single</em> object that implements the InjectionProvider
interface.</p><parameter
ac:name="language">java</parameter><plain-text-body>public class InjectWorker
implements ComponentClassTransformWorker
+ }</pre>
+</div></div><p>Now, let's see how this is used. The InjectWorker class looks
for fields with the InjectAnnotation, and uses the chain of command to inject
the appropriate value. However, to InjectWorker, there is no chain ... just a
<em>single</em> object that implements the InjectionProvider interface.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public class InjectWorker implements
ComponentClassTransformWorker
{
private final ObjectLocator locator;
@@ -134,7 +202,8 @@
}
}
-}</plain-text-body><p>Reducing the chain to a single object vastly simplifies
the code: we've <em>factored out</em> the loop implicit in the chain of
command. That eliminates a lot of code, and that's less code to test, and fewer
paths through InjectWorker, which lowers its complexity further. We don't have
to test the cases where the list of injection providers is empty, or consists
of only a single object, or where it's the third object in that returns true:
it looks like a single object, it acts like a single object ... but its
implementation uses many
objects.<plain-text-body>{scrollbar}</plain-text-body></p></div>
+}</pre>
+</div></div><p>Reducing the chain to a single object vastly simplifies the
code: we've <em>factored out</em> the loop implicit in the chain of command.
That eliminates a lot of code, and that's less code to test, and fewer paths
through InjectWorker, which lowers its complexity further. We don't have to
test the cases where the list of injection providers is empty, or consists of
only a single object, or where it's the third object in that returns true: it
looks like a single object, it acts like a single object ... but its
implementation uses many objects.</p></div>
</div>
<div class="clearer"></div>
Modified:
websites/production/tapestry/content/ioc-cookbook-service-configurations.html
==============================================================================
---
websites/production/tapestry/content/ioc-cookbook-service-configurations.html
(original)
+++
websites/production/tapestry/content/ioc-cookbook-service-configurations.html
Wed Sep 20 12:29:16 2017
@@ -27,6 +27,16 @@
</title>
<link type="text/css" rel="stylesheet" href="/resources/space.css" />
+ <link href='/resources/highlighter/styles/shCoreCXF.css'
rel='stylesheet' type='text/css' />
+ <link href='/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet'
type='text/css' />
+ <script src='/resources/highlighter/scripts/shCore.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushXml.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushPlain.js'
type='text/javascript'></script>
+ <script>
+ SyntaxHighlighter.defaults['toolbar'] = false;
+ SyntaxHighlighter.all();
+ </script>
<link href="/styles/style.css" rel="stylesheet" type="text/css"/>
@@ -67,7 +77,7 @@
</div>
<div id="content">
- <div
id="ConfluenceContent"><plain-text-body>{scrollbar}</plain-text-body>
+ <div id="ConfluenceContent">
<h1 id="IoCcookbook-ServiceConfigurations-ServiceConfigurations">Service
Configurations</h1>
@@ -91,12 +101,14 @@
<p>The Tapestry module makes a contribution into the service configuration:</p>
-<parameter ac:name="borderStyle">solid</parameter><plain-text-body>
+<div class="code panel pdl" style="border-style: solid;border-width:
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
public static void
contributeResourceDigestGenerator(Configuration<String> configuration)
{
configuration.add("class");
configuration.add("tml");
- }</plain-text-body>
+ }</pre>
+</div></div>
<p>This is a <em>service contribution method</em>, a method that is invoked to
provide values for a configuration. We'll see how the service receives these
contributions shortly. The <a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/Configuration.html">Configuration</a>
object is how values are added to the service's configuration. Other
parameters to a service configuration method are injected much as with a
service's constructor, or a service builder method.</p>
@@ -106,14 +118,16 @@
<p>Say your application stored a file on the classpath needed by your
application; for illustrative purposes, perhaps it is a PGP private key. You
don't want any client to able to download a .pgp file, no matter how unlikely
that would be. Thus:</p>
-<parameter ac:name="borderStyle">solid</parameter><plain-text-body>
+<div class="code panel pdl" style="border-style: solid;border-width:
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
public class MyAppModule
{
public static void
contributeResourceDigestGenerator(Configuration<String> configuration)
{
configuration.add("pgp");
}
-}</plain-text-body>
+}</pre>
+</div></div>
<p>The contribution in MyAppModule doesn't <em>replace</em> the normal
contribution, it is <em>combined</em>. The end result is that .class, .tml and
.pgp files would <em>all</em> be protected.</p>
@@ -121,7 +135,8 @@ public class MyAppModule
<p>A service receives the configuration as an injected parameter ... not of
type Configuration (that's used for <em>making</em> contributions), but instead
is of type Collection:</p>
-<parameter ac:name="borderStyle">solid</parameter><plain-text-body>
+<div class="code panel pdl" style="border-style: solid;border-width:
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
public class ResourceDigestGeneratorImpl implements ResourceDigestGenerator
{
private final Set<String> digestExtensions;
@@ -132,7 +147,8 @@ public class ResourceDigestGeneratorImpl
}
. . .
-}</plain-text-body>
+}</pre>
+</div></div>
<p>In many cases, the configuration is simply stored into an instance
variable; in this example, the value is transformed from a Collection to a
Set.</p>
@@ -146,7 +162,8 @@ public class ResourceDigestGeneratorImpl
<p>Alternately, if the Request can't be handled, the Dispatcher returns
false.</p>
-<parameter ac:name="borderStyle">solid</parameter><plain-text-body>
+<div class="code panel pdl" style="border-style: solid;border-width:
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
public void contributeMasterDispatcher(OrderedConfiguration<Dispatcher>
configuration, . . .)
{
// Looks for the root path and renders the start page
@@ -164,7 +181,8 @@ public void contributeMasterDispatcher(O
configuration.add("PageRender", new PageRenderDispatcher(. . .));
configuration.add("ComponentAction", new ComponentActionDispatcher(. . .),
"after:PageRender");
-}</plain-text-body>
+}</pre>
+</div></div>
<p>With an <a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/OrderedConfiguration.html">OrderedConfiguration</a>,
each contribution gets a name, which must be unique. Here the names are
RootPath, Asset, PageRender and ComponentAction.</p>
@@ -180,11 +198,13 @@ public void contributeMasterDispatcher(O
<p>The MasterDispatcher service configuration defines a <a
href="chainbuilder-service.html">Chain of Command</a> and we can provide the
implementation using virtually no code:</p>
-<parameter ac:name="borderStyle">solid</parameter><plain-text-body>
+<div class="code panel pdl" style="border-style: solid;border-width:
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
public static Dispatcher buildMasterDispatcher(List<Dispatcher>
configuration, ChainBuilder chainBuilder)
{
return chainBuilder.build(Dispatcher.class, configuration);
- }</plain-text-body>
+ }</pre>
+</div></div>
<p><a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/services/ChainBuilder.html">ChainBuilder</a>
is a service that <em>builds other services</em>. Here it creates an object of
type Dispatcher in terms of the list of Dispatchers. This is one of the most
common uses of service builder methods ... for when the service implementation
doesn't exist, but can be constructed at runtime.</p>
@@ -196,7 +216,8 @@ public void contributeMasterDispatcher(O
<p>The first step is to contribute values.</p>
-<parameter ac:name="borderStyle">solid</parameter><plain-text-body>
+<div class="code panel pdl" style="border-style: solid;border-width:
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
public static void contributeFactoryDefaults(MappedConfiguration<String,
String> configuration)
{
configuration.add(SymbolConstants.FILE_CHECK_INTERVAL, "1000"); // 1 second
@@ -210,13 +231,13 @@ public void contributeMasterDispatcher(O
"org/apache/tapestry5/scriptaculous_1_7_1_beta_3");
configuration.add("tapestry.jscalendar.path",
"org/apache/tapestry5/jscalendar-1.0");
configuration.add("tapestry.jscalendar",
"classpath:${tapestry.jscalendar.path}");
- }</plain-text-body>
+ }</pre>
+</div></div>
<p>These contribution set up a number of defaults used to configure various
Tapestry services. As you can see, you can even define symbol values in terms
of other symbol values.</p>
<p>Mapped configurations don't have to be keyed on Strings (enums or Class are
other common key types). When a mapped configuration <em>is</em> keyed on
String, then a case-insensitive map is used.</p>
-
-<plain-text-body>{scrollbar}</plain-text-body></div>
+</div>
</div>
<div class="clearer"></div>
Modified: websites/production/tapestry/content/ioc-cookbook.html
==============================================================================
--- websites/production/tapestry/content/ioc-cookbook.html (original)
+++ websites/production/tapestry/content/ioc-cookbook.html Wed Sep 20 12:29:16
2017
@@ -27,6 +27,16 @@
</title>
<link type="text/css" rel="stylesheet" href="/resources/space.css" />
+ <link href='/resources/highlighter/styles/shCoreCXF.css'
rel='stylesheet' type='text/css' />
+ <link href='/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet'
type='text/css' />
+ <script src='/resources/highlighter/scripts/shCore.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushXml.js'
type='text/javascript'></script>
+ <script src='/resources/highlighter/scripts/shBrushPlain.js'
type='text/javascript'></script>
+ <script>
+ SyntaxHighlighter.defaults['toolbar'] = false;
+ SyntaxHighlighter.all();
+ </script>
<link href="/styles/style.css" rel="stylesheet" type="text/css"/>
@@ -67,7 +77,58 @@
</div>
<div id="content">
- <div
id="ConfluenceContent"><p><plain-text-body>{scrollbar}</plain-text-body></p><parameter
ac:name="hidden">true</parameter><parameter
ac:name="atlassian-macro-output-type">BLOCK</parameter><rich-text-body><p>A
tutorial for using Tapestry's Inversion of Control
container</p></rich-text-body><p>Tapestry <strong>Inversion of Control</strong>
(IoC), though originally designed specifically for the needs of the Tapestry
web framework, may also be employed as a stand-alone IoC container, separate
from the rest of Tapestry.</p><parameter
ac:name="style">float:right</parameter><parameter ac:name="title">Related
Articles</parameter><parameter
ac:name="class">aui-label</parameter><rich-text-body><parameter
ac:name="showLabels">false</parameter><parameter
ac:name="showSpace">false</parameter><parameter ac:name="title">Related
Articles</parameter><parameter ac:name="cql">label = "ioc" and space =
currentSpace()</parameter></rich-text-body><p>Tapestry IoC is a sophisticated
tool
that takes some experience to use properly.</p><p>The IOC documentation in
the User Guide is factually correct, but it is designed more as a reference,
rather than giving the big picture. In this Cookbook, we'll show a bit more
about how to use Tapestry IoC, using real examples from the Tapestry code base
(both the tapestry-ioc and tapestry-core modules).</p><p>A word of caution:
several of the examples have been taken from Tapestry's <em>internal</em> code
base. Tapestry internals are private, subject to change at any time, so be
aware that if you go peeking at the internal source code, it may have changed
since the corresponding documentation was
written.</p><p><strong>Contents:</strong></p><ul><li><a
href="ioc-cookbook-basic-services-and-injection.html">Basic Services and
Injection</a></li><li><a
href="ioc-cookbook-overriding-ioc-services.html">Overriding Tapestry IoC
Services</a></li><li><a href="ioc-cookbook-patterns.html">Using
Patterns</a></li><li><a href="ioc-cookbook-s
ervice-configurations.html">Service Configurations</a></li></ul></div>
+ <div id="ConfluenceContent"><p>Tapestry <strong>Inversion of
Control</strong> (IoC), though originally designed specifically for the needs
of the Tapestry web framework, may also be employed as a stand-alone IoC
container, separate from the rest of Tapestry.</p><div class="aui-label"
style="float:right" title="Related Articles">
+
+
+
+
+
+
+
+
+<h3>Related Articles</h3>
+
+<ul class="content-by-label"><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small
aui-iconfont-page-default" title="Page">Page:</span> </div>
+
+ <div class="details">
+ <a href="ioc.html">IOC</a>
+
+
+ </div>
+ </li><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small
aui-iconfont-page-default" title="Page">Page:</span> </div>
+
+ <div class="details">
+ <a href="ioc-cookbook.html">IoC cookbook</a>
+
+
+ </div>
+ </li><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small
aui-iconfont-page-default" title="Page">Page:</span> </div>
+
+ <div class="details">
+ <a href="tapestry-ioc-overview.html">Tapestry IoC
Overview</a>
+
+
+ </div>
+ </li><li>
+ <div>
+ <span class="icon aui-icon aui-icon-small
aui-iconfont-page-default" title="Page">Page:</span> </div>
+
+ <div class="details">
+ <a
href="tapestry-inversion-of-control-faq.html">Tapestry Inversion of Control
FAQ</a>
+
+
+ </div>
+ </li></ul>
+</div>
+
+
+<p>Tapestry IoC is a sophisticated tool that takes some experience to use
properly.</p><p>The IOC documentation in the User Guide is factually correct,
but it is designed more as a reference, rather than giving the big picture. In
this Cookbook, we'll show a bit more about how to use Tapestry IoC, using real
examples from the Tapestry code base (both the tapestry-ioc and tapestry-core
modules).</p><p>A word of caution: several of the examples have been taken from
Tapestry's <em>internal</em> code base. Tapestry internals are private, subject
to change at any time, so be aware that if you go peeking at the internal
source code, it may have changed since the corresponding documentation was
written.</p><p><strong>Contents:</strong></p><ul><li><a
href="ioc-cookbook-basic-services-and-injection.html">Basic Services and
Injection</a></li><li><a
href="ioc-cookbook-overriding-ioc-services.html">Overriding Tapestry IoC
Services</a></li><li><a href="ioc-cookbook-patterns.html">Using Patter
ns</a></li><li><a href="ioc-cookbook-service-configurations.html">Service
Configurations</a></li></ul></div>
</div>
<div class="clearer"></div>