<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">]>
<rss version="0.92" xml:base="http://anjlab.com">
<channel>
 <title>AnjLab Blog | AnjLab  - software development team - </title>
 <link>http://anjlab.com</link>
 <description>AnjLab news and viewsВ этом разделе транслируются сообщения, которые участники команды размещают на своих персональных блогах.


</description>
 <language>ru</language>
<item>
 <title>Profiling GAE API calls</title>
 <link>http://feedproxy.google.com/~r/dmitrygusev/~3/zQc0HFl5VWo/profiling-gae-api-calls.html</link>
 <description>While optimizing performance of GAE application its convenient to measure GAE API calls.&lt;br /&gt;&lt;br /&gt;I&#039;m using the following implementation of &lt;code&gt;com.google.apphosting.api.ApiProxy.Delegate&lt;/code&gt; to do this:&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;class&lt;/font&gt;&lt;/b&gt; ProfilingDelegate &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;implements&lt;/font&gt;&lt;/b&gt; Delegate&lt;font color=&quot;#990000&quot;&gt;&amp;lt;&lt;/font&gt;Environment&lt;font color=&quot;#990000&quot;&gt;&amp;gt;&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;private&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;static&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;final&lt;/font&gt;&lt;/b&gt; Logger logger &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; LoggerFactory&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getLogger&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;ProfilingDelegate&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;class&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;private&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;final&lt;/font&gt;&lt;/b&gt; Delegate&lt;font color=&quot;#990000&quot;&gt;&amp;lt;&lt;/font&gt;Environment&lt;font color=&quot;#990000&quot;&gt;&amp;gt;&lt;/font&gt; parent&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;private&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;final&lt;/font&gt;&lt;/b&gt; String appPackage&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;ProfilingDelegate&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Delegate&lt;font color=&quot;#990000&quot;&gt;&amp;lt;&lt;/font&gt;Environment&lt;font color=&quot;#990000&quot;&gt;&amp;gt;&lt;/font&gt; parent&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; String appPackage&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;      &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;this&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;parent &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; parent&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;      &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;this&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;appPackage &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; appPackage&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;log&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Environment env&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; LogRecord logRec&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        parent&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;log&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;env&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; logRec&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;byte&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;[&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;]&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;makeSyncCall&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Environment env&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; String pkg&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; String method&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;#009900&quot;&gt;byte&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;[&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;]&lt;/font&gt; request&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;throws&lt;/font&gt;&lt;/b&gt; ApiProxyException &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#009900&quot;&gt;long&lt;/font&gt; start &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; System&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;currentTimeMillis&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#009900&quot;&gt;byte&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;[&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;]&lt;/font&gt; result &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; parent&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;makeSyncCall&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;env&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; pkg&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; method&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; request&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        StringBuilder builder &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;buildStackTrace&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;appPackage&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        logger&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;info&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;GAE/S {}.{}: -&amp;gt;{} ms&amp;lt;-\n{}&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;new&lt;/font&gt;&lt;/b&gt; Object&lt;font color=&quot;#990000&quot;&gt;[&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;]&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt; pkg&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; method&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; System&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;currentTimeMillis&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#990000&quot;&gt;-&lt;/font&gt; start&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; builder &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt; result&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;/**&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;     * &lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;     * &lt;/font&gt;&lt;/i&gt;&lt;font color=&quot;#009900&quot;&gt;@param&lt;/font&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt; appPackage&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;     *        Only classes from this package would be included in trace.&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;     * &lt;/font&gt;&lt;/i&gt;&lt;font color=&quot;#009900&quot;&gt;@return&lt;/font&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;     &lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;*/&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;static&lt;/font&gt;&lt;/b&gt; StringBuilder &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;buildStackTrace&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;String appPackage&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        StackTraceElement&lt;font color=&quot;#990000&quot;&gt;[&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;]&lt;/font&gt; traces &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; Thread&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;currentThread&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getStackTrace&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        StringBuilder builder &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;new&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;StringBuilder&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#009900&quot;&gt;int&lt;/font&gt; length &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; traces&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;length&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        StackTraceElement traceElement&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        String className&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;for&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#009900&quot;&gt;int&lt;/font&gt; i &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;font color=&quot;#993399&quot;&gt;3&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt; i &lt;font color=&quot;#990000&quot;&gt;&amp;lt;&lt;/font&gt; length&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt; i&lt;font color=&quot;#990000&quot;&gt;+&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;+&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            traceElement &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; traces&lt;font color=&quot;#990000&quot;&gt;[&lt;/font&gt;i&lt;font color=&quot;#990000&quot;&gt;]&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            className &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; traceElement&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getClassName&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;className&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;startsWith&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;appPackage&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;                &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;length&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#990000&quot;&gt;&amp;gt;&lt;/font&gt; &lt;font color=&quot;#993399&quot;&gt;0&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;                    builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;append&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&#039;\n&#039;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;                &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;                builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;append&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;..&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;                builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;append&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;className&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;substring&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;className&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;lastIndexOf&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&#039;.&#039;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;                builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;append&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&#039;.&#039;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;                builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;append&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;traceElement&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getMethodName&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;                builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;append&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&#039;:&#039;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;                builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;append&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;traceElement&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getLineNumber&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;length&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;font color=&quot;#993399&quot;&gt;0&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;for&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#009900&quot;&gt;int&lt;/font&gt; i &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;font color=&quot;#993399&quot;&gt;1&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt; i &lt;font color=&quot;#990000&quot;&gt;&amp;lt;&lt;/font&gt; length&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt; i&lt;font color=&quot;#990000&quot;&gt;+&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;+&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;                traceElement &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; traces&lt;font color=&quot;#990000&quot;&gt;[&lt;/font&gt;i&lt;font color=&quot;#990000&quot;&gt;]&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;                className &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; traceElement&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getClassName&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;                &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;length&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#990000&quot;&gt;&amp;gt;&lt;/font&gt; &lt;font color=&quot;#993399&quot;&gt;0&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;                    builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;append&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&#039;\n&#039;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;                &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;                builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;append&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;className&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;                builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;append&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&#039;.&#039;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;                builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;append&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;traceElement&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getMethodName&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;                builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;append&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&#039;:&#039;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;                builder&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;append&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;traceElement&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getLineNumber&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt; builder&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; Future&lt;font color=&quot;#990000&quot;&gt;&amp;lt;&lt;/font&gt;&lt;font color=&quot;#009900&quot;&gt;byte&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;[&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;]&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;&amp;gt;&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;makeAsyncCall&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Environment env&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; String pkg&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; String method&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;#009900&quot;&gt;byte&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;[&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;]&lt;/font&gt; request&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; ApiConfig config&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#009900&quot;&gt;long&lt;/font&gt; start &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; System&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;currentTimeMillis&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        Future&lt;font color=&quot;#990000&quot;&gt;&amp;lt;&lt;/font&gt;&lt;font color=&quot;#009900&quot;&gt;byte&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;[&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;]&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;&amp;gt;&lt;/font&gt; result &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; parent&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;makeAsyncCall&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;env&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; pkg&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; method&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; request&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; config&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        StringBuilder builder &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;buildStackTrace&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;appPackage&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        logger&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;info&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;GAE/A {}.{}: -&amp;gt;{} ms&amp;lt;-\n{}&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;new&lt;/font&gt;&lt;/b&gt; Object&lt;font color=&quot;#990000&quot;&gt;[&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;]&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt; pkg&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; method&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; System&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;currentTimeMillis&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#990000&quot;&gt;-&lt;/font&gt; start&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; builder &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt; result&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;To register this delegate add the following code to prior to any API calls, i.e. to filter &lt;code&gt;init()&lt;/code&gt; method:&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;init&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;FilterConfig config&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;throws&lt;/font&gt;&lt;/b&gt; ServletException&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;this&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;config &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; config&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;  Note: Comment this off to profile Google API requests&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;        ApiProxy&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;setDelegate&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;new&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;ProfilingDelegate&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;ApiProxy&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getDelegate&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;&quot;dmitrygusev&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here&#039;s an example of log output:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;02.09.2010 0:22:19 dmitrygusev.tapestry5.gae.ProfilingDelegate makeSyncCall&lt;br /&gt;INFO: GAE/S datastore_v3.BeginTransaction: -&gt;1076 ms&lt;-&lt;br /&gt;...LazyJPATransactionManager$1.assureTxBegin:48&lt;br /&gt;...LazyJPATransactionManager$1.createQuery:137&lt;br /&gt;...AccountDAOImpl.findByEmail:36&lt;br /&gt;...AccountDAOImpl.getAccount:26&lt;br /&gt;...AccountDAOImplCache.getAccount:36&lt;br /&gt;...Application.getUserAccount:395&lt;br /&gt;...Application.trackUserActivity:400&lt;br /&gt;...AppModule$1.service:229&lt;br /&gt;...AppModule$2.service:291&lt;br /&gt;...LazyTapestryFilter.doFilter:62&lt;br /&gt;02.09.2010 0:22:19 dmitrygusev.tapestry5.gae.LazyJPATransactionManager$1 assureTxBegin&lt;br /&gt;INFO: Transaction created (1200 ms) for context ...AccountDAOImpl.findByEmail:36&lt;br /&gt;...AccountDAOImpl.getAccount:26&lt;br /&gt;...AccountDAOImplCache.getAccount:36&lt;br /&gt;...Application.getUserAccount:395&lt;br /&gt;...Application.trackUserActivity:400&lt;br /&gt;...AppModule$1.service:229&lt;br /&gt;...AppModule$2.service:291&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;See also &lt;a href=&quot;http://dmitrygusev.blogspot.com/2010/09/gae-and-tapestry5-data-access-layer.html&quot;&gt;GAE and Tapestry5 Data Access Layer&lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&#039;1&#039; height=&#039;1&#039; src=&#039;https://blogger.googleusercontent.com/tracker/25040534-6329866412641263180?l=dmitrygusev.blogspot.com&#039; alt=&#039;&#039; /&gt;&lt;/div&gt;&lt;div class=&quot;feedflare&quot;&gt;
&lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=zQc0HFl5VWo:OGDbfuEqblg:V_sGLiPBpWU&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?i=zQc0HFl5VWo:OGDbfuEqblg:V_sGLiPBpWU&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=zQc0HFl5VWo:OGDbfuEqblg:7Q72WNTAKBA&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?d=7Q72WNTAKBA&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=zQc0HFl5VWo:OGDbfuEqblg:yIl2AUoC8zA&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?d=yIl2AUoC8zA&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src=&quot;http://feeds.feedburner.com/~r/dmitrygusev/~4/zQc0HFl5VWo&quot; height=&quot;1&quot; width=&quot;1&quot;/&gt;</description>
 <pubDate>Thu, 02 Sep 2010 00:27:17 +0400</pubDate>
</item>
<item>
 <title>GAE and Tapestry5 Data Access Layer</title>
 <link>http://feedproxy.google.com/~r/dmitrygusev/~3/AVpUjKwX5iU/gae-and-tapestry5-data-access-layer.html</link>
 <description>GAE provides two ways communicating with its &lt;a href=&quot;http://code.google.com/appengine/docs/java/datastore/&quot;&gt;datastore&lt;/a&gt; from Java:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Using low-level API&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Using JDO/JPA (with DataNucleus appengine edition)&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;In this post I will try to explain some performance improvements of JPA usage. Of course, there&#039;s always some overhead using high-level API. But I use JPA in &lt;a href=&quot;http://github.com/dmitrygusev/ping-service&quot;&gt;Ping Service&lt;/a&gt; and think it worth it.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Spring vs. Tapestry-JPA&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;Its a good practice using JPA in conjunction with IoC-container to inject &lt;code&gt;EntityManager&lt;/code&gt; into your services. At the very beginning of development I used Spring 3.0 as IoC and for transaction management. It worked, but it takes too much time to initialize during load requests, and every time user opens its first web page, he ended with &lt;code&gt;DeadlineExceededException&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;Then I tried &lt;a href=&quot;http://tynamo.org/tapestry-jpa+guide&quot;&gt;tapestry-jpa&lt;/a&gt; from Tynamo and it fits perfectly. It runs pretty fast and allows to:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;inject &lt;code&gt;EntityManager&lt;/code&gt; to DAO classes (as regular T5 services)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;manage transactions using &lt;code&gt;@CommitAfter&lt;/code&gt; annotation&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h3&gt;DAO and Caching&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;Since GAE datastore can&#039;t operate with multiple entities in a single transaction I&#039;ve added &lt;code&gt;@CommitAfter&lt;/code&gt; annotation to every method of each DAO class.&lt;br /&gt;&lt;br /&gt;Datastore access is a an expensive operation in GAE, so I&#039;ve implemented DAO-level caching:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;DAO interface&lt;/b&gt;&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;interface&lt;/font&gt;&lt;/b&gt; JobDAO &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt; ...&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;    @CommitAfter&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;abstract&lt;/font&gt;&lt;/b&gt; Job &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;find&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Key jobKey&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    @CommitAfter&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;abstract&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;update&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Job job&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;#009900&quot;&gt;boolean&lt;/font&gt; commitAfter&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;DAO implementation&lt;/b&gt;&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;class&lt;/font&gt;&lt;/b&gt; JobDAOImpl &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;implements&lt;/font&gt;&lt;/b&gt; JobDAO &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt; ...&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; Job &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;find&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Key jobKey&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt; em&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;find&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Job&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;class&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; jobKey&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;update&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Job job&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;#009900&quot;&gt;boolean&lt;/font&gt; commitAfter&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;!&lt;/font&gt;em&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getTransaction&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;isActive&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt; see Application#internalUpdateJob(Job)&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;            logger&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;debug&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;Transaction is not active. Begin new one...&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            &lt;br /&gt;            &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt; XXX Rewrite this to handle transactions more gracefully&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;            em&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getTransaction&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;begin&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;        em&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;merge&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;job&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;commitAfter&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            em&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getTransaction&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;commit&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;DAO cache&lt;/b&gt;&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;class&lt;/font&gt;&lt;/b&gt; JobDAOImplCache &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;extends&lt;/font&gt;&lt;/b&gt; JobDAOImpl &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt; ...&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; Job &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;find&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Key jobKey&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        Object entityCacheKey &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getEntityCacheKey&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Job&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;class&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getJobWideUniqueData&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;jobKey&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        Job result &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Job&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; cache&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;get&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;entityCacheKey&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;result &lt;font color=&quot;#990000&quot;&gt;!&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;null&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt; result&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;        result &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;super&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;find&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;jobKey&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;result &lt;font color=&quot;#990000&quot;&gt;!&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;null&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            cache&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;put&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;entityCacheKey&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; result&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt; result&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;update&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Job job&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;#009900&quot;&gt;boolean&lt;/font&gt; commitAfter&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;super&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;update&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;job&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; commitAfter&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        Object entityCacheKey &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getEntityCacheKey&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Job&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;class&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getJobWideUniqueData&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;job&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getKey&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        Job cachedJob &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Job&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;cache&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;get&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;entityCacheKey&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;cachedJob &lt;font color=&quot;#990000&quot;&gt;!&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;null&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            &lt;br /&gt;            &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;!&lt;/font&gt;cachedJob&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getCronString&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;equals&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;job&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getCronString&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;                &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;abandonJobsByCronStringCache&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;cachedJob&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getCronString&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;                &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;abandonJobsByCronStringCache&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;job&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getCronString&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;            &lt;br /&gt;            cache&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;put&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;entityCacheKey&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; job&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;else&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;abandonJobsByCronStringCache&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;        &lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;updateJobInScheduleCache&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;job&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Notice how update method implemented in &lt;code&gt;JobDAOImplCache&lt;/code&gt;. If DAO method changes object in database it is responsible for updating all cached object instances in the entire cache. It may be difficult to support such implementation, on the other hand it may be very effective because you have full control over cache.&lt;br /&gt;&lt;br /&gt;Each &lt;code&gt;*DAOImplCache&lt;/code&gt; class uses two-level &lt;a href=&quot;http://jcp.org/en/jsr/detail?id=107&quot;&gt;JSR-107&lt;/a&gt; based cache:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Level-1: Local memory (appserver instance, request scoped)&lt;br /&gt;&lt;p&gt;provides quick access to objects that were &quot;touched&quot; during current request&lt;/p&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Level-2: Memcache (cluster wide)&lt;br /&gt;&lt;p&gt;allows application instances to share cached objects across entire appengine cluster&lt;/p&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Note that local memory cache should be request scoped, or it may lead to stale data across appserver instances. To reset local cache after each request it should be registered as &lt;code&gt;ThreadCleanupListener&lt;/code&gt;:&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;static&lt;/font&gt;&lt;/b&gt; Cache &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;buildCache&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Logger logger&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; PerthreadManager perthreadManager&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;try&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            CacheFactory cacheFactory &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; CacheManager&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getInstance&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getCacheFactory&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            Cache cache &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; cacheFactory&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;createCache&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Collections&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;emptyMap&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            &lt;br /&gt;            LocalMemorySoftCache cache2 &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;new&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;LocalMemorySoftCache&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;cache&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;            &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;  perthreadManager may be null if we creating cache from AbstractFilter&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;            &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;perthreadManager &lt;font color=&quot;#990000&quot;&gt;!&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;null&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;                perthreadManager&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;addThreadCleanupListener&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;cache2&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;            &lt;br /&gt;            &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt; cache2&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;catch&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;CacheException e&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            logger&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;error&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;Error instantiating cache&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; e&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;null&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here&#039;s how &lt;code&gt;&lt;a href=&quot;http://github.com/dmitrygusev/ping-service/blob/master/ping-service/src/dmitrygusev/ping/services/LocalMemorySoftCache.java&quot;&gt;LocalMemorySoftCache&lt;/a&gt;&lt;/code&gt; implementation looks like:&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;class&lt;/font&gt;&lt;/b&gt; LocalMemorySoftCache &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;implements&lt;/font&gt;&lt;/b&gt; Cache&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; ThreadCleanupListener &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;private&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;final&lt;/font&gt;&lt;/b&gt; Cache cache&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;private&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;final&lt;/font&gt;&lt;/b&gt; Map&lt;font color=&quot;#990000&quot;&gt;&amp;lt;&lt;/font&gt;Object&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; Object&lt;font color=&quot;#990000&quot;&gt;&amp;gt;&lt;/font&gt; map&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    @&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;SuppressWarnings&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;unchecked&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;LocalMemorySoftCache&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Cache cache&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;this&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;map &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;new&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;SoftValueMap&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#993399&quot;&gt;100&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;this&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;cache &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; cache&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;clear&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        map&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;clear&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        cache&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;clear&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;boolean&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;containsKey&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Object key&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt; map&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;containsKey&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;key&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;br /&gt;            &lt;font color=&quot;#990000&quot;&gt;|&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;|&lt;/font&gt; cache&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;containsKey&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;key&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; Object &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;get&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Object key&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        Object value &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; map&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;get&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;key&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;value &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;null&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            value &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; cache&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;get&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;key&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            map&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;put&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;key&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; value&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt; value&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; Object &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;put&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Object key&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; Object value&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        map&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;put&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;key&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; value&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt; cache&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;put&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;key&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; value&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; Object &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;remove&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Object key&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        map&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;remove&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;key&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt; cache&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;remove&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;key&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt; ...&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;/**&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;     * Reset in-memory cache but leave original cache untouched.&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;     &lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;*/&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;reset&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        map&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;clear&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;threadDidCleanup&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;reset&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Make Tapestry-JPA Lazy&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;On every request Tapestry-JPA creates new EntityManager and starts new transaction on it. And at the end of request if current transaction is still active it gets rolled back.&lt;br /&gt;&lt;br /&gt;But if all data were taken from cache, there won&#039;t be any interaction to database. In this case &lt;code&gt;EntityManager&lt;/code&gt; creation and transaction begin/rollback were not required. But they consumed time and another resources. &lt;br /&gt;&lt;br /&gt;Moreover Tapestry-JPA creates &lt;code&gt;EntityManagerFactory&lt;/code&gt; instance on application load which is very expensive, though you might not need it (because of DAO cache or simply because request isn&#039;t using datastore at all).&lt;br /&gt;&lt;br /&gt;To avoid this I created lazy implementations of &lt;code&gt;&lt;a href=&quot;http://tynamo.org/constant/tapestry-jpa/apidocs/org/tynamo/jpa/JPAEntityManagerSource.html&quot;&gt;JPAEntityManagerSource&lt;/a&gt;&lt;/code&gt;, &lt;code&gt;&lt;a href=&quot;http://tynamo.org/constant/tapestry-jpa/apidocs/org/tynamo/jpa/JPATransactionManager.html&quot;&gt;JPATransactionManager&lt;/a&gt;&lt;/code&gt; and &lt;code&gt;EntityManager&lt;/code&gt;, you can find them here: &lt;code&gt;&lt;a href=&quot;http://github.com/dmitrygusev/ping-service/blob/master/ping-service/src/dmitrygusev/tapestry5/gae/LazyJPAEntityManagerSource.java&quot;&gt;LazyJPAEntityManagerSource&lt;/a&gt;&lt;/code&gt; and &lt;code&gt;&lt;a href=&quot;http://github.com/dmitrygusev/ping-service/blob/master/ping-service/src/dmitrygusev/tapestry5/gae/LazyJPATransactionManager.java&quot;&gt;LazyJPATransactionManager&lt;/a&gt;&lt;/code&gt;.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&#039;1&#039; height=&#039;1&#039; src=&#039;https://blogger.googleusercontent.com/tracker/25040534-5816479255653594179?l=dmitrygusev.blogspot.com&#039; alt=&#039;&#039; /&gt;&lt;/div&gt;&lt;div class=&quot;feedflare&quot;&gt;
&lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=AVpUjKwX5iU:lz-PLh8f1t8:V_sGLiPBpWU&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?i=AVpUjKwX5iU:lz-PLh8f1t8:V_sGLiPBpWU&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=AVpUjKwX5iU:lz-PLh8f1t8:7Q72WNTAKBA&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?d=7Q72WNTAKBA&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=AVpUjKwX5iU:lz-PLh8f1t8:yIl2AUoC8zA&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?d=yIl2AUoC8zA&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src=&quot;http://feeds.feedburner.com/~r/dmitrygusev/~4/AVpUjKwX5iU&quot; height=&quot;1&quot; width=&quot;1&quot;/&gt;</description>
 <pubDate>Wed, 01 Sep 2010 23:52:50 +0400</pubDate>
</item>
<item>
 <title>GAE and background workers in Tapestry5 app</title>
 <link>http://feedproxy.google.com/~r/dmitrygusev/~3/4hIkGgNfykc/gae-and-background-workers-in-tapestry5.html</link>
 <description>In GAE you use task queues API to implement background workers.&lt;br /&gt;&lt;br /&gt;For instance Ping Service uses task queues to batch ping web pages according to cron schedule.&lt;br /&gt;&lt;br /&gt;In task queue API every task considered as an HTTP request to your application.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://3.bp.blogspot.com/__b4fPTzdGYs/THeNo8Ei-BI/AAAAAAAAAlQ/6QYq5GWGLGo/s1600/task-queue.png&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 213px;&quot; src=&quot;http://3.bp.blogspot.com/__b4fPTzdGYs/THeNo8Ei-BI/AAAAAAAAAlQ/6QYq5GWGLGo/s400/task-queue.png&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5510028403570571282&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you have just several requests per your billing period (say ~100 per day) then using Tapestry5 to handle tasks requests is not a bad idea since this doesn&#039;t hurt billing too much. &lt;br /&gt;&lt;br /&gt;But if you have thousands of requests (for instance Ping Service currently servers ~13K background jobs per day) using Tapestry5 for this purposes will be a problem. Why? Because of GAE load balancing policy. The thing is GAE may (and do) shut down/start up instances of your application sporadically for better utilization of its internal resources. And every time load request happens your T5 application will have to load and initialize entire app configuration again and again.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Tapestry5 page as background worker&lt;/h3&gt;&lt;br /&gt;To implement this approach you may just create new T5 page and implement worker logic in &lt;code&gt;onActivate()&lt;/code&gt; method. In this case you have all the power of Tapestry5 (IoC, built-in services, activation context, etc.).&lt;br /&gt;&lt;br /&gt;In Tapestry5 every page should have a template file with markup. But for background workers this would typically be files with empty/dummy markup since nobody will access these pages from browser. When I used this approach I used &lt;code&gt;@Meta(Application.NO_MARKUP)&lt;/code&gt; annotation and override MarkupRender service that prevents normal rendering queue for pages having this annotation and returns empty content (&lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;/html&amp;gt;&lt;/code&gt;) to client. &lt;a href=&quot;http://tapestry-users.832.n2.nabble.com/Page-without-markup-tp4825548p4837185.html&quot;&gt;Here&#039;s the discussion&lt;/a&gt; of implementation details.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Custom filter as background worker&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;Using Filter API you can declare custom filter that handle task requests. In this way Tapestry5 shouldn&#039;t be involved to processing at all and there won&#039;t be any additional overhead during load requests.&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;filter&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;filter-name&amp;gt;&lt;/font&gt;&lt;/b&gt;runJob&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/filter-name&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;filter-class&amp;gt;&lt;/font&gt;&lt;/b&gt;dmitrygusev.ping.filters.RunJobFilter&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/filter-class&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/filter&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;filter-mapping&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;filter-name&amp;gt;&lt;/font&gt;&lt;/b&gt;runJob&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/filter-name&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;url-pattern&amp;gt;&lt;/font&gt;&lt;/b&gt;/filters/runJob/*&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/url-pattern&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/filter-mapping&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The problem here is that Tapestry5 also uses Filter API to handle requests and usually declared to serve all incoming requests:&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;filter-mapping&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;filter-name&amp;gt;&lt;/font&gt;&lt;/b&gt;app&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/filter-name&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;url-pattern&amp;gt;&lt;/font&gt;&lt;/b&gt;/*&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/url-pattern&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/filter-mapping&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;To avoid loading Tapestry5 on such request I implemented &lt;code&gt;LazyTapestryFilter&lt;/code&gt; class that checks if request is a background worker URL and ignores it.&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;class&lt;/font&gt;&lt;/b&gt; LazyTapestryFilter &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;implements&lt;/font&gt;&lt;/b&gt; Filter &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;private&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;static&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;final&lt;/font&gt;&lt;/b&gt; Logger logger &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; LoggerFactory&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getLogger&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;LazyTapestryFilter&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;class&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt; &lt;br /&gt;    &lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;private&lt;/font&gt;&lt;/b&gt; Filter tapestryFilter&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;private&lt;/font&gt;&lt;/b&gt; FilterConfig config&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;static&lt;/font&gt;&lt;/b&gt; FilterConfig FILTER_CONFIG&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;init&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;FilterConfig config&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;throws&lt;/font&gt;&lt;/b&gt; ServletException&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        FILTER_CONFIG &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; config&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;this&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;config &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; config&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;  Note: Comment this off to profile Google API requests&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;        ApiProxy.setDelegate(new ProfilingDelegate(ApiProxy.getDelegate()));&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;doFilter&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;ServletRequest request&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; ServletResponse response&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; FilterChain chain&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;br /&gt;         &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;throws&lt;/font&gt;&lt;/b&gt; IOException&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; ServletException&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        String requestURI &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;HttpServletRequest&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; request&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;getRequestURI&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;requestURI&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;startsWith&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;/filters/&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#990000&quot;&gt;|&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;|&lt;/font&gt; requestURI&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;equalsIgnoreCase&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;/favicon.ico&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;        &lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;tapestryFilter &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;null&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            &lt;font color=&quot;#009900&quot;&gt;long&lt;/font&gt; startTime &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; System&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;currentTimeMillis&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            &lt;br /&gt;            logger&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;info&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;Creating Tapestry Filter...&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            &lt;br /&gt;            tapestryFilter &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;new&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;TapestryFilter&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            tapestryFilter&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;init&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;config&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            &lt;br /&gt;            logger&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;info&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;Tapestry Filter created and initialized ({} ms)&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; System&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;currentTimeMillis&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#990000&quot;&gt;-&lt;/font&gt; startTime&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;        &lt;br /&gt;        tapestryFilter&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;doFilter&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;request&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; response&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; chain&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;destroy&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        tapestryFilter&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;destroy&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Its also a good idea to skip all non-tapestry requests that you usually declare in &lt;code&gt;AppModule.java&lt;/code&gt; like this:&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;static&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;contributeIgnoredPathsFilter&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Configuration&lt;font color=&quot;#990000&quot;&gt;&amp;lt;&lt;/font&gt;String&lt;font color=&quot;#990000&quot;&gt;&amp;gt;&lt;/font&gt; configuration&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;  GAE filters (Admin Console)&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;    configuration&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;add&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;/_ah/.*&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;&lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note its required for Tapestry5 to ignore these paths to enable Admin Console in development server.&lt;br /&gt;&lt;br /&gt;Worker filter implementation should initialize as late as possible, i.e. not in &lt;code&gt;init()&lt;/code&gt; method, but in &lt;code&gt;doFilter()&lt;/code&gt; because &lt;code&gt;init()&lt;/code&gt; may be invoked during app server startup even if incoming request will not match that filter:&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;    @Override&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;doFilter&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;ServletRequest request&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; ServletResponse response&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; FilterChain chain&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;br /&gt;            &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;throws&lt;/font&gt;&lt;/b&gt; IOException&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; ServletException&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#009900&quot;&gt;long&lt;/font&gt; startTime &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; System&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;currentTimeMillis&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;emf &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;null&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;lazyInit&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;        &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt; ...&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Also note that using this approach you will have to manage transactions manually. You may consider Ping Service &lt;a href=&quot;http://github.com/dmitrygusev/ping-service/blob/master/ping-service/src/dmitrygusev/ping/filters/AbstractFilter.java&quot;&gt;AbstractFilter&lt;/a&gt; as a reference.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&#039;1&#039; height=&#039;1&#039; src=&#039;https://blogger.googleusercontent.com/tracker/25040534-5244264949856716645?l=dmitrygusev.blogspot.com&#039; alt=&#039;&#039; /&gt;&lt;/div&gt;&lt;div class=&quot;feedflare&quot;&gt;
&lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=4hIkGgNfykc:O9Mkx-8E6a4:V_sGLiPBpWU&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?i=4hIkGgNfykc:O9Mkx-8E6a4:V_sGLiPBpWU&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=4hIkGgNfykc:O9Mkx-8E6a4:7Q72WNTAKBA&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?d=7Q72WNTAKBA&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=4hIkGgNfykc:O9Mkx-8E6a4:yIl2AUoC8zA&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?d=yIl2AUoC8zA&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src=&quot;http://feeds.feedburner.com/~r/dmitrygusev/~4/4hIkGgNfykc&quot; height=&quot;1&quot; width=&quot;1&quot;/&gt;</description>
 <pubDate>Fri, 27 Aug 2010 15:43:52 +0400</pubDate>
</item>
<item>
 <title>GAE and Tapestry5 Exception Handling</title>
 <link>http://feedproxy.google.com/~r/dmitrygusev/~3/1brkQH8urC4/gae-and-tapestry5-exception-handling.html</link>
 <description>Tapestry5 uses its own technique to process unhandled exceptions. &lt;br /&gt;When unhandled exception occurs Tapestry5 redirects response to special error page which is responsible to display exception detail.&lt;br /&gt;&lt;br /&gt;There is a standard error page in Tapestry5 that can be very helpful for developer if you configure your application to run in development mode. To do this you contribute &lt;code&gt;SymbolConstants.PRODUCTION_MODE&lt;/code&gt; symbol with value &lt;code&gt;&quot;false&quot;&lt;/code&gt; in your &lt;code&gt;AppModule.java&lt;/code&gt; like this:&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;static&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;contributeApplicationDefaults&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;br /&gt;    MappedConfiguration&lt;font color=&quot;#990000&quot;&gt;&amp;lt;&lt;/font&gt;String&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; String&lt;font color=&quot;#990000&quot;&gt;&amp;gt;&lt;/font&gt; configuration&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;br /&gt;&lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt; ...&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;    configuration&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;add&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;SymbolConstants&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;PRODUCTION_MODE&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;#FF0000&quot;&gt;&quot;false&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt; ...&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;Standard error page provides you all necessary information to understand the cause of exception:&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://2.bp.blogspot.com/__b4fPTzdGYs/THbQaaIAJkI/AAAAAAAAAkw/ykyoxwhYZGc/s1600/detailed-error-report.png&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 253px;&quot; src=&quot;http://2.bp.blogspot.com/__b4fPTzdGYs/THbQaaIAJkI/AAAAAAAAAkw/ykyoxwhYZGc/s400/detailed-error-report.png&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5509820346242442818&quot; /&gt;&lt;/a&gt;&lt;br /&gt;And here is how exception report looks like in production:&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://4.bp.blogspot.com/__b4fPTzdGYs/THbQa7Ecn9I/AAAAAAAAAk4/grHDbLWNNRI/s1600/production-error-report.png&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 48px;&quot; src=&quot;http://4.bp.blogspot.com/__b4fPTzdGYs/THbQa7Ecn9I/AAAAAAAAAk4/grHDbLWNNRI/s400/production-error-report.png&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5509820355085901778&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This is reasonable, because in production you usually don&#039;t want to display all this information to clients. But this is also not so user friendly, because it displays value of &lt;code&gt;Throwable.getMessage()&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;Tapestry5 allows &lt;a href=&quot;http://wiki.apache.org/tapestry/Tapestry5ExceptionPage&quot;&gt;overriding standard error page&lt;/a&gt; with your own exception page so you can display more user friendly messages.&lt;br /&gt;&lt;br /&gt;There&#039;s also another scenario when you don&#039;t want Tapestry5 to generate exception report, and let application server provide static HTML page with apologizes to client. This approach better suits for production, but in development mode its better to leave detailed error report as is.&lt;br /&gt;&lt;br /&gt;To change the way Tapestry5 handles exceptions you should provide another implementation of &lt;code&gt;RequestExceptionHandler&lt;/code&gt;. One way doing this is to decorate &lt;code&gt;RequestExceptionHandler&lt;/code&gt;:&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; RequestExceptionHandler &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;decorateRequestExceptionHandler&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;final&lt;/font&gt;&lt;/b&gt; Logger logger&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;final&lt;/font&gt;&lt;/b&gt; Response response&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt;&lt;br /&gt;        @&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;Symbol&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;SymbolConstants&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;PRODUCTION_MODE&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#009900&quot;&gt;boolean&lt;/font&gt; productionMode&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;br /&gt;&lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;  Leave default implementation of RequestExceptionHandler in development mode&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;!&lt;/font&gt;productionMode&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;null&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt; Provide simple implementation that logs exception and returns&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt; HTTP error code which will be handled by application server&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;return&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;new&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;RequestExceptionHandler&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;handleRequestException&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;Throwable exception&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;throws&lt;/font&gt;&lt;/b&gt; IOException&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;            logger&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;error&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;Unexpected runtime exception&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; exception&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;            &lt;br /&gt;            &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt; Return HTTP error code 500&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;            response&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;sendError&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;HttpServletResponse&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;SC_INTERNAL_SERVER_ERROR&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;null&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;        &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;&lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Next, add this markup to &lt;code&gt;web.xml&lt;/code&gt;:&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;error-page&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;error-code&amp;gt;&lt;/font&gt;&lt;/b&gt;500&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/error-code&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;location&amp;gt;&lt;/font&gt;&lt;/b&gt;/500.html&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/location&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/error-page&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now in case of any exceptions client will see contents of &lt;code&gt;500.html&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://3.bp.blogspot.com/__b4fPTzdGYs/THbSDKwKM1I/AAAAAAAAAlI/rx9inNVGkWc/s1600/error-500.png&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 122px;&quot; src=&quot;http://3.bp.blogspot.com/__b4fPTzdGYs/THbSDKwKM1I/AAAAAAAAAlI/rx9inNVGkWc/s400/error-500.png&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5509822146002170706&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This approach have one more advantage for GAE. Generating exception reports consumes billable CPU cycles and takes request processing time. &lt;br /&gt;&lt;br /&gt;Saving CPU cycles is good. And there is one note about request processing time. As you may know &lt;a href=&quot;http://code.google.com/appengine/docs/java/runtime.html#The%5FRequest%5FTimer&quot;&gt;on GAE each request have to be processed in 30 seconds&lt;/a&gt;. If it doesn&#039;t, then runtime raises &lt;code&gt;DeadlineExceededException&lt;/code&gt; and gives application few hundreds of milliseconds to fail gracefully. As practice shows, default T5 &lt;code&gt;RequestExceptionHandler&lt;/code&gt; + error report generation usually takes longer.&lt;br /&gt;&lt;br /&gt;One more note about GAE exception handling. Since version 1.3.6 GAE allows developers declare &lt;a href=&quot;http://code.google.com/appengine/docs/java/config/appconfig.html#Custom_Error_Responses&quot;&gt;custom static error handlers&lt;/a&gt; for GAE specific errors: &lt;code&gt;over_quota&lt;/code&gt;, &lt;code&gt;dos_api_denial&lt;/code&gt; and &lt;code&gt;timeout&lt;/code&gt;. &lt;br /&gt;In case of first two errors GAE doesn&#039;t even pass requests to application code. Timeout errors appear as a result of application code execution and (I suppose) this static error handler may conflict with &lt;code&gt;RequestExceptionHandler&lt;/code&gt; that overrides &lt;code&gt;DeadlineExceededException&lt;/code&gt; with HTTP error code 500.&lt;br /&gt;&lt;br /&gt;I also want to share my implementation of &lt;code&gt;over_quota.html&lt;/code&gt; page. I noticed free quotas got reset every day near 11am-12am Moscow Summer Time (its around 7am-8am UTC time, not sure if it the same for another applications). I thought it would be good if I include how many time is it left for GAE enabled free quotas next time. And though &lt;code&gt;over_quota.html&lt;/code&gt; is a static page it is possible to include a peace of javascript that calculates this time in client timezone. Here is it:&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;html&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;head&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;title&amp;gt;&lt;/font&gt;&lt;/b&gt;Ping Service - Over Capacity&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/title&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/head&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;body&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;h1&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;        Over Capacity&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;p&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;        We apologize for the inconvenience.&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/p&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;p&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;        Service is temporary unavailable until &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;span&lt;/font&gt;&lt;/b&gt; id=&lt;font color=&quot;#FF0000&quot;&gt;&quot;&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;deadline&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/b&gt;8:00 am UTC time.&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/span&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;        &lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;script&lt;/font&gt;&lt;/b&gt; type=&lt;font color=&quot;#FF0000&quot;&gt;&quot;&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;text/javascript&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;           var element = document.getElementById(&quot;deadline&quot;);&lt;br /&gt;           var now = new Date();&lt;br /&gt;           var deadline = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 8);&lt;br /&gt;           var timezoneOffset = now.getTimezoneOffset() / 60;&lt;br /&gt;           deadline.setHours(deadline.getHours() - timezoneOffset);&lt;br /&gt;           if (deadline &amp;lt;= now) {&lt;br /&gt;               deadline.setDate(deadline.getDate() + 1);&lt;br /&gt;           }&lt;br /&gt;           element.innerHTML = deadline.toLocaleTimeString().replace(/:00$/, &quot;&quot;) &lt;br /&gt;                             + &quot; your time (&quot; &lt;br /&gt;                             + Math.round((deadline - now) / 60 / 60 / 1000) &lt;br /&gt;                             + &quot; hours left).&quot;;&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/script&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/p&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/body&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/html&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://3.bp.blogspot.com/__b4fPTzdGYs/THbQbHriQAI/AAAAAAAAAlA/iVxTnpKBVUg/s1600/over-capacity.png&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 108px;&quot; src=&quot;http://3.bp.blogspot.com/__b4fPTzdGYs/THbQbHriQAI/AAAAAAAAAlA/iVxTnpKBVUg/s400/over-capacity.png&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5509820358471073794&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;See also&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;a href=&quot;http://wiki.apache.org/tapestry/Tapestry5HowToUseTapestryForCustomErrorPages&quot;&gt;Serving custom HTTP error codes with T5 pages&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Sources of &lt;a href=&quot;http://ping-service.appspot.com/&quot;&gt;one live T5 GAE application&lt;/a&gt;: &lt;a href=&quot;http://github.com/dmitrygusev/ping-service&quot;&gt;http://github.com/dmitrygusev/ping-service&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&#039;1&#039; height=&#039;1&#039; src=&#039;https://blogger.googleusercontent.com/tracker/25040534-1625985518436005333?l=dmitrygusev.blogspot.com&#039; alt=&#039;&#039; /&gt;&lt;/div&gt;&lt;div class=&quot;feedflare&quot;&gt;
&lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=1brkQH8urC4:kfdVYQwwLsw:V_sGLiPBpWU&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?i=1brkQH8urC4:kfdVYQwwLsw:V_sGLiPBpWU&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=1brkQH8urC4:kfdVYQwwLsw:7Q72WNTAKBA&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?d=7Q72WNTAKBA&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=1brkQH8urC4:kfdVYQwwLsw:yIl2AUoC8zA&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?d=yIl2AUoC8zA&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src=&quot;http://feeds.feedburner.com/~r/dmitrygusev/~4/1brkQH8urC4&quot; height=&quot;1&quot; width=&quot;1&quot;/&gt;</description>
 <pubDate>Fri, 27 Aug 2010 00:45:10 +0400</pubDate>
</item>
<item>
 <title>Mechanize и кодировки</title>
 <link>http://yurykorolev.blogspot.com/2008/10/harvester-data.html</link>
 <description>&lt;div class=&#039;posterous_autopost&#039;&gt;Для скинскрепинга мы используем &lt;a href=&quot;http://mechanize.rubyforge.org/mechanize/&quot;&gt;mechanize&lt;/a&gt;. В mechainizе все просто замечательно, если парсить сайты, которые отдают контент в ASCII или UTF-8 кодировках. Но если, попробовать отпарсить сайт в windows-1251 кодировке, то mechanize/nokogiri лажают.&lt;p /&gt;&lt;div&gt;Например, если сделать запрос к &lt;a href=&quot;http://kinopoisk.ru&quot;&gt;kinopoisk.ru&lt;/a&gt;,  то получим непонятный результат:&lt;/div&gt;&lt;div&gt;Код:&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;data syntax type-ruby&quot;&gt;  &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt; &lt;tr&gt; &lt;td&gt; &lt;pre class=&quot;line_numbers&quot;&gt;&lt;span rel=&quot;#L1&quot; id=&quot;LID1&quot;&gt;1&lt;/span&gt; &lt;span rel=&quot;#L2&quot; id=&quot;LID2&quot;&gt;2&lt;/span&gt; &lt;span rel=&quot;#L3&quot; id=&quot;LID3&quot;&gt;3&lt;/span&gt; &lt;span rel=&quot;#L4&quot; id=&quot;LID4&quot;&gt;4&lt;/span&gt; &lt;span rel=&quot;#L5&quot; id=&quot;LID5&quot;&gt;5&lt;/span&gt; &lt;span rel=&quot;#L6&quot; id=&quot;LID6&quot;&gt;6&lt;/span&gt; &lt;span rel=&quot;#L7&quot; id=&quot;LID7&quot;&gt;7&lt;/span&gt; &lt;span rel=&quot;#L8&quot; id=&quot;LID8&quot;&gt;8&lt;/span&gt; &lt;span rel=&quot;#L9&quot; id=&quot;LID9&quot;&gt;9&lt;/span&gt; &lt;span rel=&quot;#L10&quot; id=&quot;LID10&quot;&gt;10&lt;/span&gt; &lt;span rel=&quot;#L11&quot; id=&quot;LID11&quot;&gt;11&lt;/span&gt; &lt;span rel=&quot;#L12&quot; id=&quot;LID12&quot;&gt;12&lt;/span&gt; &lt;/pre&gt; &lt;/td&gt; &lt;td width=&quot;100%&quot;&gt;  &lt;div class=&quot;highlight&quot;&gt;&lt;pre /&gt;&lt;div class=&quot;line&quot; id=&quot;LC1&quot;&gt;&lt;span class=&quot;c1&quot;&gt;#encoding: utf-8&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC2&quot;&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;mechanize&amp;#39;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC3&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC4&quot;&gt;&lt;span class=&quot;no&quot;&gt;KINOPOISK_SEARCH_URL&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;http://kinopoisk.ru/index.php?kp_query=&amp;#39;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC5&quot;&gt;&lt;span class=&quot;n&quot;&gt;query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;терминатор&amp;#39;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC6&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC7&quot;&gt;&lt;span class=&quot;n&quot;&gt;agent&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Mechanize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC8&quot;&gt;&lt;span class=&quot;n&quot;&gt;agent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;  &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;KINOPOISK_SEARCH_URL&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;windows-1251&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC9&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC10&quot;&gt;&lt;span class=&quot;n&quot;&gt;agent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;search&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;td.news[width]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;map&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;section&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC11&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;section&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;at&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.all&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;content&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC12&quot;&gt;&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;  &lt;/div&gt;&lt;/div&gt; &lt;div&gt;результат:&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;data syntax type-text&quot;&gt;  &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt; &lt;tr&gt; &lt;td&gt; &lt;pre class=&quot;line_numbers&quot;&gt;&lt;span rel=&quot;#L1&quot; id=&quot;LID1&quot;&gt;1&lt;/span&gt; &lt;span rel=&quot;#L2&quot; id=&quot;LID2&quot;&gt;2&lt;/span&gt; &lt;span rel=&quot;#L3&quot; id=&quot;LID3&quot;&gt;3&lt;/span&gt; &lt;span rel=&quot;#L4&quot; id=&quot;LID4&quot;&gt;4&lt;/span&gt; &lt;span rel=&quot;#L5&quot; id=&quot;LID5&quot;&gt;5&lt;/span&gt; &lt;span rel=&quot;#L6&quot; id=&quot;LID6&quot;&gt;6&lt;/span&gt; &lt;span rel=&quot;#L7&quot; id=&quot;LID7&quot;&gt;7&lt;/span&gt; &lt;/pre&gt; &lt;/td&gt; &lt;td width=&quot;100%&quot;&gt;  &lt;div class=&quot;highlight&quot;&gt;&lt;pre /&gt;&lt;div class=&quot;line&quot; id=&quot;LC1&quot;&gt;Òåðìèíàòîð&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC2&quot;&gt;Òåðìèíàòîð: Äà ïðèä¸ò ñïàñèòåëü&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC3&quot;&gt;Òåðìèíàòîð 2: Ñóäíûé äåíü&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC4&quot;&gt;Òåðìèíàòîð 3: Âîññòàíèå ìàøèí&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC5&quot;&gt;Òåðìèíàòîð: Áèòâà çà áóäóùåå (ñåðèàë)&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC6&quot;&gt;Òåðìèíàòîð 2 - 3D&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC7&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;  &lt;/div&gt;&lt;/div&gt;&lt;p /&gt;&lt;div&gt;Решения в гугле найти не получилось, пробовали всяки манкипатчи, но как-то не очень красиво получалось :( &lt;/div&gt; &lt;div&gt;В итоге выкрутились через &lt;a href=&quot;http://mechanize.rubyforge.org/mechanize/Mechanize.html#M000225&quot;&gt;Mechanize#post_connect_hooks&lt;/a&gt;:&lt;/div&gt;&lt;div&gt;Добавили MechanizeEncodingHook&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;data syntax type-ruby&quot;&gt;  &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt; &lt;tr&gt; &lt;td&gt; &lt;pre class=&quot;line_numbers&quot;&gt;&lt;span rel=&quot;#L1&quot; id=&quot;LID1&quot;&gt;1&lt;/span&gt; &lt;span rel=&quot;#L2&quot; id=&quot;LID2&quot;&gt;2&lt;/span&gt; &lt;span rel=&quot;#L3&quot; id=&quot;LID3&quot;&gt;3&lt;/span&gt; &lt;span rel=&quot;#L4&quot; id=&quot;LID4&quot;&gt;4&lt;/span&gt; &lt;span rel=&quot;#L5&quot; id=&quot;LID5&quot;&gt;5&lt;/span&gt; &lt;span rel=&quot;#L6&quot; id=&quot;LID6&quot;&gt;6&lt;/span&gt; &lt;span rel=&quot;#L7&quot; id=&quot;LID7&quot;&gt;7&lt;/span&gt; &lt;span rel=&quot;#L8&quot; id=&quot;LID8&quot;&gt;8&lt;/span&gt; &lt;span rel=&quot;#L9&quot; id=&quot;LID9&quot;&gt;9&lt;/span&gt; &lt;span rel=&quot;#L10&quot; id=&quot;LID10&quot;&gt;10&lt;/span&gt; &lt;span rel=&quot;#L11&quot; id=&quot;LID11&quot;&gt;11&lt;/span&gt; &lt;span rel=&quot;#L12&quot; id=&quot;LID12&quot;&gt;12&lt;/span&gt; &lt;span rel=&quot;#L13&quot; id=&quot;LID13&quot;&gt;13&lt;/span&gt; &lt;span rel=&quot;#L14&quot; id=&quot;LID14&quot;&gt;14&lt;/span&gt; &lt;span rel=&quot;#L15&quot; id=&quot;LID15&quot;&gt;15&lt;/span&gt; &lt;span rel=&quot;#L16&quot; id=&quot;LID16&quot;&gt;16&lt;/span&gt; &lt;span rel=&quot;#L17&quot; id=&quot;LID17&quot;&gt;17&lt;/span&gt; &lt;span rel=&quot;#L18&quot; id=&quot;LID18&quot;&gt;18&lt;/span&gt; &lt;span rel=&quot;#L19&quot; id=&quot;LID19&quot;&gt;19&lt;/span&gt; &lt;span rel=&quot;#L20&quot; id=&quot;LID20&quot;&gt;20&lt;/span&gt; &lt;span rel=&quot;#L21&quot; id=&quot;LID21&quot;&gt;21&lt;/span&gt; &lt;span rel=&quot;#L22&quot; id=&quot;LID22&quot;&gt;22&lt;/span&gt; &lt;span rel=&quot;#L23&quot; id=&quot;LID23&quot;&gt;23&lt;/span&gt; &lt;span rel=&quot;#L24&quot; id=&quot;LID24&quot;&gt;24&lt;/span&gt; &lt;span rel=&quot;#L25&quot; id=&quot;LID25&quot;&gt;25&lt;/span&gt; &lt;span rel=&quot;#L26&quot; id=&quot;LID26&quot;&gt;26&lt;/span&gt; &lt;span rel=&quot;#L27&quot; id=&quot;LID27&quot;&gt;27&lt;/span&gt; &lt;span rel=&quot;#L28&quot; id=&quot;LID28&quot;&gt;28&lt;/span&gt; &lt;span rel=&quot;#L29&quot; id=&quot;LID29&quot;&gt;29&lt;/span&gt; &lt;span rel=&quot;#L30&quot; id=&quot;LID30&quot;&gt;30&lt;/span&gt; &lt;span rel=&quot;#L31&quot; id=&quot;LID31&quot;&gt;31&lt;/span&gt; &lt;span rel=&quot;#L32&quot; id=&quot;LID32&quot;&gt;32&lt;/span&gt; &lt;span rel=&quot;#L33&quot; id=&quot;LID33&quot;&gt;33&lt;/span&gt; &lt;span rel=&quot;#L34&quot; id=&quot;LID34&quot;&gt;34&lt;/span&gt; &lt;span rel=&quot;#L35&quot; id=&quot;LID35&quot;&gt;35&lt;/span&gt; &lt;span rel=&quot;#L36&quot; id=&quot;LID36&quot;&gt;36&lt;/span&gt; &lt;span rel=&quot;#L37&quot; id=&quot;LID37&quot;&gt;37&lt;/span&gt; &lt;span rel=&quot;#L38&quot; id=&quot;LID38&quot;&gt;38&lt;/span&gt; &lt;/pre&gt; &lt;/td&gt; &lt;td width=&quot;100%&quot;&gt;  &lt;div class=&quot;highlight&quot;&gt;&lt;pre /&gt;&lt;div class=&quot;line&quot; id=&quot;LC1&quot;&gt;&lt;span class=&quot;c1&quot;&gt;#encoding: utf-8&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC2&quot;&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;mechanize&amp;#39;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC3&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC4&quot;&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MechanizeEncodingHook&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC5&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC6&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:response&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nil?&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:response_body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nil?&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC7&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:response&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC9&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;n&quot;&gt;content_type&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;Content-Type&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC10&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC11&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;n&quot;&gt;internal_encoding&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Encoding&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;default_internal&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to_s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;downcase&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC12&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC13&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;n&quot;&gt;charset&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;windows-1251&amp;#39;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC14&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;content_type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nil?&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC15&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;charset&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;content_type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;charset&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(?&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;charset&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;charset&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nil?&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC16&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC17&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;n&quot;&gt;content_type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;content_type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sub&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/charset=.*/&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC18&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;s2&quot;&gt;&quot;charset=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;internal_encoding&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC19&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;Content-Type&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;content_type&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC20&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC21&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;n&quot;&gt;response_body&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:response_body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC22&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;n&quot;&gt;force_encoding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;charset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC23&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;n&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;internal_encoding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC24&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;n&quot;&gt;response_body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[/&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;#{charset}/] = internal_encoding&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC25&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;n&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:response_body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response_body&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC26&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC27&quot;&gt;&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC28&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC29&quot;&gt;&lt;span class=&quot;no&quot;&gt;KINOPOISK_SEARCH_URL&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;http://kinopoisk.ru/index.php?kp_query=&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC30&quot;&gt;&lt;span class=&quot;n&quot;&gt;query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;терминатор&amp;#39;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC31&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC32&quot;&gt;&lt;span class=&quot;n&quot;&gt;agent&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Mechanize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC33&quot;&gt;&lt;span class=&quot;n&quot;&gt;agent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;post_connect_hooks&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;MechanizeEncodingHook&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC34&quot;&gt;&lt;span class=&quot;n&quot;&gt;agent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;  &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;KINOPOISK_SEARCH_URL&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;windows-1251&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC35&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC36&quot;&gt;&lt;span class=&quot;n&quot;&gt;agent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;search&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;td.news[width]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;map&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;section&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC37&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;section&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;at&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.all&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;content&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC38&quot;&gt;&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;  &lt;/div&gt;&lt;/div&gt; &lt;div&gt;И в итоге получаем нормальный результат:&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;data syntax type-text&quot;&gt;  &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt; &lt;tr&gt; &lt;td&gt; &lt;pre class=&quot;line_numbers&quot;&gt;&lt;span rel=&quot;#L1&quot; id=&quot;LID1&quot;&gt;1&lt;/span&gt; &lt;span rel=&quot;#L2&quot; id=&quot;LID2&quot;&gt;2&lt;/span&gt; &lt;span rel=&quot;#L3&quot; id=&quot;LID3&quot;&gt;3&lt;/span&gt; &lt;span rel=&quot;#L4&quot; id=&quot;LID4&quot;&gt;4&lt;/span&gt; &lt;span rel=&quot;#L5&quot; id=&quot;LID5&quot;&gt;5&lt;/span&gt; &lt;span rel=&quot;#L6&quot; id=&quot;LID6&quot;&gt;6&lt;/span&gt; &lt;span rel=&quot;#L7&quot; id=&quot;LID7&quot;&gt;7&lt;/span&gt; &lt;/pre&gt; &lt;/td&gt; &lt;td width=&quot;100%&quot;&gt;  &lt;div class=&quot;highlight&quot;&gt;&lt;pre /&gt;&lt;div class=&quot;line&quot; id=&quot;LC1&quot;&gt;Терминатор&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC2&quot;&gt;Терминатор: Да придёт спаситель&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC3&quot;&gt;Терминатор 2: Судный день&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC4&quot;&gt;Терминатор 3: Восстание машин&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC5&quot;&gt;Терминатор: Битва за будущее (сериал)&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC6&quot;&gt;Терминатор 2 - 3D&lt;/div&gt;&lt;div class=&quot;line&quot; id=&quot;LC7&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;  &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&#039;1&#039; height=&#039;1&#039; src=&#039;https://blogger.googleusercontent.com/tracker/7707384552387895298-3721551655326669175?l=yurykorolev.blogspot.com&#039; alt=&#039;&#039; /&gt;&lt;/div&gt;</description>
 <pubDate>Sun, 18 Jul 2010 14:03:00 +0400</pubDate>
