<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-3646845225376270865</atom:id><lastBuildDate>Fri, 27 Feb 2026 20:41:59 +0000</lastBuildDate><category>linux</category><category>server</category><category>ubuntu</category><category>javafx</category><category>jsf2</category><category>review</category><category>jsf</category><category>test</category><category>testng</category><category>geecon</category><category>java</category><category>java4people</category><category>javafx tutorial</category><category>junit</category><category>konferencja</category><category>mockito</category><category>narzędzia</category><category>recenzja</category><category>subversion</category><category>szjug</category><category>testing</category><category>testowanie</category><category>warsjawa</category><category>2009</category><category>64 bit</category><category>JavaFX in Action</category><category>Real World Java EE Patterns Rethinking Best Practices</category><category>ajax</category><category>android</category><category>bash</category><category>bazy danych</category><category>binding</category><category>ci</category><category>clockingIT</category><category>cloud</category><category>cloudbees</category><category>coderetreat events</category><category>component</category><category>couchdb</category><category>cross</category><category>cross-field</category><category>cross-field validation</category><category>database</category><category>date</category><category>datetime</category><category>encode movie</category><category>field</category><category>filip pająk</category><category>filus</category><category>firefox</category><category>flash</category><category>flash scope</category><category>functions</category><category>git</category><category>google gadget</category><category>gwt</category><category>h2</category><category>heroku</category><category>hg-login</category><category>hosting</category><category>hudson</category><category>j2me</category><category>j2me on android</category><category>javaexpress</category><category>javafx String</category><category>javafx types</category><category>javascript</category><category>jenkins</category><category>jme</category><category>jme on android</category><category>joda</category><category>jpa</category><category>magazine</category><category>mail</category><category>make ubuntu faster</category><category>maven</category><category>mercurial</category><category>meteo.pl</category><category>mock</category><category>mocking</category><category>mysql</category><category>netbeans day</category><category>partial mocks</category><category>play</category><category>plugin</category><category>postfix</category><category>postgres</category><category>prawa do pliku</category><category>przeszczep szpiku kostnego</category><category>puzzle</category><category>repozytorium</category><category>rsync</category><category>ruby</category><category>samba</category><category>scala</category><category>script</category><category>seam</category><category>skrypt</category><category>spock</category><category>svn</category><category>template</category><category>tests</category><category>time</category><category>tokengsm</category><category>training</category><category>transaction isolation</category><category>tutorial</category><category>uibinder</category><category>upload</category><category>validation</category><category>warsjawa 2010</category><category>warsjawa 2011</category><category>zarządzanie</category><category>zostań dawcą szpiku</category><title>Java, the Programming, and Everything</title><description></description><link>http://pawelstawicki.blogspot.com/</link><managingEditor>noreply@blogger.com (pawelstawicki)</managingEditor><generator>Blogger</generator><openSearch:totalResults>65</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-7433702663765351429</guid><pubDate>Fri, 20 Mar 2015 18:56:00 +0000</pubDate><atom:updated>2015-03-20T19:56:42.072+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">database</category><category domain="http://www.blogger.com/atom/ns#">h2</category><category domain="http://www.blogger.com/atom/ns#">testing</category><category domain="http://www.blogger.com/atom/ns#">tests</category><title>Browse H2 in-memory database in tests</title><description>&lt;p&gt;If you sometimes want to look into H2 tables during the test, there is a problem, because by default in-memory H2 database is accessible only from the process where it was created. Simple way to browse the data looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Server.createWebServer().start()
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It starts the web server on port 8082, so you can connect there, enter DB url, username and password (usually username and password are empty, you don’t need to protect your in-memory test database, do you?) and voila! You can browse the data.&lt;/p&gt;

&lt;p&gt;Just remember to put some breakpoint in the test code, because after the test the process is finished, and so is the server. Another thing to remember is to set the breakpoint to stop only current thread, not all threads (like it is by default in Idea), because if you stop all of them, the server one is also stopped :)&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Written with &lt;a href=&quot;https://stackedit.io/&quot;&gt;StackEdit&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;</description><link>http://pawelstawicki.blogspot.com/2015/03/browse-h2-in-memory-database-in-tests.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>6</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-6710942792910693243</guid><pubDate>Thu, 14 Aug 2014 16:17:00 +0000</pubDate><atom:updated>2014-08-14T18:17:54.420+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">git</category><title>Git reset soft/mixed/hard</title><description>&lt;p&gt;What is the difference between git reset soft, mixed and hard? When doing reset in git, you can add &lt;code&gt;--soft&lt;/code&gt;, &lt;code&gt;--mixed&lt;/code&gt; or &lt;code&gt;--hard&lt;/code&gt; switch, or leave it, &lt;code&gt;--mixed&lt;/code&gt; is the default. What do this switches do?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Code before changes         &lt;/li&gt;
&lt;li&gt;Code after changes&lt;/li&gt;
&lt;li&gt;Changes staged on index&lt;/li&gt;
&lt;li&gt;Changes commited&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now if you issue&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git reset --xxxx HEAD~1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;--soft&lt;/code&gt; moves you back to (3), &lt;code&gt;--mixed&lt;/code&gt; to (2) and &lt;code&gt;--hard&lt;/code&gt; to (1)&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Written with &lt;a href=&quot;https://stackedit.io/&quot;&gt;StackEdit&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;</description><link>http://pawelstawicki.blogspot.com/2014/08/git-reset-softmixedhard.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-2420574161720011605</guid><pubDate>Thu, 10 Jul 2014 22:11:00 +0000</pubDate><atom:updated>2014-08-14T18:33:34.378+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ci</category><category domain="http://www.blogger.com/atom/ns#">cloud</category><category domain="http://www.blogger.com/atom/ns#">cloudbees</category><category domain="http://www.blogger.com/atom/ns#">hosting</category><category domain="http://www.blogger.com/atom/ns#">jenkins</category><category domain="http://www.blogger.com/atom/ns#">server</category><title>Develop, test and deploy standalone apps on CloudBees</title><description>&lt;p&gt;CloudBees is a cloud platform providing repository, CI service (Jenkins) and server for your apps. So everything you need to develop, test and deploy. There are many options, e.g. repository can be Git or SVN, for server you can choose Jetty, Tomcat, Glassfish, JBoss, Wildfly etc. It is also possible to run standalone applications, which are provided with port number, so you can start your own server. And that’s the case we’ll cover here.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;spray.io&quot;&gt;spray.io&lt;/a&gt; is Scala framework for web apps. It allows you to create standalone web-apps (starting their own server, spray-can) or somewhat limited .war ones (spray-servlet), which you can deploy on JEE server like Glassfish, JBoss etc. We are going to use standalone here.&lt;/p&gt;

&lt;p&gt;You can clone the app from &lt;a href=&quot;https://github.com/amorfis/sprayapp&quot;&gt;github&lt;/a&gt; Let’s take a quick look at it now.&lt;/p&gt;

&lt;h1 id=&quot;the-app&quot;&gt;The app&lt;/h1&gt;



&lt;h3 id=&quot;boot&quot;&gt;Boot&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;Boot&lt;/code&gt; file is Scala &lt;code&gt;App&lt;/code&gt;, so it’s like java class with main method. It’s runnable. It creates &lt;code&gt;Service&lt;/code&gt; actor, which is handling all the HTTP requests. It also reads port number from &lt;code&gt;app.port&lt;/code&gt; system property and binds the service to the host and port. &lt;code&gt;app.port&lt;/code&gt; is provided by CloudBees, if you want to run the app locally, you need to set it e.g. by jvm command line &lt;code&gt;-Dapp.port=8080&lt;/code&gt;.&lt;/p&gt;



&lt;h3 id=&quot;service&quot;&gt;Service&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Service&lt;/code&gt; has &lt;code&gt;MyService&lt;/code&gt; trait, which handles routing to empty path only. Yes, the app is not very complicated ;)&lt;/p&gt;



&lt;h3 id=&quot;buildfile&quot;&gt;Buildfile&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;build.gradle&lt;/code&gt; file is a bit more interesting. Let’s start from it’s end. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;mainClassName&lt;/code&gt; attribute is set to Scala App. This is the class that is going to be run when you run it locally from command line by &lt;code&gt;gradlew run&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;&lt;code&gt;applicationDefaultJvmArgs&lt;/code&gt; is set to &lt;code&gt;-Dapp.port=8080&lt;/code&gt; and it’s also necessery for running locally from gradle. This way we set port which &lt;code&gt;Service&lt;/code&gt; is going to be bound to.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;jar.archiveName&lt;/code&gt; is a setting used to set generated .jar name. Without it it’s dependent on the project directory name.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can run the application by issuing &lt;code&gt;gradlew run&lt;/code&gt; (make sure &lt;code&gt;gradlew&lt;/code&gt; file is executable). When it’s running, you can point your browser to &lt;a href=&quot;http://localhost:8080&quot;&gt;http://localhost:8080&lt;/a&gt; and you should see “Say hello to spray-routing on spray-can!” Nothing fancy, sorry.&lt;/p&gt;

&lt;p&gt;There is also “cb” task definde for gradle. If you issue &lt;code&gt;gradlew cb&lt;/code&gt;, it builds zip file, with all the dependency .jars, and &lt;code&gt;szjug-sprayapp-1.0.jar&lt;/code&gt; in it’s root. This layout is necessary for CloudBees stand alone apps.&lt;/p&gt;



&lt;h1 id=&quot;deploy-to-cloudbees&quot;&gt;Deploy to CloudBees&lt;/h1&gt;

&lt;p&gt;First you need to create an account on &lt;a href=&quot;http://www.cloudbees.com/&quot;&gt;CloudBees&lt;/a&gt;. If you have one, download &lt;a href=&quot;http://wiki.cloudbees.com/bin/view/RUN/BeesSDK&quot;&gt;CloudBees SDK&lt;/a&gt; - so you can run commands from your command line. On Mac, I prefer &lt;code&gt;brew install&lt;/code&gt;, but you are free to choose your way.&lt;/p&gt;

&lt;p&gt;When installed, run &lt;code&gt;bees&lt;/code&gt; command. When run for the first time, it asks your login/password, so you don’t need to provide it every time you want to use &lt;code&gt;bees&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Build .zip we’ll deploy to the cloud. Go into the app directory (&lt;code&gt;szjug-sprayapp&lt;/code&gt;) and issue &lt;code&gt;gradlew cb&lt;/code&gt; command. This command not only creates the .zip file, it also prints .jars list useful to pass to bees command as classpath.&lt;/p&gt;

&lt;p&gt;Deploy the application with the following command run from &lt;code&gt;szjug-sprayapp&lt;/code&gt; directory:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;bees app:deploy -a spray-can -t java -R class=pl.szjug.sprayapp.Boot -R classpath=spray-can-1.3.1.jar:spray-routing-1.3.1.jar:spray-testkit-1.3.1.jar:akka-actor_2.10-2.3.2.jar:spray-io-1.3.1.jar:spray-http-1.3.1.jar:spray-util-1.3.1.jar:scala-library-2.10.3.jar:spray-httpx-1.3.1.jar:shapeless_2.10-1.2.4.jar:akka-testkit_2.10-2.3.0.jar:config-1.2.0.jar:parboiled-scala_2.10-1.1.6.jar:mimepull-1.9.4.jar:parboiled-core-1.1.6.jar:szjug-sprayapp-1.0.jar build/distributions/szjug-sprayapp-1.0.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And here abbreviated version for readability:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;bees app:deploy -a spray-can -t java -R class=pl.szjug.sprayapp.Boot -R classpath=...:szjug-sprayapp-1.0.jar build/distributions/szjug-sprayapp-1.0.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;spray-can&lt;/code&gt; is an application name, &lt;code&gt;-t java&lt;/code&gt; is application type. &lt;code&gt;-R&lt;/code&gt; are CloudBees properties, like class to run and classpath to use. Files for classpath are helpfully printed when gradle runs &lt;code&gt;cb&lt;/code&gt; task, so you just need to copy &amp;amp; paste.&lt;/p&gt;

&lt;p&gt;And that’s it! Our application is running on the CloudBees server. It’s accessible at the URL from CloudBees console. &lt;br&gt;
&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaIM_OqEE9nthLEVDcFl3zMruGuINmkV9uYRamI4de0UIKuYdtMznBcW6DOPa3n8Giho2qirjWMoY4gE-ent4z8X7EOmfazPyJOURWrN8GKaaOP-ooLjj1ZHaz_QCGfYcTuXUecYp6RzQC/s0/&quot; alt=&quot;enter image description here&quot; title=&quot;&quot;&gt; &lt;/p&gt;



&lt;h1 id=&quot;use-cloudbees-services&quot;&gt;Use CloudBees services&lt;/h1&gt;

&lt;p&gt;The app is deployed on CloudBees, but is that all? As I mentioned we could also use git repository and Jenkins. Let’s do it now.&lt;/p&gt;



&lt;h3 id=&quot;repository-git&quot;&gt;Repository (Git)&lt;/h3&gt;

&lt;p&gt;Create new git repository on your CloudBees account. Choose “Repos” on the left, “Add Repository”… it’s all pretty straightforward.  &lt;br&gt;
&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbskHzm93GEocz0V68XXUFneNrHYKP84PBzbnM8htoK25Ndk6nNiIxajshqDHqO_CCWiijSCTHWXwaEAR7ASe7zDcZD1GFnC-dhvbmm4UGdvhgwfChhL_DNs2eDPf_T_VnSnLfisSVL-0-/s0/&quot; alt=&quot;enter image description here&quot; title=&quot;&quot;&gt;&lt;/p&gt;

&lt;p&gt;Name it “szjug-app-repo” and remember it should be Git. &lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_jF8jZH3OSUMP57_-ca_kqvZrBLwUOUOApmovIrcNjS3G-RY4bv78-d8QAX5HfiviB9XEhRb0hwxGbeGtiRtFZknExbQnoB4LHUodvas2-54CjA2fHFX_H_VCb5jCsfYNAJP51ELGdw4Q/s0/&quot; alt=&quot;enter image description here&quot; title=&quot;&quot;&gt;&lt;/p&gt;

