commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jukka Zitting <jukka.zitt...@gmail.com>
Subject Re: Re: [IO] encapsulating open/close
Date Fri, 06 Aug 2010 10:09:22 GMT
Hi,

On Fri, Aug 6, 2010 at 10:54 AM,  <Sebastian.Petzelberger@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-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message