You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2009/09/14 15:59:52 UTC
svn commit: r814646 [1/2] - in /camel/trunk/components/camel-printer: ./
src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/camel/ src/main/java/org/apache/camel/component/
src/main/java/org/apache/camel...
Author: janstey
Date: Mon Sep 14 13:59:50 2009
New Revision: 814646
URL: http://svn.apache.org/viewvc?rev=814646&view=rev
Log:
CAMEL-1675 - Initial commit of printer component for Camel. Thanks to Ashwin Karpe for this!
Added:
camel/trunk/components/camel-printer/
camel/trunk/components/camel-printer/pom.xml
camel/trunk/components/camel-printer/src/
camel/trunk/components/camel-printer/src/main/
camel/trunk/components/camel-printer/src/main/java/
camel/trunk/components/camel-printer/src/main/java/org/
camel/trunk/components/camel-printer/src/main/java/org/apache/
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/
camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/
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/main/resources/
camel/trunk/components/camel-printer/src/main/resources/META-INF/
camel/trunk/components/camel-printer/src/main/resources/META-INF/LICENSE.txt
camel/trunk/components/camel-printer/src/main/resources/META-INF/NOTICE.txt
camel/trunk/components/camel-printer/src/main/resources/META-INF/services/
camel/trunk/components/camel-printer/src/main/resources/META-INF/services/org/
camel/trunk/components/camel-printer/src/main/resources/META-INF/services/org/apache/
camel/trunk/components/camel-printer/src/main/resources/META-INF/services/org/apache/camel/
camel/trunk/components/camel-printer/src/main/resources/META-INF/services/org/apache/camel/component/
camel/trunk/components/camel-printer/src/main/resources/META-INF/services/org/apache/camel/component/lpr
camel/trunk/components/camel-printer/src/test/
camel/trunk/components/camel-printer/src/test/java/
camel/trunk/components/camel-printer/src/test/java/org/
camel/trunk/components/camel-printer/src/test/java/org/apache/
camel/trunk/components/camel-printer/src/test/java/org/apache/camel/
camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/
camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/
camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
camel/trunk/components/camel-printer/src/test/resources/
camel/trunk/components/camel-printer/src/test/resources/Thumbs.db (with props)
camel/trunk/components/camel-printer/src/test/resources/asf-logo.JPG (with props)
camel/trunk/components/camel-printer/src/test/resources/asf-logo.gif (with props)
camel/trunk/components/camel-printer/src/test/resources/log4j.properties
camel/trunk/components/camel-printer/src/test/resources/test.txt
Added: camel/trunk/components/camel-printer/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/pom.xml?rev=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/pom.xml (added)
+++ camel/trunk/components/camel-printer/pom.xml Mon Sep 14 13:59:50 2009
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<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>
+
+ <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-core</artifactId>
+ <type>test-jar</type>
+ <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>
+</project>
Added: 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=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/DocFlavorAssigner.java (added)
+++ camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/DocFlavorAssigner.java Mon Sep 14 13:59:50 2009
@@ -0,0 +1,261 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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;
+
+ public DocFlavor forMimeTypeAUTOSENSE(String flavor) {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.AUTOSENSE;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.AUTOSENSE;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.AUTOSENSE;
+ }
+
+ return d;
+ }
+
+ public DocFlavor forMimeTypeGIF(String flavor) {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.GIF;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.GIF;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.GIF;
+ }
+
+ return d;
+ }
+
+ public DocFlavor forMimeTypeJPEG(String flavor) {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.JPEG;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.JPEG;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.JPEG;
+ }
+
+ return d;
+ }
+
+ public DocFlavor forMimeTypePDF(String flavor) {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.PDF;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.PDF;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.PDF;
+ }
+
+ return d;
+ }
+
+ public DocFlavor forMimeTypePCL(String flavor) {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.PCL;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.PCL;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.PCL;
+ }
+
+ return d;
+ }
+
+ public DocFlavor forMimeTypePOSTSCRIPT(String flavor) {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.POSTSCRIPT;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.POSTSCRIPT;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.POSTSCRIPT;
+ }
+
+ return d;
+ }
+
+ public DocFlavor forMimeTypeHOST(String flavor, String mimeType) {
+ if (mimeType.equalsIgnoreCase("TEXT_HTML_HOST")) {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.TEXT_HTML_HOST;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.TEXT_HTML_HOST;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.TEXT_HTML_HOST;
+ }
+ } else {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.TEXT_PLAIN_HOST;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.TEXT_PLAIN_HOST;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.TEXT_PLAIN_HOST;
+ }
+ }
+
+ return d;
+ }
+
+ public DocFlavor forMimeTypeUSASCII(String flavor, String mimeType) {
+ if (mimeType.equalsIgnoreCase("TEXT_HTML_US_ASCII")) {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.TEXT_HTML_US_ASCII;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.TEXT_HTML_US_ASCII;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.TEXT_HTML_US_ASCII;
+ }
+ } else {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.TEXT_PLAIN_US_ASCII;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.TEXT_PLAIN_US_ASCII;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.TEXT_PLAIN_US_ASCII;
+ }
+ }
+
+ return d;
+ }
+
+ public DocFlavor forMimeTypeUTF16(String flavor, String mimeType) {
+ if (mimeType.equalsIgnoreCase("TEXT_HTML_UTF_16")) {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.TEXT_HTML_UTF_16;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.TEXT_HTML_UTF_16;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.TEXT_HTML_UTF_16;
+ }
+ } else {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.TEXT_PLAIN_UTF_16;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_16;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.TEXT_PLAIN_UTF_16;
+ }
+ }
+
+ return d;
+ }
+ public DocFlavor forMimeTypeUTF16LE(String flavor, String mimeType) {
+ if (mimeType.equalsIgnoreCase("TEXT_HTML_UTF_16LE")) {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.TEXT_HTML_UTF_16LE;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.TEXT_HTML_UTF_16LE;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.TEXT_HTML_UTF_16LE;
+ }
+ } else {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.TEXT_PLAIN_UTF_16LE;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_16LE;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.TEXT_PLAIN_UTF_16LE;
+ }
+ }
+
+ return d;
+ }
+
+ public DocFlavor forMimeTypeUTF16BE(String flavor, String mimeType) {
+ if (mimeType.equalsIgnoreCase("TEXT_HTML_UTF_16BE")) {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.TEXT_HTML_UTF_16BE;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.TEXT_HTML_UTF_16BE;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.TEXT_HTML_UTF_16BE;
+ }
+ } else {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.TEXT_PLAIN_UTF_16BE;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_16BE;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.TEXT_PLAIN_UTF_16BE;
+ }
+ }
+
+ return d;
+ }
+
+ public DocFlavor forMimeTypeUTF8(String flavor, String mimeType) {
+ if (mimeType.equalsIgnoreCase("TEXT_HTML_UTF_16BE")) {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.TEXT_HTML_UTF_8;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.TEXT_HTML_UTF_8;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.TEXT_HTML_UTF_8;
+ }
+ } else {
+ if (flavor.equalsIgnoreCase("DocFlavor.BYTE_ARRAY")) {
+ d = DocFlavor.BYTE_ARRAY.TEXT_PLAIN_UTF_8;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.INPUT_STREAM")) {
+ d = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_8;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.URL")) {
+ d = DocFlavor.URL.TEXT_PLAIN_UTF_8;
+ }
+ }
+
+ return d;
+ }
+
+ public DocFlavor forMimeTypeBasic(String flavor, String mimeType) {
+ if (mimeType.equalsIgnoreCase("TEXT_HTML_UTF_16BE")) {
+ if (flavor.equalsIgnoreCase("DocFlavor.CHAR_ARRAY")) {
+ d = DocFlavor.CHAR_ARRAY.TEXT_HTML;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.READER")) {
+ d = DocFlavor.READER.TEXT_HTML;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.STRING")) {
+ d = DocFlavor.STRING.TEXT_HTML;
+ }
+ } else {
+ if (flavor.equalsIgnoreCase("DocFlavor.CHAR_ARRAY")) {
+ d = DocFlavor.CHAR_ARRAY.TEXT_PLAIN;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.READER")) {
+ d = DocFlavor.READER.TEXT_PLAIN;
+ } else if (flavor.equalsIgnoreCase("DocFlavor.STRING")) {
+ d = DocFlavor.STRING.TEXT_PLAIN;
+ }
+ }
+
+ return d;
+ }
+
+ public DocFlavor forMimeTypePAGEABLE(String flavor) {
+ return d = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
+ }
+
+ public DocFlavor forMimeTypePRINTABLE(String flavor) {
+ return d = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
+ }
+
+ public DocFlavor forMimeTypeRENDERABLEIMAGE(String flavor) {
+ return d = DocFlavor.SERVICE_FORMATTED.RENDERABLE_IMAGE;
+ }
+}
Added: 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=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/MediaSizeAssigner.java (added)
+++ camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/MediaSizeAssigner.java Mon Sep 14 13:59:50 2009
@@ -0,0 +1,231 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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;
+
+public class MediaSizeAssigner {
+ private MediaSizeName mediaSizeName;
+
+ public MediaSizeName selectMediaSizeNameISO(String size) {
+ if (size.equalsIgnoreCase("iso-a0")) {
+ mediaSizeName = MediaSizeName.ISO_A0;
+ } else if (size.equalsIgnoreCase("iso-a1")) {
+ mediaSizeName = MediaSizeName.ISO_A1;
+ } else if (size.equalsIgnoreCase("iso-a2")) {
+ mediaSizeName = MediaSizeName.ISO_A2;
+ } else if (size.equalsIgnoreCase("iso-a3")) {
+ mediaSizeName = MediaSizeName.ISO_A3;
+ } else if (size.equalsIgnoreCase("iso-a4")) {
+ mediaSizeName = MediaSizeName.ISO_A4;
+ } else if (size.equalsIgnoreCase("iso-a5")) {
+ mediaSizeName = MediaSizeName.ISO_A5;
+ } else if (size.equalsIgnoreCase("iso-a6")) {
+ mediaSizeName = MediaSizeName.ISO_A6;
+ } else if (size.equalsIgnoreCase("iso-a7")) {
+ mediaSizeName = MediaSizeName.ISO_A7;
+ } else if (size.equalsIgnoreCase("iso-a8")) {
+ mediaSizeName = MediaSizeName.ISO_A8;
+ } else if (size.equalsIgnoreCase("iso-a9")) {
+ mediaSizeName = MediaSizeName.ISO_A9;
+ } else if (size.equalsIgnoreCase("iso-a10")) {
+ mediaSizeName = MediaSizeName.ISO_A10;
+ } else if (size.equalsIgnoreCase("iso-b0")) {
+ mediaSizeName = MediaSizeName.ISO_B0;
+ } else if (size.equalsIgnoreCase("iso-b1")) {
+ mediaSizeName = MediaSizeName.ISO_B1;
+ } else if (size.equalsIgnoreCase("iso-b2")) {
+ mediaSizeName = MediaSizeName.ISO_B2;
+ } else if (size.equalsIgnoreCase("iso-b3")) {
+ mediaSizeName = MediaSizeName.ISO_B3;
+ } else if (size.equalsIgnoreCase("iso-b4")) {
+ mediaSizeName = MediaSizeName.ISO_B4;
+ } else if (size.equalsIgnoreCase("iso-b5")) {
+ mediaSizeName = MediaSizeName.ISO_B5;
+ } else if (size.equalsIgnoreCase("iso-b6")) {
+ mediaSizeName = MediaSizeName.ISO_B6;
+ } else if (size.equalsIgnoreCase("iso-b7")) {
+ mediaSizeName = MediaSizeName.ISO_B7;
+ } else if (size.equalsIgnoreCase("iso-b8")) {
+ mediaSizeName = MediaSizeName.ISO_B8;
+ } else if (size.equalsIgnoreCase("iso-b9")) {
+ mediaSizeName = MediaSizeName.ISO_B9;
+ } else if (size.equalsIgnoreCase("iso-b10")) {
+ mediaSizeName = MediaSizeName.ISO_B10;
+ } else if (size.equalsIgnoreCase("iso-c0")) {
+ mediaSizeName = MediaSizeName.ISO_C0;
+ } else if (size.equalsIgnoreCase("iso-c1")) {
+ mediaSizeName = MediaSizeName.ISO_C1;
+ } else if (size.equalsIgnoreCase("iso-c2")) {
+ mediaSizeName = MediaSizeName.ISO_C2;
+ } else if (size.equalsIgnoreCase("iso-c3")) {
+ mediaSizeName = MediaSizeName.ISO_C3;
+ } else if (size.equalsIgnoreCase("iso-c4")) {
+ mediaSizeName = MediaSizeName.ISO_C4;
+ } else if (size.equalsIgnoreCase("iso-c5")) {
+ mediaSizeName = MediaSizeName.ISO_C5;
+ } else if (size.equalsIgnoreCase("iso-c6")) {
+ mediaSizeName = MediaSizeName.ISO_C6;
+ }
+ return mediaSizeName;
+ }
+
+ public MediaSizeName selectMediaSizeNameJIS(String size) {
+
+ if (size.equalsIgnoreCase("jis-b0")) {
+ mediaSizeName = MediaSizeName.JIS_B0;
+ } else if (size.equalsIgnoreCase("jis-b1")) {
+ mediaSizeName = MediaSizeName.JIS_B1;
+ } else if (size.equalsIgnoreCase("jis-b2")) {
+ mediaSizeName = MediaSizeName.JIS_B2;
+ } else if (size.equalsIgnoreCase("jis-b3")) {
+ mediaSizeName = MediaSizeName.JIS_B3;
+ } else if (size.equalsIgnoreCase("jis-b4")) {
+ mediaSizeName = MediaSizeName.JIS_B4;
+ } else if (size.equalsIgnoreCase("jis-b5")) {
+ mediaSizeName = MediaSizeName.JIS_B5;
+ } else if (size.equalsIgnoreCase("jis-b6")) {
+ mediaSizeName = MediaSizeName.JIS_B6;
+ } else if (size.equalsIgnoreCase("jis-b7")) {
+ mediaSizeName = MediaSizeName.JIS_B7;
+ } else if (size.equalsIgnoreCase("jis-b8")) {
+ mediaSizeName = MediaSizeName.JIS_B8;
+ } else if (size.equalsIgnoreCase("jis-b9")) {
+ mediaSizeName = MediaSizeName.JIS_B9;
+ } else if (size.equalsIgnoreCase("jis-b10")) {
+ mediaSizeName = MediaSizeName.JIS_B10;
+ }
+
+ return mediaSizeName;
+ }
+
+ public MediaSizeName selectMediaSizeNameNA(String size) {
+ if (size.equalsIgnoreCase("na-letter")) {
+ mediaSizeName = MediaSizeName.NA_LETTER;
+ } else if (size.equalsIgnoreCase("na-legal")) {
+ mediaSizeName = MediaSizeName.NA_LEGAL;
+ } else if (size.equalsIgnoreCase("executive")) {
+ mediaSizeName = MediaSizeName.EXECUTIVE;
+ } else if (size.equalsIgnoreCase("ledger")) {
+ mediaSizeName = MediaSizeName.LEDGER;
+ } else if (size.equalsIgnoreCase("tabloid")) {
+ mediaSizeName = MediaSizeName.TABLOID;
+ } else if (size.equalsIgnoreCase("invoice")) {
+ mediaSizeName = MediaSizeName.INVOICE;
+ } else if (size.equalsIgnoreCase("folio")) {
+ mediaSizeName = MediaSizeName.FOLIO;
+ } else if (size.equalsIgnoreCase("quarto")) {
+ mediaSizeName = MediaSizeName.QUARTO;
+ } else if (size.equalsIgnoreCase("japanese-postcard")) {
+ mediaSizeName = MediaSizeName.JAPANESE_POSTCARD;
+ } else if (size.equalsIgnoreCase("oufuko-postcard")) {
+ mediaSizeName = MediaSizeName.JAPANESE_DOUBLE_POSTCARD;
+ } else if (size.equalsIgnoreCase("a")) {
+ mediaSizeName = MediaSizeName.A;
+ } else if (size.equalsIgnoreCase("b")) {
+ mediaSizeName = MediaSizeName.B;
+ } else if (size.equalsIgnoreCase("c")) {
+ mediaSizeName = MediaSizeName.C;
+ } else if (size.equalsIgnoreCase("d")) {
+ mediaSizeName = MediaSizeName.D;
+ } else if (size.equalsIgnoreCase("e")) {
+ mediaSizeName = MediaSizeName.E;
+ } else if (size.equalsIgnoreCase("iso-designated-long")) {
+ mediaSizeName = MediaSizeName.ISO_DESIGNATED_LONG;
+ } else if (size.equalsIgnoreCase("italian-envelope")) {
+ mediaSizeName = MediaSizeName.ITALY_ENVELOPE;
+ } else if (size.equalsIgnoreCase("monarch-envelope")) {
+ mediaSizeName = MediaSizeName.MONARCH_ENVELOPE;
+ } else if (size.equalsIgnoreCase("personal-envelope")) {
+ mediaSizeName = MediaSizeName.PERSONAL_ENVELOPE;
+ } else if (size.equalsIgnoreCase("na-number-9-envelope")) {
+ mediaSizeName = MediaSizeName.NA_NUMBER_9_ENVELOPE;
+ } else if (size.equalsIgnoreCase("na-number-10-envelope")) {
+ mediaSizeName = MediaSizeName.NA_NUMBER_10_ENVELOPE;
+ } else if (size.equalsIgnoreCase("na-number-11-envelope")) {
+ mediaSizeName = MediaSizeName.NA_NUMBER_11_ENVELOPE;
+ } else if (size.equalsIgnoreCase("na-number-12-envelope")) {
+ mediaSizeName = MediaSizeName.NA_NUMBER_12_ENVELOPE;
+ } else if (size.equalsIgnoreCase("na-number-14-envelope")) {
+ mediaSizeName = MediaSizeName.NA_NUMBER_14_ENVELOPE;
+ } else if (size.equalsIgnoreCase("na-6x9-envelope")) {
+ mediaSizeName = MediaSizeName.NA_6X9_ENVELOPE;
+ } else if (size.equalsIgnoreCase("na-7x9-envelope")) {
+ mediaSizeName = MediaSizeName.NA_7X9_ENVELOPE;
+ } else if (size.equalsIgnoreCase("na-9x11-envelope")) {
+ mediaSizeName = MediaSizeName.NA_9X11_ENVELOPE;
+ } else if (size.equalsIgnoreCase("na-9x12-envelope")) {
+ mediaSizeName = MediaSizeName.NA_9X12_ENVELOPE;
+ } else if (size.equalsIgnoreCase("na-10x13-envelope")) {
+ mediaSizeName = MediaSizeName.NA_10X13_ENVELOPE;
+ } else if (size.equalsIgnoreCase("na-10x14-envelope")) {
+ mediaSizeName = MediaSizeName.NA_10X14_ENVELOPE;
+ } else if (size.equalsIgnoreCase("na-10x15-envelope")) {
+ mediaSizeName = MediaSizeName.NA_10X15_ENVELOPE;
+ } else if (size.equalsIgnoreCase("na-5x7")) {
+ mediaSizeName = MediaSizeName.NA_5X7;
+ } else if (size.equalsIgnoreCase("na-8x10")) {
+ mediaSizeName = MediaSizeName.NA_8X10;
+ } else {
+ mediaSizeName = MediaSizeName.NA_LETTER;
+ }
+
+ return mediaSizeName;
+ }
+
+ public MediaSizeName selectMediaSizeNameOther(String size) {
+ if (size.equalsIgnoreCase("executive")) {
+ mediaSizeName = MediaSizeName.EXECUTIVE;
+ } else if (size.equalsIgnoreCase("ledger")) {
+ mediaSizeName = MediaSizeName.LEDGER;
+ } else if (size.equalsIgnoreCase("tabloid")) {
+ mediaSizeName = MediaSizeName.TABLOID;
+ } else if (size.equalsIgnoreCase("invoice")) {
+ mediaSizeName = MediaSizeName.INVOICE;
+ } else if (size.equalsIgnoreCase("folio")) {
+ mediaSizeName = MediaSizeName.FOLIO;
+ } else if (size.equalsIgnoreCase("quarto")) {
+ mediaSizeName = MediaSizeName.QUARTO;
+ } else if (size.equalsIgnoreCase("japanese-postcard")) {
+ mediaSizeName = MediaSizeName.JAPANESE_POSTCARD;
+ } else if (size.equalsIgnoreCase("oufuko-postcard")) {
+ mediaSizeName = MediaSizeName.JAPANESE_DOUBLE_POSTCARD;
+ } else if (size.equalsIgnoreCase("a")) {
+ mediaSizeName = MediaSizeName.A;
+ } else if (size.equalsIgnoreCase("b")) {
+ mediaSizeName = MediaSizeName.B;
+ } else if (size.equalsIgnoreCase("c")) {
+ mediaSizeName = MediaSizeName.C;
+ } else if (size.equalsIgnoreCase("d")) {
+ mediaSizeName = MediaSizeName.D;
+ } else if (size.equalsIgnoreCase("e")) {
+ mediaSizeName = MediaSizeName.E;
+ } else if (size.equalsIgnoreCase("iso-designated-long")) {
+ mediaSizeName = MediaSizeName.ISO_DESIGNATED_LONG;
+ } else if (size.equalsIgnoreCase("italian-envelope")) {
+ mediaSizeName = MediaSizeName.ITALY_ENVELOPE;
+ } else if (size.equalsIgnoreCase("monarch-envelope")) {
+ mediaSizeName = MediaSizeName.MONARCH_ENVELOPE;
+ } else if (size.equalsIgnoreCase("personal-envelope")) {
+ mediaSizeName = MediaSizeName.PERSONAL_ENVELOPE;
+ }
+
+ return mediaSizeName;
+
+ }
+}
Added: 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=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrintDocument.java (added)
+++ camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrintDocument.java Mon Sep 14 13:59:50 2009
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.printer;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+
+import javax.print.Doc;
+import javax.print.DocFlavor;
+import javax.print.attribute.DocAttributeSet;
+
+class PrintDocument implements Doc {
+ private DocFlavor docFlavor;
+ private InputStream stream;
+ private Reader reader;
+ private byte[] buffer;
+
+ public PrintDocument(InputStream stream, DocFlavor docFlavor) {
+ this.stream = stream;
+ this.docFlavor = docFlavor;
+ }
+
+ public DocFlavor getDocFlavor() {
+ return docFlavor;
+ }
+
+ public DocAttributeSet getAttributes() {
+ return null;
+ }
+
+ public Object getPrintData() throws IOException {
+ return getStreamForBytes();
+ }
+
+ public Reader getReaderForText()
+ throws UnsupportedEncodingException, IOException {
+ synchronized (this) {
+ if (reader != null) {
+ return reader;
+ }
+
+ if (docFlavor.getMediaType().equalsIgnoreCase("image")) {
+ reader = null;
+ } else if ((docFlavor.getMediaType().equalsIgnoreCase("text"))
+ || ((docFlavor.getMediaType().equalsIgnoreCase("application"))
+ && (docFlavor.getMediaSubtype().equalsIgnoreCase("xml")))) {
+ buffer = new byte[stream.available()];
+ int n = stream.available();
+ for (int i = 0; i < n; i++) {
+ buffer[i] = (byte)stream.read();
+ }
+
+ reader = new StringReader(new String(buffer));
+ stream = new ByteArrayInputStream(buffer);
+ }
+
+ return reader;
+ }
+ }
+
+ public InputStream getStreamForBytes() throws IOException {
+ return stream;
+ }
+
+}
Added: 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=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterComponent.java (added)
+++ camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterComponent.java Mon Sep 14 13:59:50 2009
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.printer;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+
+public class PrinterComponent extends DefaultComponent {
+ PrinterConfiguration config;
+
+ public PrinterComponent() {
+ config = new PrinterConfiguration();
+ }
+
+ public PrinterComponent(CamelContext context) {
+ super(context);
+ config = new PrinterConfiguration();
+ }
+
+ @Override
+ protected Endpoint createEndpoint(String uri, String remaining,
+ Map parameters) throws Exception {
+ config.parseURI(new URI(uri));
+
+ PrinterEndpoint printerEndpoint = new PrinterEndpoint(uri, this, config);
+ setProperties(printerEndpoint.getConfig(), parameters);
+ return new PrinterEndpoint(uri, this, config);
+ }
+
+
+}
Added: 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=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterConfiguration.java (added)
+++ camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterConfiguration.java Mon Sep 14 13:59:50 2009
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.printer;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+
+import javax.print.DocFlavor;
+import javax.print.attribute.standard.MediaSizeName;
+import javax.print.attribute.standard.Sides;
+
+import org.apache.camel.util.URISupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+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;
+
+ public PrinterConfiguration() {
+ }
+
+ public PrinterConfiguration(URI uri) throws URISyntaxException {
+ this.uri = uri;
+ }
+
+ public void parseURI(URI uri) throws Exception {
+ String protocol = uri.getScheme();
+
+ if (!protocol.equalsIgnoreCase("lpr")) {
+ throw new IllegalArgumentException("Unrecognized Print protocol: " + protocol + " for uri: " + uri);
+ }
+ setUri(uri);
+ setHostname(uri.getHost());
+ setPort(uri.getPort());
+ LOG.info("URI Path = " + uri.getPath());
+ setPrintername(uri.getPath());
+
+ printSettings = URISupport.parseParameters(uri);
+ setFlavor((String)printSettings.get("flavor"));
+ setMimeType((String)printSettings.get("mimeType"));
+ setDocFlavor(assignDocFlavor(flavor, mimeType));
+
+ if (printSettings.containsKey("copies")) {
+ setCopies(Integer.valueOf((String) printSettings.get("copies")).intValue());
+ }
+ 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())) {
+ setSendToPrinter(false);
+ }
+ }
+ }
+
+
+ private DocFlavor assignDocFlavor(String flavor, String mimeType)
+ throws Exception {
+ DocFlavor d = DocFlavor.BYTE_ARRAY.AUTOSENSE;
+
+ if (mimeType == null) {
+ mimeType = "AUTOSENSE";
+ }
+
+ if (flavor == null) {
+ flavor = "DocFlavor.BYTE_ARRAY";
+ }
+
+ DocFlavorAssigner docFlavorAssigner = new DocFlavorAssigner();
+ if (mimeType.equalsIgnoreCase("AUTOSENSE")) {
+ d = docFlavorAssigner.forMimeTypeAUTOSENSE(flavor);
+ } else if (mimeType.equalsIgnoreCase("GIF")) {
+ d = docFlavorAssigner.forMimeTypeGIF(flavor);
+ } else if (mimeType.equalsIgnoreCase("JPEG")) {
+ d = docFlavorAssigner.forMimeTypeJPEG(flavor);
+ } else if (mimeType.equalsIgnoreCase("PDF")) {
+ d = docFlavorAssigner.forMimeTypePDF(flavor);
+ } else if (mimeType.equalsIgnoreCase("PCL")) {
+ d = docFlavorAssigner.forMimeTypePCL(flavor);
+ } else if (mimeType.equalsIgnoreCase("POSTSCRIPT")) {
+ d = docFlavorAssigner.forMimeTypePOSTSCRIPT(flavor);
+ } else if (mimeType.equalsIgnoreCase("TEXT_HTML_HOST")) {
+ d = docFlavorAssigner.forMimeTypeHOST(flavor, mimeType);
+ } else if (mimeType.equalsIgnoreCase("TEXT_HTML_US_ASCII")) {
+ d = docFlavorAssigner.forMimeTypeUSASCII(flavor, mimeType);
+ } else if (mimeType.equalsIgnoreCase("TEXT_HTML_UTF_16")) {
+ d = docFlavorAssigner.forMimeTypeUTF16(flavor, mimeType);
+ } else if (mimeType.equalsIgnoreCase("TEXT_HTML_UTF_16LE")) {
+ d = docFlavorAssigner.forMimeTypeUTF16LE(flavor, mimeType);
+ } else if (mimeType.equalsIgnoreCase("TEXT_HTML_UTF_16BE")) {
+ d = docFlavorAssigner.forMimeTypeUTF16BE(flavor, mimeType);
+ } else if (mimeType.equalsIgnoreCase("TEXT_HTML_UTF_8")) {
+ d = docFlavorAssigner.forMimeTypeUTF8(flavor, mimeType);
+ } else if (mimeType.equalsIgnoreCase("TEXT_PLAIN_HOST")) {
+ d = docFlavorAssigner.forMimeTypeHOST(flavor, mimeType);
+ } else if (mimeType.equalsIgnoreCase("TEXT_PLAIN_US_ASCII")) {
+ d = docFlavorAssigner.forMimeTypeUSASCII(flavor, mimeType);
+ } else if (mimeType.equalsIgnoreCase("TEXT_PLAIN_UTF_16")) {
+ d = docFlavorAssigner.forMimeTypeUTF16(flavor, mimeType);
+ } else if (mimeType.equalsIgnoreCase("TEXT_PLAIN_UTF_16LE")) {
+ d = docFlavorAssigner.forMimeTypeUTF16LE(flavor, mimeType);
+ } else if (mimeType.equalsIgnoreCase("TEXT_PLAIN_UTF_16BE")) {
+ d = docFlavorAssigner.forMimeTypeUTF16BE(flavor, mimeType);
+ } else if (mimeType.equalsIgnoreCase("TEXT_PLAIN_UTF_8")) {
+ d = docFlavorAssigner.forMimeTypeUTF8(flavor, mimeType);
+ } else if (mimeType.equalsIgnoreCase("TEXT_HTML")) {
+ d = docFlavorAssigner.forMimeTypeBasic(flavor, mimeType);
+ } else if (mimeType.equalsIgnoreCase("TEXT_PLAIN")) {
+ d = docFlavorAssigner.forMimeTypeBasic(flavor, mimeType);
+ } else if (mimeType.equalsIgnoreCase("PAGEABLE")) {
+ d = docFlavorAssigner.forMimeTypePAGEABLE(flavor);
+ } else if (mimeType.equalsIgnoreCase("PRINTABLE")) {
+ d = docFlavorAssigner.forMimeTypePRINTABLE(flavor);
+ } else if (mimeType.equalsIgnoreCase("RENDERABLE_IMAGE")) {
+ d = docFlavorAssigner.forMimeTypeRENDERABLEIMAGE(flavor);
+ }
+
+ return d;
+ }
+
+ private MediaSizeName assignMediaSize(String size) {
+ MediaSizeName mediaSizeName = null;
+
+ MediaSizeAssigner mediaSizeAssigner = new MediaSizeAssigner();
+ if (size.startsWith("iso")) {
+ mediaSizeName = mediaSizeAssigner.selectMediaSizeNameISO(size);
+ } else if (size.startsWith("jis")) {
+ mediaSizeName = mediaSizeAssigner.selectMediaSizeNameJIS(size);
+ } else if (size.startsWith("na")) {
+ mediaSizeName = mediaSizeAssigner.selectMediaSizeNameNA(size);
+ } else {
+ mediaSizeName = mediaSizeAssigner.selectMediaSizeNameOther(size);
+ }
+
+ return mediaSizeName;
+ }
+
+ public Sides assignSides(String sidesString) {
+ Sides ret = null;
+
+ if (sidesString.equalsIgnoreCase("one-sided")) {
+ ret = Sides.ONE_SIDED;
+ } else if (sidesString.equalsIgnoreCase("duplex")) {
+ ret = Sides.DUPLEX;
+ } else if (sidesString.equalsIgnoreCase("tumble")) {
+ ret = Sides.TUMBLE;
+ } else if (sidesString.equalsIgnoreCase("two-sided-short-edge")) {
+ ret = Sides.TWO_SIDED_SHORT_EDGE;
+ } else if (sidesString.equalsIgnoreCase("two-sided-long-edge")) {
+ ret = Sides.TWO_SIDED_LONG_EDGE;
+ } else {
+ ret = Sides.ONE_SIDED;
+ }
+
+ return ret;
+ }
+
+ public URI getUri() {
+ return uri;
+ }
+
+ public void setUri(URI uri) {
+ this.uri = uri;
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getPrintername() {
+ return printername;
+ }
+
+ public void setPrintername(String printername) {
+ this.printername = printername;
+ }
+
+ public int getCopies() {
+ return copies;
+ }
+
+ public void setCopies(int copies) {
+ this.copies = copies;
+ }
+
+ public String getFlavor() {
+ return flavor;
+ }
+
+ public void setFlavor(String flavor) {
+ this.flavor = flavor;
+ }
+
+ public DocFlavor getDocFlavor() {
+ return docFlavor;
+ }
+
+ public void setDocFlavor(DocFlavor docFlavor) {
+ this.docFlavor = docFlavor;
+ }
+
+ public String getMediaSize() {
+ return mediaSize;
+ }
+
+ public void setMediaSize(String mediaSize) {
+ this.mediaSize = mediaSize;
+ }
+
+ public String getSides() {
+ return sides;
+ }
+
+ public void setSides(String sides) {
+ this.sides = sides;
+ }
+
+
+ public MediaSizeName getMediaSizeName() {
+ return mediaSizeName;
+ }
+
+ public void setMediaSizeName(MediaSizeName mediaSizeName) {
+ this.mediaSizeName = mediaSizeName;
+ }
+
+ public Sides getInternalSides() {
+ return internalSides;
+ }
+
+ public void setInternalSides(Sides internalSides) {
+ this.internalSides = internalSides;
+ }
+
+ public String getMimeType() {
+ return mimeType;
+ }
+
+ public void setMimeType(String mimeType) {
+ this.mimeType = mimeType;
+ }
+
+ public boolean isSendToPrinter() {
+ return sendToPrinter;
+ }
+
+ public void setSendToPrinter(boolean sendToPrinter) {
+ this.sendToPrinter = sendToPrinter;
+ }
+
+}
Added: 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=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterEndpoint.java (added)
+++ camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterEndpoint.java Mon Sep 14 13:59:50 2009
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+
+public class PrinterEndpoint extends DefaultEndpoint {
+ PrinterConfiguration config;
+
+ public PrinterEndpoint(String endpointUri, Component component, PrinterConfiguration config) {
+ super(endpointUri, component);
+ this.config = config;
+ }
+
+ public Consumer createConsumer(Processor processor) throws Exception {
+ throw new UnsupportedOperationException("You cannot create a consumer for a Printer endpoint");
+ }
+
+ public Producer createProducer() throws Exception {
+ return new PrinterProducer(this, config);
+ }
+
+ public boolean isSingleton() {
+ return false;
+ }
+
+ public PrinterConfiguration getConfig() {
+ return config;
+ }
+
+ public void setConfig(PrinterConfiguration config) {
+ this.config = config;
+ }
+
+}
Added: 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=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperations.java (added)
+++ camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperations.java Mon Sep 14 13:59:50 2009
@@ -0,0 +1,182 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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;
+import javax.print.PrintException;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.MediaSizeName;
+import javax.print.attribute.standard.Sides;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+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;
+
+ 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.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 {
+ this();
+ this.setPrintService(printService);
+ this.setJob(job);
+ this.setFlavor(flavor);
+ this.setPrintRequestAttributeSet(printRequestAttributeSet);
+ }
+
+ public PrinterOperations(DocPrintJob job, DocFlavor flavor, PrintRequestAttributeSet printRequestAttributeSet) throws PrintException {
+ this();
+ this.setJob(job);
+ this.setFlavor(flavor);
+ this.setPrintRequestAttributeSet(printRequestAttributeSet);
+ }
+
+ public PrinterOperations(DocFlavor flavor, PrintRequestAttributeSet printRequestAttributeSet) throws PrintException {
+ this();
+ this.setFlavor(flavor);
+ this.setPrintRequestAttributeSet(printRequestAttributeSet);
+ }
+
+ public PrinterOperations(PrintRequestAttributeSet printRequestAttributeSet) throws PrintException {
+ this();
+ this.setPrintRequestAttributeSet(printRequestAttributeSet);
+ }
+
+ public void print(Doc doc, int copies, boolean sendToPrinter, String mimeType) throws PrintException {
+ 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)");
+
+ 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");
+ if (mimeType.equalsIgnoreCase("GIF") || mimeType.equalsIgnoreCase("RENDERABLE_IMAGE")) {
+ file = new File("./target/TestPrintJobNo" + i + "_" + UUID.randomUUID() + ".gif");
+ } else if (mimeType.equalsIgnoreCase("JPEG")) {
+ file = new File("./target/TestPrintJobNo" + i + "_" + UUID.randomUUID() + ".jpeg");
+ } else if (mimeType.equalsIgnoreCase("PDF")) {
+ file = new File("./target/TestPrintJobNo" + i + "_" + UUID.randomUUID() + ".pdf");
+ } else {
+ file = new File("./target/TestPrintJobNo" + i + "_" + UUID.randomUUID() + ".txt");
+ }
+ LOG.info("\tWriting Print Job to File: " + file.getAbsolutePath());
+ try {
+ if (buffer == null) {
+ InputStream stream = doc.getStreamForBytes();
+ buffer = new byte[stream.available()];
+ int n = stream.available();
+ for (int j = 0; j < n; j++) {
+ buffer[j] = (byte)stream.read();
+ }
+ }
+ FileOutputStream fileOutputStream = new FileOutputStream(file);
+ fileOutputStream.write(buffer);
+ fileOutputStream.flush();
+ fileOutputStream.close();
+ } catch (Exception e) {
+ throw new PrintException("Error writing Document to the target file " + file.getAbsolutePath());
+ }
+ } else {
+ LOG.info("\tIssuing Job " + i + " to Printer: " + this.printService.getName());
+ print(doc);
+ }
+ }
+ }
+
+ public void print(Doc doc) throws PrintException {
+ job.print(doc, printRequestAttributeSet);
+ }
+
+ public PrintService getPrintService() {
+ return printService;
+ }
+
+ 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;
+ }
+
+ public void setFlavor(DocFlavor flavor) {
+ this.flavor = flavor;
+ }
+
+ public PrintRequestAttributeSet getPrintRequestAttributeSet() {
+ return printRequestAttributeSet;
+ }
+
+ public void setPrintRequestAttributeSet(
+ PrintRequestAttributeSet printRequestAttributeSet) {
+ this.printRequestAttributeSet = printRequestAttributeSet;
+ }
+
+ public Doc getDoc() {
+ return doc;
+ }
+
+ public void setDoc(Doc doc) {
+ this.doc = doc;
+ }
+
+}
Added: 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=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperationsInterface.java (added)
+++ camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperationsInterface.java Mon Sep 14 13:59:50 2009
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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 {
+ void print(Doc doc) throws PrintException;
+}
Added: 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=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java (added)
+++ camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java Mon Sep 14 13:59:50 2009
@@ -0,0 +1,174 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.printer;
+
+import java.io.InputStream;
+
+import javax.print.DocFlavor;
+import javax.print.DocPrintJob;
+import javax.print.PrintException;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.standard.Copies;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class PrinterProducer extends DefaultProducer {
+ private static final transient Log LOG = LogFactory.getLog(PrinterProducer.class);
+ Endpoint endpoint;
+ PrinterConfiguration config;
+ PrinterOperations printerOperations;
+ PrintService printService;
+ String printer;
+
+ public PrinterProducer(Endpoint endpoint, PrinterConfiguration config) throws Exception {
+ super(endpoint);
+ this.endpoint = endpoint;
+ this.config = config;
+ this.printService = assignPrintService();
+ this.printerOperations = new PrinterOperations(printService, assignPrintJob(printService), assignDocFlavor(), assignPrintAttributes());
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ LOG.info("In PrinterProducer.start()");
+ super.doStart();
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ LOG.info("In PrinterProducer.stop()");
+ super.doStop();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ LOG.info("In printerProducer.print()");
+ Object body = exchange.getIn().getBody();
+ InputStream is = exchange.getContext().getTypeConverter().convertTo(InputStream.class, body);
+ print(is);
+ }
+
+ private void print(InputStream body) throws PrintException {
+ if (printerOperations.getPrintService().isDocFlavorSupported(printerOperations.getFlavor())) {
+ PrintDocument printDoc = new PrintDocument(body, printerOperations.getFlavor());
+ printerOperations.print(printDoc, config.getCopies(), config.isSendToPrinter(), config.getMimeType());
+ }
+ }
+
+ private DocFlavor assignDocFlavor() throws Exception {
+ return config.getDocFlavor();
+ }
+
+ private PrintRequestAttributeSet assignPrintAttributes() throws PrintException {
+ PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
+ if (config.getCopies() >= 1) {
+ printRequestAttributeSet.add(new Copies(config.getCopies()));
+ } else {
+ throw new PrintException("Number of print copies should be greater than zero");
+ }
+ printRequestAttributeSet.add(config.getMediaSizeName());
+ printRequestAttributeSet.add(config.getInternalSides());
+
+ return printRequestAttributeSet;
+ }
+
+ private DocPrintJob assignPrintJob(PrintService printService) {
+ return printService.createPrintJob();
+ }
+
+ private PrintService assignPrintService() throws PrintException {
+ PrintService printService;
+
+ if ((config.getHostname().equalsIgnoreCase("localhost"))
+ && (config.getPrintername().equalsIgnoreCase("/default"))) {
+ printService = PrintServiceLookup.lookupDefaultPrintService();
+ } else {
+ PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
+ setPrinter("\\\\" + config.getHostname() + "\\" + config.getPrintername());
+ int position = findPrinter(services, printer);
+ if (position < 0) {
+ LOG.error("PrintServiceLookup failed. No printer found with the Printer Name: " + printer);
+ throw new PrintException("Printer Lookup Failure. Please verify that the host and printer are registered and reachable from this machine");
+ }
+ printService = services[position];
+ }
+ // LOG.info("PrintServiceLookup succeeded. PrintService located at " + printService.getName());
+ return printService;
+ }
+
+ private int findPrinter(PrintService[] services, String printer) {
+ boolean found = false;
+ int position = -1;
+ for (int i = 0; (i < services.length) && (!found); i++) {
+ if (printer.equalsIgnoreCase(services[i].getName())) {
+ found = true;
+ position = i;
+ }
+ }
+
+ return position;
+ }
+
+ public Endpoint getEndpoint() {
+ return endpoint;
+ }
+
+ public void setEndpoint(Endpoint endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public PrinterConfiguration getConfig() {
+ return config;
+ }
+
+ public void setConfig(PrinterConfiguration config) {
+ this.config = config;
+ }
+
+ public PrinterOperations getPrinterOperations() {
+ return printerOperations;
+ }
+
+ public void setPrinterOperations(PrinterOperations printerOperations) {
+ this.printerOperations = printerOperations;
+ }
+
+ public PrintService getPrintService() {
+ return printService;
+ }
+
+ public void setPrintService(PrintService printService) {
+ this.printService = printService;
+ }
+
+ public String getPrinter() {
+ return printer;
+ }
+
+ public void setPrinter(String printer) {
+ this.printer = printer;
+ }
+
+
+}
Added: camel/trunk/components/camel-printer/src/main/resources/META-INF/LICENSE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/main/resources/META-INF/LICENSE.txt?rev=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/main/resources/META-INF/LICENSE.txt (added)
+++ camel/trunk/components/camel-printer/src/main/resources/META-INF/LICENSE.txt Mon Sep 14 13:59:50 2009
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
Added: camel/trunk/components/camel-printer/src/main/resources/META-INF/NOTICE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/main/resources/META-INF/NOTICE.txt?rev=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/main/resources/META-INF/NOTICE.txt (added)
+++ camel/trunk/components/camel-printer/src/main/resources/META-INF/NOTICE.txt Mon Sep 14 13:59:50 2009
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
Added: camel/trunk/components/camel-printer/src/main/resources/META-INF/services/org/apache/camel/component/lpr
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/main/resources/META-INF/services/org/apache/camel/component/lpr?rev=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/main/resources/META-INF/services/org/apache/camel/component/lpr (added)
+++ camel/trunk/components/camel-printer/src/main/resources/META-INF/services/org/apache/camel/component/lpr Mon Sep 14 13:59:50 2009
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class=org.apache.camel.component.printer.PrinterComponent