&lt;p&gt;Next add this repository as remote one to your local git repo. On the repositories page on your CloudBees console there is very helpful cheetsheet about how to do it. &lt;/p&gt;

&lt;p&gt;First add git remote repository. Let’s name it &lt;code&gt;cb&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git remote add cb ssh://git@git.cloudbees.com/pawelstawicki/szjug-app-repo.git
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then push your commits there:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git push cb master
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now you have your code on CloudBees.&lt;/p&gt;



&lt;h3 id=&quot;ci-build-server-jenkins&quot;&gt;CI build server (Jenkins)&lt;/h3&gt;

&lt;p&gt;It’s time to configure the app build on CI server. Go to “Builds”. This is where Jenkins lives. Create new “free-style” job.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLSFLHlnkNX75H16kbgoI5zzirRsSFlitqKrLu1se3rifS-OkRBNC4JX88EuumKFABz4R3Yz8Z77R9pgAsljd8M2n29QmBAaf_qqs5walO89LnCy0uA86ppPK_PjvEjS_0iImFsnhkrNBm/s0/&quot; alt=&quot;enter image description here&quot; title=&quot;&quot;&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimEyhfhMLLEzMY03HY-oXFUhxQUBnyWCSx63gy8xm1TZIAOb8QMf_AyuJw7bn7szvlZzkaqhD-MyOImponCu22MTr_3Buk1KbpQk3HusrYAaaySTi31RlZpbzhQi7UdNn0xavG9zbWC4lT/s0/&quot; alt=&quot;enter image description here&quot; title=&quot;2014-07-01_2359.png&quot;&gt;&lt;/p&gt;

&lt;p&gt;Set your git repository to the job, so that Jenkins checks out always fresh code version. You’ll need the repository URL. You can take it from “Repos” page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFVHE98hXTUrY2XMM8dPR35g7N35P3rT5hB2uzLjSHWdfRtbPSvN3ed-cRva4aAXDPaJyBlTehVDUyRnK2HTaEmP4UI7EhmgUpe63vZudWd6VjeiQ1tzTfTt60h9hMgYY2xegoUzQ5RRwj/s0/&quot; alt=&quot;enter image description here&quot; title=&quot;&quot;&gt;&lt;/p&gt;

&lt;p&gt;Set the URL here:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEham0kcvKtPu-i6aje1_nImPI9b55BRsriRyAQ2LETkhhDqxzcQGp5xETr4cuJeVyP5cSdLq0Gle784MCrWJ0giko2Vkmb2gzJrW6Z10bLckjPO1lUBVzk-xj8dk1c36W0sxPyc-PDBKo2Y/s0/&quot; alt=&quot;enter image description here&quot; title=&quot;&quot;&gt;&lt;/p&gt;

&lt;p&gt;Next thing to set up is gradle task. Add next build step of type “Invoke gradle script”. Select “Use Gradle Wrapper” - this way you can use gradle version provided with the project. Set “cb” as the gradle task to run.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjuq6yisBzCkrrLCKp6RXhvu61__OsMTG_85vBRDN0NjdMjsm_pwxq55PlBqvU7GlVMyS2UK8p9stuNu9ui5FMToZewAcQ_M6XzFUyuitoI2oHK92QrwalfSsg7duGUtgn9jGjUuiUWXMu/s0/&quot; alt=&quot;enter image description here&quot; title=&quot;gradlew&quot;&gt;&lt;/p&gt;

&lt;p&gt;Well, that’s all you need to have the app built. But we want to deploy it, don’t we? Add post-build action “Deploy applications”. Enter Application ID (&lt;code&gt;spray-can&lt;/code&gt; in our case, region should change automatically). This way we tell Jenkins &lt;em&gt;where&lt;/em&gt; to deploy. It also needs to know &lt;em&gt;what&lt;/em&gt; to deploy. Enter &lt;code&gt;build/distributions/szjug-app-job-*.zip&lt;/code&gt; as “Application file”.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhitGyDQXhmBb7_TugvOL7iGKpTnhlSipMUR6rNDV4VjFOtv2f1sJzZjNYc3Nqq4x_DXUX3-YqAO8HyTRRUOgS8b5Gb1O9y_N-BcTtwzUejrRMd_jGb8lD4Jzo0ySpmr1ZJs9HoyB7ipvon/s0/&quot; alt=&quot;enter image description here&quot; title=&quot;&quot;&gt;&lt;/p&gt;

&lt;p&gt;Because you deployed the application earlier from the command line, settings like application type, main class, classpath etc. are already there and you don’t need to provide it again.&lt;/p&gt;

&lt;p&gt;It might also be useful to keep the zip file from each build, so we can archive it. Just add post-build action “Archive the artifacts” and set the same zip file.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3_GWK3pz3a-Nqe-IVsfrPQLF7sxjHJiOCvOpJVOEw1Jw884ewYja4_boWDMsSbn-2OStaug0ixMu89sS5zlsdHGO-IbvV62eUx65e1grbwi_mCXRjJW8-2r4bTQ4xyY39WE4RMPMT3F39/s0/&quot; alt=&quot;enter image description here&quot; title=&quot;&quot;&gt;&lt;/p&gt;

&lt;p&gt;Ok, that’s all for build configuration on Jenkins. Now you can hit “Build now” link and the build should be added to the queue. When it is finished, you can see the logs, status etc. But what’s more important, the application should be deployed and accessible to the whole world. You can now change something in it, hit “Build now” and after it’s finished, check if the changes are applied.&lt;/p&gt;



&lt;h1 id=&quot;tests&quot;&gt;Tests&lt;/h1&gt;

&lt;p&gt;Probably you also noticed there is a test attached. You can run it by &lt;code&gt;gradlew test&lt;/code&gt;. It’s &lt;a href=&quot;http://etorreborre.github.io/specs2/&quot;&gt;specs2&lt;/a&gt; test, with trait &lt;code&gt;MyService&lt;/code&gt; so we have access to &lt;code&gt;myRoute&lt;/code&gt;, and &lt;code&gt;Specs2RouteTest&lt;/code&gt; so we have access to spray.io testing facilities.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@RunWith(classOf[JUnitRunner])&lt;/code&gt; is necessary to run tests in gradle. &lt;/p&gt;

&lt;p&gt;Now when we have tests, we’d like to see tests results. That’s another post-build step in Jenkins. Press “Add post-build action” -&amp;gt; “Publish JUnit test result report”.&lt;/p&gt;

&lt;p&gt;Gradle doesn’t put test results where maven does, so you’ll need to specify the location of report files.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgduaf4Xx-Bubn03OMpljTH1ytOrEL5GePgabvpmX7nnihIYH9YKKexRKEZEViQlv_GstqlC90_NAp7yb6AxGkgdzHjjjmaQ-qekMjulQmLds_c2-d40soZ7tXnJokQRBR0Vr8F8vv6V0u7/s0/&quot; alt=&quot;enter image description here&quot; title=&quot;publish test results&quot;&gt;&lt;/p&gt;

&lt;p&gt;When it’s done, next build should show test results. &lt;/p&gt;



&lt;h1 id=&quot;trigger-build-job&quot;&gt;Trigger build job&lt;/h1&gt;

&lt;p&gt;You now have build job able to build, test and deploy the application. However, this build is going to run only when you run it by hand. Let’s make it run every day, and after every change pushed to the repository.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7tNpl9ASl8QxwSE9FuryZ00OAF4vjvbCt44ITl9Hc17VFxNaMXfhbN7tC7mwINZV2-2XStpufO2EJLN49FGDGXEP_a47Wq78GxoTK9ZZ2nzwmRKNFvO92YBCFJUww8atStjXWwtE_tsOn/s0/&quot; alt=&quot;enter image description here&quot; title=&quot;&quot;&gt;&lt;/p&gt;



&lt;h1 id=&quot;summary&quot;&gt;Summary&lt;/h1&gt;

&lt;p&gt;So now you have everything necessary to develop an app. Git repository, continous integration build system, and infrastructure to deploy the app to (actually, also continously). &lt;/p&gt;

&lt;p&gt;Think of your own app, and… happy devopsing ;)&lt;/p&gt;</description><link>http://pawelstawicki.blogspot.com/2014/07/develop-test-and-deploy-standalone-apps_11.html</link><author>noreply@blogger.com (pawelstawicki)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaIM_OqEE9nthLEVDcFl3zMruGuINmkV9uYRamI4de0UIKuYdtMznBcW6DOPa3n8Giho2qirjWMoY4gE-ent4z8X7EOmfazPyJOURWrN8GKaaOP-ooLjj1ZHaz_QCGfYcTuXUecYp6RzQC/s72-c/" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-2819137018926414872</guid><pubDate>Sun, 25 May 2014 18:11:00 +0000</pubDate><atom:updated>2014-05-27T16:36:24.514+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">mock</category><category domain="http://www.blogger.com/atom/ns#">mocking</category><category domain="http://www.blogger.com/atom/ns#">spock</category><category domain="http://www.blogger.com/atom/ns#">testing</category><title>Validation of parameter passed to mock call in Spock</title><description>If you use Spock, sometimes you want to check mock method call. You can of course do it like this:&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/amorfis/2d6b883a547a0965edba.js&quot;&gt;&lt;/script&gt;

Problem here is that when the parameter passed to the method is wrong, you won&#39;t know what is wrong with it:&lt;br /&gt;
&lt;pre&gt;Too few invocations for:

1 * service.method({
            it.firstname == &quot;Peter&quot; &amp;amp;&amp;amp; it.surname == &quot;Stawicki&quot;
        })   (0 invocations)

Unmatched invocations (ordered by similarity):

1 * service.method(eu.vegasoft.spocktest.validateparam.Person@40f892a4)
&lt;/pre&gt;
Sometimes we want to validate also parameter passed to the mock method. We can do it like this:&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/amorfis/b8b4a06c2e1dbd7c31f5.js&quot;&gt;&lt;/script&gt;

Now when the passed parameter does not match, we can see exactly what was wrong with it:

&lt;br /&gt;
&lt;pre&gt;Condition not satisfied:

