Repository: camel Updated Branches: refs/heads/master 67053cfc6 -> d9cb3438b
Added camel-ejb docs to Gitbook Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d9cb3438 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d9cb3438 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d9cb3438 Branch: refs/heads/master Commit: d9cb3438b86812e5216506807fa8618280ac922a Parents: 67053cf Author: Andrea Cosentino <[email protected]> Authored: Thu Jun 30 13:15:08 2016 +0200 Committer: Andrea Cosentino <[email protected]> Committed: Thu Jun 30 13:15:08 2016 +0200 ---------------------------------------------------------------------- components/camel-ejb/src/main/docs/ejb.adoc | 169 +++++++++++++++++++++++ docs/user-manual/en/SUMMARY.md | 1 + 2 files changed, 170 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/d9cb3438/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 new file mode 100644 index 0000000..1cbc50b --- /dev/null +++ b/components/camel-ejb/src/main/docs/ejb.adoc @@ -0,0 +1,169 @@ +[[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. + +Then we are ready to use the EJB in the Camel route: + +*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: + +Before we are ready to use link:ejb.html[EJB] in the Camel routes: + +[[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/d9cb3438/docs/user-manual/en/SUMMARY.md ---------------------------------------------------------------------- diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md index d4a3366..931a18d 100644 --- a/docs/user-manual/en/SUMMARY.md +++ b/docs/user-manual/en/SUMMARY.md @@ -151,6 +151,7 @@ * [Dozer](dozer.adoc) * [Dropbox](dropbox.adoc) * [Eclipse](eclipse.adoc) + * [EJB](ejb.adoc) * [ElasticSearch](elasticsearch.adoc) * [Elsql](elsql.adoc) * [Eventadmin](eventadmin.adoc)
