<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>public static final</title>
	<atom:link href="http://www.publicstaticfinal.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.publicstaticfinal.de</link>
	<description>the constant Java blog</description>
	<lastBuildDate>Fri, 25 Feb 2011 14:48:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Weak References in Java</title>
		<link>http://www.publicstaticfinal.de/2011/02/25/weak-references-in-java/</link>
		<comments>http://www.publicstaticfinal.de/2011/02/25/weak-references-in-java/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 14:48:53 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[Weak Reference]]></category>

		<guid isPermaLink="false">http://www.publicstaticfinal.de/?p=169</guid>
		<description><![CDATA[Ever heard of Weak References in Java? Well, me neither. But it really sounds useful and you should give it a try.]]></description>
			<content:encoded><![CDATA[<p>Ever heard of <a title="Weak References in Java" href="http://weblogs.java.net/blog/2006/05/04/understanding-weak-references" target="_blank">Weak References</a> in Java? Well, me neither. But it really sounds useful and you should give it a try.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.publicstaticfinal.de/2011/02/25/weak-references-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FOP: Embedding fonts from classpath</title>
		<link>http://www.publicstaticfinal.de/2011/01/26/fop-embedding-fonts-from-classpath/</link>
		<comments>http://www.publicstaticfinal.de/2011/01/26/fop-embedding-fonts-from-classpath/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 07:37:33 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[FOP]]></category>
		<category><![CDATA[PDF]]></category>

		<guid isPermaLink="false">http://www.publicstaticfinal.de/?p=163</guid>
		<description><![CDATA[If you&#8217;re using Apache FOP to create PDF/A you&#8217;re forced to embed all fonts (even the base 14 fonts).  Generally there are two options how to embed the fonts: Let FOP auto-detect the fonts Create a font metrics file and tell FOP where to find it Auto-detection is a pretty nice feature since FOP does [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using <a title="Apache FOP" href="http://xmlgraphics.apache.org/fop/" target="_blank">Apache FOP</a> to create PDF/A you&#8217;re forced to embed all fonts (even the base 14 fonts).  Generally there are two options how to embed the fonts:</p>
<ol>
<li>Let FOP auto-detect the fonts</li>
<li>Create a font metrics file and tell FOP where to find it</li>
</ol>
<p><span id="more-163"></span>Auto-detection is a pretty nice feature since FOP does the job to find and interpret the font.  The major drawback of this solution is that FOP scans different places for fonts (the default font folders of the OS,  every folder in &#8220;.&#8221; and it looks for special entries in MANIFEST.MF). This is done every time you create a new Fop instance. You can guess how that might effect an application if it&#8217;s creating lots of PDF files.</p>
<p>To improve the performance you can create font metrics files an tell FOP where to find them. Compared to auto-detection this is a cheap operation. But there&#8217;s also a drawback: URIs to the files have to absolute paths. Especially if you&#8217;re using different environments  (Development, Testing, Pre-Production etc.) absolute paths are hard to find.</p>
<p>Wouldn&#8217;t it be nice if you can put your font files in a JAR and FOP just finds it? FOP can&#8217;t do it by default but you can teach FOP how to. First you have to implement an URIResolver:</p>
<pre class="brush: java; title: ; notranslate">
import java.io.InputStream;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.URIResolver;
import javax.xml.transform.stream.StreamSource;

public class ClasspathUriResolver implements URIResolver
{

  public Source resolve(String href, String base) throws TransformerException
  {
    Source source = null;
    InputStream inputStream = ClassLoader.getSystemResourceAsStream(href);
    if (inputStream != null)
    {
      source = new StreamSource(inputStream);
    }
    return source;
  }
}
</pre>
</pre>
<p>The next step is to register this URIResolver as a custom URIResolver. You can access the default URIResolver via the FopFactory:</p>
<pre class="brush: java; title: ; notranslate">
FopFactory fopFactory = FopFactory.newInstance();
FOURIResolver uriResolver = (FOURIResolver) fopFactory.getURIResolver();

uriResolver.setCustomURIResolver(new ClasspathUriResolver());
</pre>
</pre>
<p>FOP now tries to find the font and metrics file with its built in feature and if no files are found the ClasspathUriResolver is called. If still no font can be found an PDFConformanceException is thrown.</p>
<p>The final step is to put your files somewhere in the classpath (best choice would be a JAR file). If you're putting them in a JAR file in the folder fonts the appropriate FOP config would look like:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;renderers&gt;
 &lt;renderer mime=&quot;application/pdf&quot;&gt;
   &lt;fonts&gt;
     &lt;!-- Arial  --&gt;
     &lt;font
       metrics-url=&quot;\fonts\arial.xml&quot;
       kerning=&quot;yes&quot;
       embed-url=&quot;\fonts\arial.ttf&quot;&gt;
       &lt;font-triplet name=&quot;Arial&quot; style=&quot;normal&quot; weight=&quot;normal&quot; /&gt;
       &lt;font-triplet name=&quot;ArialMT&quot; style=&quot;normal&quot; weight=&quot;normal&quot; /&gt;
     &lt;/font&gt;
   &lt;/fonts&gt;
 &lt;/renderer&gt;
</pre>
</pre>
<p>FOP now finds the font and can embed it. Since the file is loaded into the Classloader ever subsequent lookup is very fast. If you don't want to open an InputStream every time and you don't have many fonts you can cache the contents in a byte[] and put an ByteArrayInputStream in the StreamSource.</p>
<p>For comparison: When I use auto-detection creating a new Fop instance takes about 300 ms. Using predefined metrics files the instance is created &lt; 20 ms.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.publicstaticfinal.de/2011/01/26/fop-embedding-fonts-from-classpath/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>String concatenation</title>
		<link>http://www.publicstaticfinal.de/2010/08/21/string-concatenation/</link>
		<comments>http://www.publicstaticfinal.de/2010/08/21/string-concatenation/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 12:09:05 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[String]]></category>

		<guid isPermaLink="false">http://www.publicstaticfinal.de/?p=148</guid>
		<description><![CDATA[One of the first things developers learn about String concatenation in Java is that the &#8220;+&#8221; operation does the magic. In this case the magician is the compiler. Lets look how the following code snippet gets translated by the compiler. Every time the String concatenation is invoked a new StringBuilder instance is created and but [...]]]></description>
			<content:encoded><![CDATA[<p>One of the first things developers learn about String concatenation in Java is that the &#8220;+&#8221; operation does the magic. In this case the magician is the compiler. Lets look how the following code snippet gets translated by the compiler.</p>
<pre class="brush: java; title: ; notranslate">
// Sample.java
String buffer = &quot;&quot;;
for (String string : listOfStrings)
{
  buffer += string;
}
</pre>
<pre class="brush: java; title: ; notranslate">
// Sample.class
String buffer = &quot;&quot;;
for (String string : listOfString)
{
  buffer = new StringBuilder(buffer).append(string).toString();
}
</pre>
</pre>
<p>Every time the String concatenation is invoked a new StringBuilder instance is created and but never assigned. Hence it is immediately eligible for Garbace Collection. What a waste of Memory. If you really need to concat Strings in a loop you better do it directly with a StringBuilder.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.publicstaticfinal.de/2010/08/21/string-concatenation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RIP Sun</title>
		<link>http://www.publicstaticfinal.de/2010/01/22/rip-sun/</link>
		<comments>http://www.publicstaticfinal.de/2010/01/22/rip-sun/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 11:49:32 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[Sun]]></category>

		<guid isPermaLink="false">http://www.publicstaticfinal.de/?p=141</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.publicstaticfinal.de/wp-content/uploads/2010/01/SunRIPsmall.jpg" rel="thumbnail"><img class="alignnone size-medium wp-image-140" title="SunRIPsmall" src="http://www.publicstaticfinal.de/wp-content/uploads/2010/01/SunRIPsmall-300x234.jpg" alt="" width="581" height="452" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.publicstaticfinal.de/2010/01/22/rip-sun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One cold day in hell</title>
		<link>http://www.publicstaticfinal.de/2010/01/12/one-cold-day-in-hell/</link>
		<comments>http://www.publicstaticfinal.de/2010/01/12/one-cold-day-in-hell/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 10:05:03 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Fun]]></category>

		<guid isPermaLink="false">http://www.publicstaticfinal.de/?p=137</guid>
		<description><![CDATA[Chemistry class at Maynooth University in Kildare, Ireland. The answer a professor got from one of his students was so &#8220;deep&#8221; he had to pass it to his colleages via internet: Bonus-question: &#8220;Is hell &#8220;exotherm&#8221; (gives off heat), or &#8220;endotherm&#8221;(absorbs heat)? Most students assumed with the help of Boyles law that gas cools down while [...]]]></description>
			<content:encoded><![CDATA[<p>Chemistry class at Maynooth University in Kildare, Ireland.</p>
<p>The answer a professor got from one of his students was so &#8220;deep&#8221; he had to pass it to his colleages via internet:</p>
<p>Bonus-question:</p>
<p>&#8220;Is hell &#8220;exotherm&#8221; (gives off heat), or &#8220;endotherm&#8221;(absorbs heat)?</p>
<p><span id="more-137"></span> Most students assumed with the help of Boyles law that gas cools down while expanding. One student however came up with this answer:</p>
<p>&#8220;First we need to find out how the mass of hell changes over time.<br />
To be able to do this we need to first find out how many souls venture into hell and out of it.</p>
<p>It is my opinion, that souls , once they&#8217;ve entered into hell, won&#8217;t leave it again.</p>
<p>That&#8217;s why no soul ever leaves hell again.</p>
<p>Concerning the question how many souls go to hell, the opinions of the religions existing today, can give us an answer.</p>
<p>Most religions assert that you go to hell when you&#8217;re not one of them.<br />
Since there is more than one religion and because you can&#8217;t belong to more than one of them you can assume further that all souls go to hell.</p>
<p>Wíth birth- and deathrates of today we can further assume that the amount of souls will exponentially increase.</p>
<p>Let&#8217;s now take a look at the size of hell.<br />
According to Boyles law the size of hell must increase proportional to the arriving souls or else we have two options:</p>
<p>1.: In case hell expands slower than the number of souls arriving, both temperature and pressure inside of hell will increase so much that the whole hell falls apart.</p>
<p>2. In case the hell expands faster then the amount of new guests then temperature and pressure will fall causing the hell to freeze up.</p>
<p>Now which is it?</p>
<p>When we take into consideration Sandra&#8217;s statement to me in our first year here, that it will be a cold day in hell before she&#8217;d go to bed with me as well as the fact that I slept with her last night only number 2 can be valid.</p>
<p>That&#8217;s why I&#8217;m convinced that hell is endotherm and must be already frozen up.</p>
<p>My conclusion is, that hell can not accept any further souls and is therefore extinct&#8230;.and so only heaven is still existing. This however, proves the existance of God, which explains why Sandra screamed: °Oh, my God!!!° the whole last evening.&#8221;</p>
<p>This student was the only one who got an &#8220;A&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.publicstaticfinal.de/2010/01/12/one-cold-day-in-hell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Collections Library 1.0 available</title>
		<link>http://www.publicstaticfinal.de/2010/01/04/google-collections-library-1-0-available/</link>
		<comments>http://www.publicstaticfinal.de/2010/01/04/google-collections-library-1-0-available/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 08:56:12 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Framework]]></category>

		<guid isPermaLink="false">http://www.publicstaticfinal.de/?p=128</guid>
		<description><![CDATA[Last year on Dec, 30th Google released version 1.0 of it&#8217;s Collections framework. Although Apache Commons Collections provide a rich set of enhancements to the standard Collections framework Google&#8217;s implementation has two big advantages: Based on Java 1.5 and hence using Generics More standard compliant (Commons Collections occasionally break standard behavior) Go to their website [...]]]></description>
			<content:encoded><![CDATA[<p>Last year on Dec, 30th Google released version 1.0 of it&#8217;s Collections framework. Although Apache Commons Collections provide a rich set of enhancements to the standard Collections framework Google&#8217;s implementation has two big advantages:</p>
<ul>
<li>Based on Java 1.5 and hence using Generics</li>
<li>More standard compliant (Commons Collections occasionally break standard behavior)</li>
</ul>
<p>Go to their <a title="Google Collections" href="http://code.google.com/p/google-collections/" target="_blank">website</a> and make sure to read the <a title="Google Collections FAQ" href="http://code.google.com/p/google-collections/wiki/Faq" target="_blank">FAQ</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.publicstaticfinal.de/2010/01/04/google-collections-library-1-0-available/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Save MySQL! campaign</title>
		<link>http://www.publicstaticfinal.de/2009/12/30/save-mysql-campaign/</link>
		<comments>http://www.publicstaticfinal.de/2009/12/30/save-mysql-campaign/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 09:34:32 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.publicstaticfinal.de/?p=123</guid>
		<description><![CDATA[Michael &#8220;Monty&#8221; Widenius, the man who brough us joy and pain by creating MySQL, has started a campaign for saving MySQL. He demands that that the European Commission should only approve the Oracle/Sun deal if MySQL will be sold to a competitor or Oralce guarantees (by signing some paper) that all previous version of MySQL [...]]]></description>
			<content:encoded><![CDATA[<p>Michael &#8220;Monty&#8221; Widenius, the man who brough us joy and pain by creating MySQL, has started a campaign for saving MySQL. He demands that that the European Commission should only approve the Oracle/Sun deal if</p>
<ul>
<li>MySQL will be sold to a competitor or</li>
<li>Oralce guarantees (by signing some paper) that all previous version of MySQL will still be freely available and additionly will be released as free years for the next three years.</li>
</ul>
<p>I&#8217;m not giving anyone an advice whether to sign the petition or not but everyone should take a look at the <a title="Help MySQL" href="http://www.helpmysql.org" target="_blank">campaign </a>and decide on which side he or she stands. More information about the topic and a little Q &amp;A can be found at <a title="Monty Says" href="http://monty-says.blogspot.com/2009/12/help-keep-internet-free.html" target="_blank">Monty&#8217;s blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.publicstaticfinal.de/2009/12/30/save-mysql-campaign/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Closures in Java</title>
		<link>http://www.publicstaticfinal.de/2009/12/14/closures-in-java/</link>
		<comments>http://www.publicstaticfinal.de/2009/12/14/closures-in-java/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 10:37:27 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[Closures]]></category>
		<category><![CDATA[JSE7]]></category>

		<guid isPermaLink="false">http://www.publicstaticfinal.de/?p=117</guid>
		<description><![CDATA[One of the most discussed (and most controversial) topics in the last years concerning the future of Java was the introduction of Closures. After 2008&#8242;s Devoxx Closures were off the Java7 release. One year later at the same event Mark Reinhold revoked it and announced that Closures will be in Java7 (and hence delaying Java [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most discussed (and most controversial) topics in the last years concerning the future of Java was the introduction of <a title="Wikipedia: Closures" href="http://en.wikipedia.org/wiki/Closure_(computer_science)" target="_blank">Closures</a>. After 2008&#8242;s Devoxx Closures were off the Java7 release. One year later at the same event Mark Reinhold revoked it and announced that Closures will be in Java7 (and hence <a title="Java7 will be delayed" href="http://mail.openjdk.java.net/pipermail/jdk7-dev/2009-November/001054.html" target="_blank">delaying Java 7 for a few months</a>).<span id="more-117"></span></p>
<p>For days ago, Reinhold published a<a href="http://cr.openjdk.java.net/~mr/lambda/straw-man/" target="_blank"> straw-man proposal</a> of how closures (or more formal: lambda expressions) could look like in Java. I&#8217;m still not sure whether I&#8217;m happy about closures in Java or not. On the one hand it definitely helps to reduce the number of lines of code since it drops redundant information (e.g. the decleration of a Runnable).</p>
<pre class="brush: java; title: ; notranslate">
Thread th = new Thread(new Runnable() {
                         public void run() {
                            doSomeStuff();
                            doMoreStuff();
                         }
                       });

Thread th = new Thread(#(){ doSomeStuff(); doMoreStuff(); } )
</pre>
<p>On the other hand it increases the complexity of the JVM itself and makes maintenance a bit harder. This will affect only few developers but it&#8217;s another stop to the grave of Java (death by non-maintainability).</p>
<p>I think time will tell how Closures will affect the Java world and if it&#8217;s a good idea to include it or not.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.publicstaticfinal.de/2009/12/14/closures-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaEE 6 has been approved</title>
		<link>http://www.publicstaticfinal.de/2009/12/02/javaee-6-has-been-approved/</link>
		<comments>http://www.publicstaticfinal.de/2009/12/02/javaee-6-has-been-approved/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 08:32:54 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[JavaEE]]></category>
		<category><![CDATA[JavaEE 6]]></category>
		<category><![CDATA[Web Profile]]></category>

		<guid isPermaLink="false">http://www.publicstaticfinal.de/?p=114</guid>
		<description><![CDATA[On Monday the final votes for &#8220;JSR 316: Java Platform, Enterprise Edition 6 (Java EE 6) Specification&#8221; have been submitted and with little surprise it has been approved. JavaEE6 marks a major milestone in enterprise Java with the arrival of subspecs such as CDI, JPA2, EJB 3.1 (with EJB Lite) or Servlet 3.0. But the [...]]]></description>
			<content:encoded><![CDATA[<p>On Monday the final votes for &#8220;JSR 316: Java Platform, Enterprise Edition 6 (Java EE 6) Specification&#8221; have been submitted and with little surprise it has been approved.</p>
<p>JavaEE6 marks a major milestone in enterprise Java with the arrival of subspecs such as CDI, JPA2, EJB 3.1 (with EJB Lite) or Servlet 3.0. But the most important part for me is the new web profile which was really overdue.<span id="more-114"></span>JavaEE5 left web developers somewhere between all or nothing. POSCs (Plain Old Servlet Containers) proveded not all of the JEE stack that might be needed while full blown application servers like JBoss were too heavy (although JBoss did a&lt; good job with the different profiles).</p>
<p>Integrating different Frameworks into POSCs can be really a pain in the ass. Take JPA for example. JPA in a POSC is nothing more than a JavaSE usage of the JPA. Which means there are no manged transactions no container managed persistence contexts etc. Everything had to be custom made which is not the desired way.</p>
<p>With the new web profile you only get what you really need: Servlets, JPA2, JTA, CDI, EJB Lite which makes web development a lot easier. But not only the developer benefits but also the vendors since they don&#8217;t have to implement the full stack.</p>
<p>Hopefully vendors will jump on the JEE6 train and there will be a vibrant market of implementations.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.publicstaticfinal.de/2009/12/02/javaee-6-has-been-approved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It&#8217;s /WEB-INF/classes/META-INF</title>
		<link>http://www.publicstaticfinal.de/2009/11/10/its-web-infclassesmeta-inf/</link>
		<comments>http://www.publicstaticfinal.de/2009/11/10/its-web-infclassesmeta-inf/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 09:42:54 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[JavaEE]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://www.publicstaticfinal.de/?p=110</guid>
		<description><![CDATA[Note to myself (which might help others): In a web application always put the stuff (which is not packaged a single JARs)  in /WEB-INF/classes/META-INF (e.g. persistence.xml or service files) and not in /META-INF. Otherwise the various applications will not be able to locate them.]]></description>
			<content:encoded><![CDATA[<p>Note to myself (which might help others):</p>
<p>In a web application always put the stuff (which is not packaged a single JARs)  in <strong>/WEB-INF/classes/META-INF</strong> (e.g. persistence.xml or service files) and not in /META-INF. Otherwise the various applications will not be able to locate them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.publicstaticfinal.de/2009/11/10/its-web-infclassesmeta-inf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