p.firstname == &quot;Peter&quot;
| |         |
| Paweł     false
|           3 differences (40% similarity)
|           P(aw)e(ł)
|           P(et)e(r)
eu.vegasoft.spocktest.validateparam.Person@34b23d12
&lt;/pre&gt;
</description><link>http://pawelstawicki.blogspot.com/2014/05/validation-of-parameter-passed-to-mock.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-478008657127363102</guid><pubDate>Wed, 23 Apr 2014 22:18:00 +0000</pubDate><atom:updated>2014-04-25T19:29:15.281+02:00</atom:updated><title>Do not underestimate the power of the fun</title><description>&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: large;&quot;&gt;Do you like your tools?&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Are you working with the technology, programming language and tools that you like? Are you having fun working with it?&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;When a new project starts, the company has to decide what technologies, frameworks and tools will be used to develop it. Most common sense factor to take into consideration is the tool&#39;s ability to get the job done. However, especially in Java world, usually there is more than one tool &amp;nbsp;able to pass this test. Well, usually there are tens, if not hundreds of them. So another factors have to be used.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The next important and also quite obvious one is how easy the tool is to use, and how fast can we get the job done with it. &quot;Easy&quot; is subjective, and &quot;fast&quot; depends strongly on the tool itself and the environment it is used in. Like the tool&#39;s learning curve or the developers knowledge of it.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;While the developers knowledge of the tool usually is taken into account, their desire to work with it (or not), usually is not. Here I would like to convince you that it is really important too.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: large;&quot;&gt;Known != best&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;There are cases where it&#39;s better to choose &lt;b&gt;cool&lt;/b&gt;&amp;nbsp;tools instead of known ones. Yes, the developers need to learn it, and it obviously costs some time, but I believe it is an investment that pays off later. Especially if alternatives are the ones that the devs are experienced with, but don&#39;t want to use any more. Probably there are some people who like to code in the same language and use the same frameworks for 10 years, but I don&#39;t know many of them. Most of the coders I know like to learn new languages, use new frameworks, tools and libs. Sadly, some of them can&#39;t do it because of corporate policies, customer&#39;s requirements or other restrictions.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Why do I believe such an investment pays off? If you think developer writes 800 LOC/day, so 100 LOC/hour, so 10 LOC/minute... well, you&#39;re wrong. Developers are not machines working with constant speed 9 to 5. Sometimes we are &quot;in the zone&quot;, coding like crazy (let&#39;s leave the code quality aside), sometimes we are creative, working with pen and paper, inventing clever solutions, algorithms etc. and sometimes we are just bored, forcing ourselves to put 15th form on the page or write boilerplate code.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWTgTK3GQdsw42rtwv3NewpKr5mbN_d2hb1ULcID0vstVBwS-YZxWTfF8drchq_XDEX5pi9nDlzDl5NevEhiuu-AkPShtYmVT4hOz46qN5Obg60Zz72ovcJCrNn4mduEznrA_sP8MGA2MC/s1600/bored+orangutan.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWTgTK3GQdsw42rtwv3NewpKr5mbN_d2hb1ULcID0vstVBwS-YZxWTfF8drchq_XDEX5pi9nDlzDl5NevEhiuu-AkPShtYmVT4hOz46qN5Obg60Zz72ovcJCrNn4mduEznrA_sP8MGA2MC/s1600/bored+orangutan.jpg&quot; height=&quot;200&quot; width=&quot;320&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: large;&quot;&gt;The power of fun&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now ask yourself, in which situation you (or your developers) usually find themselves? And if you are often bored, working 5th year with the same technology and tools, think about the times when you were learning it. Remember when you were using it for the first time? Were you bored then? Or rather excited? Were you &lt;b&gt;less productive&lt;/b&gt;? That&#39;s truism, but we are not productive when we need to force ourselves to work. Maybe it&#39;s a good idea to change your work to be more fun? Use some tools you &lt;b&gt;don&#39;t know&lt;/b&gt; (yet), but really want to try? It might seem you are going to be less productive, at least at the beginning, but is it really true? Moreover, if it allows you to write less boilerplate code or closures or anything else that can make you faster and more efficient in the long run, it seems a really good investment.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;There is one more advantage of cool and fun tools. If you are a company owner, do you want your business partners to consider your company expensive but very good, delivering high quality services and worth the price, or not-so-good but cheap? I don&#39;t know any software company that wants the latter. We all want to be good - and earn more, but well deserved, money. Now think about good and best developers - where do they go? Do they choose companies where they have to work with old, boring tools and frameworks? Even when you pay them much, the best devs are not motivated by the money. Probably you know it already. Good devs are the ones that like to learn and discover new stuff. There is no better way to learn new stuff other then working with it. And there are not many things that are as fun for a geek as working with languages, technologies and tools they like.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnadKOOSzZyKTFopyioxVUr41YEmH2ZKMpYgxNHg6AzJfwace7mbX5C_s6TuHdBAUblwTBBUcXTDcVf8Kua-HHcHmiBsgt9YfcFoZfIlKi-2rktyZ6fQOqyvGHWsbLaK7D5cSueXKF05p5/s1600/cool.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnadKOOSzZyKTFopyioxVUr41YEmH2ZKMpYgxNHg6AzJfwace7mbX5C_s6TuHdBAUblwTBBUcXTDcVf8Kua-HHcHmiBsgt9YfcFoZfIlKi-2rktyZ6fQOqyvGHWsbLaK7D5cSueXKF05p5/s1600/cool.jpg&quot; height=&quot;320&quot; width=&quot;320&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;So, when choosing tools for your next project, take fun factor into account. Or even better - let the developers make the choice.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;--&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This presentation might be interesting:&amp;nbsp;&lt;a href=&quot;http://www.infoq.com/presentations/Scala-Guardian&quot;&gt;http://www.infoq.com/presentations/Scala-Guardian&lt;/a&gt; It&#39;s&amp;nbsp;&lt;span style=&quot;background-color: white; line-height: 21px;&quot;&gt;Graham Tackley story about how they introduced Scala in Guardian, and what happened then.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-size: xx-small;&quot;&gt;&lt;span style=&quot;background-color: white; line-height: 21px;&quot;&gt;Cool image courtesy of Łukasz Żuchowski&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;a href=&quot;http://blog.zuchos.com/&quot;&gt;http://blog.zuchos.com&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;</description><link>http://pawelstawicki.blogspot.com/2014/04/do-not-underestimate-power-of-fun.html</link><author>noreply@blogger.com (pawelstawicki)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWTgTK3GQdsw42rtwv3NewpKr5mbN_d2hb1ULcID0vstVBwS-YZxWTfF8drchq_XDEX5pi9nDlzDl5NevEhiuu-AkPShtYmVT4hOz46qN5Obg60Zz72ovcJCrNn4mduEznrA_sP8MGA2MC/s72-c/bored+orangutan.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-5996496497421708214</guid><pubDate>Tue, 22 Jan 2013 21:43:00 +0000</pubDate><atom:updated>2013-01-22T22:43:16.764+01:00</atom:updated><title>Spock testing framework</title><description>&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Some time ago I gave presentation about Spock on &lt;a href=&quot;http://szczecin.jug.pl/&quot; target=&quot;&quot;&gt;Szczecin JUG&lt;/a&gt;. Later I gave this presentation also on my company &lt;a href=&quot;https://softwaremill.com/&quot; target=&quot;&quot;&gt;SoftwareMill&lt;/a&gt; meeting.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I think it&#39;s high time to share it on my blog too:&amp;nbsp;&lt;a href=&quot;http://amorfis.github.com/spock-pres/&quot;&gt;http://amorfis.github.com/spock-pres/&lt;/a&gt; (navigate with arrow keys).&lt;/span&gt;</description><link>http://pawelstawicki.blogspot.com/2013/01/spock-testing-framework.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-508366018539917291</guid><pubDate>Fri, 02 Nov 2012 22:31:00 +0000</pubDate><atom:updated>2012-11-02T23:31:36.456+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">date</category><category domain="http://www.blogger.com/atom/ns#">datetime</category><category domain="http://www.blogger.com/atom/ns#">joda</category><category domain="http://www.blogger.com/atom/ns#">junit</category><category domain="http://www.blogger.com/atom/ns#">test</category><category domain="http://www.blogger.com/atom/ns#">testng</category><category domain="http://www.blogger.com/atom/ns#">testowanie</category><category domain="http://www.blogger.com/atom/ns#">time</category><title>FEST Assertions for Joda Time</title><description>&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Do you write unit tests? Of course you do. Do you use &lt;a href=&quot;http://joda-time.sourceforge.net/&quot;&gt;Joda Time&lt;/a&gt;? I think so. Do you use &lt;a href=&quot;https://github.com/alexruiz/fest-assert-2.x&quot;&gt;FEST Assertions&lt;/a&gt;? You should try it if you haven&#39;t yet. With FEST Assertions we can write fluent code like this:

&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint linenums:1&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;assertThat(result).isEqualTo(expected);
assertThat(testRunSeconds).isLessThan(maxTestRunSeconds);
assertThat(someList).isNotNull().hasSize(3).contains(&quot;expectedEntry&quot;);
&lt;/span&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;

Now let&#39;s assume we have some functions that return joda DateTime, and we want to test it. Can we do this in FEST Assertions?
&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;assertThat(resultDateTime).isAfter(timeframeBeginning).isBefore(timeframeEnd);
&lt;/span&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;No, we can&#39;t :( FEST Assertions don&#39;t handle Joda Time classes. However, do not worry :) At &lt;a href=&quot;http://softwaremill.com/&quot;&gt;SoftwareMill&lt;/a&gt; we have written our own &lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;TimeAssertions&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt; for that :) So you can write your code like this:&lt;/span&gt;

&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;TimeAssertions.assertTime(someTime).isAfterOrAt(someOtherTime);&lt;/span&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;
TimeAssertions works for &lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;org.joda.time.DateTime&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;java.util.Date&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt; and &lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;org.joda.time.LocalDateTime&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;. You can freely exchange DateTime and Date, i.e. you can compare DateTime to Date, DateTime to DateTime etc. LocalDateTime can be compared only to instances of the same class, as it doesn&#39;t make sense to compare it to DateTime or Date without specifying the time zone.

TimeAssertions is available on &lt;a href=&quot;http://github.com/softwaremill/softwaremill-common/tree/master/softwaremill-test/softwaremill-test-util&quot;&gt;github&lt;/a&gt;. If you want to use it from Maven project, add repository:

&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;lt;repository&amp;gt;
    &amp;lt;id&amp;gt;softwaremill-releases&amp;lt;/id&amp;gt;
    &amp;lt;name&amp;gt;SoftwareMill Releases&amp;lt;/name&amp;gt;
    &amp;lt;url&amp;gt;http://tools.softwaremill.pl/nexus/content/repositories/releases&amp;lt;/url&amp;gt;
&amp;lt;/repository&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;And dependency:

&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;lt;dependency&amp;gt;
    &amp;lt;groupId&amp;gt;pl.softwaremill.common&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;softwaremill-test-util&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;70&amp;lt;/version&amp;gt;
&amp;lt;/dependency&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Happy testing!
&lt;/span&gt;</description><link>http://pawelstawicki.blogspot.com/2012/11/fest-assertions-for-joda-time.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>5</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-4882541740199203642</guid><pubDate>Wed, 26 Sep 2012 20:37:00 +0000</pubDate><atom:updated>2012-09-26T22:37:00.218+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">bash</category><category domain="http://www.blogger.com/atom/ns#">script</category><title>Get script&#39;s own directory in bash script</title><description>&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;
It was always a problem for me to get the directory the called script is stored in, in the script itself. Thanks to this SO question (http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in) it&#39;s not a problem anymore. As it says:&lt;/span&gt;&lt;br /&gt;

&lt;pre class=&quot;brush: bash&quot;&gt;DIR=&quot;$( cd &quot;$( dirname &quot;${BASH_SOURCE[0]}&quot; )&quot; &amp;amp;&amp;amp; pwd )&quot;&lt;/pre&gt;

&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Or, to get the dereferenced path (all directory symlinks resolved), do this:&lt;/span&gt;


&lt;pre class=&quot;brush: bash&quot;&gt;DIR=&quot;$( cd -P &quot;$( dirname &quot;${BASH_SOURCE[0]}&quot; )&quot; &amp;amp;&amp;amp; pwd )&quot;&lt;/pre&gt;</description><link>http://pawelstawicki.blogspot.com/2012/09/get-scripts-own-directory-in-bash-script.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-3507604757099883682</guid><pubDate>Sat, 15 Sep 2012 00:40:00 +0000</pubDate><atom:updated>2012-09-15T02:40:24.433+02:00</atom:updated><title>Get specific PC IP from &quot;arp -a&quot;</title><description>&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I want to extract IP of machine &lt;i&gt;leonidas&lt;/i&gt;. &lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;arp -a&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt; returns such line (among others):&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;leonidas.home (192.168.1.5) at 0:1c:c0:de:8f:28 on en1 ifscope [ethernet]&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;To have only IP:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;arp -a | grep leonidas | cut -f 2 -d &#39; &#39; | sed &#39;s/[()]//g&#39;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;prints&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;192.168.1.5&lt;/span&gt;</description><link>http://pawelstawicki.blogspot.com/2012/09/get-specific-pc-ip-from-arp-a.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-9162154941077105213</guid><pubDate>Sun, 08 Jan 2012 23:58:00 +0000</pubDate><atom:updated>2012-11-02T23:18:22.297+01:00</atom:updated><title>My encounter with a small bug in Hibernate</title><description>&lt;h4&gt;

&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The problem&lt;/span&gt;&lt;/h4&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;
At work, I needed to use entities with @DiscriminatorColumn&amp;nbsp;inheritance. It means all types are kept in the same table, with value in this column showing what type given row is of. It&#39;s not recommended way to handle inheritance, but for some reasons we needed to use it. In developement, locally, I was using PostgreSQL database. When I tried to store this entities, I was receiving strange errors. Saying I cannot store an entity because entity with such id is already in database. It was quite strange, I was trying to store vanilla new entity. Test case to show this error is very short, so I&#39;ll include it here:
&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;//Parent entity
@Entity
@Inheritance(strategy = SINGLE_TABLE)
@DiscriminatorColumn(name = &quot;CLASS_ID&quot;, discriminatorType = INTEGER)
public abstract class ParentEntity {
  @Id
  @GeneratedValue(strategy = IDENTITY)
  private Long id;
}

//Child entity with discriminator  
@Entity
@DiscriminatorValue(&quot;1&quot;)
public class InheritingEntity extends ParentEntity {
}

//Test
public class PersistChildEntitiesWithDiscriminatorTest extends BaseCoreFunctionalTestCase {
  
  @Test
  public void shouldPersistTwoEntities() {
    Session session = openSession();
    session.beginTransaction();
    InheritingEntity child1 = new InheritingEntity();
    InheritingEntity child2 = new InheritingEntity();
    session.save(child1);
    session.save(child2);
    session.getTransaction().rollback();
  }
}&lt;/pre&gt;
&lt;h4&gt;

&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;
The cause&lt;/span&gt;&lt;/h4&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;
This test throws exception on second save, but only on PostgreSQL. Why is that? Well, when you save new entity to persistence context, Hibernate issues SQL call to database instantly. Other queries, like updates, are cached, and sent to database on &lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;em.flush&lt;/span&gt; or &lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;em.commit&lt;/span&gt;. But inserting of new entities
  is not cached and there is a reason for that. When we save new entity, Hibernate needs to assign ID to it, and this is taken from database. Most databases
  return &lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;ResultSet&lt;/span&gt; with one row and one column after insert, and it contains newly assigned ID. However, PostgreSQL behaves a bit differently.
  It returns whole inserted row (of course, with ID filled in). In most cases it works, because ID is the first column in this row, so when Hibernate takes
  value from the first row and the first column, it is the correct one. However, in case of classes with discriminator, ID is not the first column.
  Discriminator is the first column. So first insert is correct, ID 1 is assigned to &lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;child1&lt;/span&gt;, but then when we try to store &lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;child2&lt;/span&gt;, Hibernate also tries to assign 1 to it&#39;s ID, and complaints that there already is another entity with it.

&lt;/span&gt;&lt;br /&gt;
&lt;h4&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;


The solution&lt;/span&gt;&lt;/h4&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;
So there was a bug in Hibernate. Can I solve it? I asked this question to myself, but to answer I couldn&#39;t do anything else than try ;) So I forked hibernate repository (yes, it&#39;s on &lt;a href=&quot;https://github.com/&quot;&gt;github&lt;/a&gt;!) and... I was quite overwhelmed by the mass of code there. First challenge was to try to open it in my IDE, with all the subprojects and their interdependencies configured correctly. Thankfully there is gradle task for creating project files for IntelliJ IDEA, the IDE I&#39;m happy user of. Next task was configuring Hibernate tests to use my PostgreSQL database. It turned out quite easy after one or two emails on hibernate-dev list. Now I had to change the code assigning IDs to entities to take it not always from first column first row, but sometimes from column of given name. So I had to get the name of column keeping IDs, which I did with a little help from other developers on the dev list.

&lt;/span&gt;&lt;br /&gt;
&lt;h4&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;

The contribution&lt;/span&gt;&lt;/h4&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;
Now I commited fix to my forked repository on github, issued a pull request, got some comments, fixed files formatting... We&#39;ll see if it&#39;s accepted.
UPDATE:
It is accepted :)
&lt;br /&gt;

