You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2012/02/22 04:19:45 UTC

svn commit: r1292114 - in /camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer: PrinterOperations.java PrinterProducer.java

Author: ningjiang
Date: Wed Feb 22 03:19:44 2012
New Revision: 1292114

URL: http://svn.apache.org/viewvc?rev=1292114&view=rev
Log:
CAMEL-5023 Fixed the issue that Printer endpoint can only print a single job.

Modified:
    camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperations.java
    camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java

Modified: camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperations.java?rev=1292114&r1=1292113&r2=1292114&view=diff
==============================================================================
--- camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperations.java (original)
+++ camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperations.java Wed Feb 22 03:19:44 2012
@@ -39,7 +39,6 @@ import org.slf4j.LoggerFactory;
 public class PrinterOperations implements PrinterOperationsInterface {
     private static final transient Logger LOG = LoggerFactory.getLogger(PrinterOperations.class);
     private PrintService printService;
-    private DocPrintJob job;
     private DocFlavor flavor;
     private PrintRequestAttributeSet printRequestAttributeSet;
     private Doc doc;
@@ -49,7 +48,6 @@ public class PrinterOperations implement
         if (printService == null) {
             throw new PrintException("Printer lookup failure. No default printer set up for this host");
         }
-        job = printService.createPrintJob(); 
         flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
         printRequestAttributeSet = new HashPrintRequestAttributeSet();
         printRequestAttributeSet.add(new Copies(1));
@@ -57,10 +55,9 @@ public class PrinterOperations implement
         printRequestAttributeSet.add(Sides.ONE_SIDED);
     }
 
-    public PrinterOperations(PrintService printService, DocPrintJob job, DocFlavor flavor, PrintRequestAttributeSet printRequestAttributeSet) throws PrintException {
+    public PrinterOperations(PrintService printService, DocFlavor flavor, PrintRequestAttributeSet printRequestAttributeSet) throws PrintException {
         this();
         this.setPrintService(printService);
-        this.setJob(job);
         this.setFlavor(flavor);
         this.setPrintRequestAttributeSet(printRequestAttributeSet);
     }
@@ -104,6 +101,8 @@ public class PrinterOperations implement
     }
         
     public void print(Doc doc) throws PrintException {
+        // we need create a new job for each print 
+        DocPrintJob job = getPrintService().createPrintJob();
         job.print(doc, printRequestAttributeSet);
     }
 
@@ -114,15 +113,7 @@ public class PrinterOperations implement
     public void setPrintService(PrintService printService) {
         this.printService = printService;
     }
-
-    public DocPrintJob getJob() {
-        return job;
-    }
-
-    public void setJob(DocPrintJob job) {
-        this.job = job;
-    }
-
+    
     public DocFlavor getFlavor() {
         return flavor;
     }

Modified: camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java?rev=1292114&r1=1292113&r2=1292114&view=diff
==============================================================================
--- camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java (original)
+++ camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java Wed Feb 22 03:19:44 2012
@@ -150,7 +150,7 @@ public class PrinterProducer extends Def
         ObjectHelper.notNull(printService, "PrintService", this);
 
         if (printerOperations == null) {
-            printerOperations = new PrinterOperations(printService, assignPrintJob(printService), assignDocFlavor(), assignPrintAttributes());
+            printerOperations = new PrinterOperations(printService, assignDocFlavor(), assignPrintAttributes());
         }
         super.doStart();
     }