</item>
<item>
 <title>AnjLab.FX Scheduler for ASP.NET</title>
 <link>http://feedproxy.google.com/~r/dmitrygusev/~3/qV0NNCMH2rA/anjlabfx-scheduler-for-aspnet.html</link>
 <description>If you need simple yet easy configurable scheduler in your ASP.NET application, AnjLab.FX Scheduler might be your choise.&lt;br /&gt;&lt;br /&gt;To use AnjLab.FX Scheduler you need to do 3 simple steps:&lt;br /&gt;&lt;br /&gt;&lt;ol start=&quot;0&quot;&gt;&lt;br /&gt;&lt;li&gt;Get the latest version of AnjLab.FX from &lt;a href=&quot;http://github.com/anjlab/fx&quot;&gt;github&lt;/a&gt;, make a build and add AnjLab.FX.dll as a reference to your project;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Implement &lt;code&gt;AnjLab.FX.Sys.ICommand&lt;/code&gt; interface on your task workers&lt;/span&gt;, like this:&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;class&lt;/font&gt;&lt;/b&gt; HelloWorldTask &lt;font color=&quot;#990000&quot;&gt;:&lt;/font&gt; ICommand&lt;br /&gt;&lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;private&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;static&lt;/font&gt;&lt;/b&gt; readonly log4net&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;ILog Log &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; log4net&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;LogManager&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;GetLogger&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;typeof&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;HelloWorldTask&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;public&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;Execute&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;        Log&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;Info&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;Hello World!&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Configure tasks schedule in &lt;code&gt;web.config&lt;/code&gt;.&lt;/span&gt; To do this you need to:&lt;br /&gt;&lt;ol start=&quot;a&quot;&gt;&lt;br /&gt;&lt;li&gt;add the following line to &lt;code&gt;web.config/configuration/configSections&lt;/code&gt;:&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#000080&quot;&gt;&amp;lt;?xml&lt;/font&gt;&lt;/b&gt; version=&lt;font color=&quot;#FF0000&quot;&gt;&quot;&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;1.0&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;&lt;/font&gt; encoding=&lt;font color=&quot;#FF0000&quot;&gt;&quot;&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;UTF-8&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000080&quot;&gt;?&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;configuration&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;configSections&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;        ...&lt;br /&gt;        &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;section&lt;/font&gt;&lt;/b&gt; name=&lt;font color=&quot;#FF0000&quot;&gt;&quot;&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;triggers&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;&lt;/font&gt; type=&lt;font color=&quot;#FF0000&quot;&gt;&quot;&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;AnjLab.FX.Tasks.Scheduling.SchedulerConfigSection, AnjLab.FX&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;/&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;        ...&lt;/tt&gt;&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;define &lt;code&gt;triggers&lt;/code&gt; section:&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;configuration&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;  ...&lt;br /&gt;  &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;triggers&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;&amp;lt;!--&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;    &amp;lt;daily    tag=&#039;restoreDB&#039;    timeOfDay=&#039;23:00&#039;/&amp;gt;&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;    &amp;lt;weekly   tag=&#039;backupDB&#039;     timeOfDay=&#039;01:30&#039; weekDays=&#039;monday,friday&#039;/&amp;gt;&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;    &amp;lt;hourly   tag=&#039;delTempFiles&#039; minutes=&#039;30&#039;/&amp;gt;&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;    &amp;lt;interval tag=&#039;dumpLog&#039;      interval=&#039;00:05:00&#039;/&amp;gt;&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;    &amp;lt;once     tag=&#039;upgradeDB&#039;    dateTime=&#039;01/15/2007 23:00&#039;/&amp;gt;&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;    &amp;lt;monthly  tag=&#039;archiveDB&#039;    monthDay=&#039;29&#039; timeOfDay=&#039;23:00&#039;/&amp;gt;&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;    &lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;--&amp;gt;&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;interval&lt;/font&gt;&lt;/b&gt; tag=&#039;helloworld-task&#039; interval=&#039;00:00:10&#039;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;/&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;  &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/triggers&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;  ...&lt;br /&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;&amp;lt;/configuration&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;br /&gt;Here we defined named trigger &quot;helloworld-task&quot; to be triggered every 10 seconds.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;li&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Map trigger names to your task workers and start up the scheduler.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To map your task workers you create instance of KeyedFactory and register your tasks. We propose you do this in &lt;code&gt;Global.asax&lt;/code&gt; &lt;code&gt;Application_Start&lt;/code&gt; method:&lt;br /&gt;&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.1.2&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;protected&lt;/font&gt;&lt;/b&gt; &lt;font color=&quot;#009900&quot;&gt;void&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;Application_Start&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;object sender&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; EventArgs e&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;br /&gt;&lt;font color=&quot;#FF0000&quot;&gt;{&lt;/font&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;//&lt;/font&gt;&lt;/i&gt;&lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt; Map trigger names to task workers&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;    var factory &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;new&lt;/font&gt;&lt;/b&gt; KeyedFactory&lt;font color=&quot;#990000&quot;&gt;&amp;lt;&lt;/font&gt;string&lt;font color=&quot;#990000&quot;&gt;,&lt;/font&gt; ICommand&lt;font color=&quot;#990000&quot;&gt;&amp;gt;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    factory&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;RegisterType&lt;font color=&quot;#990000&quot;&gt;&amp;lt;&lt;/font&gt;HelloWorldTask&lt;font color=&quot;#990000&quot;&gt;&amp;gt;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;helloworld-task&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color=&quot;#9A1900&quot;&gt;// Start up scheduler&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;    var scheduler &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color=&quot;#0000FF&quot;&gt;new&lt;/font&gt;&lt;/b&gt; Scheduler&lt;font color=&quot;#990000&quot;&gt;&amp;lt;&lt;/font&gt;ICommand&lt;font color=&quot;#990000&quot;&gt;&amp;gt;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;factory&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;    &lt;br /&gt;    var triggers &lt;font color=&quot;#990000&quot;&gt;=&lt;/font&gt; &lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;List&lt;font color=&quot;#990000&quot;&gt;&amp;lt;&lt;/font&gt;ITrigger&lt;font color=&quot;#990000&quot;&gt;&amp;gt;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;ConfigurationManager&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;GetSection&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#FF0000&quot;&gt;&quot;triggers&quot;&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    scheduler&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;RegisterTriggers&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;triggers&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;ToArray&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;    scheduler&lt;font color=&quot;#990000&quot;&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#000000&quot;&gt;Start&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;#990000&quot;&gt;;&lt;/font&gt;&lt;br /&gt;&lt;font color=&quot;#FF0000&quot;&gt;}&lt;/font&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Thats it!&lt;br /&gt;&lt;br /&gt;Resources:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;AnjLab.FX on github: &lt;a href=&quot;http://github.com/anjlab/fx&quot;&gt;http://github.com/anjlab/fx&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href=&quot;http://www.rsdn.ru/article/patterns/KeyedFactory.xml&quot;&gt;Here&lt;/a&gt; is an article about KeyedFactory pattern in Russian&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;P.S.&lt;br /&gt;By the way, you can also use this API to schedule your tasks in Windows.Forms applications as well.&lt;br /&gt;&lt;br /&gt;P.P.S.&lt;br /&gt;AnjLab.FX is a framework we built during development of our projects. Its continue evolving and you can use it in your applications without any restrictions.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&#039;1&#039; height=&#039;1&#039; src=&#039;https://blogger.googleusercontent.com/tracker/25040534-1536218083141262518?l=dmitrygusev.blogspot.com&#039; alt=&#039;&#039; /&gt;&lt;/div&gt;&lt;div class=&quot;feedflare&quot;&gt;
&lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=qV0NNCMH2rA:QMqpUsXpss8:V_sGLiPBpWU&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?i=qV0NNCMH2rA:QMqpUsXpss8:V_sGLiPBpWU&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=qV0NNCMH2rA:QMqpUsXpss8:7Q72WNTAKBA&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?d=7Q72WNTAKBA&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?a=qV0NNCMH2rA:QMqpUsXpss8:yIl2AUoC8zA&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~ff/dmitrygusev?d=yIl2AUoC8zA&quot; border=&quot;0&quot;&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src=&quot;http://feeds.feedburner.com/~r/dmitrygusev/~4/qV0NNCMH2rA&quot; height=&quot;1&quot; width=&quot;1&quot;/&gt;</description>
 <pubDate>Fri, 14 May 2010 17:02:01 +0400</pubDate>
</item>
<item>
 <title>C#: RefreshSection method of ConfigurationManager is not refreshing sections under debug mode</title>
 <link>http://zhebrun.blogspot.com/2007/10/converting-object-collection-to.html</link>
 <description>RefreshSection method of ConfigurationManager is not refreshing sections when you run application at Visual Studio. Try to run application without VS.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&#039;1&#039; height=&#039;1&#039; src=&#039;https://blogger.googleusercontent.com/tracker/1376361569711944681-1058313331807553685?l=zhebrun.blogspot.com&#039; alt=&#039;&#039; /&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 13 Apr 2010 14:52:00 +0400</pubDate>
</item>
</channel>
</rss>