&lt;/span&gt;</description><link>http://pawelstawicki.blogspot.com/2011/12/my-encounter-with-small-bug-in.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-7234445584577402540</guid><pubDate>Wed, 28 Dec 2011 17:10:00 +0000</pubDate><atom:updated>2011-12-30T14:09:54.048+01:00</atom:updated><title>Easy way to convert file encoding</title><description>&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Easy way to convert text files to UTF-8 on Ubuntu. Install package &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;enca&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt; and you are able to:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;enconv -L pl -x UTF-8 myfile.txt&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Where after &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;-L&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt; is language specified (necessary for enca to recognize file encoding before conversion) and after &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;-x&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt; destination encoding.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Warning: enconv overwrites existing file, so better create backup copy before.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;UPDATE: Another way, useful if you know source file encoding:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; line-height: 18px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;iconv -f ISO-8859-2 -t UTF-8 source.txt &amp;gt; utf8.txt&lt;/span&gt;&lt;/span&gt;</description><link>http://pawelstawicki.blogspot.com/2011/12/easy-way-to-convert-file-encoding.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>7</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-2508088679170622379</guid><pubDate>Wed, 30 Nov 2011 22:18:00 +0000</pubDate><atom:updated>2012-11-02T23:18:56.884+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">heroku</category><category domain="http://www.blogger.com/atom/ns#">play</category><title>Play! with Heroku</title><description>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;
Recently, inspired by some talks on Devoxx, I decided to check &lt;a href=&quot;http://www.playframework.org/&quot;&gt;Play framework&lt;/a&gt; and &lt;a href=&quot;http://www.heroku.com/&quot;&gt;Heroku&lt;/a&gt;.
&lt;br /&gt;
&lt;br /&gt;
Play is another java web framework, but this one is heavily influenced by Ruby on Rails. Convention over configuration, little code necessary etc. Looks like Play is gaining momentum, version 2 (now beta) supports Scala and now it became part of &lt;a href=&quot;http://typesafe.com/stack&quot;&gt;Typesafe&lt;/a&gt; stack.
&lt;br /&gt;
&lt;br /&gt;Heroku is another cloud. Well, quite different than AWS or GAE (actually, as far as I know, it works on AWS). Heroku is not only running applications, it is also able to build and deploy them. So to deploy your changes, it&#39;s enough to make &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;git push&lt;/span&gt;.
&lt;br /&gt;
&lt;br /&gt;
So first, download Play 2 beta from &lt;a href=&quot;http://www.playframework.org/2.0&quot;&gt;this site&lt;/a&gt;. Unpack, add dir to your &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$PATH&lt;/span&gt;, so that you could use &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;play&lt;/span&gt; command from anywhere.
&lt;br /&gt;
&lt;br /&gt;
Go to dir where you want to create the app and issue &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;play new helloapp&lt;/span&gt; (where &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;helloapp&lt;/span&gt; is your app name). Play should create &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;helloapp&lt;/span&gt; directory. No go into it. You can notice that Play nicely added &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;.gitignore&lt;/span&gt; file there, so when you create git repository here, unnecessary files won&#39;t be added.
Play created fully functional, basic web application. You can issue &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;play run&lt;/span&gt; in &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;helloapp&lt;/span&gt; directory and the server is going to be started and application deployed. You can now see it on &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;localhost:9000&lt;/span&gt;.
&lt;br /&gt;
&lt;br /&gt;
Now you&#39;ll need account on Heroku. Create one on &lt;a href=&quot;http://heroku.com/&quot;&gt;heroku.com&lt;/a&gt;, it&#39;s easy as creating email or forum account. Then just activate it by email sent to you from Heroku.
&lt;br /&gt;
&lt;br /&gt;
For your app to be able to run on Heroku cloud, you&#39;ll need to add one more file. In the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;helloapp&lt;/span&gt; dir create &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Procfile&lt;/span&gt; file with content like this:
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;web: target/start&lt;/span&gt;
&lt;br /&gt;
If you created your app with Play 1.x instead of 2.0, &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Procfile&lt;/span&gt; should be quite different:
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;web: play run --http.port=$PORT $PLAY_OPTS&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
To interact with the cloud you&#39;ll also need &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;heroku-toolbelt&lt;/span&gt;. Get one from &lt;a href=&quot;http://toolbelt.herokuapp.com/&quot;&gt;here&lt;/a&gt;.
&lt;br /&gt;
&lt;br /&gt;
Ok, you have your app and all the tools necessary to deploy it to the cloud. You&#39;ll also need git, which I assume you have already installed ;) As I mentioned on the beginning, it&#39;s necessary to push your app&#39;s code to Heroku.
&lt;br /&gt;
&lt;br /&gt;
Create git repository in the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;helloapp&lt;/span&gt; directory. Enter the directory and issue the following comands.
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
git init&lt;br /&gt;
git add .&lt;br /&gt;
git commit -m init&lt;/span&gt;
&lt;br /&gt;
This commands created git repository in the directory, added current directory (&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;helloapp&lt;/span&gt;) to the git index, and commited the changes to the local repository.
&lt;br /&gt;
&lt;br /&gt;
Next thing to do is creating new application on Heroku: &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;heroku create --stack cedar&lt;/span&gt; from &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;helloapp&lt;/span&gt; dir. This not only creates new application, but also nicely adds remote git repository. Heroku has few stacks. Stack is OS and stuff installed on it for our applications to run. For now, the only stack that supports Play is called Cedar. It&#39;s not the default one, so you need to tell Heroku explicitely that it should be used for your application.
&lt;br /&gt; 
&lt;br /&gt; 
It is also going to ask about your credentials to authenticate you on Heroku. It is done only once, and then your &lt;strike&gt;credentials&lt;/strike&gt; key and token are stored on disk. If you want to delete them, just &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;heroku auth:logout&lt;/span&gt;.
&lt;br /&gt;
&lt;br /&gt;
Ok, so you have application on Heroku, with git repository added to your remote ones, and you have one app locally which you want now to deploy to the cloud. Well, it couldn&#39;t be simplier:
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
git push heroku master&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
From now on it only takes some patience. Deployment takes time. When it&#39;s finished, it gives you the address, something like &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;http://blooming-stone-5863.herokuapp.com deployed to Heroku&lt;/span&gt; in the console.
&lt;br /&gt;
&lt;br /&gt;
Go to this address and you&#39;ll see your app. Have fun!&lt;/span&gt;</description><link>http://pawelstawicki.blogspot.com/2011/11/play-with-heroku.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>5</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-1551430185588176169</guid><pubDate>Thu, 20 Oct 2011 06:56:00 +0000</pubDate><atom:updated>2011-10-20T08:56:48.470+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">warsjawa</category><category domain="http://www.blogger.com/atom/ns#">warsjawa 2011</category><title>Warsjawa 2011</title><description>&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Dear reader. This post is about Polish event, organised by Polish programmers for Polish programmers. Speaking only Polish. So if you don&#39;t speak Polish, I don&#39;t think you&#39;d be interested. Therefore, this post is in Polish.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
W miniony weekend wybrałem się na warsztaty Warsjawa 2011. Wybrałem się z ekipą ze Szczecina jak zwykle pociągiem, co okazało się mieć taki minus, że pora roku jaka już nadeszła zapewnia że w pociągu może być albo zimno, albo gorąco. My wybraliśmy zimno. Jakoś jednak dojechaliśmy rankiem do Warszawy. Ja udałem się załatwić jeszcze parę prywatnych spraw, i nie bez drobnych komplikacji dotarłem do budynku przy Nowowiejskiej na tyle wcześnie, że mogłem jeszcze pomóc nosić ławki i krzesła.&lt;br /&gt;
&lt;br /&gt;
Z czterech dostępnych ścieżek wybrałem &lt;b&gt;DDD i CqRS,&lt;/b&gt;&amp;nbsp;prowadzone przez Sławka Sobótkę i Rafała Jamroza. Warsztaty miały części prezentacyjne, i stricte warsztatowe. O ile prezentacjom niczego nie zabrakło (przynajmniej dla mnie, ale obie widziałem już wcześniej), to część warsztatowa jakoś się &quot;rozlazła&quot;.&lt;br /&gt;
&lt;br /&gt;
Z początku wstęp do DDD, ciekawy i świetnie poprowadzony. Dowiedzieliśmy się co to takiego to DDD, do czego się nadaje i z czym to się je. Po wstępie Sławek &quot;oprowadził&quot; nas po wcześniej przygotowanej na warsztaty aplikacji, pokazując &quot;klocki DDD&quot;, z których jest zbudowana.&lt;br /&gt;
&lt;br /&gt;
W pierwszej części warsztatowej zadaniem uczestników było rozszerzenie funkcjonalności aplikacji w duchu DDD. Zaczęliśmy prawidłowo, od testów. Z braku czasu testy pozostały na etapie wstępnym, tzn. takim, w którym wystarczyło w klasie testowanej z każdej metody zwrócić &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt; żeby przechodziły&lt;/span&gt;. Więcej chyba było w tej części dyskusji, pytań i odpowiedzi niż kodowania, ale nie uważam tego za jej wadę. Wszak programowanie to przede wszystkim komunikacja. I tak czas upłynął nam do obiadu.&lt;br /&gt;
&lt;br /&gt;
Na obiad była pizza, zgodnie z obietnicami organizatorów nie zabrakło :)&lt;br /&gt;
&lt;br /&gt;
Po przerwie obiadowej znowu miała miejsce część prezentacyjna, w której Sławek pokazał co to takiego ten CqRS, i jakie ciekawe triki można stosować w celu poprawienia wydajności aplikacji. Np. mieć osobną bazę danych do zapisu i osobną do odczytu.&lt;br /&gt;
&lt;br /&gt;
Prezentacja dość płynnie przeszła w kolejne warsztaty, które jednak chyba więcej miały z prezentacji. Nie żeby mi to przeszkadzało, może nawet tak miało być :) Dowiedzieliśmy się czegoś więcej o kilku bardziej skomplikowanych wzorcach, jak &lt;i&gt;Saga&lt;/i&gt; czy &lt;i&gt;Specification&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
W ostatniej części Sławek pokazał nowe dla mnie narzędzie &lt;i&gt;JBehave&lt;/i&gt;. Musze powiedzieć, że zrobiło na mnie wrażenie, i zamierzam poświęcić trochę czasu na bliższe poznanie tegoż. Zauważam też spore podobieństwo do &lt;i&gt;Cucumbera&lt;/i&gt;, ciekawym czym się różnią.&lt;br /&gt;
&lt;br /&gt;
Po wszystkim cała nasza ekipa czuła się pozytywnie naładowana informacjami, czuło się entuzjazm do dalszego zgłębiania poruszonych tematów, a to przecież najważniejsze. I choćby to świadczyć może o sukcesie tych warsztatów.&lt;br /&gt;
&lt;br /&gt;
Jeśli miałbym szukać minusów to może za mało było napojów, no i nie było kawy. Aczkolwiek nie był do duży problem, bo w budynku były automaty zarówno z kawą, jak i z zimnymi napojami.</description><link>http://pawelstawicki.blogspot.com/2011/10/warsjawa-2011.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-8653849272248510331</guid><pubDate>Thu, 20 Jan 2011 21:53:00 +0000</pubDate><atom:updated>2011-01-20T22:53:20.475+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">coderetreat events</category><title>First CodeRetreat in Poznań</title><description>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;On 15th January I had a pleasure to participate in first Code Retreat in Poznań. The event was organised by Adam Dudczak and &lt;a href=&quot;http://www.jug.poznan.pl/&quot;&gt;Poznań JUG&lt;/a&gt;. If you don&#39;t know what Code Retreat is, take a look &lt;a href=&quot;http://www.coderetreat.com/how-it-works.html&quot;&gt;here&lt;/a&gt;. It is a great opportunity to meet other coders, see how they work and exchange knowledge and experience. There were 5 sessions, and the pairs were changing each time, so everyone coded with 5 different people.&lt;br /&gt;
&lt;br /&gt;
Idea of Code Retreat is not only to code in pairs but also to use TDD. After lunch, during break, there were two discussion groups, one discussing BDD, and the other pair programming. I joined BDD group. First it was explained what BDD is, then we were discussing. The group was very active, many people had questions but there were also many answers :)&lt;br /&gt;
&lt;br /&gt;
Programming task was standard for Code Retreats - Conway&#39;s &lt;a href=&quot;http://en.wikipedia.org/wiki/Conway%27s_game_of_life&quot;&gt;Game Of Life&lt;/a&gt;. It&#39;s nice to watch development. During the first session we didn&#39;t finish our task, like most pairs. We barely started when the time was over. After the third session, most pairs had Game Of Life algorithm finished. Of course together with tests :)&lt;br /&gt;
&lt;br /&gt;
Such an event is not only opportunity to learn, but also to meet people. Some I already knew from twitter, blogs etc., some from other events, and some were completely new to me. There was time to talk, not only during quite short breaks between sessions, but also during lunch and &quot;afterparty&quot;. For lunch there was not pizza, but some decent dish, huge and tasty.&lt;br /&gt;
&lt;br /&gt;
I have to write also about the place the event was held at. It was in &lt;a href=&quot;http://www.cognifide.com/AboutUs/Events/Code-Retreat&quot;&gt;Cognifide&lt;/a&gt;&amp;nbsp;offices, and it was one of the nicest offices I&#39;ve ever seen! Lunch and afterparty was in the basement, but this basement looked like a decent pub. Brick walls and ceilings, bar, comfy sofas and tables. There was also refrigerator full of beer, and it was used during afterparty :)&lt;br /&gt;
&lt;br /&gt;
For me this event was a big success. Congrats, organizers!&lt;/span&gt;</description><link>http://pawelstawicki.blogspot.com/2011/01/first-coderetreat-in-poznan.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-4755608585134430693</guid><pubDate>Fri, 24 Dec 2010 23:07:00 +0000</pubDate><atom:updated>2010-12-25T00:07:52.353+01:00</atom:updated><title>Scala script to find duplicate files</title><description>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here is simple Scala script finding duplicate files and moving them to another directory. It searches &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;album-with-duplicates&lt;/span&gt; for duplicates of files in &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;main-album&lt;/span&gt;. All duplicates found are moved to &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;copies&lt;/span&gt; directory in user&#39;s home.&lt;br /&gt;
&lt;br /&gt;
If you have some ideas how to improve it, I&#39;d appreciate if you share it in comments.&lt;br /&gt;
&lt;br /&gt;
MD5 algorithm taken from &lt;a href=&quot;http://code-redefined.blogspot.com/2009/05/md5-sum-in-scala.html&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;/span&gt;&lt;pre class=&quot;brush: scala&quot;&gt;package com.blogspot.pawelstawicki.remove.duplicates

import java.security.MessageDigest
import java.io.{FileInputStream, File}
import org.apache.commons.io.{FilenameUtils, FileUtils, IOUtils}

