X Tutup
Skip to content

Commit ace8b3e

Browse files
committed
iluwatar#107 RAII example JavaDoc
1 parent 57a271d commit ace8b3e

File tree

2 files changed

+18
-8
lines changed
  • resource-acquisition-is-initialization/src
    • main/java/com/iluwatar/resource/acquisition/is/initialization
    • test/java/com/iluwatar/resource/acquisition/is/initialization

2 files changed

+18
-8
lines changed

resource-acquisition-is-initialization/src/main/java/com/iluwatar/resource/acquisition/is/initialization/App.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,32 @@
55
* Resource Acquisition Is Initialization pattern was developed
66
* for exception safe resource management by C++ creator Bjarne
77
* Stroustrup.
8-
*
8+
* <p>
99
* In RAII resource is tied to object lifetime: resource allocation
1010
* is done during object creation while resource deallocation is
1111
* done during object destruction.
12-
*
12+
* <p>
1313
* In Java RAII is achieved with try-with-resources statement and
14-
* interfaces Closeable and AutoCloseable. The try-with-resources
14+
* interfaces {@link Closeable} and {@link AutoCloseable}. The try-with-resources
1515
* statement ensures that each resource is closed at the end of the
16-
* statement. Any object that implements java.lang.AutoCloseable, which
17-
* includes all objects which implement java.io.Closeable, can be used
16+
* statement. Any object that implements {@link java.lang.AutoCloseable}, which
17+
* includes all objects which implement {@link java.io.Closeable}, can be used
1818
* as a resource.
1919
*
20-
* In this example, SlidingDoor implements AutoCloseable and
21-
* TreasureChest implements Closeable. Running the example, we can
20+
* In this example, {@link SlidingDoor} implements {@link AutoCloseable} and
21+
* {@link TreasureChest} implements {@link Closeable}. Running the example, we can
2222
* observe that both resources are automatically closed.
23-
*
23+
* <p>
2424
* http://docs.oracle.com/javase/7/docs/technotes/guides/language/try-with-resources.html
2525
*
2626
*/
2727
public class App {
2828

29+
/**
30+
* Program entry point
31+
* @param args command line args
32+
* @throws Exception
33+
*/
2934
public static void main( String[] args ) throws Exception {
3035

3136
try (SlidingDoor slidingDoor = new SlidingDoor()) {

resource-acquisition-is-initialization/src/test/java/com/iluwatar/resource/acquisition/is/initialization/AppTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
import com.iluwatar.resource.acquisition.is.initialization.App;
66

7+
/**
8+
*
9+
* Application test
10+
*
11+
*/
712
public class AppTest {
813

914
@Test

0 commit comments

Comments
 (0)
X Tutup