#502 Replaced usages of System.out with logger.
This commit is contained in:
@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.resource.acquisition.is.initialization;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* Resource Acquisition Is Initialization pattern was developed for exception safe resource
|
||||
@ -44,17 +47,19 @@ package com.iluwatar.resource.acquisition.is.initialization;
|
||||
*/
|
||||
public class App {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
try (SlidingDoor slidingDoor = new SlidingDoor()) {
|
||||
System.out.println("Walking in.");
|
||||
LOGGER.info("Walking in.");
|
||||
}
|
||||
|
||||
try (TreasureChest treasureChest = new TreasureChest()) {
|
||||
System.out.println("Looting contents.");
|
||||
LOGGER.info("Looting contents.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.resource.acquisition.is.initialization;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* SlidingDoor resource
|
||||
@ -29,12 +32,14 @@ package com.iluwatar.resource.acquisition.is.initialization;
|
||||
*/
|
||||
public class SlidingDoor implements AutoCloseable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SlidingDoor.class);
|
||||
|
||||
public SlidingDoor() {
|
||||
System.out.println("Sliding door opens.");
|
||||
LOGGER.info("Sliding door opens.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
System.out.println("Sliding door closes.");
|
||||
LOGGER.info("Sliding door closes.");
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.resource.acquisition.is.initialization;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
@ -32,12 +35,14 @@ import java.io.IOException;
|
||||
*/
|
||||
public class TreasureChest implements Closeable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TreasureChest.class);
|
||||
|
||||
public TreasureChest() {
|
||||
System.out.println("Treasure chest opens.");
|
||||
LOGGER.info("Treasure chest opens.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
System.out.println("Treasure chest closes.");
|
||||
LOGGER.info("Treasure chest closes.");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user