Example #1
0
 /**
  * Method that calls print() methods on each printer
  *
  * @param message message to log
  * @throws PrinterManagerException
  */
 public void print(String message) throws PrinterManagerException {
   PrinterManagerException printerManagerException = new PrinterManagerException();
   for (Printer printer : printers) {
     try {
       printer.print(message);
     } catch (PrinterException e) {
       printerManagerException.addPrinterException(e);
     }
   }
   if (!printerManagerException.getPrinterExceptions().isEmpty()) {
     throw printerManagerException;
   }
 }
Example #2
0
 public void closePrinters() throws PrinterManagerException {
   PrinterManagerException printerManagerException = new PrinterManagerException();
   for (Printer printer : printers) {
     if (printer instanceof Closeable) {
       try {
         ((Closeable) printer).close();
       } catch (PrinterException e) {
         printerManagerException.addPrinterException(e);
       }
     }
   }
   if (!printerManagerException.getPrinterExceptions().isEmpty()) {
     throw printerManagerException;
   }
 }