a mac and glasses

A Less Mixin for JSF 2 Resource Handling

JSF 2.0 introduced it’s own resource handling. One of the disadvantages of this solution is, that referring to an images inside your CSS doesn’t work the common way:

.foo {
    background-image: url('images/logo.gif'); // doesn't work with JSF 2.x
}

You need to use expression language like:

.foo {
    background-image: url("#{resource['images/logo.gif']}");
}

Now if you are using LESS and don’t want to write this expression over and over again—you need a mixin:

.background-image(@filename) {
    background-image: e(%("url(#{resource['images:%s']})", @filename));
}
public class FooService {

    // TODO: remove me!
    // public final static String NOT_YET = "";

    ...
}

(Taken from production code)

clock

Timeout Configuration in HikariCP, DB2 and MySQL

Motivation

Michael T. Nygard warns in “Release it” [1] about the lack of timeouts caused by misconfigured database drivers and connection pools. He argues that if a connection pool gets exhausted when none of its calls return than all others threads get blocked as soon as they require a connection too. His advice is:

Scrutinize Resource Pools
Safe resource pools always limit the time a thread can wait to check out a resource.
(Michael T. Nygard, “Release it”, P. 50)

So I wondered, whether the connection pool HikariCP as well as the JDBC-driver of IBM DB2 and MySQL already ships with default timeouts (and how to adjust them).

Read more

Repair Artifact Captions when downgrading a Visual Paradigm Project

Lately I was forced to downgrade a Visual Paradigm Project [1] from version 10.1 to version 9.

As stated in the Visual Paradigm Know-How Area ([2]) this could easily be done by exporting the project to XML (note: not XMI) and re-import it in the older program version. But after doing so all of my artifact’s captions were stick to the upper left corner of the diagrams. There was no chance to move the captions to the correct positions but only to replace the artifacts with new ones. But this is a very time consuming (and annoying) task.

Then I found a more automated solution:

  1. Open the exported xml-file with a text editor (like Notepad++ [3]).
  2. Find and remove all caption-tags.
    In Notepad++ this can be done using the function „search & replace“ in combination with the regular expression „“. Replace with an empty string.
  3. Import the modified xml-file in the older Visual Paradigm installation. Now there are no captions shown at all.
  4. Select all elements in your diagram (STRG+A) and simply move the selection a bit. As a result all captions appear at their original positions (inside the artifacts).

Please note: this does the the job for me. But I really cannot guarantee for success on bigger or more complex Visual Paradigm Projects. Just give it a try—if you have to downgrade, there’s nothing to loose :-).