/**
 * @author ${user.name}
 */
object App {
  
  def main(args : Array[String]) {
    val dir1 = new File(&quot;/photos/main-album,&quot;);
    val dir2 = new File(&quot;/photos/album-with-duplicates&quot;);

    val dir1Content = getAllFiles(dir1)
    val dir2Content = getAllFiles(dir2)

    var dir1Map = Map[String, File]()
    dir1Content.foreach(f =&amp;gt; {
      val md5 = md5SumString(IOUtils.toByteArray(new FileInputStream(f)))
      println(&quot;md5 for &quot; + f.getPath + &quot;: &quot; + md5)
      dir1Map = dir1Map + (md5 -&amp;gt; f)
    })

    var dir2Map = Map[String, File]()
    dir2Content.foreach(f =&amp;gt; {
      val md5 = md5SumString(IOUtils.toByteArray(new FileInputStream(f)))
      println(&quot;md5 for &quot; + f.getPath + &quot;: &quot; + md5)
      dir2Map = dir2Map + (md5 -&amp;gt; f)
    })

    for(md51 &amp;lt;- dir1Map.keys; md52 &amp;lt;- dir2Map.keys) {

      if (md51.equals(md52)) {
        val suspectedDuplicate = dir2Map(md52)
        val original = dir1Map(md52)

        if (checkDuplicate(original, suspectedDuplicate)) {
          println(suspectedDuplicate.getPath + &quot; is duplicate of &quot; + original.getPath)
          val copiesDir = new File(FileUtils.getUserDirectory + &quot;/copies/&quot; + FilenameUtils.getPathNoEndSeparator(original.getAbsolutePath()));
          println(&quot;Moving to &quot; + copiesDir.getPath)
          FileUtils.moveFileToDirectory(suspectedDuplicate, copiesDir, true)
        }
      }
    }
  }

  def checkDuplicate(f1: File, f2: File): Boolean = {
    val bytes1 = new Array[Byte](1024*1024)
    val bytes2 = new Array[Byte](1024*1024)

    val input1 = new FileInputStream(f1)
    val input2 = new FileInputStream(f2)

    var bytesRead1 = input1.read(bytes1)
    while(bytesRead1 &amp;gt; 0) {
      val bytesRead2 = input2.read(bytes2)

      if (bytesRead1 != bytesRead2) {
        return false;
      }

      //Bytes read number the same
      if (!bytes1.sameElements(bytes2)) {
        return false
      }

      bytesRead1 = input1.read(bytes1)
    }

    //bytesRead1 is -1. Check if bytes read number from file2 is also -1
    if (input2.read(bytes2) == -1) {
      return true;
    } else {
      return false;
    }
  }

  def md5SumString(bytes : Array[Byte]) : String = {
    val md5 = MessageDigest.getInstance(&quot;MD5&quot;)
    md5.reset()
    md5.update(bytes)

    md5.digest().map(0xFF &amp;amp; _).map { &quot;%02x&quot;.format(_) }.foldLeft(&quot;&quot;){_ + _}
  }

  def getAllFiles(dir : File) : List[File] = {
    var l = List[File]()
    dir.listFiles.foreach(f =&amp;gt; {
      if (f.isFile) {
        l = f :: l
      } else {
        l = l ::: getAllFiles(f)
      }
    })

    l
  }

}
&lt;/pre&gt;</description><link>http://pawelstawicki.blogspot.com/2010/12/scala-script-to-find-duplicate-files.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>7</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-1787883164214733154</guid><pubDate>Mon, 20 Dec 2010 23:02:00 +0000</pubDate><atom:updated>2014-07-18T14:07:40.821+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">component</category><category domain="http://www.blogger.com/atom/ns#">cross</category><category domain="http://www.blogger.com/atom/ns#">cross-field</category><category domain="http://www.blogger.com/atom/ns#">cross-field validation</category><category domain="http://www.blogger.com/atom/ns#">field</category><category domain="http://www.blogger.com/atom/ns#">jsf</category><category domain="http://www.blogger.com/atom/ns#">jsf2</category><category domain="http://www.blogger.com/atom/ns#">validation</category><title>JSF2.0 component for cross-field validation</title><description>&lt;script type=&quot;text/javascript&quot;&gt;var dzone_url = &#39;http://pawelstawicki.blogspot.com/2010/12/jsf20-component-for-cross-field.html&#39;;&lt;/script&gt;&lt;script type=&quot;text/javascript&quot;&gt;var dzone_title = &#39;JSF2.0 component for cross-field validation&#39;;&lt;/script&gt;&lt;script type=&quot;text/javascript&quot;&gt;var dzone_blurb = &#39;&#39;;&lt;/script&gt;&lt;script type=&quot;text/javascript&quot;&gt;var dzone_style = &#39;2&#39;;&lt;/script&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://widgets.dzone.com/links/widgets/zoneit.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Have you ever had problems with cross-field validation in JSF? Me too, so I created this component. You can validate few &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;UIInput&lt;/span&gt; components and have their values as &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;List&lt;/span&gt; in validator. The component is in softwaremill-faces library. To use it in maven project, add repository:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;lt;repository&amp;gt;
  &amp;lt;url&amp;gt;http://tools.softwaremill.pl/nexus/content/groups/smlcommon-repos/ &amp;lt;/url&amp;gt;
  &amp;lt;layout&amp;gt;default&amp;lt;/layout&amp;gt;
  &amp;lt;releases&amp;gt;
    &amp;lt;enabled&amp;gt;true&amp;lt;/enabled&amp;gt;
  &amp;lt;/releases&amp;gt;
  &amp;lt;snapshots&amp;gt;
    &amp;lt;enabled&amp;gt;true&amp;lt;/enabled&amp;gt;
  &amp;lt;/snapshots&amp;gt;
&amp;lt;/repository&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;and dependency:&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;dependency&amp;gt;
  &amp;lt;groupId&amp;gt;pl.softwaremill.common&amp;lt;/groupId&amp;gt;
  &amp;lt;artifactId&amp;gt;softwaremill-faces&amp;lt;/artifactId&amp;gt;
  &amp;lt;version&amp;gt;43-SNAPSHOT&amp;lt;/version&amp;gt;
&amp;lt;/dependency&amp;gt;
&lt;/pre&gt;
Now you can use multiValidator component. First add namespace to your .xhtml page:&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;xmlns:v=&quot;http://pl.softwaremill.common.faces/components&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Then just wrap components you want to cross-validate in &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;v:multiValidator&amp;gt;&lt;/span&gt;. If you attach validator to this component, &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;value&lt;/span&gt;&amp;nbsp;parameter that goes to validation method is &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;List&lt;/span&gt; of values of &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;UIInput&lt;/span&gt; components inside&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;v:multivalidator&gt;&lt;/v:multivalidator&gt;&lt;/span&gt;&amp;nbsp;tag.&lt;br /&gt;
&lt;br /&gt;
E.g. if you want to validate two checkboxes. Each can be checked or unchecked, but at least one has to be checked.&lt;br /&gt;
&lt;pre class=&quot;brush: xhtml&quot;&gt;&amp;lt;v:multiValidator id=&quot;multi&quot; validator=&quot;#{bean.validationMethod}&quot;&amp;gt;
  &amp;lt;h:selectBooleanCheckbox value=&quot;#{bean.check1}&quot; /&amp;gt;
  &amp;lt;h:selectBooleanCheckbox value=&quot;#{bean.check2}&quot; /&amp;gt;
