http://git-wip-us.apache.org/repos/asf/camel/blob/9c0b7baf/components/camel-dozer/src/main/docs/dozer-component.adoc ---------------------------------------------------------------------- diff --git a/components/camel-dozer/src/main/docs/dozer-component.adoc b/components/camel-dozer/src/main/docs/dozer-component.adoc new file mode 100644 index 0000000..d75be57 --- /dev/null +++ b/components/camel-dozer/src/main/docs/dozer-component.adoc @@ -0,0 +1,286 @@ +[[Dozer-Dozer]] +Dozer +~~~~~ + +The *dozer:* component provides the ability to map between Java beans +using the http://camel.apache.org/dozer-type-conversion.html[Dozer] +mapping framework since *Camel 2.15.0*.  Camel also supports the ability +to trigger Dozer mappings +http://camel.apache.org/dozer-type-conversion.html[as a type converter]. + The primary differences between using a Dozer endpoint and a Dozer +converter are: + +* The ability to manage Dozer mapping configuration on a per-endpoint +basis vs. global configuration via the converter registry. +* A Dozer endpoint can be configured to marshal/unmarshal input and +output data using Camel data formats to support a single, any-to-any +transformation endpoint +* The Dozer component allows for fine-grained integration and extension +of Dozer to support additional functionality (e.g. mapping literal +values, using expressions for mappings, etc.). + +In order to use the Dozer component, Maven users will need to add the +following dependency to their `pom.xml`: + +[source,xml] +------------------------------------------------------------ +<dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-dozer</artifactId> + <version>x.x.x</version> + <!-- use the same version as your Camel core version --> +</dependency> +------------------------------------------------------------ + +[[Dozer-URIformat]] +URI format +^^^^^^^^^^ + +The Dozer component only supports producer endpoints. + +[source,java] +-------------------------- +dozer:endpointId[?options] +-------------------------- + +Where *endpointId* is a name used to uniquely identify the Dozer +endpoint configuration. + +An example Dozer endpoint URI: + +[source,java] +--------------------------------------------------------------------------------------- +from("direct:orderInput"). + to("dozer:transformOrder?mappingFile=orderMapping.xml&targetModel=example.XYZOrder"). + to("direct:orderOutput"); +--------------------------------------------------------------------------------------- + +[[Dozer-Options]] +Options +^^^^^^^ + +[width="100%",cols="10%,10%,80%",options="header",] +|======================================================================= +|Name |Default |Description + +|`mappingFile` |dozerBeanMapping.xml |The location of a Dozer configuration file. The file is loaded from the +classpath by default, but you can use `file:`, +`classpath:, or ``http: `to load the configuration from a specific +location. + +|`unmarshalId` |none |The id of a dataFormat defined within the Camel Context to use for +unmarshalling the mapping input from a non-Java type. + +|`marshalId` |none |The id of a dataFormat defined within the Camel Context to use for +marshalling the mapping output to a non-Java type. + +|`sourceModel` |none |Fully-qualified class name for the source type used in the mapping. If +specified, the input to the mapping is converted to the specified type +before being mapped with Dozer. + +|`targetModel` |none |Fully-qualified class name for the target type used in the mapping. This +option is required. + +|`mappingConfiguration` |none |The name of a DozerBeanMapperConfiguration bean in the Camel registry +which should be used for configuring the Dozer mapping. This is an +alternative to the mappingFile option that can be used for fine-grained +control over how Dozer is configured. Remember to use a "#" prefix in +the value to indicate that the bean is in the Camel registry (e.g. +"#myDozerConfig"). +|======================================================================= + +[[Dozer-UsingDataFormatswithDozer]] +Using Data Formats with Dozer +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Dozer does not support non-Java sources and targets for mappings, so it +cannot, for example, map an XML document to a Java object on its own. + Luckily, Camel has extensive support for marshalling between Java and a +wide variety of formats using +http://camel.apache.org/data-format.html[data formats].  The Dozer +component takes advantage of this support by allowing you to specify +that input and output data should be passed through a data format prior +to processing via Dozer.  You can always do this on your own outside the +call to Dozer, but supporting it directly in the Dozer component allows +you to use a single endpoints to configure any-to-any transformation +within Camel. + +As an example, let's say you wanted to map between an XML data structure +and a JSON data structure using the Dozer component.  If you had the +following data formats defined in a Camel Context: + +[source,xml] +----------------------------------------------- +<dataFormats> + <json library="Jackson" id="myjson"/> + <jaxb contextPath="org.example" id="myjaxb"/> +</dataFormats> +----------------------------------------------- + +You could then configure a Dozer endpoint to unmarshal the input XML +using a JAXB data format and marshal the mapping output using Jackson. + +[source,xml] +---------------------------------------------------------------------------------------------------------- +<endpoint uri="dozer:xml2json?marshalId=myjson&unmarshalId=myjaxb&targetModel=org.example.Order"/> +---------------------------------------------------------------------------------------------------------- + +[[Dozer-ConfiguringDozer]] +Configuring Dozer +^^^^^^^^^^^^^^^^^ + +All Dozer endpoints require a Dozer mapping configuration file which +defines mappings between source and target objects.  The component will +default to a location of META-INF/dozerBeanMapping.xml if the +mappingFile or mappingConfiguration options are not specified on an +endpoint.  If you need to supply multiple mapping configuration files +for a single endpoint or specify additional configuration options (e.g. +event listeners, custom converters, etc.), then you can use an instance +of `org.apache.camel.converter.dozer.DozerBeanMapperConfiguration`. + +[source,xml] +------------------------------------------------------------------------------------------ +<bean id="mapper" class="org.apache.camel.converter.dozer.DozerBeanMapperConfiguration">  + <property name="mappingFiles"> + <list> + <value>mapping1.xml</value> + <value>mapping2.xml</value> + </list> + </property> +</bean> +------------------------------------------------------------------------------------------ + +[[Dozer-MappingExtensions]] +Mapping Extensions +^^^^^^^^^^^^^^^^^^ + +The Dozer component implements a number of extensions to the Dozer +mapping framework as custom converters.  These converters implement +mapping functions that are not supported directly by Dozer itself. + +[[Dozer-VariableMappings]] +Variable Mappings ++++++++++++++++++ + +Variable mappings allow you to map the value of a variable definition +within a Dozer configuration into a target field instead of using the +value of a source field.  This is equivalent to constant mapping in +other mapping frameworks, where can you assign a literal value to a +target field.  To use a variable mapping, simply define a variable +within your mapping configuration and then map from the VariableMapper +class into your target field of choice: + +[source,xml] +-------------------------------------------------------------------------------------------------------- +<mappings xmlns="http://dozer.sourceforge.net" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://dozer.sourceforge.net http://dozer.sourceforge.net/schema/beanmapping.xsd"> + <configuration> + <variables> + <variable name="CUST_ID">ACME-SALES</variable> + </variables> + </configuration> + <mapping> + <class-a>org.apache.camel.component.dozer.VariableMapper</class-a> + <class-b>org.example.Order</class-b> + <field custom-converter-id="_variableMapping" custom-converter-param="${CUST_ID}"> + <a>literal</a> + <b>custId</b> + </field> + </mapping> +</mappings> +-------------------------------------------------------------------------------------------------------- + +[[Dozer-CustomMappings]] +Custom Mappings ++++++++++++++++ + +Custom mappings allow you to define your own logic for how a source +field is mapped to a target field.  They are similar in function to +Dozer customer converters, with two notable differences: + +* You can have multiple converter methods in a single class with custom +mappings. +* There is no requirement to implement a Dozer-specific interface with +custom mappings. + +A custom mapping is declared by using the built-in '_customMapping' +converter in your mapping configuration.  The parameter to this +converter has the following syntax: + +[source,shell] +-------------------------- +[class-name][,method-name] +-------------------------- + +Method name is optional - the Dozer component will search for a method +that matches the input and output types required for a mapping.  An +example custom mapping and configuration are provided below. + +[source,java] +-------------------------------------------------- +public class CustomMapper { + // All customer ids must be wrapped in "[ ]" + public Object mapCustomer(String customerId) { + return "[" + customerId + "]"; + } +} +-------------------------------------------------- + +[source,xml] +-------------------------------------------------------------------------------------------------------- +<mappings xmlns="http://dozer.sourceforge.net" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://dozer.sourceforge.net http://dozer.sourceforge.net/schema/beanmapping.xsd"> + <mapping> + <class-a>org.example.A</class-a> + <class-b>org.example.B</class-b> + <field custom-converter-id="_customMapping" + custom-converter-param="org.example.CustomMapper,mapCustomer"> + <a>header.customerNum</a> + <b>custId</b> + </field> + </mapping> +</mappings> +-------------------------------------------------------------------------------------------------------- + +[[Dozer-ExpressionMappings]] +Expression Mappings ++++++++++++++++++++ + +Expression mappings allow you to use the powerful +http://camel.apache.org/languages.html[language] capabilities of Camel +to evaluate an expression and assign the result to a target field in a +mapping.  Any language that Camel supports can be used in an expression +mapping.  Basic examples of expressions include the ability to map a +Camel message header or exchange property to a target field or to +concatenate multiple source fields into a target field.  The syntax of a +mapping expression is: + +[source,shell] +----------------------- +[language]:[expression] +----------------------- + +An example of mapping a message header into a target field: + +[source,xml] +-------------------------------------------------------------------------------------------------------------- +<mappings xmlns="http://dozer.sourceforge.net" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://dozer.sourceforge.net http://dozer.sourceforge.net/schema/beanmapping.xsd"> + <mapping> + <class-a>org.apache.camel.component.dozer.ExpressionMapper</class-a> + <class-b>org.example.B</class-b> + <field custom-converter-id="_expressionMapping" custom-converter-param="simple:\${header.customerNumber}"> + <a>expression</a> + <b>custId</b> + </field> + </mapping> +</mappings> +-------------------------------------------------------------------------------------------------------------- + +Note that any properties within your expression must be escaped with "\" +to prevent an error when Dozer attempts to resolve variable values +defined using the EL. +
http://git-wip-us.apache.org/repos/asf/camel/blob/9c0b7baf/components/camel-dozer/src/main/docs/dozer.adoc ---------------------------------------------------------------------- diff --git a/components/camel-dozer/src/main/docs/dozer.adoc b/components/camel-dozer/src/main/docs/dozer.adoc deleted file mode 100644 index d75be57..0000000 --- a/components/camel-dozer/src/main/docs/dozer.adoc +++ /dev/null @@ -1,286 +0,0 @@ -[[Dozer-Dozer]] -Dozer -~~~~~ - -The *dozer:* component provides the ability to map between Java beans -using the http://camel.apache.org/dozer-type-conversion.html[Dozer] -mapping framework since *Camel 2.15.0*.  Camel also supports the ability -to trigger Dozer mappings -http://camel.apache.org/dozer-type-conversion.html[as a type converter]. - The primary differences between using a Dozer endpoint and a Dozer -converter are: - -* The ability to manage Dozer mapping configuration on a per-endpoint -basis vs. global configuration via the converter registry. -* A Dozer endpoint can be configured to marshal/unmarshal input and -output data using Camel data formats to support a single, any-to-any -transformation endpoint -* The Dozer component allows for fine-grained integration and extension -of Dozer to support additional functionality (e.g. mapping literal -values, using expressions for mappings, etc.). - -In order to use the Dozer component, Maven users will need to add the -following dependency to their `pom.xml`: - -[source,xml] ------------------------------------------------------------- -<dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-dozer</artifactId> - <version>x.x.x</version> - <!-- use the same version as your Camel core version --> -</dependency> ------------------------------------------------------------- - -[[Dozer-URIformat]] -URI format -^^^^^^^^^^ - -The Dozer component only supports producer endpoints. - -[source,java] --------------------------- -dozer:endpointId[?options] --------------------------- - -Where *endpointId* is a name used to uniquely identify the Dozer -endpoint configuration. - -An example Dozer endpoint URI: - -[source,java] ---------------------------------------------------------------------------------------- -from("direct:orderInput"). - to("dozer:transformOrder?mappingFile=orderMapping.xml&targetModel=example.XYZOrder"). - to("direct:orderOutput"); ---------------------------------------------------------------------------------------- - -[[Dozer-Options]] -Options -^^^^^^^ - -[width="100%",cols="10%,10%,80%",options="header",] -|======================================================================= -|Name |Default |Description - -|`mappingFile` |dozerBeanMapping.xml |The location of a Dozer configuration file. The file is loaded from the -classpath by default, but you can use `file:`, -`classpath:, or ``http: `to load the configuration from a specific -location. - -|`unmarshalId` |none |The id of a dataFormat defined within the Camel Context to use for -unmarshalling the mapping input from a non-Java type. - -|`marshalId` |none |The id of a dataFormat defined within the Camel Context to use for -marshalling the mapping output to a non-Java type. - -|`sourceModel` |none |Fully-qualified class name for the source type used in the mapping. If -specified, the input to the mapping is converted to the specified type -before being mapped with Dozer. - -|`targetModel` |none |Fully-qualified class name for the target type used in the mapping. This -option is required. - -|`mappingConfiguration` |none |The name of a DozerBeanMapperConfiguration bean in the Camel registry -which should be used for configuring the Dozer mapping. This is an -alternative to the mappingFile option that can be used for fine-grained -control over how Dozer is configured. Remember to use a "#" prefix in -the value to indicate that the bean is in the Camel registry (e.g. -"#myDozerConfig"). -|======================================================================= - -[[Dozer-UsingDataFormatswithDozer]] -Using Data Formats with Dozer -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Dozer does not support non-Java sources and targets for mappings, so it -cannot, for example, map an XML document to a Java object on its own. - Luckily, Camel has extensive support for marshalling between Java and a -wide variety of formats using -http://camel.apache.org/data-format.html[data formats].  The Dozer -component takes advantage of this support by allowing you to specify -that input and output data should be passed through a data format prior -to processing via Dozer.  You can always do this on your own outside the -call to Dozer, but supporting it directly in the Dozer component allows -you to use a single endpoints to configure any-to-any transformation -within Camel. - -As an example, let's say you wanted to map between an XML data structure -and a JSON data structure using the Dozer component.  If you had the -following data formats defined in a Camel Context: - -[source,xml] ------------------------------------------------ -<dataFormats> - <json library="Jackson" id="myjson"/> - <jaxb contextPath="org.example" id="myjaxb"/> -</dataFormats> ------------------------------------------------ - -You could then configure a Dozer endpoint to unmarshal the input XML -using a JAXB data format and marshal the mapping output using Jackson. - -[source,xml] ----------------------------------------------------------------------------------------------------------- -<endpoint uri="dozer:xml2json?marshalId=myjson&unmarshalId=myjaxb&targetModel=org.example.Order"/> ----------------------------------------------------------------------------------------------------------- - -[[Dozer-ConfiguringDozer]] -Configuring Dozer -^^^^^^^^^^^^^^^^^ - -All Dozer endpoints require a Dozer mapping configuration file which -defines mappings between source and target objects.  The component will -default to a location of META-INF/dozerBeanMapping.xml if the -mappingFile or mappingConfiguration options are not specified on an -endpoint.  If you need to supply multiple mapping configuration files -for a single endpoint or specify additional configuration options (e.g. -event listeners, custom converters, etc.), then you can use an instance -of `org.apache.camel.converter.dozer.DozerBeanMapperConfiguration`. - -[source,xml] ------------------------------------------------------------------------------------------- -<bean id="mapper" class="org.apache.camel.converter.dozer.DozerBeanMapperConfiguration">  - <property name="mappingFiles"> - <list> - <value>mapping1.xml</value> - <value>mapping2.xml</value> - </list> - </property> -</bean> ------------------------------------------------------------------------------------------- - -[[Dozer-MappingExtensions]] -Mapping Extensions -^^^^^^^^^^^^^^^^^^ - -The Dozer component implements a number of extensions to the Dozer -mapping framework as custom converters.  These converters implement -mapping functions that are not supported directly by Dozer itself. - -[[Dozer-VariableMappings]] -Variable Mappings -+++++++++++++++++ - -Variable mappings allow you to map the value of a variable definition -within a Dozer configuration into a target field instead of using the -value of a source field.  This is equivalent to constant mapping in -other mapping frameworks, where can you assign a literal value to a -target field.  To use a variable mapping, simply define a variable -within your mapping configuration and then map from the VariableMapper -class into your target field of choice: - -[source,xml] --------------------------------------------------------------------------------------------------------- -<mappings xmlns="http://dozer.sourceforge.net" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://dozer.sourceforge.net http://dozer.sourceforge.net/schema/beanmapping.xsd"> - <configuration> - <variables> - <variable name="CUST_ID">ACME-SALES</variable> - </variables> - </configuration> - <mapping> - <class-a>org.apache.camel.component.dozer.VariableMapper</class-a> - <class-b>org.example.Order</class-b> - <field custom-converter-id="_variableMapping" custom-converter-param="${CUST_ID}"> - <a>literal</a> - <b>custId</b> - </field> - </mapping> -</mappings> --------------------------------------------------------------------------------------------------------- - -[[Dozer-CustomMappings]] -Custom Mappings -+++++++++++++++ - -Custom mappings allow you to define your own logic for how a source -field is mapped to a target field.  They are similar in function to -Dozer customer converters, with two notable differences: - -* You can have multiple converter methods in a single class with custom -mappings. -* There is no requirement to implement a Dozer-specific interface with -custom mappings. - -A custom mapping is declared by using the built-in '_customMapping' -converter in your mapping configuration.  The parameter to this -converter has the following syntax: - -[source,shell] --------------------------- -[class-name][,method-name] --------------------------- - -Method name is optional - the Dozer component will search for a method -that matches the input and output types required for a mapping.  An -example custom mapping and configuration are provided below. - -[source,java] --------------------------------------------------- -public class CustomMapper { - // All customer ids must be wrapped in "[ ]" - public Object mapCustomer(String customerId) { - return "[" + customerId + "]"; - } -} --------------------------------------------------- - -[source,xml] --------------------------------------------------------------------------------------------------------- -<mappings xmlns="http://dozer.sourceforge.net" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://dozer.sourceforge.net http://dozer.sourceforge.net/schema/beanmapping.xsd"> - <mapping> - <class-a>org.example.A</class-a> - <class-b>org.example.B</class-b> - <field custom-converter-id="_customMapping" - custom-converter-param="org.example.CustomMapper,mapCustomer"> - <a>header.customerNum</a> - <b>custId</b> - </field> - </mapping> -</mappings> --------------------------------------------------------------------------------------------------------- - -[[Dozer-ExpressionMappings]] -Expression Mappings -+++++++++++++++++++ - -Expression mappings allow you to use the powerful -http://camel.apache.org/languages.html[language] capabilities of Camel -to evaluate an expression and assign the result to a target field in a -mapping.  Any language that Camel supports can be used in an expression -mapping.  Basic examples of expressions include the ability to map a -Camel message header or exchange property to a target field or to -concatenate multiple source fields into a target field.  The syntax of a -mapping expression is: - -[source,shell] ------------------------ -[language]:[expression] ------------------------ - -An example of mapping a message header into a target field: - -[source,xml] --------------------------------------------------------------------------------------------------------------- -<mappings xmlns="http://dozer.sourceforge.net" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://dozer.sourceforge.net http://dozer.sourceforge.net/schema/beanmapping.xsd"> - <mapping> - <class-a>org.apache.camel.component.dozer.ExpressionMapper</class-a> - <class-b>org.example.B</class-b> - <field custom-converter-id="_expressionMapping" custom-converter-param="simple:\${header.customerNumber}"> - <a>expression</a> - <b>custId</b> - </field> - </mapping> -</mappings> --------------------------------------------------------------------------------------------------------------- - -Note that any properties within your expression must be escaped with "\" -to prevent an error when Dozer attempts to resolve variable values -defined using the EL. - http://git-wip-us.apache.org/repos/asf/camel/blob/9c0b7baf/components/camel-dropbox/src/main/docs/dropbox-component.adoc ---------------------------------------------------------------------- diff --git a/components/camel-dropbox/src/main/docs/dropbox-component.adoc b/components/camel-dropbox/src/main/docs/dropbox-component.adoc new file mode 100644 index 0000000..84c4a50 --- /dev/null +++ b/components/camel-dropbox/src/main/docs/dropbox-component.adoc @@ -0,0 +1,385 @@ +[[Dropbox-CamelDropboxcomponent]] +Camel Dropbox component +~~~~~~~~~~~~~~~~~~~~~~~ + +*Available as of Camel 2.14* + +The *dropbox:* component allows you to treat +https://www.dropbox.com[Dropbox] remote folders as a producer or +consumer of messages. Using the +http://dropbox.github.io/dropbox-sdk-java/api-docs/v1.7.x/[Dropbox Java +Core API] (reference version for this component is 1.7.x), this camel +component has the following features: + +* As a consumer, download files and search files by queries +* As a producer, download files, move files between remote directories, +delete files/dir, upload files and search files by queries + +Maven users will need to add the following dependency to their `pom.xml` +for this component: + +[source,xml] +------------------------------------------------------------ +<dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-dropbox</artifactId> + <version>x.x.x</version> + <!-- use the same version as your Camel core version --> +</dependency> +------------------------------------------------------------ + +[[Dropbox-URIformat]] +URI format +^^^^^^^^^^ + +[source,java] +------------------------------- +dropbox://[operation]?[options] +------------------------------- + +Where *operation* is the specific action (typically is a CRUD action) to +perform on Dropbox remote folder. + +[[Dropbox-Operations]] +Operations +^^^^^^^^^^ + +[width="100%",cols="40%,60%",options="header",] +|======================================================================= +|Operation |Description + +|`del` |deletes files or directories on Dropbox + +|`get` |download files from Dropbox + +|`move` |move files from folders on Dropbox + +|`put` |upload files on Dropbox + +|`search` |search files on Dropbox based on string queries +|======================================================================= + +*Operations* require additional options to work, some are mandatory for +the specific operation. + +[[Dropbox-Options]] +Options +^^^^^^^ + +In order to work with Dropbox API you need to obtain an *accessToken* +and a *clientIdentifier.* + +You can refer to the +https://www.dropbox.com/developers/core/start/java[Dropbox +documentation] that expalins how to get them.  + +Below are listed the mandatory options for all operations: + +[width="100%",cols="20%,20%,60%",options="header",] +|======================================================================= +|Property |Mandatory |Description + +|`accessToken` |`true` |The access token to make API requests for a specific Dropbox user + +|`clientIdentifier` |`true` |Name of the app registered to make API requests +|======================================================================= + +[[Dropbox-Deloperation]] +Del operation +^^^^^^^^^^^^^ + +Delete files on Dropbox. + +Works only as Camel producer. + +Below are listed the options for this operation: + +[width="100%",cols="20%,20%,60%",options="header",] +|======================================================================= +|Property |Mandatory |Description + +|`remotePath` |`true` |Folder or file to delete on Dropbox +|======================================================================= + +[[Dropbox-Samples]] +Samples ++++++++ + +[source,java] +------------------------------- +from("direct:start").to("dropbox://del?accessToken=XXX&clientIdentifier=XXX&remotePath=/root/folder1").to("mock:result"); + +from("direct:start").to("dropbox://del?accessToken=XXX&clientIdentifier=XXX&remotePath=/root/folder1/file1.tar.gz").to("mock:result"); +------------------------------- + +[[Dropbox-ResultMessageHeaders]] +Result Message Headers +++++++++++++++++++++++ + +The following headers are set on message result: + +[width="100%",cols="50%,50%",options="header",] +|======================================================================= +|Property |Value + +|`DELETED_PATH` |name of the path deleted on dropbox +|======================================================================= + +[[Dropbox-ResultMessageBody]] +Result Message Body ++++++++++++++++++++ + +The following objects are set on message body result: + +[width="100%",cols="50%,50%",options="header",] +|======================================================================= +|Object type |Description + +|`String` |name of the path deleted on dropbox +|======================================================================= + +[[Dropbox-Getoperation]] +Get (download) operation +^^^^^^^^^^^^^^^^^^^^^^^^ + +Download files from Dropbox. + +Works as Camel producer or Camel consumer. + +Below are listed the options for this operation: + +[width="100%",cols="20%,20%,60%",options="header",] +|======================================================================= +|Property |Mandatory |Description + +|`remotePath` |`true` |Folder or file to download from Dropbox +|======================================================================= + +[[Dropbox-Samples.1]] +Samples ++++++++ + +[source,java] +------------------------------- +from("direct:start").to("dropbox://get?accessToken=XXX&clientIdentifier=XXX&remotePath=/root/folder1/file1.tar.gz").to("file:///home/kermit/?fileName=file1.tar.gz"); + +from("direct:start").to("dropbox://get?accessToken=XXX&clientIdentifier=XXX&remotePath=/root/folder1").to("mock:result"); + +from("dropbox://get?accessToken=XXX&clientIdentifier=XXX&remotePath=/root/folder1").to("file:///home/kermit/"); +------------------------------- + +[[Dropbox-ResultMessageHeaders.1]] +Result Message Headers +++++++++++++++++++++++ + +The following headers are set on message result: + +[width="100%",cols="50%,50%",options="header",] +|======================================================================= +|Property |Value + +|`DOWNLOADED_FILE` |in case of single file download, path of the remote file downloaded + +|`DOWNLOADED_FILES` |in case of multiple files download, path of the remote files downloaded +|======================================================================= + +[[Dropbox-ResultMessageBody.1]] +Result Message Body ++++++++++++++++++++ + +The following objects are set on message body result: + +[width="100%",cols="50%,50%",options="header",] +|======================================================================= +|Object type |Description + +|`ByteArrayOutputStream` |in case of single file download, stream representing the file downloaded + +|`Map<String, ByteArrayOutputStream>` |in case of multiple files download, a map with as key the path of the +remote file downloaded and as value the stream representing the file +downloaded +|======================================================================= + +[[Dropbox-Moveoperation]] +Move operation +^^^^^^^^^^^^^^ + +Move files on Dropbox between one folder to another. + +Works only as Camel producer. + +Below are listed the options for this operation: + +[width="100%",cols="20%,20%,60%",options="header",] +|======================================================================= +|Property |Mandatory |Description + +|`remotePath` |`true` |Original file or folder to move + +|`newRemotePath` |`true` |Destination file or folder +|======================================================================= + +[[Dropbox-Samples.2]] +Samples ++++++++ + +[source,java] +------------------------------- +from("direct:start").to("dropbox://move?accessToken=XXX&clientIdentifier=XXX&remotePath=/root/folder1&newRemotePath=/root/folder2").to("mock:result"); +------------------------------- + +[[Dropbox-ResultMessageHeaders.2]] +Result Message Headers +++++++++++++++++++++++ + +The following headers are set on message result: + +[width="100%",cols="50%,50%",options="header",] +|======================================================================= +|Property |Value + +|`MOVED_PATH` |name of the path moved on dropbox +|======================================================================= + +[[Dropbox-ResultMessageBody.2]] +Result Message Body ++++++++++++++++++++ + +The following objects are set on message body result: + +[width="100%",cols="50%,50%",options="header",] +|======================================================================= +|Object type |Description + +|`String` |name of the path moved on dropbox +|======================================================================= + +[[Dropbox-Putoperation]] +Put (upload) operation +^^^^^^^^^^^^^^^^^^^^^^ + +Upload files on Dropbox. + +Works as Camel producer. + +Below are listed the options for this operation: + +[width="100%",cols="20%,20%,60%",options="header",] +|======================================================================= +|Property |Mandatory |Description + +|`uploadMode` |`true` |add or force this option specifies how a file should be saved on +dropbox: in case of "add" the new file will be renamed if a file with the same +name already exists on dropbox. In case of "force" if a file with the same name already exists on +dropbox, this will be overwritten. + +|`localPath` |`true` |Folder or file to upload on Dropbox from the local filesystem . + +|`remotePath` |`false` |Folder destination on Dropbox. If the property is not set, the component +will upload the file on a remote path equal to the local path. +|======================================================================= + +[[Dropbox-Samples.3]] +Samples ++++++++ + +[source,java] +------------------------------- +from("direct:start").to("dropbox://put?accessToken=XXX&clientIdentifier=XXX&uploadMode=add&localPath=/root/folder1").to("mock:result"); + +from("direct:start").to("dropbox://put?accessToken=XXX&clientIdentifier=XXX&uploadMode=add&localPath=/root/folder1&remotePath=/root/folder2").to("mock:result"); +------------------------------- + +[[Dropbox-ResultMessageHeaders.3]] +Result Message Headers +++++++++++++++++++++++ + +The following headers are set on message result: + +[width="100%",cols="50%,50%",options="header",] +|======================================================================= +|Property |Value + +|`UPLOADED_FILE` |in case of single file upload, path of the remote path uploaded + +|`UPLOADED_FILES` |in case of multiple files upload, string with the remote paths uploaded +|======================================================================= + +[[Dropbox-ResultMessageBody.3]] +Result Message Body ++++++++++++++++++++ + +The following objects are set on message body result: + +[width="100%",cols="50%,50%",options="header",] +|======================================================================= +|Object type |Description + +|`String` |in case of single file upload, result of the upload operation, OK or KO + +|`Map<String, DropboxResultCode>` |in case of multiple files upload, a map with as key the path of the +remote file uploaded and as value the result of the upload operation, OK +or KO +|======================================================================= + +[[Dropbox-Searchoperation]] +Search operation +^^^^^^^^^^^^^^^^ + +Search inside a remote Dropbox folder including its sub directories. + +Works as Camel producer and as Camel consumer. + +Below are listed the options for this operation: + +[width="100%",cols="20%,20%,60%",options="header",] +|======================================================================= +|Property |Mandatory |Description + +|`remotePath` |`true` |Folder on Dropbox where to search in. + +|`query` |`false` |A space-separated list of substrings to search for. A file matches only +if it contains all the substrings. If this option is not set, all files +will be matched. +|======================================================================= + +[[Dropbox-Samples.4]] +Samples ++++++++ + +[source,java] +------------------------------- +from("dropbox://search?accessToken=XXX&clientIdentifier=XXX&remotePath=/XXX&query=XXX").to("mock:result"); + +from("direct:start").to("dropbox://search?accessToken=XXX&clientIdentifier=XXX&remotePath=/XXX").to("mock:result"); +------------------------------- + +[[Dropbox-ResultMessageHeaders.4]] +Result Message Headers +++++++++++++++++++++++ + +The following headers are set on message result: + +[width="100%",cols="50%,50%",options="header",] +|======================================================================= +|Property |Value + +|`FOUNDED_FILES` |list of file path founded +|======================================================================= + +[[Dropbox-ResultMessageBody.4]] +Result Message Body ++++++++++++++++++++ + +The following objects are set on message body result: + +[width="100%",cols="50%,50%",options="header",] +|======================================================================= +|Object type |Description + +|`List<DbxEntry>` |list of file path founded. For more information on this object refer to +Dropbox documentation, +|======================================================================= + +link:http://dropbox.github.io/dropbox-sdk-java/api-docs/v1.7.x/com/dropbox/core/DbxEntry.html[http://dropbox.github.io/dropbox-sdk-java/api-docs/v1.7.x/com/dropbox/core/DbxEntry.html] + + http://git-wip-us.apache.org/repos/asf/camel/blob/9c0b7baf/components/camel-dropbox/src/main/docs/dropbox.adoc ---------------------------------------------------------------------- diff --git a/components/camel-dropbox/src/main/docs/dropbox.adoc b/components/camel-dropbox/src/main/docs/dropbox.adoc deleted file mode 100644 index 84c4a50..0000000 --- a/components/camel-dropbox/src/main/docs/dropbox.adoc +++ /dev/null @@ -1,385 +0,0 @@ -[[Dropbox-CamelDropboxcomponent]] -Camel Dropbox component -~~~~~~~~~~~~~~~~~~~~~~~ - -*Available as of Camel 2.14* - -The *dropbox:* component allows you to treat -https://www.dropbox.com[Dropbox] remote folders as a producer or -consumer of messages. Using the -http://dropbox.github.io/dropbox-sdk-java/api-docs/v1.7.x/[Dropbox Java -Core API] (reference version for this component is 1.7.x), this camel -component has the following features: - -* As a consumer, download files and search files by queries -* As a producer, download files, move files between remote directories, -delete files/dir, upload files and search files by queries - -Maven users will need to add the following dependency to their `pom.xml` -for this component: - -[source,xml] ------------------------------------------------------------- -<dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-dropbox</artifactId> - <version>x.x.x</version> - <!-- use the same version as your Camel core version --> -</dependency> ------------------------------------------------------------- - -[[Dropbox-URIformat]] -URI format -^^^^^^^^^^ - -[source,java] -------------------------------- -dropbox://[operation]?[options] -------------------------------- - -Where *operation* is the specific action (typically is a CRUD action) to -perform on Dropbox remote folder. - -[[Dropbox-Operations]] -Operations -^^^^^^^^^^ - -[width="100%",cols="40%,60%",options="header",] -|======================================================================= -|Operation |Description - -|`del` |deletes files or directories on Dropbox - -|`get` |download files from Dropbox - -|`move` |move files from folders on Dropbox - -|`put` |upload files on Dropbox - -|`search` |search files on Dropbox based on string queries -|======================================================================= - -*Operations* require additional options to work, some are mandatory for -the specific operation. - -[[Dropbox-Options]] -Options -^^^^^^^ - -In order to work with Dropbox API you need to obtain an *accessToken* -and a *clientIdentifier.* + -You can refer to the -https://www.dropbox.com/developers/core/start/java[Dropbox -documentation] that expalins how to get them.  - -Below are listed the mandatory options for all operations: - -[width="100%",cols="20%,20%,60%",options="header",] -|======================================================================= -|Property |Mandatory |Description - -|`accessToken` |`true` |The access token to make API requests for a specific Dropbox user - -|`clientIdentifier` |`true` |Name of the app registered to make API requests -|======================================================================= - -[[Dropbox-Deloperation]] -Del operation -^^^^^^^^^^^^^ - -Delete files on Dropbox. - -Works only as Camel producer. - -Below are listed the options for this operation: - -[width="100%",cols="20%,20%,60%",options="header",] -|======================================================================= -|Property |Mandatory |Description - -|`remotePath` |`true` |Folder or file to delete on Dropbox -|======================================================================= - -[[Dropbox-Samples]] -Samples -+++++++ - -[source,java] -------------------------------- -from("direct:start").to("dropbox://del?accessToken=XXX&clientIdentifier=XXX&remotePath=/root/folder1").to("mock:result"); - -from("direct:start").to("dropbox://del?accessToken=XXX&clientIdentifier=XXX&remotePath=/root/folder1/file1.tar.gz").to("mock:result"); -------------------------------- - -[[Dropbox-ResultMessageHeaders]] -Result Message Headers -++++++++++++++++++++++ - -The following headers are set on message result: - -[width="100%",cols="50%,50%",options="header",] -|======================================================================= -|Property |Value - -|`DELETED_PATH` |name of the path deleted on dropbox -|======================================================================= - -[[Dropbox-ResultMessageBody]] -Result Message Body -+++++++++++++++++++ - -The following objects are set on message body result: - -[width="100%",cols="50%,50%",options="header",] -|======================================================================= -|Object type |Description - -|`String` |name of the path deleted on dropbox -|======================================================================= - -[[Dropbox-Getoperation]] -Get (download) operation -^^^^^^^^^^^^^^^^^^^^^^^^ - -Download files from Dropbox. - -Works as Camel producer or Camel consumer. - -Below are listed the options for this operation: - -[width="100%",cols="20%,20%,60%",options="header",] -|======================================================================= -|Property |Mandatory |Description - -|`remotePath` |`true` |Folder or file to download from Dropbox -|======================================================================= - -[[Dropbox-Samples.1]] -Samples -+++++++ - -[source,java] -------------------------------- -from("direct:start").to("dropbox://get?accessToken=XXX&clientIdentifier=XXX&remotePath=/root/folder1/file1.tar.gz").to("file:///home/kermit/?fileName=file1.tar.gz"); - -from("direct:start").to("dropbox://get?accessToken=XXX&clientIdentifier=XXX&remotePath=/root/folder1").to("mock:result"); - -from("dropbox://get?accessToken=XXX&clientIdentifier=XXX&remotePath=/root/folder1").to("file:///home/kermit/"); -------------------------------- - -[[Dropbox-ResultMessageHeaders.1]] -Result Message Headers -++++++++++++++++++++++ - -The following headers are set on message result: - -[width="100%",cols="50%,50%",options="header",] -|======================================================================= -|Property |Value - -|`DOWNLOADED_FILE` |in case of single file download, path of the remote file downloaded - -|`DOWNLOADED_FILES` |in case of multiple files download, path of the remote files downloaded -|======================================================================= - -[[Dropbox-ResultMessageBody.1]] -Result Message Body -+++++++++++++++++++ - -The following objects are set on message body result: - -[width="100%",cols="50%,50%",options="header",] -|======================================================================= -|Object type |Description - -|`ByteArrayOutputStream` |in case of single file download, stream representing the file downloaded - -|`Map<String, ByteArrayOutputStream>` |in case of multiple files download, a map with as key the path of the -remote file downloaded and as value the stream representing the file -downloaded -|======================================================================= - -[[Dropbox-Moveoperation]] -Move operation -^^^^^^^^^^^^^^ - -Move files on Dropbox between one folder to another. - -Works only as Camel producer. - -Below are listed the options for this operation: - -[width="100%",cols="20%,20%,60%",options="header",] -|======================================================================= -|Property |Mandatory |Description - -|`remotePath` |`true` |Original file or folder to move - -|`newRemotePath` |`true` |Destination file or folder -|======================================================================= - -[[Dropbox-Samples.2]] -Samples -+++++++ - -[source,java] -------------------------------- -from("direct:start").to("dropbox://move?accessToken=XXX&clientIdentifier=XXX&remotePath=/root/folder1&newRemotePath=/root/folder2").to("mock:result"); -------------------------------- - -[[Dropbox-ResultMessageHeaders.2]] -Result Message Headers -++++++++++++++++++++++ - -The following headers are set on message result: - -[width="100%",cols="50%,50%",options="header",] -|======================================================================= -|Property |Value - -|`MOVED_PATH` |name of the path moved on dropbox -|======================================================================= - -[[Dropbox-ResultMessageBody.2]] -Result Message Body -+++++++++++++++++++ - -The following objects are set on message body result: - -[width="100%",cols="50%,50%",options="header",] -|======================================================================= -|Object type |Description - -|`String` |name of the path moved on dropbox -|======================================================================= - -[[Dropbox-Putoperation]] -Put (upload) operation -^^^^^^^^^^^^^^^^^^^^^^ - -Upload files on Dropbox. - -Works as Camel producer. - -Below are listed the options for this operation: - -[width="100%",cols="20%,20%,60%",options="header",] -|======================================================================= -|Property |Mandatory |Description - -|`uploadMode` |`true` |add or force this option specifies how a file should be saved on -dropbox: in case of "add" the new file will be renamed if a file with the same -name already exists on dropbox. In case of "force" if a file with the same name already exists on -dropbox, this will be overwritten. - -|`localPath` |`true` |Folder or file to upload on Dropbox from the local filesystem . - -|`remotePath` |`false` |Folder destination on Dropbox. If the property is not set, the component -will upload the file on a remote path equal to the local path. -|======================================================================= - -[[Dropbox-Samples.3]] -Samples -+++++++ - -[source,java] -------------------------------- -from("direct:start").to("dropbox://put?accessToken=XXX&clientIdentifier=XXX&uploadMode=add&localPath=/root/folder1").to("mock:result"); - -from("direct:start").to("dropbox://put?accessToken=XXX&clientIdentifier=XXX&uploadMode=add&localPath=/root/folder1&remotePath=/root/folder2").to("mock:result"); -------------------------------- - -[[Dropbox-ResultMessageHeaders.3]] -Result Message Headers -++++++++++++++++++++++ - -The following headers are set on message result: - -[width="100%",cols="50%,50%",options="header",] -|======================================================================= -|Property |Value - -|`UPLOADED_FILE` |in case of single file upload, path of the remote path uploaded - -|`UPLOADED_FILES` |in case of multiple files upload, string with the remote paths uploaded -|======================================================================= - -[[Dropbox-ResultMessageBody.3]] -Result Message Body -+++++++++++++++++++ - -The following objects are set on message body result: - -[width="100%",cols="50%,50%",options="header",] -|======================================================================= -|Object type |Description - -|`String` |in case of single file upload, result of the upload operation, OK or KO - -|`Map<String, DropboxResultCode>` |in case of multiple files upload, a map with as key the path of the -remote file uploaded and as value the result of the upload operation, OK -or KO -|======================================================================= - -[[Dropbox-Searchoperation]] -Search operation -^^^^^^^^^^^^^^^^ - -Search inside a remote Dropbox folder including its sub directories. - -Works as Camel producer and as Camel consumer. - -Below are listed the options for this operation: - -[width="100%",cols="20%,20%,60%",options="header",] -|======================================================================= -|Property |Mandatory |Description - -|`remotePath` |`true` |Folder on Dropbox where to search in. - -|`query` |`false` |A space-separated list of substrings to search for. A file matches only -if it contains all the substrings. If this option is not set, all files -will be matched. -|======================================================================= - -[[Dropbox-Samples.4]] -Samples -+++++++ - -[source,java] -------------------------------- -from("dropbox://search?accessToken=XXX&clientIdentifier=XXX&remotePath=/XXX&query=XXX").to("mock:result"); - -from("direct:start").to("dropbox://search?accessToken=XXX&clientIdentifier=XXX&remotePath=/XXX").to("mock:result"); -------------------------------- - -[[Dropbox-ResultMessageHeaders.4]] -Result Message Headers -++++++++++++++++++++++ - -The following headers are set on message result: - -[width="100%",cols="50%,50%",options="header",] -|======================================================================= -|Property |Value - -|`FOUNDED_FILES` |list of file path founded -|======================================================================= - -[[Dropbox-ResultMessageBody.4]] -Result Message Body -+++++++++++++++++++ - -The following objects are set on message body result: - -[width="100%",cols="50%,50%",options="header",] -|======================================================================= -|Object type |Description - -|`List<DbxEntry>` |list of file path founded. For more information on this object refer to -Dropbox documentation, -|======================================================================= - -link:http://dropbox.github.io/dropbox-sdk-java/api-docs/v1.7.x/com/dropbox/core/DbxEntry.html[http://dropbox.github.io/dropbox-sdk-java/api-docs/v1.7.x/com/dropbox/core/DbxEntry.html] - - http://git-wip-us.apache.org/repos/asf/camel/blob/9c0b7baf/components/camel-ehcache/src/main/docs/ehcache-component.adoc ---------------------------------------------------------------------- diff --git a/components/camel-ehcache/src/main/docs/ehcache-component.adoc b/components/camel-ehcache/src/main/docs/ehcache-component.adoc new file mode 100644 index 0000000..2b1815f --- /dev/null +++ b/components/camel-ehcache/src/main/docs/ehcache-component.adoc @@ -0,0 +1,198 @@ +[[Ehcache-EhcacheComponent]] +Ehcache Component +~~~~~~~~~~~~~~~~~ + +*Available as of Camel 2.18.x* + +The *ehcache* component enables you to perform caching operations using +Ehcache 3 as the Cache Implementation. + +This component supports producer and event based consumer endpoints. + +The Cache consumer is an event based consumer and can be used to listen +and respond to specific cache activities. + +Maven users will need to add the following dependency to +their `pom.xml` for this component: + +[source,xml] +------------------------------------------------------------ +<dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-ehcache</artifactId> + <version>x.x.x</version> + <!-- use the same version as your Camel core version --> +</dependency> +------------------------------------------------------------ + +[[Ehcache-URIformat]] +URI format +^^^^^^^^^^ + +[source,java] +----------------------------- +ehcache://cacheName[?options] +----------------------------- + +You can append query options to the URI in the following +format, `?option=value&option=#beanRef&...` + +[[Ehcache-Options]] +Options +^^^^^^^ + + +// component options: START +The Ehcache component has no options. +// component options: END + + + +// endpoint options: START +The Ehcache component supports 5 endpoint options which are listed below: + +{% raw %} +[width="100%",cols="2s,1,1m,1m,5",options="header"] +|======================================================================= +| Name | Group | Default | Java Type | Description +| cacheName | common | | String | *Required* the cache name +| bridgeErrorHandler | consumer | false | boolean | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored. +| exceptionHandler | consumer (advanced) | | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored. +| exchangePattern | advanced | InOnly | ExchangePattern | Sets the default exchange pattern when creating an exchange +| synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). +|======================================================================= +{% endraw %} +// endpoint options: END + + +[[Ehcache-MessageHeadersCamel]] +Message Headers Camel +++++++++++++++++++++++ + + +[width="100%",cols="10%,10%,80%",options="header",] +|======================================================================= +|Header |Type |Description + +|CamelEhcacheAction |`String` |The operation to be perfomed on the cache, valid options are: + +* CLEAR +* PUT +* PUT_ALL +* PUT_IF_ABSENT +* GET +* GET_ALL +* REMOVE +* REMOVE_ALL +* REPLACE + +|CamelEhcacheActionHasResult |Boolean |Set to true if the action has a result + +|CamelEhcacheActionSucceeded |`Boolean` |Set to true if the actionsuccedded + +|CamelEhcacheKey |Object |The cache key used for an action + +|CamelEhcacheKeys |Set<Object> |A list of keys, used in + +* PUT_ALL +* GET_ALL +* REMOVE_ALL + +|CamelEhcacheValue |Object |The value to put in the cache or the result of an operation + +|CamelEhcacheOldValue |Object |The old value associated to a key for actions like PUT_IF_ABSENT or the +Object used for comparison for actions like REPLACE + +|CamelEhcacheEventType |EventType |The type of event received +|======================================================================= + +[[Ehcache-Ehcachebasedidempotentrepositoryexample:]] +Ehcache based idempotent repository example: +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +[source,java] +------------------------------------------------------------------------------------------------ +CacheManager manager = CacheManagerBuilder.newCacheManager(new XmlConfiguration("ehcache.xml")); +EhcacheIdempotentRepository repo = new EhcacheIdempotentRepository(manager, "idempotent-cache"); + +from("direct:in") + .idempotentConsumer(header("messageId"), idempotentRepo) + .to("mock:out"); +------------------------------------------------------------------------------------------------ + + + +[[Ehcache-Ehcachebasedaggregationrepositoryexample:]] +Ehcache based aggregation repository example: +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +[source,java] +--------------------------------------------------------------------------------------------------------------------------------- +public class EhcacheAggregationRepositoryRoutesTest extends CamelTestSupport { + private static final String ENDPOINT_MOCK = "mock:result"; + private static final String ENDPOINT_DIRECT = "direct:one"; + private static final int[] VALUES = generateRandomArrayOfInt(10, 0, 30); + private static final int SUM = IntStream.of(VALUES).reduce(0, (a, b) -> a + b); + private static final String CORRELATOR = "CORRELATOR"; + + @EndpointInject(uri = ENDPOINT_MOCK) + private MockEndpoint mock; + + @Produce(uri = ENDPOINT_DIRECT) + private ProducerTemplate producer; + + @Test + public void checkAggregationFromOneRoute() throws Exception { + mock.expectedMessageCount(VALUES.length); + mock.expectedBodiesReceived(SUM); + + IntStream.of(VALUES).forEach( + i -> producer.sendBodyAndHeader(i, CORRELATOR, CORRELATOR) + ); + + mock.assertIsSatisfied(); + } + + private Exchange aggregate(Exchange oldExchange, Exchange newExchange) { + if (oldExchange == null) { + return newExchange; + } else { + Integer n = newExchange.getIn().getBody(Integer.class); + Integer o = oldExchange.getIn().getBody(Integer.class); + Integer v = (o == null ? 0 : o) + (n == null ? 0 : n); + + oldExchange.getIn().setBody(v, Integer.class); + + return oldExchange; + } + } + + @Override + protected RoutesBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from(ENDPOINT_DIRECT) + .routeId("AggregatingRouteOne") + .aggregate(header(CORRELATOR)) + .aggregationRepository(createAggregateRepository()) + .aggregationStrategy(EhcacheAggregationRepositoryRoutesTest.this::aggregate) + .completionSize(VALUES.length) + .to("log:org.apache.camel.component.ehcache.processor.aggregate.level=INFO&showAll=true&mulltiline=true") + .to(ENDPOINT_MOCK); + } + }; + } + + protected EhcacheAggregationRepository createAggregateRepository() throws Exception { + CacheManager cacheManager = CacheManagerBuilder.newCacheManager(new XmlConfiguration("ehcache.xml")); + cacheManager.init(); + + EhcacheAggregationRepository repository = new EhcacheAggregationRepository(); + repository.setCacheManager(cacheManager); + repository.setCacheName("aggregate"); + + return repository; + } +} +--------------------------------------------------------------------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/9c0b7baf/components/camel-ehcache/src/main/docs/ehcache.adoc ---------------------------------------------------------------------- diff --git a/components/camel-ehcache/src/main/docs/ehcache.adoc b/components/camel-ehcache/src/main/docs/ehcache.adoc deleted file mode 100644 index 2b1815f..0000000 --- a/components/camel-ehcache/src/main/docs/ehcache.adoc +++ /dev/null @@ -1,198 +0,0 @@ -[[Ehcache-EhcacheComponent]] -Ehcache Component -~~~~~~~~~~~~~~~~~ - -*Available as of Camel 2.18.x* - -The *ehcache* component enables you to perform caching operations using -Ehcache 3 as the Cache Implementation. - -This component supports producer and event based consumer endpoints. - -The Cache consumer is an event based consumer and can be used to listen -and respond to specific cache activities. - -Maven users will need to add the following dependency to -their `pom.xml` for this component: - -[source,xml] ------------------------------------------------------------- -<dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-ehcache</artifactId> - <version>x.x.x</version> - <!-- use the same version as your Camel core version --> -</dependency> ------------------------------------------------------------- - -[[Ehcache-URIformat]] -URI format -^^^^^^^^^^ - -[source,java] ------------------------------ -ehcache://cacheName[?options] ------------------------------ - -You can append query options to the URI in the following -format, `?option=value&option=#beanRef&...` - -[[Ehcache-Options]] -Options -^^^^^^^ - - -// component options: START -The Ehcache component has no options. -// component options: END - - - -// endpoint options: START -The Ehcache component supports 5 endpoint options which are listed below: - -{% raw %} -[width="100%",cols="2s,1,1m,1m,5",options="header"] -|======================================================================= -| Name | Group | Default | Java Type | Description -| cacheName | common | | String | *Required* the cache name -| bridgeErrorHandler | consumer | false | boolean | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored. -| exceptionHandler | consumer (advanced) | | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored. -| exchangePattern | advanced | InOnly | ExchangePattern | Sets the default exchange pattern when creating an exchange -| synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). -|======================================================================= -{% endraw %} -// endpoint options: END - - -[[Ehcache-MessageHeadersCamel]] -Message Headers Camel -++++++++++++++++++++++ - - -[width="100%",cols="10%,10%,80%",options="header",] -|======================================================================= -|Header |Type |Description - -|CamelEhcacheAction |`String` |The operation to be perfomed on the cache, valid options are: - -* CLEAR -* PUT -* PUT_ALL -* PUT_IF_ABSENT -* GET -* GET_ALL -* REMOVE -* REMOVE_ALL -* REPLACE - -|CamelEhcacheActionHasResult |Boolean |Set to true if the action has a result - -|CamelEhcacheActionSucceeded |`Boolean` |Set to true if the actionsuccedded - -|CamelEhcacheKey |Object |The cache key used for an action - -|CamelEhcacheKeys |Set<Object> |A list of keys, used in - -* PUT_ALL -* GET_ALL -* REMOVE_ALL - -|CamelEhcacheValue |Object |The value to put in the cache or the result of an operation - -|CamelEhcacheOldValue |Object |The old value associated to a key for actions like PUT_IF_ABSENT or the -Object used for comparison for actions like REPLACE - -|CamelEhcacheEventType |EventType |The type of event received -|======================================================================= - -[[Ehcache-Ehcachebasedidempotentrepositoryexample:]] -Ehcache based idempotent repository example: -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -[source,java] ------------------------------------------------------------------------------------------------- -CacheManager manager = CacheManagerBuilder.newCacheManager(new XmlConfiguration("ehcache.xml")); -EhcacheIdempotentRepository repo = new EhcacheIdempotentRepository(manager, "idempotent-cache"); - -from("direct:in") - .idempotentConsumer(header("messageId"), idempotentRepo) - .to("mock:out"); ------------------------------------------------------------------------------------------------- - - - -[[Ehcache-Ehcachebasedaggregationrepositoryexample:]] -Ehcache based aggregation repository example: -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -[source,java] ---------------------------------------------------------------------------------------------------------------------------------- -public class EhcacheAggregationRepositoryRoutesTest extends CamelTestSupport { - private static final String ENDPOINT_MOCK = "mock:result"; - private static final String ENDPOINT_DIRECT = "direct:one"; - private static final int[] VALUES = generateRandomArrayOfInt(10, 0, 30); - private static final int SUM = IntStream.of(VALUES).reduce(0, (a, b) -> a + b); - private static final String CORRELATOR = "CORRELATOR"; - - @EndpointInject(uri = ENDPOINT_MOCK) - private MockEndpoint mock; - - @Produce(uri = ENDPOINT_DIRECT) - private ProducerTemplate producer; - - @Test - public void checkAggregationFromOneRoute() throws Exception { - mock.expectedMessageCount(VALUES.length); - mock.expectedBodiesReceived(SUM); - - IntStream.of(VALUES).forEach( - i -> producer.sendBodyAndHeader(i, CORRELATOR, CORRELATOR) - ); - - mock.assertIsSatisfied(); - } - - private Exchange aggregate(Exchange oldExchange, Exchange newExchange) { - if (oldExchange == null) { - return newExchange; - } else { - Integer n = newExchange.getIn().getBody(Integer.class); - Integer o = oldExchange.getIn().getBody(Integer.class); - Integer v = (o == null ? 0 : o) + (n == null ? 0 : n); - - oldExchange.getIn().setBody(v, Integer.class); - - return oldExchange; - } - } - - @Override - protected RoutesBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from(ENDPOINT_DIRECT) - .routeId("AggregatingRouteOne") - .aggregate(header(CORRELATOR)) - .aggregationRepository(createAggregateRepository()) - .aggregationStrategy(EhcacheAggregationRepositoryRoutesTest.this::aggregate) - .completionSize(VALUES.length) - .to("log:org.apache.camel.component.ehcache.processor.aggregate.level=INFO&showAll=true&mulltiline=true") - .to(ENDPOINT_MOCK); - } - }; - } - - protected EhcacheAggregationRepository createAggregateRepository() throws Exception { - CacheManager cacheManager = CacheManagerBuilder.newCacheManager(new XmlConfiguration("ehcache.xml")); - cacheManager.init(); - - EhcacheAggregationRepository repository = new EhcacheAggregationRepository(); - repository.setCacheManager(cacheManager); - repository.setCacheName("aggregate"); - - return repository; - } -} ---------------------------------------------------------------------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/9c0b7baf/components/camel-ejb/src/main/docs/ejb-component.adoc ---------------------------------------------------------------------- diff --git a/components/camel-ejb/src/main/docs/ejb-component.adoc b/components/camel-ejb/src/main/docs/ejb-component.adoc new file mode 100644 index 0000000..4339603 --- /dev/null +++ b/components/camel-ejb/src/main/docs/ejb-component.adoc @@ -0,0 +1,222 @@ +[[EJB-EJBComponent]] +EJB Component +~~~~~~~~~~~~~ + +*Available as of Camel 2.4* + +The *ejb:* component binds EJBs to Camel message exchanges. + +Maven users will need to add the following dependency to their `pom.xml` +for this component: + +[source,xml] +------------------------------------------------------------ +<dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-ejb</artifactId> + <version>x.x.x</version> + <!-- use the same version as your Camel core version --> +</dependency> +------------------------------------------------------------ + +[[EJB-URIformat]] +URI format +^^^^^^^^^^ + +[source,java] +--------------------- +ejb:ejbName[?options] +--------------------- + +Where *ejbName* can be any string which is used to look up the EJB in +the Application Server JNDI link:registry.html[Registry] + +[[EJB-Options]] +Options +^^^^^^^ + + +// component options: START +The EJB component supports 2 options which are listed below. + + + +{% raw %} +[width="100%",cols="2s,1m,8",options="header"] +|======================================================================= +| Name | Java Type | Description +| context | Context | The Context to use for looking up the EJBs +| properties | Properties | Properties for creating javax.naming.Context if a context has not been configured. +|======================================================================= +{% endraw %} +// component options: END + + + +// endpoint options: START +The EJB component supports 7 endpoint options which are listed below: + +{% raw %} +[width="100%",cols="2s,1,1m,1m,5",options="header"] +|======================================================================= +| Name | Group | Default | Java Type | Description +| beanName | producer | | String | *Required* Sets the name of the bean to invoke +| method | producer | | String | Sets the name of the method to invoke on the bean +| cache | advanced | false | boolean | If enabled Camel will cache the result of the first Registry look-up. Cache can be enabled if the bean in the Registry is defined as a singleton scope. +| exchangePattern | advanced | InOnly | ExchangePattern | Sets the default exchange pattern when creating an exchange +| multiParameterArray | advanced | false | boolean | How to treat the parameters which are passed from the message body.true means the message body should be an array of parameters. Note: This option is used internally by Camel and is not intended for end users to use. +| parameters | advanced | | Map | Used for configuring additional properties on the bean +| synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). +|======================================================================= +{% endraw %} +// endpoint options: END + + +[[EJB-BeanBinding]] +Bean Binding +^^^^^^^^^^^^ + +How bean methods to be invoked are chosen (if they are not specified +explicitly through the *method* parameter) and how parameter values are +constructed from the link:message.html[Message] are all defined by the +link:bean-binding.html[Bean Binding] mechanism which is used throughout +all of the various link:bean-integration.html[Bean Integration] +mechanisms in Camel. + +[[EJB-Examples]] +Examples +^^^^^^^^ + +In the following examples we use the Greater EJB which is defined as +follows: + +*GreaterLocal.java* + +[source,java] +------------------------------------------------------------------------------------------------------------------------------------------------------------- +public interface GreaterLocal { + + String hello(String name); + + String bye(String name); + +} +------------------------------------------------------------------------------------------------------------------------------------------------------------- + +And the implementation + +*GreaterImpl.java* + +[source,java] +------------------------------------------------------------------------------------------------------------------------------------------------------------- +@Stateless +public class GreaterImpl implements GreaterLocal { + + public String hello(String name) { + return "Hello " + name; + } + + public String bye(String name) { + return "Bye " + name; + } + +} +------------------------------------------------------------------------------------------------------------------------------------------------------------- + +[[EJB-UsingJavaDSL]] +Using Java DSL +++++++++++++++ + +In this example we want to invoke the `hello` method on the EJB. Since +this example is based on an unit test using Apache OpenEJB we have to +set a `JndiContext` on the link:ejb.html[EJB] component with the OpenEJB +settings. + +[source,java] +------------------------------------------------------------------------------------------------------------------------------------------------------------- +@Override +protected CamelContext createCamelContext() throws Exception { + CamelContext answer = new DefaultCamelContext(); + + // enlist EJB component using the JndiContext + EjbComponent ejb = answer.getComponent("ejb", EjbComponent.class); + ejb.setContext(createEjbContext()); + + return answer; +} + +private static Context createEjbContext() throws NamingException { + // here we need to define our context factory to use OpenEJB for our testing + Properties properties = new Properties(); + properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); + + return new InitialContext(properties); +} +------------------------------------------------------------------------------------------------------------------------------------------------------------- + +Then we are ready to use the EJB in the Camel route: + +[source,java] +------------------------------------------------------------------------------------------------------------------------------------------------------------- +from("direct:start") + // invoke the greeter EJB using the local interface and invoke the hello method + .to("ejb:GreaterImplLocal?method=hello") + .to("mock:result"); +------------------------------------------------------------------------------------------------------------------------------------------------------------- + +*In a real application server* + +In a real application server you most likely do not have to setup a +`JndiContext` on the link:ejb.html[EJB] component as it will create a +default `JndiContext` on the same JVM as the application server, which +usually allows it to access the JNDI registry and lookup the +link:ejb.html[EJB]s. However if you need to access a application server on a remote JVM or +the likes, you have to prepare the properties beforehand. + +[[EJB-UsingSpringXML]] +Using Spring XML +++++++++++++++++ + +And this is the same example using Spring XML instead: + +Again since this is based on an unit test we need to setup the +link:ejb.html[EJB] component: + +[source,XML] +------------------------------------------------------------------------------------------------------------------------------------------------------------- +<!-- setup Camel EJB component --> +<bean id="ejb" class="org.apache.camel.component.ejb.EjbComponent"> + <property name="properties" ref="jndiProperties"/> +</bean> + +<!-- use OpenEJB context factory --> +<p:properties id="jndiProperties"> + <prop key="java.naming.factory.initial">org.apache.openejb.client.LocalInitialContextFactory</prop> +</p:properties> +------------------------------------------------------------------------------------------------------------------------------------------------------------- + +Before we are ready to use link:ejb.html[EJB] in the Camel routes: + +[source,XML] +------------------------------------------------------------------------------------------------------------------------------------------------------------- +<camelContext xmlns="http://camel.apache.org/schema/spring"> + <route> + <from uri="direct:start"/> + <to uri="ejb:GreaterImplLocal?method=hello"/> + <to uri="mock:result"/> + </route> +</camelContext> +------------------------------------------------------------------------------------------------------------------------------------------------------------- + +[[EJB-SeeAlso]] +See Also +^^^^^^^^ + +* link:configuring-camel.html[Configuring Camel] +* link:component.html[Component] +* link:endpoint.html[Endpoint] +* link:getting-started.html[Getting Started] +* link:bean.html[Bean] +* link:bean-binding.html[Bean Binding] +* link:bean-integration.html[Bean Integration] + http://git-wip-us.apache.org/repos/asf/camel/blob/9c0b7baf/components/camel-ejb/src/main/docs/ejb.adoc ---------------------------------------------------------------------- diff --git a/components/camel-ejb/src/main/docs/ejb.adoc b/components/camel-ejb/src/main/docs/ejb.adoc deleted file mode 100644 index 4339603..0000000 --- a/components/camel-ejb/src/main/docs/ejb.adoc +++ /dev/null @@ -1,222 +0,0 @@ -[[EJB-EJBComponent]] -EJB Component -~~~~~~~~~~~~~ - -*Available as of Camel 2.4* - -The *ejb:* component binds EJBs to Camel message exchanges. - -Maven users will need to add the following dependency to their `pom.xml` -for this component: - -[source,xml] ------------------------------------------------------------- -<dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-ejb</artifactId> - <version>x.x.x</version> - <!-- use the same version as your Camel core version --> -</dependency> ------------------------------------------------------------- - -[[EJB-URIformat]] -URI format -^^^^^^^^^^ - -[source,java] ---------------------- -ejb:ejbName[?options] ---------------------- - -Where *ejbName* can be any string which is used to look up the EJB in -the Application Server JNDI link:registry.html[Registry] - -[[EJB-Options]] -Options -^^^^^^^ - - -// component options: START -The EJB component supports 2 options which are listed below. - - - -{% raw %} -[width="100%",cols="2s,1m,8",options="header"] -|======================================================================= -| Name | Java Type | Description -| context | Context | The Context to use for looking up the EJBs -| properties | Properties | Properties for creating javax.naming.Context if a context has not been configured. -|======================================================================= -{% endraw %} -// component options: END - - - -// endpoint options: START -The EJB component supports 7 endpoint options which are listed below: - -{% raw %} -[width="100%",cols="2s,1,1m,1m,5",options="header"] -|======================================================================= -| Name | Group | Default | Java Type | Description -| beanName | producer | | String | *Required* Sets the name of the bean to invoke -| method | producer | | String | Sets the name of the method to invoke on the bean -| cache | advanced | false | boolean | If enabled Camel will cache the result of the first Registry look-up. Cache can be enabled if the bean in the Registry is defined as a singleton scope. -| exchangePattern | advanced | InOnly | ExchangePattern | Sets the default exchange pattern when creating an exchange -| multiParameterArray | advanced | false | boolean | How to treat the parameters which are passed from the message body.true means the message body should be an array of parameters. Note: This option is used internally by Camel and is not intended for end users to use. -| parameters | advanced | | Map | Used for configuring additional properties on the bean -| synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). -|======================================================================= -{% endraw %} -// endpoint options: END - - -[[EJB-BeanBinding]] -Bean Binding -^^^^^^^^^^^^ - -How bean methods to be invoked are chosen (if they are not specified -explicitly through the *method* parameter) and how parameter values are -constructed from the link:message.html[Message] are all defined by the -link:bean-binding.html[Bean Binding] mechanism which is used throughout -all of the various link:bean-integration.html[Bean Integration] -mechanisms in Camel. - -[[EJB-Examples]] -Examples -^^^^^^^^ - -In the following examples we use the Greater EJB which is defined as -follows: - -*GreaterLocal.java* - -[source,java] -------------------------------------------------------------------------------------------------------------------------------------------------------------- -public interface GreaterLocal { - - String hello(String name); - - String bye(String name); - -} -------------------------------------------------------------------------------------------------------------------------------------------------------------- - -And the implementation - -*GreaterImpl.java* - -[source,java] -------------------------------------------------------------------------------------------------------------------------------------------------------------- -@Stateless -public class GreaterImpl implements GreaterLocal { - - public String hello(String name) { - return "Hello " + name; - } - - public String bye(String name) { - return "Bye " + name; - } - -} -------------------------------------------------------------------------------------------------------------------------------------------------------------- - -[[EJB-UsingJavaDSL]] -Using Java DSL -++++++++++++++ - -In this example we want to invoke the `hello` method on the EJB. Since -this example is based on an unit test using Apache OpenEJB we have to -set a `JndiContext` on the link:ejb.html[EJB] component with the OpenEJB -settings. - -[source,java] -------------------------------------------------------------------------------------------------------------------------------------------------------------- -@Override -protected CamelContext createCamelContext() throws Exception { - CamelContext answer = new DefaultCamelContext(); - - // enlist EJB component using the JndiContext - EjbComponent ejb = answer.getComponent("ejb", EjbComponent.class); - ejb.setContext(createEjbContext()); - - return answer; -} - -private static Context createEjbContext() throws NamingException { - // here we need to define our context factory to use OpenEJB for our testing - Properties properties = new Properties(); - properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); - - return new InitialContext(properties); -} -------------------------------------------------------------------------------------------------------------------------------------------------------------- - -Then we are ready to use the EJB in the Camel route: - -[source,java] -------------------------------------------------------------------------------------------------------------------------------------------------------------- -from("direct:start") - // invoke the greeter EJB using the local interface and invoke the hello method - .to("ejb:GreaterImplLocal?method=hello") - .to("mock:result"); -------------------------------------------------------------------------------------------------------------------------------------------------------------- - -*In a real application server* - -In a real application server you most likely do not have to setup a -`JndiContext` on the link:ejb.html[EJB] component as it will create a -default `JndiContext` on the same JVM as the application server, which -usually allows it to access the JNDI registry and lookup the -link:ejb.html[EJB]s. However if you need to access a application server on a remote JVM or -the likes, you have to prepare the properties beforehand. - -[[EJB-UsingSpringXML]] -Using Spring XML -++++++++++++++++ - -And this is the same example using Spring XML instead: - -Again since this is based on an unit test we need to setup the -link:ejb.html[EJB] component: - -[source,XML] -------------------------------------------------------------------------------------------------------------------------------------------------------------- -<!-- setup Camel EJB component --> -<bean id="ejb" class="org.apache.camel.component.ejb.EjbComponent"> - <property name="properties" ref="jndiProperties"/> -</bean> - -<!-- use OpenEJB context factory --> -<p:properties id="jndiProperties"> - <prop key="java.naming.factory.initial">org.apache.openejb.client.LocalInitialContextFactory</prop> -</p:properties> -------------------------------------------------------------------------------------------------------------------------------------------------------------- - -Before we are ready to use link:ejb.html[EJB] in the Camel routes: - -[source,XML] -------------------------------------------------------------------------------------------------------------------------------------------------------------- -<camelContext xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="direct:start"/> - <to uri="ejb:GreaterImplLocal?method=hello"/> - <to uri="mock:result"/> - </route> -</camelContext> -------------------------------------------------------------------------------------------------------------------------------------------------------------- - -[[EJB-SeeAlso]] -See Also -^^^^^^^^ - -* link:configuring-camel.html[Configuring Camel] -* link:component.html[Component] -* link:endpoint.html[Endpoint] -* link:getting-started.html[Getting Started] -* link:bean.html[Bean] -* link:bean-binding.html[Bean Binding] -* link:bean-integration.html[Bean Integration] -