Author: davsclaus
Date: Fri Sep 18 12:31:57 2009
New Revision: 816600
URL: http://svn.apache.org/viewvc?rev=816600&view=rev
Log:
Polished code and fixed CS.
Modified:
camel/trunk/components/camel-printer/pom.xml
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/DocFlavorAssigner.java
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/MediaSizeAssigner.java
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrintDocument.java
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterComponent.java
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterConfiguration.java
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterEndpoint.java
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/PrinterOperationsInterface.java
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
Modified: camel/trunk/components/camel-printer/pom.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/pom.xml?rev=816600&r1=816599&r2=816600&view=diff
==============================================================================
--- camel/trunk/components/camel-printer/pom.xml (original)
+++ camel/trunk/components/camel-printer/pom.xml Fri Sep 18 12:31:57 2009
@@ -20,124 +20,89 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.camel</groupId>
- <artifactId>components</artifactId>
- <version>2.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>camel-printer</artifactId>
- <packaging>bundle</packaging>
- <name>Camel :: Printer</name>
- <description>Camel Printer support</description>
-
- <properties>
-
<camel.osgi.export.pkg>org.apache.camel.component.printer.*</camel.osgi.export.pkg>
- </properties>
-
- <repositories>
- <repository>
- <id>servicemix</id>
- <name>Apache ServiceMix Repository</name>
- <url>http://svn.apache.org/repos/asf/servicemix/m2-repo</url>
- </repository>
- </repositories>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>jsch</groupId> <!-- com.jcraft -->
- <artifactId>jsch</artifactId>
- <version>0.1.40</version>
- </dependency>
- <dependency>
- <groupId>commons-net</groupId>
- <artifactId>commons-net</artifactId>
- <version>2.0</version>
- </dependency>
-
- <!-- testing -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- <!-- logging -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <scope>test</scope>
- </dependency>
- <!-- to allow Spring annotations (jmx) to be tested -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <optional>true</optional>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aop</artifactId>
- <optional>true</optional>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-clean-plugin</artifactId>
- <configuration>
- <filesets>
- <fileset>
- <directory>${basedir}/res</directory>
- </fileset>
- </filesets>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-printer</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: Printer</name>
+ <description>Camel Printer support</description>
+
+ <properties>
+
<camel.osgi.export.pkg>org.apache.camel.component.printer.*</camel.osgi.export.pkg>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- to allow Spring annotations (jmx) to be tested -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <optional>true</optional>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ <optional>true</optional>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>${basedir}/res</directory>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
</project>
Modified:
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/DocFlavorAssigner.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/DocFlavorAssigner.java?rev=816600&r1=816599&r2=816600&view=diff
==============================================================================
---
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/DocFlavorAssigner.java
(original)
+++
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/DocFlavorAssigner.java
Fri Sep 18 12:31:57 2009
@@ -14,13 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.component.printer;
import javax.print.DocFlavor;
public class DocFlavorAssigner {
- DocFlavor d = DocFlavor.BYTE_ARRAY.AUTOSENSE;
+ private DocFlavor d = DocFlavor.BYTE_ARRAY.AUTOSENSE;
public DocFlavor forMimeTypeAUTOSENSE(String flavor) {
if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
Modified:
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/MediaSizeAssigner.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/MediaSizeAssigner.java?rev=816600&r1=816599&r2=816600&view=diff
==============================================================================
---
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/MediaSizeAssigner.java
(original)
+++
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/MediaSizeAssigner.java
Fri Sep 18 12:31:57 2009
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.component.printer;
import javax.print.attribute.standard.MediaSizeName;
Modified:
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrintDocument.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrintDocument.java?rev=816600&r1=816599&r2=816600&view=diff
==============================================================================
---
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrintDocument.java
(original)
+++
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrintDocument.java
Fri Sep 18 12:31:57 2009
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.component.printer;
import java.io.ByteArrayInputStream;
@@ -53,8 +52,7 @@
return getStreamForBytes();
}
- public Reader getReaderForText()
- throws UnsupportedEncodingException, IOException {
+ public Reader getReaderForText() throws IOException {
synchronized (this) {
if (reader != null) {
return reader;
Modified:
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterComponent.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterComponent.java?rev=816600&r1=816599&r2=816600&view=diff
==============================================================================
---
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterComponent.java
(original)
+++
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterComponent.java
Fri Sep 18 12:31:57 2009
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.component.printer;
import java.net.URI;
@@ -37,8 +36,7 @@
}
@Override
- protected Endpoint createEndpoint(String uri, String remaining,
- Map parameters) throws Exception {
+ protected Endpoint createEndpoint(String uri, String remaining, Map
parameters) throws Exception {
config.parseURI(new URI(uri));
PrinterEndpoint printerEndpoint = new PrinterEndpoint(uri, this,
config);
@@ -46,5 +44,4 @@
return new PrinterEndpoint(uri, this, config);
}
-
}
Modified:
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterConfiguration.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterConfiguration.java?rev=816600&r1=816599&r2=816600&view=diff
==============================================================================
---
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterConfiguration.java
(original)
+++
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterConfiguration.java
Fri Sep 18 12:31:57 2009
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.component.printer;
import java.net.URI;
@@ -31,20 +30,20 @@
public class PrinterConfiguration {
private static final transient Log LOG =
LogFactory.getLog(PrinterConfiguration.class);
- URI uri;
- String hostname;
- int port;
- String printername;
- int copies = 1;
- String flavor;
- DocFlavor docFlavor;
- String mimeType;
- String mediaSize;
- MediaSizeName mediaSizeName;
- String sides;
- Sides internalSides;
- boolean sendToPrinter = true;
- Map printSettings;
+ private URI uri;
+ private String hostname;
+ private int port;
+ private String printername;
+ private int copies = 1;
+ private String flavor;
+ private DocFlavor docFlavor;
+ private String mimeType;
+ private String mediaSize;
+ private MediaSizeName mediaSizeName;
+ private String sides;
+ private Sides internalSides;
+ private boolean sendToPrinter = true;
+ private Map printSettings;
public PrinterConfiguration() {
}
@@ -71,14 +70,14 @@
setDocFlavor(assignDocFlavor(flavor, mimeType));
if (printSettings.containsKey("copies")) {
- setCopies(Integer.valueOf((String)
printSettings.get("copies")).intValue());
+ setCopies(Integer.valueOf((String) printSettings.get("copies")));
}
setMediaSize((String)printSettings.get("mediaSize"));
setSides((String)printSettings.get("sides"));
setMediaSizeName(assignMediaSize(mediaSize));
setInternalSides(assignSides(sides));
if (printSettings.containsKey("sendToPrinter")) {
- if
(!(Boolean.valueOf((String)printSettings.get("sendToPrinter")).booleanValue()))
{
+ if (!(Boolean.valueOf((String)
printSettings.get("sendToPrinter")))) {
setSendToPrinter(false);
}
}
@@ -258,7 +257,6 @@
this.sides = sides;
}
-
public MediaSizeName getMediaSizeName() {
return mediaSizeName;
}
Modified:
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterEndpoint.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterEndpoint.java?rev=816600&r1=816599&r2=816600&view=diff
==============================================================================
---
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterEndpoint.java
(original)
+++
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterEndpoint.java
Fri Sep 18 12:31:57 2009
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.component.printer;
import org.apache.camel.Component;
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=816600&r1=816599&r2=816600&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
Fri Sep 18 12:31:57 2009
@@ -14,17 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.component.printer;
-import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.util.UUID;
-
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
@@ -42,26 +37,23 @@
public class PrinterOperations implements PrinterOperationsInterface {
private static final transient Log LOG =
LogFactory.getLog(PrinterOperations.class);
- PrintService printService;
- DocPrintJob job;
- DocFlavor flavor;
- PrintRequestAttributeSet printRequestAttributeSet;
- Doc doc;
+ private PrintService printService;
+ private DocPrintJob job;
+ private DocFlavor flavor;
+ private PrintRequestAttributeSet printRequestAttributeSet;
+ private Doc doc;
public PrinterOperations() throws PrintException {
printService = PrintServiceLookup.lookupDefaultPrintService();
if (printService == null) {
- LOG.error("PrintServiceLookup failed. No Default printer set up
for this host: ");
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 = new HashPrintRequestAttributeSet();
printRequestAttributeSet.add(new Copies(1));
printRequestAttributeSet.add(MediaSizeName.NA_LETTER);
printRequestAttributeSet.add(Sides.ONE_SIDED);
-
}
public PrinterOperations(PrintService printService, DocPrintJob job,
DocFlavor flavor, PrintRequestAttributeSet printRequestAttributeSet) throws
PrintException {
@@ -94,13 +86,13 @@
byte[] buffer = null;
File file;
- LOG.info("In printerOperations.print()");
- LOG.info("Print Service = " + this.printService.getName());
- LOG.info("About to print " + copies + " copy(s)");
+ LOG.trace("In printerOperations.print()");
+ LOG.trace("Print Service = " + this.printService.getName());
+ LOG.trace("About to print " + copies + " copy(s)");
for (int i = 0; i < copies; i++) {
if (!sendToPrinter) {
- LOG.info("\tPrint Flag is set to false. This job(s) will not
be printed until this setting remains in effect. Please set the flag to true or
remove the setting");
+ LOG.debug("\tPrint Flag is set to false. This job(s) will not
be printed until this setting remains in effect. Please set the flag to true or
remove the setting");
if (mimeType.equalsIgnoreCase("GIF") ||
mimeType.equalsIgnoreCase("RENDERABLE_IMAGE")) {
file = new File("./target/TestPrintJobNo" + i + "_" +
UUID.randomUUID() + ".gif");
} else if (mimeType.equalsIgnoreCase("JPEG")) {
@@ -110,7 +102,7 @@
} else {
file = new File("./target/TestPrintJobNo" + i + "_" +
UUID.randomUUID() + ".txt");
}
- LOG.info("\tWriting Print Job to File: " +
file.getAbsolutePath());
+ LOG.debug("\tWriting Print Job to File: " +
file.getAbsolutePath());
try {
if (buffer == null) {
InputStream stream = doc.getStreamForBytes();
@@ -128,7 +120,7 @@
throw new PrintException("Error writing Document to the
target file " + file.getAbsolutePath());
}
} else {
- LOG.info("\tIssuing Job " + i + " to Printer: " +
this.printService.getName());
+ LOG.debug("\tIssuing Job " + i + " to Printer: " +
this.printService.getName());
print(doc);
}
}
@@ -166,8 +158,7 @@
return printRequestAttributeSet;
}
- public void setPrintRequestAttributeSet(
- PrintRequestAttributeSet printRequestAttributeSet) {
+ public void setPrintRequestAttributeSet(PrintRequestAttributeSet
printRequestAttributeSet) {
this.printRequestAttributeSet = printRequestAttributeSet;
}
Modified:
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperationsInterface.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperationsInterface.java?rev=816600&r1=816599&r2=816600&view=diff
==============================================================================
---
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperationsInterface.java
(original)
+++
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperationsInterface.java
Fri Sep 18 12:31:57 2009
@@ -14,12 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.component.printer;
import javax.print.Doc;
import javax.print.PrintException;
public interface PrinterOperationsInterface {
+
+ /**
+ * Prints the document.
+ *
+ * @param doc document to print
+ * @throws PrintException is thrown if printing failed
+ */
void print(Doc doc) throws PrintException;
+
}
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=816600&r1=816599&r2=816600&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
Fri Sep 18 12:31:57 2009
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.component.printer;
import java.io.InputStream;
Modified:
camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java?rev=816600&r1=816599&r2=816600&view=diff
==============================================================================
---
camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
(original)
+++
camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
Fri Sep 18 12:31:57 2009
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.component.printer;
import java.io.BufferedInputStream;
@@ -26,6 +25,7 @@
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
import org.junit.Test;
public class PrinterPrintTest extends CamelTestSupport {
@@ -37,7 +37,6 @@
// Check if there is an awt library
private boolean isAwtHeadless() {
-
if (Boolean.getBoolean("java.awt.headless")) {
System.out.println("Running headless. Skipping test as Images may
not work.");
return true;
@@ -114,6 +113,7 @@
}
@Test
+ @Ignore
public void testSendingFileToPrinter() throws Exception {
if (isAwtHeadless()) {
return;
@@ -130,6 +130,7 @@
}
@Test
+ @Ignore
public void testSendingGIFToPrinter() throws Exception {
if (isAwtHeadless()) {
return;
@@ -146,6 +147,7 @@
}
@Test
+ @Ignore
public void testSendingJPEGToPrinter() throws Exception {
if (isAwtHeadless()) {
return;