&amp;lt;/v:multiValidator&amp;gt;
&amp;lt;h:message for=&quot;multi&quot; /&amp;gt;
&lt;/pre&gt;
Validation method in bean:&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;public void validationMethod(FacesContext context, UIComponent component, Object value) {
  List&amp;lt;Object&amp;gt; values = (List&amp;lt;Object&amp;gt;) value;
  //value is list of values of both selectBooleanCheckboxes
  Boolean firstChecked = (Boolean) values.get(0);
  Boolean secondChecked = (Boolean) values.get(1);

  if (! (firstChecked || secondChecked)) {
    Message message = new FacesMessage(FacesMessage.SEVERITY_ERROR, &quot;Check at least one checkbox&quot;, null);
    throw new ValidatorException(message);
  }
}
&lt;/pre&gt;
If none checkbox is checked error message is displayed in &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;h:message for=&quot;multi&quot;&amp;gt;&lt;/span&gt; tag.&lt;br /&gt;
&lt;br /&gt;
Source code of this component is on &lt;a href=&quot;https://github.com/softwaremill/softwaremill-common/blob/master/softwaremill-faces/src/main/java/com/softwaremill/common/faces/validator/MultiValidator.java&quot; target=&quot;_blank&quot;&gt;github&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Any suggestions, opinions or questions regarding this component are welcome. Have a good time using it :)&lt;/span&gt;</description><link>http://pawelstawicki.blogspot.com/2010/12/jsf20-component-for-cross-field.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-2335318368224110209</guid><pubDate>Tue, 02 Nov 2010 22:51:00 +0000</pubDate><atom:updated>2010-11-02T23:51:43.626+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">gwt</category><category domain="http://www.blogger.com/atom/ns#">uibinder</category><title>GWT table row as UiBinder</title><description>&lt;div class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Some time ago I wanted to dynamically add rows to a table in GWT, but I wanted to define row template using &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;UiBinder&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;. Programatically it is no problem. You can create &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;FlexTable&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; and add widgets to it. The problem arises when you want to do it using &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;UiBinder&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;. You can create a &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;FlexTable&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; in &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;UiBinder&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;, and you can create widgets, but you can&#39;t create element which renders to html tag &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;. &lt;a href=&quot;http://blog.xemantic.com/&quot;&gt;Kazik Pogoda&lt;/a&gt; found a way to do it.&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;First we need two widgets which renter to &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; and &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;. The code for TR:&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;brush: java&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;public class TrElement extends ComplexPanel {
  private TableRowElement tr;

  public TrElement() {
    Document doc = Document.get();
    tr = doc.createTRElement();
    setElement(tr);
  }

  @Override
  public void add(Widget child) {
    add(child, (Element) tr.cast());
  }
}
&lt;/pre&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The TD is analogous, just change &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;TableRowElement&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; into &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;TableCellElement&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; and &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;doc.createTRElement()&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; into &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;doc.createTDElement()&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;. We can now create &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;UiBinder xml&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; file which renders to single table row (TR element is it&#39;s root):&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;brush: xml&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;lt;!DOCTYPE ui:UiBinder SYSTEM &quot;http://dl.google.com/gwt/DTD/xhtml.ent&quot;&amp;gt;
&amp;lt;ui:UiBinder xmlns:ui=&quot;urn:ui:com.google.gwt.uibinder&quot;
      xmlns:g=&quot;urn:import:com.google.gwt.user.client.ui&quot;
      xmlns:my=&quot;urn:import:pl.my.gwt.client&quot;&amp;gt;
 
  &amp;lt;my:TrElement&amp;gt;
    &amp;lt;my:TdElement&amp;gt;
      &amp;lt;g:HTMLPanel&amp;gt;
        &amp;lt;g:Label ui:field=&quot;icon&quot; styleName=&quot;Icon&quot;&amp;gt;&amp;lt;/g:Label&amp;gt;
        &amp;lt;g:Label ui:field=&quot;title&quot; styleName=&quot;Title&quot;&amp;gt;&amp;lt;/g:Label&amp;gt;
        &amp;lt;g:Label ui:field=&quot;description&quot; styleName=&quot;Description&quot;&amp;gt;&amp;lt;/g:Label&amp;gt;
      &amp;lt;/g:HTMLPanel&amp;gt;
    &amp;lt;/my:TdElement&amp;gt;
    &amp;lt;my:TdElement&amp;gt;
      &amp;lt;g:Label ui:field=&quot;price&quot; styleName=&quot;Price&quot;&amp;gt;&amp;lt;/g:Label&amp;gt;
    &amp;lt;/my:TdElement&amp;gt;
  &amp;lt;/my:TrElement&amp;gt;
&amp;lt;/ui:UiBinder&amp;gt;
&lt;/pre&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here is how we can use it to add to a table (&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;FlexTable&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;brush: java&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;TableRowView trView = new TableRowView();
table.getElement().appendChild(trView.getElement());
&lt;/pre&gt;&lt;/div&gt;</description><link>http://pawelstawicki.blogspot.com/2010/11/gwt-table-row-as-uibinder.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>6</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-2971570036167162028</guid><pubDate>Fri, 29 Oct 2010 23:45:00 +0000</pubDate><atom:updated>2010-10-30T01:45:22.406+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">warsjawa</category><category domain="http://www.blogger.com/atom/ns#">warsjawa 2010</category><title>Warsjawa 2010. Impressions.</title><description>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;My impressions after this year&#39;s &lt;a href=&quot;http://github.com/warszawajug/warsjawa2010/wiki/Konferencja-Warsjawa-2010&quot;&gt;Warsjawa&lt;/a&gt; are very positive. Well, in fact I could expect this :) Presentations were interesting, meeting other IT people is always good too. I met &lt;a href=&quot;http://bartekzdanowski.pl/&quot;&gt;Bartek Zdanowski&lt;/a&gt;, who wanted to meet me. It&#39;s quite strange feeling when you meet somebody who knows you, but didn&#39;t meet you before. Strange but nice :)&lt;br /&gt;
&lt;br /&gt;
First presentation was about &lt;a href=&quot;http://www.playframework.org/&quot;&gt;Play&lt;/a&gt;&amp;nbsp;framework by &lt;a href=&quot;http://sites.google.com/site/wojtassj2/&quot;&gt;Wojciech Erbetowski&lt;/a&gt;. I was a little late, but I&#39;ve seen enough to notice that Play is framework different than all the others.&lt;br /&gt;
&lt;br /&gt;
I was a bit disappointed that &lt;a href=&quot;http://art-of-software.blogspot.com/&quot;&gt;Sławek Sobótka&lt;/a&gt; didn&#39;t make it there (he fell ill). He&#39;s topic was the most interesting for me. However, &lt;a href=&quot;http://www.pawellipinski.com/&quot;&gt;Paweł Lipiński&lt;/a&gt; worthily replaced him. Paweł was talking about what in programming he was taught by... his own children, kindergarten, &lt;a href=&quot;http://en.wikipedia.org/wiki/Roomba&quot;&gt;Roomba&lt;/a&gt;&amp;nbsp;etc. I never noticed that when there are 2-3 people in a project, it is much cleaner, but it&#39;s becoming a mess when there are more than 5 people. I never noticed it, but now it&#39;s very clear to me. It seems Paweł is a man who can learn and get knowledge from anything. Ah, and he mentioned me :)&lt;br /&gt;
&lt;br /&gt;
This year on Warsjawa there was also something from our &lt;a href=&quot;http://groups.google.com/group/szczecin-jug&quot;&gt;Szczecin JUG&lt;/a&gt;. &lt;a href=&quot;http://luksza.org/&quot;&gt;Darek &quot;Lock&quot; Łuksza&lt;/a&gt; presented &lt;a href=&quot;http://git-scm.com/&quot;&gt;Git&lt;/a&gt; version control system and it&#39;s Eclipse plugin &lt;a href=&quot;http://www.eclipse.org/egit/&quot;&gt;EGit&lt;/a&gt;. Darek did great job, and even found one bug during presentation :) It seemed a bit embarassing for him, but the rest was very good. He knows the topic very well (he&#39;s EGit commiter) and he showed many things coding live. Overall presentation was very good.&lt;br /&gt;
&lt;br /&gt;
After Darek&#39;s presentation pizza arrived. It disappeared quite quickly, maybe there was a bit too few. We run out of beverages too. Anyway I didn&#39;t hear somebody died of hunger or thirst, so it wasn&#39;t that bad :)&lt;br /&gt;
&lt;br /&gt;
Next interesting presentation was about &lt;a href=&quot;http://clojure.org/&quot;&gt;Clojure&lt;/a&gt;. This time there were two presenters. First &lt;a href=&quot;http://www.clojureblog.pl/&quot;&gt;Marcin Rzewucki&lt;/a&gt; showed us some theory, then &lt;a href=&quot;http://jan.rychter.com/&quot;&gt;Jan Rychter&lt;/a&gt; told about practical use of Clojure in &lt;a href=&quot;http://fablo.pl/&quot;&gt;Fablo&lt;/a&gt;. He showed few interesting features of this language, like &lt;a href=&quot;http://en.wikipedia.org/wiki/Software_transactional_memory&quot;&gt;STM&lt;/a&gt;. Thanks to STM in Fablo they are able to replace customer&#39;s database without stopping the service. Pretty impressive.&lt;br /&gt;
&lt;br /&gt;
Did you know that in Java you can have two methods with the same name and arguments, differing only by return type? Compiler can&#39;t compile this, but if you write it in bytecode it is perfectly valid! This and others interesting things about bytecode were shown by Adam Michalik. I wonder if any company needs &quot;bytecode programmer&quot;? I like such low-level stuff. At the university I always liked assembler.&lt;br /&gt;
&lt;br /&gt;
The last presentation by &lt;a href=&quot;http://rrusin.blogspot.com/&quot;&gt;Rafał Rusin&lt;/a&gt; was about &lt;a href=&quot;http://incubator.apache.org/hise/&quot;&gt;Apache HISE&lt;/a&gt;. I have to admit I was too tired and the topic was not very interesting for me, so I didn&#39;t remember much from this one.&lt;br /&gt;
&lt;br /&gt;
Generally I think this was very nice conference. Meeting new people, and some older friends, is always nice. Listening to interesting people talking about interesting things is also nice. It seems one hour for presentation is very good duration. All the presenters could do all they wanted/needed (at least it seemed so). I remember on &lt;a href=&quot;http://2010.geecon.org/&quot;&gt;GeeCON&lt;/a&gt;&amp;nbsp;there was only 45 minutes and it was too little. If only there was more pizza (or maybe something better?) and beverages it would be perfect.&lt;/span&gt;</description><link>http://pawelstawicki.blogspot.com/2010/10/warsjawa-2010-impressions.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-8770566953086883390</guid><pubDate>Wed, 13 Oct 2010 08:58:00 +0000</pubDate><atom:updated>2010-10-13T10:58:53.222+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android</category><category domain="http://www.blogger.com/atom/ns#">j2me</category><category domain="http://www.blogger.com/atom/ns#">j2me on android</category><category domain="http://www.blogger.com/atom/ns#">jme</category><category domain="http://www.blogger.com/atom/ns#">jme on android</category><category domain="http://www.blogger.com/atom/ns#">tokengsm</category><title>Convert JME application to Android</title><description>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here is the story:&lt;br /&gt;
&lt;br /&gt;
I bought Android phone. Earlier I was using Windows Mobile phone, and I had one j2me application on it that was very important to me. It was &quot;TokenGSM&quot;, application which serves the same purpose as RSA tokens, but installed on my phone. Very good decision of my bank that they created it so users don&#39;t have to carry additional device with them (users have choice, you can also get RSA token if you prefer it). So this application is necessary if I want to log in to my bank account. Pretty vital.&lt;br /&gt;
&lt;br /&gt;
But, as you probably know, there is no Java ME on Android :( Here is what I did (&lt;a href=&quot;http://forum.android.com.pl/f34/tokengsm-1673/index3.html&quot;&gt;this forum was useful&lt;/a&gt;):&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Call the bank and ask for new GSM token. Token is somehow bound to the phone, so if you change phone, you need new token.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Write down URL from WAP Push SMS. Do it before opening it. On my phone (Android 2.2, HTC Desire) if you don&#39;t do it but just try to open URL, it&#39;s lost. Browser can&#39;t open it, but you don&#39;t even have chance to see it. Browser just blinks and returns to home screen :| It&#39;s not in history, nor in downloads.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Go to &lt;a href=&quot;http://www.netmite.com/android/&quot;&gt;http://www.netmite.com/android/&lt;/a&gt; and download App Runner. I went there from my phone and downloaded directly to it. I&#39;m not sure if this point is really necessary, but some say it is.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Click &quot;Convert existing j2mes into apk &amp;amp; upload to Android Market.&quot; I don&#39;t think it really uploads to Market.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Enter your written down URL and click &quot;Get Apk&quot;. You have your Android TokenGSM :)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Transfer the file to your phone and install it.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now you have to activate the token with code you received from the bank.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;</description><link>http://pawelstawicki.blogspot.com/2010/10/convert-jme-application-to-android.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-1877647165714347737</guid><pubDate>Sun, 26 Sep 2010 21:38:00 +0000</pubDate><atom:updated>2010-12-06T16:29:57.866+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">flash scope</category><category domain="http://www.blogger.com/atom/ns#">jsf2</category><title>Flash scope in JSF 2.0 (nothing about Adobe Flash)</title><description>&lt;div class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In JSF 2.0, amongst &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Request&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Session&lt;/span&gt; etc, there is the new scope called &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Flash&lt;/span&gt;. (However there is no annotation &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;@FlashScope&lt;/span&gt;, and you can&#39;t put bean in this scope). It&#39;s concept is taken from Ruby on Rails. Data in &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Flash&lt;/span&gt; scope are available for current and for next request, but not for subsequent requests. Usage is very simple.&lt;br /&gt;
On first page (e.g. &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;index.html&lt;/span&gt;):&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;h:form&amp;gt;
  &amp;lt;h:inputtext value=&quot;#{flash.text}&quot;&amp;gt;
  &amp;lt;h:commandbutton action=&quot;page?faces-redirect=true&quot; value=&quot;To page&quot;&amp;gt;
&amp;lt;/h:form&amp;gt;
&lt;/pre&gt;And this is the page we are redirecting to, &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;page.xhtml&lt;/span&gt;:&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;h:form&amp;gt;
  &amp;lt;h:outputtext value=&quot;#{flash.text}&quot;&amp;gt;
&amp;lt;/h:form&amp;gt;
&lt;/pre&gt;Why would you need such scope? Imagine you want to enter data on one page, then redirect to another page, and display this data. If not for redirect, we could use &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Request&lt;/span&gt; scope. But with redirect value is sent with request, then browser is redirected to another page, and makes another request. &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Request&lt;/span&gt; scoped value is gone. In such case &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Flash&lt;/span&gt; scope becomes useful. We can put value in this scope with one request, and when another request is made, the value is still there. But it is not stored in session, and is not available for subsequent requests.&lt;br /&gt;
&lt;br /&gt;
However, there is a way to make data in &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Flash&lt;/span&gt; scope alive a bit longer. It is enough if in &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;page.xhtml&lt;/span&gt; we change &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;#{flash.text}&lt;/span&gt; to &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;#{flash.keep.text}&lt;/span&gt;. This way data is not removed from the scope after first request, but is available for one more.&lt;br /&gt;
&lt;br /&gt;
In managed beans, you can get flash scope by&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;Flash flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
&lt;/pre&gt;&lt;/div&gt;</description><link>http://pawelstawicki.blogspot.com/2010/09/flash-scope-in-jsf-20-nothing-about.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-6868328936791707726</guid><pubDate>Fri, 27 Aug 2010 23:22:00 +0000</pubDate><atom:updated>2010-08-28T01:40:54.039+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jsf</category><category domain="http://www.blogger.com/atom/ns#">jsf2</category><category domain="http://www.blogger.com/atom/ns#">template</category><title>JSF 2 templating</title><description>&lt;script type=&quot;text/javascript&quot;&gt;var dzone_url = &#39;http://pawelstawicki.blogspot.com/2010/08/jsf-2-templating.html&#39;;&lt;/script&gt;&lt;script type=&quot;text/javascript&quot;&gt;var dzone_title = &#39;JSF 2 templating&#39;;&lt;/script&gt;&lt;script type=&quot;text/javascript&quot;&gt;var dzone_blurb = &#39;JSF 2 templating with &amp;lt;ui:...&amp;gt; tags&#39;;&lt;/script&gt;&lt;script type=&quot;text/javascript&quot;&gt;var dzone_style = &#39;2&#39;;&lt;/script&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://widgets.dzone.com/links/widgets/zoneit.js&quot;&gt;&lt;/script&gt;&lt;div class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In this post I want to share my knowledge about JSF 2 templating. Most of this post are source codes, but if you are novice and don&#39;t know how to start, and where to put the source code, here you go.&lt;br /&gt;
&lt;h4&gt;0. Download Netbeans and setup the project.&lt;/h4&gt;Install Netbeans and run it. I use version 6.9. In Netbeans, go to &lt;i&gt;File -&amp;gt; New Project...&lt;/i&gt; and then choose &lt;i&gt;Java Web&lt;/i&gt; and &lt;i&gt;Web Application&lt;/i&gt;. Click Next.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjToAlihPvfOXYNeJY-5l_k63EAjlaCIHVispOFKMsUAOV4IaSE8ptFWbASq-XQyssALTzvaoTwKBnIU0pleE8wph4YelN4CkdMfBImivFOjKwuSkprzbXiYb4zJa8IlZRrGbU3TL1Nt8TZ/s1600/choose+project.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;427&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjToAlihPvfOXYNeJY-5l_k63EAjlaCIHVispOFKMsUAOV4IaSE8ptFWbASq-XQyssALTzvaoTwKBnIU0pleE8wph4YelN4CkdMfBImivFOjKwuSkprzbXiYb4zJa8IlZRrGbU3TL1Nt8TZ/s640/choose+project.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
In next window choose project name, optionally directory where to store it, and set the project as the main project.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUTGkhpKPNr6qvK8pmIo1RBU6CCdD0jiM_uYFVd7pw2MAVNy8y7YlHgEnDTXYC3TgxVceKsJaw_JNvRF2V4OCQ_UpwRIAR1bcPO05vTaUJJGyzNMU2-ZBXmBnDICGfyRynce9Dq4__5aOt/s1600/project+name.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;411&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUTGkhpKPNr6qvK8pmIo1RBU6CCdD0jiM_uYFVd7pw2MAVNy8y7YlHgEnDTXYC3TgxVceKsJaw_JNvRF2V4OCQ_UpwRIAR1bcPO05vTaUJJGyzNMU2-ZBXmBnDICGfyRynce9Dq4__5aOt/s640/project+name.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;In the next window leave &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;None&amp;gt;&lt;/span&gt; in enterprise application and choose web server. Default should be ok, the same about context path.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXKKpixrqKduXz2M1kUVLsdNC0hwWiBA-29fCLAlSa_A4bPUToZOT1khVqQPpkHkTVvn05qL-87SxQWen1wAOJolUo7IJOcxNq75cuNb_n-l-S-lqNOBbKzdJCpFpEBlz63vo8oOGa-zyY/s1600/server.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;356&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXKKpixrqKduXz2M1kUVLsdNC0hwWiBA-29fCLAlSa_A4bPUToZOT1khVqQPpkHkTVvn05qL-87SxQWen1wAOJolUo7IJOcxNq75cuNb_n-l-S-lqNOBbKzdJCpFpEBlz63vo8oOGa-zyY/s640/server.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Check &lt;i&gt;JavaServer Faces&lt;/i&gt;. In &lt;i&gt;Libraries&lt;/i&gt;&amp;nbsp;tab&amp;nbsp;select &lt;i&gt;Registered Libraries&lt;/i&gt;&amp;nbsp;and &lt;i&gt;JSF 2.0&lt;/i&gt;.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4lwaBsGB1fEAHDGE2lBB-5MGBCMWBmmPEJkDYUcRhyV0V5PXasYfJLSq-pwRmQ9sgFDEc3Y7k5zf3DBVjl0IXKZ6nwIZTYq59GQ6Cl6Pi8Im7MnEyTGE-KFGeze16wuHIOr27HktMOfD2/s1600/frameworks.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;358&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4lwaBsGB1fEAHDGE2lBB-5MGBCMWBmmPEJkDYUcRhyV0V5PXasYfJLSq-pwRmQ9sgFDEc3Y7k5zf3DBVjl0IXKZ6nwIZTYq59GQ6Cl6Pi8Im7MnEyTGE-KFGeze16wuHIOr27HktMOfD2/s640/frameworks.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;h4&gt;1. Simple template and it&#39;s client. &amp;lt;ui:insert&amp;gt; and &amp;lt;ui:define&amp;gt;&lt;/h4&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Ok, we&#39;ll create simpliest template possible. In &lt;i&gt;Web Pages&lt;/i&gt;&amp;nbsp;create new &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;.xhtml&lt;/span&gt; file, let&#39;s name it &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;headerFooter.xhtml&lt;/span&gt;. It&#39;s our template containing header, footer, and place for some content between them.&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVlHdo0R13JAhM90Vg74fzfKkk9F1i_XvpesRmepIwaiZhmBpyWW90s9FzBZ6bDGD_7dzVTLWZT1G7bsCrRZw5MScfcPvksLzFrKzPWwPRfgqOrqgz2rZxidD7j9p-I0qKchon5Gs1uVt9/s1600/simpleTemplate.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;336&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVlHdo0R13JAhM90Vg74fzfKkk9F1i_XvpesRmepIwaiZhmBpyWW90s9FzBZ6bDGD_7dzVTLWZT1G7bsCrRZw5MScfcPvksLzFrKzPWwPRfgqOrqgz2rZxidD7j9p-I0qKchon5Gs1uVt9/s640/simpleTemplate.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;You can let Netbeans create it for you along with nice CSS files, you can also select one of predefined template layouts. Click &lt;i&gt;File -&amp;gt; &amp;nbsp;New File -&amp;gt; JavaServer Faces -&amp;gt; Facelets Template&lt;/i&gt;. Our template code:&lt;/div&gt;&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;?xml version=&#39;1.0&#39; encoding=&#39;UTF-8&#39; ?&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&amp;gt;
&amp;lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
      xmlns:ui=&quot;http://java.sun.com/jsf/facelets&quot;
      xmlns:h=&quot;http://java.sun.com/jsf/html&quot;&amp;gt;
    &amp;lt;h:head&amp;gt;
        &amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&amp;gt;
        &amp;lt;title&amp;gt;Header-Footer Template&amp;lt;/title&amp;gt;
    &amp;lt;/h:head&amp;gt;
    &amp;lt;h:body&amp;gt;
        &amp;lt;div id=&quot;top&quot;&amp;gt;
            Here goes our header
        &amp;lt;/div&amp;gt;
        &amp;lt;div id=&quot;content&quot; class=&quot;center_content&quot;&amp;gt;
            &amp;lt;ui:insert name=&quot;content&quot;&amp;gt;Content&amp;lt;/ui:insert&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div id=&quot;bottom&quot;&amp;gt;
            And here footer
        &amp;lt;/div&amp;gt;
    &amp;lt;/h:body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Now create template client. It is a page which uses the template. Let&#39;s call it &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;templateClient.xhtml&lt;/span&gt;:&lt;/div&gt;&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;?xml version=&#39;1.0&#39; encoding=&#39;UTF-8&#39; ?&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&amp;gt;
&amp;lt;ui:composition xmlns:ui=&quot;http://java.sun.com/jsf/facelets&quot;
                template=&quot;./headerFooter.xhtml&quot;&amp;gt;
    
    &amp;lt;ui:define name=&quot;content&quot;&amp;gt;
        content
    &amp;lt;/ui:define&amp;gt;

&amp;lt;/ui:composition&amp;gt;
&lt;/pre&gt;In template there is &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;ui:insert&amp;gt;&lt;/span&gt; tag. This is a named place where content from template client goes, and it&#39;s name in this case is &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;content&lt;/span&gt;. In client, there is &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;ui:composition&amp;gt;&lt;/span&gt;. It uses template given as tags attribute, and has &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;ui:define&amp;gt;&lt;/span&gt; tags, with the same name as &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;ui:insert&amp;gt;&lt;/span&gt; in template. So what&#39;s in &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;ui:define&amp;gt;&lt;/span&gt; tag is inserted in place of &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;ui:insert&amp;gt;&lt;/span&gt; with the same name. You can run your project (in Netbeans right-click on project and select &lt;i&gt;Run&lt;/i&gt;) and see the templated page&amp;nbsp;at&amp;nbsp;&lt;a href=&quot;http://localhost:8080/JsfTemplating/faces/templateClient.xhtml&quot;&gt;http://localhost:8080/JsfTemplating/faces/templateClient.xhtml&lt;/a&gt;&amp;nbsp;Any content surrounding &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;ui:composition&amp;gt;&lt;/span&gt; tag is ommitted.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhLoEVE59m8CxYf9Pa6bteAGMeKuSZzNql-5o1MrybWvGBRCjyMX_RDtzjg2bhgjCy8si-j8024LAVPR6vcw8KG3yAwi37MiFsMyfk-WgNf4dZxdjwAke-Ain4hUXLCDxTbx5M2HjSkE5R/s1600/dataflow.jpg.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;508&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhLoEVE59m8CxYf9Pa6bteAGMeKuSZzNql-5o1MrybWvGBRCjyMX_RDtzjg2bhgjCy8si-j8024LAVPR6vcw8KG3yAwi37MiFsMyfk-WgNf4dZxdjwAke-Ain4hUXLCDxTbx5M2HjSkE5R/s640/dataflow.jpg.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Template client can also be a template. Just put some&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;ui:insert&amp;gt;&lt;/span&gt;&amp;nbsp;tag inside of&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;ui:define&amp;gt;&lt;/span&gt;&amp;nbsp;block. E.g.&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;ui:define name=&quot;content&quot;&amp;gt;
    &amp;lt;div class=&quot;info&quot;&amp;gt;
        Here goes some additional info, which is not in the header nor in the footer, but we need it on some pages.
    &amp;lt;/div&amp;gt;
    &amp;lt;ui:insert name=&quot;innerContent&quot;&amp;gt;
&amp;lt;/ui:define&amp;gt;
&lt;/pre&gt;&lt;h4&gt;2. Decorate&lt;/h4&gt;We can also insert parts of markup in our pages. If you have piece of code which you put on some pages and it&#39;s always the same, you can separate it to a file and just insert it in the pages. &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;ui:decorate&amp;gt;&lt;/span&gt; tag is used for this:&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;?xml version=&#39;1.0&#39; encoding=&#39;UTF-8&#39; ?&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&amp;gt;
&amp;lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
      xmlns:ui=&quot;http://java.sun.com/jsf/facelets&quot;&amp;gt;
    &amp;lt;body&amp;gt;
        Some page text
        &amp;lt;ui:decorate template=&quot;./disclaimer.xhtml&quot;/&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;Content of &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;disclaimer.xhtml&lt;/span&gt;&amp;nbsp;is injected where&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;ui:decorate&amp;gt;&lt;/span&gt;&amp;nbsp;tag is. Don&#39;t add &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;?xml ... ?&amp;gt;&lt;/span&gt; declaration or doctype there, or it is going to be inserted in the middle of your page, which is not desirable. You can also use standard templating&amp;nbsp;in &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;disclaimer.xhtml&lt;/span&gt;. You can put&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;ui:insert&amp;gt;&lt;/span&gt;&amp;nbsp;there and&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;ui:define&amp;gt;&lt;/span&gt;&amp;nbsp;in page which uses it.&lt;br /&gt;
&lt;h4&gt;3. Include&lt;/h4&gt;Another method to attach some piece of markup is&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;ui:include&amp;gt;&lt;/span&gt;. This one also lets us pass some parameter to the piece of code we want to include, and this parameter can be managed bean. Lets say we have bean with information about some documents:&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;@ManagedBean
public class Paper {

    private String author;
    private String title;

    //getters and setters omitted
}&lt;/pre&gt;Piece of code to display information about a book is prepared in &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;book.xhtml&lt;/span&gt; file:&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&amp;gt;
    Book &quot;#{book.title}&quot; by #{book.author}
&amp;lt;/div&amp;gt;&lt;/pre&gt;Now in any other JSF page we can use it:&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;ui:include src=&quot;./book.xhtml&quot;&amp;gt;
    &amp;lt;ui:param name=&quot;book&quot; value=&quot;#{tomSawyer}&quot; /&amp;gt;
&amp;lt;/ui:include&amp;gt;&lt;/pre&gt;I hope this post is going to be helpful to somebody. At least to me. Happy templating with JSF!&lt;br /&gt;
&lt;/div&gt;&lt;iframe src=&quot;http://www.facebook.com/widgets/like.php?href=http://pawelstawicki.blogspot.com/2010/08/jsf-2-templating.html&quot;
        scrolling=&quot;no&quot; frameborder=&quot;0&quot;
        style=&quot;border:none; width:450px; height:80px&quot;&gt;&lt;/iframe&gt;</description><link>http://pawelstawicki.blogspot.com/2010/08/jsf-2-templating.html</link><author>noreply@blogger.com (pawelstawicki)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjToAlihPvfOXYNeJY-5l_k63EAjlaCIHVispOFKMsUAOV4IaSE8ptFWbASq-XQyssALTzvaoTwKBnIU0pleE8wph4YelN4CkdMfBImivFOjKwuSkprzbXiYb4zJa8IlZRrGbU3TL1Nt8TZ/s72-c/choose+project.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-8495082012833529782</guid><pubDate>Mon, 09 Aug 2010 21:11:00 +0000</pubDate><atom:updated>2010-08-10T09:26:20.309+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jpa</category><category domain="http://www.blogger.com/atom/ns#">puzzle</category><title>JPA Puzzle. When your entity misses some fields.</title><description>Today I encountered quite interesting problem. It wasted few hours of my life, so maybe if you read this you can save some. Example is simplified as much as possible.&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;@Entity
@Table(name = &quot;PERSONS&quot;)
@NamedNativeQueries({
    @NamedNativeQuery(
        name = &quot;getPersonBasic&quot;,
        query = &quot;SELECT p.name, p.surname FROM persons where p.surname = ?&quot;,
        resultClass = Person.class),
    @NamedNativeQuery(
        name = &quot;getPersonDetails&quot;,
        query = &quot;SELECT p.name, p.surname, p.age, p.street, p.city FROM persons where p.surname = ?&quot;,
        resultClass = Person.class)
})
public class Person {
    
    private String name;

    @Id
    private String surname;

    private int age;

    private String street;

    private String city;

}
&lt;/pre&gt;&lt;br /&gt;
Now, in my application I am getting &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Person&lt;/span&gt; with surname &quot;Stawicki&quot; without details, by &lt;i&gt;&quot;getPersonBasic&quot;&lt;/i&gt; query. Then I need detailed person in the same transaction, so I execute &lt;i&gt;&quot;getPersonDetails&quot;&lt;/i&gt;. And... I am getting &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Person&lt;/span&gt; without age, street and city. This three fields are null. Why? Do you already know? If not, look below for answer.&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;
The problem is in cache, and in &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;@Id&lt;/span&gt; which is only on surname field. First person is retrieved without details and stored in cache. Then we try to get person with details, but JPA doesn&#39;t understand difference between our queries. It queries the database, and identifies that if it builds entity from resulting &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;ResultSet&lt;/span&gt;, it is going to have the same &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;@Id&lt;/span&gt; as entity which is already in cache. If &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;@Id&lt;/span&gt; is the same, logically it is the same entity. So it just returns it without building whole entity from &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;ResultSet&lt;/span&gt;.&lt;br /&gt;
&lt;iframe src=&quot;http://www.facebook.com/widgets/like.php?href=http://pawelstawicki.blogspot.com/2010/08/jpa-puzzle-when-your-entity-misses-some.html&quot;
        scrolling=&quot;no&quot; frameborder=&quot;0&quot;
        style=&quot;border:none; width:450px; height:80px&quot;&gt;&lt;/iframe&gt;</description><link>http://pawelstawicki.blogspot.com/2010/08/jpa-puzzle-when-your-entity-misses-some.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-1938916841431681315</guid><pubDate>Tue, 27 Jul 2010 20:57:00 +0000</pubDate><atom:updated>2010-07-28T12:02:48.311+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Real World Java EE Patterns Rethinking Best Practices</category><category domain="http://www.blogger.com/atom/ns#">review</category><title>Review: Real World Java EE Patterns Rethinking Best Practices, by Adam Bien</title><description>&lt;a href=&quot;http://www.amazon.com/Real-World-Patterns-Rethinking-Practices/dp/0557078326?ie=UTF8&amp;amp;tag=pawelsblog-20&amp;amp;link_code=bil&amp;amp;camp=213689&amp;amp;creative=392969&quot; imageanchor=&quot;1&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;Real World Java EE Patterns Rethinking Best Practices&quot; src=&quot;http://ws.amazon.com/widgets/q?MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;ID=AsinImage&amp;amp;WS=1&amp;amp;Format=_SL160_&amp;amp;ASIN=0557078326&amp;amp;tag=pawelsblog-20&quot; /&gt;&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=pawelsblog-20&amp;amp;l=bil&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=0557078326&quot; style=&quot;border: none !important; margin: 0px !important; padding: 0px !important;&quot; width=&quot;1&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&quot;Real World Java EE Patterns&quot; is a book targeted rather for developers with some experience with JEE. If you are a beginner, you can miss some context. If you have some experience with JEE, in this book you&#39;ll probably find solutions to problems that are familiar to you.&lt;br /&gt;
&lt;br /&gt;
Adam Bien is great at explaining difficult topics. Difficult? I didn&#39;t find anything difficult in this book ;) E.g. transactions isolation is explained very clearly. &lt;br /&gt;
&lt;br /&gt;
The book is very good catalog of JEE Patterns. Each pattern is described separately in similar manner. Each chapter has subchapters: &quot;Problem&quot;, &quot;Forces&quot;, &quot;Solution&quot;, &quot;Testing&quot;, &quot;Documentation&quot;, &quot;Consequences&quot; and &quot;Related Patterns&quot;. In &quot;Problem&quot; a reader can find short description of a problem the pattern should solve. &quot;Forces&quot; shows features that solution should have. &quot;Solution&quot; contains description of pattern, what classes it consists of and what is their responsibility. Usually accompanied by very clear and simple pieces of code. In &quot;Testing&quot; and &quot;Documentation&quot; author highlights what should we test when we use certain pattern, and what should be documented (quite obvious, isn&#39;t it?). In &quot;Consequences&quot; we can read about what are pros and cons of the pattern. &quot;Related Patterns&quot; is self explanatory. Most interesting subchapter is &quot;Solution&quot;, and it also has sub-subchapters. One of them is &quot;Rethinking&quot;. It is good part for experienced JEE developers. Adam shows why some patterns are obsolete. It doesn&#39;t mean you should never use it, but in most cases it is no longer necessary in JEE5 or 6. Some patterns, when moved from EJB2 to EJB3, are not adding any value, but instead are adding layer of abstraction and unnecessary complicating the system.&lt;br /&gt;
&lt;br /&gt;
What I like about Adam Bien is that he is not only writing and talking about programming, but he&#39;s also programming. While reading the book, one can feel that the author has real experience with the topic. Sometimes he advices not to use what is common &quot;best practice&quot;, when it is not necessary and is not adding any value. Good programmer should be able to balance pros and cons of possible solutions, not just blindly follow common practice.&lt;br /&gt;
&lt;br /&gt;
There are small mistakes in the book, but only editor ones, like misspellings and formatting mistakes, single lines of code on next/previous page etc. Nothing really annoying, but there is room for improvement on this field.&lt;br /&gt;
&lt;br /&gt;
Thank you Adam for this book!&lt;br /&gt;
&lt;br /&gt;
&lt;iframe src=&quot;http://www.facebook.com/widgets/like.php?href=http://pawelstawicki.blogspot.com/2010/07/review-real-world-java-ee-patterns.html&quot;
        scrolling=&quot;no&quot; frameborder=&quot;0&quot;
        style=&quot;border:none; width:450px; height:80px&quot;&gt;&lt;/iframe&gt;</description><link>http://pawelstawicki.blogspot.com/2010/07/review-real-world-java-ee-patterns.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-2603365714764060619</guid><pubDate>Sun, 30 May 2010 22:23:00 +0000</pubDate><atom:updated>2010-06-07T00:05:49.279+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">transaction isolation</category><title>Transaction isolation level</title><description>&lt;script type=&quot;text/javascript&quot;&gt;var dzone_url = &#39;http://pawelstawicki.blogspot.com/2010/05/transaction-isolation-level.html&#39;;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;var dzone_title = &#39;Transaction isolation levels explained&#39;;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;var dzone_blurb = &#39;Transactions were invented to make operations on database atomic, and to isolate operations made by different users from each other. There are 4 levels of transaction isolations, all have their pros and cons and work differently. In this article I tried to explain what transactions are and the differences between the 4 levels of isolation.&#39;;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;var dzone_style = &#39;2&#39;;&lt;/script&gt;
&lt;script language=&quot;javascript&quot; src=&quot;http://widgets.dzone.com/links/widgets/zoneit.js&quot;&gt;&lt;/script&gt;
&lt;p&gt;
Recently I have read very good explanation of transaction isolation levels in &quot;&lt;a href=&quot;http://press.adam-bien.com/&quot;&gt;Real World Java EE Patterns. Rethinking Best Practices.&lt;/a&gt;&quot; by Adam Bien.
&lt;/p&gt;&lt;p&gt;
Transactions were introduced for two reasons. To make complex operations atomic (all or nothing) and to give possibility to concurrently use resources. Without transactions it is possible that two users (or more specifically actors, this can be some parts of the system, not necessarly live users) read/write the same resource simultaneously, and changes made by one of them are lost and overwriten by the other one.
&lt;/p&gt;
&lt;p&gt;Consider following example document:
&lt;pre&gt;
Cheesecake bottom
250g crunchy bisquits
100g butter

Cheesecake top
900g cottage cheese
250g mascarpone cheese
1 lemon
&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;
Imagine one user gets the document and the other user also is getting the same document. Both users have the same data. Now both of them are editing it. One likes sweeter cake bottom, so adds &quot;2 spoons of sugar&quot; to the recipe, and writes changed recipe back to the database. In database now it looks like this:
&lt;pre&gt;
Cheesecake bottom
250g crunchy bisquits
100g butter
&lt;span style=&quot;color: green;&quot;&gt;2 spoons of sugar&lt;/span&gt;

Cheesecake top
900g cottage cheese
250g mascarpone cheese
1 lemon
&lt;/pre&gt;
&lt;/p&gt;&lt;p&gt;

Meanwhile second user adds &quot;2 eggs&quot; to cheescake top recipe and saves his version:
&lt;pre&gt;
Cheesecake bottom
250g crunchy bisquits
100g butter
&lt;span style=&quot;color: gray; text-decoration: line-through;&quot;&gt;2 spoons of sugar&lt;/span&gt;

Cheesecake top
900g cottage cheese
250g mascarpone cheese
1 lemon
&lt;span style=&quot;color: green;&quot;&gt;2 eggs&lt;/span&gt;
&lt;/pre&gt;

Change made by the first user is lost. In some cases it can lead to inconsistent data.
&lt;/p&gt;&lt;p&gt;
So that&#39;s why transactions were introduced. Transaction isolates changes made by one user from changes made by the other. There are 4 levels of transaction isolation.
&lt;/p&gt;
&lt;p&gt;
&lt;h4&gt;Serializable&lt;/h4&gt;
Transaction locks all necessary resources. If user wants to read or write some resource, it is locked and no one else can read or write it. This level of isolation can easly lead to deadlocks:
&lt;ol&gt;
&lt;li&gt;
User Ann opens transaction. Ann needs resource A, transaction locks it.
&lt;/li&gt;&lt;li&gt;
User John opens another transaction. John needs resource B, transaction locks it.
&lt;/li&gt;&lt;li&gt;
Ann needs resource B, but it is locked, so Ann&#39;s transaction needs to wait until it is released
&lt;/li&gt;&lt;li&gt;
John needs resource A, but it is locked. John&#39;s transaction waits until it is released. Both users wait endlessly.
&lt;/li&gt;
&lt;/ol&gt;
&lt;/p&gt;&lt;p&gt;
If John didn&#39;t need A, he finishes his transaction, B is released and Ann can finish her transaction too.
&lt;/p&gt;&lt;p&gt;
&lt;h4&gt;Repeatable reads&lt;/h4&gt;
Guarantees that the same query will return the same results if executed in one transaction. Even if other transaction modifies resource meanwhile. Exception is adding - new rows can appear in query result. If another transaction deletes existing rows or modifies them, this changes are not visible.
&lt;ol&gt;&lt;li&gt;
Ann opens transaction. She reads names of java4people organizers: &quot;Stawicki&quot; and &quot;Gruchała&quot;.
&lt;/li&gt;&lt;li&gt;
Bob opens transaction and deletes &quot;Stawicki&quot;. Bob commits changes and closes transaction.
&lt;/li&gt;&lt;li&gt;
Again Ann reads names. She gets &quot;Stawicki&quot; and &quot;Gruchała&quot;.
&lt;/li&gt;&lt;/ol&gt;
&lt;/p&gt;&lt;p&gt;
If Bob added some name, Ann would read it too.
&lt;/p&gt;&lt;p&gt;
&lt;h4&gt;Read commited&lt;/h4&gt;
The same query can return different result even in one transaction if another transaction makes changes and commits them.
&lt;ol&gt;&lt;li&gt;
Ann opens transaction and reads names of java4people organizers: &quot;Stawicki&quot; and &quot;Gruchała&quot;.
&lt;/li&gt;&lt;li&gt;
Bob opens transaction and deletes &quot;Stawicki&quot;.
&lt;/li&gt;&lt;li&gt;
Ann reads names again. She gets &quot;Stawicki&quot; and &quot;Gruchała&quot;.
&lt;/li&gt;&lt;li&gt;
Bob commits his transaction
&lt;/li&gt;&lt;li&gt;
Ann reads names again (still in one transaction). She gets &quot;Gruchała&quot;.
&lt;/li&gt;&lt;/ol&gt;
&lt;/p&gt;&lt;p&gt;
&lt;h4&gt;Read uncommited&lt;/h4&gt;
Like no transactions at all. It only gives us atomic operations. User can rollback all the changes in transaction. Changes are visible to other transactions even before commit. Of course, if transaction that made changes is rolled back, changes are not visible any more.
&lt;/p&gt;</description><link>http://pawelstawicki.blogspot.com/2010/05/transaction-isolation-level.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-2274192340944233254</guid><pubDate>Sat, 15 May 2010 10:02:00 +0000</pubDate><atom:updated>2010-05-16T01:07:27.493+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">geecon</category><title>After GeeCON 2010</title><description>&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;
&lt;p&gt;
This year &lt;a href=&quot;http://2010.geecon.org/main/home&quot;&gt;GeeCON&lt;/a&gt; took place in Poznań which is much closer to Szczecin than Cracow. I expected it to be as good as a year before, maybe I expected too much. I don&#39;t mean it was bad, but previous year it was so great that maybe it was hard to keep this level. Or maybe I was not choosing right presentations. There were three tracks this year so choice was sometimes difficult.
&lt;/p&gt;&lt;p&gt;
Like a previous year there was &quot;University Day&quot; before the conference. University Day is day of workshops on various topics. I have chosen Gradle, like many other people. Too many unfortunately. &lt;a href=&quot;http://2010.geecon.org/speakerdetails/30&quot;&gt;Hans&lt;/a&gt; said there are too many attendants to make exercises for everyone, so only he coded live. I missed coding myself.
&lt;/p&gt;&lt;p&gt;
First interesting concept I heard about was &lt;a href=&quot;http://www.objectteams.org/index.html&quot;&gt;Object Teams&lt;/a&gt;. It is a new idea of modularizing our programs, based on entities, collaborations and roles. All three look pretty much like java classes. In OOP there are objects which are data and methods. We can use objects to modularize our applications, but often connections between modules are becoming complicated. Creators of Object Teams concluded that modularization and OOP is not about modules/objects itself but about connections between them. So there are &lt;b&gt;entities&lt;/b&gt;, which represent data. There are &lt;b&gt;collaborations&lt;/b&gt;, that represent operations on data, and &lt;b&gt;roles&lt;/b&gt;. In a collaboration, each entity plays some role. Everything looks pretty and neat, and I wonder if it is going to become popular in coming years. I must admit I haven&#39;t heard about it before.
&lt;/p&gt;&lt;p&gt;
Quite interesting presentation was about &lt;a href=&quot;http://java.sun.com/javaee/javaserverfaces/&quot;&gt;JSF 2.0&lt;/a&gt; by &lt;a href=&quot;http://2010.geecon.org/speakerdetails/1&quot;&gt;Ed Burns&lt;/a&gt;. Nothing quite new for me, but if someone thinks JSF didn&#39;t change much since 1.2 version he should attend this presentation (or watch on &lt;a href=&quot;http://parleys.com/#id=51713&amp;amp;st=4&quot;&gt;GeeCON&#39;s channel on parleys.com&lt;/a&gt; when it becomes available ;)). Guys who created version 2.0 addressed all the problems developers were complaining about with previous versions. I remember Seam was framework which was built on JSF and addressed such problems. Now, when it is solved in JSF itself, I wonder what are differences between Seam and JSF 2.0.
&lt;/p&gt;&lt;p&gt;
On the second day &lt;a href=&quot;http://2010.geecon.org/speakerdetails/5&quot;&gt;Jonas Bonér&lt;/a&gt; was talking about actors, agents, STM and other solutions making concurrent programming much easier than threads with shared state and locks. Next time I&#39;ll need to do some concurrent programming in Java I&#39;ll definitely use something from Akka.
&lt;/p&gt;&lt;p&gt;
&lt;a href=&quot;http://2010.geecon.org/speakerdetails/18&quot;&gt;Vaclav Pech&lt;/a&gt;&#39;s presentation was quite similar. He also talked about concurrent programming with actors, but in Groovy. As usual Vaclav gave very good presentation.
&lt;/p&gt;&lt;p&gt;
&lt;a href=&quot;http://vaadin.com/home&quot;&gt;Vaadin&lt;/a&gt; is the next thing I want to use. At work I use &lt;a href=&quot;http://code.google.com/webtoolkit/&quot;&gt;GWT&lt;/a&gt; and I don&#39;t really like it. GWT compilation is very long and asynchronous callbacks are making code more complicated. Besides most of work is done on the server anyway. Programming in Vaadin is very similar to programming in GWT, but everything is server side. Vaadin uses GWT for presentation, so it is possible to write custom components for Vaadin in GWT, but then compilation is needed only once. Damn, this could save many hours of my life.
&lt;/p&gt;&lt;p&gt;
&lt;a href=&quot;http://2010.geecon.org/speakerdetails/3&quot;&gt;Bruno Bossola&lt;/a&gt;&#39;s presentation was very good and funny. No suprise here :) Bruno talks about things that many developers really need. I agree somewhere we lost real &lt;b&gt;Object Oriented&lt;/b&gt; programming. Bruno also mentioned a book which I feel is unfairly forgotten. &quot;&lt;a href=&quot;http://www.amazon.com/Applying-UML-Patterns-Introduction-Object-Oriented/dp/0131489062/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1273964626&amp;amp;sr=8-1&quot;&gt;Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development&lt;/a&gt;&quot; by Craig Larman. When I started working for &lt;a href=&quot;http://www.ncdc.pl/&quot;&gt;NCDC&lt;/a&gt; more than few years ago, my boss put this book to company&#39;s library and recommended it to us. I read it and I feel it made me a better developer. If you put all your code into one huge class or even method, buy or borrow this book and read it. Even if it&#39;s old it&#39;s worth it. Some things don&#39;t change even in IT ;)
&lt;/p&gt;&lt;p&gt;
If I can have some hint for the organizers I&#39;d like to suggest to make presentations longer. Many presenters didn&#39;t manage to show everything they wanted. I think 1.5 hour is minimum.
&lt;/p&gt;&lt;p&gt;
I heard food was also a problem on the first day. It didn&#39;t suffice for everybody, but I managed to grab my plate so I don&#39;t complain :)&lt;/p&gt;
&lt;/span&gt;</description><link>http://pawelstawicki.blogspot.com/2010/05/after-geecon-2010.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>0</thr:total></item></channel></rss>