Hi, On Fri, Aug 6, 2010 at 10:54 AM, <sebastian.petzelber...@aformatik.com> wrote: > My suggestion is providing an interface and a convenience method, which an > expression of this interface als argument. In this method opening and > closing will be done. I think, this would be the natural way in java. When > closures came, the client code will look short.
OK, I see what you're after. Not sure though if there can be any clean API (i.e. one that's less verbose than a "open(); try { ... } finally { close(); }" block) for that without language extensions. The best solutions I've seen are the automatic resource management blocks [1] proposed for Java 7 and the @Cleanup annotation [2] from Project Lombok. [1] http://mail.openjdk.java.net/pipermail/coin-dev/2009-April/001481.html [2] http://projectlombok.org/features/Cleanup.html BR, Jukka Zitting --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org