<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2429877696364208688</id><updated>2012-01-25T20:22:32.149+01:00</updated><category term='Seam 2.1.1'/><category term='MyISAM'/><category term='Ubuntu hardy'/><category term='JPA'/><category term='java 5'/><category term='Cache'/><category term='Seam'/><category term='IdentityManager'/><category term='Hibernate'/><category term='jodconverter 3'/><category term='Encryption'/><category term='Tehran'/><category term='rpi'/><category term='JavaOne'/><category term='second level cache'/><category term='OSS'/><category term='Jasypt'/><category term='firefox'/><category term='jboss 4'/><category term='jrebel'/><category term='seam-gen'/><category term='testng'/><category term='Devoxx'/><category term='wicket'/><category term='Guava'/><category term='Comment'/><category term='ODT'/><category term='richfaces'/><category term='axis2'/><category term='JavaPolis'/><category term='rollermouse pro'/><category term='musehånd'/><category term='sigar'/><category term='persistence.xml'/><category term='ant'/><category term='MySQL'/><category term='Seam Series'/><category term='java 7'/><category term='EJB3'/><category term='Freemarker'/><category term='PDF'/><category term='UTF-8'/><category term='Seam book'/><category term='OpenOffice'/><category term='treecache'/><category term='ptql'/><category term='prettify'/><category term='Windows vista'/><category term='Java'/><category term='html cache'/><category term='InnoDB'/><category term='webservice'/><category term='filters'/><category term='s:cache'/><category term='jquery'/><category term='java 6'/><category term='javazone'/><category term='JOOReport'/><category term='hash password'/><category term='jodconverter'/><category term='Iran'/><category term='interceptor'/><category term='IE8'/><category term='damenes tale'/><category term='jboss'/><category term='julebord'/><category term='JSF'/><category term='Memory'/><category term='Enum'/><category term='Seam 2'/><category term='chess'/><category term='pdfa'/><category term='jboss-ws'/><title type='text'>Java, write once, run away!</title><subtitle type='html'>This blog is mainly about Java...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>53</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-1358061000435410834</id><published>2011-09-08T19:56:00.000+02:00</published><updated>2011-09-08T19:56:20.911+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javazone'/><title type='text'>JavaZone 2011 - My two cents</title><content type='html'>I just came back from JavaZone 2011, and I have some thoughts.&lt;br /&gt;&lt;br /&gt;All in all it was a nice conference. The first day was a little booring. Few really nice talks. However the last day had some really nice talks.&lt;br /&gt;&lt;br /&gt;The talks I went to that are worth mentioning are: &lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;a href="http://jashkenas.github.com/coffee-script"&gt;CoffeScript&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;I am not sure what to make of this relatively new scripting language. At first during the presentation, I was very sceptical. The idea is basically to remove/hide out a lot of boiler plate JavaScript code and replace it by magic that adds this at runtime later. It also adds a lot of features on top of JavaScript which made it very cool. That's why I am still on the fence on this one. Can't really decide. However, I don't write that much JavaScript, and thankfully with the help of JQuery, I don't need to. So I don't think I will be looking into this until I really feel that I write a lot of tedious JavaScript.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;a href="http://www.javaposse.com/"&gt;JavaPosse&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;Always great! Nuff said!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;"Men så hør du da bruker det feil" (dust)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;This was a really nice talk from Kåre Nilsen, which basically warned us about Java Frameworks and library hell. He said that we should all think before we add or use a framework, and have a valid reason as to why we use it. We also should know what each library that is bundled with the framework is doing, and we should ask our self if we really need it. Maybe we just can take out the part of the code in the library we are using, and just paste that in our projects.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;a href="http://www.blogger.com/www.playframework.org/"&gt;Play! Framework: to infinity and beyond&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;I had heard and tested Play! once before this talk, and I found the framework so interesting that I wanted to learn more. And boy am I impressed. This is a framework that you definetly will hear more about in the future. But they did announce that in Play 2, they might break java compatibility and only work with Scala. I don't know what I feel about that, because that kinda forces you to learn "two" things at once. Both Scala and Play!&lt;br /&gt;However, instead of me explaining what Play! is, go check it out! &lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;DISCLAIMER&lt;/b&gt;: If your talk is not in this list, its probably just because I didn't attend it. It doesn't mean your session was bad or uninteresting.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-1358061000435410834?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/1358061000435410834/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=1358061000435410834' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/1358061000435410834'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/1358061000435410834'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2011/09/javazone-2011-my-two-cents.html' title='JavaZone 2011 - My two cents'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-5114501487818601682</id><published>2011-03-21T14:51:00.003+01:00</published><updated>2011-03-21T14:56:27.898+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ptql'/><category scheme='http://www.blogger.com/atom/ns#' term='jodconverter 3'/><category scheme='http://www.blogger.com/atom/ns#' term='sigar'/><title type='text'>API helper / wrapper for ProcessFinder in Hyperic Sigar PTQL</title><content type='html'>In my previous &lt;a href="http://shervinasgari.blogspot.com/2011/03/commit-access-to-jodconverter.html"&gt;blog post&lt;/a&gt; I wrote that I was going to implement &lt;a href="http://support.hyperic.com/display/SIGAR/Home"&gt;Hyperic Sigar&lt;/a&gt; in &lt;a href="http://code.google.com/p/jodconverter/"&gt;JODConverter&lt;/a&gt;. Well the alpha is done, and you can go try it out &lt;a href="http://code.google.com/p/jodconverter/source/browse/#svn%2Fbranches%2F3.0-sigar%2Fjodconverter-core"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;When rewriting the code to use the ProcessFinder in Sigar, I found it very cumbersome to work with &lt;a href="http://support.hyperic.com/display/SIGAR/PTQL"&gt;PTQL&lt;/a&gt;, which is the Process Table Query Language for Sigar.&lt;br /&gt;&lt;br /&gt;Sigar describes PTQL as:&lt;br /&gt;&lt;i&gt;Hyperic SIGAR provides a mechanism to identify processes called Process Table Query Language. All operating systems assign a unique id (PID) to each running process. However, the PID is a random number that may also change at any point in time when a process is restarted. PTQL uses process attributes that will persist over time to identify a process.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;PTQL is string based, and the processFinder takes the ptql as string as parameter.&lt;br /&gt;&lt;code class="prettyprint"&gt;&lt;br /&gt;processFinder.find("State.Name.eq=java"); //Returns all the process id's named java&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;I have jboss already running and the ps command locally gives me the pid: &lt;b&gt;28258&lt;/b&gt;&lt;br /&gt;&lt;pre class="prettyprint" style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&amp;gt; ps -ef | grep jboss&lt;br /&gt;&amp;gt; shervin  28258 27055 20 13:53 pts/1    00:02:36 /usr/lib/jvm/java-6-sun-1.6.0.24/bin/java -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:54988 -javaagent:/home/shervin/opt/jrebel/jrebel.jar -noverify -Dprogram.name=JBossTools: JBoss EAP 5.0 Runtime -Xms512m -Xmx768m -XX:MaxPermSize=512m -Djava.net.preferIPv4Stack=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.endorsed.dirs=/home/shervin/opt/jboss/lib/endorsed -Djava.library.path=/usr/lib/jvm/java-6-sun/jre/lib/i386/server:/usr/lib/jvm/jdk1.5.0_22/jre/lib/i386:/usr/lib/jvm/jdk1.5.0_22/jre/../lib/i386:/usr/lib/jvm/jdk1.5.0_22/jre/lib/i386/client:/usr/lib/jvm/jdk1.5.0_22/jre/lib/i386:/usr/lib/xulrunner-addons:/usr/lib/xulrunner-addons:/usr/lib/ure/lib/:/home/shervin/lib/lib-src/hyperic-sigar-1.6.4-src/bindings/java/sigar-bin/lib -Dfile.encoding=UTF-8 -classpath /home/shervin/opt/jboss/bin/run.jar org.jboss.Main --configuration=default -b localhost&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;When running the sigar shell &lt;i&gt;(java -jar sigar.jar)&lt;/i&gt; and writing &lt;br /&gt;&lt;code class="prettyprint"&gt;sigar&amp;gt; pargs 28258&lt;/code&gt;&lt;br /&gt;It gives the output (the numbers are arguments) &lt;br /&gt;&lt;pre class="prettyprint" style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;pid=28258&lt;br /&gt;exe=/usr/lib/jvm/java-6-sun-1.6.0.24/jre/bin/java&lt;br /&gt;cwd=/home/shervin/opt/jboss-eap-5.1/jboss-as/bin&lt;br /&gt;   0=&amp;gt;/usr/lib/jvm/java-6-sun-1.6.0.24/bin/java&amp;lt;=&lt;br /&gt;   1=&amp;gt;-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:54988&amp;lt;=&lt;br /&gt;   2=&amp;gt;-javaagent:/home/shervin/opt/jrebel/jrebel.jar&amp;lt;=&lt;br /&gt;   3=&amp;gt;-noverify&amp;lt;=&lt;br /&gt;   4=&amp;gt;-Dprogram.name=JBossTools: JBoss EAP 5.0 Runtime&amp;lt;=&lt;br /&gt;   5=&amp;gt;-Xms512m&amp;lt;=&lt;br /&gt;   6=&amp;gt;-Xmx768m&amp;lt;=&lt;br /&gt;   7=&amp;gt;-XX:MaxPermSize=512m&amp;lt;=&lt;br /&gt;   8=&amp;gt;-Djava.net.preferIPv4Stack=true&amp;lt;=&lt;br /&gt;   9=&amp;gt;-Dsun.rmi.dgc.client.gcInterval=3600000&amp;lt;=&lt;br /&gt;   10=&amp;gt;-Dsun.rmi.dgc.server.gcInterval=3600000&amp;lt;=&lt;br /&gt;   11=&amp;gt;-Djava.endorsed.dirs=/home/shervin/opt/jboss/lib/endorsed&amp;lt;=&lt;br /&gt;   12=&amp;gt;-Djava.library.path=/usr/lib/jvm/java-6-sun/jre/lib/i386/server:/usr/lib/jvm/jdk1.5.0_22/jre/lib/i386:/usr/lib/jvm/jdk1.5.0_22/jre/../lib/i386:/usr/lib/jvm/jdk1.5.0_22/jre/lib/i386/client:/usr/lib/jvm/jdk1.5.0_22/jre/lib/i386:/usr/lib/xulrunner-addons:/usr/lib/xulrunner-addons:/usr/lib/ure/lib/:/home/shervin/lib/lib-src/hyperic-sigar-1.6.4-src/bindings/java/sigar-bin/lib&amp;lt;=&lt;br /&gt;   13=&amp;gt;-Dfile.encoding=UTF-8&amp;lt;=&lt;br /&gt;   14=&amp;gt;-classpath&amp;lt;=&lt;br /&gt;   15=&amp;gt;/home/shervin/opt/jboss/bin/run.jar&amp;lt;=&lt;br /&gt;   16=&amp;gt;org.jboss.Main&amp;lt;=&lt;br /&gt;   17=&amp;gt;--configuration=default&amp;lt;=&lt;br /&gt;   18=&amp;gt;-b&amp;lt;=&lt;br /&gt;   19=&amp;gt;localhost&amp;lt;=&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Now imagine you want to create a more advanced query which takes the one or more of the 19 arguments the java process takes.&lt;br /&gt;&lt;br /&gt;The query would look something like this:&lt;br /&gt;&lt;br /&gt;&lt;pre class="prettyprint" style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;processFinder.find("State.Name.ct=java,Args.5.eq=-Xms512m,Args.6.eq=-Xmx768m,Args.7.re=.*MaxPermSize=512m,Args.17.ct=configuration=default,Args.19.eq=localhost");&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;or you are building the query based on variables which you must retrieve somewhere else&lt;br /&gt;&lt;pre class="prettyprint" style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;public void testArgs() throws Exception {&lt;br /&gt;        String state_name= "State.Name.ct=java";&lt;br /&gt;        String arg5 = ",Args.5.eq=-Xms512m";&lt;br /&gt;        String arg6 = ",Args.6.eq=-Xmx768m";&lt;br /&gt;        String arg7 = ",Args.7.re=.*MaxPermSize=512m";&lt;br /&gt;        String arg17 = ",Args.17.ct=configuration=default";&lt;br /&gt;        String arg19 = ",Args.19.eq=localhost"; &lt;br /&gt;        ProcessFinder processFinder = new ProcessFinder(new Sigar());&lt;br /&gt;        processFinder.find(state_name + arg5 + arg6+ arg7 + arg17 + arg19);&lt;br /&gt;    }&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;It doesn't take a genius to see that it is easy to make mistakes. Hence the more type-safe way of creating PTQL queries.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;SimplePTQL&lt;/h3&gt;&lt;br /&gt;I took the liberty to create a helper/wrapper class for ProcessFinder which tries to eliminate some of the errors you can do. &lt;br /&gt;For instance, instead of the code above, you would write the following:&lt;br /&gt;&lt;br /&gt;&lt;pre class="prettyprint" style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;SimplePTQL ptql = new SimplePTQL.Builder(SimplePTQL.STATE_NAME(), SimplePTQL.CT(), &amp;quot;java&amp;quot;)&lt;br /&gt;                    .addArgs(5, SimplePTQL.EQ(), &amp;quot;-Xms512m&amp;quot;, Strategy.NOT_ESCAPE)&lt;br /&gt;                    .addArgs(6, SimplePTQL.EQ(), &amp;quot;-Xmx768m&amp;quot;, Strategy.NOT_ESCAPE)&lt;br /&gt;                    .addArgs(7, SimplePTQL.RE(), &amp;quot;.*MaxPermSize=512m&amp;quot;, Strategy.ESCAPE)&lt;br /&gt;                    .addArgs(17, SimplePTQL.CT(), &amp;quot;configuration=default&amp;quot;, Strategy.NOT_ESCAPE)&lt;br /&gt;                    .addArgs(19, SimplePTQL.EQ(), &amp;quot;localhost&amp;quot;, Strategy.NOT_ESCAPE)&lt;br /&gt;                    .createQuery();&lt;br /&gt;        &lt;br /&gt;ProcessFinder processFinder = new ProcessFinder(new Sigar());&lt;br /&gt;processFinder.find(ptql.getQuery());&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;The constructor of the Builder takes the first part of the query as parameters and you can optionally add arguments. You can escape the input which regular expressions should do. It will basically replace all commas (,) with period (.), this because the find method doesn't like commas in the searchValue inside a regular expression.&lt;br /&gt;&lt;pre class="prettyprint" style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;/**&lt;br /&gt;     * This method will escape Comma (,) to Period (.)&lt;br /&gt;     * Because the PTQL cannot escape those correctly, so we will use '.' in regular expression.&lt;br /&gt;     * We also have to remove \Q and \E because they are not correctly interpreted as literal characters&lt;br /&gt;     * &lt;br /&gt;     * @param s - The string you want to espace&lt;br /&gt;     * &lt;br /&gt;     * NB: Note that you should only espace the value of the PTQL, not the query it self&lt;br /&gt;     * ie: State.Name.ct=pipe,name=office1 should be converted to State.Name.ct=pipe.name.office1&lt;br /&gt;     * @return - The escaped string&lt;br /&gt;     */&lt;br /&gt;    public static String escapePTQLForRegex(String s) {&lt;br /&gt;        return s.replaceAll(&amp;quot;,&amp;quot;, &amp;quot;.&amp;quot;).replaceAll(&amp;quot;\\\\Q&amp;#124;\\\\E&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;    }&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;The latest version of SimplePTQL can be found &lt;a href="http://code.google.com/p/jodconverter/source/browse/branches/3.0-sigar/jodconverter-core/src/main/java/org/artofsolving/jodconverter/sigar/SimplePTQL.java"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;And the source (subject to change, see the former link for latest version) is:&lt;br /&gt;At the time of writing, the SimplePTQL class does not support Env and Modules&lt;br /&gt;&lt;br /&gt;&lt;pre class="prettyprint" style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;//&lt;br /&gt;// JODConverter - Java OpenDocument Converter&lt;br /&gt;// Copyright 2011 Art of Solving Ltd&lt;br /&gt;// Copyright 2004-2011 Mirko Nasato&lt;br /&gt;//&lt;br /&gt;// JODConverter is free software: you can redistribute it and/or&lt;br /&gt;// modify it under the terms of the GNU Lesser General Public License&lt;br /&gt;// as published by the Free Software Foundation, either version 3 of&lt;br /&gt;// the License, or (at your option) any later version.&lt;br /&gt;//&lt;br /&gt;// JODConverter is distributed in the hope that it will be useful,&lt;br /&gt;// but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;// Lesser General Public License for more details.&lt;br /&gt;//&lt;br /&gt;// You should have received a copy of the GNU Lesser General&lt;br /&gt;// Public License along with JODConverter.  If not, see&lt;br /&gt;// &amp;lt;http://www.gnu.org/licenses/&amp;gt;.&lt;br /&gt;//&lt;br /&gt;package org.artofsolving.jodconverter.sigar;&lt;br /&gt;&lt;br /&gt;import java.util.regex.Matcher;&lt;br /&gt;import java.util.regex.Pattern;&lt;br /&gt;&lt;br /&gt;import org.artofsolving.jodconverter.util.PlatformUtils;&lt;br /&gt;&lt;br /&gt;import com.google.common.base.Preconditions;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * A simplified PTQL so to simplify the query building and make it less error prone and typesafe. &lt;br /&gt; * &lt;br /&gt; * See more information http://support.hyperic.com/display/SIGAR/PTQL&lt;br /&gt; * &lt;br /&gt; * @author Shervin Asgari - &amp;lt;a href=&amp;quot;mailto:shervin@asgari.no&amp;quot;&amp;gt;shervin@asgari.no&amp;lt;/a&amp;gt;&lt;br /&gt; */&lt;br /&gt;public class SimplePTQL {&lt;br /&gt;    private final Operator operator;&lt;br /&gt;    private final Attribute attribute;&lt;br /&gt;    private final String searchValue;&lt;br /&gt;    private final String args;&lt;br /&gt;    private final Strategy strategy;&lt;br /&gt;    &lt;br /&gt;    public enum Strategy {&lt;br /&gt;        ESCAPE, NOT_ESCAPE&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private SimplePTQL(Attribute attribute, Operator operator, String searchValue, String args, Strategy strategy) {&lt;br /&gt;        this.attribute = attribute;&lt;br /&gt;        this.operator = operator;&lt;br /&gt;        this.searchValue = searchValue;&lt;br /&gt;        this.args = args;&lt;br /&gt;        this.strategy = strategy;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    public static class Builder {&lt;br /&gt;        private final Operator operator;&lt;br /&gt;        private final Attribute attribute;&lt;br /&gt;        private final String searchValue;&lt;br /&gt;        &lt;br /&gt;        private Strategy strategy = Strategy.NOT_ESCAPE; &lt;br /&gt;        private StringBuilder args = new StringBuilder(&amp;quot;&amp;quot;); //Default blank&lt;br /&gt;        &lt;br /&gt;        public Builder(Attribute attribute, Operator operator, String searchValue) {&lt;br /&gt;            this.attribute = attribute;&lt;br /&gt;            this.operator = operator;&lt;br /&gt;            this.searchValue = searchValue;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public Builder addArgs(int argument, Operator operator, String searchValue, Strategy strategy) {&lt;br /&gt;            Preconditions.checkNotNull(searchValue);&lt;br /&gt;            &lt;br /&gt;            if(strategy == Strategy.ESCAPE) {&lt;br /&gt;                args.append(&amp;quot;,Args.&amp;quot; + String.valueOf(argument) + &amp;quot;.&amp;quot; + operator.toString() + PlatformUtils.escapePTQLForRegex(searchValue));&lt;br /&gt;            } else {&lt;br /&gt;                Pattern pattern = Pattern.compile(&amp;quot;,&amp;#124;=&amp;quot;);&lt;br /&gt;                Matcher matcher = pattern.matcher(searchValue);&lt;br /&gt;                Preconditions.checkArgument(!matcher.find(), &amp;quot;searchValue cannot contain comma or equals sign. Either set Strategy.ESCAPE or remove it from the search value&amp;quot;);&lt;br /&gt;                args.append(&amp;quot;,Args.&amp;quot; + String.valueOf(argument) + &amp;quot;.&amp;quot; + operator.toString() + searchValue);&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;            return this;&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        public Builder setStrategy(Strategy strategy) {&lt;br /&gt;            this.strategy = strategy;&lt;br /&gt;            return this;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public SimplePTQL createQuery() {&lt;br /&gt;            return new SimplePTQL(attribute, operator, searchValue, args.toString(), strategy);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    /**&lt;br /&gt;     * Returns the entiry PTQL query.&lt;br /&gt;     * ie: &lt;br /&gt;     * &amp;lt;ul&amp;gt;&lt;br /&gt;     * &amp;lt;li&amp;gt;State.Name.eq=java&amp;lt;/li&amp;gt;&lt;br /&gt;     * &amp;lt;li&amp;gt;Pid.Pid.eq=4245&amp;lt;/li&amp;gt;&lt;br /&gt;     * &amp;lt;li&amp;gt;State.Name.re=^(https?d.*&amp;#124;[Aa]pache2?)$&amp;lt;/li&amp;gt;&lt;br /&gt;     * &amp;lt;/ul&amp;gt;&lt;br /&gt;     * @return&lt;br /&gt;     */&lt;br /&gt;    public String getQuery() {&lt;br /&gt;        return attribute.toString() + operator.toString() + (strategy == Strategy.ESCAPE ? PlatformUtils.escapePTQLForRegex(searchValue): searchValue) + args;&lt;br /&gt;    }    &lt;br /&gt;&lt;br /&gt;    private interface Operator {&lt;br /&gt;        String toString();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private interface Attribute {&lt;br /&gt;        String toString();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Equal to value&lt;br /&gt;     */&lt;br /&gt;    public static Operator EQ() {&lt;br /&gt;        return new Operator() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;eq=&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Not Equal to value&lt;br /&gt;     */&lt;br /&gt;    public static Operator NE() {&lt;br /&gt;        return new Operator() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;ne&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Ends with value&lt;br /&gt;     */&lt;br /&gt;    public static Operator EW() {&lt;br /&gt;        return new Operator() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;ew=&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Starts with value&lt;br /&gt;     */&lt;br /&gt;    public static Operator SW() {&lt;br /&gt;        return new Operator() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;sw=&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Contains value (substring)&lt;br /&gt;     */&lt;br /&gt;    public static Operator CT() {&lt;br /&gt;        return new Operator() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;ct=&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Regular expression value matches&lt;br /&gt;     */&lt;br /&gt;    public static Operator RE() {&lt;br /&gt;        return new Operator() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;re=&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * &amp;lt;i&amp;gt;Only for numeric value&amp;lt;i&amp;gt; Greater than value&lt;br /&gt;     */&lt;br /&gt;    public static Operator GT() {&lt;br /&gt;        return new Operator() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;gt=&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * &amp;lt;i&amp;gt;Only for numeric value&amp;lt;i&amp;gt; Greater than or equal value&lt;br /&gt;     */&lt;br /&gt;    public static Operator GE() {&lt;br /&gt;        return new Operator() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;ge=&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * &amp;lt;i&amp;gt;Only for numeric value&amp;lt;i&amp;gt; Less than value&lt;br /&gt;     */&lt;br /&gt;    public static Operator LT() {&lt;br /&gt;        return new Operator() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;lt=&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * &amp;lt;i&amp;gt;Only for numeric value&amp;lt;i&amp;gt; Less than value or equal value&lt;br /&gt;     */&lt;br /&gt;    public static Operator LE() {&lt;br /&gt;        return new Operator() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;le=&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * The Process ID&lt;br /&gt;     */&lt;br /&gt;    public static Attribute PID_PID() {&lt;br /&gt;        return new Attribute() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;Pid.Pid.&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * File containing the process ID&lt;br /&gt;     */&lt;br /&gt;    public static Attribute PID_PIDFILE() {&lt;br /&gt;        return new Attribute() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;Pid.PidFile.&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Windows Service name used to pid from the service manager&lt;br /&gt;     */&lt;br /&gt;    public static Attribute PID_SERVICE() {&lt;br /&gt;        return new Attribute() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;Pid.Service.&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Base name of the process executable&lt;br /&gt;     */&lt;br /&gt;    public static Attribute STATE_NAME() {&lt;br /&gt;        return new Attribute() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;State.Name.&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * User Name of the process owner&lt;br /&gt;     */&lt;br /&gt;    public static Attribute CREDNAME_USER() {&lt;br /&gt;        return new Attribute() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;CredName.User.&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Group Name of the process owner&lt;br /&gt;     */&lt;br /&gt;    public static Attribute CREDNAME_GROUP() {&lt;br /&gt;        return new Attribute() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;CredName.Group.&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * User ID of the process owner&lt;br /&gt;     */&lt;br /&gt;    public static Attribute CRED_UID() {&lt;br /&gt;        return new Attribute() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;Cred.Uid.&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Group ID of the process owner&lt;br /&gt;     */&lt;br /&gt;    public static Attribute CRED_GID() {&lt;br /&gt;        return new Attribute() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;Cred.Gid.&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Effective User ID of the process owner&lt;br /&gt;     */&lt;br /&gt;    public static Attribute CRED_EUID() {&lt;br /&gt;        return new Attribute() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;Cred.Euid.&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Effective Group ID of the process owner&lt;br /&gt;     */&lt;br /&gt;    public static Attribute CRED_EGID() {&lt;br /&gt;        return new Attribute() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;Cred.Egid.&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Full path name of the process executable&lt;br /&gt;     */&lt;br /&gt;    public static Attribute EXE_NAME() {&lt;br /&gt;        return new Attribute() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;Exe.Name.&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Current Working Directory of the process&lt;br /&gt;     */&lt;br /&gt;    public static Attribute EXE_CWD() {&lt;br /&gt;        return new Attribute() {&lt;br /&gt;            @Override&lt;br /&gt;            public String toString() {&lt;br /&gt;                return &amp;quot;Exe.Cwd.&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;The unit test for this class can also be found &lt;a href="http://code.google.com/p/jodconverter/source/browse/branches/3.0-sigar/jodconverter-core/src/test/java/org/artofsolving/jodconverter/sigar/SimplePTQLTest.java"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Or the source (at the time of writing)&lt;br /&gt;&lt;pre class="prettyprint" style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;//&lt;br /&gt;// JODConverter - Java OpenDocument Converter&lt;br /&gt;// Copyright 2011 Art of Solving Ltd&lt;br /&gt;// Copyright 2004-2011 Mirko Nasato&lt;br /&gt;//&lt;br /&gt;// JODConverter is free software: you can redistribute it and/or&lt;br /&gt;// modify it under the terms of the GNU Lesser General Public License&lt;br /&gt;// as published by the Free Software Foundation, either version 3 of&lt;br /&gt;// the License, or (at your option) any later version.&lt;br /&gt;//&lt;br /&gt;// JODConverter is distributed in the hope that it will be useful,&lt;br /&gt;// but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;// Lesser General Public License for more details.&lt;br /&gt;//&lt;br /&gt;// You should have received a copy of the GNU Lesser General&lt;br /&gt;// Public License along with JODConverter.  If not, see&lt;br /&gt;// &amp;lt;http://www.gnu.org/licenses/&amp;gt;.&lt;br /&gt;//&lt;br /&gt;package org.artofsolving.jodconverter.sigar;&lt;br /&gt;&lt;br /&gt;import java.util.List;&lt;br /&gt;&lt;br /&gt;import org.artofsolving.jodconverter.process.ProcessManager;&lt;br /&gt;import org.artofsolving.jodconverter.process.SigarProcessManager;&lt;br /&gt;import org.artofsolving.jodconverter.sigar.SimplePTQL.Strategy;&lt;br /&gt;import org.artofsolving.jodconverter.util.PlatformUtils;&lt;br /&gt;import org.testng.Assert;&lt;br /&gt;import org.testng.SkipException;&lt;br /&gt;import org.testng.annotations.Test;&lt;br /&gt;&lt;br /&gt;@Test&lt;br /&gt;public class SimplePTQLTest {&lt;br /&gt;    &lt;br /&gt;    public void simpleQuery() throws Exception {&lt;br /&gt;        ProcessManager spm = new SigarProcessManager();&lt;br /&gt;        SimplePTQL ptql = new SimplePTQL.Builder(SimplePTQL.STATE_NAME(), SimplePTQL.EQ(), &amp;quot;java&amp;quot;).createQuery();&lt;br /&gt;        Assert.assertEquals(ptql.getQuery(), &amp;quot;State.Name.eq=java&amp;quot;);&lt;br /&gt;        &lt;br /&gt;        List&amp;lt;Long&amp;gt; find = spm.find(ptql);&lt;br /&gt;        Assert.assertTrue(find.size() &amp;gt; 0);&lt;br /&gt;        &lt;br /&gt;        if(find.size() &amp;gt; 1) {&lt;br /&gt;            try {&lt;br /&gt;                spm.findSingle(ptql);&lt;br /&gt;                Assert.fail(&amp;quot;Should not reach here, should get exception&amp;quot;);&lt;br /&gt;            } catch(NonUniqueResultException nre) {&lt;br /&gt;                //More than one results where found&lt;br /&gt;            }    &lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        ptql = new SimplePTQL.Builder(SimplePTQL.PID_PID(), SimplePTQL.EQ(), String.valueOf(find.get(0))).createQuery();&lt;br /&gt;        Long findSingle = spm.findSingle(ptql);&lt;br /&gt;        Assert.assertEquals(findSingle, find.get(0));&lt;br /&gt;        &lt;br /&gt;        ptql = new SimplePTQL.Builder(SimplePTQL.STATE_NAME(), SimplePTQL.EQ(), &amp;quot;Hopefully There is no Process called this&amp;quot;).createQuery();&lt;br /&gt;        List&amp;lt;Long&amp;gt; find2 = spm.find(ptql);&lt;br /&gt;        Assert.assertTrue(find2.size() == 0);&lt;br /&gt;        &lt;br /&gt;        ptql = new SimplePTQL.Builder(SimplePTQL.PID_PID(), SimplePTQL.GT(), &amp;quot;1&amp;quot;).createQuery();&lt;br /&gt;        List&amp;lt;Long&amp;gt; find3 = spm.find(ptql);&lt;br /&gt;        Assert.assertTrue(find3.size() &amp;gt; 1);&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    public void args() throws Exception {&lt;br /&gt;        SimplePTQL ptql = new SimplePTQL.Builder(SimplePTQL.STATE_NAME(), SimplePTQL.RE(), &amp;quot;office.*&amp;quot;)&lt;br /&gt;        .addArgs(1, SimplePTQL.RE(), &amp;quot;\\Qpipe,name,office1\\E&amp;quot;, Strategy.ESCAPE)&lt;br /&gt;        .createQuery();&lt;br /&gt;        Assert.assertEquals(ptql.getQuery(), &amp;quot;State.Name.re=office.*,Args.1.re=pipe.name.office1&amp;quot;);&lt;br /&gt;        &lt;br /&gt;        ptql = new SimplePTQL.Builder(SimplePTQL.STATE_NAME(), SimplePTQL.EQ(), &amp;quot;office.*&amp;quot;)&lt;br /&gt;        .addArgs(1, SimplePTQL.RE(), &amp;quot;\\Qpipe,name,office1\\E&amp;quot;, Strategy.ESCAPE)&lt;br /&gt;        .addArgs(2, SimplePTQL.EQ(), &amp;quot;\\Qpipe,name=office2\\E&amp;quot;, Strategy.ESCAPE)&lt;br /&gt;        .setStrategy(Strategy.ESCAPE)&lt;br /&gt;        .createQuery();&lt;br /&gt;        &lt;br /&gt;        Assert.assertEquals(ptql.getQuery(), &amp;quot;State.Name.eq=office.*,Args.1.re=pipe.name.office1,Args.2.eq=pipe.name=office2&amp;quot;);&lt;br /&gt;        &lt;br /&gt;        try {&lt;br /&gt;            ptql = new SimplePTQL.Builder(SimplePTQL.STATE_NAME(), SimplePTQL.EQ(), &amp;quot;office.*&amp;quot;)&lt;br /&gt;            .addArgs(1, SimplePTQL.RE(), &amp;quot;\\Qpipe,name,office1\\E&amp;quot;, Strategy.ESCAPE)&lt;br /&gt;            .addArgs(2, SimplePTQL.EQ(), &amp;quot;\\Qpipe,name,office2\\E&amp;quot;, Strategy.NOT_ESCAPE)&lt;br /&gt;            .createQuery();&lt;br /&gt;        &lt;br /&gt;            Assert.fail(&amp;quot;Method should have thrown IllegalArgumentException&amp;quot;);&lt;br /&gt;        } catch(IllegalArgumentException ex) {}&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void realArguments() throws Exception {&lt;br /&gt;        if (PlatformUtils.isWindows()) {&lt;br /&gt;            throw new SkipException(&amp;quot;Sleep only works on unix&amp;quot;);&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        Process process = new ProcessBuilder(&amp;quot;sleep&amp;quot;, &amp;quot;60s&amp;quot;).start();&lt;br /&gt;        Assert.assertNotNull(process);&lt;br /&gt;        &lt;br /&gt;        SimplePTQL ptql = new SimplePTQL.Builder(SimplePTQL.STATE_NAME(), SimplePTQL.EQ(), &amp;quot;sleep&amp;quot;)&lt;br /&gt;                            .addArgs(1, SimplePTQL.EQ(), &amp;quot;60s&amp;quot;, Strategy.NOT_ESCAPE).createQuery();&lt;br /&gt;        &lt;br /&gt;        &lt;br /&gt;        ProcessManager spm = new SigarProcessManager();&lt;br /&gt;        Long findSingle = spm.findSingle(ptql);&lt;br /&gt;        Assert.assertTrue(findSingle &amp;gt; 0L);&lt;br /&gt;        &lt;br /&gt;        spm.kill(findSingle, 9);&lt;br /&gt;        Assert.assertEquals(spm.findSingle(ptql).longValue(), 0L);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-5114501487818601682?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/5114501487818601682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=5114501487818601682' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5114501487818601682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5114501487818601682'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2011/03/api-helper-wrapper-for-processfinder-in.html' title='API helper / wrapper for ProcessFinder in Hyperic Sigar PTQL'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-2194402434792383656</id><published>2011-03-21T11:41:00.004+01:00</published><updated>2011-03-21T11:45:12.434+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='prettify'/><title type='text'>Testing Prettify</title><content type='html'>This is a test of &lt;a href="http://code.google.com/p/google-code-prettify/"&gt;Prettify&lt;/a&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code class="prettyprint"&gt;public class NonUniqueResultException extends Exception {&lt;br /&gt;&lt;br /&gt; private static final long serialVersionUID = -7862607833306958651L;&lt;br /&gt; &lt;br /&gt; public NonUniqueResultException(String string) {&lt;br /&gt;        super(string);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-2194402434792383656?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/2194402434792383656/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=2194402434792383656' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/2194402434792383656'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/2194402434792383656'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2011/03/testing-prettyprint.html' title='Testing Prettify'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-3305660790177511687</id><published>2011-03-14T20:45:00.000+01:00</published><updated>2011-03-14T20:45:42.866+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jodconverter 3'/><category scheme='http://www.blogger.com/atom/ns#' term='sigar'/><category scheme='http://www.blogger.com/atom/ns#' term='OSS'/><category scheme='http://www.blogger.com/atom/ns#' term='jodconverter'/><title type='text'>Commit access to JodConverter</title><content type='html'>I have gotten commit access to &lt;a href="http://code.google.com/p/jodconverter"&gt;jodconverter 3&lt;/a&gt; so that I can work on some issues.&lt;br /&gt;&lt;br /&gt;The first issue I am going to work on is refactoring the code to use &lt;a href="http://support.hyperic.com/display/SIGAR/Home"&gt;Sigar&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Sigar &lt;i&gt;"provides a portable interface for gathering system information"&lt;/i&gt; with native libraries for many OSes and it has an Apache License Version 2.&lt;br /&gt;&lt;br /&gt;This is my first commit access to an open source project. Looking forward to contribute.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-3305660790177511687?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/3305660790177511687/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=3305660790177511687' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3305660790177511687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3305660790177511687'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2011/03/commit-access-to-jodconverter.html' title='Commit access to JodConverter'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-3569810418484803991</id><published>2011-03-07T12:08:00.001+01:00</published><updated>2011-03-21T11:47:56.609+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Cache'/><category scheme='http://www.blogger.com/atom/ns#' term='Guava'/><category scheme='http://www.blogger.com/atom/ns#' term='Memory'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam'/><title type='text'>Creating an efficient memory based cache</title><content type='html'>If you find your self in the situation where you are creating global maps as cache, then you have to stop and rethink. &lt;br /&gt;&lt;a href="http://www.ibm.com/developerworks/java/library/j-jtp11225/"&gt;Global maps are prone to memory leaks&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You should instead consider using soft reference and &lt;a href="http://download.oracle.com/javase/6/docs/api/java/util/WeakHashMap.html"&gt;WeakHashMap&lt;/a&gt; or what I prefer, the &lt;a href="http://guava-libraries.googlecode.com/svn/tags/release08/javadoc/com/google/common/collect/MapMaker.html"&gt;MapMaker&lt;/a&gt; of &lt;a href="http://code.google.com/p/guava-libraries/"&gt;Google Guava&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In this blog post, I will describe an efficient way of creating a map based cache. This can can either be stored in the session, application, or your existing cache.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Weak References&lt;/span&gt;&lt;br /&gt;&lt;i&gt;- What are weak references? &lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Weak reference basically means that the garbage collector can come and remove it when it is no longer in use. You have no guarantee that whatever you put in the map, will actually be around when you try to get it.&lt;br /&gt;The reason why that is so useful is if you don't want to (or cannot afford to) retain an object indefinitely in memory. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Consider the following use case: You need to associate information with classes. Now, since you are running in an environment, where classes might get reloaded (say, a Tomcat, or OSGi environment), you want the garbage collector to be able to reclaim old versions of a class as soon as it deems safe to do so.&lt;br /&gt;&lt;br /&gt;An initial attempt to implement this, might look like something like this:&lt;br /&gt;&lt;pre style="background: url(&amp;quot;http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif&amp;quot;) repeat scroll 0% 0% rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"&gt;&lt;code style="color: black; word-wrap: normal;" class="prettyprint"&gt; class ClassAssociation {  &lt;br /&gt;   private final IdentityHashMap&amp;lt;Class&amp;lt;?&amp;gt;,MyMetaData&amp;gt; cache = new ...;  &lt;br /&gt; }  &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;The problem here is; this would keep all classes in the cache member forever (or at least, unless they are manually removed), forcing the garbage collector to retain them indefinitely, including everything referenced from the class (static member values, class loader information, etc).&lt;br /&gt;&lt;br /&gt;By using weak references, the garbage collector can reclaim old version of the class as soon as no other references to it (usually instances) exist. &lt;br /&gt;On the other hand, as long as such references exist, the value is guaranteed to also be reachable from the weak reference object, and thus, is a valid key in the cache table.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;MapMaker FTW!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The thing about MapMaker is that there are many options for the kind of map you build, which enables those maps to serve many different purposes.&lt;br /&gt;With the MapMaker you can choose between weak keys or weak values.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Soft values are useful for caching, as you can cache values in the map without worrying about running out of memory since the system is free to evict entries from the cache if it needs memory.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;You can choose to have entries expire after a certain amount of time. This is also useful for caching, since you may want certain data cached for a specific period of time before doing an expensive operation to update it.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;One of my favorite things is making a computing map. A computing map uses a Function&lt;k, v=""&gt; to automatically retrieve the value associated with a given key if it isn't already in the map. This combines well with soft values and/or expiration times. After an entry is evicted by the map (due to memory demand or expiration), the next time the value associated with that key is requested it will automatically be retrieved and cached in the map once more.&lt;/k,&gt;&lt;/li&gt;&lt;/ul&gt;&lt;k, v=""&gt; Consider this example:&lt;/k,&gt;&lt;br /&gt;&lt;k, v=""&gt;You have an expensive computation or query which you want to cache for performance gains. You store the value in a map with an id as key which you will use to retrieve your values.&lt;/k,&gt;&lt;br /&gt;&lt;k, v=""&gt;Normally you would store these values in a regular HashMap and store the hashmap in the cache, session or application. Now we have seen that this is generally not a good idea, since it will consume a lot of memory.&lt;/k,&gt;&lt;br /&gt;&lt;k, v=""&gt;It is in these situations the MapMaker shines!&lt;/k,&gt;&lt;br /&gt;&lt;k, v=""&gt;Lets say you have a list of Tasks for each User.&amp;nbsp;&lt;/k,&gt;&lt;br /&gt;&lt;k, v=""&gt;You would normally query the tasks like this:&lt;/k,&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code class="prettyprint"&gt;Map&amp;lt;User,List&amp;lt;Task&amp;gt;&amp;gt; cache = new HashMap&amp;lt;User,List&amp;lt;Task&amp;gt;&amp;gt;(); //the global cache defined somewhere&lt;br /&gt;&amp;nbsp;if(cache.get(user) == null) {&lt;br /&gt;&amp;nbsp;&amp;nbsp; List&amp;lt;Task&amp;gt; userTasks = getTasksForUser(user); // perform an intensive computation/query which we want to cache&lt;br /&gt;&amp;nbsp;&amp;nbsp; cache.put(user, userTasks);&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;return cache.get(user);&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;If you want to rewrite this to use a Computing MapMaker you would write like this:&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code class="prettyprint"&gt;ConcurrentMap&amp;lt;String, List&amp;lt;Task&amp;gt;&amp;gt; cache = ...// Get the cache&lt;br /&gt;    if(cache != null) {&lt;br /&gt;      //If the tasks have been garbage collected, the function is applied, and you get the tasks &lt;br /&gt;      return cache.get(user);&lt;br /&gt;    } else {&lt;br /&gt;      ConcurrentMap&amp;lt;String, List&amp;lt;Task&amp;gt;&amp;gt; cache = new MapMaker().softValues().expireAfterWrite(2L, TimeUnit.HOURS)&lt;br /&gt;        .makeComputingMap(new Function&amp;lt;User, List&amp;lt;Task&amp;gt;&amp;gt;() {&lt;br /&gt;        @Override&lt;br /&gt;        public List&amp;lt;Task&amp;gt; apply(User user) {&lt;br /&gt;          return getTasksForUser(user); // perform an intensive computation/query which we want to cache &lt;br /&gt;        }&lt;br /&gt;      });&lt;br /&gt;      &lt;br /&gt;      cache.put(user, getTasksForUser(user));&lt;br /&gt;      return cache.get(user);&lt;br /&gt;    }&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Here we have created a ConcurrentMap with weak values, which will be garbage collected in two hours. If the tasks have been garbage collected and the user is retrieving the tasks, the function is applied, and you get the tasks automatically, and put it back in the cache for another two hours.&lt;br /&gt;&lt;br /&gt;Simple and great!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-3569810418484803991?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/3569810418484803991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=3569810418484803991' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3569810418484803991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3569810418484803991'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2011/03/creating-efficient-memory-based-cache.html' title='Creating an efficient memory based cache'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-3729113739654402245</id><published>2011-01-11T14:15:00.003+01:00</published><updated>2011-01-11T14:22:29.693+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='JPA'/><title type='text'>Remember that ordinal parameters are 1-based in hibernate</title><content type='html'>I got this strange exception &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When running this query in hibernate/jpa&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;jbpmContext.getSession().createQuery("select pi from org.jbpm.graph.exe.ProcessInstance pi where pi.id = ?1 or pi.id = ?2 or pi.id =?3")&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .setParameter(1, 9L).setParameter(2, 10L).setParameter(3, 11L).list();&lt;/code&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/span&gt; Which is very strange. The reason why hibernate cannot figure this out is because the ejb 3 form &lt;br /&gt;&lt;pre&gt;&lt;code&gt;(&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-family: inherit;"&gt;"&lt;/span&gt;&lt;/span&gt;?1&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-family: inherit;"&gt;"&lt;/span&gt;&lt;/span&gt;)&lt;/code&gt;&lt;/pre&gt;is interpreted as a named parameter! So here we actually have to write it as &lt;pre&gt;&lt;code&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-family: inherit;"&gt;.setParameter(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-family: inherit;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-family: inherit;"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-family: inherit;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-family: inherit;"&gt;, 9L)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-family: inherit;"&gt; instead, or change the query and only type ? like so.&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;jbpmContext.getSession().createQuery("select&lt;br /&gt; pi from org.jbpm.graph.exe.ProcessInstance pi where pi.id = ? or pi.id&lt;br /&gt; = ? or pi.id =?").setParameter(0, 9L).setParameter(1, 10L).setParameter(2, 11L).list();&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The message about "1-based" is misleading here. It refers to the fact the the metadata for parameters is actually indexed by their sql positions (which is 1-based).&lt;br /&gt;&lt;br /&gt;Good to know!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-3729113739654402245?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/3729113739654402245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=3729113739654402245' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3729113739654402245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3729113739654402245'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2011/01/remember-that-ordinal-parameters-are-1.html' title='Remember that ordinal parameters are 1-based in hibernate'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-4957209702356247664</id><published>2010-12-14T14:10:00.001+01:00</published><updated>2010-12-14T14:11:25.585+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='jrebel'/><title type='text'>How to reduce your re-deployment time</title><content type='html'>Are you tired of always waiting for re-deployment whenever you change something during development?&lt;br /&gt;&lt;br /&gt;I sure am! Recently it has even become worse, because my Enterprise JBoss Application Server takes around 4 minutes to boot, and it is not uncommon that I redeploy the application up to 20 - 30 times during one day.&lt;br /&gt;That's already&amp;nbsp; 80 - 120 minutes per day accumulated that I just have to wait for the application to start, and what's worse, many times I am in the flow, and really concentrated on the task at hand, then I have to redeploy, and I will unset my mind and start browsing some emails, forums, etc and totally loose my flow. It's hard to get back in that mindset again.&lt;br /&gt;&lt;br /&gt;Wouldn't it be awesome that whenever you saved a change in your IDE, that it would instantly be picked up by the application server, and reloaded? Why do we need to reload the entire application each time? It doesn't make sense.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;a href="http://www.zeroturnaround.com/jrebel/"&gt;JRebel&lt;/a&gt; to the rescue!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;I have known about &lt;a href="http://www.zeroturnaround.com/jrebel/"&gt;JRebel&lt;/a&gt; for some time, and I knew about its awesomeness. However, when I tried to install it a few years back, it was really tedious and error prone, and I couldn't really get it working correctly. But recently JRebel has been shipped with a new configuration wizard which basically does everything for you. It took next to no time to install it and get it working, and already it is saving me a lot of time.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;JRebel is just awesome, and every Java developer should (read must) use it!&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-4957209702356247664?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/4957209702356247664/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=4957209702356247664' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/4957209702356247664'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/4957209702356247664'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2010/12/how-to-reduce-your-re-deployment.html' title='How to reduce your re-deployment time'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-7453750696637231870</id><published>2010-12-03T14:06:00.000+01:00</published><updated>2010-12-03T14:06:41.077+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='chess'/><title type='text'>Moments when you should sense danger in Chess</title><content type='html'>1. There has been a change in the pawn structure. Your opponent has 8 and you don't have any. &lt;br /&gt;&lt;br /&gt;2. Your opponent begins to throw pawns at your eyes. &lt;br /&gt;&lt;br /&gt;3. You have a position won but your opponent has a gun. &lt;br /&gt;&lt;br /&gt;4. The Director tells you not to bother turning in your scoresheet after the game. &lt;br /&gt;&lt;br /&gt;5. Before the game begins you notice your opponents 1st initials are 'GM'. &lt;br /&gt;&lt;br /&gt;6. After completing your development you sense your opponent playing the endgame. &lt;br /&gt;&lt;br /&gt;7. Just as you make your opening move your opponent announces mate in 11. &lt;br /&gt;&lt;br /&gt;8. You don't control any squares at all. &lt;br /&gt;&lt;br /&gt;9. Your draw offer sends all the people watching your game into uncontrollable laughter. &lt;br /&gt;&lt;br /&gt;10. Your opponent has 3 bishops. &lt;br /&gt;&lt;br /&gt;11. Your opponent slaps his head and cries "Noooo what a mistake!!", then few moves later, you are down a queen. &lt;br /&gt;&lt;br /&gt;12. You announce forced mate in 7 by sacking two pieces, then you resign after the 8'th move. &lt;br /&gt;&lt;br /&gt;13. You crush your opponent on the chess board, but the opponent crushes you with the chess board.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-7453750696637231870?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/7453750696637231870/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=7453750696637231870' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7453750696637231870'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7453750696637231870'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2010/12/moments-when-you-should-sense-danger-in.html' title='Moments when you should sense danger in Chess'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-6974178779907198914</id><published>2010-11-04T18:50:00.003+01:00</published><updated>2011-09-26T09:57:39.217+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jquery'/><category scheme='http://www.blogger.com/atom/ns#' term='richfaces'/><title type='text'>How to add RichFaces to your existing  jQuery enabled site</title><content type='html'>As of Richfaces 3.0, jQuery has been inbuilt. If you don't know what jQuery is, you can watch a video about it &lt;a href="http://jquery.org/about"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;We have been using jQuery separately in our project, but wanted to add some Richfaces components. Now since Richfaces is using jQuery, there is a conflict that appears. &lt;br /&gt;&lt;br /&gt;They both use $ as their main function name. That might brake the behaviour, and you might see error messages in your web browser, such as:&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;this.focusKeeper.observe is not a function&lt;br /&gt;&lt;br /&gt;[Break on this error] Richfaces.ListBase.ASC="acs";Richfaces...ner('load',this.imagesOnLoad,true);}}&lt;br /&gt;ListBase.js (line 4)&lt;br /&gt;&lt;br /&gt;and&lt;br /&gt;element.dispatchEvent is not a function&lt;br /&gt;&lt;br /&gt;[Break on this error] event.eventName=eventName;event.memo=m...nt.fireEvent(event.eventType,event);}&lt;br /&gt;3_3_1....eScript (line 265)&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;To resolve such cases jQuery introduces the &lt;code&gt;.noConflict()&lt;/code&gt; function.&lt;br /&gt;&lt;br /&gt;To use the jQuery that is bundled in RichFaces, you have to load the correct script.&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&amp;lt;a:loadScript src="resource://jquery.js"/&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Then you can assign jQuery to $j for convenience. Add the following in your javascript code:&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;$j = jQuery.noConflict();&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;Then you have to replace all your former &lt;i&gt;&lt;b&gt;&lt;code&gt;$()&lt;/code&gt;&lt;/b&gt;&lt;/i&gt; with &lt;i&gt;&lt;b&gt;&lt;code&gt;$j()&lt;/code&gt;&lt;/b&gt;&lt;/i&gt; or the equivalents &lt;i&gt;&lt;b&gt;&lt;code&gt;$. $[] &lt;/code&gt;&lt;/b&gt;&lt;/i&gt;&lt;b&gt;&lt;code&gt;&lt;/code&gt;&lt;/b&gt;&lt;code&gt;and&lt;/code&gt;&lt;i&gt;&lt;b&gt;&lt;code&gt; function($)&lt;/code&gt;&lt;/b&gt;&lt;/i&gt; with &lt;code&gt;&lt;i&gt;&lt;b&gt;$j.&lt;/b&gt;&lt;/i&gt; &lt;i&gt;&lt;b&gt;$j[]&lt;/b&gt;&lt;/i&gt; and &lt;i&gt;&lt;b&gt;function($j)&lt;/b&gt;&lt;/i&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Your new code now may look something like this:&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;function showMessages() {&lt;br /&gt;&amp;nbsp; $j("div#messagetextPanel").fadeIn("fast");&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;And your Richfaces component will display and work without any problems! Thats it!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-6974178779907198914?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/6974178779907198914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=6974178779907198914' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/6974178779907198914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/6974178779907198914'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2010/11/how-to-use-jquery-with-richfaces.html' title='How to add RichFaces to your existing  jQuery enabled site'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-6887741208621355573</id><published>2010-10-07T10:53:00.001+02:00</published><updated>2010-10-08T10:17:41.790+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Seam'/><title type='text'>Why you should NOT use the Seam Application Framework</title><content type='html'>&lt;b&gt;NOT TO BE CONFUSED WITH &lt;a href="http://seamframework.org/"&gt;SEAM&lt;/a&gt;, WHICH IS AWESOME!&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;I am a very experienced Seam user. I have used Seam daily now for almost 3 years. &lt;br /&gt;&lt;br /&gt;In this blog post, I will try to convince you to avoid the Seam Application Framework, and truly understanding when it should be used, and when it shouldn't.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;What is Seam Application Framework?&lt;/span&gt;&lt;br /&gt;&amp;nbsp;Seam in Action says: "Seam is an application framework for Java EE. It provides a container that manages components and leverage's those components to tie the layers of an enterprise Java application together. Nestled within the Seam code base lies a handful of classes that comprise the Seam Application Framework. This "framework within a framework" is a specialized collection of component templates that effortlessly blanket the programming requirements of garden-variety web applications. Such tasks include performing create,read,update and delete (CRUD) operations on entity instances;querying for data; and developing JSF page controllers. &lt;b&gt;You may be hesitant to give this spattering of classes much notice, but I assure you that they'll carry you a long way."&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;According to Dan Allen, he is encouraging you to check this "framework within a framework" out. However, though he is right, that there are benefits with this framework, I will prove that there are far more disadvantages than advantages and that he should have rewritten the last line to include that the framework is only really useful for small CRUD applications, and not something to leverage and build upon.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Way too many people are using this framework&lt;/span&gt;&lt;br /&gt;If you have a look at the &lt;a href="http://seamframework.org/Community/SeamUsers"&gt;Seamframework.org forums&lt;/a&gt;, you will see tons of questions from people having problems and issues with the Seam Application Framework. Either a lot of people are developing small CRUD based applications, or there is a growing misconception about Seam and Seam Application Framework.&lt;br /&gt;&lt;br /&gt;There are many people that are confused about this notion. They think that Seam == Seam Application Framework, and that they have to use it. And who can blame them? The &lt;a href="http://docs.jboss.org/seam/2.2.1.CR1/reference/en-US/html/gettingstarted.html"&gt;seam-gen&lt;/a&gt; utility is a fantastic way of getting you quickly started. However, I have always encouraged people to only use the &lt;i&gt;create-project&lt;/i&gt; and &lt;i&gt;generate-entities&lt;/i&gt; part of the utility, and not the &lt;i&gt;generate-ui&lt;/i&gt; part of it, this because most people I have talked with, are not developing small CRUD based applications, but rather medium sized enterprise apps, but since you get the Seam Application Framework for free, it is quite easy to extend and use it.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;PROS&lt;/span&gt;&lt;br /&gt;I did mention that there are a few pro's about using this framework, but it depends on people truly understanding the inner workings of the framework.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Quick to get started&lt;/li&gt;&lt;li&gt;Excellent for small models,presentation and proof of concept&lt;/li&gt;&lt;li&gt;Great in-built pagination of lists&lt;/li&gt;&lt;li&gt;Can @Override the methods and inherit classes to extend/tweak upon the framework&lt;/li&gt;&lt;/ul&gt;If you want to visualize for your customer, boss or client, an application as a proof of concept, then it is very easy to do this using the framework. In this case you don't care so much about performance and inherited abstraction layers, but rather how quickly you can get something visual and up and running.&lt;br /&gt;&lt;br /&gt;I also want to note, before I get spammed with comments about how wrong I am, that you can if you know what you are doing, speed things up. Details can be found &lt;a href="http://jsfcentral.com/articles/speed_up_your_jsf_app_1.html"&gt;here&lt;/a&gt;. However, this again requires some knowledge about Seam.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;CONS&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Its a bit slower&lt;/li&gt;&lt;li&gt;More abstraction which might not suit your requirements&lt;/li&gt;&lt;li&gt;More difficult to use than the plain components. You need to "learn a new framework as well as Seam"&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Consider this very very simple example. We have a SystemLog, and we want to display the log.&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;br /&gt;@Entity&lt;br /&gt;public class SystemLog {&lt;br /&gt;&lt;br /&gt;    @Getter @Setter&lt;br /&gt;    @Id&lt;br /&gt;    @GeneratedValue&lt;br /&gt;    private Long id;&lt;br /&gt;&lt;br /&gt;    @Getter @Setter&lt;br /&gt;    @NotEmpty&lt;br /&gt;    private String description;&lt;br /&gt;&lt;br /&gt;    @Getter @Setter&lt;br /&gt;    @Column&lt;br /&gt;    private String category;&lt;br /&gt;&lt;br /&gt;    @Getter @Setter&lt;br /&gt;    @Temporal(TemporalType.TIMESTAMP)&lt;br /&gt;    private Date date;&lt;br /&gt;&lt;br /&gt;    @Getter @Setter&lt;br /&gt;    @Column&lt;br /&gt;    private String username;&lt;br /&gt;&lt;br /&gt;    @Getter @Setter&lt;br /&gt;    @Column&lt;br /&gt;    private String organization;&lt;br /&gt;&lt;br /&gt;    @Getter @Setter&lt;br /&gt;    @Column(length = 1024)&lt;br /&gt;    @Lob&lt;br /&gt;    private String details;&lt;br /&gt;&lt;br /&gt;    @Getter @Setter&lt;br /&gt;    @Column&lt;br /&gt;    private String severity;&lt;br /&gt;&lt;br /&gt;    @Getter @Setter&lt;br /&gt;    @Column&lt;br /&gt;    private String ipAddress;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;We have an action class that used the EntityQuery of the Seam Application Framework.&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;br /&gt;@Name("systemLogQuery")&lt;br /&gt;@MeasureCalls&lt;br /&gt;public class SystemLogQuery extends EntityQuery&amp;lt;SystemLog&amp;gt; {&lt;br /&gt;  @Logger Log log;&lt;br /&gt;  &lt;br /&gt;  @Override&lt;br /&gt;  public String getEjbql() {&lt;br /&gt;    return "select sys from SystemLog sys";&lt;br /&gt;  }&lt;br /&gt;  &lt;br /&gt;  @Override&lt;br /&gt;  public List&amp;lt;SystemLog&amp;gt; getResultList() {&lt;br /&gt;    log.warn("Inside systemlog query getResultList");&lt;br /&gt;    return super.getResultList();&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;And this normal (non tweaked) seam component.&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;br /&gt;@Name("systemLogNormal")&lt;br /&gt;@MeasureCalls&lt;br /&gt;public class SystemLogNormal {&lt;br /&gt;&lt;br /&gt;  @Logger Log log;&lt;br /&gt;  &lt;br /&gt;  @In EntityManager entityManager;&lt;br /&gt;  &lt;br /&gt;  List&amp;lt;SystemLog&amp;gt; result;&lt;br /&gt;  &lt;br /&gt;  public List&amp;lt;SystemLog&amp;gt; getResultList() {&lt;br /&gt;    log.warn("Inside systemLog normal resultList");&lt;br /&gt;    if(result == null)&lt;br /&gt;      this.result = entityManager.createQuery("FROM SystemLog").getResultList();&lt;br /&gt;     &lt;br /&gt;    return result;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;And a simple data table iterating over the elements&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&amp;lt;h:dataTable value="#{systemLogNormal.resultList}" var="sys"&amp;gt;&lt;br /&gt;    &amp;lt;h:column&amp;gt;&lt;br /&gt;      &amp;lt;f:facet name="header"&amp;gt;&lt;br /&gt;        description&lt;br /&gt;      &amp;lt;/f:facet&amp;gt;&lt;br /&gt;      #{sys.description}&lt;br /&gt;    &amp;lt;/h:column&amp;gt;&lt;br /&gt;&amp;lt;/h:dataTable&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Now at first glance, I think the normal seam component is much cleaner and easier to read. Remember, this is a very simple example. In a normal real life example you would have extended the component to be much more complicated, and if you want to do this using the existing framework, you will need to find out what the framework already is doing, and correctly override those methods. Otherwise, you risk of doing the same thing twice.&lt;br /&gt;&lt;br /&gt;If you ask your self what the &lt;i&gt;@MeasureCalls&lt;/i&gt; annotation is doing, then have a look &lt;a href="http://shervinasgari.blogspot.com/2010/02/advanced-seam-series-part-1-of-3-seam.html"&gt;here&lt;/a&gt;, and scroll down to the second example. But a short description is that it measures the time of execution for a method.&lt;br /&gt;&lt;br /&gt;When you run this example using the SystemLogNormal and the Query component, they are pretty much equal. However, you will see that the Query component is also calling the validate() method, which takes a few milliseconds to execute.&lt;br /&gt;It is correct that a few milliseconds is hardly anything noteworthy, however this is a very very simple example, with very little data, and in a more realistic scenario, the number could possibly be different. Either way, the overall time difference is that the EntityQuery object is a few milliseconds slower.&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;13:58:24,224 WARN  [SystemLogQuery] Inside systemlog query getResultList&lt;br /&gt;13:58:24,228 INFO  [STDOUT] Hibernate: &lt;br /&gt;    select&lt;br /&gt;        systemlog0_.id as id0_,&lt;br /&gt;        systemlog0_.category as category0_,&lt;br /&gt;        systemlog0_.date as date0_,&lt;br /&gt;        systemlog0_.description as descript4_0_,&lt;br /&gt;        systemlog0_.details as details0_,&lt;br /&gt;        systemlog0_.ipAddress as ipAddress0_,&lt;br /&gt;        systemlog0_.organization as organiza7_0_,&lt;br /&gt;        systemlog0_.severity as severity0_,&lt;br /&gt;        systemlog0_.username as username0_ &lt;br /&gt;    from&lt;br /&gt;        SystemLog systemlog0_&lt;br /&gt;13:58:24,239 WARN  [SystemLogQuery] Inside systemlog query getResultList&lt;br /&gt;13:58:24,257 WARN  [SystemLogQuery] Inside systemlog query getResultList&lt;br /&gt;13:58:24,334 INFO  [TimingFilter] 2.201607 ms   1   EntityQuery.validate()&lt;br /&gt;13:58:24,334 INFO  [TimingFilter] 15.967185 ms   3   SystemLogQuery.getResultList()&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;13:58:31,647 WARN  [SystemLogNormal] Inside systemLog normal resultList&lt;br /&gt;13:58:31,648 INFO  [STDOUT] Hibernate: &lt;br /&gt;    select&lt;br /&gt;        systemlog0_.id as id0_,&lt;br /&gt;        systemlog0_.category as category0_,&lt;br /&gt;        systemlog0_.date as date0_,&lt;br /&gt;        systemlog0_.description as descript4_0_,&lt;br /&gt;        systemlog0_.details as details0_,&lt;br /&gt;        systemlog0_.ipAddress as ipAddress0_,&lt;br /&gt;        systemlog0_.organization as organiza7_0_,&lt;br /&gt;        systemlog0_.severity as severity0_,&lt;br /&gt;        systemlog0_.username as username0_ &lt;br /&gt;    from&lt;br /&gt;        SystemLog systemlog0_&lt;br /&gt;13:58:31,662 WARN  [SystemLogNormal] Inside systemLog normal resultList&lt;br /&gt;13:58:31,678 WARN  [SystemLogNormal] Inside systemLog normal resultList&lt;br /&gt;13:58:31,712 INFO  [TimingFilter] 15.740409 ms   3   SystemLogNormal.getResultList()&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;As you can see, we get three outputs of "Inside systemlog". Really there should only be one. So adding a @Factory annotation on top of it will do the trick for both versions.&lt;br /&gt;&lt;br /&gt;Then there are the &lt;b&gt;Home &lt;/b&gt;and &lt;b&gt;Query&lt;/b&gt;&amp;nbsp;objects, with methods like &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,&amp;quot;Courier&amp;quot;,monospace;"&gt;isIdDefined(), &lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,&amp;quot;Courier&amp;quot;,monospace;"&gt;clearDirty(), isManaged(), getEjbql(), RESTRICTIONS&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,&amp;quot;Courier&amp;quot;,monospace;"&gt; &lt;/span&gt;and more confusing methods which you need to read the documentation to understand.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In my opinion, for first time users who are learning Seam, it is more than enough to understand and learn the framework, instead of in addition learning "a framework inside a framework". The seam-gen utility is sort of a devil in disguise. Its great for a shortcut to get started, but its evil in disguise for new comers.&lt;br /&gt;&lt;br /&gt;Newbies think Seam Application Framework is Seam, and all components they create must extends the Home, List or Query objects. Its confusing, and in my opinion they should avoid using it unless they know all the ins and out of both Seam and the application framework.&lt;br /&gt;&lt;br /&gt;So if you are new to Seam, start by looking at the Seam examples that comes with the bundle. They are far better to use, than generating the UI with seam-gen and going from there.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-6887741208621355573?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/6887741208621355573/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=6887741208621355573' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/6887741208621355573'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/6887741208621355573'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2010/10/why-you-should-not-use-seam-application.html' title='Why you should NOT use the Seam Application Framework'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-5892446193974044533</id><published>2010-09-17T14:51:00.000+02:00</published><updated>2010-09-17T14:51:47.664+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Devoxx'/><category scheme='http://www.blogger.com/atom/ns#' term='JavaOne'/><title type='text'>Devoxx versus JavaOne</title><content type='html'>&lt;a href="http://www.devoxx.com/display/Devoxx2K10/Home"&gt;Devoxx&lt;/a&gt; or &lt;a href="http://www.oracle.com/us/javaonedevelop/index.html"&gt;JavaOne&lt;/a&gt;?&lt;br /&gt;Thats the question...&lt;br /&gt;&lt;br /&gt;It's really not that difficult to choose.&lt;br /&gt;If you are based in Europe (as our company is), then you will for sure get more value for your money attending Devoxx instead of JavaOne.&lt;br /&gt;&lt;br /&gt;However, if you look at a technical perspective, then still Devoxx comes on top in my opinion. The opening talk is by &lt;i&gt;&lt;a href="http://blogs.sun.com/mr/"&gt;Mark Reinhold&lt;/a&gt;&lt;/i&gt; and one of the last talks, "Java state of the Union" is by no other than &lt;i&gt;James Gosling&lt;/i&gt;. (I don't even need to link to him, every Java developer should know who he is), and there are tons of fameous speakers: &lt;i&gt;Brian Goetz, The JavaPosse, Heinz Kabutz, Richard Bair and Roberto Chinnici &lt;/i&gt;just to name a few. (No pun intented for the others I didn't mention).&lt;br /&gt;&lt;br /&gt;So it shouldn't come as a big surprise that I am also attending Devoxx. If you are going, lemme know and we can hook up!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-5892446193974044533?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/5892446193974044533/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=5892446193974044533' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5892446193974044533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5892446193974044533'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2010/09/devoxx-versus-javaone.html' title='Devoxx versus JavaOne'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-7086013230966203976</id><published>2010-09-12T20:02:00.000+02:00</published><updated>2010-09-12T20:02:20.555+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java 7'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Java 7, yet another delay</title><content type='html'>Mark Reinhold has published a &lt;a href="http://blogs.sun.com/mr/entry/rethinking_jdk7"&gt;blog&lt;/a&gt; stating what has been painfully obvious to everyone following the JDK 7 development: It will yet again be delayed until mid 2012(!)&lt;br /&gt;&lt;br /&gt;Mark is further saying that there is an alternative which they are considering, and that &lt;i&gt;"is to take everything we have now, test and stabilize it, and ship that as JDK 7. We could then ﬁnish Lambda, Jigsaw, the rest of Coin, and maybe a few additional key features in a JDK 8 release which would ship fairly soon thereafter."&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;I couldn't agree more. The community has waited too long for Java 7 to come out. There are so many problems in the current Java version, that makes people look around for alternatives in the Java Virtual Machine.&lt;br /&gt;I am certain that if Java 7 will be delayed for yet two more years, then most people by that time will move to other languages such as &lt;a href="http://www.scala-lang.org/"&gt;Scala&lt;/a&gt; and &lt;a href="http://www.grails.org/"&gt;Grails&lt;/a&gt;, which doesn't have the problems Java has today.&lt;i&gt;&amp;nbsp;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;So, to sum up. Oracle has my vote to ship whatever they have now, and then come with the rest of it with JDK 8.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-7086013230966203976?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/7086013230966203976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=7086013230966203976' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7086013230966203976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7086013230966203976'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2010/09/java-7-yet-another-delay.html' title='Java 7, yet another delay'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-7330609962089287695</id><published>2010-08-02T16:44:00.004+02:00</published><updated>2011-09-16T09:18:10.426+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PDF'/><category scheme='http://www.blogger.com/atom/ns#' term='jodconverter 3'/><category scheme='http://www.blogger.com/atom/ns#' term='pdfa'/><category scheme='http://www.blogger.com/atom/ns#' term='jodconverter'/><title type='text'>Migrating from JODConverter 2 to JODConverter 3</title><content type='html'>In the previous &lt;a href="http://shervinasgari.blogspot.com/2010/05/automate-converting-of-documents-to-pdf.html"&gt;posting&lt;/a&gt; I showed you how you could automate conversions of documents to PDF &amp;amp; PDF/A using JODConverter 2.&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&lt;a href="http://code.google.com/p/jodconverter/"&gt;JODConverter 3.0.beta&lt;/a&gt; has been out for some time, and even though it is still beta, it is very stable. Maybe even more stable than JODConverter 2. &lt;br /&gt;&lt;br /&gt;In this blog posting I will highlight the benefits of JODConverter 3 compared to its predecessor and show you how you can modify your code to create PDF/A documents with JODConverter 3. &lt;i&gt;&amp;nbsp;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;To be able to convert an existing PDF document to PDF/A in OpenOffice.org, you will need to install &lt;a href="http://extensions.services.openoffice.org/project/pdfimport"&gt;Sun PDF Import extension&lt;/a&gt;!&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;JODConverter 2 versus 3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;JODConverter 3 still uses OpenOffice.org to perform its conversion. It is still a wrapper to the OOo API. It is only a complete rewrite of the JODConverter core library which is much cleaner and easier to use.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;u&gt;&lt;b&gt;Whats new?&lt;/b&gt;&lt;/u&gt;&amp;nbsp;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;No more init script(!)&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;You don't have to manually start OpenOffice.org as a service anymore. This will be handled automatic.&lt;/li&gt;&lt;li&gt;You can even create multiple processes which is useful for multi-core CPU's. Best practise is one process for each CPU core.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Automatically restart an OOo instance if it crashes.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;If for some reason your process crashes, JODConverter will detect this, and restart the process automatic. This was a hassle with JODConverter 2, as you needed to manually do this in Linux.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Abort conversions that take too long (according to a configurable timeout parameter)&lt;/li&gt;&lt;li&gt;Automatically restart an OOo instance after n conversions (workaround for OOo memory leaks)&lt;/li&gt;&lt;/ul&gt;Additionally the new architecture will make it easier to use the core  JODConverter classes as a generic framework for working with OOo - not  just limited to document conversions.&lt;br /&gt;I am sure there will be more features when JODConverter 3 goes final.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Configuration&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;All you need to do do is point your OpenOffice.org installation to the OfficeManager, and you are good to go.&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;OfficeManager officeManager = new DefaultOfficeManagerConfiguration()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .setOfficeHome("/usr/lib/openoffice")&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .buildOfficeManager().start();&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;This manager will use the default settings for &lt;i&gt;Task Queue Timeout, Task Execution Timeout, Port Number etc&lt;/i&gt; but you can easily change them&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code class="prettyprint"&gt;OfficeManager officeManager = new DefaultOfficeManagerConfiguration()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .setOfficeHome("/usr/lib/openoffice")&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .setTaskExecutionTimeout(240000L)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .setTaskQueueTimeout(60000L)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .buildOfficeManager().start();&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;If you want to utilize piping (Recommended is one process per CPU-core), you will need to set VM argument and point &lt;i&gt;java.library.path&lt;/i&gt; to the location of &lt;i&gt;$URE_LIB&lt;/i&gt; which on my Ubuntu machine is&lt;i&gt;&lt;span class="str"&gt; /usr/lib/ure/lib/&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;span class="str"&gt;For instance: &lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="str"&gt;-Djava.library.path="/usr/lib/ure/lib"&lt;/span&gt;&lt;/pre&gt;&lt;span class="str"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;And then you can change your OfficeManager.&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code class="prettyprint"&gt;&lt;span class="str"&gt;OfficeManager officeManager = new DefaultOfficeManagerConfiguration()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .setOfficeHome("/usr/lib/openoffice")&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .setConnectionProtocol(OfficeConnectionProtocol.PIPE)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .setPipeNames("office1","office2") //two pipes&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .setTaskExecutionTimeout(240000L) //4 minutes&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .setTaskQueueTimeout(60000L)&amp;nbsp; // 1 minute&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .buildOfficeManager().start();&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span class="str"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;u&gt;&lt;span class="str"&gt;&lt;b&gt;ConverterService3Impl&lt;/b&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;span class="str"&gt;&lt;b&gt; &lt;/b&gt;The following codes performs all the converting. It supports a &lt;i&gt;File or byte[]&lt;/i&gt; as input.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="str"&gt;This is how you use it:&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt; Lets say you have a PDF file as byte[], and you want to convert this byte to PDF/A as byte.&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;All you would have to do is call method:&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code class="prettyprint"&gt;&lt;span class="str"&gt;byte[] pdfa = converterService.convertToPDFA(pdfFile);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span class="str"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;Similarly, if you have a Document (say a OpenOffice.org writer document) and you want to convert this to PDF you would call the method:&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code class="prettyprint"&gt;&lt;span class="str"&gt;File doc = new File("myDocument.odt");&lt;br /&gt;File pdfDocument = converterService.convert(doc, ".pdf");&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span class="str"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;Note that you will always get a PDF/A compliant pdf. All you need to do is change the extension from ".pdf" to ".html" and the converter would do the magic.&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;Here is the source. Please read the comments in the source code if you want to understand it, or just ask in the comment section below.&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code class="prettyprint"&gt;&lt;span class="str"&gt;import java.io.BufferedInputStream;&lt;br /&gt;import java.io.BufferedOutputStream;&lt;br /&gt;import java.io.ByteArrayInputStream;&lt;br /&gt;import java.io.ByteArrayOutputStream;&lt;br /&gt;import java.io.File;&lt;br /&gt;import java.io.FileInputStream;&lt;br /&gt;import java.io.FileOutputStream;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;import java.io.InputStream;&lt;br /&gt;import java.net.ConnectException;&lt;br /&gt;import java.util.HashMap;&lt;br /&gt;import java.util.Map;&lt;br /&gt;import java.util.regex.Matcher;&lt;br /&gt;import java.util.regex.Pattern;&lt;br /&gt;&lt;br /&gt;import javax.ejb.Local;&lt;br /&gt;import javax.ejb.Stateless;&lt;br /&gt;&lt;br /&gt;import lombok.Cleanup;&lt;br /&gt;&lt;br /&gt;import org.apache.commons.io.FilenameUtils;&lt;br /&gt;import org.apache.commons.io.IOUtils;&lt;br /&gt;import org.artofsolving.jodconverter.OfficeDocumentConverter;&lt;br /&gt;import org.artofsolving.jodconverter.document.DefaultDocumentFormatRegistry;&lt;br /&gt;import org.artofsolving.jodconverter.document.DocumentFamily;&lt;br /&gt;import org.artofsolving.jodconverter.document.DocumentFormat;&lt;br /&gt;import org.artofsolving.jodconverter.document.DocumentFormatRegistry;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;&amp;nbsp;* This service converts files from one thing to another ie ODT to PDF, DOC to ODT etc&lt;br /&gt;&amp;nbsp;* @author Shervin Asgari&lt;br /&gt;&amp;nbsp;*&lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;@Stateless&lt;br /&gt;@Local(ConverterService.class)&lt;br /&gt;public class ConverterService3Impl implements ConverterService {&lt;br /&gt;&lt;br /&gt;&amp;nbsp; private static final String PDF_EXTENSION = ".pdf";&lt;br /&gt;&amp;nbsp; private static final String PDF = "pdf";&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&amp;nbsp; // Uncomment these when we want to use them&lt;br /&gt;&lt;br /&gt;&amp;nbsp; // private final int PDFXNONE = 0;&lt;br /&gt;&amp;nbsp; private final int PDFX1A2001 = 1;&lt;br /&gt;&amp;nbsp; // private final int PDFX32002 = 2;&lt;br /&gt;&amp;nbsp; // private final int PDFA1A = 3;&lt;br /&gt;&amp;nbsp; // private final int PDFA1B = 4; &lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;&amp;nbsp; @Logger //Your favourite logger (ie Log4J) could be injected here &lt;br /&gt;&amp;nbsp; private Log log;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; public File convert(File inputFile, String extension) throws IOException, ConnectException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (inputFile == null) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new IOException("The document to be converted is null");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Pattern p = Pattern.compile("^.?pdf$", Pattern.CASE_INSENSITIVE);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Matcher m = p.matcher(extension);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OfficeDocumentConverter converter;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //If inputfile is a PDF you will need to use another FormatRegistery, namely DRAWING&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(FilenameUtils.isExtension(inputFile.getName(), PDF) &amp;amp;&amp;amp; m.find()) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DocumentFormatRegistry formatRegistry = new DefaultDocumentFormatRegistry();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; formatRegistry.getFormatByExtension(PDF).setInputFamily(DocumentFamily.DRAWING);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; converter = new OfficeDocumentConverter(officeManager, formatRegistry);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; converter = new OfficeDocumentConverter(officeManager);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; String inputExtension = FilenameUtils.getExtension(inputFile.getName());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; File outputFile = File.createTempFile(FilenameUtils.getBaseName(inputFile.getName()), extension);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; long startTime = System.currentTimeMillis();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //If both input and output file is PDF&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (FilenameUtils.isExtension(inputFile.getName(), PDF) &amp;amp;&amp;amp; m.matches()) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //We need to add the DocumentFormat with DRAW&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; converter.convert(inputFile, outputFile, toFormatPDFA_DRAW());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else if(FilenameUtils.isExtension(outputFile.getName(), PDF)) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; converter.convert(inputFile, outputFile, toFormatPDFA());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; converter.convert(inputFile, outputFile);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; long conversionTime = System.currentTimeMillis() - startTime;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; log.info(String.format("successful conversion: %s [%db] to %s in %dms", inputExtension, inputFile.length(), extension, conversionTime));&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return outputFile;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (Exception exception) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; log.error(String.format("failed conversion: %s [%db] to %s; %s; input file: %s", inputExtension, inputFile.length(), extension, exception, inputFile.getName()));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exception.printStackTrace();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new IOException("Converting failed");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } finally {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //outputFile.deleteOnExit();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //inputFile.deleteOnExit();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp; /**&lt;br /&gt;&amp;nbsp;&amp;nbsp; * Convert pdf file to pdf/a&lt;br /&gt;&amp;nbsp;&amp;nbsp; * You will need to install OpenOffice extension (pdf viewer) to get it working&lt;br /&gt;&amp;nbsp;&amp;nbsp; * @param pdf&lt;br /&gt;&amp;nbsp;&amp;nbsp; * @return Byte array&lt;br /&gt;&amp;nbsp;&amp;nbsp; * @throws IOException&lt;br /&gt;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;&amp;nbsp; public byte[] convertToPDFA(byte[] pdfByte) throws IOException, ConnectException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Cleanup InputStream is = new ByteArrayInputStream(pdfByte);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; File pdf = createFile(is, PDF_EXTENSION);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; log.debug("PDF is: #0 #1", pdf.getName(), pdf.isFile());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return convert(pdf);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp; private byte[] convert(File pdf) throws IOException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (pdf == null) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new IOException("The document to be converted is null");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; File convertedPdfA = convert(pdf, PDF_EXTENSION);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Cleanup final InputStream inputStream = new BufferedInputStream(new FileInputStream(convertedPdfA));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte[] pdfa = IOUtils.toByteArray(inputStream);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return pdfa;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; /**&lt;br /&gt;&amp;nbsp;&amp;nbsp; * Creates a temp file and writes the content of InputStream to it. doesn't close input&lt;br /&gt;&amp;nbsp;&amp;nbsp; * &lt;br /&gt;&amp;nbsp;&amp;nbsp; * @return File&lt;br /&gt;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;&amp;nbsp; private java.io.File createFile(InputStream in, String extension) throws IOException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; java.io.File f = File.createTempFile("tmpFile", extension);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Cleanup BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(f));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IOUtils.copy(in, out);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return f;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp; /**&lt;br /&gt;&amp;nbsp;&amp;nbsp; * This DocumentFormat must be used when converting from document (not pdf) to pdf/a&lt;br /&gt;&amp;nbsp;&amp;nbsp; * For some reason "PDF/A-1" is called "SelectPdfVersion" internally; maybe they plan to add other PdfVersions later.&lt;br /&gt;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;&amp;nbsp; private DocumentFormat toFormatPDFA() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DocumentFormat format = new DocumentFormat("PDF/A", PDF, "application/pdf");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map&amp;lt;String, Object&amp;gt; properties = new HashMap&amp;lt;String, Object&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; properties.put("FilterName", "writer_pdf_Export");&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map&amp;lt;String, Object&amp;gt; filterData = new HashMap&amp;lt;String, Object&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; filterData.put("SelectPdfVersion", this.PDFX1A2001);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; properties.put("FilterData", filterData);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; format.setStoreProperties(DocumentFamily.TEXT, properties);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return format;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp; /**&lt;br /&gt;&amp;nbsp;&amp;nbsp; * This DocumentFormat must be used when converting from pdf to pdf/a&lt;br /&gt;&amp;nbsp;&amp;nbsp; * For some reason "PDF/A-1" is called "SelectPdfVersion" internally; maybe they plan to add other PdfVersions later.&lt;br /&gt;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;&amp;nbsp; private DocumentFormat toFormatPDFA_DRAW() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DocumentFormat format = new DocumentFormat("PDF/A", PDF, "application/pdf");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map&amp;lt;String, Object&amp;gt; properties = new HashMap&amp;lt;String, Object&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; properties.put("FilterName", "draw_pdf_Export");&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map&amp;lt;String, Object&amp;gt; filterData = new HashMap&amp;lt;String, Object&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; filterData.put("SelectPdfVersion", this.PDFX1A2001);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; properties.put("FilterData", filterData);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; format.setStoreProperties(DocumentFamily.DRAWING, properties);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return format;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="str"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span class="str"&gt;Remember to close the connection when your application is quit/shutdown&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-7330609962089287695?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/7330609962089287695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=7330609962089287695' title='39 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7330609962089287695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7330609962089287695'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2010/08/migrating-from-jodconverter-2-to.html' title='Migrating from JODConverter 2 to JODConverter 3'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>39</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-5102883999089844809</id><published>2010-05-12T14:15:00.000+02:00</published><updated>2010-05-12T14:15:42.808+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PDF'/><category scheme='http://www.blogger.com/atom/ns#' term='pdfa'/><category scheme='http://www.blogger.com/atom/ns#' term='jodconverter'/><title type='text'>Automate converting of documents to PDF &amp; PDF/A using JODConverter 2</title><content type='html'>In this blog post I will be showing a great library for converting existing documents to PDF/A using an OpenSource library called &lt;a href="http://www.artofsolving.com/opensource/jodconverter"&gt;JODConverter.&lt;/a&gt;&lt;br /&gt;Note there is nothing that prevents you to convert to normal PDF.&lt;br /&gt;&lt;br /&gt;JODConverter leverages OpenOffice.org, which provides arguably the best import/export filters for OpenDocument and Microsoft Office formats available today. Thus, it requires an installation of OpenOffice and it supports all documents which OpenOffice supports.&lt;br /&gt;&lt;br /&gt;JODConverter automates all conversions supported by OpenOffice.org, including&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Microsoft Office to OpenDocument, and viceversa &lt;br /&gt;&lt;ul&gt;&lt;li&gt;Word to OpenDocument Text (odt); OpenDocument Text (odt) to Word&lt;/li&gt;&lt;li&gt;Excel to OpenDocument Spreadsheet (ods); OpenDocument Spreadsheet (ods) to Excel&lt;/li&gt;&lt;li&gt;PowerPoint to OpenDocument Presentation (odp); OpenDocument Presentation (odp) to PowerPoint&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Any format to PDF &lt;br /&gt;&lt;ul&gt;&lt;li&gt;OpenDocument (Text, Spreadsheet, Presentation) to PDF&lt;/li&gt;&lt;li&gt;Word to PDF; Excel to PDF; PowerPoint to PDF&lt;/li&gt;&lt;li&gt;RTF to PDF; WordPerfect to PDF; ...&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;And more &lt;br /&gt;&lt;ul&gt;&lt;li&gt;OpenDocument Presentation (odp) to Flash; PowerPoint to Flash&lt;/li&gt;&lt;li&gt;RTF to OpenDocument; WordPerfect to OpenDocument&lt;/li&gt;&lt;li&gt;Any format to HTML (with limitations)&lt;/li&gt;&lt;li&gt;Support for OpenOffice.org 1.0 and old StarOffice formats&lt;/li&gt;&lt;li&gt;...&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;i&gt;JODConverter&lt;/i&gt; can be used in many different ways&lt;br /&gt;&lt;ul&gt;&lt;li&gt;As a Java library, embedded in your own Java application&lt;/li&gt;&lt;li&gt;As a command line tool, possibly invoked from your own scripts&lt;/li&gt;&lt;li&gt;As a simple web application: upload your input document, select the desired format and download the converted version&lt;/li&gt;&lt;li&gt;As a web service, invoked from your own application written in your favourite language (.NET, PHP, Python, Ruby, ...)&lt;/li&gt;&lt;/ul&gt;&lt;i&gt;JODConverter&lt;/i&gt; is open source software released under the terms of the &lt;a href="http://www.gnu.org/licenses/lgpl.html"&gt;LGPL&lt;/a&gt; and can be downloaded from &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=91849"&gt;SourceForge.net&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Starting OpenOffice as a service&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;JODConverter needs to connect to a running OpenOffice.org instance in order to perform the document conversions. This is different from starting the OpenOffice.org program as you would normally do. OpenOffice.org can be configured to run as a service and listen for commands on a TCP port. One way of doing this is to run the following command in Linux: (You only need to change location of the soffice)&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;/usr/bin/soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -norestore -nofirststartwizard -nologo -headless &amp;amp;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;I suggest putting this script in &lt;i&gt;/etc/init.d/&lt;/i&gt; so it will run automatically.&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Note&lt;/b&gt;&lt;/span&gt; that you &lt;b&gt;cannot&lt;/b&gt; open OpenOffice.org if you have this service running as &lt;i&gt;headless&lt;/i&gt; mode.&lt;br /&gt;If you are running your system on Windows, you can read &lt;a href="http://www.artofsolving.com/node/11"&gt;here&lt;/a&gt; for information on how to create a service on Windows. &lt;br /&gt;See the &lt;a href="http://wiki.services.openoffice.org/wiki/Uno/FAQ#How_do_I_remotely_connect_to_an_OpenOffice.org_running_on_a_different_machine.3F"&gt;Uno/FAQ&lt;/a&gt; on the OpenOffice.org Wiki for more on this topic.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Command-Line Tool (cli like)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;You can run JODConverter as cli (command line interface) like program.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;To use it as a command line tool, you need to download the 2.2.2 distribution, unpack it, and run it using Java.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;To convert a single file specify input and output files as parameters&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;java -jar lib/jodconverter-cli-2.2.0.jar document.doc document.pdf&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;To convert multiple files to a given format specify the format using the -f (or --output-format) option and then pass the input files as parameters&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;java -jar lib/jodconverter-cli-2.2.0.jar -f pdf *.odt&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Usage in your Java applications&lt;/span&gt;&lt;br /&gt;Using JODConverter in your own Java application is very easy. The following example shows the skeleton code required to perform a one off conversion from a Word document to PDF:&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;File inputFile = new File("document.doc");&lt;br /&gt;File outputFile = new File("document.pdf");&lt;br /&gt;&amp;nbsp;&lt;br /&gt;// connect to an OpenOffice.org instance running on port 8100&lt;br /&gt;OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);&lt;br /&gt;connection.connect();&lt;br /&gt;&amp;nbsp;&lt;br /&gt;// convert&lt;br /&gt;DocumentConverter converter = new OpenOfficeDocumentConverter(connection);&lt;br /&gt;converter.convert(inputFile, outputFile);&lt;br /&gt;&amp;nbsp;&lt;br /&gt;// close the connection&lt;br /&gt;connection.disconnect();&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;To get convert the same document to PDF/A instead, you need to create a custom &lt;i&gt;DocumentFormat&lt;/i&gt; that is of type &lt;i&gt;PDF/A&lt;/i&gt; and then send that into the &lt;i&gt;convert&lt;/i&gt; method like this:&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;/**&lt;br /&gt;* Returns DocumentFormat of PDF/A&lt;br /&gt;*/&lt;br /&gt;private DocumentFormat toDocumentFormatPDFA() {&lt;br /&gt;&amp;nbsp; //These are the different PDF version's you can get. 1 is the default PDF/A&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; final int PDFXNONE = 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; final int PDFX1A2001 = 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; final int PDFX32002 = 2;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; final int PDFA1A = 3;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; final int PDFA1B = 4;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // create a PDF DocumentFormat (as normally configured in document-formats.xml)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DocumentFormat customPdfFormat = new DocumentFormat(PORTABEL_FORMAT, PDF_APP, "pdf");&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //now set our custom options&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; customPdfFormat.setExportFilter(DocumentFamily.TEXT, "writer_pdf_Export");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * For some reason "PDF/A-1" is called "SelectPdfVersion" internally; maybe they plan to add other&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * PdfVersions later.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; final Map&amp;lt;String, Integer&amp;gt; pdfOptions = new HashMap&amp;lt;String, Integer&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pdfOptions.put("SelectPdfVersion", PDFX1A2001);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; customPdfFormat.setExportOption(DocumentFamily.TEXT, "FilterData", pdfOptions);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return customPdfFormat;&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;And then you call the convert method with &lt;i&gt;toDocumentFormatPDFA() &lt;/i&gt;as parameter.&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;converter.convert(inputFile, outputFile, toDocumentFormatPDFA());&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Note that this is a very simple example. I do not recommend opening and closing connection for each conversion. You open once the application is started (or the first time you want to convert), and then close the connection when the application shuts down.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-5102883999089844809?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/5102883999089844809/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=5102883999089844809' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5102883999089844809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5102883999089844809'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2010/05/automate-converting-of-documents-to-pdf.html' title='Automate converting of documents to PDF &amp; PDF/A using JODConverter 2'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-8642463653590349291</id><published>2010-04-05T12:36:00.002+02:00</published><updated>2010-09-23T10:07:43.771+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Seam 2'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam Series'/><title type='text'>Advanced Seam series part 3 of 3: Asynchronous mail sending</title><content type='html'>&lt;span style="font-size: x-large;"&gt;Advanced Seam series part 3 of 3: Asynchronous mail sending&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;In this last series I will be showing how easy you can set up your seam environment to handle asynchronous mail sending. You can even raise other events asynchronously.&lt;br /&gt;&lt;br /&gt;Seam makes it very easy to perform work asynchronously from a web request.&lt;br /&gt;&lt;br /&gt;Seam layers a simple asynchronous method and event         facility over your choice of &lt;span class="emphasis"&gt;&lt;i&gt;dispatchers&lt;/i&gt;&lt;/span&gt;:     &lt;br /&gt;&lt;div class="itemizedlist"&gt;&lt;ul&gt;&lt;li&gt;&lt;code class="literal"&gt;java.util.concurrent.ScheduledThreadPoolExecutor&lt;/code&gt; (by default)&lt;/li&gt;&lt;li&gt;The EJB timer service (for EJB 3.0 environments)&lt;/li&gt;&lt;li&gt;Quartz&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;span style="font-size: large;"&gt;Asynchronous configuration&lt;/span&gt;&lt;br /&gt;The default dispatcher, based upon a&lt;code class="literal"&gt;ScheduledThreadPoolExecutor &lt;/code&gt;performs efficiently but does not guarantee that the task will ever actually be executed. This is because it does not have a persistence state, meaning it only stores the events in memory. If your application server goes down in between the calls, they will not run.&lt;br /&gt;If you have a task that is not critical that it must be performed, ie a clean up task, or something trivial, then it is no reason not to use the default dispatcher.&lt;br /&gt;&lt;br /&gt;However, if you want the guarantee that the task is called you might use the Timer Service.&lt;br /&gt;If you're working in an environment that supports EJB 3.0, you can add the following line to &lt;code class="literal"&gt;components.xml&lt;/code&gt;:&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&amp;lt;async:timer-service-dispatcher/&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;Then your asynchronous tasks will be processed by the container's EJB timer service. The Timer Service implementation is persistence based, thus you will get some guarantee that the tasks will eventually run.&lt;br /&gt;&lt;br /&gt;Finally, your third is to use an Open Source alternative called Quartz (recently acquired by Terracotta). To use Quartz, you will need to bundle the Quartz library JAR (found in the &lt;code class="literal"&gt;lib&lt;/code&gt; directory)              in your EAR and declare it as a Java module in &lt;code class="literal"&gt;application.xml&lt;/code&gt;.The Quartz dispatcher may be configured by adding a Quartz property file to the classpath. It must be named &lt;code class="literal"&gt;seam.quartz.properties&lt;/code&gt;.In addition, you need to add the following line to &lt;code class="literal"&gt;components.xml&lt;/code&gt; to install the              Quartz dispatcher.&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&amp;lt;async:quartz-dispatcher/&amp;gt;&lt;/code&gt;&lt;/pre&gt;Note that Quartz uses RAMJobStore as default, thus it is not persistence based on default. You will need to configure it to use persistence base. &lt;br /&gt;It is up to the reader to choose whichever asynchronous strategy they see fit.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Sending emails Asynchronously&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;It is really very easy sending a plain email with Seam. All you have to do is use Seam mail, annotate the method and interface (if you are using EJB's) with @Asynchronous and its done. However, the tricky part is using EL expressions and variables stored in the different Contexts, so that you can produce dynamic emails.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;There are two ways you can call a task asynchronously. You can either send an asynchronous event, or as I previously explained, annotate a method with @Asynchronous, and call it normally, ie: &lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;Events.instance().raiseAsynchronousEvent("sendOneTimepassword", user, theOnetimepass);&lt;br /&gt;//Or the normal way&lt;br /&gt;@In MailService mailService;&lt;br /&gt;mailService.sendSupport(sender,supportEmail,supportMessage);&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Lets say you have the following Stateless EJB that is responsible for sending emails:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;import javax.ejb.Local;&lt;br /&gt;import javax.ejb.Stateless;&lt;br /&gt;&lt;br /&gt;import org.jboss.seam.annotations.AutoCreate;&lt;br /&gt;import org.jboss.seam.annotations.In;&lt;br /&gt;import org.jboss.seam.annotations.Name;&lt;br /&gt;import org.jboss.seam.annotations.Observer;&lt;br /&gt;import org.jboss.seam.annotations.async.Asynchronous;&lt;br /&gt;import org.jboss.seam.contexts.Contexts;&lt;br /&gt;import org.jboss.seam.faces.Renderer;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;&amp;nbsp;* This service is responsible for sending emails asynchronously&lt;br /&gt;&amp;nbsp;* @author Shervin Asgari&lt;br /&gt;&amp;nbsp;*&lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;@Stateless&lt;br /&gt;@Local(MailService.class)&lt;br /&gt;@Name("mailService")&lt;br /&gt;@AutoCreate&lt;br /&gt;public class MailServiceImpl implements MailService {&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; @In(create = true)&lt;br /&gt;&amp;nbsp; &amp;nbsp; private Renderer renderer;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; @Asynchronous&lt;br /&gt;&amp;nbsp; &amp;nbsp; public void sendSupport(User sender, String supportEmail, String supportMessage) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Contexts.getEventContext().set("sender", sender);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Contexts.get&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Event&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Context().set("supportEmail", supportEmail);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Contexts.get&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Event&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Context().set("supportMessage", supportMessage);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; renderer.render("/generic/email-template/support-email-template.xhtml");&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; @Observer("sendOneTimepassword")&lt;br /&gt;&amp;nbsp; &amp;nbsp; //@Asynchronous, we dont need to annotate with @Asynchronous if we are raising the event asynchronously&lt;br /&gt;&amp;nbsp; &amp;nbsp; public void sendOneTimepassword(User emailUser, String oneTimePassword) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Contexts.get&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Event&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Context().set(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;emailUser&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;, emailUser);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Contexts.get&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Event&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Context().set(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;"&lt;/span&gt;&lt;/span&gt;oneTimePassword&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;, oneTimePassword);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; renderer.render("/generic/email-template/onetimepassword-email-template.xhtml");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;One of the methods &lt;code&gt;sendSupport()&lt;/code&gt;&lt;/span&gt;&lt;/span&gt; is responsible for sending support messages as email, whilst the other method &lt;code&gt;sendOneTimepassword&lt;/code&gt; is used to send generated one time passwords to a user so that they can authenticate to the system. Have you look &lt;a href="http://thelabdude.blogspot.com/2009/05/user-registration-solution-using-jboss.html"&gt;here&lt;/a&gt; for information on how you can set up your system to do exactly that.&lt;br /&gt;&lt;br /&gt;The key point to note is the &lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Contexts.get&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Event&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Context().set(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;emailUser&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;, emailUser);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;. If I would have normally injected the user in the EmailService, it would not work. Since the call is made asynchronously we need to set the variables in the asynchronous context. Thus we can now get hold of them in the email template:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&amp;lt;m:message &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns="http://www.w3.org/1999/xhtml"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:ui="http://java.sun.com/jsf/facelets"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:m="http://jboss.com/products/seam/mail"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:f="http://java.sun.com/jsf/core"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:h="http://java.sun.com/jsf/html"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;m:from name="Someone"&amp;gt;no-reply@someplace.com&amp;lt;/m:from&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;m:to name="#{emailUser.name}" address="#{emailUser.fromEmail}" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;m:subject&amp;gt;#{messages['mail.onetime.heading']}&amp;lt;/m:subject&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;m:body&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Your one time password is: &amp;lt;i&amp;gt;#{oneTimePassword}&amp;lt;/i&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;p&amp;gt;#{messages['mail.onetime.noreply']}&amp;lt;/p&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/m:body&amp;gt;&lt;br /&gt;&amp;lt;/m:message&amp;gt;&lt;/code&gt;&lt;/pre&gt;Thats really all there is to it! Now your emails will be sent asynchronously.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-8642463653590349291?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/8642463653590349291/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=8642463653590349291' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/8642463653590349291'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/8642463653590349291'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2010/04/advanced-seam-series-part-2-of-3.html' title='Advanced Seam series part 3 of 3: Asynchronous mail sending'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-7850100834756849360</id><published>2010-03-26T11:04:00.002+01:00</published><updated>2010-03-26T11:07:56.979+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='filters'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam 2'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam Series'/><title type='text'>Advanced Seam series part 2 of 3: Seam Filters</title><content type='html'>&lt;span style="font-size: large;"&gt;&lt;span style="font-family: inherit;"&gt;Seam Filters.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In this blog post I will be showing two filters. One that hacks in UTF-8 as encoding, and the other, a download filter for downloading files efficiently. &lt;br /&gt;&lt;br /&gt;Seam filters can potentially be called outside of the Seam context, thus they are not truly a Seam component, but they act as one. However, they are able to reuse the functionality for component scanning, installation and configuration for filters.&lt;br /&gt;&lt;br /&gt;There are two ways to define filters.&lt;br /&gt;&lt;br /&gt;1. Through web.xml&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&amp;lt;filter&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;filter-name&amp;gt;UTF8 Filter&amp;lt;/filter-name&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;filter-class&amp;gt;com.something.filter.UTF8Filter&amp;lt;/filter-class&amp;gt;&lt;br /&gt;&amp;lt;/filter&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;filter-mapping&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;filter-name&amp;gt;UTF8 Filter&amp;lt;/filter-name&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;url-pattern&amp;gt;*.seam&amp;lt;/url-pattern&amp;gt;&lt;br /&gt;&amp;lt;/filter-mapping&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;And the Filter it self:&lt;br /&gt;This filter is a fix for a bug in Seam encoding filter. More information &lt;a href="https://jira.jboss.org/jira/browse/JBSEAM-3006"&gt;here&lt;/a&gt;.&lt;br /&gt;Remember you must implement Filter. &lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;/**&lt;br /&gt; * This Filter is a fix for bug in seam encoding filter, see here for more details: https://jira.jboss.org/jira/browse/JBSEAM-3006&lt;br /&gt; * It might be removed if the version will be upgraded to at least 2.2.1.CR1&lt;br /&gt; *    &lt;br /&gt; */&lt;br /&gt;public class UTF8Filter implements Filter {&lt;br /&gt;&lt;br /&gt;    public void destroy() {}&lt;br /&gt;&lt;br /&gt;    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)   throws IOException, ServletException {&lt;br /&gt;        // set encoding to UTF-8&lt;br /&gt;        req.setCharacterEncoding("UTF-8");&lt;br /&gt;        chain.doFilter(req, res);&lt;br /&gt;        return;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void init(FilterConfig arg0) throws ServletException {}&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;However, the servlet specification doesn't provide a well defined order if you specify your filters in a &lt;code class="literal"&gt;web.xml&lt;/code&gt;, however Seam provides a way to do that by using the &lt;i&gt;&lt;b&gt;@Filter&lt;/b&gt;&lt;/i&gt; annotation.&lt;br /&gt;&lt;br /&gt;In this next example I will show an efficient and pretty safe download filter which you can use to serve files to the user. First I want to present the way you &lt;b&gt;shouldn't&lt;/b&gt; do it.&lt;br /&gt;&lt;br /&gt;Say you have a File entity class.&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;import java.io.ByteArrayInputStream;&lt;br /&gt;import java.io.InputStream;&lt;br /&gt;import java.security.GeneralSecurityException;&lt;br /&gt;&lt;br /&gt;import javax.persistence.Basic;&lt;br /&gt;import javax.persistence.Column;&lt;br /&gt;import javax.persistence.Entity;&lt;br /&gt;import javax.persistence.FetchType;&lt;br /&gt;import javax.persistence.GeneratedValue;&lt;br /&gt;import javax.persistence.Id;&lt;br /&gt;import javax.persistence.Lob;&lt;br /&gt;import javax.persistence.ManyToOne;&lt;br /&gt;import javax.persistence.PrePersist;&lt;br /&gt;import javax.persistence.PreUpdate;&lt;br /&gt;import javax.persistence.Transient;&lt;br /&gt;&lt;br /&gt;import org.hibernate.validator.NotNull;&lt;br /&gt;&lt;br /&gt;@Entity&lt;br /&gt;public class File {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Id&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @GeneratedValue&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Long id;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @NotNull&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Column(nullable = false, length = 256)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private String name;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Column&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private String hash;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // BLOB = L + 2 bytes (max size is 2^16 - 1 or 65,535 bytes, 65KB)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // MEDIUMBLOB = L + 3 bytes (max size is 2^24 - 1 or 16,777,215 bytes, 16MB)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // LONGBLOB = L + 4 bytes (max size is 2^32 - 1 or 4,294,967,295 bytes, 4GB)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Basic(fetch = FetchType.LAZY)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // @Basic is used in conjunction with @Lob&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Lob&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;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set to MAX 100MB LONGBLOB in MySQL&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Column(length = 104857600, nullable = false)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private byte[] data;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @PrePersist&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @PreUpdate&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void setHash() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hash = PasswordSupport.generateFileHash(data);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (GeneralSecurityException e) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.printStackTrace();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hash = null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Transient&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public InputStream getInputStream() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new ByteArrayInputStream(data);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;    //getters and setters&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;For the PasswordSupport class (which basically hashes the input), have a look at &lt;a href="http://shervinasgari.blogspot.com/search/label/hash%20password"&gt;my previous post&lt;/a&gt;. We always want to generate a new hash if a new file appears, thus the triggers &lt;i&gt;@PreUpdate&lt;/i&gt; and &lt;i&gt;@PrePersist&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;But to save you some time, here is the method:&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Hash file&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * @throws GeneralSecurityException &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static final String generateFileHash(byte[] data) throws GeneralSecurityException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte[] salt = new byte[1024];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String theHash;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AnnotatedBeanProperty&amp;lt;UserPassword&amp;gt; userPasswordProperty = new AnnotatedBeanProperty&amp;lt;UserPassword&amp;gt;(ProcessUser.class, UserPassword.class);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Will get the hash value from annotation UserPassword in User.class&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PasswordHash.instance().setHashAlgorithm(userPasswordProperty.getAnnotation().hash().toUpperCase());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; theHash = PasswordHash.instance().createPasswordKey(String.valueOf(Arrays.hashCode(data)).toCharArray(), salt, userPasswordProperty.getAnnotation().iterations());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return theHash;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } finally {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; salt = null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; theHash = null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/code&gt;&lt;/pre&gt;Typically, you would do the following to serve the user a file:&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;import java.io.FileInputStream;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;import java.io.OutputStream;&lt;br /&gt;import java.net.FileNameMap;&lt;br /&gt;import java.net.URLConnection;&lt;br /&gt;&lt;br /&gt;import javax.annotation.PostConstruct;&lt;br /&gt;import javax.ejb.Local;&lt;br /&gt;import javax.ejb.Stateless;&lt;br /&gt;import javax.faces.context.FacesContext;&lt;br /&gt;import javax.persistence.EntityManager;&lt;br /&gt;import javax.persistence.EntityNotFoundException;&lt;br /&gt;import javax.servlet.http.HttpServletResponse;&lt;br /&gt;&lt;br /&gt;import org.jboss.seam.annotations.AutoCreate;&lt;br /&gt;import org.jboss.seam.annotations.In;&lt;br /&gt;import org.jboss.seam.annotations.Name;&lt;br /&gt;&lt;br /&gt;@Name("fileService")&lt;br /&gt;@AutoCreate&lt;br /&gt;@Stateless&lt;br /&gt;@Local(FileService.class)&lt;br /&gt;public class FileServiceImpl implements FileService {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @In&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private EntityManager entityManager;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private FileNameMap fileNameMap;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @PostConstruct&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void contruct() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fileNameMap = URLConnection.getFileNameMap();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Deprecated&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void download(File file) throws IOException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte[] data = file.getData();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Take mime type from filename, I don't know if the null check is necessary, the API doesn't say. &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String mime = fileNameMap.getContentTypeFor(file.getName());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (mime == null || "".equals(mime.trim())) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mime = "application/octet-stream";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; response.setContentType(mime);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; response.addHeader("Content-Disposition", "attachment;filename=" + file.getName());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; response.setContentLength(data.length);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OutputStream writer = response.getOutputStream();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.write(data);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.flush();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.close();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Skip the rest of JSF phases&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FacesContext.getCurrentInstance().responseComplete();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //rest of ejb not shown&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;This method of doing it is bad because it will load the file in to memory and serve it to the user. Not to mention all the Seam interceptors along the way.&lt;br /&gt;&lt;br /&gt;A much better way is to use a filter.&lt;br /&gt;All you need to do is create a link that has the &lt;i&gt;downloadFileId&lt;/i&gt; as parameter and the filter will activate, like this &lt;a href="http://somedomain.com/myApp/somePage.seam?downloadFileId=1-BAC272728189887A672"&gt;http://somedomain.com/myApp/somePage.seam?downloadFileId=1-BAC272728189887A672&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;import java.io.IOException;&lt;br /&gt;import java.io.InputStream;&lt;br /&gt;import java.io.OutputStream;&lt;br /&gt;import java.net.URLEncoder;&lt;br /&gt;&lt;br /&gt;import javax.faces.context.FacesContext;&lt;br /&gt;import javax.persistence.EntityManager;&lt;br /&gt;import javax.servlet.FilterChain;&lt;br /&gt;import javax.servlet.ServletException;&lt;br /&gt;import javax.servlet.ServletRequest;&lt;br /&gt;import javax.servlet.ServletResponse;&lt;br /&gt;import javax.servlet.http.HttpServletRequest;&lt;br /&gt;import javax.servlet.http.HttpServletResponse;&lt;br /&gt;&lt;br /&gt;import com.mydomain.model.File;&lt;br /&gt;&lt;br /&gt;import org.jboss.seam.Component;&lt;br /&gt;import org.jboss.seam.ScopeType;&lt;br /&gt;import org.jboss.seam.annotations.Name;&lt;br /&gt;import org.jboss.seam.annotations.Scope;&lt;br /&gt;import org.jboss.seam.annotations.Startup;&lt;br /&gt;import org.jboss.seam.annotations.intercept.BypassInterceptors;&lt;br /&gt;import org.jboss.seam.annotations.web.Filter;&lt;br /&gt;import org.jboss.seam.contexts.Lifecycle;&lt;br /&gt;import org.jboss.seam.web.AbstractFilter;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;&amp;nbsp;* Implemented from suggestion on &lt;br /&gt;&amp;nbsp;* {@link http://seamframework.org/Community/LargeFileDownload}&lt;br /&gt;&amp;nbsp;* @author Shervin Asgari&lt;br /&gt;&amp;nbsp;* &lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;@Name("downloadFilter")&lt;br /&gt;@Filter(around = { "org.jboss.seam.web.ajax4jsfFilter" })&lt;br /&gt;@Scope(ScopeType.APPLICATION)&lt;br /&gt;@Startup&lt;br /&gt;@BypassInterceptors&lt;br /&gt;public class DownloadFilter extends AbstractFilter {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void doFilter(ServletRequest request, ServletResponse resp, FilterChain arg2) throws IOException, ServletException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (HttpServletRequest.class.isAssignableFrom(request.getClass())) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpServletRequest req = (HttpServletRequest) request;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpServletResponse response = (HttpServletResponse) resp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String downloadFileId = req.getParameter("downloadFileId");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //The param is seperated with the id of the file and the hash eg http://localhost:8080/myapp/somePage.xhtml/?downloadFileId=1-8B94B45466C738FE90EF9CA8D47281EAE821F4E0 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //The two ifs could be one, but for debugging and breakpoints, its easier this way&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (downloadFileId != null &amp;amp;&amp;amp; downloadFileId.matches("^\\d+-.*$")) {&lt;br /&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; boolean started = false;&lt;br /&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; try {&lt;br /&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; String[] ids = downloadFileId.split("-",0);&lt;br /&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; if(ids.length &amp;gt;= 1) {&lt;br /&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; String fileId = ids[0];&lt;br /&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; String hash = ids.length &amp;gt;= 2 ? ids[1] : null;&lt;br /&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; &lt;br /&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; started = true;&lt;br /&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; Lifecycle.beginCall();&lt;br /&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; File file = null;&lt;br /&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; &lt;br /&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; EntityManager entityManager = (EntityManager) Component.getInstance("entityManager");&lt;br /&gt;&lt;br /&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; if(hash != null) {&lt;br /&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; file = (File) entityManager.createQuery("SELECT f FROM " + File.class.getName() + " f " +&lt;br /&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; "WHERE f.id=:id and f.hash=:hash").setMaxResults(1).setParameter("id", Long.valueOf(fileId)).setParameter("hash", hash).getSingleResult();&lt;br /&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; } else {&lt;br /&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; //This is here for backward compatibility&lt;br /&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; file = (File) entityManager.createQuery("SELECT f FROM " + File.class.getName() + " f " +&lt;br /&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; "WHERE f.id=:id and f IS NULL").setMaxResults(1).setParameter("id", Long.valueOf(fileId)).getSingleResult();&lt;br /&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; }&lt;br /&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; &lt;br /&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; if(file != null) {&lt;br /&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; FacesContext facesContext = FacesContext.getCurrentInstance();&lt;br /&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; InputStream stream = file.getInputStream();&lt;br /&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; response.setContentType("application/octet-stream");&lt;br /&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; response.setContentLength(stream.available());&lt;br /&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; response.setCharacterEncoding("UTF-8");&lt;br /&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; response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(file.getName(), "UTF-8"));&lt;br /&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; OutputStream out = response.getOutputStream();&lt;br /&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; try {&lt;br /&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; byte[] buf = new byte[response.getBufferSize()];&lt;br /&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; int len;&lt;br /&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; while ((len = stream.read(buf)) &amp;gt; 0) {&lt;br /&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; out.write(buf, 0, len);&lt;br /&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; }&lt;br /&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; } finally {&lt;br /&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; out.close();&lt;br /&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; }&lt;br /&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; &lt;br /&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; if(facesContext != null)&lt;br /&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; facesContext.responseComplete();&lt;br /&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; }&lt;br /&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; }&lt;br /&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; &lt;br /&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; } catch (Exception e) {&lt;br /&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; e.printStackTrace();&lt;br /&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; resp.getOutputStream().write(String.valueOf("Error downloading file" + e.getMessage()).getBytes());&lt;br /&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; }&lt;br /&gt;&lt;br /&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; finally {&lt;br /&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; if(started)&lt;br /&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; Lifecycle.endCall();&lt;br /&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; else &lt;br /&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; arg2.doFilter(req, response);&lt;br /&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; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;br /&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; arg2.doFilter(req, response);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;This way you will not load the file into memory, and avoid all the interceptors of Seam, thus it will perform much faster and better. Note that we have included a backward compatibility in case the file entity does not have a hash yet.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-7850100834756849360?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/7850100834756849360/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=7850100834756849360' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7850100834756849360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7850100834756849360'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2010/03/advanced-seam-series-part-2-of-3-seam.html' title='Advanced Seam series part 2 of 3: Seam Filters'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-114871129264870323</id><published>2010-02-13T00:33:00.003+01:00</published><updated>2010-03-26T11:05:15.302+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='interceptor'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam 2'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam Series'/><title type='text'>Advanced Seam series part 1 of 3: Seam Interceptors</title><content type='html'>&lt;span style="font-size: large;"&gt;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Seam Interceptors&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;EJB 3.0 introduced a standard interceptor model for session bean components. &lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Interceptors are a great way of performing extra functionality. I will not go into detail of what Interceptors are. If you want to know more, google is your friend.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Prerequisites you should know:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Seam has a few built in Interceptors, these include but are not limited to:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;BijectionInterceptor&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;MethodContextInterceptor&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/li&gt;&lt;li&gt;ConversationInterceptor&lt;/li&gt;&lt;li&gt;SynchronizationInterceptor&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt; ConversationalInterceptor&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;RemoveInterceptor&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;SeamInterceptor&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;SecurityInterceptor&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;TransactionInterceptor&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;EventInterceptor&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;HibernateSessionProxyInterceptor&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;@BypassInterceptors will skip Interceptors&amp;nbsp;&lt;/span&gt; &lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;In this example I will show you two examples on how you can use your own interceptor as a way to enhance your security domain and measure how long each method takes to execute. &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;First example&lt;/span&gt;&lt;br /&gt;Imagine this simple model. A user is connected to one organization, and only the user connected to that Organization is allowed to view information about that organization.&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_nbzuXQmcHXc/S3WpZkZ_f8I/AAAAAAAAAPo/xfcTDLwf7c8/s1600-h/Test.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_nbzuXQmcHXc/S3WpZkZ_f8I/AAAAAAAAAPo/xfcTDLwf7c8/s320/Test.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Let's say you print out the users organization, and you have a page with detailed information about that organization like this:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-size: small;"&gt;&amp;lt;s:link view="myOrganization.xhtml" value="#{organizationAction.choose}"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;f:param name="id" value="#{organization.id}"/&amp;gt;&lt;br /&gt;&amp;lt;/s:link&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;In the request, something like this will appear: &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;i&gt;http://mydomain.com/myOrganization.xhtml?actionMethod=myOrganization.xhtml%3organizationAction%choose()&amp;amp;organizationId=3&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;i&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;And this is how your simple OrganizationAdmin.java component looks like:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-size: small;"&gt;@Name("organizationAdmin")&lt;br /&gt;@Scope(ScopeType.CONVERSATION)&lt;br /&gt;@Restrict("#{s:hasRole('user')}&amp;amp;;quot;)&lt;br /&gt;public class OrganizationAction {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @RequestParameter&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Long id;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @In&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EntityManager entityManager;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Organization myOrganization;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Begin&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void choose() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(id != null) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.myOrganization = (Organization) entityManager.find(Organization.class, id);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Organization getMyOrganization() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return this.myOrganization;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Now, imagine changing the organizationId in the request to show information about an organization you should initially not be allowed to see.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;This is obviously very bad. We have restricted the component to role user, but another user can easily change the request to another id, and get hold of another organization.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;To fix this, you can add this extra security check:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-size: small;"&gt;@Name("organizationAdmin")&lt;br /&gt;@Scope(ScopeType.CONVERSATION)&lt;br /&gt;@Restrict("#{s:hasRole('user')}")&lt;br /&gt;public class OrganizationAction {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @RequestParameter&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Long id;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @In&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EntityManager entityManager;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Organization myOrganization;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;@In(create = true)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; User currentUser; //The current user logged in&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Begin&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void choose() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(id != null) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.myOrganization = (Organization) entityManager.find(Organization.class, id);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;if(!currentUser.getOrganization().getId().equals(myOrganization.getId()))&lt;br /&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; throw new SecurityException("You are not allowed to view this page");&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Organization getMyOrganization() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return this.myOrganization;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Voila! Now if an authorized user tries to "hack" the system, you will throw a SecurityException. This is fine and works just fine. However, it is cumbersome to do and you have to remember to do this everywhere where these exploits exists.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Wouldn't it be nice to just do this:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-size: small;"&gt;@Name("organizationAdmin")&lt;br /&gt;@Scope(ScopeType.CONVERSATION)&lt;br /&gt;@Restrict("#{s:hasRole('user')}")&lt;br /&gt;&lt;b&gt;@MySecurityAuthorized&lt;/b&gt;&lt;br /&gt;public class OrganizationAction {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @RequestParameter&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Long id;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @In&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EntityManager entityManager;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Organization myOrganization;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Begin&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void choose() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(id != null) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.myOrganization = (Organization) entityManager.find(Organization.class, id);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;@AuthorizeOrganization&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Organization getMyOrganization() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return this.myOrganization;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;I for one think this is much easier to do. You can even reuse the &lt;b&gt;@AuthorizeOrganization&lt;/b&gt; annotation to apply the same security other places. You only need to write the logic once.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Our first Interceptor&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;We can do this by using @Interceptor or @Interceptors. The latter is pre Java EE 5 compatible. I will cover both, but will show the latter in this example.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We start by creating our two annotations.&lt;br /&gt;&lt;b&gt;@AuthorizeOrganization&lt;/b&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;@Target({ElementType.METHOD})&lt;br /&gt;@Retention(RetentionPolicy.RUNTIME)&lt;br /&gt;@Documented&lt;br /&gt;public @interface AuthorizeOrganization {}&lt;/code&gt;&lt;/pre&gt;&lt;b&gt;@MySecurityAuthorized&lt;/b&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;/**&lt;br /&gt;&amp;nbsp;* This annotation can be added to any Seam component to hook in interception of our custom annotations.&lt;br /&gt;&amp;nbsp;* Important: Unless a custom specific @AuthorizeX annotation (like @AuthorizeOrganization) is also present, this annotation won't do anything &lt;br /&gt;&amp;nbsp;*&lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;@Target(ElementType.TYPE)&lt;br /&gt;@Retention(RetentionPolicy.RUNTIME)&lt;br /&gt;@Documented&lt;br /&gt;&lt;b&gt;@org.jboss.seam.annotations.intercept.Interceptors(MyInterceptor.class)&lt;/b&gt;&lt;br /&gt;public @interface MySecurityAuthorized {}&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Note the &lt;i&gt;@Interceptors(MyInterceptor&lt;/i&gt;.&lt;i&gt;class)&lt;/i&gt;. It is here we register this annotation to the Interceptor MyInterceptor&lt;span style="font-size: small;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;AnnotationHandler.java&lt;/b&gt;&lt;br /&gt;Note that this is just an interface that all our custom annotations will inherit from&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-size: small;"&gt;public interface AnnotationHandler {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void preProceed();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void postProceed(Object retObj);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public boolean isCurrentlyUsed();&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;BasicHandler&lt;/b&gt;&lt;b&gt;.java &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;An abstract class all handler will extend from. Read javadoc and comments in code to get real understanding of what's going on. Much of this code is really not necessary for this simple example. But this is a good portion of the one we are using, and it is quite flexible.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-size: small;"&gt;import java.lang.annotation.Annotation;&lt;br /&gt;import java.util.ArrayList;&lt;br /&gt;import java.util.Collection;&lt;br /&gt;import java.util.List;&lt;br /&gt;&lt;br /&gt;import javax.interceptor.InvocationContext;&lt;br /&gt;&lt;br /&gt;import org.jboss.seam.Component;&lt;br /&gt;import org.jboss.seam.core.Events;&lt;br /&gt;import org.jboss.seam.log.Logging;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;&amp;nbsp;* Class that can be extended when creating new custom managed annotations.&lt;br /&gt;&amp;nbsp;* Add extending classes to MyInterceptor.&lt;br /&gt;&amp;nbsp;*&lt;br /&gt;&amp;nbsp;* @param &amp;lt;T&amp;gt; The Annotation that should be looked for&lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;public abstract class BasicHandler&amp;lt;T extends Annotation, U&amp;gt; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private User user;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Boolean isAdmin;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private boolean isMethodAnnotated;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private List&amp;lt;U&amp;gt; allInstanceParams = new ArrayList&amp;lt;U&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private List&amp;lt;U&amp;gt; annotatedInstanceParams = new ArrayList&amp;lt;U&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private List&amp;lt;Long&amp;gt; annotatedIdParams = new ArrayList&amp;lt;Long&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Class&amp;lt;U&amp;gt; authorizedClass;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * This constructor parses the method signature for annotations,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * validated annotated types and&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * if needed verifies the current User&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param ic, the current InvocationContext&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param annotationClazz, the class of the annotation to be scanned for&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param authorizedClass, the class of the object to authorize&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @SuppressWarnings("unchecked")&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public BasicHandler(InvocationContext ic, Class&amp;lt;T&amp;gt; annotationClazz, Class&amp;lt;U&amp;gt; authorizedClass) {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.authorizedClass = authorizedClass;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //method annotation&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Annotation annotation = ic.getMethod().getAnnotation(annotationClazz);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (annotation != null) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; isMethodAnnotated = true;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //parameter annotations - why why why is there no Parameter class with methods for annotations, values, types?&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Annotation[][] aaa = ic.getMethod().getParameterAnnotations();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; aaa.length; i++) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Object obj = ic.getParameters()[i];&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (isMethodAnnotated) {&lt;br /&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; allInstanceParams.add((U) obj);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Annotation[] aa = aaa[i];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int j = 0; j &amp;lt; aa.length; j++) {&lt;br /&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; Annotation a = aa[j];&lt;br /&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; if (a.annotationType().equals(annotationClazz) &amp;amp;&amp;amp; ic.getParameters()[i] != null) {&lt;br /&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; //So we've found an annotated not null param&lt;br /&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; if (authorizedClass.isInstance(obj)) {&lt;br /&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; //instance of class to be authorized&lt;br /&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; annotatedInstanceParams.add((U) obj);&lt;br /&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; } else if (obj instanceof Long) {&lt;br /&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; //id of instance of class to be authorized&lt;br /&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; annotatedIdParams.add((Long) obj);&lt;br /&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; } else {&lt;br /&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; //Annotation put on erronous type&lt;br /&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; illegalObjectAnnotated((U) obj, annotationClazz);&lt;br /&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; }&lt;br /&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; //params.add(ic.getParameters()[i]);&lt;br /&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; }&lt;br /&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; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Verify user&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (isCurrentlyUsed()) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getUser();&lt;br /&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; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;//public methods&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public boolean isCurrentlyUsed() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (isMethodAnnotated || !annotatedInstanceParams.isEmpty() || !annotatedIdParams.isEmpty() ? true : false);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;//protected methods&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @SuppressWarnings("unchecked")&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected List&amp;lt;U&amp;gt; getAllReturnInstances(Object retObj) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;U&amp;gt; l = new ArrayList&amp;lt;U&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (isMethodAnnotated()) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (authorizedClass.isInstance(retObj)) {&lt;br /&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; //Simple object&lt;br /&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; l.add((U) retObj);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else if (retObj instanceof Collection&amp;lt;?&amp;gt;) {&lt;br /&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; //Collections&lt;br /&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; for (Object obj : (Collection&amp;lt;?&amp;gt;) retObj) {&lt;br /&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; if (authorizedClass.isInstance(obj)) {&lt;br /&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; l.add((U) obj);&lt;br /&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&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; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&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; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return l;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Authorizing Organization&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Role "admin" may access everything&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Other (like "user") must be within the organization to have privilege&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param organization&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected boolean authorize(Organization organization) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (organization != null) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return authorizeUser(organization.getId().toString());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //null object need no authorization&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;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&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; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Getting current logged in user&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * @return Getting current logged in user&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected User getUser() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (user == null) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; user = (User) Component.getInstance("currentUser", true);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (user.getId() == null || user.getId() == 0) {&lt;br /&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; //annotation is present but we don't have an user&lt;br /&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; logAndThrow("User is null, must exsist to enable authentication");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return user;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Is user admin?&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * @return&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected boolean isAdmin() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (isAdmin == null) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return isRoleInRoles(user.getRoles(), "admin");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return isAdmin;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Checks to see if the role is in the Collection&amp;lt;Role&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * If one of the roles appears in the Collection it returns true&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param allroles - All the roles&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param roles - varargs containing the roles to check for&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * @return true if any of the role is found&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private boolean isRoleInRoles(Collection&amp;lt;Role&amp;gt; allroles, String ...roles) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (allroles == null || roles == null || roles.length == 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (Role r : allroles)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(String role : roles)&lt;br /&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; if (r.getName().equals(role))&lt;br /&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; return true;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected boolean logAndThrow(String s) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Logging.getLogProvider(this.getClass()).warn(s);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new SecurityException(s);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;//private methods&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private boolean authorizeUser(String orgId) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; User user = getUser();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (isAdmin()) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Admin can do whatever&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else if (user.getOrganization().getId().equals(orgId)) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Correct organization, can also check role here if you want&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&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;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //wrong organization, fail authorization&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return logAndThrow("User '" + user.getUsername() + "' is not authorized to view this page");&lt;br /&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; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private boolean isMethodAnnotated() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return isMethodAnnotated;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private void illegalObjectAnnotated(U obj, Class&amp;lt;? extends Annotation&amp;gt; annotationClass) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logAndThrow("Program error, annotation " + annotationClass.getSimpleName() + " cannot handle object of type " + obj.getClass().getSimpleName());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;//Getters&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public List&amp;lt;U&amp;gt; getAllInstanceParams() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return allInstanceParams;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public List&amp;lt;U&amp;gt; getAnnotatedInstanceParams() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return annotatedInstanceParams;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public List&amp;lt;Long&amp;gt; getAnnotatedIdParams() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return annotatedIdParams;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;@AuthorizeOrganizationHandler.java&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-size: small;"&gt;/**&lt;br /&gt;&amp;nbsp;* This AnnotationHandler handles the @AuthorizeOrganization annotation.&lt;br /&gt;&amp;nbsp;* It authorizes a User for an Organization&lt;br /&gt;&amp;nbsp;*&lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;public class AuthorizeOrganizationHandler extends BasicHandler&amp;lt;AuthorizeOrganization, Organization&amp;gt; implements AnnotationHandler {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * This constructor looks for @AuthorizeOrganization markers on method&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * If any exists, User is validated directly.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param ic&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public AuthorizeOrganizationHandler(InvocationContext ic) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; super(ic, AuthorizeOrganization.class, Organization.class);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;//Public methods&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void preProceed() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Method level - input parameters&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (Organization obj : getAllInstanceParams()) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; authorize(obj);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void postProceed(Object retObj) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //return value(s)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (Organization obj : getAllReturnInstances(retObj)) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; authorize(obj);&lt;br /&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; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;Last but not least, our interceptor.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;MyInterceptor.java&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-size: small;"&gt;import javax.interceptor.AroundInvoke;&lt;br /&gt;import javax.interceptor.InvocationContext;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;&amp;nbsp;* This interceptor handles method/param level annotations&lt;br /&gt;&amp;nbsp;* (Seam only provides Class (ElementType.TYPE) level annotation support)&lt;br /&gt;&amp;nbsp;* Thus this interceptor must be added to those beans that wish to use these annotations&lt;br /&gt;&amp;nbsp;* If we implement new annotations, their corresponding AnnotationHandler must be registered below&lt;br /&gt;&amp;nbsp;*&lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;public class MyInterceptor {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @AroundInvoke&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Object aroundInvoke(InvocationContext ic) throws Exception {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //gather custom annotation handlers&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;AnnotationHandler&amp;gt; ahs = new ArrayList&amp;lt;AnnotationHandler&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; addHandlerIfNeeded(new AuthorizeOrganizationHandler(ic), ahs);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //add new annotation handlers here - TODO: Use more clever generics instead&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //handle pre proceed&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (AnnotationHandler ah : ahs) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ah.preProceed();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //proceed&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Object obj = ic.proceed();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //handle post proceed&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Collections.reverse(ahs); //Reversing list in order to get same behavior as interceptors/filters&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (AnnotationHandler ah : ahs) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ah.postProceed(obj);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&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; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return obj;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private void addHandlerIfNeeded(AnnotationHandler handler, List&amp;lt;AnnotationHandler&amp;gt; ahs) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (handler.isCurrentlyUsed()) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ahs.add(handler);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Thats it! Now you can easily add new annotation and handlers and just add login in BasicHandler. If you look closely you will see that we automatically give all privileges to admin, but only check user's organization if they are role user. You can modify and do whatever fits your need.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: large;"&gt;Second Example&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Finally I want to also mention the other Seam interceptor.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;This is taken directly from the Seam forum (&lt;a href="http://www.seamframework.org/Community/SeamPerformanceProblemRewardingWorkaround"&gt;Link here&lt;/a&gt;). Which will print something like this:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre class="wikiPreformatted"&gt;284.94 ms   1   FooBean.getRandomDroplets()&lt;br /&gt;284.56 ms   1   GahBean.getRandomDroplets()&lt;br /&gt;201.60 ms   2   SohBean.searchRatedDoodlesWithinHead()&lt;br /&gt;185.94 ms   1   FroBean.doSearchPopular()&lt;br /&gt;157.63 ms   1   FroBean.doSearchRecent()&lt;br /&gt; 42.34 ms   1   FooBean.fetchMostRecentYodel()&lt;br /&gt; 41.94 ms   1   GahBean.getMostRecentYodel()&lt;br /&gt; 15.89 ms   1   FooBean.getNoOfYodels()&lt;br /&gt; 15.00 ms   1   GahBean.getNoOfYodels()&lt;br /&gt;  9.14 ms   1   SohBean.mainYodels()&lt;br /&gt;  1.11 ms   2   SohBean.trackHoorayEvent()&lt;br /&gt;  0.32 ms   1   FroBean.reset()&lt;br /&gt;  0.22 ms  43   NohBean.thumbPicture()&lt;br /&gt;  0.03 ms  18   FooBean.getMostRecentYodels()&lt;br /&gt;  0.01 ms   1   NohBean.profilePicture()&lt;br /&gt;  0.01 ms   1   FroBean.setToDefault()&lt;br /&gt;  0.01 ms   1   FroBean.getRecentMarker() &lt;/pre&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;The first column contains the accumulated time spent in this method. The second column contains the number of times the method has been called, and the final column shows which method was called.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;This Interceptor will measure how long each method will take to execute in milliseconds.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;TimingInterceptor.java&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;import java.lang.reflect.Method;&lt;br /&gt;import java.util.Collection;&lt;br /&gt;import java.util.HashMap;&lt;br /&gt;import java.util.Map;&lt;br /&gt;&lt;br /&gt;import org.jboss.seam.annotations.intercept.AroundInvoke;&lt;br /&gt;import org.jboss.seam.annotations.intercept.Interceptor;&lt;br /&gt;import org.jboss.seam.core.BijectionInterceptor;&lt;br /&gt;import org.jboss.seam.core.ConversationInterceptor;&lt;br /&gt;import org.jboss.seam.core.ConversationalInterceptor;&lt;br /&gt;import org.jboss.seam.core.EventInterceptor;&lt;br /&gt;import org.jboss.seam.core.MethodContextInterceptor;&lt;br /&gt;import org.jboss.seam.core.SynchronizationInterceptor;&lt;br /&gt;import org.jboss.seam.ejb.RemoveInterceptor;&lt;br /&gt;import org.jboss.seam.ejb.SeamInterceptor;&lt;br /&gt;import org.jboss.seam.intercept.InvocationContext;&lt;br /&gt;import org.jboss.seam.persistence.HibernateSessionProxyInterceptor;&lt;br /&gt;import org.jboss.seam.security.SecurityInterceptor;&lt;br /&gt;import org.jboss.seam.transaction.TransactionInterceptor;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;&amp;nbsp;* This interceptor will calculate how long it takes to execute each method&lt;br /&gt;&amp;nbsp;* &lt;br /&gt;&amp;nbsp;* Copied and modified from @link http://www.seamframework.org/Community/SeamPerformanceProblemRewardingWorkaround&lt;br /&gt;&amp;nbsp;*&lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;@Interceptor(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; around = {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BijectionInterceptor.class,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MethodContextInterceptor.class,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConversationInterceptor.class,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SynchronizationInterceptor.class,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConversationalInterceptor.class,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RemoveInterceptor.class,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SeamInterceptor.class,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SecurityInterceptor.class,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TransactionInterceptor.class,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EventInterceptor.class,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HibernateSessionProxyInterceptor.class&lt;br /&gt;})&lt;br /&gt;public class TimingInterceptor {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public final static CallChain callChain = new CallChain();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @AroundInvoke&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Object timeCall(InvocationContext invocation) throws Exception {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; long t0 = System.nanoTime();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return invocation.proceed();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } finally {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; long dt = System.nanoTime() - t0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; callChain.addInvocation(invocation, dt);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // -----------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * A call chain is the set of invocations on methods (annotated &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * with MeasureCalls) that a request issued on its way through &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * the application stack.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static class CallChain extends ThreadLocal&amp;lt;Map&amp;lt;Method, TimedInvocation&amp;gt;&amp;gt; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected Map&amp;lt;Method, TimedInvocation&amp;gt; initialValue() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new HashMap&amp;lt;Method, TimedInvocation&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void addInvocation(InvocationContext invocation, long dt) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map&amp;lt;Method, TimedInvocation&amp;gt; invocations = get();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Method method = invocation.getMethod();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!invocations.containsKey(method)) {&lt;br /&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; invocations.put(method, new TimedInvocation(invocation.getMethod(), dt));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;br /&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; TimedInvocation timedInvocation = invocations.get(method);&lt;br /&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; timedInvocation.anotherCall(dt);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int totalNumberOfInvocations() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map&amp;lt;Method, TimedInvocation&amp;gt; invocations = get();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Collection&amp;lt;TimedInvocation&amp;gt; timedInvocationCollection = invocations.values();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int totCalls = 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (TimedInvocation invocation : timedInvocationCollection)&lt;br /&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; totCalls += invocation.getCalls();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return totCalls;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;TimedInvocation.java&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;import java.lang.reflect.Method;&lt;br /&gt;&lt;br /&gt;import org.apache.commons.lang.StringUtils;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;&amp;nbsp;* TimedInvocation is an invocation (i.e. a method call) which is being&lt;br /&gt;&amp;nbsp;* counted and timed. &lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;public class TimedInvocation implements Comparable&amp;lt;TimedInvocation&amp;gt; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private long dt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private int calls = 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Method method;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public TimedInvocation(Method method, long dt) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.method = method;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.dt = dt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public long getDt() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return dt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Method getMethod() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return method;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * The first column contains the accumulated time spent in this method. &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * The second column contains the number of times the method has been called.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * The third column contains the method which was called&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public String toString() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String className = method.getDeclaringClass().getName();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String shortendName = className.substring(method.getDeclaringClass().getPackage().getName().length() + 1);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String duration = StringUtils.leftPad(Double.valueOf(dt / 1e6) + " ms", 11);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String nCallStr = StringUtils.leftPad(String.valueOf(calls), 4);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return duration + nCallStr + "&amp;nbsp;&amp;nbsp; " + shortendName + "." + method.getName() + "()";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void anotherCall(long dt) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.dt += dt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; calls++;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int compareTo(TimedInvocation o) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return -Long.valueOf(dt).compareTo(o.dt);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int getCalls() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return calls;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt; &lt;/b&gt;Lastly, we will create a simple filter that will print out the result. The filter is only installed in debug mode so that it doesn't run on production. Be aware that the interceptor will still run if you don't forget to uncomment the interceptor.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;TimingFilter.java&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;/**&lt;br /&gt;&amp;nbsp;* This filter is used in conjunction with the TimingInterceptor. * &lt;br /&gt;&amp;nbsp;* It is defaulted to only work in debug mode (debug = true)&lt;br /&gt;&amp;nbsp;* To use this filter you need to set value to true&lt;br /&gt;&amp;nbsp;* &lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;@Startup&lt;br /&gt;@Scope(ScopeType.APPLICATION)&lt;br /&gt;@Name("timingFilter")&lt;br /&gt;@BypassInterceptors&lt;br /&gt;@Filter&lt;br /&gt;@Install(debug = true)&lt;br /&gt;public class TimingFilter extends AbstractFilter {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private static final LogProvider log = Logging.getLogProvider(TimingFilter.class);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!(req instanceof HttpServletRequest)) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; chain.doFilter(req, res);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TimingInterceptor.callChain.remove();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; chain.doFilter(req, res);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map&amp;lt;Method, TimedInvocation&amp;gt; invocations = TimingInterceptor.callChain.get();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(TimedInvocation timedInvocation : invocations.values()) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; log.debug(timedInvocation.toString());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Finally create an annotation where you register the interceptor.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;code&gt; &lt;/code&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;@MeasureCalls&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;/**&lt;br /&gt;&amp;nbsp;* This is an annotation that is used with the Interceptor TimingInterceptor,&lt;br /&gt;&amp;nbsp;* that will measure time it takes to execute each method in a seam component.&lt;br /&gt;&amp;nbsp;* &lt;br /&gt;&amp;nbsp;* The filter that uses this interceptor only works in debug mode and you will need to set value to true &lt;br /&gt;&amp;nbsp;* on the TimingFilter. Otherwize you will not see anything when running this in production or test. &lt;br /&gt;&amp;nbsp;* However, the interceptor will still run, so be "careful" where you put this annotation.&lt;br /&gt;&amp;nbsp;* &lt;br /&gt;&amp;nbsp;* Usage: &lt;br /&gt;&amp;nbsp;* @AutoCreate&lt;br /&gt;&amp;nbsp;* @Name("theBeanILikeToInvestigate")&lt;br /&gt;&amp;nbsp;* @MeasureCalls&lt;br /&gt;&amp;nbsp;* public class TheBeanILikeToInvestigare&lt;br /&gt;&amp;nbsp;* &lt;br /&gt;&amp;nbsp;*&lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;@Target(ElementType.TYPE)&lt;br /&gt;@Retention(RetentionPolicy.RUNTIME)&lt;br /&gt;@Interceptors(TimingInterceptor.class)&lt;br /&gt;public @interface MeasureCalls {}&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;span style="font-size: small;"&gt;Just put @MeasureCalls on your component and all methods on that component will be invoked on.&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-114871129264870323?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/114871129264870323/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=114871129264870323' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/114871129264870323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/114871129264870323'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2010/02/advanced-seam-series-part-1-of-3-seam.html' title='Advanced Seam series part 1 of 3: Seam Interceptors'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_nbzuXQmcHXc/S3WpZkZ_f8I/AAAAAAAAAPo/xfcTDLwf7c8/s72-c/Test.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-8978255522925775533</id><published>2010-02-09T15:47:00.000+01:00</published><updated>2010-02-09T15:47:30.556+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Seam'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam Series'/><title type='text'>Advanced Seam series</title><content type='html'>In the upcoming weeks I will be posting some nice articles about some of the advanced features of Seam I know people have trouble understanding and incorporating.&amp;nbsp; &lt;br /&gt;&lt;br /&gt;The articles will be a "three" (may be more) part series where I will cover the topics Interceptors, Filters and Asynchronous events.&lt;br /&gt;&lt;br /&gt;I will show working real life examples of all three. You will learned:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;What Interceptors are, and how you can use them and incorporate security techniques using interceptors.&lt;/li&gt;&lt;li&gt;Filters - Why they are useful to use.&amp;nbsp;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;I will show how you can implement a filter that enables downloading of files without consumption of unnecessary memory.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Asynchronous - I will show how you can send a mail asynchronously&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;If there are any advanced areas you wish to know more about, let me know by writing in the comment section and I will consider adding them to the series.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-8978255522925775533?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/8978255522925775533/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=8978255522925775533' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/8978255522925775533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/8978255522925775533'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2010/02/advanced-seam-series.html' title='Advanced Seam series'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-5270522281848199594</id><published>2010-01-25T19:46:00.000+01:00</published><updated>2010-01-25T19:46:01.427+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='testng'/><title type='text'>"Too many open files error" when running TestNG in Eclipse</title><content type='html'>I frequently get this exception when trying to run a test from TestNG in  Eclipse. &lt;br /&gt;&lt;br /&gt;Open a terminal and write ulimit -n and you will most probably get 1024. &lt;br /&gt;(ulimit -a) for everything. (I am running Ubuntu 9.10)&lt;br /&gt;&lt;br /&gt;This means you can have max 1024 open files.&lt;br /&gt;&lt;br /&gt;To fix this check this page out and follow the instructions. &lt;br /&gt;&lt;a class="moz-txt-link-freetext" href="http://knol.google.com/k/fred-grott/open-file-limits-settings-on-ubuntu/166jfml0mowlh/3#"&gt;http://knol.google.com/k/fred-grott/open-file-limits-settings-on-ubuntu/166jfml0mowlh/3#&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-5270522281848199594?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/5270522281848199594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=5270522281848199594' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5270522281848199594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5270522281848199594'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2010/01/too-many-open-files-error-when-running.html' title='&quot;Too many open files error&quot; when running TestNG in Eclipse'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-238986047410134549</id><published>2010-01-25T19:41:00.000+01:00</published><updated>2010-01-25T19:41:19.108+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jboss 4'/><category scheme='http://www.blogger.com/atom/ns#' term='java 5'/><category scheme='http://www.blogger.com/atom/ns#' term='jboss-ws'/><category scheme='http://www.blogger.com/atom/ns#' term='java 6'/><title type='text'>setProperty must be overridden by all subclasses of SOAPMessage</title><content type='html'>Have you gotten this error message? Then you probably either upgraded from Java 5 to Java 6 in JBoss application, or you just tried to run your webservice client for the first time.&lt;br /&gt;&lt;br /&gt;The reason your Webservice client call suddenly fails is because of a bug in JBoss WS with JBoss 4.x&lt;br /&gt;&lt;br /&gt;I haven't tested this on JBoss 5, so I cannot for sure exclude this bug in JBoss 5. However, the bug seem to be fixed in jbossws-2.0.&lt;br /&gt;&lt;br /&gt;The solution to this problem is to &lt;br /&gt;&lt;pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"&gt;&lt;code&gt;Copy the three jars from &amp;lt;JBOSS_HOME&amp;gt;\server\default\lib to &amp;lt;JBOSS_HOME&amp;gt;\lib\endorsed.&lt;br /&gt;&lt;br /&gt;jboss-jaxrpc.jar&lt;br /&gt;jboss-jaxws.jar&lt;br /&gt;jboss-saaj.jar &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;More information can be found &lt;a href="https://jira.jboss.org/jira/browse/JBWS-1439?focusedCommentId=12460326#action_12460326"&gt;here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-238986047410134549?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/238986047410134549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=238986047410134549' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/238986047410134549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/238986047410134549'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2010/01/setproperty-must-be-overridden-by-all.html' title='setProperty must be overridden by all subclasses of SOAPMessage'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-644270567645030519</id><published>2009-11-25T11:28:00.001+01:00</published><updated>2009-12-10T13:31:43.730+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Seam 2'/><title type='text'>s:convertDateTime</title><content type='html'>In the Seam documentation there is very little information about this tag.&lt;br /&gt;In the documentation, there is only one example:&lt;br /&gt;&lt;pre class="XHTML" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" xmlns=""&gt;&amp;lt;h:outputText&amp;nbsp;value="#{item.orderDate}"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;s:convertDateTime&amp;nbsp;type="both"&amp;nbsp;dateStyle="full"/&amp;gt;&lt;br /&gt;h:outputText&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This doesn't really say much. However, after some googling, I can explain some of the attributes, and what is actually useful to use.&lt;br /&gt;If you want to show both date and time: dd-MM-yyyy hh:mm:ss you can use type="both" and dateStyle="full". If you want to show only date. Use type="date".&lt;br /&gt;&lt;br /&gt;You choose from a range of different dateStyle.&lt;br /&gt;&lt;i&gt;default&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; May 14, 2007 2:35:45 PM ( Default Value)&lt;br /&gt;short&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; 5/14/07 12:55:42 PM&lt;br /&gt;medium&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; May 14, 2007 2:42:36 PM&lt;br /&gt;long&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; May 14, 2007 2:41:08 PM&lt;br /&gt;full&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; Monday, May 14, 2007 2:39:56 PM&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;However what I have found the most useful is just to use the pattern attribute together with the type.&lt;br /&gt;So if you want the style 14.07.2009 you just write&lt;br /&gt;&lt;br /&gt;&lt;pre class="XHTML" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" xmlns=""&gt;&amp;lt;h:outputText&amp;nbsp;value="#{item.orderDate}"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;s:convertDateTime&amp;nbsp;type="both" pattern="dd-MM-yyyy"/&amp;gt;&lt;br /&gt;h:outputText&amp;gt;&lt;/pre&gt;&lt;pre class="XHTML" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" xmlns=""&gt;And you are set to go! &lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-644270567645030519?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/644270567645030519/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=644270567645030519' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/644270567645030519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/644270567645030519'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/11/in-seam-documentation-there-is-very.html' title='s:convertDateTime'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-5027114392612951036</id><published>2009-11-23T20:50:00.000+01:00</published><updated>2009-11-23T20:50:58.059+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='axis2'/><title type='text'>Axis 2 gotcha</title><content type='html'>Just wanted to give a quick GOTCHA I discovered with Axis 2. The other day I wanted to install and use &lt;a href="http://www.projectlombok.org/"&gt;lombok&lt;/a&gt; (which is &lt;b&gt;AWESOME&lt;/b&gt; by the way).&lt;br /&gt;&lt;br /&gt;However lombok needs Java 6 to run, and my WebService was compiled with Java 5, so I changed to Java 6, recompiled, but obviously forgot to recompile the WebService client stubs.&lt;br /&gt;&amp;nbsp;I didn't get any exception that remotely told me that I had a class version issue. However, I got this exception:&lt;br /&gt;&lt;pre&gt;com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog&lt;/pre&gt;After reverting back to Java 5, everything worked just fine. So just a heads up.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-5027114392612951036?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/5027114392612951036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=5027114392612951036' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5027114392612951036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5027114392612951036'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/11/axis-2-gotcha.html' title='Axis 2 gotcha'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-3796372138141235955</id><published>2009-11-20T22:53:00.013+01:00</published><updated>2009-11-20T23:49:30.967+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Seam'/><category scheme='http://www.blogger.com/atom/ns#' term='Devoxx'/><title type='text'>Seam / Infinispan meetup in Devoxx</title><content type='html'>So I just returned from the Seam / Infinispan meetup here in Devoxx and there where a few GOTCHA that I will come back to.&lt;br /&gt;&lt;br /&gt;Firstly, the meeting it self was pretty awesome.  Although I feel that the Seam discussion wasn't that coordinated as the Infinispan talk. There were too much focus on &lt;a href="http://seamframework.org/Weld"&gt;Weld&lt;/a&gt;, but I guess thats not surprising since Weld was just recently released, and most Seam developers except poor Norman Richards, where working on Weld to get it finished before the deadline.&lt;br /&gt;Don't take my words literally, Norman might have done some work towards Weld for all I know, but he was at least the only one working on Seam 2.&lt;br /&gt;&lt;br /&gt;Anyways, the ones from the Seam team who where present (forgive me if I forget someone) where: Pete Muir, Dan Allen, Norman Richards, Shane Bryzak and Christian Bauer.&lt;br /&gt;Dan held a quick intro on Seam, for the 3 people who didn't know what Seam was, and then Pete talked a bunch about Weld, and finally Dan closed with showing a very cool testing framework which I cannot remember the name of now which will be implemented for Seam 3, and also Rest on Seam. Of course with a lot of Q&amp;amp;A in between.&lt;br /&gt;&lt;br /&gt;So finally I got a chance to speak with Dan, Norman and Pete. I really wanted to have a chat with Shane as well, but unfortunaltly by the time I went to get a beer and come back he was gone. :-(&lt;br /&gt;First I got a chance to ask Dan about the strange behaviour I found regarding injection of a stateless EJB in Seam, discussed &lt;a href="http://seamframework.org/Community/StatelessDefaultScopeType"&gt;here&lt;/a&gt; , and he confirmed what I suspected all along, that it was infact a bug in Seam. Now, I he didn't actually say "That is a bug" per say, but he did say "If that doesn't work, it is a bug in Seam". But from my experience I can safely conclude that this is a bug in Seam.&lt;br /&gt;Before you say "Hey, why don't you file a JIRA on it", I will tell you why I will not.&lt;br /&gt;After talking with Pete, I discovered that infact there WILL BE NO MORE releases of Seam. Meaning, even if there are any bugs, or even if someone in the community upload a patch, or even some core devel0per fix the bug in the Seam 2.2 branch, there will be no official release of it. You can however checkout a version of that fix and build binaries for your self.&lt;br /&gt;I know, pretty lame and to be honest a big surprise from my part. But Pete did explain why, and the reason is that before shipping an official release, it has to go to the QA team for testing, and probably some other branches and this takes up rescources that JBoss doesn't want to commit to. Instead they want to focus on the development and shipping Seam 3, which is planned to come around march 2010.&lt;br /&gt;So you must ask your self "What about us who are using Seam 2.x and really need to fix this and that issue? Is all hope gone, other than fixing it our selves and running a build?" The answer is no. If you REALLY want something, basically all you have to do, is buy a support deal from JBoss or a certified JBoss partner (as we are), and ask them to fix it. JBoss will then put resources into fixing that and actually commiting the fix in the branch so that it is available for everyone to checkout and build, however, they still will not release a version of that fix. You have to build it your self.&lt;br /&gt;&lt;br /&gt;Lastly, this blog post deserves to be mentioning what Seam 3 will look like. Though this is not official or final, it is what I know has been discussed and agreed upon.&lt;br /&gt;Seam 3 will be what is missing from the Java EE 6 stack. Everything thats sort of extra that didn't get into the spec. It will obviously contain all the pdf, rss, excel goodies we are familiar to from Seam 2, including JBPM 4 and Drools 5 support. Not to forget all the goodies that comes with Java EE 6, Bean validation, Servlet 3.0, EJB 3.1, JPA 2 and so on. It will also be modular based, meaning, that if you only need certain parts of Seam, then it is no need to get anything else which is irrelevant to you. There is probably more that I have forgotten, but Pete will blog about this pretty soon.&lt;br /&gt;Lastly, I want to mention that I did try to encourage the people to participate on the seam forums, and help people that are struggling with their Seam 2.x apps. Because face it; those people are most likely to move to Seam 3 and Weld, and if you want them to do that, you should try to make the learning curve of Seam 2.x as little as possible.&lt;br /&gt;Pete did agree, however he did say that the reason why he couldn't reallly encourage the core developers to use more time on the forums is because of all the time they spent on getting Weld finished. 14 hour(!) days jikes. But hopefully in the future, they will have more time to help the users out there.&lt;br /&gt;&lt;br /&gt;Good night from Devoxx.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-3796372138141235955?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/3796372138141235955/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=3796372138141235955' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3796372138141235955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3796372138141235955'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/11/seam-infinispan-meetup-in-devoxx.html' title='Seam / Infinispan meetup in Devoxx'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-1901701738661227841</id><published>2009-10-08T11:27:00.004+02:00</published><updated>2009-10-08T11:33:31.428+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IE8'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam'/><title type='text'>IE8 bug in Seam 2</title><content type='html'>There seem to be a problem with IE8 and Seam applications. We are running Seam 2.1, JSF 1.2 and Facelets, and I cannot say for sure where the bug is. For all I know its a bug with IE8.&lt;br /&gt;&lt;br /&gt;There seem to be problems when creating long-running conversations. In link using IE8 the cid doesnt appear. Somehow it is stripped or doesn't render correctly, and it causes some strange behaviour.&lt;br /&gt;When trying to create a long running conversation by pushing an edit link for instance, we get a "Your session has timeout" exception.&lt;br /&gt;&lt;br /&gt;We fixed this IE8 problem by telling Internet Explorer to emulate IE7 in pages.xml&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;code&gt;&amp;lt;page view-id="*"&amp;gt;&lt;br /&gt;       &amp;lt;header name="X-UA-Compatible"&amp;gt;IE=EmulateIE7&amp;lt;/header&amp;gt;&lt;br /&gt;&amp;lt;/page&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;I suggest you do the same until the bug is identified and fixed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-1901701738661227841?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/1901701738661227841/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=1901701738661227841' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/1901701738661227841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/1901701738661227841'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/10/ie8-bug-in-seam-2.html' title='IE8 bug in Seam 2'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-653955872297340364</id><published>2009-08-20T16:10:00.004+02:00</published><updated>2009-08-20T17:48:28.565+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Enum'/><category scheme='http://www.blogger.com/atom/ns#' term='JPA'/><title type='text'>Using Enum in your entity beans</title><content type='html'>It is quite handy to use an Enum, especially with type String. This means that the enum will be translated as a text field in your database.&lt;br /&gt;&lt;br /&gt;Imagine the following Entity Simple.java:&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;@Entity&lt;br /&gt;public class Simple {&lt;br /&gt;  Process process;&lt;br /&gt; &lt;br /&gt;  @Enumerated(EnumType.STRING)&lt;br /&gt;  public void Process getProcess() {&lt;br /&gt;      return process;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;And Process.java:&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;public enum Process {&lt;br /&gt;  WHAT,&lt;br /&gt;  THE,&lt;br /&gt;  BUCK&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now, I initally thought, that since you are defining the enum type to be string, then you can simply query the database using string as well like this:&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;entityManager.createQuery(&amp;quot;from Simple s where s.process=:process&amp;quot;).setParameter(&amp;quot;process&amp;quot;,&amp;quot;WHAT&amp;quot;).getResultList();&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;However this doesn't work. You will need to use an Enum type. So the solution is to use Enum.valueOf()&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;entityManager.createQuery(&amp;quot;from Simple s where s.process=:process&amp;quot;).setParameter(&amp;quot;process&amp;quot;,Process.valueOf(&amp;quot;WHAT&amp;quot;)).getResultList();&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Now the query will run and return your list :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-653955872297340364?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/653955872297340364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=653955872297340364' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/653955872297340364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/653955872297340364'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/08/using-enum-in-your-entity-beans.html' title='Using Enum in your entity beans'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-5351279721992897971</id><published>2009-08-04T15:20:00.004+02:00</published><updated>2009-08-05T14:41:05.125+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='testng'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam 2.1.1'/><category scheme='http://www.blogger.com/atom/ns#' term='wicket'/><category scheme='http://www.blogger.com/atom/ns#' term='ant'/><title type='text'>Wicket error in Seam test</title><content type='html'>&lt;span style="font-weight: bold;font-size:130%;" &gt;The Problem&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Recently we upgrade to Seam  2.1.x and suddenly our testng test using ant failed with the following message: &lt;pre&gt;No wicket components directory specified to give Seam super powers to&lt;/pre&gt;Wicket was added to Seam 2.1.0.BETA1.&lt;br /&gt;This error message doesn't really say anything. Also it said further:&lt;br /&gt;&lt;pre&gt;Must set application-class using &lt;wicket:web-application&gt; in components.xml &lt;/wicket:web-application&gt;&lt;/pre&gt;&lt;br /&gt;But we where not using wicket and didnt want to add it.&lt;br /&gt;&lt;br /&gt;The stacktrace was as following:&lt;br /&gt;&lt;pre&gt;&lt;pre class="wikiPreformatted"&gt;WARN  [org.jboss.seam.wicket.web.WicketFilterInstantiator] No wicket components directory specified to give Seam super powers to&lt;br /&gt; [testng] FAILED: getDefaultContacts&lt;br /&gt; [testng] java.lang.IllegalStateException: Must set application-class using &lt;wicket:web-application&gt; in components.xml&lt;br /&gt; [testng]  at org.jboss.seam.wicket.web.WicketFilterInstantiator$1.init(WicketFilterInstantiator.java:107)&lt;br /&gt; [testng]  at org.jboss.seam.web.WicketFilter.doFilter(WicketFilter.java:124)&lt;br /&gt; [testng]  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)&lt;br /&gt; [testng]  at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)&lt;br /&gt; [testng]  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)&lt;br /&gt; [testng]  at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)&lt;br /&gt; [testng]  at org.jboss.seam.mock.AbstractSeamTest$Request.run(AbstractSeamTest.java:491)&lt;br /&gt; [testng]  at no.whatever.test.AddressBookTest.getDefaultContacts(AddressBookTest.java:18)&lt;br /&gt; [testng] ... Removed 22 stack frames&lt;br /&gt; [testng] FAILED: setup&lt;br /&gt;&lt;/wicket:web-application&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;&lt;br /&gt;The Solution&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It seems like ant will just put all the libraries in the lib folder in the classpath, and eclipse obviously would not. Thus, when the wicket jars where removed, the tests where back online. I believe it is sufficient to remove  jboss-seam-wicket.jar and jboss-seam-wicket-ant.jar, however I just removed all jars that included the name wicket.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-5351279721992897971?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/5351279721992897971/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=5351279721992897971' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5351279721992897971'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5351279721992897971'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/08/wicket-error-in-seam-test.html' title='Wicket error in Seam test'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-2505355758462028099</id><published>2009-07-14T16:33:00.003+02:00</published><updated>2009-07-14T16:39:05.961+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Seam'/><title type='text'>Injecting checking of roles in Seam</title><content type='html'>It is well known that you can perform &lt;pre&gt;#{s:hasRole('admin')}&lt;/pre&gt;on the view.&lt;br /&gt;You can easily check for the role of the logged in user, by injecting the same thing.&lt;pre&gt;&lt;br /&gt;@In(value = "#{s:hasRole('admin')}")&lt;br /&gt;private boolean isAdmin;&lt;br /&gt;&lt;/pre&gt;If the user has a role of admin the boolean is set to true. You can also use the static method, &lt;pre&gt;Identity.instance().checkRole("admin");&lt;/pre&gt;&lt;br /&gt;But the former is nicer right?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-2505355758462028099?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/2505355758462028099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=2505355758462028099' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/2505355758462028099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/2505355758462028099'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/07/injecting-checking-of-roles-in-seam.html' title='Injecting checking of roles in Seam'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-5621068043094395138</id><published>2009-06-28T20:24:00.004+02:00</published><updated>2009-06-28T20:36:54.896+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Seam'/><category scheme='http://www.blogger.com/atom/ns#' term='hash password'/><title type='text'>Iteration on password is added in JBoss Seam 2.1.2</title><content type='html'>&lt;div style="text-align: left;"&gt;I blogged about how you could hash your password using Seam 2.1.1 &lt;a href="http://shervinasgari.blogspot.com/2009/02/hash-user-password-in-seam-211-manually.html"&gt;hash-user-password-in-seam-211-manually&lt;/a&gt;.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In the latest production release of JBoss Seam 2.1.2 and the @UserPassword annotation, an attribute of iteration is now added with a default of 1000.&lt;br /&gt;&lt;br /&gt;We should then modify our GeneratePasswordHash method to the following:&lt;br /&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;code&gt;/**&lt;br /&gt;        * This method will generate a hash password&lt;br /&gt;        *&lt;br /&gt;        * @param password&lt;br /&gt;        *            - The password in cleartext&lt;br /&gt;        * @param salt&lt;br /&gt;        *            - The username is used as salt&lt;br /&gt;        * @return - hash password based on password and username&lt;br /&gt;        */&lt;br /&gt;       public static String generatePasswordHash(String password, String salt) throws GeneralSecurityException {&lt;br /&gt;               char[] passToChar;&lt;br /&gt;               byte[] saltToByte;&lt;br /&gt;               String thePassword;&lt;br /&gt;               try {&lt;br /&gt;                       passToChar = password.toCharArray();&lt;br /&gt;                       saltToByte = salt.getBytes();&lt;br /&gt;                       AnnotatedBeanProperty&amp;lt;UserPassword&amp;gt; userPasswordProperty = new AnnotatedBeanProperty&amp;lt;UserPassword&amp;gt;(ProcessUser.class, UserPassword.class);&lt;br /&gt;                       // Will get the hash value from annotation UserPassword in ProcessUser.class&lt;br /&gt;                       PasswordHash.instance().setHashAlgorithm(userPasswordProperty.getAnnotation().hash().toUpperCase());&lt;br /&gt;                       thePassword = PasswordHash.instance().createPasswordKey(passToChar, saltToByte, userPasswordProperty.getAnnotation().iterations());&lt;br /&gt;                       return thePassword;&lt;br /&gt;               } finally {&lt;br /&gt;                       // Ensure that the password is not in memory&lt;br /&gt;                       password = null;&lt;br /&gt;                       passToChar = null;&lt;br /&gt;                       salt = null;&lt;br /&gt;                       saltToByte = null;&lt;br /&gt;                       thePassword = null;&lt;br /&gt;               }&lt;br /&gt;       }&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-5621068043094395138?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/5621068043094395138/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=5621068043094395138' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5621068043094395138'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5621068043094395138'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/06/iteration-on-password-is-added-in-jboss.html' title='Iteration on password is added in JBoss Seam 2.1.2'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-6132637891957275406</id><published>2009-06-17T09:33:00.002+02:00</published><updated>2009-06-17T10:01:34.506+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Seam book'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam 2.1.1'/><title type='text'>Review of Seam 2.x Web Development</title><content type='html'>So I have read the Seam 2.x Web Development&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Build Robust Web Applications with Seam, Facelets, and RichFaces, using the JBoss Application Server&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This book tries to cover a very very large aspect of Seam and friends.&lt;br /&gt;The book has 11 chapters and almost 300 pages. If you are new Seam, this is a great kick start. Because the book covers a huge portion of the most important aspects of Seam, plus some advanced topics such as Remoting, however I feel that the chapters are too small and that they don't give a thourough and in depth explanation. Many of the examples can be found by googling a bit and reading the documentation of Seam, but this is why it is so good to have a book covering a very large portion of it.&lt;br /&gt;&lt;br /&gt;The RichFaces chapter could have been improved alot. Around 30 pages is hardly enough to cover this very big framework. I believe you will get more out of downloading the live examples and looking at the source code and playing around with it instead.&lt;br /&gt;&lt;br /&gt;So to sum up, this book is good for someone new to Seam, that want an overview of most of what Seam has to offer, however I would supplement with Seam in Action to cover more ground.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-6132637891957275406?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/6132637891957275406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=6132637891957275406' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/6132637891957275406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/6132637891957275406'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/06/review-of-seam-2x-web-development.html' title='Review of Seam 2.x Web Development'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-3104792554711149537</id><published>2009-05-20T13:59:00.002+02:00</published><updated>2009-05-20T14:05:10.270+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Seam'/><title type='text'>New Seam book "Seam 2.x Web Development"</title><content type='html'>I have been asked to review the new book &lt;span style="color:#000000;"&gt;Seam 2.x Web Development from &lt;a href="http://packtpub.com"&gt;Packt Publishing&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can buy the book &lt;a href="http://www.packtpub.com/seam-2-x-web-development/book"&gt;here&lt;/a&gt;&lt;br /&gt;and there is also a free chapter "Developing Seam Applications" in PDF here: &lt;a href="http://www.packtpub.com/files/seam-2-x-web-development-sample-chapter-2-developing-seam-applications.pdf"&gt;http://www.packtpub.com/files/seam-2-x-web-development-sample-chapter-2-developing-seam-applications.pdf&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I am quite curious as to how this book is compared to Seam in Action by Dan Allen, and I will post my review here as soon as I have read the book.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-3104792554711149537?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/3104792554711149537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=3104792554711149537' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3104792554711149537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3104792554711149537'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/05/new-seam-book-seam-2x-web-development.html' title='New Seam book &quot;Seam 2.x Web Development&quot;'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-8062356068101538547</id><published>2009-04-26T12:03:00.004+02:00</published><updated>2009-04-26T12:08:11.702+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaOne'/><title type='text'>My JavaOne 2009 schedule</title><content type='html'>I am attending JavaOne 2009 this year, and very much looking forward to it. Only one month ahead now.&lt;br /&gt;This is the schedule I have chosen:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nbzuXQmcHXc/SfQxsrc7n9I/AAAAAAAAAGU/2CBZkKHOKHU/s1600-h/javaone_schedule.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 236px;" src="http://4.bp.blogspot.com/_nbzuXQmcHXc/SfQxsrc7n9I/AAAAAAAAAGU/2CBZkKHOKHU/s400/javaone_schedule.png" alt="" id="BLOGGER_PHOTO_ID_5328938902734217170" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Unfortunately, many tracks go simultaneously, but I did put the tracks that I also am interested in, in "My interest"&lt;br /&gt;&lt;br /&gt;&lt;table style="width: 1024px;"&gt;&lt;tbody&gt;&lt;tr width="100%" align="left" bgcolor="#838f9f"&gt;&lt;td colspan="5" style="font-size: 8pt; font-weight: bold; color: rgb(255, 255, 255);"&gt; Tuesday, Jun 02&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" id="ri32763" bgcolor="#e8e8e8"&gt; &lt;td style="width: 80px;"&gt;10:50-11:50&lt;/td&gt;&lt;td style="width: 180px;" align="center"&gt;Esplanade 307-310, Moscone&lt;/td&gt;&lt;td style="width: 20px;"&gt; &lt;img style="width: 18px; height: 18px;" src="https://www35.cplan.com/sb230/images/delete_from_schedule.gif" onclick="removeInterest('32763')" alt="Remove From Interests" align="center" /&gt;&lt;/td&gt;&lt;td style="width: 550px; font-weight: bold;" align="left"&gt;&lt;a href="https://www35.cplan.com/sb230/myCalendar.jsp#" onclick="getSessionAbstract2('304645', '32763','a   ','int')"&gt; Ajaxifying Existing Web Applications&lt;/a&gt;&lt;/td&gt;&lt;td style="width: 120px;"&gt;Seats Available&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" id="ri33304" bgcolor="#ffffff"&gt; &lt;td style="width: 80px;"&gt;16:40-17:40&lt;/td&gt;&lt;td style="width: 180px;" align="center"&gt;Hall E 134, Moscone&lt;/td&gt;&lt;td style="width: 20px;"&gt; &lt;img style="width: 18px; height: 18px;" src="https://www35.cplan.com/sb230/images/delete_from_schedule.gif" onclick="removeInterest('33304')" alt="Remove From Interests" align="center" /&gt;&lt;/td&gt;&lt;td style="width: 550px; font-weight: bold;" align="left"&gt;&lt;a href="https://www35.cplan.com/sb230/myCalendar.jsp#" onclick="getSessionAbstract2('305225', '33304','a   ','int')"&gt; Spring Framework 3.0: New and Notable&lt;/a&gt;&lt;/td&gt;&lt;td style="width: 120px;"&gt;Seats Available&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" id="ri33148" bgcolor="#e8e8e8"&gt; &lt;td style="width: 80px;"&gt;18:00-19:00&lt;/td&gt;&lt;td style="width: 180px;" align="center"&gt;Esplanade 304-306, Moscone&lt;/td&gt;&lt;td style="width: 20px;"&gt; &lt;img style="width: 18px; height: 18px;" src="https://www35.cplan.com/sb230/images/delete_from_schedule.gif" onclick="removeInterest('33148')" alt="Remove From Interests" align="center" /&gt;&lt;/td&gt;&lt;td style="width: 550px; font-weight: bold;" align="left"&gt;&lt;a href="https://www35.cplan.com/sb230/myCalendar.jsp#" onclick="getSessionAbstract2('304213', '33148','a   ','int')"&gt; Securing Web and Service-Oriented Architectures with Apache Axis, WSS4J, Spring, and OpenLDAP&lt;/a&gt;&lt;/td&gt;&lt;td style="width: 120px;"&gt;Seats Available&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" align="left" bgcolor="#838f9f"&gt;&lt;td colspan="5" style="font-size: 8pt; font-weight: bold; color: rgb(255, 255, 255);"&gt; Wednesday, Jun 03&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" id="ri32771" bgcolor="#ffffff"&gt; &lt;td style="width: 80px;"&gt;09:45-10:45&lt;/td&gt;&lt;td style="width: 180px;" align="center"&gt;Esplanade 307-310, Moscone&lt;/td&gt;&lt;td style="width: 20px;"&gt; &lt;img style="width: 18px; height: 18px;" src="https://www35.cplan.com/sb230/images/delete_from_schedule.gif" onclick="removeInterest('32771')" alt="Remove From Interests" align="center" /&gt;&lt;/td&gt;&lt;td style="width: 550px; font-weight: bold;" align="left"&gt;&lt;a href="https://www35.cplan.com/sb230/myCalendar.jsp#" onclick="getSessionAbstract2('305330', '32771','a   ','int')"&gt; Extreme Google Web Toolkit: Exploring Advanced Aspects of GWT&lt;/a&gt;&lt;/td&gt;&lt;td style="width: 120px;"&gt;Seats Available&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" id="ri33437" bgcolor="#e8e8e8"&gt; &lt;td style="width: 80px;"&gt;09:45-10:45&lt;/td&gt;&lt;td style="width: 180px;" align="center"&gt;Gateway 102-103, Moscone&lt;/td&gt;&lt;td style="width: 20px;"&gt; &lt;img style="width: 18px; height: 18px;" src="https://www35.cplan.com/sb230/images/delete_from_schedule.gif" onclick="removeInterest('33437')" alt="Remove From Interests" align="center" /&gt;&lt;/td&gt;&lt;td style="width: 550px; font-weight: bold;" align="left"&gt;&lt;a href="https://www35.cplan.com/sb230/myCalendar.jsp#" onclick="getSessionAbstract2('305359', '33437','a   ','int')"&gt; The Modular Java? Platform and Project Jigsaw&lt;/a&gt;&lt;/td&gt;&lt;td style="width: 120px;"&gt;Seats Available&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" id="ri33308" bgcolor="#ffffff"&gt; &lt;td style="width: 80px;"&gt;09:45-10:45&lt;/td&gt;&lt;td style="width: 180px;" align="center"&gt;Hall E 134, Moscone&lt;/td&gt;&lt;td style="width: 20px;"&gt; &lt;img style="width: 18px; height: 18px;" src="https://www35.cplan.com/sb230/images/delete_from_schedule.gif" onclick="removeInterest('33308')" alt="Remove From Interests" align="center" /&gt;&lt;/td&gt;&lt;td style="width: 550px; font-weight: bold;" align="left"&gt;&lt;a href="https://www35.cplan.com/sb230/myCalendar.jsp#" onclick="getSessionAbstract2('304966', '33308','a   ','int')"&gt; Upgrading OSGi&lt;/a&gt;&lt;/td&gt;&lt;td style="width: 120px;"&gt;Seats Available&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" id="ri33153" bgcolor="#e8e8e8"&gt; &lt;td style="width: 80px;"&gt;11:05-12:05&lt;/td&gt;&lt;td style="width: 180px;" align="center"&gt;Esplanade 304-306, Moscone&lt;/td&gt;&lt;td style="width: 20px;"&gt; &lt;img style="width: 18px; height: 18px;" src="https://www35.cplan.com/sb230/images/delete_from_schedule.gif" onclick="removeInterest('33153')" alt="Remove From Interests" align="center" /&gt;&lt;/td&gt;&lt;td style="width: 550px; font-weight: bold;" align="left"&gt;&lt;a href="https://www35.cplan.com/sb230/myCalendar.jsp#" onclick="getSessionAbstract2('304775', '33153','a   ','int')"&gt; RESTful Transaction Systems&lt;/a&gt;&lt;/td&gt;&lt;td style="width: 120px;"&gt;Seats Available&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" id="ri33309" bgcolor="#ffffff"&gt; &lt;td style="width: 80px;"&gt;11:05-12:05&lt;/td&gt;&lt;td style="width: 180px;" align="center"&gt;Hall E 134, Moscone&lt;/td&gt;&lt;td style="width: 20px;"&gt; &lt;img style="width: 18px; height: 18px;" src="https://www35.cplan.com/sb230/images/delete_from_schedule.gif" onclick="removeInterest('33309')" alt="Remove From Interests" align="center" /&gt;&lt;/td&gt;&lt;td style="width: 550px; font-weight: bold;" align="left"&gt;&lt;a href="https://www35.cplan.com/sb230/myCalendar.jsp#" onclick="getSessionAbstract2('304875', '33309','a   ','int')"&gt; Developing RESTful Web Services with the Java? API for RESTful Web Services (JAX-RS)&lt;/a&gt;&lt;/td&gt;&lt;td style="width: 120px;"&gt;Seats Available&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" id="ri33438" bgcolor="#e8e8e8"&gt; &lt;td style="width: 80px;"&gt;11:05-12:05&lt;/td&gt;&lt;td style="width: 180px;" align="center"&gt;Gateway 102-103, Moscone&lt;/td&gt;&lt;td style="width: 20px;"&gt; &lt;img style="width: 18px; height: 18px;" src="https://www35.cplan.com/sb230/images/delete_from_schedule.gif" onclick="removeInterest('33438')" alt="Remove From Interests" align="center" /&gt;&lt;/td&gt;&lt;td style="width: 550px; font-weight: bold;" align="left"&gt;&lt;a href="https://www35.cplan.com/sb230/myCalendar.jsp#" onclick="getSessionAbstract2('304954', '33438','a   ','int')"&gt; Modularity in the Java? Programming Language: JSR 294 and Beyond&lt;/a&gt;&lt;/td&gt;&lt;td style="width: 120px;"&gt;Seats Available&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" id="ri32772" bgcolor="#ffffff"&gt; &lt;td style="width: 80px;"&gt;11:05-12:05&lt;/td&gt;&lt;td style="width: 180px;" align="center"&gt;Esplanade 307-310, Moscone&lt;/td&gt;&lt;td style="width: 20px;"&gt; &lt;img style="width: 18px; height: 18px;" src="https://www35.cplan.com/sb230/images/delete_from_schedule.gif" onclick="removeInterest('32772')" alt="Remove From Interests" align="center" /&gt;&lt;/td&gt;&lt;td style="width: 550px; font-weight: bold;" align="left"&gt;&lt;a href="https://www35.cplan.com/sb230/myCalendar.jsp#" onclick="getSessionAbstract2('305400', '32772','a   ','int')"&gt; Ajax Performance Tuning and Best Practice&lt;/a&gt;&lt;/td&gt;&lt;td style="width: 120px;"&gt;Seats Available&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" id="ri33033" bgcolor="#e8e8e8"&gt; &lt;td style="width: 80px;"&gt;13:30-14:30&lt;/td&gt;&lt;td style="width: 180px;" align="center"&gt;Esplanade 307-310, Moscone&lt;/td&gt;&lt;td style="width: 20px;"&gt; &lt;img style="width: 18px; height: 18px;" src="https://www35.cplan.com/sb230/images/delete_from_schedule.gif" onclick="removeInterest('33033')" alt="Remove From Interests" align="center" /&gt;&lt;/td&gt;&lt;td style="width: 550px; font-weight: bold;" align="left"&gt;&lt;a href="https://www35.cplan.com/sb230/myCalendar.jsp#" onclick="getSessionAbstract2('305588', '33033','a   ','int')"&gt; Creating Compelling User Experiences &lt;/a&gt;&lt;/td&gt;&lt;td style="width: 120px;"&gt;Seats Available&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" id="ri33439" bgcolor="#ffffff"&gt; &lt;td style="width: 80px;"&gt;13:30-14:30&lt;/td&gt;&lt;td style="width: 180px;" align="center"&gt;Gateway 102-103, Moscone&lt;/td&gt;&lt;td style="width: 20px;"&gt; &lt;img style="width: 18px; height: 18px;" src="https://www35.cplan.com/sb230/images/delete_from_schedule.gif" onclick="removeInterest('33439')" alt="Remove From Interests" align="center" /&gt;&lt;/td&gt;&lt;td style="width: 550px; font-weight: bold;" align="left"&gt;&lt;a href="https://www35.cplan.com/sb230/myCalendar.jsp#" onclick="getSessionAbstract2('305217', '33439','a   ','int')"&gt; "Effective Java": Still Effective After All These Years&lt;/a&gt;&lt;/td&gt;&lt;td style="width: 120px;"&gt;Seats Available&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" align="left" bgcolor="#838f9f"&gt;&lt;td colspan="5" style="font-size: 8pt; font-weight: bold; color: rgb(255, 255, 255);"&gt; Thursday, Jun 04&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" id="ri33419" bgcolor="#e8e8e8"&gt; &lt;td style="width: 80px;"&gt;14:50-15:50&lt;/td&gt;&lt;td style="width: 180px;" align="center"&gt;Esplanade 305, Moscone&lt;/td&gt;&lt;td style="width: 20px;"&gt; &lt;img style="width: 18px; height: 18px;" src="https://www35.cplan.com/sb230/images/delete_from_schedule.gif" onclick="removeInterest('33419')" alt="Remove From Interests" align="center" /&gt;&lt;/td&gt;&lt;td style="width: 550px; font-weight: bold;" align="left"&gt;&lt;a href="https://www35.cplan.com/sb230/myCalendar.jsp#" onclick="getSessionAbstract2('304945', '33419','a   ','int')"&gt; FIRST (For Inspiration &amp;amp; Recognition of Science and Technology): FRC-FIRST Robotic Competition &lt;/a&gt;&lt;/td&gt;&lt;td style="width: 120px;"&gt;Seats Available&lt;/td&gt;&lt;/tr&gt;&lt;tr width="100%" id="ri33338" bgcolor="#ffffff"&gt; &lt;td style="width: 80px;"&gt;16:10-17:10&lt;/td&gt;&lt;td style="width: 180px;" align="center"&gt;Hall E 134, Moscone&lt;/td&gt;&lt;td style="width: 20px;"&gt; &lt;img style="width: 18px; height: 18px;" src="https://www35.cplan.com/sb230/images/delete_from_schedule.gif" onclick="removeInterest('33338')" alt="Remove From Interests" align="center" /&gt;&lt;/td&gt;&lt;td style="width: 550px; font-weight: bold;" align="left"&gt;&lt;a href="https://www35.cplan.com/sb230/myCalendar.jsp#" onclick="getSessionAbstract2('303977', '33338','a   ','int')"&gt; Keeping a Relational Perspective for Optimizing the Java? Persistence API (JPA)&lt;/a&gt;&lt;/td&gt;&lt;td style="width: 120px;"&gt;Seats Available&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;I will see you there!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-8062356068101538547?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/8062356068101538547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=8062356068101538547' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/8062356068101538547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/8062356068101538547'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/04/my-javaone-2009-schedule.html' title='My JavaOne 2009 schedule'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_nbzuXQmcHXc/SfQxsrc7n9I/AAAAAAAAAGU/2CBZkKHOKHU/s72-c/javaone_schedule.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-2685903715496592880</id><published>2009-04-06T14:29:00.003+02:00</published><updated>2009-04-06T14:33:03.033+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Seam 2.1.1'/><category scheme='http://www.blogger.com/atom/ns#' term='EJB3'/><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='JPA'/><title type='text'>All unique annotations we are using in our Java EE 5 (Seam 2.1.1 GA and EJB 3 / Hibernate 3) project</title><content type='html'>Here is all the unique annoations we are using in our project (Seam 2.1.1, Hibernate, JPA, EJB 3 annotations) with a short explanation on each of them.&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;@AroundInvoke -- To add an interceptor to a bean, you need to write a class with a method annotated @AroundInvoke and annotate the bean with an @Interceptors annotation that specifies the name of the interceptor class.&lt;br /&gt;@Asynchronous -- Specifies that the method call is processed asynchronously.&lt;br /&gt;@AutoCreate -- Specifies that a component will be automatically created, even if the client does not specify create=true. &lt;br /&gt;@Basic(LAZY) -- Tells the entitymanager to lazily fetch the column. This is not needed since that is the default.&lt;br /&gt;@Begin(flushMode = FlushModeType.MANUAL) -- Begins a long running conversation and sets flushmode to manual. Doesnt execute operation until flush() is called.&lt;br /&gt;@Begin(join = true) -- Specifies that if a long-running conversation is already in progress, the conversation context is simply propagated.&lt;br /&gt;@BypassInterceptors -- disable interceptors for the component. Features such as bijection, annotated security restrictions, synchronization and others are unavailable for components marked as @ByPassInterceptors.&lt;br /&gt;@CaptchaResponse(message=&amp;quot;#{messages['verificationError']}&amp;quot;) -- Tells what kind of message the response of the captcha should be&lt;br /&gt;@CollectionOfElements --hibernate annotation that is used in conjunction with Embeddables.&lt;br /&gt;@Column(length=16777215, nullable=false) -- sets an entity column to 16kb in length and not null&lt;br /&gt;@Column(unique = true) -- Sets this column to be unique&lt;br /&gt;@Create -- Specifies that the method should be called when an instance of the component is instantiated by Seam. Note that create methods are only supported for JavaBeans and stateful session beans.&lt;br /&gt;@DataModel -- Exposes an attribute of type java.util.List to the JSF page as an instance of javax.faces.model.DataModel. This allows us to use the list in a JSF &amp;lt;h:dataTable&amp;gt; with clickable links for each row.&lt;br /&gt;@DataModelSelection -- Annotation that tells Seam to inject the List element that corresponded to the clicked button&lt;br /&gt;@Deprecated -- Marks the method or class as deprecated&lt;br /&gt;@Documented -- Used in conjuction with creating annotations. Will make the annotation available in JavaDoc&lt;br /&gt;@Duration -- Specifies that a parameter of the asynchronous call is the duration before the call is processed (or first processed for recurring calls).&lt;br /&gt;@Email -- Hibernate validator for emails&lt;br /&gt;@Embeddable -- Marks a class as Embeddable &lt;br /&gt;@Embedded -- Classes that are Embeddable will be Embedded in the other class that uses them. IE, Address is embeddable, and is @Embedded in Person &lt;br /&gt;@End -- Specifies that a long-running conversation ends when this method returns a non-null outcome without exception.&lt;br /&gt;@Entity -- Marks a class as an Entity&lt;br /&gt;@Expiration -- Specifies that a parameter of the asynchronous call is the datetime at which the call is processed (or first processed for recurring calls).&lt;br /&gt;@Factory(value=&amp;quot;officerAdminContact&amp;quot;, scope=ScopeType.EVENT) -- Creates a factory with the name officerAdminContact with a scope of Event.&lt;br /&gt;@Filter(name=&amp;quot;orgFilter&amp;quot;,condition = &amp;quot;organization_id = :orgid&amp;quot;) -- Marks a class as hibernate filter with the name orgFilter, and sets the condition of the filter&lt;br /&gt;@FilterDef(name=&amp;quot;orgFilter&amp;quot;, parameters = { @ParamDef(type=&amp;quot;long&amp;quot;, name=&amp;quot;orgid&amp;quot;)}) -- Hibernate annotation that defines a filter. The name defines which filter should be defined, and sets what kind of parameters the filter has.&lt;br /&gt;@GeneratedValue -- Sets a id to be generated automatically&lt;br /&gt;@Id -- Sets an attribute as Id for the entity&lt;br /&gt;@In(create = true) -- Injects the field and if it is null, it will create the field&lt;br /&gt;@In(required = false) -- Injects the field and tells seam that this field can be null, and will not be created if it is null&lt;br /&gt;@In(required=false, scope=ScopeType.APPLICATION) -- Injects a field and sets the scope to be Application wide&lt;br /&gt;@In(scope = ScopeType.BUSINESS_PROCESS) -- Injects a field and sets the scope to be BUSINESS_PROCESS&lt;br /&gt;@In(value = &amp;quot;#{s:hasRole('sysadmin')}&amp;quot;) -- Injects a field with an EL expression that returns true or false. In this example true if the user has role of sysadmin. &lt;br /&gt;@In(value = &amp;quot;org.jboss.seam.bpm.jbpm&amp;quot;) -- Injects a seam component that bootstraps a JBPM SessionFactory&lt;br /&gt;@Inherited -- Indicates that an annotation type is automatically inherited. Used in conjunction with creating annotations.(?)&lt;br /&gt;@Install(precedence = Install.APPLICATION) -- The @Install annotation lets you control conditional installation of components that are required in some deployment scenarios and not in others. This is useful if: *You want to mock out some infrastructural component in tests. *You want change the  implementation of a component in certain deployment scenarios. *You want to install some components only if their dependencies are available (useful for framework authors). APPLICATION is the default precedence. This is appropriate for most application components.&lt;br /&gt;@JoinTable(name = &amp;quot;ProcessUserRoles&amp;quot;, joinColumns = @JoinColumn(name = &amp;quot;userId&amp;quot;), inverseJoinColumns = @JoinColumn(name = &amp;quot;roleId&amp;quot;)) - Tells which table and what column should be joined in a table.&lt;br /&gt;@Lob -- Persistence annotation that specifies that the attribute should be a large object.&lt;br /&gt;@Local(ArchivingConnector.class) -- Tells the ejb which interface is the Local. An EJB can use local client view only if it is really guaranteed that other enterprise beans or clients will only address the bean within a single JVM. If this is the case, such access will be carried out with direct method calls, instead of RMI.&lt;br /&gt;@Logger -- Seam's Log4J.&lt;br /&gt;@ManyToOne(fetch = FetchType.LAZY, optional = true) -- Defines which filed is ManyToOne relation, with default fetch size as LAZY and that the field is optional (can be null)&lt;br /&gt;@Name(&amp;quot;lostPasswordAction&amp;quot;) -- Creates a seam component with the name &amp;quot;lostPasswordAction&amp;quot;&lt;br /&gt;@NamedQuery(name = &amp;quot;applicationprocess.find&amp;quot;, query = &amp;quot;select ap from ApplicationProcess ap join ap.organization o where ap.name = :processName and o.name = :orgName&amp;quot;) -- Creates a named query with the name &amp;quot;applicationprocess.find&amp;quot; which will execute the specified query. This means that you can call the query like this: entityManager.createNamedQuery(&amp;quot;applicationprocess.find&amp;quot;).getResultList();&lt;br /&gt;@Namespace(value=&amp;quot;http://kommuneforlaget.no/products/saksapp/process&amp;quot;) -- Specifies the configuration namespace of a Java package containing Seam components.&lt;br /&gt;@NotEmpty -- NotEmpty checks for not null and empty&lt;br /&gt;@Observer(&amp;quot;org.jboss.seam.security.loginSuccessful&amp;quot;) -- An observer listens to the following event. In this example it will listen to successfully logins&lt;br /&gt;@Officer -- Custom annotation that defines a class or a method as restricted with the role of Officer&lt;br /&gt;@OneToOne(cascade = CascadeType.ALL) -- One to one relation with all cascading&lt;br /&gt;@Orgadmin  -- Custom annotation that defines a class or a method as restricted with the role of Orgadmin&lt;br /&gt;@Out(required = false) -- Outjects the variable in the seam scope event and tell that the object can be null. Similar as request.setAttribute(&amp;quot;bestRestaurant&amp;quot;, restaurant);&lt;br /&gt;@Out(scope = ScopeType.EVENT, required = false) -- Same as above, because the default scope in Seam is EVENT.&lt;br /&gt;@Out(scope=ScopeType.SESSION, required=false) -- Same as above only the scope is set to SESSION&lt;br /&gt;@Override -- Marks a method as Override. This tells the compiler that this method should override a parent method inherited.&lt;br /&gt;@Parent -- A hibernate annotation that reference the property as a pointer back to the owner (generally the owning entity)&lt;br /&gt;@Pattern(regex=&amp;quot;\\D*-\\D+&amp;quot;) -- Hibernate validator that checks the value with a regex pattern&lt;br /&gt;@PermissionCheck(&amp;quot;upgrade&amp;quot;) --  Override the default permission action name (which is the lower case version of the annotation name) with another value. Used in conjuction with custom annotations.&lt;br /&gt;@PostConstruct -- javax.annotation.PostConstruct. Used on a method that needs to be executed after dependency injection is done to perform any initialization. Only one method can be annotated with this annotation. The method MUST NOT have any parameters except in the case of EJB interceptors in which case it takes an InvocationC ontext object as defined by the EJB specification. The return type of the method MUST be void. The method MUST NOT throw a checked exception. The method on which PostConstruct is applied MAY be public, protected, package private or private. The method MUST NOT be static except for the application client. If the method throws an unchecked exception the class MUST NOT be put into service except in the case of EJBs where the EJB can handle exceptions and even recover from them. &lt;br /&gt;@PrePersist -- JPA annotation that will be called right before a persist is done. Similar annotations are: PostPersist, PreUpdate, PostUpdate, PreRemove, PostRemove and PostLoad.&lt;br /&gt;@RaiseEvent(&amp;quot;templateHandler.pdf&amp;quot;) - If a method is annotated with @RaiseEvent, it will raise an event with the name &amp;quot;templateHandler.pdf&amp;quot; after the method is finished. &lt;br /&gt;@RequestParameter -- Specifies that a component attribute is to be injected with the value of a request parameter. Basic type conversions are performed automatically.&lt;br /&gt;@Restrict(&amp;quot;#{s:hasRole('orgadmin') or s:hasRole('sysadmin')}&amp;quot;) -- Tells seam that the class can only be used if the role is orgadmin or sysadmin&lt;br /&gt;@Retention(RUNTIME) -- Indicates how long annotations with the annotated type are to be retained. If no Retention annotation is present on an annotation type declaration, the retention policy defaults to RetentionPolicy.CLASS.&lt;br /&gt;@Role(name=&amp;quot;asyncReminderAction&amp;quot;, scope=ScopeType.EVENT) -- Allows a Seam component to be bound to multiple contexts variables. The @Name/@Scope annotations define a &amp;quot;default role&amp;quot;. Each @Role annotation defines an additional role. * Name &amp;#8212; the context variable name. * scope &amp;#8212; the context variable  scope. When no scope is explicitly specified, the default depends upon the component type.&lt;br /&gt;@RoleCheck -- Meta-annotation that designates an annotation as being a role, requiring a security check prior to invoking the annotated method or class.&lt;br /&gt;@RoleName -- Flags an entity field or method as representing the name of a role&lt;br /&gt;@Scope(ScopeType.CONVERSATION) -- Sets the scope to be CONVERSATION&lt;br /&gt;@Scope(ScopeType.EVENT) -- Sets the scope to be EVENT (default)&lt;br /&gt;@Scope(ScopeType.SESSION) -- Sets the scope to be SESSION&lt;br /&gt;@Startup -- Specifies that an instance of this component is created at system initialization time for an application scoped component, or when a session is started for a session scoped component. May only be applied to APPLICATION or SESSION scoped components.&lt;br /&gt;@Stateless -- Component-defining annotation for a stateless session bean. &lt;br /&gt;@SuppressWarnings(&amp;quot;unchecked&amp;quot;) -- Tells the compiler to suppress warnings of type unchecked. Normally from entityManager.createQuery().getResultList()&lt;br /&gt;@Sysadmin -- Custom annotation that defines a class or a method as restricted with the role of Sysadmin&lt;br /&gt;@Target({TYPE, METHOD}) -- Indicates the kinds of program element to which an annotation type is applicable.&lt;br /&gt;@Temporal(TemporalType.TIMESTAMP) --JPA annotation for date attributes. This will set the timestamp on a variable automatically&lt;br /&gt;@Test(dependsOnMethods = &amp;quot;setup&amp;quot;) -- TestNG annotation that defines this test to be dependant on a test called setup, and cant be run until that test is finished.&lt;br /&gt;@Transactional -- Specifies that a JavaBean component should have a similar transactional behavior to the default behavior of a session bean component. ie. method invocations should take place in a transaction, and if no transaction exists when the method is called, a transaction will be started just for that method.&lt;br /&gt;@Transient -- Defines this field to be transient. It will not be stored or serialized.&lt;br /&gt;@UniqueConstraint(columnNames = &amp;quot;{name,organization}&amp;quot;) -- JPA annotation that in this case defines that the attributes name and organization together should be unique.&lt;br /&gt;@UserFirstName -- Flags an entity field or method as representing the first name of a user&lt;br /&gt;@UserLastName -- Flags an entity field or method as representing the last name of a user&lt;br /&gt;@UserPassword(hash = &amp;quot;md5&amp;quot;) --Flags an entity field or method as representing the password for a user. The hash method that is used is md5 here. However sha is more secure, and &amp;quot;none&amp;quot; is also a valid option, which will not hash anything.&lt;br /&gt;@UserPrincipal --Flags an entity field or method as representing the principal (username) for a user&lt;br /&gt;@UserRoles --Flags an entity field or method as representing the list of role memberships for a user&lt;br /&gt;@Valid -- Hibernate validator that enables recursive validation of an associated object. If used on an field, it will check all the fields validators, ie @Valid Address address = new Address(); will check all the validators of class Adress.&lt;br /&gt;@Validator --Allows a Seam component to act as a JSF validator. The annotated class must be a Seam component, and must implement javax.faces.validator.Validator.&lt;br /&gt;@Version --JPA annotation that specifies the version field or property of an entity class that serves as its optimistic lock value. The version is used to ensure integrity when performing the merge operation and for optimistic concurrency control. Only a single Version property or field should be used per class; applications that use more than one Version property or field will not be portable. The Version property should be mapped to the primary table for the entity class; applications that map the Version property to a table other than the primary table will not be portable. &lt;br /&gt;@WebParam(name=&amp;quot;data&amp;quot;) --Used with WebServices and is used to customize the mapping of a single parameter to a message part or element.&lt;br /&gt;@WebService -- The purpose of this annotation is to mark an endpoint implementation as implementing a web service or to mark that a service endpoint interface as defining a web service interface. All endpoint implementation classes MUST have a WebService annotation and must meet the requirements of section 3.3 of the JAX-WS 2.0 specification.&lt;br /&gt;@XmlRootElement --Maps a class or an enum type to an XML element. When a top level class or an enum type is annotated with the @XmlRootElement annotation, then its value is represented as XML element in an XML document. &lt;br /&gt;     //Example: Code fragment&lt;br /&gt;     @XmlRootElement&lt;br /&gt;     class Point {&lt;br /&gt;        int x;&lt;br /&gt;        int y;&lt;br /&gt;        Point(int _x,int _y) {x=_x;y=_y;}&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     //Example: Code fragment corresponding to XML output&lt;br /&gt;     marshal( new Point(3,5), System.out);&lt;br /&gt; &lt;br /&gt;     &amp;lt;!-- Example: XML output --&amp;gt;&lt;br /&gt;     &amp;lt;point&amp;gt;&lt;br /&gt;       &amp;lt;x&amp;gt;3&amp;lt;/x&amp;gt;&lt;br /&gt;       &amp;lt;y&amp;gt;5&amp;lt;/y&amp;gt;&lt;br /&gt;     &amp;lt;/point&amp;gt;&lt;br /&gt; &lt;br /&gt;@XmlSeeAlso -- Instructs JAXB to also bind other classes when binding this class.&lt;br /&gt;Java makes it impractical/impossible to list all sub-classes of a given class. This often gets in a way of JAXB users, as it JAXB cannot automatically list up the classes that need to be known to JAXBContext.&lt;br /&gt;For example, with the following class definitions:&lt;br /&gt;&lt;br /&gt; class Animal {}&lt;br /&gt; class Dog extends Animal {}&lt;br /&gt; class Cat extends Animal {}&lt;br /&gt; &lt;br /&gt;The user would be required to create JAXBContext as JAXBContext.newInstance(Dog.class,Cat.class) (Animal will be automatically picked up since Dog and Cat refers to it.)&lt;br /&gt;XmlSeeAlso annotation would allow you to write:&lt;br /&gt; @XmlSeeAlso({Dog.class,Cat.class})&lt;br /&gt; class Animal {}&lt;br /&gt; class Dog extends Animal {}&lt;br /&gt; class Cat extends Animal {}&lt;br /&gt;&lt;br /&gt;This would allow you to do JAXBContext.newInstance(Animal.class). By the help of this annotation, JAXB implementations will be able to correctly bind Dog and Cat.&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-2685903715496592880?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/2685903715496592880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=2685903715496592880' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/2685903715496592880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/2685903715496592880'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/04/all-unique-annotations-we-are-using-in.html' title='All unique annotations we are using in our Java EE 5 (Seam 2.1.1 GA and EJB 3 / Hibernate 3) project'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-747158423848968688</id><published>2009-03-30T22:30:00.008+02:00</published><updated>2009-04-06T14:33:49.831+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='treecache'/><category scheme='http://www.blogger.com/atom/ns#' term='html cache'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam 2.1.1'/><category scheme='http://www.blogger.com/atom/ns#' term='s:cache'/><title type='text'>Adding html cache on a JSF 1.2 / Seam 2.1.1 application</title><content type='html'>Adding  cache in seam is very easy, and the 2.1.1 release has even made using caching easier.&lt;br /&gt;&lt;br /&gt;It is useful to cache html typically when you have lots of hits to the database, otherwise you shouldn't use html cache.&lt;br /&gt;&lt;br /&gt;I recently needed to read the current url, extract a part of the url, and check the database for a hit on that pattern. This was done on every request and is something that suits caching. The data I was retrieving was something that was changed very rarely thus it could also be cached infinetly. For this purpose, I have chosen the in-built treecache that ships with JBoss and Seam. &lt;br /&gt;&lt;br /&gt;Getting the url from a JSF page can be done like this:&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;       &lt;br /&gt;HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();&lt;br /&gt;String uri = request.getRequestURI();&lt;br /&gt;// zero so that trailing empty strings will be discarded&lt;br /&gt;String[] values = uri.split(&amp;quot;/&amp;quot;, 0);&lt;br /&gt;//Concatinate the string and create a query based on the concatinated string&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;Now in the xhtml page you will have to write:&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&amp;lt;s:cache region=&amp;quot;instructionPageFragments&amp;quot; key=&amp;quot;instruction-#{instructionHandler.instructionUrl}&amp;quot;&amp;gt;&lt;br /&gt;#{instructionHandler.getInstruction()}&lt;br /&gt;&amp;lt;/s:cache&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;Note that the key must be something unique. In this example the key value will get the current url as a key, and in our web application this is unique, thus works excellent as a key. The s:cache will use the key to retrieve the value from its HashMap.&lt;br /&gt;s:cache uses pojoCache internally, but we want to configure it to use treecache and that is done in components.xml.&lt;br /&gt;You do this by defining the namespace &lt;pre&gt;xmlns:cache="http://jboss.com/products/seam/cache"&lt;/pre&gt; and then &lt;pre class="source-code"&gt;&lt;code&gt;&amp;lt;cache:jboss-cache-provider configuration=&amp;quot;META-INF/treecache.xml&amp;quot;&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;Furthermore, we have defined a region on the s:cache called instructionPageFragments. This can be configured in treecache.xml where we can define timeToLive maxAgeSeconds and so on.&lt;br /&gt;&lt;br /&gt;&lt;pre class="source-code"&gt;&lt;code&gt;&amp;lt;region name=&amp;quot;/instructionPageFragments&amp;quot; policyClass=&amp;quot;org.jboss.cache.eviction.LRUPolicy&amp;quot;&amp;gt;&lt;br /&gt;  &amp;lt;attribute name=&amp;quot;maxNodes&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;  &amp;lt;attribute name=&amp;quot;timeToLiveSeconds&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;  &amp;lt;attribute name=&amp;quot;maxAgeSeconds&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;&amp;lt;/region&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;A copy of our entire treecache.xml is here:&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- ===================================================================== --&amp;gt;&lt;br /&gt;&amp;lt;!--                                                                       --&amp;gt;&lt;br /&gt;&amp;lt;!--  Sample TreeCache Service Configuration                               --&amp;gt;&lt;br /&gt;&amp;lt;!--                                                                       --&amp;gt;&lt;br /&gt;&amp;lt;!-- ===================================================================== --&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;server&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;classpath codebase=&amp;quot;../lib&amp;quot; archives=&amp;quot;jboss-cache.jar, jgroups.jar&amp;quot;/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;!-- ==================================================================== --&amp;gt;&lt;br /&gt;    &amp;lt;!-- Defines TreeCache configuration                                      --&amp;gt;&lt;br /&gt;    &amp;lt;!-- ==================================================================== --&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;mbean code=&amp;quot;org.jboss.cache.TreeCache&amp;quot;&lt;br /&gt;        name=&amp;quot;jboss.cache:service=TreeCache&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;depends&amp;gt;jboss:service=Naming&amp;lt;/depends&amp;gt;&lt;br /&gt;        &amp;lt;depends&amp;gt;jboss:service=TransactionManager&amp;lt;/depends&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;!--&lt;br /&gt;        Configure the TransactionManager&lt;br /&gt;    --&amp;gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;TransactionManagerLookupClass&amp;quot;&amp;gt;org.jboss.cache.JBossTransactionManagerLookup&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;!--&lt;br /&gt;            Isolation level : SERIALIZABLE&lt;br /&gt;                              REPEATABLE_READ (default)&lt;br /&gt;                              READ_COMMITTED&lt;br /&gt;                              READ_UNCOMMITTED&lt;br /&gt;                              NONE&lt;br /&gt;        --&amp;gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;IsolationLevel&amp;quot;&amp;gt;REPEATABLE_READ&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;!--&lt;br /&gt;             Valid modes are LOCAL&lt;br /&gt;                             REPL_ASYNC&lt;br /&gt;                             REPL_SYNC&lt;br /&gt;                             INVALIDATION_ASYNC&lt;br /&gt;                             INVALIDATION_SYNC&lt;br /&gt;        --&amp;gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;CacheMode&amp;quot;&amp;gt;LOCAL&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;!--&lt;br /&gt;        Just used for async repl: use a replication queue&lt;br /&gt;        --&amp;gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;UseReplQueue&amp;quot;&amp;gt;false&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;!--&lt;br /&gt;            Replication interval for replication queue (in ms)&lt;br /&gt;        --&amp;gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;ReplQueueInterval&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;!--&lt;br /&gt;            Max number of elements which trigger replication&lt;br /&gt;        --&amp;gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;ReplQueueMaxElements&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;!-- Name of cluster. Needs to be the same for all clusters, in order&lt;br /&gt;             to find each other&lt;br /&gt;        --&amp;gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;ClusterName&amp;quot;&amp;gt;TreeCache-Cluster&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;!-- JGroups protocol stack properties. Can also be a URL,&lt;br /&gt;             e.g. file:/home/bela/default.xml&lt;br /&gt;           &amp;lt;attribute name=&amp;quot;ClusterProperties&amp;quot;&amp;gt;&amp;lt;/attribute&amp;gt;&lt;br /&gt;        --&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;ClusterConfig&amp;quot;&amp;gt;&lt;br /&gt;            &amp;lt;config&amp;gt;&lt;br /&gt;                &amp;lt;!-- UDP: if you have a multihomed machine,&lt;br /&gt;                set the bind_addr attribute to the appropriate NIC IP address --&amp;gt;&lt;br /&gt;                &amp;lt;!-- UDP: On Windows machines, because of the media sense feature&lt;br /&gt;                 being broken with multicast (even after disabling media sense)&lt;br /&gt;                 set the loopback attribute to true --&amp;gt;&lt;br /&gt;                &amp;lt;UDP mcast_addr=&amp;quot;228.1.2.3&amp;quot; mcast_port=&amp;quot;48866&amp;quot;&lt;br /&gt;                    ip_ttl=&amp;quot;64&amp;quot; ip_mcast=&amp;quot;true&amp;quot; &lt;br /&gt;                    mcast_send_buf_size=&amp;quot;150000&amp;quot; mcast_recv_buf_size=&amp;quot;80000&amp;quot;&lt;br /&gt;                    ucast_send_buf_size=&amp;quot;150000&amp;quot; ucast_recv_buf_size=&amp;quot;80000&amp;quot;&lt;br /&gt;                    loopback=&amp;quot;false&amp;quot;/&amp;gt;&lt;br /&gt;                &amp;lt;PING timeout=&amp;quot;2000&amp;quot; num_initial_members=&amp;quot;3&amp;quot;&lt;br /&gt;                    up_thread=&amp;quot;false&amp;quot; down_thread=&amp;quot;false&amp;quot;/&amp;gt;&lt;br /&gt;                &amp;lt;MERGE2 min_interval=&amp;quot;10000&amp;quot; max_interval=&amp;quot;20000&amp;quot;/&amp;gt;&lt;br /&gt;                &amp;lt;!--        &amp;lt;FD shun=&amp;quot;true&amp;quot; up_thread=&amp;quot;true&amp;quot; down_thread=&amp;quot;true&amp;quot; /&amp;gt;--&amp;gt;&lt;br /&gt;                &amp;lt;FD_SOCK/&amp;gt;&lt;br /&gt;                &amp;lt;VERIFY_SUSPECT timeout=&amp;quot;1500&amp;quot;&lt;br /&gt;                    up_thread=&amp;quot;false&amp;quot; down_thread=&amp;quot;false&amp;quot;/&amp;gt;&lt;br /&gt;                &amp;lt;pbcast.NAKACK gc_lag=&amp;quot;50&amp;quot; retransmit_timeout=&amp;quot;600,1200,2400,4800&amp;quot;&lt;br /&gt;                    max_xmit_size=&amp;quot;8192&amp;quot; up_thread=&amp;quot;false&amp;quot; down_thread=&amp;quot;false&amp;quot;/&amp;gt;&lt;br /&gt;                &amp;lt;UNICAST timeout=&amp;quot;600,1200,2400&amp;quot; window_size=&amp;quot;100&amp;quot; min_threshold=&amp;quot;10&amp;quot;&lt;br /&gt;                    down_thread=&amp;quot;false&amp;quot;/&amp;gt;&lt;br /&gt;                &amp;lt;pbcast.STABLE desired_avg_gossip=&amp;quot;20000&amp;quot;&lt;br /&gt;                    up_thread=&amp;quot;false&amp;quot; down_thread=&amp;quot;false&amp;quot;/&amp;gt;&lt;br /&gt;                &amp;lt;FRAG frag_size=&amp;quot;8192&amp;quot;&lt;br /&gt;                    down_thread=&amp;quot;false&amp;quot; up_thread=&amp;quot;false&amp;quot;/&amp;gt;&lt;br /&gt;                &amp;lt;pbcast.GMS join_timeout=&amp;quot;5000&amp;quot; join_retry_timeout=&amp;quot;2000&amp;quot;&lt;br /&gt;                    shun=&amp;quot;true&amp;quot; print_local_addr=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;                &amp;lt;pbcast.STATE_TRANSFER up_thread=&amp;quot;true&amp;quot; down_thread=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;            &amp;lt;/config&amp;gt;&lt;br /&gt;        &amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;!--&lt;br /&gt;         Whether or not to fetch state on joining a cluster&lt;br /&gt;         NOTE this used to be called FetchStateOnStartup and has been renamed to be more descriptive.&lt;br /&gt;        --&amp;gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;FetchInMemoryState&amp;quot;&amp;gt;true&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;!--&lt;br /&gt;            The max amount of time (in milliseconds) we wait until the&lt;br /&gt;            initial state (ie. the contents of the cache) are retrieved from&lt;br /&gt;            existing members in a clustered environment&lt;br /&gt;        --&amp;gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;InitialStateRetrievalTimeout&amp;quot;&amp;gt;20000&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;!--&lt;br /&gt;            Number of milliseconds to wait until all responses for a&lt;br /&gt;            synchronous call have been received.&lt;br /&gt;        --&amp;gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;SyncReplTimeout&amp;quot;&amp;gt;20000&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;!-- Max number of milliseconds to wait for a lock acquisition --&amp;gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;LockAcquisitionTimeout&amp;quot;&amp;gt;15000&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;!-- Name of the eviction policy class. --&amp;gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;EvictionPolicyClass&amp;quot;&amp;gt;&amp;lt;/attribute&amp;gt;&lt;br /&gt;       &lt;br /&gt;       &amp;lt;!--&lt;br /&gt;          Indicate whether to use marshalling or not. Set this to true if you are running under a scoped&lt;br /&gt;          class loader, e.g., inside an application server. Default is &amp;quot;false&amp;quot;.&lt;br /&gt;       --&amp;gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;UseMarshalling&amp;quot;&amp;gt;false&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;!-- Specific eviction policy configurations. --&amp;gt;&lt;br /&gt;        &amp;lt;attribute name=&amp;quot;EvictionPolicyConfig&amp;quot;&amp;gt;&lt;br /&gt;            &amp;lt;config&amp;gt;&lt;br /&gt;                &amp;lt;attribute name=&amp;quot;wakeUpIntervalSeconds&amp;quot;&amp;gt;120&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;                &amp;lt;!-- Cache wide default --&amp;gt;&lt;br /&gt;                &amp;lt;region name=&amp;quot;/_default_&amp;quot;&lt;br /&gt;                    policyClass=&amp;quot;org.jboss.cache.eviction.LRUPolicy&amp;quot;&amp;gt;&lt;br /&gt;                    &amp;lt;!-- This is the maximum number of nodes allowed in this region. --&amp;gt;&lt;br /&gt;                    &amp;lt;!-- 0 denotes no limit. --&amp;gt;&lt;br /&gt;                    &amp;lt;attribute name=&amp;quot;maxNodes&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;                    &amp;lt;!-- The amount of time a node is not written to or read (in seconds) before the node is swept away.--&amp;gt;&lt;br /&gt;                    &amp;lt;!-- 0 denotes no limit. --&amp;gt;&lt;br /&gt;                    &amp;lt;attribute name=&amp;quot;timeToLiveSeconds&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;                    &amp;lt;!-- Lifespan of a node (in seconds) regardless of idle time before the node is swept away. --&amp;gt;&lt;br /&gt;                    &amp;lt;!-- 0 denotes no limit. --&amp;gt;&lt;br /&gt;                    &amp;lt;attribute name=&amp;quot;maxAgeSeconds&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;                &amp;lt;/region&amp;gt;&lt;br /&gt;&lt;br /&gt;                &amp;lt;!-- We dont have to define each region if we have default 0 values, but just incase we want to change it later --&amp;gt;&lt;br /&gt;&lt;br /&gt;                &amp;lt;!--&lt;br /&gt;                &amp;lt;region name=&amp;quot;/instructionPageFragments&amp;quot; policyClass=&amp;quot;org.jboss.cache.eviction.LRUPolicy&amp;quot;&amp;gt;&lt;br /&gt;                    &amp;lt;attribute name=&amp;quot;maxNodes&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;                    &amp;lt;attribute name=&amp;quot;timeToLiveSeconds&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;                    &amp;lt;attribute name=&amp;quot;maxAgeSeconds&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;                &amp;lt;/region&amp;gt;&lt;br /&gt;                &lt;br /&gt;                &amp;lt;region name=&amp;quot;/reviewInputPageFragments&amp;quot; policyClass=&amp;quot;org.jboss.cache.eviction.LRUPolicy&amp;quot;&amp;gt;&lt;br /&gt;                    &amp;lt;attribute name=&amp;quot;maxNodes&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;                    &amp;lt;attribute name=&amp;quot;timeToLiveSeconds&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;                    &amp;lt;attribute name=&amp;quot;maxAgeSeconds&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;                &amp;lt;/region&amp;gt;&lt;br /&gt;                &lt;br /&gt;                &amp;lt;region name=&amp;quot;/actorPageFragments&amp;quot; policyClass=&amp;quot;org.jboss.cache.eviction.LRUPolicy&amp;quot;&amp;gt;&lt;br /&gt;                    &amp;lt;attribute name=&amp;quot;maxNodes&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;                    &amp;lt;attribute name=&amp;quot;timeToLiveSeconds&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;                    &amp;lt;attribute name=&amp;quot;maxAgeSeconds&amp;quot;&amp;gt;0&amp;lt;/attribute&amp;gt;&lt;br /&gt;                &amp;lt;/region&amp;gt;&lt;br /&gt;                --&amp;gt;&lt;br /&gt;            &amp;lt;/config&amp;gt;&lt;br /&gt;        &amp;lt;/attribute&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;/mbean&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   &amp;lt;!--  Uncomment to get a graphical view of the TreeCache MBean above --&amp;gt;&lt;br /&gt;   &amp;lt;!--   &amp;lt;mbean code=&amp;quot;org.jboss.cache.TreeCacheView&amp;quot; name=&amp;quot;jboss.cache:service=TreeCacheView&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;   &amp;lt;!--      &amp;lt;depends&amp;gt;jboss.cache:service=TreeCache&amp;lt;/depends&amp;gt;--&amp;gt;&lt;br /&gt;   &amp;lt;!--      &amp;lt;attribute name=&amp;quot;CacheService&amp;quot;&amp;gt;jboss.cache:service=TreeCache&amp;lt;/attribute&amp;gt;--&amp;gt;&lt;br /&gt;   &amp;lt;!--   &amp;lt;/mbean&amp;gt;--&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/server&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;Since I want everything to be cached infinetly I have uncommented the regions out and put 0 (no limit) on the _default_ region&lt;br /&gt;&lt;br /&gt;You can also programatically add and remove content to the cache.&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;@In &lt;br /&gt;private CacheProvider cacheProvider;&lt;br /&gt;&lt;br /&gt;//Removing the cache with the region instructionPageFragments, and the key instruction-'current url'&lt;br /&gt;cacheProvider.remove(&amp;quot;instructionPageFragments&amp;quot;, &amp;quot;instruction-&amp;quot; + url);&lt;br /&gt;//Adding to the cache&lt;br /&gt;cacheProvider.put(&amp;quot;instructionPageFragments&amp;quot;, &amp;quot;instruction-&amp;quot; + url, &amp;quot;This text will be cached!!&amp;quot;);&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-747158423848968688?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/747158423848968688/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=747158423848968688' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/747158423848968688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/747158423848968688'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/03/adding-html-cache-on-jsf-12-seam-211.html' title='Adding html cache on a JSF 1.2 / Seam 2.1.1 application'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-4555448133129215742</id><published>2009-02-13T14:57:00.007+01:00</published><updated>2009-02-13T15:46:45.820+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IdentityManager'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam'/><category scheme='http://www.blogger.com/atom/ns#' term='hash password'/><title type='text'>Hash user password in Seam 2.1.1 manually without using IdentityManager</title><content type='html'>In the Seam Documentation, they give a minimal schema example of how you can create Users and Roles here: &lt;a href="http://docs.jboss.com/seam/2.1.1.GA/reference/en-US/html_single/#d0e9178"&gt;http://docs.jboss.com/seam/2.1.1.GA/reference/en-US/html_single/#d0e9178&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As it is explained in the documentation, you can annotate your password with&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span class="java_plain"&gt;@&lt;/span&gt;&lt;span class="java_type"&gt;UserPassword&lt;/span&gt;&lt;span class="java_separator"&gt;(&lt;/span&gt;&lt;span class="java_plain"&gt;hash &lt;/span&gt;&lt;span class="java_operator"&gt;=&lt;/span&gt;&lt;span class="java_plain"&gt; &lt;/span&gt;&lt;span class="java_literal"&gt;"md5"&lt;/span&gt;&lt;span class="java_separator"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;!--  --&gt;&lt;span class="java_plain"&gt;&lt;/span&gt;&lt;span class="java_keyword"&gt;public&lt;/span&gt;&lt;span class="java_plain"&gt; &lt;/span&gt;&lt;span class="java_type"&gt;String&lt;/span&gt;&lt;span class="java_plain"&gt; getPasswordHash&lt;/span&gt;&lt;span class="java_separator"&gt;()&lt;/span&gt;&lt;span class="java_plain"&gt; &lt;/span&gt;&lt;span class="java_separator"&gt;{&lt;/span&gt;&lt;span class="java_plain"&gt; &lt;/span&gt;&lt;span class="java_keyword"&gt;return&lt;/span&gt;&lt;span class="java_plain"&gt; passwordHash&lt;/span&gt;&lt;span class="java_separator"&gt;;&lt;/span&gt;&lt;span class="java_plain"&gt; &lt;/span&gt;}&lt;a id="d0e9178"&gt;&lt;span class="java_plain"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="java_keyword"&gt;public&lt;/span&gt;&lt;span class="java_plain"&gt; &lt;/span&gt;&lt;span class="java_type"&gt;void&lt;/span&gt;&lt;span class="java_plain"&gt; setPasswordHash&lt;/span&gt;&lt;span class="java_separator"&gt;(&lt;/span&gt;&lt;span class="java_type"&gt;String&lt;/span&gt;&lt;span class="java_plain"&gt; passwordHash&lt;/span&gt;&lt;span class="java_separator"&gt;)&lt;/span&gt;&lt;span class="java_plain"&gt; &lt;/span&gt;&lt;span class="java_separator"&gt;{&lt;/span&gt;&lt;span class="java_plain"&gt; &lt;/span&gt;&lt;span class="java_keyword"&gt;this&lt;/span&gt;&lt;span class="java_separator"&gt;.&lt;/span&gt;&lt;span class="java_plain"&gt;passwordHash &lt;/span&gt;&lt;span class="java_operator"&gt;=&lt;/span&gt;&lt;span class="java_plain"&gt; passwordHash&lt;/span&gt;&lt;span class="java_separator"&gt;;&lt;/span&gt;&lt;span class="java_plain"&gt; &lt;/span&gt;&lt;span class="java_separator"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/pre&gt;You could also use &lt;pre&gt;hash= "none"&lt;/pre&gt; which doesnt hash the password which is what I did at first. The reason why I didnt start using md5 at once is because you needed a default username and password to be able to log into your seam application. And since I was using an import.sql script that created a default user for me, I had no way of knowing how to hash the password.&lt;br /&gt;&lt;br /&gt;So what I needed to do is manually somehow hash a password which I could put in my import.sql script, so that I could enable hashing and correctly log in to my seam application. However this was easier said then done.&lt;br /&gt;I tried changing the @UserPassword(hash="md5") and try to log in, but for obvious reason the login failed, because it was expecting a hashed password.&lt;br /&gt;&lt;br /&gt;So then I got the idea to call a method that doesn't require login, which creates a user for us, that is called from a button in the login page. However when I persisted the user, the password was saved as clear text. This baffled me, because I thought that seam would handle that automatically. But if you actually look at the user entity and the setHashPassword method, it is not annotated, and it only sets a string. So it was obvious it only persisted the password as string.&lt;br /&gt;In Seam you can also use IdentityManager to create a user for you. This will perform the hashing for you. So I tried to call &lt;pre&gt;identityManager.createUser("username","password","firstname","lastname");&lt;/pre&gt;&lt;br /&gt;However, identityManager requires that you are correctly Authenticated, and it threw an exception &lt;pre&gt;org.jboss.seam.security.AuthorizationException: Authorization check failed for permission seam.user,create&lt;/pre&gt;&lt;br /&gt;So apparently IdentityManager requires the correct permissions, which must be set in your drools setting in security.drl, but I didn't want to do that, since that is not how I wanted to configure my seam application.&lt;br /&gt;&lt;br /&gt;So what I did, was look in the seam source and IdentityManager class and find the exact code that performs the hashing for us, and do that manually. And this worked great. Here is the source.&lt;br /&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;code&gt;public String saveProcessUser() {&lt;br /&gt;       // Check if a new password has been entered&lt;br /&gt;       if (currentUser.getPasswordHash() != null &amp;amp;&amp;amp; !"".equals(currentUser.getPasswordHash())) {&lt;br /&gt;           if (!currentUser.getPasswordHash().equals(passwordVerify)) {&lt;br /&gt;               StatusMessages.instance().addFromResourceBundle("admin.wrongPassword");&lt;br /&gt;               return "failure";&lt;br /&gt;           }&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       // If passwordVerify is not empty, it generally means its a new password&lt;br /&gt;       if (!passwordVerify.equals("")) {&lt;br /&gt;           String hashPass = generatePasswordHash(currentUser.getPasswordHash(), currentUser.getUsername());&lt;br /&gt;           log.debug("Setting new hash password: " + hashPass);&lt;br /&gt;           currentUser.setPasswordHash(hashPass);&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       if (getCurrentUser().getId() != null) {&lt;br /&gt;           entityManager.flush();&lt;br /&gt;       } else {&lt;br /&gt;           entityManager.persist(currentUser);&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       FacesMessages.instance().addToControlFromResourceBundle("successMessage", "admin.user.saved");&lt;br /&gt;       return "success";&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;    * This method will generate a hash password&lt;br /&gt;    *&lt;br /&gt;    * @param password - The password in cleartext&lt;br /&gt;    * @param salt - The username is used as salt&lt;br /&gt;    * @return - hash password based on password and username&lt;br /&gt;    */&lt;br /&gt;   private String generatePasswordHash(String password, String salt) {&lt;br /&gt;       AnnotatedBeanProperty&amp;lt;UserPassword&amp;gt; userPasswordProperty = new AnnotatedBeanProperty&amp;lt;UserPassword&amp;gt;(ProcessUser.class, UserPassword.class);&lt;br /&gt;       // Will get the hash value from annotation UserPassword in ProcessUser.class&lt;br /&gt;       String algorithm = userPasswordProperty.getAnnotation().hash();&lt;br /&gt;       return PasswordHash.instance().generateSaltedHash(password, salt, algorithm);&lt;br /&gt;   }&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note that the method saveProcessUser() is called from the user administration form, and the currentUser object is my User entity. Seam will inject all the methods for us, so we dont have to do that. So we check if the verifyPassword is set and correct and then we hash the password. If the @UserPassword is set to something other than none, then it will correctly save a user and you can finally copy the hashed password in your import.sql script.&lt;br /&gt;&lt;br /&gt;PS: You first should have the @UserPassword(hash="none")  and then go to your user registration and then just print out what the password is, and then copy that to your import.sql script. When the authentication correctly works with either md5 or sha, then you can safely add the user to the database.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-4555448133129215742?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/4555448133129215742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=4555448133129215742' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/4555448133129215742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/4555448133129215742'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/02/hash-user-password-in-seam-211-manually.html' title='Hash user password in Seam 2.1.1 manually without using IdentityManager'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-6367441766172666597</id><published>2009-02-04T16:09:00.016+01:00</published><updated>2009-02-05T09:53:21.523+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='axis2'/><category scheme='http://www.blogger.com/atom/ns#' term='webservice'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam'/><category scheme='http://www.blogger.com/atom/ns#' term='jboss'/><title type='text'>How to create and use a WebService with Axis 2 and Seam 2.x in JBoss 4.x</title><content type='html'>In this example, I will show how you can create a Webservice using Axis 2.&lt;br /&gt;First of all, download the latest version of Axix 2 from &lt;a href="http://ws.apache.org/axis2/"&gt;http://ws.apache.org/axis2/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To create a WebService in Java EE 5 you can use the annotation @WebService.&lt;br /&gt;We also annotate this class as a seam component so that we can incorporate it in our existing business logic.&lt;br /&gt;&lt;br /&gt;This is our WebService:&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;package somepackage.webservice;&lt;br /&gt;&lt;br /&gt;import java.util.ArrayList;&lt;br /&gt;import java.util.List;&lt;br /&gt;import java.util.Set;&lt;br /&gt;&lt;br /&gt;import javax.ejb.Stateless;&lt;br /&gt;import javax.jws.WebMethod;&lt;br /&gt;import javax.jws.WebParam;&lt;br /&gt;import javax.jws.WebService;&lt;br /&gt;import javax.jws.soap.SOAPBinding;&lt;br /&gt;import javax.persistence.EntityManager;&lt;br /&gt;&lt;br /&gt;import org.jboss.seam.Component;&lt;br /&gt;import org.jboss.seam.annotations.In;&lt;br /&gt;import org.jboss.seam.annotations.Name;&lt;br /&gt;import org.jboss.seam.security.Credentials;&lt;br /&gt;import org.jboss.seam.security.Identity;&lt;br /&gt;&lt;br /&gt;@Name("fooService")&lt;br /&gt;@Stateless&lt;br /&gt;@WebService(name = "FooService", serviceName = "FooService")&lt;br /&gt;@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)&lt;br /&gt;public class FooService implements FooServiceLocal {&lt;br /&gt;&lt;br /&gt; @In EntityManager entityManager;&lt;br /&gt;&lt;br /&gt; @In Credentials credentials;&lt;br /&gt;&lt;br /&gt; private boolean login(String username, String password) {&lt;br /&gt;     credentials.setUsername(username);&lt;br /&gt;     credentials.setPassword(password);&lt;br /&gt;     Identity.instance().login();&lt;br /&gt;     return Identity.instance().isLoggedIn();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; private boolean logout() {&lt;br /&gt;     Identity.instance().logout();&lt;br /&gt;     return !Identity.instance().isLoggedIn();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; @WebMethod&lt;br /&gt; public List&amp;lt;FooCanonical&amp;gt; getFoo(@WebParam(name = "username")&lt;br /&gt; String username, @WebParam(name = "password")&lt;br /&gt; String password, @WebParam(name = "orgnumber")&lt;br /&gt; String orgnumber) {&lt;br /&gt;     // orgnumber can be null!&lt;br /&gt;     if (username == null || password == null) {&lt;br /&gt;         return null;&lt;br /&gt;     }&lt;br /&gt;     //First thing we do is to login to ensure that the user has the correct username/password&lt;br /&gt;     //We are using basic seam login method&lt;br /&gt;     boolean isLoggedIn = login(username, password);&lt;br /&gt;&lt;br /&gt;     if (isLoggedIn) {&lt;br /&gt;     &lt;br /&gt;         List&amp;lt;FooCanonical&amp;gt; returnList = new ArrayList&amp;lt;FooCanonical&amp;gt;();&lt;br /&gt;         //Do some stuff with the list&lt;br /&gt;         //Remember to log out&lt;br /&gt;         logout();&lt;br /&gt;         return returnList;&lt;br /&gt;     } else {&lt;br /&gt;         // Probably wrong username password&lt;br /&gt;         return null;&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Next what we need to do, is create a way for this webservice to interact with JBoss through our SOAP definition. We do that by creating a xml file called &lt;pre&gt;standard-jaxws-endpoint-config.xml&lt;/pre&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&amp;lt;jaxws-config xmlns="urn:jboss:jaxws-config:2.0"&lt;br /&gt;   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br /&gt;   xmlns:javaee="http://java.sun.com/xml/ns/javaee"&lt;br /&gt;   xsi:schemaLocation="urn:jboss:jaxws-config:2.0 jaxws-config_2.1.xsd"&amp;gt;&lt;br /&gt;&amp;lt;endpoint-config&amp;gt;&lt;br /&gt;   &amp;lt;config-name&amp;gt;Seam WebService Endpoint&amp;lt;/config-name&amp;gt;&lt;br /&gt;   &amp;lt;pre-handler-chains&amp;gt;&lt;br /&gt;      &amp;lt;javaee:handler-chain&amp;gt;&lt;br /&gt;         &amp;lt;javaee:protocol-bindings&amp;gt;##SOAP11_HTTP&amp;lt;/javaee:protocol-bindings&amp;gt;&lt;br /&gt;         &amp;lt;javaee:handler&amp;gt;&lt;br /&gt;            &amp;lt;javaee:handler-name&amp;gt;SOAP Request Handler&amp;lt;/javaee:handler-name&amp;gt;&lt;br /&gt;            &amp;lt;javaee:handler-class&amp;gt;org.jboss.seam.webservice.SOAPRequestHandler&amp;lt;/javaee:handler-class&amp;gt;&lt;br /&gt;         &amp;lt;/javaee:handler&amp;gt;&lt;br /&gt;      &amp;lt;/javaee:handler-chain&amp;gt;&lt;br /&gt;   &amp;lt;/pre-handler-chains&amp;gt;&lt;br /&gt;&amp;lt;/endpoint-config&amp;gt;&lt;br /&gt;&amp;lt;/jaxws-config&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;And place this file in the $JBOSS_HOME/resources/META-INF directory.&lt;br /&gt;Now you are done! Deploy your application and look in &lt;pre&gt;http://localhost:8080/jbossws/services &lt;/pre&gt; and see if your WebService is correctly deployed and the wsdl available.&lt;br /&gt;This should look something like this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Endpoint Name&lt;/td&gt;&lt;td&gt;jboss.ws:context=foo-foo,endpoint=FooService&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Endpoint Address&lt;/td&gt;&lt;td&gt;&lt;a href="http://ky:8080/alkohol_register-alkohol_register/RelationService?wsdl"&gt;http://localhost:8080/foo-foo/FooService?wsdl&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/pre&gt;&lt;br /&gt;Next, we will use the Axis2 framework to create client stubs by using axis2-1.4.1 and the script wsdl2java. Navigate to $AXIS_HOME/bin and type in the following command:&lt;br /&gt;&lt;pre&gt;./wsdl2java.sh -uri http://127.0.0.1:8080/foo_foo/FooService?wsdl -o build/client&lt;/pre&gt;&lt;br /&gt;This command will create an ant script under the directly build/client.&lt;br /&gt;Now go to build/client and type ant after setting $AXIS_HOME. This will generate FooService-test-client.jar which we now can use to retrieve data from the WebService in the client. I recommend changing the name to something more appropriate.&lt;br /&gt;&lt;br /&gt;In your client, you can call the getFoo WebMethod like this:&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;FooServiceStub stub;&lt;br /&gt;GetFoo getFoo;&lt;br /&gt;&lt;br /&gt;stub = new FooServiceStub();&lt;br /&gt;getFoo = new FooServiceStub.GetFoo();&lt;br /&gt;getFoo.setUsername("username");&lt;br /&gt;getFoo.setPassword("password");&lt;br /&gt;getFoo.setOrgnumber("1234");&lt;br /&gt;&lt;br /&gt;FooServiceStub.GetFooE fooImpl = new FooServiceStub.GetFooE();&lt;br /&gt;fooImpl.setGetFoo(getFoo);&lt;br /&gt;&lt;br /&gt;//Retrieve the List as an array&lt;br /&gt;FooCanonical[] get_return = stub.getFoo(fooImpl).getGetFooResponse().get_return();&lt;br /&gt;//Do what you want with the array&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Note that even if you return a List from the WebService, you will get it as an array. But it is quite easy to put it in a List in the client afterwards. Also remember that the username and password is sendt in clear text, so you might want to send it through https, so it is encrypted.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-6367441766172666597?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/6367441766172666597/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=6367441766172666597' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/6367441766172666597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/6367441766172666597'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2009/02/how-to-create-and-use-webservice-with.html' title='How to create and use a WebService with Axis 2 and Seam 2.x in JBoss 4.x'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-5115283363608995001</id><published>2008-12-12T18:14:00.004+01:00</published><updated>2008-12-12T18:38:12.626+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaPolis'/><category scheme='http://www.blogger.com/atom/ns#' term='Devoxx'/><title type='text'>Devoxx 2008 conference comes to an end</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_nbzuXQmcHXc/SUKhdvEuowI/AAAAAAAAAGA/iWF-k7PIKOo/s1600-h/logo.jpeg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 300px; height: 125px;" src="http://1.bp.blogspot.com/_nbzuXQmcHXc/SUKhdvEuowI/AAAAAAAAAGA/iWF-k7PIKOo/s320/logo.jpeg" alt="" id="BLOGGER_PHOTO_ID_5278959245456220930" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I have just attended Devoxx (former JavaPolis) in Belgium Antwerpen, and I must say I am pretty amazed. It was not how I expected it to be.&lt;br /&gt;&lt;br /&gt;Although it is much smaller than JavaOne, it is however bigger and better than JavaZone. The conference it self was on a big cinema stadium called Metropolis. It was huge, with 8 different rooms, and all the sessions where video recorded and will be available online on &lt;a href="http://www.parleys.com/"&gt;Parleys&lt;/a&gt;&lt;br /&gt;early next year.&lt;br /&gt;&lt;br /&gt;The conference was very much focused on &lt;a href="http://javafx.com/"&gt;JavaFX&lt;/a&gt; since the 1.0 release came out 4th of December 2008.&lt;br /&gt;I attended many different sessions such as JavaFX, WebBeans, Hibernate tuning, Dojo and DWR and how to hack and secure Java web applications, plus a few others.&lt;br /&gt;I will most certainly try to attend next year again, depending on my schedule. However next time, I will try to live a little closer to the event, and not 10 minute drive or an hour walk.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-5115283363608995001?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/5115283363608995001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=5115283363608995001' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5115283363608995001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/5115283363608995001'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/12/devoxx-2008-conference-comes-to-end.html' title='Devoxx 2008 conference comes to an end'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_nbzuXQmcHXc/SUKhdvEuowI/AAAAAAAAAGA/iWF-k7PIKOo/s72-c/logo.jpeg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-2799162477144970199</id><published>2008-12-06T14:57:00.003+01:00</published><updated>2008-12-06T14:59:58.906+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='damenes tale'/><category scheme='http://www.blogger.com/atom/ns#' term='julebord'/><title type='text'>Damenes tale ved julebord 2008</title><content type='html'>&lt;p&gt;Idag skal jeg holde damenes tale ved vårt julebord.&lt;br /&gt;Her er talen i sin helhet:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Kjære alle sammen, men mest av alt, kjære til alle damene her ikveld. Jeg vil først og fremst takke for at jeg fikk lov til å stå her ikveld og gjøre stas på dere.&lt;br /&gt;I år har jeg fått den ærefulle oppgave å holde damenes tale, hvilket er veldig rart, for jeg hadde ingen&lt;br /&gt;anelse hvordan man skulle holde damenes tale.&lt;br /&gt;&lt;br /&gt;Jeg er som kjent for mange av dere veldig flink til å forføre damene med mine velvalgte ord, og hypnotiserende kroppspråk. &lt;br /&gt;Her er jeg på hjemmebane som en løve i serengetti på jakt etter sitt utvalgte bytte.&lt;br /&gt;Men det å stå foran en forsamling av velkledde, flotte og lett berusede damer og forsøke å forføre dem alle samtidig, er ingen enkel sak.&lt;br /&gt;Men ingen utfordring er for stor for en velrenommert sjekker som meg. Her er det bare å begrave seg dypt i materie&lt;br /&gt;og en av de første tingene som står der er at man må ha en god wingman til å hjelpe en ute i feltet.&lt;br /&gt;&lt;br /&gt;Derfor, som den geeken jeg er tydde jeg til Google som min trofaste wingman og søkte opp "damenes tale", og det første treffet jeg får opp er følgende:&lt;br /&gt;&lt;quote&gt;&lt;br /&gt;"Damenes tale er som regel en veldig morsom tale. En ganske kompleks tale som krever mye av deg som skal holde den.&lt;br /&gt;Damenes tale er kanskje den mest omtalte talen man kan holde hvis man ser bort fra den likestilte talen Herrenes tale."&lt;br /&gt;&lt;/quote&gt;&lt;br /&gt;&lt;br /&gt;Dette høres veldig utfordrende ut men jeg skal gjøre mitt beste og ta tyren ved hornene. &lt;p&gt;Det finnes vesentlig store forskjeller mellom gutter og jenter. Ikke minst utspringer disse forskjellene seg i sjekke scenen.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Her følger en typisk sjekke-prosedyre på en bar en sen lørdagskveld nær stengetid sett fra en gutts perspektiv:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- Gutt ser jente som er sexy.&lt;br /&gt;- Gutt tar en stoor slurk av drinken for å manne seg opp&lt;br /&gt;- Gutt venter ti minutter til jente er alene (før han tør å dra bort)&lt;br /&gt;- Gutt tar en ny stooor slurk&lt;br /&gt;- Gutt drar bort og åpner med et sleskete uttrykk: "Hei sexy, hvordan går det?" (blunker)&lt;br /&gt;- Jente ser stygt på gutt og danser videre&lt;br /&gt;- Gutt står å ser dum ut&lt;br /&gt;- Gutt begynner å danse for seg selv i noen sekunder&lt;br /&gt;- Gutt tar en ny slurk og går tilbake til lattermilde kompiser&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Og her følger kvinnenes typiske sjekke-prosedyre.&lt;/p&gt;&lt;p&gt;- Jente ser forførende på gutt (pause)&lt;br /&gt;- Jente blir med gutt hjem&lt;br /&gt;- Så lar jeg dere selv sette inn det sensurerte mellom linjene&lt;/p&gt;&lt;p&gt;Ikke mindre vanskelig er det for dere heller tidligere på lørdagskvelden utenfor inngangen til utestedet.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- Jente ankommer utested og ser mil lang kø.&lt;br /&gt;- Jente går forbi køen, smiler til dørvaktene, viser litt pupper og lår, og slipper gratis inn.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- Gutt ankommer utested&lt;br /&gt;- Gutt plasserer seg helt bak den milelange køen bak andre virile og håpefulle beilere i timesvis&lt;br /&gt;- Gutt fryser&lt;br /&gt;- Gutt fryser enda mer&lt;br /&gt;- Timesvis etterpå står gutt håpefull først køen&lt;br /&gt;- Gutt må stå enda noen minutter&lt;br /&gt;- Gutt fryser&lt;br /&gt;- Dørvakt kommer bort til gutt og påminner gutten om at det er et lukket selskap, eller at joggeskoene og manglende skjorte ikke står helt i stil til stedet, som egentlig direkte oversatt betyr:&lt;br /&gt;"Jeg bruker min steroid forspiste kropp som ikke duger til annet enn å krympe ballene og hjernecellene mine til å vise deg at fordi du garantert er mye smartere enn meg&lt;br /&gt;og tjener mer enn meg, så skal jeg bruke min autoritære mulighet til å overbevise meg selv om at livet mitt ikke stinker, og at jeg kan få noen små ynkelige gleder i livet".&lt;br /&gt;- Gutt må betale ekstra til dørvakta for å slippe inn, i tillegg til inngang.&lt;/p&gt;&lt;p&gt;Men det er ikke så rart at vi gutter går gjennom alt dette for dere skjønne piker. Ja, for hva gjør ikke vi gutter for dere jenter? Vi spiste til og med eplet for dere vi.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;For hadde det ikke vært for dere hadde vi fortsatt kost oss i Edens have i perfekt harmoni med alle dyrene.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Istedet har dere tatt til takke med en mink i skapet, en jaguar i garasjen, en tiger i senga og en bjellesau som betaler for alt dere vil ha.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Nei men fra spøk til alvor, vi gutter hadde aldri klart å leve uten dere vakre jenter som fyller hverdagen vår. Vi er kjempe glad i dere og derfor spør jeg dere om dere vennligst kan komme opp her alle sammen.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Jeg vil at alle gutta skal se godt på de kjære og vakre jentene vi har i Redpill Linpro. De sørger for å komplementere hverdagen vår og &lt;br /&gt;&lt;/p&gt;&lt;p&gt;bidrar til at vår testosteron nivå balanseres med deres østrogen til å skape en mer eller mindre perfekt symbiose.&lt;br /&gt;&lt;/p&gt;Det er veldig vanlig å gi roser til den bedre halvdelen. Men roser varer kun bare noen uker, og de eksisterer kun for å være vakre, og hvis de står en stund så visner de bare.&lt;br /&gt;Så det er det samme som å si at vår kjærlighet baserer seg kun på utseendet.&lt;br /&gt;Derimot, en potet varer evig, og i poteten er det det indre som teller. Faktisk, har du poteten liggende lenge nok, ikke bare vil den IKKE råtne,&lt;br /&gt;men det vokser faktisk ting ut av poteten, så det er det samme som å si at vår kjærlighet vokser gjennom tiden. Derfor vil jeg på vegne av alle gutta beære de vakre jentene i Redpill Linpro med hver sin potet.&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;- Da vil jeg at alle guttene skal reise seg opp og skåle for verdens vakreste skapninger. Skål!&lt;br /&gt;&lt;p&gt;Takk for meg...&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-2799162477144970199?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/2799162477144970199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=2799162477144970199' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/2799162477144970199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/2799162477144970199'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/12/damenes-tale-ved-julebord-2008.html' title='Damenes tale ved julebord 2008'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-2370774300615181018</id><published>2008-12-03T12:24:00.006+01:00</published><updated>2009-01-21T15:13:23.800+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PDF'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Freemarker'/><category scheme='http://www.blogger.com/atom/ns#' term='OpenOffice'/><category scheme='http://www.blogger.com/atom/ns#' term='JOOReport'/><category scheme='http://www.blogger.com/atom/ns#' term='ODT'/><title type='text'>Dynamically generate ODT and PDF documents from Java</title><content type='html'>&lt;p&gt;I would like to generate a OpenOffice document and a PDF document without having a running OpenOffice service in Java. This was not as easy as it sounds, however I have found a solution.&lt;/p&gt;&lt;p&gt;You can create ODT document fairly easy without having a running instance of OpenOffice. However I have not found an easy way to convert that document to a PDF. However, I found a solution for the latter when running Linux. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;All the following libraries are Open Source .&lt;br /&gt;&lt;br /&gt;The easiest way to generate ODT documents from templates is by using a (unmaintaned) library by the name of &lt;a href="http://jodreports.sourceforge.net/"&gt;JOOReport&lt;/a&gt;. &lt;a href="http://jodreports.sourceforge.net/"&gt;JOOReport&lt;/a&gt; uses &lt;a href="http://freemarker.sourceforge.net/"&gt;Freemarker&lt;/a&gt; to create ODT documents based on templates. &lt;br /&gt;&lt;br /&gt;Basically what you need to do is create a template odt document in OpenOffice and whereever you want to insert something, you can insert it with the syntax &lt;br /&gt;${anythingGoesHere}&lt;br /&gt;ie: &lt;span style="font-family:courier new;"&gt;My name is ${name}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When you have finished implementing the template, you must then create a properties file defining the values. &lt;br /&gt;&lt;br /&gt;ie. &lt;br /&gt;&lt;span style="font-family:courier new;"&gt;name=&lt;br /&gt;age=&lt;br /&gt;birthday=&lt;br /&gt;address=&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We can then from the Java program get the Properties file, and fill inn already pre defined variables. We then give the template and the properties file as well as the output odt file in arguments to the program. After the creation is successfull, the easiest way is to call a linux program called &lt;br /&gt;&lt;span style="font-family:courier new;"&gt;odt2pdf someFile.odt&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;which takes the odt file as argument and creates a pdf file with the same name. &lt;br /&gt;&lt;br /&gt;Vouila. As easy as that. You can also style the template as you like and the styling will also be implemented in the generated output file.&lt;/p&gt;&lt;p&gt;This is a standalone program that creates a document from a template and a data file and converts it to the specific format. &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&lt;br /&gt;&lt;template-document&gt;&lt;data-file&gt;&lt;output-document&gt;// JOOReports - The Open Source Java/OpenOffice Report Engine &lt;br /&gt;// Copyright (C) 2004-2006 - Mirko Nasato &lt;br /&gt;// &lt;br /&gt;// This library is free software; you can redistribute it and/or &lt;br /&gt;// modify it under the terms of the GNU Lesser General Public &lt;br /&gt;// License as published by the Free Software Foundation; either &lt;br /&gt;// version 2.1 of the License, or (at your option) any later version. &lt;br /&gt;// &lt;br /&gt;// This library is distributed in the hope that it will be useful, &lt;br /&gt;// but WITHOUT ANY WARRANTY; without even the implied warranty of &lt;br /&gt;// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU &lt;br /&gt;// Lesser General Public License for more details. &lt;br /&gt;// http://www.gnu.org/copyleft/lesser.html &lt;br /&gt;// &lt;br /&gt;package net.sf.jooreports.tools; &lt;br /&gt;&lt;br /&gt;import java.io.File; &lt;br /&gt;import java.io.FileInputStream; &lt;br /&gt;import java.io.FileOutputStream; &lt;br /&gt;import java.net.ConnectException; &lt;br /&gt;import java.util.Properties; &lt;br /&gt;&lt;br /&gt;import org.apache.commons.io.FilenameUtils; &lt;br /&gt;&lt;br /&gt;import net.sf.jooreports.converter.DocumentConverter; &lt;br /&gt;import net.sf.jooreports.openoffice.connection.OpenOfficeConnection; &lt;br /&gt;import net.sf.jooreports.openoffice.connection.SocketOpenOfficeConnection; &lt;br /&gt;import net.sf.jooreports.openoffice.converter.OpenOfficeDocumentConverter; &lt;br /&gt;import net.sf.jooreports.templates.DocumentTemplate; &lt;br /&gt;import net.sf.jooreports.templates.UnzippedDocumentTemplate; &lt;br /&gt;import net.sf.jooreports.templates.ZippedDocumentTemplate; &lt;br /&gt;import freemarker.ext.dom.NodeModel; &lt;br /&gt;&lt;br /&gt;/** &lt;br /&gt; * Command line tool to create a document from a template and a data file &lt;br /&gt; * and convert it to the specified format. &lt;br /&gt; * &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; * The data file can be in XML format or a simple .properties file. &lt;br /&gt; * &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; * Requires an OpenOffice.org service to be running on localhost:8100 &lt;br /&gt; * (if the output format is other than ODT). &lt;br /&gt; */ &lt;br /&gt;public class CreateAndConvertDocument { &lt;br /&gt;&lt;br /&gt;  public static void main(String[] args) throws Exception { &lt;br /&gt;  if (args.length &amp;lt; 3) {   System.err.println(&amp;quot;USAGE: &amp;quot;+ CreateAndConvertDocument.class.getName() +&amp;quot; &amp;quot;); &lt;br /&gt;  System.exit(0); &lt;br /&gt;  }   &lt;br /&gt;  File templateFile = new File(args[0]); &lt;br /&gt;  File dataFile = new File(args[1]); &lt;br /&gt;  File outputFile = new File(args[2]); &lt;br /&gt;&lt;br /&gt;  DocumentTemplate template = null; &lt;br /&gt;  if (templateFile.isDirectory()) { &lt;br /&gt;  template = new UnzippedDocumentTemplate(templateFile); &lt;br /&gt;  } else { &lt;br /&gt;  template = new ZippedDocumentTemplate(templateFile); &lt;br /&gt;  } &lt;br /&gt;    &lt;br /&gt;  Object model = null; &lt;br /&gt;  String dataFileExtension = FilenameUtils.getExtension(dataFile.getName()); &lt;br /&gt;  if (dataFileExtension.equals(&amp;quot;xml&amp;quot;)) { &lt;br /&gt;  model = NodeModel.parse(dataFile); &lt;br /&gt;  } else if (dataFileExtension.equals(&amp;quot;properties&amp;quot;)) { &lt;br /&gt;  Properties properties = new Properties(); &lt;br /&gt;  properties.load(new FileInputStream(dataFile)); &lt;br /&gt;  model = properties; &lt;br /&gt;  } else { &lt;br /&gt;  throw new IllegalArgumentException(&amp;quot;data file must be 'xml' or 'properties'; unsupported type: &amp;quot; + dataFileExtension); &lt;br /&gt;  } &lt;br /&gt;   &lt;br /&gt;  if (&amp;quot;odt&amp;quot;.equals(FilenameUtils.getExtension(outputFile.getName()))) { &lt;br /&gt;  template.createDocument(model, new FileOutputStream(outputFile)); &lt;br /&gt;  } else { &lt;br /&gt;  OpenOfficeConnection connection = new SocketOpenOfficeConnection(); &lt;br /&gt;  try { &lt;br /&gt;  connection.connect(); &lt;br /&gt;  } catch (ConnectException connectException) { &lt;br /&gt;  System.err.println(&amp;quot;ERROR: connection failed. Please make sure OpenOffice.org is running and listening on port &amp;quot;+ SocketOpenOfficeConnection.DEFAULT_PORT +&amp;quot;.&amp;quot;); &lt;br /&gt;  System.exit(1); &lt;br /&gt;  } &lt;br /&gt;    &lt;br /&gt;  File temporaryFile = File.createTempFile(&amp;quot;document&amp;quot;, &amp;quot;.odt&amp;quot;); &lt;br /&gt;  temporaryFile.deleteOnExit(); &lt;br /&gt;  template.createDocument(model, new FileOutputStream(temporaryFile)); &lt;br /&gt;  &lt;br /&gt;  try { &lt;br /&gt;  DocumentConverter converter = new OpenOfficeDocumentConverter(connection); &lt;br /&gt;  converter.convert(temporaryFile, outputFile); &lt;br /&gt;  } finally { &lt;br /&gt;  connection.disconnect(); &lt;br /&gt;  } &lt;br /&gt;  } &lt;br /&gt;  } &lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-2370774300615181018?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/2370774300615181018/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=2370774300615181018' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/2370774300615181018'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/2370774300615181018'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/12/dynamically-generate-odt-and-pdf.html' title='Dynamically generate ODT and PDF documents from Java'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-8607434114829168410</id><published>2008-10-13T08:42:00.007+02:00</published><updated>2008-10-13T09:02:46.938+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='musehånd'/><category scheme='http://www.blogger.com/atom/ns#' term='rpi'/><category scheme='http://www.blogger.com/atom/ns#' term='rollermouse pro'/><title type='text'>No more Repetitive Strain Injury (RPI)</title><content type='html'>RPI or (musehånd) in Norwegian is something I have had problems with the last three years.&lt;br /&gt;Read more about RPI here: &lt;a href="http://en.wikipedia.org/wiki/Repetitive_strain_injury"&gt;RPI&lt;/a&gt;&lt;br /&gt;&lt;p&gt;Since I work as a developer and using a mouse every day, it has put a strain on my wrist. I have tried many different things throughout the years, like different types of mouse and such.&lt;br /&gt;But I have finally found something that works! And that is the &lt;a href="http://www.contourdesign.com/rollermouse/"&gt;RollerMouse Pro &lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:left;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_nbzuXQmcHXc/SPLw_YYpRiI/AAAAAAAAAEM/yvkch651GYo/s320/rmpro-bar-lg.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5256528686763034146" /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_nbzuXQmcHXc/SPLxUYZbkyI/AAAAAAAAAEU/lqmetc7pEm0/s320/rmpro-sm.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5256529047543583522" /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;This is how it looks like. The roller is used as a mouse. So you dont have to change position so much with your hands. And you use your thumbs to roll the mouse and clicking, instead of your point finger. Remember that when you buy the RollerMouse Pro it doesnt come with a keyboard. You can use your own keyboard with it. The RollerMouse Pro is quite expensive, but it was well worth the 2000kr I paid for it. It also works great on Linux.&lt;/p&gt;&lt;p&gt;I can warmly recommend this product.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-8607434114829168410?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/8607434114829168410/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=8607434114829168410' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/8607434114829168410'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/8607434114829168410'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/10/no-more-repetitive-strain-injury-rpi.html' title='No more Repetitive Strain Injury (RPI)'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_nbzuXQmcHXc/SPLw_YYpRiI/AAAAAAAAAEM/yvkch651GYo/s72-c/rmpro-bar-lg.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-919745765006881241</id><published>2008-10-01T18:37:00.003+02:00</published><updated>2008-10-01T18:40:08.878+02:00</updated><title type='text'>Richfaces 3.2.x useful tips</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Using &amp;lt;a4j:log&amp;gt;&lt;/span&gt;&lt;br /&gt;To see this in action, you can use an &amp;lt;a4j:log&amp;gt;, which shows request&lt;br /&gt;data, response data, DOM tree changes on update, and other useful debug&lt;br /&gt;information. When placed on the page, the control doesn’t produce any&lt;br /&gt;visible output, but after hitting Ctrl+Shift+L (the default register hotkey), a&lt;br /&gt;debug window will open. If for some reason a debug log window doesn’t&lt;br /&gt;open, change the hotkey by setting the hotkey attribute to a letter of your&lt;br /&gt;choice, for example, &amp;lt;a4j:log hotkey="D"/&amp;gt;.&lt;br /&gt;…&lt;br /&gt;&amp;lt;/rich:panel&amp;gt;&lt;br /&gt;&amp;lt;a4j:log/&amp;gt;&lt;br /&gt;&lt;br /&gt;------------------------------------&lt;br /&gt;&amp;lt;h:inputText value="#{profile.age}"&amp;gt;&lt;br /&gt;&amp;lt;a4j:support event="onblur" reRender="userInfo"&lt;br /&gt;ajaxSingle="true"&amp;gt;&lt;br /&gt;&amp;lt;/h:inputText&amp;gt;&lt;br /&gt;&lt;br /&gt;is equivalent to this:&lt;br /&gt;&lt;br /&gt;&amp;lt;a4j:region&amp;gt;&lt;br /&gt;&amp;lt;h:inputText value=”#{profile.age}”&amp;gt;&lt;br /&gt;&amp;lt;a4j:support event=”onblur” reRender=”userInfo”&amp;gt;&lt;br /&gt;&amp;lt;/h:inputText&amp;gt;&lt;br /&gt;&amp;lt;/a4j:region&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;*********&lt;span style="font-weight: bold;"&gt;a4j:support&lt;/span&gt;****************&lt;br /&gt;----------------------------------------&lt;br /&gt;JavaScript Interactions&lt;br /&gt;Although RichFaces shields you from writing JavaScript, sometimes you&lt;br /&gt;might want to invoke a custom JavaScript function. Injecting custom&lt;br /&gt;JavaScript is possible by using the following attributes on components that&lt;br /&gt;initiate an Ajax request:&lt;br /&gt;- onsubmit: Just before Ajax request is sent&lt;br /&gt;- onbeforedomupdate: Before any DOM updates are processed&lt;br /&gt;- oncomplete: After DOM updates have been processed&lt;br /&gt;&lt;br /&gt;-----------------------&lt;br /&gt;Using bypassUpdates&lt;br /&gt;When just validating form values, set bypassUpdates="true". When set&lt;br /&gt;to true, the Update Model and Invoke Application phases will not be&lt;br /&gt;invoked, improving response time.&lt;br /&gt;-------------------------------------------&lt;br /&gt;Using eventsQueue and requestDelay&lt;br /&gt;Use the eventsQueue attribute when possible. When setting&lt;br /&gt;eventsQueue, the next request will not be set until the previous request&lt;br /&gt;comes back (the response). To further control the sending of requests, use&lt;br /&gt;requestDelay to delay the sending of a request by some number of&lt;br /&gt;milliseconds.&lt;br /&gt;--------------------------------------------------------&lt;br /&gt;Another attribute is data, which allows you to get any additional data from&lt;br /&gt;the server during an Ajax request. The data attribute can simply point to a&lt;br /&gt;bean property via EL, and the data will be serialized in JSON format and&lt;br /&gt;available on the client side. Here’s an example:&lt;br /&gt;&amp;lt;a4j:commandButton value="Submit" reRender="out"&lt;br /&gt;data="#{bean.text}"&lt;br /&gt;oncomplete="alert(data)"/&amp;gt;&lt;br /&gt;where text is as follows:&lt;br /&gt;private String text = "Nice, I can get any data from the server";&lt;br /&gt;*********&lt;span style="font-weight: bold;"&gt;/a4j:support&lt;/span&gt;****************&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;Notice that the event on which an&lt;br /&gt;Ajax request is sent is onblur. The onblur event means the user has to tab&lt;br /&gt;out of the current field or click somewhere else using the mouse.&lt;br /&gt;-------------------------------------------------------------------&lt;br /&gt;To show a modal window with a status "Please wait" and block everything in the background, you can do something like this:&lt;br /&gt;&amp;lt;h:form&amp;gt;&lt;br /&gt;&amp;lt;a4j:commandButton actionListener="#{bean.calculate}"&lt;br /&gt;value="Calculate"/&amp;gt;&lt;br /&gt;&amp;lt;/h:form&amp;gt;&lt;br /&gt;&amp;lt;rich:modalPanel id="mp" style="text-align:center"&amp;gt;&lt;br /&gt;&amp;lt;h:outputText value="Please wait..."&lt;br /&gt;style="font-weight:bold;font-size:large"/&amp;gt;&lt;br /&gt;&amp;lt;/rich:modalPanel&amp;gt;&lt;br /&gt;186 Using RichFaces&lt;br /&gt;&amp;lt;a4j:status id="actionStatus"&lt;br /&gt;onstart="#{rich:component('mp')}.show('',{height:'80',&lt;br /&gt;width:'150'})"&lt;br /&gt;onstop="#{rich:component('mp')}.hide()" /&amp;gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-919745765006881241?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/919745765006881241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=919745765006881241' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/919745765006881241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/919745765006881241'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/10/richfaces-32x-useful-tips.html' title='Richfaces 3.2.x useful tips'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-3378245407492288348</id><published>2008-09-27T21:23:00.002+02:00</published><updated>2008-09-27T21:24:09.951+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='second level cache'/><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate'/><title type='text'>How to enable second level caching in Hibernate</title><content type='html'>To enable second level caching in hibernate you can do it two ways:&lt;br /&gt;One of them is by creating a namedQuery and put it as cacheable and then call the namedQuery.&lt;br /&gt;&lt;br /&gt;In your Entity class type&lt;br /&gt;@NamedQueries( { @NamedQuery(name = "findAllDistinctPersons", query = "SELECT DISTINCT p FROM Person p", hints = {&lt;br /&gt;        @QueryHint(name = "org.hibernate.cacheable", value = "true"), @QueryHint(name = "org.hibernate.cacheRegion", value = "alkohol_register") }) })&lt;br /&gt;&lt;br /&gt;Here I have created a NamedQuery called findAllDistinctPerons, and I put hints to be org.hibernate.cacheable as value true. Then you can if you want put a region.&lt;br /&gt;This is optional. This basically means that you can define a region in your configuration file and define which part of the application should use this region.&lt;br /&gt;You should do this if you want some region to be cacheable and some region not to be, but still want to reuse the object.&lt;br /&gt;&lt;br /&gt;The other way is doing it when you are creating the query.&lt;br /&gt;personList = entityManager.createQuery("SELECT DISTINCT p FROM " + Person.class.getName() + " p INNER JOIN p.personAdresseAdressetypes paa " + &lt;br /&gt;"WHERE p.aktiv = " + getSearchAktiv() + " "&lt;br /&gt;+ SearchHelper.getAdresseSearch(getSearchStringAdresse(),true, "paa")).setHint("org.hibernate.cacheable", true).getResultList();&lt;br /&gt;Here you set the Hint directly on the query. Note that we are not defining any region here.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-3378245407492288348?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/3378245407492288348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=3378245407492288348' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3378245407492288348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3378245407492288348'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/09/how-to-enable-second-level-caching-in.html' title='How to enable second level caching in Hibernate'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-452987693230131991</id><published>2008-09-27T21:19:00.003+02:00</published><updated>2008-09-27T21:36:02.012+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JSF'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam'/><category scheme='http://www.blogger.com/atom/ns#' term='EJB3'/><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate'/><title type='text'>Seam, EJB and Hibernate useful tips</title><content type='html'>Here are some tips I have gathered during our Seam project.&lt;br /&gt;&lt;br /&gt;@Create - Signals that this method should be called upon instantiation of the JavaBean.&lt;br /&gt;&lt;br /&gt;@Stateless - Makes an EJB3 object&lt;br /&gt;&lt;br /&gt;@Stateful - (SESSION) Caches in memory between server requests&lt;br /&gt;&lt;br /&gt;@In - These variables will automatically be set by Seam through injection of the variables labeled by the annotation. i.e&lt;br /&gt;String zipCode; (Behind the curtain: zipCode = request.getParameter("zipCode"); )&lt;br /&gt;&lt;br /&gt;@Out - Same as above. This variable is also automatically set by Seam. Behind the curtain this variable is set in the HttpSession object.&lt;br /&gt;( request.setAttribute("bestRestaurant", restaurant); )&lt;br /&gt;What you also must remember is that if you want to use the outjected object, you only call it with its name. Not component name first.&lt;br /&gt;i.e. If you stateful session bean is named @Name("someName") and you have a @Out String test, then when you use it in the view, you must write #{test} and not #{someName.test}&lt;br /&gt;You can also say @Out(required = false) which means that the Object can be null. Otherwize it cannot.&lt;br /&gt;&lt;br /&gt;@DataModel annotation exposes an attribute of type java.util.List to the JSF page as an instance of javax.faces.model.DataModel. This allows us to use the list in a JSF &lt;h:datatable&gt; with clickable links for each row. The DataModel is made available in a session context variable named the variable name.&lt;br /&gt;&lt;br /&gt;@PersistenceContext(type=EXTENDED)&lt;br /&gt;EntityManager em;&lt;br /&gt;This stateful bean has an EJB3 extended persistence context. The messages retrieved in the query remain in the managed state as long as the bean exists, so any subsequent method calls to the stateful bean can update them without needing to make any explicit call to the EntityManager.&lt;br /&gt;Remember, its a good idea to clear the entitymanager once in a while if you do lots of searches&lt;br /&gt;&lt;br /&gt;@Factory("messageList")&lt;br /&gt;public void findMessages() {&lt;br /&gt;     messageList = em.createQuery("from Message msg order by msg.datetime desc").getResultList();&lt;br /&gt;}&lt;br /&gt;The first time we navigate to the JSP page, there will be no value in the messageList context variable. The @Factory annotation tells Seam to create an instance of MessageManagerBean and invoke the findMessages() method to initialize the value. We call findMessages() a factory method for messages.&lt;br /&gt;&lt;br /&gt;@Remove&lt;br /&gt;@Destroy&lt;br /&gt;public void destroy() {}&lt;br /&gt;All stateful session bean Seam components must have a method with no parameters marked @Remove that Seam uses to remove the stateful bean when the Seam context ends, and clean up any server-side state.&lt;br /&gt;&lt;br /&gt;@NamedQuery(name="findProeveByAddress",&lt;br /&gt;       query = "SELECT p " +&lt;br /&gt;               "FROM Proeve p, PersonAdresseAdressetype paa "&lt;br /&gt;               + "WHERE paa.person = p.person "&lt;br /&gt;               + "AND (lower(p.person.fornavn) like :fornavn OR lower(p.person.mellomnavn) like :fornavn) "&lt;br /&gt;               + "AND (lower(p.person.etternavn) like :etternavn) "&lt;br /&gt;               + "AND (lower(p.person.foedselsnummer) like :foedselsnr) "&lt;br /&gt;               + "AND (lower(paa.adresse.adressefelt1) like :adresse) "&lt;br /&gt;               + "AND (lower(p.kommune.navn) like :kommunenavn) "&lt;br /&gt;               + "order by p.person.etternavn, p.avlagt desc"&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;@Lob - Used for storing large string/byte objects. Becomes text or blob.&lt;br /&gt;&lt;br /&gt;Join Fetch - Makes the fetch eager. Be careful using join fetch. What I mean with that is that you should only use fetch when you are going to call methods&lt;br /&gt;on the object being fetched. Otherwize it will be a performance issue.&lt;br /&gt;&lt;br /&gt;@Enumerated(EnumType.STRING) - Makes the enum as string in the database&lt;br /&gt;&lt;br /&gt;&lt;s:fragment&gt;&lt;s:fragment&gt;&lt;h:outputtext value="#{timeList.start} - #{timeList.end}"&gt;&lt;/h:outputtext&gt;@Observer("proeveSearchDirty")&lt;br /&gt;   public void clear() {&lt;br /&gt;       proeveSokList = null;&lt;br /&gt;   }&lt;br /&gt;With the observer annotation you can call on methods by giving it a name from other seam components.&lt;br /&gt;For instance you can raise event which will call the observer method after an persist is made&lt;br /&gt;&lt;br /&gt;@RaiseEvent("proeveSearchDirty")&lt;br /&gt;public String persist() {&lt;br /&gt;   return super.persist();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;If you want to override the default "Successfully created/updated/removed" from Seam and your EntityHome objects, then you can either override the methods&lt;br /&gt;in the Home class. i.e&lt;br /&gt;@Override&lt;br /&gt;public String getCreatedMessage() {&lt;br /&gt;   return "Saved";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@Override&lt;br /&gt;public String getUpdatedMessage() {&lt;br /&gt;   return "Updated";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@Override&lt;br /&gt;public String getDeletedMessage() {&lt;br /&gt;   return "Removed";&lt;br /&gt;}&lt;br /&gt;Or you can put it in the messages.properties file with the notation:&lt;br /&gt;*EntityName*.created. For instance:&lt;br /&gt;Adresse_created=Lagret&lt;br /&gt;Adresse_updated=Oppdatert&lt;br /&gt;Adresse_deleted=Slettet&lt;br /&gt;The messages.properties will be the default even if you have overrided the methods in your Home objects.&lt;/s:fragment&gt;&lt;/s:fragment&gt;&lt;/h:datatable&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-452987693230131991?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/452987693230131991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=452987693230131991' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/452987693230131991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/452987693230131991'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/09/seam-ejb-and-hibernate-useful-tips.html' title='Seam, EJB and Hibernate useful tips'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-3649301814239467627</id><published>2008-09-02T11:24:00.005+02:00</published><updated>2008-09-02T20:41:56.117+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='EJB3'/><category scheme='http://www.blogger.com/atom/ns#' term='JPA'/><title type='text'>Deleted entity passed to persist exception</title><content type='html'>Deleting an entity was seemingly more difficult than I thought.&lt;br /&gt;I thought that I could just loop through a list, find the objects I wanted to delete and just delete them.&lt;br /&gt;&lt;br /&gt;Look at this block of code:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;List&lt;relasjon&gt; relasjoner = entityManager.createQuery(&lt;/relasjon&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                "SELECT rel FROM " + Relasjon.class.getName() + " rel " + "WHERE rel.personA.personId = " + personb.getPersonId()&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                        + " OR rel.personB.personId = " + personb.getPersonId()).getResultList();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;for (Relasjon rel : relasjoner) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    if((rel.getPersonB().getPersonId().equals(personb.getPersonId()) || rel.getPersonA().getPersonId().equals(personb.getPersonId()))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;                // Time to remove&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                log.debug("Going to remove this relasjon with id: " + rel.getRelasjonId());&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;entityManager.remove(rel);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;The line entityManager.remove(rel) gave me a "Deleted entity passed to persist" exception with Relasjon&lt;#null&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;After some Googling I found out that I had to add these two lines before trying to remove the entity:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;font-family:courier new;" &gt;rel.getPersonA().getRelasjonsForPersonA().remove(rel);&lt;/span&gt;&lt;span style="font-family: courier new;font-family:arial;" &gt;&lt;br /&gt;rel.getPersonB().getRelasjonsForPersonB().remove(rel);&lt;/span&gt; &lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;getRelasjonsForPersonA() is a Set&lt;relasjon&gt; of persons.&lt;br /&gt;So I have to remove all the references to a Relasjon first before deleting the entity, and then no more exception.&lt;/relasjon&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-3649301814239467627?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/3649301814239467627/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=3649301814239467627' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3649301814239467627'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3649301814239467627'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/09/deleted-entity-passed-to-persist.html' title='Deleted entity passed to persist exception'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-7672317806572108985</id><published>2008-08-28T21:21:00.005+02:00</published><updated>2008-08-28T22:12:38.250+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Comment'/><title type='text'>Enabled commenting on my blogs</title><content type='html'>I decided to enable commenting on my blogs.&lt;br /&gt;I dont know why I havent done this earlier, but anyways, never to late. So if you have something to say or a question, please comment the blog and I will answer ASAP.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-7672317806572108985?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/7672317806572108985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=7672317806572108985' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7672317806572108985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7672317806572108985'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/08/enabled-commenting-on-my-blogs.html' title='Enabled commenting on my blogs'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-7704789579742527975</id><published>2008-08-28T21:21:00.004+02:00</published><updated>2008-08-28T21:51:23.811+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu hardy'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows vista'/><title type='text'>Ubuntu Hardy for parents</title><content type='html'>&lt;p&gt;A few months ago I installed Ubuntu Hardy on my newly purchased HP laptop for my mom. My parents have no clue with using computers and I was fed up with frequent calls about viruses, slow computer and stuff like that. Obviously they used Windows XP, so when my mom announced she wanted a new laptop I installed a dual boot for her. She didn't want to only have Ubuntu because she was sceptic, which I can understand. I asked my step dad if he wanted me to do the same for his laptop, but he respectfully declined.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;However after a few months of using Ubuntu my mom really loves it. I no more get calls with virus, slow computer, and other miscellaneous windows stuff. They especially love the games that come out of the box on Ubuntu, and now my step dad has asked me to install Ubuntu on his laptop as well :-)&lt;/p&gt;&lt;p&gt;My mom is still using Vista once in a while for stuff that is not working out of the box on Ubuntu, such as copying pictures and videoes from her Nokia to the computer. But when I fix these small issues that come along, then hopefully she will one day convert totally and never use Windows Vista again.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-7704789579742527975?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/7704789579742527975/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=7704789579742527975' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7704789579742527975'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7704789579742527975'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/08/ubuntu-hardy-for-parents.html' title='Ubuntu Hardy for parents'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-3817423324292404311</id><published>2008-08-22T15:25:00.007+02:00</published><updated>2008-08-22T15:43:52.055+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Jasypt'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Encryption'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam'/><title type='text'>Using Encryption (Jasypt) in Seam 2.0 and how to search on encrypted values</title><content type='html'>In our project we had to encrypt all fields in the person table that can identify a person.&lt;br /&gt;I found a nice framework that makes encryption quite easy called &lt;a href="http://jasypt.org"&gt;Jasypt&lt;/a&gt; and more specifically, it had very nice and easy configuration for Seam 2, which can be found here: &lt;a href="http://www.jasypt.org/seam2.html"&gt;Jasypt with Seam 2&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The problem however is that all our searches that we had created for the person fields that are now encrypted fail. For obvious reasons, you cannot compare (run LIKE) on encrypted fields. &lt;br /&gt;But the user demanded to still be able to filter the search based on the encrypted values. &lt;br /&gt;There are two theories on how I could do this.&lt;br /&gt;&lt;br /&gt;The first, was to encrypt the user input and then try to find a match against the encrypted fields. However since Jasypt uses SALT I cannot easily do this because SALT generates x amount of random bytes and makes two equal values different chipertext. So to solve that I would have to remove the SALT and do the comparing. However we have very little time to solve this, so I went with the second option which I really wanted to avoid.&lt;br /&gt;&lt;br /&gt;What I do know is create a query based on the values that are not encrypted and return the List. However, it is not certain that the user will enter one of the values that is not encrypted, so the search will then retrieve all Person objects, and then I loop through the List, decrypt the values (which Jasypt automatically does) and compare against what the user has inputted in the search criteria and then return the correct list.&lt;br /&gt;This is a very cumbersome method to retrieve the List. Having all the Person objects in memory is not feasible. I will have to add some sort of caching so that it at least will be better when it is in production, but still this is something I would like to avoid. (Yes I know I have all the objects decrypted in the memory/cache, but I don't see any other solution)&lt;br /&gt;&lt;br /&gt;If anyone has other ideas on how could be solved, then please leave a comment or contact me.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-3817423324292404311?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/3817423324292404311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=3817423324292404311' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3817423324292404311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3817423324292404311'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/08/using-encryption-jasypt-in-seam-20-and.html' title='Using Encryption (Jasypt) in Seam 2.0 and how to search on encrypted values'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-9174886378519744550</id><published>2008-07-04T21:38:00.002+02:00</published><updated>2008-07-04T21:43:10.594+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='firefox'/><title type='text'>How to change the language of your Firefox</title><content type='html'>I have installed ubuntu on a HP Compaq 6910p for my mom. She is not so fluent in english, so she wanted everything in Norwegian. I thought first that it would be easy to install firefox in norwegian. Boy was I wrong. Yes, I can easily download firefox in the language I wanted, but I wanted to modify the already existing mozilla firefox that was in Ubuntu Hardy Heron. This because all the plugins and whatnot was already installed for me.&lt;br /&gt;&lt;br /&gt;Anyways, about two days worth of Googling, and I found a way.&lt;br /&gt;What you need to do is go to this page:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://releases.mozilla.org/pub/mozilla.org/firefox/releases/"&gt;http://releases.mozilla.org/pub/mozilla.org/firefox/releases/ &lt;/a&gt;&lt;br /&gt;Then you want to find your version of firefox, choose xpi, and then the language you want for firefox, and voilla! Enjoy...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-9174886378519744550?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/9174886378519744550/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=9174886378519744550' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/9174886378519744550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/9174886378519744550'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/07/how-to-change-language-of-your-firefox.html' title='How to change the language of your Firefox'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-4369977615303879088</id><published>2008-07-04T10:47:00.008+02:00</published><updated>2008-07-04T21:51:21.499+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='UTF-8'/><category scheme='http://www.blogger.com/atom/ns#' term='persistence.xml'/><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='InnoDB'/><title type='text'>Generating InnoDB engine and UTF-8 for MySQL using hibernate</title><content type='html'>I found these blogs:&lt;br /&gt;&lt;a href="http://blog.tremend.ro/2007/08/14/how-to-set-the-default-charset-to-utf-8-for-create-table-when-using-hibernate-with-java-persistence-annotations"&gt;&lt;br /&gt;http://blog.tremend.ro/2007/08/14/how-to-set-the-default-charset-to-utf-8-for-create-table-when-using-hibernate-with-java-persistence-annotations&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;and&lt;br /&gt;&lt;br /&gt;&lt;a href="http://neoexpedition.wordpress.com/2007/11/01/persisting-japanese-characters-in-db-using-hibernate"&gt;http://neoexpedition.wordpress.com/2007/11/01/persisting-japanese-characters-in-db-using-hibernate&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;They had the same problem as me, on how to generate InnoDB engine and UTF-8 for MySQL through hibernate.&lt;br /&gt;&lt;br /&gt;This is the solution for doing it:&lt;br /&gt;&lt;br /&gt;In persistence.xml or hibernate.cfg.xml (depending on what you are using), you add this line to get InnoDB as engine.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&amp;#60;property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/&amp;#62;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&amp;#60;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"&amp;#62;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;if you are using MySQL 4.x.&lt;br /&gt;&lt;br /&gt;To get utf8 as default charset, you have to create the database as default charset utf8 and hibernate will do that automatically for you.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;create database foo default charset utf8;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-4369977615303879088?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/4369977615303879088/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=4369977615303879088' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/4369977615303879088'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/4369977615303879088'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/07/generating-innodb-engine-and-utf-8-for.html' title='Generating InnoDB engine and UTF-8 for MySQL using hibernate'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-8934508434120584746</id><published>2008-06-15T16:50:00.000+02:00</published><updated>2008-06-15T16:51:17.648+02:00</updated><title type='text'>Cities I have visited</title><content type='html'>&lt;div id="ta_travelmap" style="width:430px;"&gt;&lt;br /&gt;&lt;img src="http://www.tripadvisor.com/CommunityMapImage?id=17128647&amp;type=TRIPADVISOR&amp;size=LARGE"&gt;&lt;br /&gt;&lt;ol id="ta_favoritelist"&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.tripadvisor.com/Tourism-g293999-Tehran-Vacations.html"&gt;Tehran, Iran&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.tripadvisor.com/Tourism-g32655-Los_Angeles_California-Vacations.html"&gt;Los Angeles, CA, USA&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://las-vegas-hotels.tripadvisor.com/Tourism-g45963-Las_Vegas_Nevada-Vacations.html"&gt;Las Vegas, NV, USA&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.tripadvisor.com/Tourism-g60763-New_York_City_New_York-Vacations.html"&gt;New York City, NY, USA&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;ul id="ta_links"&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.tripadvisor.com/members/cash1981"&gt;View my profile&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create your own &lt;a href="http://www.tripadvisor.com/MemberProfile-cpt" style="font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#3860B0; text-decoration:none;"&gt;travel map&lt;/a&gt; or &lt;a href="http://www.travelpod.com/" style="font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#3860B0; text-decoration:none;"&gt;travel blog&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.tripadvisor.com/"&gt;Visit TripAdvisor.com&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;script src="http://www.tripadvisor.com/MapEmbed?mid=17128647&amp;frm=fb"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-8934508434120584746?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/8934508434120584746/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=8934508434120584746' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/8934508434120584746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/8934508434120584746'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/06/cities-i-have-visited.html' title='Cities I have visited'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-7167610180582775886</id><published>2008-05-23T22:30:00.000+02:00</published><updated>2008-05-23T15:40:25.176+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tehran'/><category scheme='http://www.blogger.com/atom/ns#' term='Iran'/><title type='text'>Visiting Iran first time in 21 years (part 2)</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_nbzuXQmcHXc/SB9vJjKZW-I/AAAAAAAAAB4/rnY_qxss1UM/s1600-h/IMG_0005.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://1.bp.blogspot.com/_nbzuXQmcHXc/SB9vJjKZW-I/AAAAAAAAAB4/rnY_qxss1UM/s200/IMG_0005.jpg" alt="" id="BLOGGER_PHOTO_ID_5196994704857193442" border="0" /&gt;&lt;/a&gt;Heading back from where I used to live, it was time for dinner. My aunt had made a list of all the food she knew to be good, and wanted me to choose which ones I liked. Mmmm. In hindsight, I shouldn't have eaten that much. I did gain a few kilos in the short period I was there :-D&lt;br /&gt;Oh well....&lt;br /&gt;&lt;br /&gt;Food like "Fesenghon", "Ghormesabsi", "Mirza Ghasemi", "Joje kabab", "Cholo kabab" and more are all coming back to me...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Party party party&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nbzuXQmcHXc/SB9xSDKZW_I/AAAAAAAAACA/tUtOwCF9xiw/s1600-h/CIMG1146.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://3.bp.blogspot.com/_nbzuXQmcHXc/SB9xSDKZW_I/AAAAAAAAACA/tUtOwCF9xiw/s200/CIMG1146.JPG" alt="" id="BLOGGER_PHOTO_ID_5196997049909337074" border="0" /&gt;&lt;/a&gt;My cousin Bashir, on the left here, through a party for me and invited some of his friends. Now I don't want to say too much, but it was a pretty cool party, much like the ones we have here in Norway if you know what I mean.&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nbzuXQmcHXc/SB9x5DKZXAI/AAAAAAAAACI/Ah-yUQDP_EY/s1600-h/CIMG1128.JPG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://3.bp.blogspot.com/_nbzuXQmcHXc/SB9x5DKZXAI/AAAAAAAAACI/Ah-yUQDP_EY/s200/CIMG1128.JPG" alt="" id="BLOGGER_PHOTO_ID_5196997719924235266" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;But one thing that can never prepare you was the smoking. The house was filled with smoke.  I had to go out and take fresh air every 10 minutes.&lt;br /&gt;Not much more happened that evening. We ended the party quite early and went home singing in the car.&lt;br /&gt;Here is a short video clip from that car...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The days that followed was spent on sightseeing in Tehran. I went to a big museum, which is a park and some castles of the old palace from the Shah time, plus some other cool stuff.&lt;br /&gt;Here is some pictures from inside and outside of the museum.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nbzuXQmcHXc/SDbFzoQjgPI/AAAAAAAAADM/rWT9nq0yCCo/s1600-h/IMG_0031.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://2.bp.blogspot.com/_nbzuXQmcHXc/SDbFzoQjgPI/AAAAAAAAADM/rWT9nq0yCCo/s320/IMG_0031.JPG" alt="" id="BLOGGER_PHOTO_ID_5203563910244040946" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nbzuXQmcHXc/SDbGmIQjgUI/AAAAAAAAAD0/fFF5z6Y7xI0/s1600-h/IMG_0032.JPG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://4.bp.blogspot.com/_nbzuXQmcHXc/SDbGmIQjgUI/AAAAAAAAAD0/fFF5z6Y7xI0/s320/IMG_0032.JPG" alt="" id="BLOGGER_PHOTO_ID_5203564777827434818" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;These pictures are taken from outside of the museum. You can see the old cars which was used back during the Shah times.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_nbzuXQmcHXc/SDbGSYQjgRI/AAAAAAAAADc/QexuNdN-M6Y/s1600-h/IMG_0038.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://1.bp.blogspot.com/_nbzuXQmcHXc/SDbGSYQjgRI/AAAAAAAAADc/QexuNdN-M6Y/s320/IMG_0038.JPG" alt="" id="BLOGGER_PHOTO_ID_5203564438525018386" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nbzuXQmcHXc/SDbGeIQjgTI/AAAAAAAAADs/nK-GynLJUfk/s1600-h/IMG_0048.JPG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://4.bp.blogspot.com/_nbzuXQmcHXc/SDbGeIQjgTI/AAAAAAAAADs/nK-GynLJUfk/s320/IMG_0048.JPG" alt="" id="BLOGGER_PHOTO_ID_5203564640388481330" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;These pictures are from inside of the castle. The rugs are hand made the one on the left was huge!&lt;br /&gt;&lt;br /&gt;We also went to another castle where one could see The Marble Throne terrace. &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nbzuXQmcHXc/SDbE14QjgNI/AAAAAAAAAC8/rk8yjPsid2U/s1600-h/IMG_0097.JPG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://3.bp.blogspot.com/_nbzuXQmcHXc/SDbE14QjgNI/AAAAAAAAAC8/rk8yjPsid2U/s320/IMG_0097.JPG" alt="" id="BLOGGER_PHOTO_ID_5203562849387118802" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;It was a place where the former King used to receive gifts among other things when visitors came. There was also other gifts from Kings, Queens and other royalty as well as countries in one of the museums.&lt;br /&gt;&lt;br /&gt;The king used to sit up on the throne and people would come from both sides and give gifts.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_nbzuXQmcHXc/SDbFSYQjgOI/AAAAAAAAADE/IpMnhj9qFgo/s1600-h/IMG_0106.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://1.bp.blogspot.com/_nbzuXQmcHXc/SDbFSYQjgOI/AAAAAAAAADE/IpMnhj9qFgo/s200/IMG_0106.JPG" alt="" id="BLOGGER_PHOTO_ID_5203563339013390562" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here is right outside of the throne.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;to be continued....&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-7167610180582775886?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/7167610180582775886/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=7167610180582775886' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7167610180582775886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7167610180582775886'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/05/visiting-iran-first-time-in-21-years_05.html' title='Visiting Iran first time in 21 years (part 2)'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_nbzuXQmcHXc/SB9vJjKZW-I/AAAAAAAAAB4/rnY_qxss1UM/s72-c/IMG_0005.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-8499917424224635451</id><published>2008-05-07T11:19:00.002+02:00</published><updated>2008-12-03T12:46:55.464+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='MyISAM'/><category scheme='http://www.blogger.com/atom/ns#' term='seam-gen'/><category scheme='http://www.blogger.com/atom/ns#' term='Seam'/><title type='text'>Seam-gen problems when having MyISAM as engine in MySQL</title><content type='html'>I tried running seam-gen on an existing MySQL database, where the engine is MyISAM.&lt;br /&gt;Jboss-seam-2.0.1.GA is the version of seam I was running.&lt;br /&gt;&lt;br /&gt;The strangest thing happened. When I reversed engineered the database to create entity beans, the foreign keys where not Objects like it is normally, but rather String.&lt;br /&gt;For instance, in our Address entity bean, I have a foreign key that is mapped to the Country entity bean.&lt;br /&gt;Normally the Address.java should look something like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:webdings;"&gt;&lt;span style="font-family:courier new;"&gt;@Entity&lt;br /&gt;@Table(name = "address")&lt;br /&gt;public class Address implements java.io.Serializable {&lt;br /&gt;&lt;br /&gt;private Integer addressId;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt; //The ID&lt;/span&gt;&lt;br /&gt;     &lt;span style="font-style: italic;font-family:webdings;"&gt;&lt;span style="font-family:courier new;"&gt;private Country country;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt; //The foreign key&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;....&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;However, the foreign key was generated like this:&lt;br /&gt;&lt;span style="font-style: italic;font-family:webdings;"&gt;&lt;span style="font-family:courier new;"&gt;private String countryId;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt; //The foreign key&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But when I changed the MySQL engine to use InnoDB instead, and I ran a new seam-gen, it was generated correctly.&lt;br /&gt;&lt;br /&gt;Just a heads up if someone encounters the same problem. I would guess it is a bug in either seam or hibernate. Probably hibernate, since it is hibernate that does the generation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-8499917424224635451?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/8499917424224635451/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=8499917424224635451' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/8499917424224635451'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/8499917424224635451'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/05/seam-gen-problems-when-having-myisam-as.html' title='Seam-gen problems when having MyISAM as engine in MySQL'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-7216033455493287058</id><published>2008-05-05T02:36:00.000+02:00</published><updated>2008-05-05T03:28:58.508+02:00</updated><title type='text'>Visiting Iran first time in 21 years</title><content type='html'>I recently went to Iran for the first time in 21 years. Back to the "motherland". It was a great experience, one which I had been looking for, for many years.&lt;br /&gt;&lt;br /&gt;I took the flight from Oslo to Amsterdam, and from Amsterdam to Tehran (Emam Khomeni Aiport). Typical my luck, KLM managed to forget my bags, so I was without a suitcase for a couple of days. I forgot to complaint to get some kind of compensation. Oh well....&lt;br /&gt;&lt;br /&gt;I was greeted in the airport from my cousins with their better half's. It was a bit strange to meet them for the first time in 21 years, but that feeling was quickly vanished when I said my hellos and the hugs where given. My farsi, from what I believe isn't that good, but they were very astonished that I spoke so well. They imagined that they would have to use sign language or try to translate half of the words in english :-)&lt;br /&gt;&lt;br /&gt;In the car driving to my aunts apartment, they put on a cd which they had found for me. The guy was singing "My name is Shervin", and it was pretty fun. They never did managed to find that CD again, because I was imagining myself driving around in Oslo with my new ride pumping the volume with "Esme man Shervin'e", which is translated my name is Shervin. Oh well.... :-)&lt;br /&gt;&lt;br /&gt;Before my trip to Iran I had of course heard stories of the infamous traffic. Luck have it seems, I went to Iran during the holidays, so the traffic was non-existent.&lt;br /&gt;Here is a little video from the traffic and other stuff. (Mind the poor quality, it was taking with my camera)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;object width="320" height="266" class="BLOG_video_class" id="BLOG_video-1cce08becdde917f" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"&gt;&lt;param name="movie" value="http://www.youtube.com/get_player"&gt;&lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;param name="allowfullscreen" value="true"&gt;&lt;param name="flashvars" value="flvurl=http://v10.nonxt6.googlevideo.com/videoplayback?id%3D1cce08becdde917f%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1329888428%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D24E5B0AE0A69FC7E557D545C50EF10870796A183.64B7E1515DAC5389DD8CD354B00F218378AD16F%26key%3Dck1&amp;amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3D1cce08becdde917f%26offsetms%3D5000%26itag%3Dw160%26sigh%3D7_aUkaP8685rWdCar-gHAcMv_mQ&amp;amp;autoplay=0&amp;amp;ps=blogger"&gt;&lt;embed src="http://www.youtube.com/get_player" type="application/x-shockwave-flash"width="320" height="266" bgcolor="#FFFFFF"flashvars="flvurl=http://v10.nonxt6.googlevideo.com/videoplayback?id%3D1cce08becdde917f%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1329888428%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D24E5B0AE0A69FC7E557D545C50EF10870796A183.64B7E1515DAC5389DD8CD354B00F218378AD16F%26key%3Dck1&amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3D1cce08becdde917f%26offsetms%3D5000%26itag%3Dw160%26sigh%3D7_aUkaP8685rWdCar-gHAcMv_mQ&amp;autoplay=0&amp;ps=blogger"allowFullScreen="true" /&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;object width="320" height="266" class="BLOG_video_class" id="BLOG_video-ae9a483a8244ccb3" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"&gt;&lt;param name="movie" value="http://www.youtube.com/get_player"&gt;&lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;param name="allowfullscreen" value="true"&gt;&lt;param name="flashvars" value="flvurl=http://v11.nonxt7.googlevideo.com/videoplayback?id%3Dae9a483a8244ccb3%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1329888428%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D30FECCCCF7B3942A8CA33BCD9BE45300545E75F9.1AD788226DB9A081B6D37A5DA00A4EA125FB0EB3%26key%3Dck1&amp;amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3Dae9a483a8244ccb3%26offsetms%3D5000%26itag%3Dw160%26sigh%3DiMkfmmk8N7BNVczliQssDXTY8X0&amp;amp;autoplay=0&amp;amp;ps=blogger"&gt;&lt;embed src="http://www.youtube.com/get_player" type="application/x-shockwave-flash"width="320" height="266" bgcolor="#FFFFFF"flashvars="flvurl=http://v11.nonxt7.googlevideo.com/videoplayback?id%3Dae9a483a8244ccb3%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1329888428%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D30FECCCCF7B3942A8CA33BCD9BE45300545E75F9.1AD788226DB9A081B6D37A5DA00A4EA125FB0EB3%26key%3Dck1&amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3Dae9a483a8244ccb3%26offsetms%3D5000%26itag%3Dw160%26sigh%3DiMkfmmk8N7BNVczliQssDXTY8X0&amp;autoplay=0&amp;ps=blogger"allowFullScreen="true" /&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;The first day my two cousins Hanieh and Hedieh, took me to the place where I grew up in Tehran. This is the place where I spent my first 5 years of my life. And this is how it looked like:&lt;br /&gt;&lt;br /&gt;&lt;object width="320" height="266" class="BLOG_video_class" id="BLOG_video-9792fefe4f0c13d8" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"&gt;&lt;param name="movie" value="http://www.youtube.com/get_player"&gt;&lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;param name="allowfullscreen" value="true"&gt;&lt;param name="flashvars" value="flvurl=http://v5.nonxt6.googlevideo.com/videoplayback?id%3D9792fefe4f0c13d8%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1329888428%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D61B2777CFE84F9AA82F9409A732EC3F7FA4ED72B.27249F0F2008D856F6480C377F4291F2B1331C63%26key%3Dck1&amp;amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3D9792fefe4f0c13d8%26offsetms%3D5000%26itag%3Dw160%26sigh%3DH7kGym6L9_9dFwTwab_TI06mzrk&amp;amp;autoplay=0&amp;amp;ps=blogger"&gt;&lt;embed src="http://www.youtube.com/get_player" type="application/x-shockwave-flash"width="320" height="266" bgcolor="#FFFFFF"flashvars="flvurl=http://v5.nonxt6.googlevideo.com/videoplayback?id%3D9792fefe4f0c13d8%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1329888428%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D61B2777CFE84F9AA82F9409A732EC3F7FA4ED72B.27249F0F2008D856F6480C377F4291F2B1331C63%26key%3Dck1&amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3D9792fefe4f0c13d8%26offsetms%3D5000%26itag%3Dw160%26sigh%3DH7kGym6L9_9dFwTwab_TI06mzrk&amp;autoplay=0&amp;ps=blogger"allowFullScreen="true" /&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;To be continued...&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-7216033455493287058?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='enclosure' type='video/mp4' href='http://www.blogger.com/video-play.mp4?contentId=1cce08becdde917f&amp;type=video%2Fmp4' length='0'/><link rel='enclosure' type='video/mp4' href='http://www.blogger.com/video-play.mp4?contentId=9792fefe4f0c13d8&amp;type=video%2Fmp4' length='0'/><link rel='enclosure' type='video/mp4' href='http://www.blogger.com/video-play.mp4?contentId=ae9a483a8244ccb3&amp;type=video%2Fmp4' length='0'/><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/7216033455493287058/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=7216033455493287058' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7216033455493287058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/7216033455493287058'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/05/visiting-iran-first-time-in-21-years.html' title='Visiting Iran first time in 21 years'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429877696364208688.post-3281772241206434657</id><published>2008-04-28T10:01:00.000+02:00</published><updated>2008-05-07T11:35:21.786+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='JavaOne'/><title type='text'>No JavaOne for me</title><content type='html'>I was planning to go to JavaOne in San Francisco this year, but my manager gave me the thumbs down the last minute. We have recently won a contract from the Kommuneforlaget, and we are going to work on an electronic application for alcohol serving. They need me on the team ASAP so I can't go :-(&lt;br /&gt;&lt;br /&gt;I had ordered the ticket and everything. Anyways, I'm glad to be on the team, it looks like a really cool project where we are going to use JBoss, RHEL, JBoss JBPM, Seam, Mule or JBoss ESB and other cool stuff.&lt;br /&gt;&lt;br /&gt;So 1. may is the date I will start working with the Linpro team...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429877696364208688-3281772241206434657?l=shervinasgari.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shervinasgari.blogspot.com/feeds/3281772241206434657/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2429877696364208688&amp;postID=3281772241206434657' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3281772241206434657'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429877696364208688/posts/default/3281772241206434657'/><link rel='alternate' type='text/html' href='http://shervinasgari.blogspot.com/2008/04/no-javaone-for-me.html' title='No JavaOne for me'/><author><name>Shervin Asgari</name><uri>http://www.blogger.com/profile/01834844003287589312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp2.blogger.com/_nbzuXQmcHXc/SBWGFjKZW4I/AAAAAAAAABI/h-g6N93fEPM/S220/shervin.jpg'/></author><thr:total>0</thr:total></entry></feed>
