[CONF] Apache Camel Spring Redis

2014-04-29 Thread Claus Ibsen (Confluence)














  


Claus Ibsen edited the page:
 


Spring Redis   






...
This component allows sending and receiving messages from Redis. Redis is advanced key-value store where keys can contain strings, hashes, lists, sets and sorted sets. In addition it provides pub/sub functionality for inter-app comunicationscommunications. Camel provides a producer for executing commands, consumer for subscribing to pub/sub messages an idempotent repository for filtering out duplicate messages.



 Info








title
Prerequisites


 




 In order to use this component, you must have a Redis server running. 



URI Format



 Code Block




 

spring-redis://host:port[?options]
 



...
Message headers evaluated by the Redis producer
The producer issues commads commands to the server and each command has different set of parameters with specific types. The result from the command execution is returned in the message body.
...



 Wiki Markup


   

[CONF] Apache Camel Spring Security

2014-03-11 Thread Colm O hEigeartaigh (Confluence)














  


Colm O hEigeartaigh edited the page:
 


Spring Security   






...
The process of obtaining security credentials that are used for authorization is not specified by this component. You can write your own processors or components which get authentication information from the exchange depending on your needs. For example, you might create a processor that gets credentials from an HTTP request header originating in the Jetty component. No matter how the credentials are collected, they need to be placed in the In message or the SecurityContextHolder so the Camel Spring Security component can access them:



 Code Block









java


 




 

import javax.security.auth.Subject;
import org.apache.camel.*;
import org.apache.commons.codec.binary.Base64;
import org.springframework.security.authentication.*;


public class MyAuthService implements Processor {
public void process(Exchange exchange) throws Exception {
// get the username and password from the HTTP header
// http://en.wikipedia.org/wiki/Basic_access_authentication
String userpass = new String(Base64.decodeBase64(exchange.getIn().getHeader(Authorization, String.class)));
String[] tokens = userpass.split(:);

// create an Authentication object
UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(tokens[0], tokens[1]);

// wrap it in a Subject
Subject subject = new Subject();
subject.getPrincipals().add(tokenauthToken);

// place the Subject in the In message
exchange.getIn().setHeader(Exchange.AUTHENTICATION, subject);

// you could also do this if useThreadSecurityContext is set to true
// SecurityContextHolder.getContext().setAuthentication(authToken);
}
}
 



...
If authentication or authorization fails in the SpringSecurityAuthorizationPolicy, a CamelAuthorizationException will be thrown. This can be handled using Camel's standard exception handling methods, like the Exception Clause. The CamelAuthorizationException will have a reference to the ID of the policy which threw the exception so you can handle errors based on the policy as 

[CONF] Apache Camel Spring Security Example

2013-12-16 Thread Colm O hEigeartaigh (Confluence)














  


Colm O hEigeartaigh edited the page:
 


Spring Security Example   






Spring Security Example
 This example shows you how to leverage the Spring Security already provides authentication mechanism and authoriationPolicy which is provided in The camel-spring-security module provides authentication and authorization capabilities via Spring Security. This example shows you how to use this functionality to implement a role based authorization application.
This example consumes messages from a servlet endpoint which is secured by Spring Security with http basic authentication, there are two serviceservices:



 Code Block




 
 http://localhost:8080/camel/user is for the authenticated user whose role is ROLE_USER
 http://localhost:8080/camel/admin is for the authenticated user whose role is ROLE_ADMIN
 



You will need to compile this example first:



 Code Block




 
 cd $CAMEL_HOME/examples/camel-example-spring-security
  mvn clean install
 



To run the example, you need to start up the server by typing



 Code Block




 
 mvn jetty:run
 



To stop the server hit ctrl + c
...






 View Online   Like   View Changes  
 Stop 

[CONF] Apache Camel Spring Java Config

2013-11-02 Thread Henryk Konsek (Confluence)







Spring Java Config
Page edited by Henryk Konsek


Comment:
Deprecated JavaConfigContextLoader. See CAMEL-6917.


 Changes (12)
 




...
Note that this library is totally optional; you could just wire Camel together yourself with Java Config.  
h3. Common cases 
h3. Configuration 
 The most common case of using JavaConfig with Camel would be to create configuration with defined list of routes to be used by router. 
...
{code}  
h3. Other examples 
h3. Testing 
 
The following [example using Java Config|http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java] is actually a [Spring Testing] based unit test. 
Since *Camel 2.11.0* you can use the {{CamelSpringJUnit4ClassRunner}} with {{CamelSpringDelegatingTestContextLoader}}. This is the recommended way to test Java Config and Camel integration. 
 
{snippet:lang=java|id=example|url=""> {snippet:lang=java|id=example|url=""> 
 
The *@ContextConfiguration* annotation tells the [Spring Testing] framework to load the *ContextConfig* class as the configuration to use. This class derives from *SingleRouteCamelConfiguration* which is a helper Spring Java Config class which will configure the CamelContext for us and then register the RouteBuilder we create.  
If you wish to create a collection of *RouteBuilder* instances then derive from the *CamelConfiguration* helper class and implement the *routes()* method. Keep in mind that (starting from the Camel 2.13.0) if you dont override *routes()* method, then *CamelConfiguration* will use all *RouteBuilder* instances available in the Spring context.  
Since *Camel 2.11.0* you can use the CamelSpringJUnit4ClassRunner with CamelSpringDelegatingTestContextLoader like [example using Java Config with CamelSpringJUnit4ClassRunner|http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java]. 
The following [example using Java Config|http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java] demonstrates how to test Java Config integration with Camel 2.10 and lower. Keep in mind that {{JavaConfigContextLoader}} is deprecated and could be removed in the future versions of Camel on the behalf of the {{CamelSpringDelegatingTestContextLoader}}.  
{snippet:lang=java|id=example|url=""> {snippet:lang=java|id=example|url=""> 
 The *@ContextConfiguration* annotation tells the [Spring Testing] framework to load the *ContextConfig* class as the configuration to use. This class derives from *SingleRouteCamelConfiguration* which is a helper Spring Java Config class which will configure the CamelContext for us and then register the RouteBuilder we create. 


Full Content

Spring Java Config

Spring started life using XML Config to wire beans together. However some folks don't like using XML and would rather use Java code which led to the creation of Guice along with the Spring JavaConfig project.

You can use either the XML or Java config approachs with Camel; its your choice really on which you prefer.

NOTE: From Camel 2.2.0 camel-spring-javaconfig is moved to Spring 3.x, which means you can't run it with spring 2.x.

Using Spring Java Config

To use Spring Java Config in your Camel project the easiest thing to do is add the following to your pom.xml



dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring-javaconfig/artifactId
  version${camel-version}/version
/dependency



This will then add the dependencies on the Spring JavaConfig library along with some helper classes for configuring Camel inside Spring.

Note that this library is totally optional; you could just wire Camel together yourself with Java Config.

Configuration

The most common case of using JavaConfig with Camel would be to create configuration with defined list of routes to be used by router.



@Configuration
public class MyRouteConfiguration extends CamelConfiguration {

@Autowire
private MyRouteBuilder myRouteBuilder;

@Autowire
private MyAnotherRouteBuilder myAnotherRouteBuilder;

@Override
public ListRouteBuilder routes() {
return Arrays.asList(myRouteBuilder, myAnotherRouteBuilder);
} 

}



Starting from Camel 2.13.0 you can skip the routes() definition, and fall back to the RouteBuilder instances located in the Spring context.




[CONF] Apache Camel Spring Java Config

2013-10-25 Thread Henryk Konsek (Confluence)







Spring Java Config
Page edited by Henryk Konsek


Comment:
Updated RouteBuilder autodetection information.


 Changes (1)
 




...
The *@ContextConfiguration* annotation tells the [Spring Testing] framework to load the *ContextConfig* class as the configuration to use. This class derives from *SingleRouteCamelConfiguration* which is a helper Spring Java Config class which will configure the CamelContext for us and then register the RouteBuilder we create.  
If you wish to create a collection of *RouteBuilder* instances then derive from the *CamelConfiguration* helper class and implement the *routes()* method. Keep in mind that starting from the Camel 2.13.0 if you dont override *routes()* method, then *CamelConfiguration* will use all *RouteBuilder* instances available in the Spring context. 
 Since *Camel 2.11.0* you can use the CamelSpringJUnit4ClassRunner with CamelSpringDelegatingTestContextLoader like [example using Java Config with CamelSpringJUnit4ClassRunner|http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java]. 
...


Full Content

Spring Java Config

Spring started life using XML Config to wire beans together. However some folks don't like using XML and would rather use Java code which led to the creation of Guice along with the Spring JavaConfig project.

You can use either the XML or Java config approachs with Camel; its your choice really on which you prefer.

NOTE: From Camel 2.2.0 camel-spring-javaconfig is moved to Spring 3.x, which means you can't run it with spring 2.x.

Using Spring Java Config

To use Spring Java Config in your Camel project the easiest thing to do is add the following to your pom.xml



dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring-javaconfig/artifactId
  version${camel-version}/version
/dependency



This will then add the dependencies on the Spring JavaConfig library along with some helper classes for configuring Camel inside Spring.

Note that this library is totally optional; you could just wire Camel together yourself with Java Config.

Example

The following example using Java Config is actually a Spring Testing based unit test.





The @ContextConfiguration annotation tells the Spring Testing framework to load the ContextConfig class as the configuration to use. This class derives from SingleRouteCamelConfiguration which is a helper Spring Java Config class which will configure the CamelContext for us and then register the RouteBuilder we create.

If you wish to create a collection of RouteBuilder instances then derive from the CamelConfiguration helper class and implement the routes() method. Keep in mind that starting from the Camel 2.13.0 if you don't override routes() method, then CamelConfiguration will use all RouteBuilder instances available in the Spring context.

Since Camel 2.11.0 you can use the CamelSpringJUnit4ClassRunner with CamelSpringDelegatingTestContextLoader like example using Java Config with CamelSpringJUnit4ClassRunner.


.



Stop watching space
|
Change email notification preferences

View Online
|
View Changes









[CONF] Apache Camel Spring Java Config

2013-10-25 Thread Henryk Konsek (Confluence)







Spring Java Config
Page edited by Henryk Konsek


 Changes (1)
 




...
The *@ContextConfiguration* annotation tells the [Spring Testing] framework to load the *ContextConfig* class as the configuration to use. This class derives from *SingleRouteCamelConfiguration* which is a helper Spring Java Config class which will configure the CamelContext for us and then register the RouteBuilder we create.  
If you wish to create a collection of *RouteBuilder* instances then derive from the *CamelConfiguration* helper class and implement the *routes()* method. Keep in mind that (starting from the Camel 2.13.0) if you dont override *routes()* method, then *CamelConfiguration* will use all *RouteBuilder* instances available in the Spring context. 
 Since *Camel 2.11.0* you can use the CamelSpringJUnit4ClassRunner with CamelSpringDelegatingTestContextLoader like [example using Java Config with CamelSpringJUnit4ClassRunner|http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java]. 
...


Full Content

Spring Java Config

Spring started life using XML Config to wire beans together. However some folks don't like using XML and would rather use Java code which led to the creation of Guice along with the Spring JavaConfig project.

You can use either the XML or Java config approachs with Camel; its your choice really on which you prefer.

NOTE: From Camel 2.2.0 camel-spring-javaconfig is moved to Spring 3.x, which means you can't run it with spring 2.x.

Using Spring Java Config

To use Spring Java Config in your Camel project the easiest thing to do is add the following to your pom.xml



dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring-javaconfig/artifactId
  version${camel-version}/version
/dependency



This will then add the dependencies on the Spring JavaConfig library along with some helper classes for configuring Camel inside Spring.

Note that this library is totally optional; you could just wire Camel together yourself with Java Config.

Example

The following example using Java Config is actually a Spring Testing based unit test.





The @ContextConfiguration annotation tells the Spring Testing framework to load the ContextConfig class as the configuration to use. This class derives from SingleRouteCamelConfiguration which is a helper Spring Java Config class which will configure the CamelContext for us and then register the RouteBuilder we create.

If you wish to create a collection of RouteBuilder instances then derive from the CamelConfiguration helper class and implement the routes() method. Keep in mind that (starting from the Camel 2.13.0) if you don't override routes() method, then CamelConfiguration will use all RouteBuilder instances available in the Spring context.

Since Camel 2.11.0 you can use the CamelSpringJUnit4ClassRunner with CamelSpringDelegatingTestContextLoader like example using Java Config with CamelSpringJUnit4ClassRunner.


.



Stop watching space
|
Change email notification preferences

View Online
|
View Changes









[CONF] Apache Camel Spring Java Config

2013-10-25 Thread Henryk Konsek (Confluence)







Spring Java Config
Page edited by Henryk Konsek


Comment:
Extended documentation with common use cases.


 Changes (3)
 




...
Note that this library is totally optional; you could just wire Camel together yourself with Java Config.  
h3. Example 
h3. Common cases 
 
The most common case of using JavaConfig with Camel would be to create configuration with defined list of routes to be used by router.  {code:java} @Configuration public class MyRouteConfiguration extends CamelConfiguration {  @Autowire private MyRouteBuilder myRouteBuilder;  @Autowire private MyAnotherRouteBuilder myAnotherRouteBuilder;  @Override public ListRouteBuilder routes() { return Arrays.asList(myRouteBuilder, myAnotherRouteBuilder); }   } {code}  Starting from Camel 2.13.0 you can skip the *routes()* definition, and fall back to the *RouteBuilder* instances located in the Spring context.  {code:java} @Configuration @ComponentScan(com.example.routes) public class MyRouteConfiguration extends CamelConfiguration { } {code}  h3. Other examples  
The following [example using Java Config|http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java] is actually a [Spring Testing] based unit test.  
...


Full Content

Spring Java Config

Spring started life using XML Config to wire beans together. However some folks don't like using XML and would rather use Java code which led to the creation of Guice along with the Spring JavaConfig project.

You can use either the XML or Java config approachs with Camel; its your choice really on which you prefer.

NOTE: From Camel 2.2.0 camel-spring-javaconfig is moved to Spring 3.x, which means you can't run it with spring 2.x.

Using Spring Java Config

To use Spring Java Config in your Camel project the easiest thing to do is add the following to your pom.xml



dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring-javaconfig/artifactId
  version${camel-version}/version
/dependency



This will then add the dependencies on the Spring JavaConfig library along with some helper classes for configuring Camel inside Spring.

Note that this library is totally optional; you could just wire Camel together yourself with Java Config.

Common cases

The most common case of using JavaConfig with Camel would be to create configuration with defined list of routes to be used by router.



@Configuration
public class MyRouteConfiguration extends CamelConfiguration {

@Autowire
private MyRouteBuilder myRouteBuilder;

@Autowire
private MyAnotherRouteBuilder myAnotherRouteBuilder;

@Override
public ListRouteBuilder routes() {
return Arrays.asList(myRouteBuilder, myAnotherRouteBuilder);
} 

}



Starting from Camel 2.13.0 you can skip the routes() definition, and fall back to the RouteBuilder instances located in the Spring context.



@Configuration
@ComponentScan("com.example.routes")
public class MyRouteConfiguration extends CamelConfiguration {
}



Other examples

The following example using Java Config is actually a Spring Testing based unit test.





The @ContextConfiguration annotation tells the Spring Testing framework to load the ContextConfig class as the configuration to use. This class derives from SingleRouteCamelConfiguration which is a helper Spring Java Config class which will configure the CamelContext for us and then register the RouteBuilder we create.

If you wish to create a collection of RouteBuilder instances then derive from the CamelConfiguration helper class and implement the routes() method. Keep in mind that (starting from the Camel 2.13.0) if you don't override routes() method, then CamelConfiguration will use all RouteBuilder instances available in the Spring context.

Since Camel 2.11.0 you can use the CamelSpringJUnit4ClassRunner with CamelSpringDelegatingTestContextLoader like example using Java Config with CamelSpringJUnit4ClassRunner.


.



Stop watching space
|
Change email notification preferences

View Online
|
View Changes









[CONF] Apache Camel Spring Event

2013-09-17 Thread Christian Posta (Confluence)







Spring Event
Page edited by Christian Posta


 Changes (3)
 




...
 {code} 
spring-event://default 
spring-event://default[?options] 
{code}  
Note, at the moment there are no options for this component. That can easily change in future releases, so please check back. 
{include:Endpoint See Also} 


Full Content

Spring Event Component

The spring-event: component provides access to the Spring ApplicationEvent objects. This allows you to publish ApplicationEvent objects to a Spring ApplicationContext or to consume them. You can then use Enterprise Integration Patterns to process them such as Message Filter.

URI format



spring-event://default[?options]



Note, at the moment there are no options for this component. That can easily change in future releases, so please check back.
See Also

	Configuring Camel
	Component
	Endpoint
	Getting Started





Stop watching space
|
Change email notification preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Spring Event

2013-09-11 Thread Claus Ibsen (Confluence)







Spring Event
Page edited by Claus Ibsen


 Changes (2)
 




h2. Spring Event Component 
 
The *spring-event:* component provides access to the Spring {{ApplicationEvent}} objects. This allows you to publish {{ApplicationEvent}} objects to a Spring {{ApplicationContext}} or to consume them. You can then use [Enterprise Integration Patterns] to process them such as [Message Filter]. 
 h3. URI format 
...


Full Content

Spring Event Component

The spring-event: component provides access to the Spring ApplicationEvent objects. This allows you to publish ApplicationEvent objects to a Spring ApplicationContext or to consume them. You can then use Enterprise Integration Patterns to process them such as Message Filter.

URI format



spring-event://default



See Also

	Configuring Camel
	Component
	Endpoint
	Getting Started





Stop watching space
|
Change email notification preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Spring LDAP

2013-06-20 Thread confluence







Spring LDAP
Page moved by Claus Ibsen






From: 

Apache Camel
 Component List


To: 

Apache Camel
 Components





Children moved






   
Change Notification Preferences
   
   View Online
  |
   Add Comment
   









[CONF] Apache Camel Spring Security Example

2013-05-15 Thread confluence







Spring Security Example
Page edited by Babak Vahdat


 Changes (1)
 




...
{code}  http://localhost:8080/camel/user is for the authenticated user whose role is ROLE_USER 
http://localhost:8080/camel/admimn is for the authenticated user whose role is ROLE_ADMIN 
{code}  
...


Full Content

Spring Security Example

This example shows you how to leverage the Spring Security already provides authentication mechanism and authoriationPolicy which is provided in camel-spring-security module to implement a role based authorization application. 

This example consumes messages from a servlet endpoint which is secured by Spring Security with http basic authentication, there are two service:


 "http://localhost:8080/camel/user" is for the authenticated user whose role is ROLE_USER
 "http://localhost:8080/camel/admin" is for the authenticated user whose role is ROLE_ADMIN



You will need to compile this example first:


  cd $CAMEL_HOME/examples/camel-example-spring-security
  mvn clean install



To run the example, you need to start up the server by typing


  mvn jetty:run


To stop the server hit ctrl + c

Then you can use the script in the client directory to send the request and check the response, or use browser to access upper service with the user/password ("jim/jimspassword" with the admin and user role  or "rob/robspassword" with user role).

Here is the camel route configuration:


beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:spring-security="http://www.springframework.org/schema/security"
   xsi:schemaLocation="
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
 http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
 http://camel.apache.org/schema/spring-security http://camel.apache.org/schema/spring-security/camel-spring-security.xsd
 http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"

  spring-security:http realm="User Restrict Realm"
spring-security:intercept-url pattern="/camel/**" access="ROLE_USER"/
spring-security:http-basic/
spring-security:remember-me/
  /spring-security:http

!--  set up the user configuration here --
  spring-security:authentication-manager alias="authenticationManager"
spring-security:authentication-provider user-service-ref="userDetailsService"/
  /spring-security:authentication-manager

  spring-security:user-service id="userDetailsService"
spring-security:user name="jim" password="jimspassword" authorities="ROLE_USER, ROLE_ADMIN"/
spring-security:user name="bob" password="bobspassword" authorities="ROLE_USER"/
  /spring-security:user-service

  bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased"
property name="allowIfAllAbstainDecisions" value="true"/
property name="decisionVoters"
  list
bean class="org.springframework.security.access.vote.RoleVoter"/
  /list
/property
  /bean

  !-- The Policy for checking the authentication role of ADMIN --
  authorizationPolicy id="admin" access="ROLE_ADMIN"
   authenticationManager="authenticationManager"
   accessDecisionManager="accessDecisionManager"
   xmlns="http://camel.apache.org/schema/spring-security"/

  !-- The Policy for checking the authentication role of USER --
  authorizationPolicy id="user" access="ROLE_USER"
   xmlns="http://camel.apache.org/schema/spring-security"/

  camelContext id="myCamelContext" xmlns="http://camel.apache.org/schema/spring"
!-- Catch the authorization exception and set the Access Denied message back --
onException
  exceptionorg.apache.camel.CamelAuthorizationException/exception
  handled
constanttrue/constant
  /handled
  transform
simpleAccess Denied with the Policy of ${exception.policyId} !/simple
  /transform
/onException

route
  from uri="servlet:///user"/
  !-- wrap the route in the policy which enforces security check --
  policy ref="user"
transform
  simpleNormal user can access this service/simple
/transform
  /policy
/route

route
  from uri="servlet:///admin"/
  !-- wrap the route in the policy which enforces security check --
  policy ref="admin"
transform
  simpleCall the admin operation OK/simple
/transform
  /policy
/route

  /camelContext

/beans



You can find how to configure the camel-servlet with http basic 

[CONF] Apache Camel Spring Web Services

2013-05-09 Thread confluence







Spring Web Services
Page edited by Babak Vahdat


 Changes (3)
 




...
| {{wsAddressingAction}} | No | WS-Addressing 1.0 action header to include when accessing web services. The {{To}} header is set to the _address_ of the web service as specified in the endpoint URI (default Spring-WS behavior). | | {{_expression_}} | Only when _mapping-type_ is {{xpathresult}} | XPath _expression_ to use in the process of mapping web service requests, should match the result specified by {{xpathresult}} | 
*Camel 2.12:*nbsp;The built-in message sendernbsp;_HttpComponentsMessageSender_nbsp;is considered *instead of*nbsp;_CommonsHttpMessageSender_nbsp;which has been deprecated, see [HttpComponentsMessageSender.setReadTimeout()|http://static.springsource.org/spring-ws/site/apidocs/org/springframework/ws/transport/http/HttpComponentsMessageSender.html#setReadTimeout(int)]. | 
| {{timeout}} | No | *Camel 2.10:* Sets the socket read timeout (in milliseconds) while invoking a webservice using the producer, see [URLConnection.setReadTimeout()|http://docs.oracle.com/javase/6/docs/api/java/net/URLConnection.html#setReadTimeout(int)] and [CommonsHttpMessageSender.setReadTimeout()|http://static.springsource.org/spring-ws/site/apidocs/org/springframework/ws/transport/http/CommonsHttpMessageSender.html#setReadTimeout(int)]. nbsp;This option works when using the built-in message sender implementations:nbsp;_CommonsHttpMessageSender_nbsp;andnbsp;_HttpUrlConnectionMessageSender_. nbsp;One of these implementations will be used by default for HTTP based services unless you customize the Spring WS configuration options supplied to the component. nbsp;If you are using a non-standard sender, it is assumed that you will handle your own timeout configuration.\\
| {{sslContextParameters}} | No | *Camel 2.10:*nbsp;Reference to annbsp;{{org.apache.camel.util.jsse.SSLContextParameters}} innbsp;thenbsp;[Registry|http://camel.apache.org/registry.html]. nbsp;Seenbsp;[Using the JSSE Configuration Utility|http://camel.apache.org/http4.html#HTTP4-UsingtheJSSEConfigurationUtility]. nbsp;This option works when using the built-in message sender implementations:nbsp;_CommonsHttpMessageSender_nbsp;andnbsp;_HttpUrlConnectionMessageSender_. nbsp;One of these implementations will be used by default for HTTP based services unless you customize the Spring WS configuration options supplied to the component. nbsp;If you are using a non-standard sender, it is assumed that you will handle your own TLS configuration.\\ 
*Camel 2.12:*nbsp;The built-in message sendernbsp;_HttpComponentsMessageSender_nbsp;is considered *instead of*nbsp;_CommonsHttpMessageSender_nbsp;which has been deprecated. | 
{div}  
...
Spring configuration: {code:xml}!-- authenticate using HTTP Basic Authentication -- 
bean id=messageSender class=org.springframework.ws.transport.http.CommonsHttpMessageSender class=org.springframework.ws.transport.http.HttpComponentsMessageSender 
	property name=credentials 		bean class=org.apache.commons.httpclient.UsernamePasswordCredentials 
...


Full Content

Spring Web Services Component

Available as of Camel 2.6

The spring-ws: component allows you to integrate with Spring Web Services. It offers both clientside support, for accessing web services, and serverside support for creating your own contract-first web services.

Maven users will need to add the following dependency to their pom.xml for this component:



dependency
	groupIdorg.apache.camel/groupId
	artifactIdcamel-spring-ws/artifactId
	versionx.x.x/version
	!-- use the same version as your Camel core version --
/dependency



DependenciesAs of Camel 2.8 this component ships with Spring-WS 2.0.x which (like the rest of Camel) requires Spring 3.0.x.

Earlier Camel versions shipped Spring-WS 1.5.9 which is compatible with Spring 2.5.x and 3.0.x. In order to run earlier versions of camel-spring-ws on Spring 2.5.x you need to add the spring-webmvc module from Spring 2.5.x. In order to run Spring-WS 1.5.9 on Spring 3.0.x you need to exclude the OXM module from Spring 3.0.x as this module is also included in Spring-WS 1.5.9 (see this post)

URI format

The URI scheme for this component is as follows



spring-ws:[mapping-type:]address[?options]



To expose a web service mapping-type needs to be set to any of the following:




 Mapping type 
 Description 


 rootqname 
 Offers the option to map web service requests based on the qualified name of the root element contained in the message. 


 soapaction 
 Used to map web service requests based on the SOAP action specified in the header of the message. 


 uri 
 In order to map web service requests that target a specific URI. 


 

[CONF] Apache Camel Spring Web Services

2013-04-27 Thread confluence







Spring Web Services
Page edited by Claus Ibsen


 Changes (2)
 




...
| {{CamelSpringWebserviceSoapAction}} | String | Header to specify the SOAP action of the message, overrides {{soapAction}} option if present | | {{CamelSpringWebserviceAddressingAction}} | URI | Use this header to specify the WS-Addressing action of the message, overrides {{wsAddressingAction}} option if present | 
| {{CamelSpringWebserviceSoapHeader}} | Source | *Camel 2.11.1:* Use this header to specify/access the SOAP headers of the message. | 
{div}  
...
{code}  
 h3. Using SOAP headers *Available as of Camel 2.11.1*  You can provide the SOAP header(s) as a Camel Message header when sending a message to a spring-ws endpoint, for example given the following SOAP header in a String {code} String body = ... String soapHeader = h:Header xmlns:h=\http://www.webserviceX.NET/\h:MessageID1234567890/h:MessageIDh:Nestedh:NestedID/h:NestedID/h:Nested/h:Header; {code}  We can set the body and header on the Camel Message as follows: {code} exchange.getIn().setBody(body); exchange.getIn().setHeader(SpringWebserviceConstants.SPRING_WS_SOAP_HEADER, soapHeader); {code}  And then send the Exchange to a {{spring-ws}} endpoint to call the Web Service.  Likewise the spring-ws consumer will also enrich the Camel Message with the SOAP header.  For an example see this [unit test|https://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/SoapHeaderTest.java].   
h3. The header and attachment propagation Spring WS Camel supports propagation of the headers and attachments into Spring-WS WebServiceMessage response since version *2.10.3*. 
...


Full Content

Spring Web Services Component

Available as of Camel 2.6

The spring-ws: component allows you to integrate with Spring Web Services. It offers both clientside support, for accessing web services, and serverside support for creating your own contract-first web services.

Maven users will need to add the following dependency to their pom.xml for this component:



dependency
	groupIdorg.apache.camel/groupId
	artifactIdcamel-spring-ws/artifactId
	versionx.x.x/version
	!-- use the same version as your Camel core version --
/dependency



DependenciesAs of Camel 2.8 this component ships with Spring-WS 2.0.x which (like the rest of Camel) requires Spring 3.0.x.

Earlier Camel versions shipped Spring-WS 1.5.9 which is compatible with Spring 2.5.x and 3.0.x. In order to run earlier versions of camel-spring-ws on Spring 2.5.x you need to add the spring-webmvc module from Spring 2.5.x. In order to run Spring-WS 1.5.9 on Spring 3.0.x you need to exclude the OXM module from Spring 3.0.x as this module is also included in Spring-WS 1.5.9 (see this post)

URI format

The URI scheme for this component is as follows



spring-ws:[mapping-type:]address[?options]



To expose a web service mapping-type needs to be set to any of the following:




 Mapping type 
 Description 


 rootqname 
 Offers the option to map web service requests based on the qualified name of the root element contained in the message. 


 soapaction 
 Used to map web service requests based on the SOAP action specified in the header of the message. 


 uri 
 In order to map web service requests that target a specific URI. 


 xpathresult 
 Used to map web service requests based on the evaluation of an XPath _expression_ against the incoming message. The result of the evaluation should match the XPath result specified in the endpoint URI. 


 beanname 
 Allows you to reference an org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher object in order to integrate with existing (legacy) endpoint mappings like PayloadRootQNameEndpointMapping, SoapActionEndpointMapping, etc 





As a consumer the address should contain a value relevant to the specified mapping-type (e.g. a SOAP action, XPath _expression_). As a producer the address should be set to the URI of the web service your calling upon.

You can append query options to the URI in the following format, ?option=valueoption=value...

Options




 Name 
 Required? 
 Description 


 soapAction 
 No 
 SOAP action to include inside a SOAP request when accessing remote web services 


 wsAddressingAction 
 No 
 WS-Addressing 1.0 action header to include when accessing web services. The To header is set to the address of the web service as specified in the endpoint URI (default Spring-WS behavior). 


 _expression_ 
 Only when mapping-type is xpathresult 
 XPath _expression_ to use in the process of mapping web service requests, should match the result specified by xpathresult 


 timeout 
 No 
 Camel 2.10: Sets the socket 

[CONF] Apache Camel Spring Neo4j

2013-03-29 Thread confluence







Spring Neo4j
Page  added by Christian Mueller

 

 Spring Neo4j Component

Available as of Camel Extra 2.11

The camel-spring-neo4j library is provided by the Camel Extra project which hosts *GPL related components for Camel.

The neo4j: component allows you to treat Neo4j as a camel producer endpoint. This means you can use this component in to() calls but not from() calls. This component is backed by the Spring Data Neo4j Library.


	As a producer, can create or remove nodes, and create or remove relationships.
	Can support as many endpoints as required, eg for multiple databases across multiple instances.
	Headers set for node id (for created nodes), relationship id (for created relationships)



Maven users will need to add the following dependency to their pom.xml for this component:



dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-spring-neo4j/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



spring-neo4j:http://hostname[:port]/database?options



Where the URL is the location of the of running neo4j rest server.

Headers

The following headers are set on exchanges during message transport.



 Property 
 Value 


 Neo4jOperation 
 One of the Neo4jOperation enum values `CREATE_NODE, REMOVE_NODE, CREATE_RELATIONSHIP, REMOVE_RELATIONSHIP` which determines which action to perform 


 Neo4jNodeId 
 the id of the created node 


 Neo4jRelationshipId 
 the id of the created relationship 





The producer will set the headers for downstream processors once the operation has taken place. Any ID headers set prior to the producer are ignored.

Operations

The neo4j component looks for the Neo4jOperation header to determine what kind of entity to create, which is one of the following enum types

`CREATE_NODE, REMOVE_NODE, CREATE_RELATIONSHIP,	REMOVE_RELATIONSHIP`

The body of the message is used to determine the node or relationship to manipulate. The following body types are supported:

For CREATE_NODE:


	null body - create default node
	Map body - create node with the properties set from the map



For REMOVE_NODE:


	Long or Integer - remove node using the body as the id
	neo4j Node instance - remove the node specified by that instance



For CREATE_RELATIONSHIP:


	SpringDataRelationship - create relationship specified by any @NodeEntity annoted Spring entities.
	org.apache.camel.component.neo4j.BasicRelationship - create relationship specified by the neo4j node types



For REMOVE_RELATIONSHIP:


	Long or Integer - remove relationship using the body as the id
	SpringDataRelationship - remove relationship specified by the @NodeEntity annoted Spring entities.
	org.apache.camel.component.neo4j.BasicRelationship - remove relationship specified by the neo4j node types



Samples

If you wanted to insert a new empty node every 1 seconds



from("timer://foo?period=1000").to("spring-neo4j:http://localhost:7474/data")



If you wanted to delete a specific node specified by a filename, eg a file of 100 would delete node 100.



from("file:/var/data").process(new Processor() {
	@Override
	public void process(Exchange exchange) throws Exception {
		exchange.getIn().setBody(exchange.getIn().getHeader("CamelFileName"));
	}
}).to("spring-neo4j:http://localhost:7474/data")




   
Change Notification Preferences
   
   View Online
  |
   Add Comment
   








[CONF] Apache Camel Spring

2013-03-28 Thread confluence







Spring
Page edited by Claus Ibsen


 Changes (2)
 




...
  
{include:how do i import routes from other xml files}   
h4. Test time exclusion.   
...
* [Xml Reference] * [Advanced configuration of CamelContext using Spring] 
* [How do i import routes from other xml files] 


Full Content

Spring Support

Apache Camel is designed to work nicely with the Spring Framework in a number of ways.

	Camel uses Spring Transactions as the default transaction handling in components like JMS and JPA
	Camel works with Spring 2 XML processing with the Xml Configuration
	Camel Spring XML Schema's is defined at Xml Reference
	Camel supports a powerful version of Spring Remoting which can use powerful routing between the client and server side along with using all of the available Components for the transport
	Camel provides powerful Bean Integration with any bean defined in a Spring ApplicationContext
	Camel integrates with various Spring helper classes; such as providing Type Converter support for Spring Resources etc
	Allows Spring to dependency inject Component instances or the CamelContext instance itself and auto-expose Spring beans as components and endpoints.
	Allows you to reuse the Spring Testing framework to simplify your unit and integration testing using Enterprise Integration Patterns and Camel's powerful Mock and Test endpoints



Using Spring to configure the CamelContext

You can configure a CamelContext inside any spring.xml using the CamelContextFactoryBean. This will automatically start the CamelContext along with any referenced Routes along any referenced Component and Endpoint instances.


	Adding Camel schema
	Configure Routes in two ways:
	
		Using Java Code
		Using Spring XML
	
	



Adding Camel Schema
For Camel 1.x you need to use the following namespace:


http://activemq.apache.org/camel/schema/spring


with the following schema location:


http://activemq.apache.org/camel/schema/spring/camel-spring.xsd


You need to add Camel to the schemaLocation declaration


http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd



So the XML file looks like this:


beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"



Using camel: namespace
Or you can refer to camel XSD in the XML declaration:


xmlns:camel="http://camel.apache.org/schema/spring"


... so the declaration is:

beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:camel="http://camel.apache.org/schema/spring"
   xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"


... and then use the camel: namespace prefix, and you can omit the inline namespace declaration:

camel:camelContext id="camel5"
  camel:packageorg.apache.camel.spring.example/camel:package
/camel:camelContext



Advanced configuration using Spring
See more details at Advanced configuration of CamelContext using Spring

Using Java Code

You can use Java Code to define your RouteBuilder implementations. These can be defined as beans in spring and then referenced in your camel context e.g.

  camelContext id="camel5" xmlns="http://camel.apache.org/schema/spring"
routeBuilder ref="myBuilder" /
  /camelContext
  
  bean id="myBuilder" class="org.apache.camel.spring.example.test1.MyRouteBuilder"/
  
/beans



Using package
Camel also provides a powerful feature that allows for the automatic discovery and initialization of routes in given packages. This is configured by adding tags to the camel context in your spring context definition, specifying the packages to be recursively searched for RouteBuilder implementations. To use this feature in 1.X, requires a package/package tag specifying a comma separated list of packages that should be searched e.g.


  camelContext xmlns="http://camel.apache.org/schema/spring"
packageorg.apache.camel.spring.config.scan.route/package
  /camelContext



Use caution when specifying the package name as org.apache.camel or a sub package of this. This causes Camel to search in its own packages for your routes which could cause problems.

Will ignore already instantiated classesThe package and packageScan will skip any classes which has already been 

[CONF] Apache Camel Spring Neo4j

2013-03-28 Thread confluence







 Spring Neo4j
 Page removed by Christian Mueller

 
 
 Camel Spring Neo4j component

Available as of Camel 2.11

The neo4j: component allows you to treat Neo4j as a camel producer endpoint. This means you can use this component in to() calls but not from() calls. This component is backed by the Spring Data Neo4j Library.


	As a producer, can create or remove nodes, and create or remove relationships.
	Can support as many endpoints as required, eg for multiple databases across multiple instances.
	Headers set for node id (for created nodes), relationship id (for created relationships)



Maven users will need to add the following dependency to their pom.xml for this component:



dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-spring-neo4j/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



spring-neo4j:http://hostname[:port]/database?options



Where the URL is the location of the of running neo4j rest server.

Headers

The following headers are set on exchanges during message transport.



 Property 
 Value 


 Neo4jOperation 
 One of the Neo4jOperation enum values `CREATE_NODE, REMOVE_NODE, CREATE_RELATIONSHIP, REMOVE_RELATIONSHIP` which determines which action to perform 


 Neo4jNodeId 
 the id of the created node 


 Neo4jRelationshipId 
 the id of the created relationship 





The producer will set the headers for downstream processors once the operation has taken place. Any ID headers set prior to the producer are ignored.

Operations

The neo4j component looks for the Neo4jOperation header to determine what kind of entity to create, which is one of the following enum types

`CREATE_NODE, REMOVE_NODE, CREATE_RELATIONSHIP,	REMOVE_RELATIONSHIP`

The body of the message is used to determine the node or relationship to manipulate. The following body types are supported:

For CREATE_NODE:


	null body - create default node
	Map body - create node with the properties set from the map



For REMOVE_NODE:


	Long or Integer - remove node using the body as the id
	neo4j Node instance - remove the node specified by that instance



For CREATE_RELATIONSHIP:


	SpringDataRelationship - create relationship specified by any @NodeEntity annoted Spring entities.
	org.apache.camel.component.neo4j.BasicRelationship - create relationship specified by the neo4j node types



For REMOVE_RELATIONSHIP:


	Long or Integer - remove relationship using the body as the id
	SpringDataRelationship - remove relationship specified by the @NodeEntity annoted Spring entities.
	org.apache.camel.component.neo4j.BasicRelationship - remove relationship specified by the neo4j node types



Samples

If you wanted to insert a new empty node every 1 seconds



from("timer://foo?period=1000").to("spring-neo4j:http://localhost:7474/data")



If you wanted to delete a specific node specified by a filename, eg a file of 100 would delete node 100.



from("file:/var/data").process(new Processor() {
	@Override
	public void process(Exchange exchange) throws Exception {
		exchange.getIn().setBody(exchange.getIn().getHeader("CamelFileName"));
	}
}).to("spring-neo4j:http://localhost:7474/data")


 








[CONF] Apache Camel Spring Java Config

2013-03-14 Thread confluence







Spring Java Config
Page edited by willem jiang


 Changes (1)
 




...
 If you wish to create a collection of *RouteBuilder* instances then derive from the *CamelConfiguration* helper class and implement the *routes()* method. 
 Since *Camel 2.11.0* you can use the CamelSpringJUnit4ClassRunner with CamelSpringDelegatingTestContextLoader like [example using Java Config with CamelSpringJUnit4ClassRunner|http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java]. {snippet:lang=java|id=example|url="" 


Full Content

Spring Java Config

Spring started life using XML Config to wire beans together. However some folks don't like using XML and would rather use Java code which led to the creation of Guice along with the Spring JavaConfig project.

You can use either the XML or Java config approachs with Camel; its your choice really on which you prefer.

NOTE: From Camel 2.2.0 camel-spring-javaconfig is moved to Spring 3.x, which means you can't run it with spring 2.x.

Using Spring Java Config

To use Spring Java Config in your Camel project the easiest thing to do is add the following to your pom.xml



dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring-javaconfig/artifactId
  version${camel-version}/version
/dependency



This will then add the dependencies on the Spring JavaConfig library along with some helper classes for configuring Camel inside Spring.

Note that this library is totally optional; you could just wire Camel together yourself with Java Config.

Example

The following example using Java Config is actually a Spring Testing based unit test.


@ContextConfiguration(
locations = "org.apache.camel.spring.javaconfig.patterns.FilterTest$ContextConfig",
loader = JavaConfigContextLoader.class)
public class FilterTest extends AbstractJUnit4SpringContextTests {

@EndpointInject(uri = "mock:result")
protected MockEndpoint resultEndpoint;

@Produce(uri = "direct:start")
protected ProducerTemplate template;

@DirtiesContext
@Test
public void testSendMatchingMessage() throws Exception {
String expectedBody = "matched/";

resultEndpoint.expectedBodiesReceived(expectedBody);

template.sendBodyAndHeader(expectedBody, "foo", "bar");

resultEndpoint.assertIsSatisfied();
}

@DirtiesContext
@Test
public void testSendNotMatchingMessage() throws Exception {
resultEndpoint.expectedMessageCount(0);

template.sendBodyAndHeader("notMatched/", "foo", "notMatchedHeaderValue");

resultEndpoint.assertIsSatisfied();
}

@Configuration
public static class ContextConfig extends SingleRouteCamelConfiguration {
@Bean
public RouteBuilder route() {
return new RouteBuilder() {
public void configure() {
from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
}
};
}
}
}



The @ContextConfiguration annotation tells the Spring Testing framework to load the ContextConfig class as the configuration to use. This class derives from SingleRouteCamelConfiguration which is a helper Spring Java Config class which will configure the CamelContext for us and then register the RouteBuilder we create.

If you wish to create a collection of RouteBuilder instances then derive from the CamelConfiguration helper class and implement the routes() method.

Since Camel 2.11.0 you can use the CamelSpringJUnit4ClassRunner with CamelSpringDelegatingTestContextLoader like example using Java Config with CamelSpringJUnit4ClassRunner.

@RunWith(CamelSpringJUnit4ClassRunner.class)
@ContextConfiguration(
classes = {CamelSpringDelegatingTestContextLoaderTest.TestConfig.class},
// Since Camel 2.11.0 
loader = CamelSpringDelegatingTestContextLoader.class
)
@MockEndpoints
public class CamelSpringDelegatingTestContextLoaderTest {
@EndpointInject(uri = "mock:direct:end")
protected MockEndpoint endEndpoint;

@EndpointInject(uri = "mock:direct:error")
protected MockEndpoint errorEndpoint;

@Produce(uri = "direct:test")
protected ProducerTemplate testProducer;

@Configuration
public static class TestConfig extends SingleRouteCamelConfiguration {
@Bean
@Override
public RouteBuilder route() {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:test").errorHandler(deadLetterChannel("direct:error")).to("direct:end");

from("direct:error").log("Received 

[CONF] Apache Camel Spring Redis

2013-03-12 Thread confluence







Spring Redis
Page edited by Claus Ibsen


 Changes (0)
 




...


Full Content

Spring Redis Component
Available as of Camel 2.11

This component allows sending and receiving messages from Redis. Redis is advanced key-value store where keys can contain strings, hashes, lists, sets and sorted sets. In addition it provides pub/sub functionality for inter-app comunications.
Camel provides a producer for executing commands, consumer for subscribing to pub/sub messages an idempotent repository for filtering out duplicate messages.

PrerequisitesIn order to use this component, you must have a Redis server running.

URI Format


spring-redis://host:port[?options]


You can append query options to the URI in the following format, ?options=valueoption2=value...

URI Options



 Name 
 Default Value 
 Context 
 Description 


host
 null 
 Both 
 The host where Redis server is running. 


port
 null 
 Both 
 Redis port number. 


command
 SET 
 Both 
 Default command, which can be overriden by message header. 


channels
 SET 
 Consumer 
 List of topic names or name patterns to subscibe to. 


redisTemplate
 null 
 Producer 
 Reference to a pre-configured org.springframework.data.redis.core.RedisTemplate instance in the Registry. 


connectionFactory
 null 
 Both 
 Reference to a org.springframework.data.redis.connection.RedisConnectionFactory instance in the Registry. 


listenerContainer
 null 
 Consumer 
 Referebce to a org.springframework.data.redis.listener.RedisMessageListenerContainer instance in the Registry instance in the Registry. 


serializer
 null 
 Consumer 
 Referebce to a org.springframework.data.redis.serializer.RedisSerializer instance in the Registry. 





Usage
Message headers evaluated by the Redis producer
The producer issues commads to the server and each command has different set of parameters with specific types. The result from the command execution is returned in the message body. 



 Hash Commands 
 Description 
 Parameters 
 Result 


 HSET 
 Set the string value of a hash field 
 CamelRedis.Key (String), CamelRedis.Field (String), CamelRedis.Value (Object) 
 void 


 HGET 
 Get the value of a hash field 
 CamelRedis.Key (String), CamelRedis.Field (String) 
 String 


 HSETNX 
 Set the value of a hash field, only if the field does not exist 
 CamelRedis.Key (String), CamelRedis.Field (String), CamelRedis.Value (Object) 
 void 


 HMSET 
 Set multiple hash fields to multiple values 
 CamelRedis.Key (String), CamelRedis.Values(MapString, Object) 
 void 


 HMGET 
 Get the values of all the given hash fields 
 CamelRedis.Key (String), CamelRedis.Fields (CollectionString) 
 CollectionObject 


 HINCRBY 
 Increment the integer value of a hash field by the given number 
 CamelRedis.Key (String), CamelRedis.Field (String), CamelRedis.Value (Long) 
 Long 


 HEXISTS 
 Determine if a hash field exists 
 CamelRedis.Key (String), CamelRedis.Field (String) 
 Boolean 


 HDEL 
 Delete one or more hash fields 
 CamelRedis.Key (String), CamelRedis.Field (String) 
 void 


 HLEN 
 Get the number of fields in a hash 
 CamelRedis.Key (String) 
 Long 


 HKEYS 
 Get all the fields in a hash 
 CamelRedis.Key (String) 
 SetString 


 HVALS 
 Get all the values in a hash 
 CamelRedis.Key (String) 
 CollectionObject 


 HGETALL 
 Get all the fields and values in a hash 
 CamelRedis.Key (String) 
 MapString, Object 








 List Commands 
 Description 
 Parameters 
 Result 


 RPUSH 
 Append one or multiple values to a list 
 CamelRedis.Key (String), CamelRedis.Value (Object) 
 Long 


 RPUSHX 
 Append a value to a list, only if the list exists 
 CamelRedis.Key (String), CamelRedis.Value (Object) 
 Long 


 LPUSH 
 Prepend one or multiple values to a list 
 CamelRedis.Key (String), CamelRedis.Value (Object) 
 Long 


 LLEN 
 Get the length of a list 
 CamelRedis.Key (String) 
 Long


 LRANGE 
 Get a range of elements from a list 
 CamelRedis.Key (String), CamelRedis.Start (Long), CamelRedis.End (Long) 
 ListObject 


 LTRIM 
 Trim a list to the specified range 
 CamelRedis.Key (String), CamelRedis.Start (Long), CamelRedis.End (Long) 
 void 


 LINDEX 
 Get an element from a list by its index 
 CamelRedis.Key (String), CamelRedis.Index (Long) 
 String 


 LINSERT 
 Insert an element before or after another element in a list 
 CamelRedis.Key (String), CamelRedis.Value (Object), CamelRedis.Pivot (String), CamelRedis.Position (String) 
 Long 


 LSET 
 Set the value of an element in a list by its index 
 CamelRedis.Key (String), CamelRedis.Value (Object), CamelRedis.Index (Long) 
 void 


 LREM 
 Remove elements from a list 
 CamelRedis.Key (String), CamelRedis.Value (Object), CamelRedis.Count (Long) 
 Long 


 LPOP 
 Remove and get the first element in a list 
 CamelRedis.Key (String) 
 Object 


 RPOP 

[CONF] Apache Camel Spring Neo4j

2013-03-12 Thread confluence







Spring Neo4j
Page edited by Claus Ibsen


 Changes (4)
 




h2. Camel Spring Neo4j component 
 *Available as of Camel 2.11* 
...
 {code} 
spring-neo4j:http://hostname[:port]/database?options 
{code}  
...
 {code} 
from(timer://foo?period=1000).to(spring-neo4j:http://localhost:7474/data) 
{code}  
...
		exchange.getIn().setBody(exchange.getIn().getHeader(CamelFileName)); 	} 
}).to(spring-neo4j:http://localhost:7474/data) 
{code} 


Full Content

Camel Spring Neo4j component

Available as of Camel 2.11

The neo4j: component allows you to treat Neo4j as a camel producer endpoint. This means you can use this component in to() calls but not from() calls. This component is backed by the Spring Data Neo4j Library.


	As a producer, can create or remove nodes, and create or remove relationships.
	Can support as many endpoints as required, eg for multiple databases across multiple instances.
	Headers set for node id (for created nodes), relationship id (for created relationships)



Maven users will need to add the following dependency to their pom.xml for this component:



dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-spring-neo4j/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



spring-neo4j:http://hostname[:port]/database?options



Where the URL is the location of the of running neo4j rest server.

Headers

The following headers are set on exchanges during message transport.



 Property 
 Value 


 Neo4jOperation 
 One of the Neo4jOperation enum values `CREATE_NODE, REMOVE_NODE, CREATE_RELATIONSHIP, REMOVE_RELATIONSHIP` which determines which action to perform 


 Neo4jNodeId 
 the id of the created node 


 Neo4jRelationshipId 
 the id of the created relationship 





The producer will set the headers for downstream processors once the operation has taken place. Any ID headers set prior to the producer are ignored.

Operations

The neo4j component looks for the Neo4jOperation header to determine what kind of entity to create, which is one of the following enum types

`CREATE_NODE, REMOVE_NODE, CREATE_RELATIONSHIP,	REMOVE_RELATIONSHIP`

The body of the message is used to determine the node or relationship to manipulate. The following body types are supported:

For CREATE_NODE:


	null body - create default node
	Map body - create node with the properties set from the map



For REMOVE_NODE:


	Long or Integer - remove node using the body as the id
	neo4j Node instance - remove the node specified by that instance



For CREATE_RELATIONSHIP:


	SpringDataRelationship - create relationship specified by any @NodeEntity annoted Spring entities.
	org.apache.camel.component.neo4j.BasicRelationship - create relationship specified by the neo4j node types



For REMOVE_RELATIONSHIP:


	Long or Integer - remove relationship using the body as the id
	SpringDataRelationship - remove relationship specified by the @NodeEntity annoted Spring entities.
	org.apache.camel.component.neo4j.BasicRelationship - remove relationship specified by the neo4j node types



Samples

If you wanted to insert a new empty node every 1 seconds



from("timer://foo?period=1000").to("spring-neo4j:http://localhost:7474/data")



If you wanted to delete a specific node specified by a filename, eg a file of 100 would delete node 100.



from("file:/var/data").process(new Processor() {
	@Override
	public void process(Exchange exchange) throws Exception {
		exchange.getIn().setBody(exchange.getIn().getHeader("CamelFileName"));
	}
}).to("spring-neo4j:http://localhost:7474/data")





Change Notification Preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Spring LDAP

2013-02-27 Thread confluence







Spring LDAP
Page edited by Claus Ibsen


 Changes (2)
 




h2. Spring LDAP Component 
*Available since Camel 2.11* 
 
_available since: 2.11_  
The *spring-ldap:* component provides a Camel wrapper for [Spring LDAP|http://www.springsource.org/ldap].  
...


Full Content

Spring LDAP Component
Available since Camel 2.11

The spring-ldap: component provides a Camel wrapper for Spring LDAP.

Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-spring-ldap/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



spring-ldap:springLdapTemplate[?options]


Where springLdapTemplate is the name of the Spring LDAP Template bean. In this bean, you configure the URL and the credentials for your LDAP access.

Options



 Name 
 Type 
 Description 


 operation 
 String 
 The LDAP operation to be performed. Must be one of search, bind, or unbind. 


 scope 
 String 
 The scope of the search operation. Must be one of object, onelevel, or subtree, see also http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare 




If an unsupported value is specified for some option, the component throws an UnsupportedOperationException.

Usage

The component supports producer endpoint only. An attempt to create a consumer endpoint will result in an UnsupportedOperationException.
The body of the message must be a map (an instance of java.util.Map). This map must contain at least an entry with the key dn that specifies the root node for the LDAP operation to be performed. Other entries of the map are operation-specific (see below).

The body of the message remains unchanged for the bind and unbind operations. For the search operation, the body is set to the result of the search, see http://static.springsource.org/spring-ldap/site/apidocs/org/springframework/ldap/core/LdapTemplate.html#search%28java.lang.String,%20java.lang.String,%20int,%20org.springframework.ldap.core.AttributesMapper%29.

Search

The message body must have an entry with the key filter. The value must be a String representing a valid LDAP filter, see http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare.

Bind

The message body must have an entry with the key attributes. The value must be an instance of javax.naming.directory.Attributes This entry specifies the LDAP node to be created.

Unbind

No further entries necessary, the node with the specified dn is deleted.

Key definitions

In order to avoid spelling errors, the following constants are defined in org.apache.camel.springldap.SpringLdapProducer:

	public static final String DN = "dn"
	public static final String FILTER = "filter"
	public static final String ATTRIBUTES = "attributes"





Change Notification Preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Spring LDAP

2013-02-21 Thread confluence







Spring LDAP
Page edited by Leonid Kof


 Changes (1)
 




h2. Spring LDAP Component  
_available since: 2.11_  
The *spring-ldap:* component provides a Camel wrapper for [Spring LDAP|http://www.springsource.org/ldap].  
...


Full Content

Spring LDAP Component

available since: 2.11

The spring-ldap: component provides a Camel wrapper for Spring LDAP.

Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-spring-ldap/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



spring-ldap:springLdapTemplate[?options]


Where springLdapTemplate is the name of the Spring LDAP Template bean. In this bean, you configure the URL and the credentials for your LDAP access.

Options



 Name 
 Type 
 Description 


 operation 
 String 
 The LDAP operation to be performed. Must be one of search, bind, or unbind. 


 scope 
 String 
 The scope of the search operation. Must be one of object, onelevel, or subtree, see also http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare 




If an unsupported value is specified for some option, the component throws an UnsupportedOperationException.

Usage

The component supports producer endpoint only. An attempt to create a consumer endpoint will result in an UnsupportedOperationException.
The body of the message must be a map (an instance of java.util.Map). This map must contain at least an entry with the key dn that specifies the root node for the LDAP operation to be performed. Other entries of the map are operation-specific (see below).

The body of the message remains unchanged for the bind and unbind operations. For the search operation, the body is set to the result of the search, see http://static.springsource.org/spring-ldap/site/apidocs/org/springframework/ldap/core/LdapTemplate.html#search%28java.lang.String,%20java.lang.String,%20int,%20org.springframework.ldap.core.AttributesMapper%29.

Search

The message body must have an entry with the key filter. The value must be a String representing a valid LDAP filter, see http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare.

Bind

The message body must have an entry with the key attributes. The value must be an instance of javax.naming.directory.Attributes This entry specifies the LDAP node to be created.

Unbind

No further entries necessary, the node with the specified dn is deleted.

Key definitions

In order to avoid spelling errors, the following constants are defined in org.apache.camel.springldap.SpringLdapProducer:

	public static final String DN = "dn"
	public static final String FILTER = "filter"
	public static final String ATTRIBUTES = "attributes"





Change Notification Preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Spring LDAP

2013-02-20 Thread confluence







Spring LDAP
Page edited by Leonid Kof


 Changes (2)
 




Specification of the component to come soon. 
h2. Spring LDAP Component  The *spring-ldap:* component provides a Camel wrapper for [Spring LDAP|http://www.springsource.org/ldap].  Maven users will need to add the following dependency to their {{pom.xml}} for this component: {code:xml} dependency groupIdorg.apache.camel/groupId artifactIdcamel-spring-ldap/artifactId versionx.x.x/version !-- use the same version as your Camel core version -- /dependency {code}  h3. URI format  {code} spring-ldap:springLdapTemplate[?options] {code} Where *springLdapTemplate* is the name of the [Spring LDAP Template bean|http://static.springsource.org/spring-ldap/site/apidocs/org/springframework/ldap/core/LdapTemplate.html]. In this bean, you configure the URL and the credentials for your LDAP access.  h3. Options {div:class=confluenceTableSmall} || Name || Type || Description ||  | {{operation}} | String | The LDAP operation to be performed. Must be one of {{search}}, {{bind}}, or {{unbind}}. |   | {{scope}} | String | The scope of the search operation. Must be one of {{object}}, {{onelevel}}, or {{subtree}}, see also {{http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare}} |  {div} If an unsupported value is specified for some option, the component throws an {{UnsupportedOperationException}}.  h3. Usage  The component supports producer endpoint only. An attempt to create a consumer endpoint will result in an {{UnsupportedOperationException}}. The body of the message must be a map (an instance of {{java.util.Map}}). This map must contain at least an entry with the key {{dn}} that specifies the root node for the LDAP operation to be performed. Other entries of the map are operation-specific (see below).  The body of the message remains unchanged for the {{bind}} and {{unbind}} operations. For the {{search}} operation, the body is set to the result of the search, see [http://static.springsource.org/spring-ldap/site/apidocs/org/springframework/ldap/core/LdapTemplate.html#search%28java.lang.String,%20java.lang.String,%20int,%20org.springframework.ldap.core.AttributesMapper%29].  h4. Search  The message body must have an entry with the key {{filter}}. The value must be a String representing a valid LDAP filter, see [http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare].  h4. Bind  The message body must have an entry with the key {{attributes}}. The value must be an instance of [javax.naming.directory.Attributes|http://docs.oracle.com/javase/6/docs/api/javax/naming/directory/Attributes.html] This entry specifies the LDAP node to be created.  h4. Unbind  No further entries necessary, the node with the specified {{dn}} is deleted. 


Full Content

Spring LDAP Component

The spring-ldap: component provides a Camel wrapper for Spring LDAP.

Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-spring-ldap/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



spring-ldap:springLdapTemplate[?options]


Where springLdapTemplate is the name of the Spring LDAP Template bean. In this bean, you configure the URL and the credentials for your LDAP access.

Options



 Name 
 Type 
 Description 


 operation 
 String 
 The LDAP operation to be performed. Must be one of search, bind, or unbind. 


 scope 
 String 
 The scope of the search operation. Must be one of object, onelevel, or subtree, see also {{
http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare
}} 




If an unsupported value is specified for some option, the component throws an UnsupportedOperationException.

Usage

The component supports producer endpoint only. An attempt to create a consumer endpoint will result in an UnsupportedOperationException.
The body of the message must be a map (an instance of java.util.Map). This map must contain at least an entry with the key dn that specifies the root node for the LDAP operation to be performed. Other entries of the map are operation-specific (see below).

The body of the message remains unchanged for the bind and unbind operations. For the search operation, the body is set to the result of the search, see http://static.springsource.org/spring-ldap/site/apidocs/org/springframework/ldap/core/LdapTemplate.html#search%28java.lang.String,%20java.lang.String,%20int,%20org.springframework.ldap.core.AttributesMapper%29.

Search

The message body must have an entry with the key filter. The value must be a String representing a valid LDAP filter, see 

[CONF] Apache Camel Spring LDAP

2013-02-20 Thread confluence







Spring LDAP
Page edited by Leonid Kof


 Changes (1)
 




...
|| Name || Type || Description ||  | {{operation}} | String | The LDAP operation to be performed. Must be one of {{search}}, {{bind}}, or {{unbind}}. |   
| {{scope}} | String | The scope of the search operation. Must be one of {{object}}, {{onelevel}}, or {{subtree}}, see also {{http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare}} [http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare] | 
{div} If an unsupported value is specified for some option, the component throws an {{UnsupportedOperationException}}. 
...


Full Content

Spring LDAP Component

The spring-ldap: component provides a Camel wrapper for Spring LDAP.

Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-spring-ldap/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



spring-ldap:springLdapTemplate[?options]


Where springLdapTemplate is the name of the Spring LDAP Template bean. In this bean, you configure the URL and the credentials for your LDAP access.

Options



 Name 
 Type 
 Description 


 operation 
 String 
 The LDAP operation to be performed. Must be one of search, bind, or unbind. 


 scope 
 String 
 The scope of the search operation. Must be one of object, onelevel, or subtree, see also http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare 




If an unsupported value is specified for some option, the component throws an UnsupportedOperationException.

Usage

The component supports producer endpoint only. An attempt to create a consumer endpoint will result in an UnsupportedOperationException.
The body of the message must be a map (an instance of java.util.Map). This map must contain at least an entry with the key dn that specifies the root node for the LDAP operation to be performed. Other entries of the map are operation-specific (see below).

The body of the message remains unchanged for the bind and unbind operations. For the search operation, the body is set to the result of the search, see http://static.springsource.org/spring-ldap/site/apidocs/org/springframework/ldap/core/LdapTemplate.html#search%28java.lang.String,%20java.lang.String,%20int,%20org.springframework.ldap.core.AttributesMapper%29.

Search

The message body must have an entry with the key filter. The value must be a String representing a valid LDAP filter, see http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare.

Bind

The message body must have an entry with the key attributes. The value must be an instance of javax.naming.directory.Attributes This entry specifies the LDAP node to be created.

Unbind

No further entries necessary, the node with the specified dn is deleted.



Change Notification Preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Spring LDAP

2013-02-20 Thread confluence







Spring LDAP
Page edited by Leonid Kof


 Changes (3)
 




...
 The component supports producer endpoint only. An attempt to create a consumer endpoint will result in an {{UnsupportedOperationException}}. 
The body of the message must be a map (an instance of {{java.util.Map}}). This map must contain at least an entry with the key *{{dn}}* that specifies the root node for the LDAP operation to be performed. Other entries of the map are operation-specific (see below). 
 The body of the message remains unchanged for the {{bind}} and {{unbind}} operations. For the {{search}} operation, the body is set to the result of the search, see [http://static.springsource.org/spring-ldap/site/apidocs/org/springframework/ldap/core/LdapTemplate.html#search%28java.lang.String,%20java.lang.String,%20int,%20org.springframework.ldap.core.AttributesMapper%29]. 
...
h4. Search  
The message body must have an entry with the key *{{filter}}*. The value must be a String representing a valid LDAP filter, see [http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare]. 
 h4. Bind  
The message body must have an entry with the key *{{attributes}}*. The value must be an instance of [javax.naming.directory.Attributes|http://docs.oracle.com/javase/6/docs/api/javax/naming/directory/Attributes.html] This entry specifies the LDAP node to be created. 
 h4. Unbind 
...


Full Content

Spring LDAP Component

The spring-ldap: component provides a Camel wrapper for Spring LDAP.

Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-spring-ldap/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



spring-ldap:springLdapTemplate[?options]


Where springLdapTemplate is the name of the Spring LDAP Template bean. In this bean, you configure the URL and the credentials for your LDAP access.

Options



 Name 
 Type 
 Description 


 operation 
 String 
 The LDAP operation to be performed. Must be one of search, bind, or unbind. 


 scope 
 String 
 The scope of the search operation. Must be one of object, onelevel, or subtree, see also http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare 




If an unsupported value is specified for some option, the component throws an UnsupportedOperationException.

Usage

The component supports producer endpoint only. An attempt to create a consumer endpoint will result in an UnsupportedOperationException.
The body of the message must be a map (an instance of java.util.Map). This map must contain at least an entry with the key dn that specifies the root node for the LDAP operation to be performed. Other entries of the map are operation-specific (see below).

The body of the message remains unchanged for the bind and unbind operations. For the search operation, the body is set to the result of the search, see http://static.springsource.org/spring-ldap/site/apidocs/org/springframework/ldap/core/LdapTemplate.html#search%28java.lang.String,%20java.lang.String,%20int,%20org.springframework.ldap.core.AttributesMapper%29.

Search

The message body must have an entry with the key filter. The value must be a String representing a valid LDAP filter, see http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare.

Bind

The message body must have an entry with the key attributes. The value must be an instance of javax.naming.directory.Attributes This entry specifies the LDAP node to be created.

Unbind

No further entries necessary, the node with the specified dn is deleted.



Change Notification Preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Spring LDAP

2013-02-20 Thread confluence







Spring LDAP
Page edited by Leonid Kof


 Changes (1)
 




...
h4. Unbind  
No further entries necessary, the node with the specified *{{dn}}* is deleted. 


Full Content

Spring LDAP Component

The spring-ldap: component provides a Camel wrapper for Spring LDAP.

Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-spring-ldap/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



spring-ldap:springLdapTemplate[?options]


Where springLdapTemplate is the name of the Spring LDAP Template bean. In this bean, you configure the URL and the credentials for your LDAP access.

Options



 Name 
 Type 
 Description 


 operation 
 String 
 The LDAP operation to be performed. Must be one of search, bind, or unbind. 


 scope 
 String 
 The scope of the search operation. Must be one of object, onelevel, or subtree, see also http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare 




If an unsupported value is specified for some option, the component throws an UnsupportedOperationException.

Usage

The component supports producer endpoint only. An attempt to create a consumer endpoint will result in an UnsupportedOperationException.
The body of the message must be a map (an instance of java.util.Map). This map must contain at least an entry with the key dn that specifies the root node for the LDAP operation to be performed. Other entries of the map are operation-specific (see below).

The body of the message remains unchanged for the bind and unbind operations. For the search operation, the body is set to the result of the search, see http://static.springsource.org/spring-ldap/site/apidocs/org/springframework/ldap/core/LdapTemplate.html#search%28java.lang.String,%20java.lang.String,%20int,%20org.springframework.ldap.core.AttributesMapper%29.

Search

The message body must have an entry with the key filter. The value must be a String representing a valid LDAP filter, see http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare.

Bind

The message body must have an entry with the key attributes. The value must be an instance of javax.naming.directory.Attributes This entry specifies the LDAP node to be created.

Unbind

No further entries necessary, the node with the specified dn is deleted.



Change Notification Preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Spring LDAP

2013-02-20 Thread confluence







Spring LDAP
Page edited by Leonid Kof


 Changes (1)
 




...
 No further entries necessary, the node with the specified *{{dn}}* is deleted. 
 *Key definitions*  In order to avoid spelling errors, the following constants are defined in {{org.apache.camel.springldap.SpringLdapProducer}}: * DN = dn * FILTER = filter * ATTRIBUTES = attributes 


Full Content

Spring LDAP Component

The spring-ldap: component provides a Camel wrapper for Spring LDAP.

Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-spring-ldap/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



spring-ldap:springLdapTemplate[?options]


Where springLdapTemplate is the name of the Spring LDAP Template bean. In this bean, you configure the URL and the credentials for your LDAP access.

Options



 Name 
 Type 
 Description 


 operation 
 String 
 The LDAP operation to be performed. Must be one of search, bind, or unbind. 


 scope 
 String 
 The scope of the search operation. Must be one of object, onelevel, or subtree, see also http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare 




If an unsupported value is specified for some option, the component throws an UnsupportedOperationException.

Usage

The component supports producer endpoint only. An attempt to create a consumer endpoint will result in an UnsupportedOperationException.
The body of the message must be a map (an instance of java.util.Map). This map must contain at least an entry with the key dn that specifies the root node for the LDAP operation to be performed. Other entries of the map are operation-specific (see below).

The body of the message remains unchanged for the bind and unbind operations. For the search operation, the body is set to the result of the search, see http://static.springsource.org/spring-ldap/site/apidocs/org/springframework/ldap/core/LdapTemplate.html#search%28java.lang.String,%20java.lang.String,%20int,%20org.springframework.ldap.core.AttributesMapper%29.

Search

The message body must have an entry with the key filter. The value must be a String representing a valid LDAP filter, see http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare.

Bind

The message body must have an entry with the key attributes. The value must be an instance of javax.naming.directory.Attributes This entry specifies the LDAP node to be created.

Unbind

No further entries necessary, the node with the specified dn is deleted.

Key definitions

In order to avoid spelling errors, the following constants are defined in org.apache.camel.springldap.SpringLdapProducer:

	DN = "dn"
	FILTER = "filter"
	ATTRIBUTES = "attributes"





Change Notification Preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Spring LDAP

2013-02-20 Thread confluence







Spring LDAP
Page edited by Leonid Kof


 Changes (3)
 




...
 In order to avoid spelling errors, the following constants are defined in {{org.apache.camel.springldap.SpringLdapProducer}}: 
* public static final String DN = dn 
* public static final String FILTER = filter 
* public static final String ATTRIBUTES = attributes 


Full Content

Spring LDAP Component

The spring-ldap: component provides a Camel wrapper for Spring LDAP.

Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-spring-ldap/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



spring-ldap:springLdapTemplate[?options]


Where springLdapTemplate is the name of the Spring LDAP Template bean. In this bean, you configure the URL and the credentials for your LDAP access.

Options



 Name 
 Type 
 Description 


 operation 
 String 
 The LDAP operation to be performed. Must be one of search, bind, or unbind. 


 scope 
 String 
 The scope of the search operation. Must be one of object, onelevel, or subtree, see also http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare 




If an unsupported value is specified for some option, the component throws an UnsupportedOperationException.

Usage

The component supports producer endpoint only. An attempt to create a consumer endpoint will result in an UnsupportedOperationException.
The body of the message must be a map (an instance of java.util.Map). This map must contain at least an entry with the key dn that specifies the root node for the LDAP operation to be performed. Other entries of the map are operation-specific (see below).

The body of the message remains unchanged for the bind and unbind operations. For the search operation, the body is set to the result of the search, see http://static.springsource.org/spring-ldap/site/apidocs/org/springframework/ldap/core/LdapTemplate.html#search%28java.lang.String,%20java.lang.String,%20int,%20org.springframework.ldap.core.AttributesMapper%29.

Search

The message body must have an entry with the key filter. The value must be a String representing a valid LDAP filter, see http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare.

Bind

The message body must have an entry with the key attributes. The value must be an instance of javax.naming.directory.Attributes This entry specifies the LDAP node to be created.

Unbind

No further entries necessary, the node with the specified dn is deleted.

Key definitions

In order to avoid spelling errors, the following constants are defined in org.apache.camel.springldap.SpringLdapProducer:

	public static final String DN = "dn"
	public static final String FILTER = "filter"
	public static final String ATTRIBUTES = "attributes"





Change Notification Preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Spring LDAP

2013-02-20 Thread confluence







Spring LDAP
Page edited by Leonid Kof


 Changes (2)
 




...
*Key definitions*  
In order to avoid spelling errors, the following constants are defined in {{org.apache.camel.springldap.SpringLdapProducer}}: 
* DN = dn * FILTER = filter * ATTRIBUTES = attributes 


Full Content

Spring LDAP Component

The spring-ldap: component provides a Camel wrapper for Spring LDAP.

Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-spring-ldap/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



spring-ldap:springLdapTemplate[?options]


Where springLdapTemplate is the name of the Spring LDAP Template bean. In this bean, you configure the URL and the credentials for your LDAP access.

Options



 Name 
 Type 
 Description 


 operation 
 String 
 The LDAP operation to be performed. Must be one of search, bind, or unbind. 


 scope 
 String 
 The scope of the search operation. Must be one of object, onelevel, or subtree, see also http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare 




If an unsupported value is specified for some option, the component throws an UnsupportedOperationException.

Usage

The component supports producer endpoint only. An attempt to create a consumer endpoint will result in an UnsupportedOperationException.
The body of the message must be a map (an instance of java.util.Map). This map must contain at least an entry with the key dn that specifies the root node for the LDAP operation to be performed. Other entries of the map are operation-specific (see below).

The body of the message remains unchanged for the bind and unbind operations. For the search operation, the body is set to the result of the search, see http://static.springsource.org/spring-ldap/site/apidocs/org/springframework/ldap/core/LdapTemplate.html#search%28java.lang.String,%20java.lang.String,%20int,%20org.springframework.ldap.core.AttributesMapper%29.

Search

The message body must have an entry with the key filter. The value must be a String representing a valid LDAP filter, see http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Search_and_Compare.

Bind

The message body must have an entry with the key attributes. The value must be an instance of javax.naming.directory.Attributes This entry specifies the LDAP node to be created.

Unbind

No further entries necessary, the node with the specified dn is deleted.

Key definitions

In order to avoid spelling errors, the following constants



Change Notification Preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Spring LDAP

2013-02-18 Thread confluence







Spring LDAP
Page  added by Leonid Kof

 

 Specification of the component to come soon.


   
Change Notification Preferences
   
   View Online
  |
   Add Comment
   








[CONF] Apache Camel Spring Web Services

2012-12-22 Thread confluence







Spring Web Services
Page edited by willem jiang


Comment:
CAMEL-5724


 Changes (2)
 




...
| {{transformerFactory}} | No | Option to override default TransformerFactory. The provided transformer factory must be of type {{javax.xml.transform.TransformerFactory}} | | {{endpointMapping}} | Only when _mapping-type_ is {{rootqname}}, {{soapaction}}, {{uri}} or {{xpathresult}} | Reference to an instance of {{org.apache.camel.component.spring.ws.bean.CamelEndpointMapping}} in the Registry/ApplicationContext. Only one bean is required in the registry to serve all Camel/Spring-WS endpoints. This bean is auto-discovered by the [MessageDispatcher|http://static.springsource.org/spring-ws/sites/1.5/apidocs/org/springframework/ws/server/MessageDispatcher.html] and used to map requests to Camel endpoints based on characteristics specified on the endpoint (like root QName, SOAP action, etc) | 
| {{messageFilter}} | No | Option to provide a custom MessageFilter since 2.10.3. For example when you want to process your headers or attachments by your own. |  
{div}  
...
{code}  
h3. The header and attachment propagation Spring WS Camel supports propagation of the headers and attachments into Spring-WS WebServiceMessage response since version *2.10.3*. The endpoint will use so called hook the MessageFilter (default implementation is provided by BasicMessageFilter) to propagate the exchange headers and attachments into WebSdrviceMessage response. Now you can use  {code} exchange.getOut().getHeaders().put(myCustom,myHeaderValue) exchange.getIn().addAttachment(myAttachment, new DataHandler(...)) {code} Note: If the exchange header in the pipeline contains text, it generates Qname(key)=value attribute in the soap header.  Recommended is to create a QName class directly and put into any key into header.  h3. How to use MTOM attachments The BasicMessageFilter provides all required information for Apache Axiom in order to produce MTOM message. If you want to use Apache Camel Spring WS within Apache Axiom, here is an example: 1. Simply define the messageFactory as is bellow and spring-ws will use MTOM strategy to populate your SOAP message with optimized attachments. {code} bean id=axiomMessageFactory class=org.springframework.ws.soap.axiom.AxiomSoapMessageFactory property name=payloadCaching value=false / property name=attachmentCaching value=true / property name=attachmentCacheThreshold value=1024 / /bean {code}  2. Add into your pom.xml the following dependencies {code} dependency groupIdorg.apache.ws.commons.axiom/groupId artifactIdaxiom-api/artifactId version1.2.13/version /dependency dependency groupIdorg.apache.ws.commons.axiom/groupId artifactIdaxiom-impl/artifactId version1.2.13/version scoperuntime/scope /dependency {code} 3. Add your attachment into the pipeline, for example using a Processor implementation. {code} private class Attachement implements Processor { public void process(Exchange exchange) throws Exception { exchange.getOut().copyFrom(exchange.getIn()); File file = new File(testAttachment.txt); exchange.getOut().addAttachment(test, new DataHandler(new FileDataSource(file)));	 } } {code} 4. Define endpoint (producer) as ussual, for example like this: {code} from(direct:send) .process(new Attachement()) .to(spring-ws:http://localhost:8089/mySoapService?soapAction=mySoapmessageFactory=axiomMessageFactory); {code} 5. Now, your producer will generate MTOM message with otpmized attachments.  h3. The custom header and attachment filtering If you need to provide your custome processing of either headers or attachments, extend existing BasicMessageFilter and override the approchiate methods or write a brand new implementation of the MessageFilter interface. To use your custom filter, add this into your spring context: You can specify either a global a or a local message filter as follows: a) the global custome filter that provides the global configuration for all spring-ws endpoints {code}  bean id=messageFilter class=your.domain.myMessageFiler scope=singleton / {code} or b) the local messageFilter directly on the endpoint as follows: {code} to(spring-ws:http://yourdomain.com?messageFilter=#myEndpointSpecificMessageFilter); {code} For more information see [CAMEL-5724|https://issues.apache.org/jira/browse/CAMEL-5724]  If you want to create your own MessageFilter, consider overrideing the following methods in the default implementation of MessageFilter in class BasicMessageFilter: {code} protected void doProcessSoapHeader(Message inOrOut, SoapMessage soapMessage) {your code /*no need to call super*/ } protected void doProcessSoapAttachements(Message inOrOut, SoapMessage response) { your code /*no need to call super*/ } {code}  
h3. Using a custom MessageSender and 

[CONF] Apache Camel Spring Security Example

2012-11-07 Thread confluence







Spring Security Example
Page edited by willem jiang


Comment:
updated the camel route configuration link


 Changes (1)
 




...
Here is the camel route configuration:  
{snippet:id=example|lang=xml|url=""> {snippet:id=example|lang=xml|url=""> 
 You can find how to configure the camel-servlet with http basic authentication by check the files in [WEB-INF|https://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-spring-security/src/main/webapp/WEB-INF]  


Full Content

Spring Security Example

This example shows you how to leverage the Spring Security already provides authentication mechanism and authoriationPolicy which is provided in camel-spring-security module to implement a role based authorization application. 

This example consumes messages from a servlet endpoint which is secured by Spring Security with http basic authentication, there are two service:


 "http://localhost:8080/camel/user" is for the authenticated user whose role is ROLE_USER
 "http://localhost:8080/camel/admim" is for the authenticated user whose role is ROLE_ADMIN



You will need to compile this example first:


  cd $CAMEL_HOME/examples/camel-example-spring-security
  mvn clean install



To run the example, you need to start up the server by typing


  mvn jetty:run


To stop the server hit ctrl + c

Then you can use the script in the client directory to send the request and check the response, or use browser to access upper service with the user/password ("jim/jimspassword" with the admin and user role  or "rob/robspassword" with user role).

Here is the camel route configuration:


beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:spring-security="http://www.springframework.org/schema/security"
   xsi:schemaLocation="
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
 http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
 http://camel.apache.org/schema/spring-security http://camel.apache.org/schema/spring-security/camel-spring-security.xsd
 http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"

  spring-security:http realm="User Restrict Realm"
spring-security:intercept-url pattern="/camel/**" access="ROLE_USER"/
spring-security:http-basic/
spring-security:remember-me/
  /spring-security:http

!--  set up the user configuration here --
  spring-security:authentication-manager alias="authenticationManager"
spring-security:authentication-provider user-service-ref="userDetailsService"/
  /spring-security:authentication-manager

  spring-security:user-service id="userDetailsService"
spring-security:user name="jim" password="jimspassword" authorities="ROLE_USER, ROLE_ADMIN"/
spring-security:user name="bob" password="bobspassword" authorities="ROLE_USER"/
  /spring-security:user-service

  bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased"
property name="allowIfAllAbstainDecisions" value="true"/
property name="decisionVoters"
  list
bean class="org.springframework.security.access.vote.RoleVoter"/
  /list
/property
  /bean

  !-- The Policy for checking the authentication role of ADMIN --
  authorizationPolicy id="admin" access="ROLE_ADMIN"
   authenticationManager="authenticationManager"
   accessDecisionManager="accessDecisionManager"
   xmlns="http://camel.apache.org/schema/spring-security"/

  !-- The Policy for checking the authentication role of USER --
  authorizationPolicy id="user" access="ROLE_USER"
   xmlns="http://camel.apache.org/schema/spring-security"/

  camelContext id="myCamelContext" xmlns="http://camel.apache.org/schema/spring"
!-- Catch the authorization exception and set the Access Denied message back --
onException
  exceptionorg.apache.camel.CamelAuthorizationException/exception
  handled
constanttrue/constant
  /handled
  transform
simpleAccess Denied with the Policy of ${exception.policyId} !/simple
  /transform
/onException

route
  from uri="servlet:///user"/
  !-- wrap the route in the policy which enforces security check --
  policy ref="user"
transform
  simpleNormal user can access this service/simple
/transform
  /policy
/route

route
  from uri="servlet:///admin"/
  !-- wrap the route in the policy which enforces security check --
  policy ref="admin"
   

[CONF] Apache Camel Spring Web Services

2012-06-21 Thread confluence







Spring Web Services
Page edited by David Valeri


 Changes (1)
 




...
| {{wsAddressingAction}} | No | WS-Addressing 1.0 action header to include when accessing web services. The {{To}} header is set to the _address_ of the web service as specified in the endpoint URI (default Spring-WS behavior). | | {{_expression_}} | Only when _mapping-type_ is {{xpathresult}} | XPath _expression_ to use in the process of mapping web service requests, should match the result specified by {{xpathresult}} | 
| {{timeout}} | No | *Camel 2.10:* Sets the socket read timeout (in milliseconds) while invoking a webservice using the producer, see [URLConnection.setReadTimeout()|http://docs.oracle.com/javase/6/docs/api/java/net/URLConnection.html#setReadTimeout(int)] and [CommonsHttpMessageSender.setReadTimeout()|http://static.springsource.org/spring-ws/site/apidocs/org/springframework/ws/transport/http/CommonsHttpMessageSender.html#setReadTimeout(int)]. nbsp;This option works when using the built-in message sender implementations:nbsp;_CommonsHttpMessageSender_nbsp;andnbsp;_HttpUrlConnectionMessageSender_. nbsp;One of these implementations will be used by default for HTTP based services unless you customize the Spring WS configuration options supplied to the component. nbsp;If you are using a non-standard sender, it is assumed that you will handle your own timeout configuration. | 
| {{sslContextParameters}} | No | *Camel 2.10:*nbsp;Reference to annbsp;{{org.apache.camel.util.jsse.SSLContextParameters}} innbsp;thenbsp;[Registry|http://camel.apache.org/registry.html]. nbsp;Seenbsp;[Using the JSSE Configuration Utility|http://camel.apache.org/http4.html#HTTP4-UsingtheJSSEConfigurationUtility]. nbsp;This option works when using the built-in message sender implementations:nbsp;_CommonsHttpMessageSender_nbsp;andnbsp;_HttpUrlConnectionMessageSender_. nbsp;One of these implementations will be used by default for HTTP based services unless you customize the Spring WS configuration options supplied to the component. nbsp;If you are using a non-standard sender, it is assumed that you will handle your own TLS configuration. | {div} 
...


Full Content

Spring Web Services Component

Available as of Camel 2.6

The spring-ws: component allows you to integrate with Spring Web Services. It offers both clientside support, for accessing web services, and serverside support for creating your own contract-first web services.

Maven users will need to add the following dependency to their pom.xml for this component:


dependency
	groupIdorg.apache.camel/groupId
	artifactIdcamel-spring-ws/artifactId
	versionx.x.x/version
	!-- use the same version as your Camel core version --
/dependency



DependenciesAs of Camel 2.8 this component ships with Spring-WS 2.0.x which (like the rest of Camel) requires Spring 3.0.x.

Earlier Camel versions shipped Spring-WS 1.5.9 which is compatible with Spring 2.5.x and 3.0.x. In order to run earlier versions of camel-spring-ws on Spring 2.5.x you need to add the spring-webmvc module from Spring 2.5.x. In order to run Spring-WS 1.5.9 on Spring 3.0.x you need to exclude the OXM module from Spring 3.0.x as this module is also included in Spring-WS 1.5.9 (see this post)

URI format

The URI scheme for this component is as follows


spring-ws:[mapping-type:]address[?options]



To expose a web service mapping-type needs to be set to any of the following:




 Mapping type 
 Description 


 rootqname 
 Offers the option to map web service requests based on the qualified name of the root element contained in the message. 


 soapaction 
 Used to map web service requests based on the SOAP action specified in the header of the message. 


 uri 
 In order to map web service requests that target a specific URI. 


 xpathresult 
 Used to map web service requests based on the evaluation of an XPath _expression_ against the incoming message. The result of the evaluation should match the XPath result specified in the endpoint URI. 


 beanname 
 Allows you to reference an org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher object in order to integrate with existing (legacy) endpoint mappings like PayloadRootQNameEndpointMapping, SoapActionEndpointMapping, etc 





As a consumer the address should contain a value relevant to the specified mapping-type (e.g. a SOAP action, XPath _expression_). As a producer the address should be set to the URI of the web service your calling upon.

You can append query options to the URI in the following format, ?option=valueoption=value...

Options




 Name 
 Required? 
 Description 


 soapAction 
 No 
 SOAP action to include inside a SOAP request when accessing remote web services 


 wsAddressingAction 
 No 
 WS-Addressing 

[CONF] Apache Camel Spring Web Services

2012-04-16 Thread confluence







Spring Web Services
Page edited by David Valeri


 Changes (6)
 




...
*Available as of Camel 2.6*  
The *spring-ws:* component allows you to integrate with [Spring Web Services|http://static.springsource.org/spring-ws/sites/1.5/]. It offers both _client_\-side support, for accessing web services, and _server_\-side support for creating your own contract-first web services. 
 Maven users will need to add the following dependency to their {{pom.xml}} for this component: 
...
| {{_expression_}} | Only when _mapping-type_ is {{xpathresult}} | XPath _expression_ to use in the process of mapping web service requests, should match the result specified by {{xpathresult}} | | {{timeout}} | No | *Camel 2.10:* Sets the socket read timeout (in milliseconds) while invoking a webservice using the producer, see [URLConnection.setReadTimeout()|http://docs.oracle.com/javase/6/docs/api/java/net/URLConnection.html#setReadTimeout(int)] and [CommonsHttpMessageSender.setReadTimeout()|http://static.springsource.org/spring-ws/site/apidocs/org/springframework/ws/transport/http/CommonsHttpMessageSender.html#setReadTimeout(int)] | 
| {{sslContextParameters}} | No | *Camel 2.10:*nbsp;Reference to anbsp;{{org.apache.camel.util.jsse.SSLContextParameters}}nbsp;in thenbsp;[Registry|http://camel.apache.org/registry.html]. nbsp;Seenbsp;[Using the JSSE Configuration Utility|http://camel.apache.org/http4.html#HTTP4-UsingtheJSSEConfigurationUtility]. nbsp;This option works when using the built-in message sender implementations:nbsp;_CommonsHttpMessageSender_nbsp;andnbsp;_HttpUrlConnectionMessageSender_. nbsp;One of these implementations will be used by default for HTTP based services unless you customize the Spring WS configuration options supplied to the component. nbsp;If you are using a non-standard sender, it is assumed that you will handle your own TLS configuration. | 
{div}  
...
h2. Accessing web services  
To call a web service at {{[http://foo.com/bar]}} simply define a route: 
{code} from(direct:example).to(spring-ws:http://foo.com/bar) 
...
With the XML configuration in-place you can now use Camels DSL to define what web service requests are handled by your endpoint:  
The following route will receive all web service requests that have a root element named GetFoo within the {{[http://example.com/]}} namespace. 
{code} from(spring-ws:rootqname:{http://example.com/}GetFoo?endpointMapping=#endpointMapping) 
...
{code}  
The following route will receive web service requests containing the {{[http://example.com/GetFoo]}} SOAP action. 
{code} from(spring-ws:soapaction:http://example.com/GetFoo?endpointMapping=#endpointMapping) 
...
{code}  
The following route will receive all requests sent to {{[http://example.com/foobar]}}. 
{code} from(spring-ws:uri:http://example.com/foobar?endpointMapping=#endpointMapping) 
...


Full Content

Spring Web Services Component

Available as of Camel 2.6

The spring-ws: component allows you to integrate with Spring Web Services. It offers both clientside support, for accessing web services, and serverside support for creating your own contract-first web services.

Maven users will need to add the following dependency to their pom.xml for this component:


dependency
	groupIdorg.apache.camel/groupId
	artifactIdcamel-spring-ws/artifactId
	versionx.x.x/version
	!-- use the same version as your Camel core version --
/dependency



DependenciesAs of Camel 2.8 this component ships with Spring-WS 2.0.x which (like the rest of Camel) requires Spring 3.0.x.

Earlier Camel versions shipped Spring-WS 1.5.9 which is compatible with Spring 2.5.x and 3.0.x. In order to run earlier versions of camel-spring-ws on Spring 2.5.x you need to add the spring-webmvc module from Spring 2.5.x. In order to run Spring-WS 1.5.9 on Spring 3.0.x you need to exclude the OXM module from Spring 3.0.x as this module is also included in Spring-WS 1.5.9 (see this post)

URI format

The URI scheme for this component is as follows


spring-ws:[mapping-type:]address[?options]



To expose a web service mapping-type needs to be set to any of the following:




 Mapping type 
 Description 


 rootqname 
 Offers the option to map web service requests based on the qualified name of the root element contained in the message. 


 soapaction 
 Used to map web service requests based on the SOAP action specified in the header of the message. 


 uri 
 In order to map web service requests that target a specific URI. 


 xpathresult 
 Used to map web service 

[CONF] Apache Camel Spring Testing

2012-04-16 Thread confluence







Spring Testing
Page edited by David Valeri


 Changes (1)
 




...
| org.apache.camel.test.spring.LazyLoadTypeConverters (Deprecated) \\ | Class \\ | Indicates if thenbsp;CamelContexts that are bootstrapped during the test through the use of Spring Testnbsp;loaded application contexts should use lazy loading of type converters. | Type converters are not lazy loaded | Type converters are not lazy loaded | | org.apache.camel.test.spring.MockEndpoints \\ | Class \\ | Triggers the auto-mocking of endpoints whose URIs match the provided filter.nbsp; The defaultnbsp;filter is * which matches all endpoints. nbsp;Seenbsp;org.apache.camel.impl.InterceptSendToMockEndpointStrategynbsp;fornbsp;more details on the registration of the mock endpoints. | Not enabled | All endpoints are sniffed and recorded in a mock endpoint. | 
| org.apache.camel.test.spring.MockEndpointsAndSkip\\ | Class | Triggers the auto-mocking of endpoints whose URIs match the provided filter.nbsp; The defaultnbsp;filter is * which matches all endpoints. nbsp;Seenbsp;org.apache.camel.impl.InterceptSendToMockEndpointStrategynbsp;fornbsp;more details on the registration of the mock endpoints. nbsp;This annotation will also skip sending the message to matched endpoints as well.\\ | Not enabled\\ | All endpoints are sniffed and recorded in a mock endpoint. nbsp;The original endpoint is not invoked.\\ | 
| org.apache.camel.test.spring.ProvidesBreakpoint \\ | Method | Indicates that the annotated method returns annbsp;org.apache.camel.spi.Breakpointnbsp;for use in the test.nbsp; Useful for interceptingnbsp;traffic to all endpoints or simply for setting a break point in an IDE for debugging.nbsp; The method mustnbsp;be public, static, take no arguments, and return org.apache.camel.spi.Breakpoint. \\ | N/A | The returned Breakpoint is registered in the CamelContext(s) | | org.apache.camel.test.spring.ShutdownTimeout \\ | Class \\ | Indicates to set the shutdown timeout of all CamelContexts instantiated through thenbsp;use of Spring Test loaded application contexts.nbsp; If no annotation is used, the timeout isnbsp;automatically reduced to 10 seconds by the test framework. \\ | 10 seconds | 10 seconds | 
...


Full Content

Spring Testing

Testing is a crucial part of any development or integration work. The Spring Framework offers a number of features that makes it easy to test while using Spring for Inversion of Control which works with JUnit 3.x, JUnit 4.x, and TestNG.

We can use Spring for IoC and the Camel Mock and Test endpoints to create sophisticated integration/unit tests that are easy to run and debug inside your IDE. There are three supported approaches for testing with Spring in Camel.



 Name 
 Testing Frameworks Supported 
 Description 
 Required Camel Test Dependencies 


 CamelSpringTestSupport 

	JUnit 3.x (deprecated)
	JUnit 4.x
	TestNG - Camel 2.8


 Provided by org.apache.camel.test.CamelSpringTestSupport, org.apache.camel.test.junit4.CamelSpringTestSupport, and org.apache.camel.testng.CamelSpringTestSupport. These base classes provide feature parity withthe simple CamelTestSupport classes fromCamel Testbut do not support Spring annotations on the test class such as @Autowired,@DirtiesContext, and@ContextConfiguration.  

	JUnit 3.x (deprecated) - camel-test-spring
	JUnit 4.x camel-test-spring
	TestNG - camel-test-ng




 Plain Spring Test  

	JUnit 3.x
	JUnit 4.x
	TestNG


 Extend the abstract base classes (org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests,org.springframework.test.context.junit38.AbstractJUnit4SpringContextTests, etc.)provided in Spring Test or use the Spring Test JUnit4 runner. These approaches support both the Camel annotations and Spring annotations, but do not have feature parity withorg.apache.camel.test.CamelTestSupport, org.apache.camel.test.junit4.CamelTestSupport, and org.apache.camel.testng.CamelSpringTestSupport.  

	JUnit 3.x (deprecated) - None
	JUnit 4.x None
	TestNG - None




 Camel Enhanced Spring Test  

	JUnit 4.x - Camel 2.10
	TestNG - Camel 2.10


 Use the org.apache.camel.test.junit4.CamelSpringJUnit4ClassRunnerrunner with the@RunWithannotation or extend org.apache.camel.testng.AbstractCamelTestNGSpringContextTeststo enable feature parity with org.apache.camel.test.CamelTestSupport and org.apache.camel.test.junit4.CamelTestSupport and also support the full suite of Spring Test annotations such as@Autowired,@DirtiesContext, and @ContextConfiguration. 

	JUnit 3.x (deprecated) - camel-test-spring
	JUnit 4.x camel-test-spring
	TestNG - camel-test-ng







CamelSpringTestSupport

org.apache.camel.test.CamelSpringTestSupport, org.apache.camel.test.junit4.CamelSpringTestSupport, and 

[CONF] Apache Camel Spring Testing

2012-03-02 Thread confluence







Spring Testing
Page edited by Babak Vahdat


 Changes (1)
 




...
h3. See Also  
* a A [real example test case using Mock and Spring|http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/test/TestEndpointTest.java?view=markup] Spring|https://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/mock/InterceptSendToMockEndpointStrategyTest.java] along with its [Spring XML|http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/test/TestEndpointTest-context.xml] XML|https://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/mock/InterceptSendToMockEndpointStrategyTest.xml] 
* [Bean Integration] * [Mock] endpoint 
...


Full Content

Spring Testing

Testing is a crucial part of any development or integration work. The Spring Framework offers a number of features that makes it easy to test while using Spring for Inversion of Control which works with JUnit 3.x, JUnit 4.x, and TestNG.

We can use Spring for IoC and the Camel Mock and Test endpoints to create sophisticated integration/unit tests that are easy to run and debug inside your IDE. There are three supported approaches for testing with Spring in Camel.



 Name 
 Testing Frameworks Supported 
 Description 
 Required Camel Test Dependencies 


 CamelSpringTestSupport 

	JUnit 3.x (deprecated)
	JUnit 4.x
	TestNG - Camel 2.8


 Provided by org.apache.camel.test.CamelSpringTestSupport, org.apache.camel.test.junit4.CamelSpringTestSupport, and org.apache.camel.testng.CamelSpringTestSupport. These base classes provide feature parity withthe simple CamelTestSupport classes fromCamel Testbut do not support Spring annotations on the test class such as @Autowired,@DirtiesContext, and@ContextConfiguration.  

	JUnit 3.x (deprecated) - camel-test-spring
	JUnit 4.x camel-test-spring
	TestNG - camel-test-ng




 Plain Spring Test  

	JUnit 3.x
	JUnit 4.x
	TestNG


 Extend the abstract base classes (org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests,org.springframework.test.context.junit38.AbstractJUnit4SpringContextTests, etc.)provided in Spring Test or use the Spring Test JUnit4 runner. These approaches support both the Camel annotations and Spring annotations, but do not have feature parity withorg.apache.camel.test.CamelTestSupport, org.apache.camel.test.junit4.CamelTestSupport, and org.apache.camel.testng.CamelSpringTestSupport.  

	JUnit 3.x (deprecated) - None
	JUnit 4.x None
	TestNG - None




 Camel Enhanced Spring Test  

	JUnit 4.x - Camel 2.10
	TestNG - Camel 2.10


 Use the org.apache.camel.test.junit4.CamelSpringJUnit4ClassRunnerrunner with the@RunWithannotation or extend org.apache.camel.testng.AbstractCamelTestNGSpringContextTeststo enable feature parity with org.apache.camel.test.CamelTestSupport and org.apache.camel.test.junit4.CamelTestSupport and also support the full suite of Spring Test annotations such as@Autowired,@DirtiesContext, and @ContextConfiguration. 

	JUnit 3.x (deprecated) - camel-test-spring
	JUnit 4.x camel-test-spring
	TestNG - camel-test-ng







CamelSpringTestSupport

org.apache.camel.test.CamelSpringTestSupport, org.apache.camel.test.junit4.CamelSpringTestSupport, and org.apache.camel.testng.CamelSpringTestSupportextend their non-Spring aware counterparts (org.apache.camel.test.CamelTestSupport, org.apache.camel.test.junit4.CamelTestSupport, and org.apache.camel.testng.CamelTestSupport) and deliver integration with Spring into your test classes. Instead ofinstantiatingthe CamelContext and routes programmatically, these classes rely on a Spring context to wire the needed components together. If your test extends one of these classes, you must provide the Spring context by implementing the following method.



protected abstract AbstractApplicationContext createApplicationContext();


You are responsible for the instantiation of the Spring context in the method implementation. All of the features available in the non-Spring aware counterparts from Camel Test are available in your test.

Plain Spring Test

In this approach, your test classes directly inherit from the Spring Test abstract test classes or use the JUnit 4.x test runner provided in Spring Test. This approach supportsdependencyinjection into your test class and the full suite of Spring Test annotations but does not support the features provided by the CamelSpringTestSupport classes.

Plain Spring Test using JUnit 3.x with XML Config Example

Here is a simple unit test using JUnit 3.x support from Spring Test usingXML Config.

@ContextConfiguration
public class FilterTest extends 

[CONF] Apache Camel Spring Web Services

2012-02-11 Thread confluence







Spring Web Services
Page edited by Babak Vahdat


 Changes (1)
 




...
| {{wsAddressingAction}} | No | WS-Addressing 1.0 action header to include when accessing web services. The {{To}} header is set to the _address_ of the web service as specified in the endpoint URI (default Spring-WS behavior). | | {{_expression_}} | Only when _mapping-type_ is {{xpathresult}} | XPath _expression_ to use in the process of mapping web service requests, should match the result specified by {{xpathresult}} | 
| {{timeout}} | No | *Camel 2.10:* Sets the socket read timeout (in milliseconds) while invoking a webservice using the producer, see [URLConnection|http://docs.oracle.com/javase/6/docs/api/java/net/URLConnection.html#setReadTimeout%28int%29] [URLConnection.setReadTimeout()|http://docs.oracle.com/javase/6/docs/api/java/net/URLConnection.html#setReadTimeout(int)] and [CommonsHttpMessageSender|http://static.springsource.org/spring-ws/site/apidocs/org/springframework/ws/transport/http/CommonsHttpMessageSender.html#setReadTimeout%28int%29] [CommonsHttpMessageSender.setReadTimeout()|http://static.springsource.org/spring-ws/site/apidocs/org/springframework/ws/transport/http/CommonsHttpMessageSender.html#setReadTimeout(int)] | 
{div}  
...


Full Content

Spring Web Services Component
Available as of Camel 2.6

The spring-ws: component allows you to integrate with Spring Web Services. It offers both client-side support, for accessing web services, and server-side support for creating your own contract-first web services.

Maven users will need to add the following dependency to their pom.xml for this component:



dependency
	groupIdorg.apache.camel/groupId
	artifactIdcamel-spring-ws/artifactId
	versionx.x.x/version
	!-- use the same version as your Camel core version --
/dependency



DependenciesAs of Camel 2.8 this component ships with Spring-WS 2.0.x which (like the rest of Camel) requires Spring 3.0.x. 

Earlier Camel versions shipped Spring-WS 1.5.9 which is compatible with Spring 2.5.x and 3.0.x. In order to run earlier versions of camel-spring-ws on Spring 2.5.x you need to add the spring-webmvc module from Spring 2.5.x. In order to run Spring-WS 1.5.9 on Spring 3.0.x you need to exclude the OXM module from Spring 3.0.x as this module is also included in Spring-WS 1.5.9 (see this post)

URI format

The URI scheme for this component is as follows



spring-ws:[mapping-type:]address[?options]



To expose a web service mapping-type needs to be set to any of the following:




 Mapping type 
 Description 


 rootqname 
 Offers the option to map web service requests based on the qualified name of the root element contained in the message. 


 soapaction 
 Used to map web service requests based on the SOAP action specified in the header of the message. 


 uri 
 In order to map web service requests that target a specific URI. 


 xpathresult 
 Used to map web service requests based on the evaluation of an XPath _expression_ against the incoming message. The result of the evaluation should match the XPath result specified in the endpoint URI. 


 beanname 
 Allows you to reference a org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher in order to integrate with existing (legacy) endpoint mappings like PayloadRootQNameEndpointMapping, SoapActionEndpointMapping, etc 





As a consumer the address should contain a value relevant to the specified mapping-type (e.g. a SOAP action, XPath _expression_). As a producer the address should be set to the URI of the web service your calling upon.

You can append query options to the URI in the following format, ?option=valueoption=value...

Options




 Name 
 Required? 
 Description 


 soapAction 
 No 
 SOAP action to include inside a SOAP request when accessing remote web services 


 wsAddressingAction 
 No 
 WS-Addressing 1.0 action header to include when accessing web services. The To header is set to the address of the web service as specified in the endpoint URI (default Spring-WS behavior). 


 _expression_ 
 Only when mapping-type is xpathresult 
 XPath _expression_ to use in the process of mapping web service requests, should match the result specified by xpathresult 


 timeout 
 No 
 Camel 2.10: Sets the socket read timeout (in milliseconds) while invoking a webservice using the producer, see URLConnection.setReadTimeout() and CommonsHttpMessageSender.setReadTimeout() 





Registry based options

The following options can be specified in the registry (most likely a Spring ApplicationContext) and referenced from the endpoint URI using the # notation.




 Name 
 Required? 
 Description 


 webServiceTemplate 
 No 
 Option to provide a custom WebServiceTemplate. This allows for full control over  

[CONF] Apache Camel Spring Web Services

2012-02-09 Thread confluence







Spring Web Services
Page edited by Babak Vahdat


 Changes (1)
 




...
| {{wsAddressingAction}} | No | WS-Addressing 1.0 action header to include when accessing web services. The {{To}} header is set to the _address_ of the web service as specified in the endpoint URI (default Spring-WS behavior). | | {{_expression_}} | Only when _mapping-type_ is {{xpathresult}} | XPath _expression_ to use in the process of mapping web service requests, should match the result specified by {{xpathresult}} | 
| {{timeout}} | No | *Camel 2.10:* Sets the socket read timeout while invoking a webservice using the producer, see [URLConnection|http://docs.oracle.com/javase/6/docs/api/java/net/URLConnection.html#setReadTimeout%28int%29] and [CommonsHttpMessageSender|http://static.springsource.org/spring-ws/site/apidocs/org/springframework/ws/transport/http/CommonsHttpMessageSender.html#setReadTimeout%28int%29] | 
{div}  
...


Full Content

Spring Web Services Component
Available as of Camel 2.6

The spring-ws: component allows you to integrate with Spring Web Services. It offers both client-side support, for accessing web services, and server-side support for creating your own contract-first web services.

Maven users will need to add the following dependency to their pom.xml for this component:



dependency
	groupIdorg.apache.camel/groupId
	artifactIdcamel-spring-ws/artifactId
	versionx.x.x/version
	!-- use the same version as your Camel core version --
/dependency



DependenciesAs of Camel 2.8 this component ships with Spring-WS 2.0.x which (like the rest of Camel) requires Spring 3.0.x. 

Earlier Camel versions shipped Spring-WS 1.5.9 which is compatible with Spring 2.5.x and 3.0.x. In order to run earlier versions of camel-spring-ws on Spring 2.5.x you need to add the spring-webmvc module from Spring 2.5.x. In order to run Spring-WS 1.5.9 on Spring 3.0.x you need to exclude the OXM module from Spring 3.0.x as this module is also included in Spring-WS 1.5.9 (see this post)

URI format

The URI scheme for this component is as follows



spring-ws:[mapping-type:]address[?options]



To expose a web service mapping-type needs to be set to any of the following:




 Mapping type 
 Description 


 rootqname 
 Offers the option to map web service requests based on the qualified name of the root element contained in the message. 


 soapaction 
 Used to map web service requests based on the SOAP action specified in the header of the message. 


 uri 
 In order to map web service requests that target a specific URI. 


 xpathresult 
 Used to map web service requests based on the evaluation of an XPath _expression_ against the incoming message. The result of the evaluation should match the XPath result specified in the endpoint URI. 


 beanname 
 Allows you to reference a org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher in order to integrate with existing (legacy) endpoint mappings like PayloadRootQNameEndpointMapping, SoapActionEndpointMapping, etc 





As a consumer the address should contain a value relevant to the specified mapping-type (e.g. a SOAP action, XPath _expression_). As a producer the address should be set to the URI of the web service your calling upon.

You can append query options to the URI in the following format, ?option=valueoption=value...

Options




 Name 
 Required? 
 Description 


 soapAction 
 No 
 SOAP action to include inside a SOAP request when accessing remote web services 


 wsAddressingAction 
 No 
 WS-Addressing 1.0 action header to include when accessing web services. The To header is set to the address of the web service as specified in the endpoint URI (default Spring-WS behavior). 


 _expression_ 
 Only when mapping-type is xpathresult 
 XPath _expression_ to use in the process of mapping web service requests, should match the result specified by xpathresult 


 timeout 
 No 
 Camel 2.10: Sets the socket read timeout while invoking a webservice using the producer, see URLConnection and CommonsHttpMessageSender 





Registry based options

The following options can be specified in the registry (most likely a Spring ApplicationContext) and referenced from the endpoint URI using the # notation.




 Name 
 Required? 
 Description 


 webServiceTemplate 
 No 
 Option to provide a custom WebServiceTemplate. This allows for full control over  client-side web services handling; like adding a custom interceptor or specifying a fault resolver, message sender or message factory. 


 messageSender 
 No 
 Option to provide a custom WebServiceMessageSender. For example to perform authentication or use alternative transports 


 messageFactory 
 No 
 Option to provide a custom WebServiceMessageFactory. For example when you want 

[CONF] Apache Camel Spring Web Services

2012-02-09 Thread confluence







Spring Web Services
Page edited by Babak Vahdat


 Changes (1)
 




...
| {{wsAddressingAction}} | No | WS-Addressing 1.0 action header to include when accessing web services. The {{To}} header is set to the _address_ of the web service as specified in the endpoint URI (default Spring-WS behavior). | | {{_expression_}} | Only when _mapping-type_ is {{xpathresult}} | XPath _expression_ to use in the process of mapping web service requests, should match the result specified by {{xpathresult}} | 
| {{timeout}} | No | *Camel 2.10:* Sets the socket read timeout (in milliseconds) while invoking a webservice using the producer, see [URLConnection|http://docs.oracle.com/javase/6/docs/api/java/net/URLConnection.html#setReadTimeout%28int%29] and [CommonsHttpMessageSender|http://static.springsource.org/spring-ws/site/apidocs/org/springframework/ws/transport/http/CommonsHttpMessageSender.html#setReadTimeout%28int%29] | 
{div}  
...


Full Content

Spring Web Services Component
Available as of Camel 2.6

The spring-ws: component allows you to integrate with Spring Web Services. It offers both client-side support, for accessing web services, and server-side support for creating your own contract-first web services.

Maven users will need to add the following dependency to their pom.xml for this component:



dependency
	groupIdorg.apache.camel/groupId
	artifactIdcamel-spring-ws/artifactId
	versionx.x.x/version
	!-- use the same version as your Camel core version --
/dependency



DependenciesAs of Camel 2.8 this component ships with Spring-WS 2.0.x which (like the rest of Camel) requires Spring 3.0.x. 

Earlier Camel versions shipped Spring-WS 1.5.9 which is compatible with Spring 2.5.x and 3.0.x. In order to run earlier versions of camel-spring-ws on Spring 2.5.x you need to add the spring-webmvc module from Spring 2.5.x. In order to run Spring-WS 1.5.9 on Spring 3.0.x you need to exclude the OXM module from Spring 3.0.x as this module is also included in Spring-WS 1.5.9 (see this post)

URI format

The URI scheme for this component is as follows



spring-ws:[mapping-type:]address[?options]



To expose a web service mapping-type needs to be set to any of the following:




 Mapping type 
 Description 


 rootqname 
 Offers the option to map web service requests based on the qualified name of the root element contained in the message. 


 soapaction 
 Used to map web service requests based on the SOAP action specified in the header of the message. 


 uri 
 In order to map web service requests that target a specific URI. 


 xpathresult 
 Used to map web service requests based on the evaluation of an XPath _expression_ against the incoming message. The result of the evaluation should match the XPath result specified in the endpoint URI. 


 beanname 
 Allows you to reference a org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher in order to integrate with existing (legacy) endpoint mappings like PayloadRootQNameEndpointMapping, SoapActionEndpointMapping, etc 





As a consumer the address should contain a value relevant to the specified mapping-type (e.g. a SOAP action, XPath _expression_). As a producer the address should be set to the URI of the web service your calling upon.

You can append query options to the URI in the following format, ?option=valueoption=value...

Options




 Name 
 Required? 
 Description 


 soapAction 
 No 
 SOAP action to include inside a SOAP request when accessing remote web services 


 wsAddressingAction 
 No 
 WS-Addressing 1.0 action header to include when accessing web services. The To header is set to the address of the web service as specified in the endpoint URI (default Spring-WS behavior). 


 _expression_ 
 Only when mapping-type is xpathresult 
 XPath _expression_ to use in the process of mapping web service requests, should match the result specified by xpathresult 


 timeout 
 No 
 Camel 2.10: Sets the socket read timeout (in milliseconds) while invoking a webservice using the producer, see URLConnection and CommonsHttpMessageSender 





Registry based options

The following options can be specified in the registry (most likely a Spring ApplicationContext) and referenced from the endpoint URI using the # notation.




 Name 
 Required? 
 Description 


 webServiceTemplate 
 No 
 Option to provide a custom WebServiceTemplate. This allows for full control over  client-side web services handling; like adding a custom interceptor or specifying a fault resolver, message sender or message factory. 


 messageSender 
 No 
 Option to provide a custom WebServiceMessageSender. For example to perform authentication or use alternative transports 


 messageFactory 
 No 
 Option to provide a custom 

[CONF] Apache Camel Spring

2012-01-13 Thread confluence







Spring
Page edited by Claus Ibsen


 Changes (4)
 




...
   xmlns:xsi=http://www.w3.org/2001/XMLSchema-instancexsi:schemaLocation= 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/beans/spring-beans.xsd 
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd {code} 
...
Or you can refer to camel XSD in the XML declaration: {code} 
xmlns:camel=http://activemq.apache.org/camel/schema/spring xmlns:camel=http://camel.apache.org/schema/spring 
{code} ... so the declaration is: 
...
Camel also provides a powerful feature that allows for the automatic discovery and initialization of routes in given packages. This is configured by adding tags to the camel context in your spring context definition, specifying the packages to be recursively searched for [RouteBuilder] implementations. To use this feature in 1.X, requires a package/package tag specifying a comma separated list of packages that should be searched e.g. {code:xml} 
camelContext http://activemq.apache.org/camel/schema/spring xmlns=http://camel.apache.org/schema/spring 
packageorg.apache.camel.spring.config.scan.route/package   /camelContext 
...
 {info:title=Will ignore already instantiated classes} 
The package and packageScan will skip any classes which has already been created by Spring etc. So if you define a route builder as a spring bean tag then that class will be skipped. You can include those beans using {{routeBuilder ref=theBeanId/}} or the {{contextScan/}} feature. 
{info}  
...


Full Content

Spring Support

Apache Camel is designed to work nicely with the Spring Framework in a number of ways.

	Camel uses Spring Transactions as the default transaction handling in components like JMS and JPA
	Camel works with Spring 2 XML processing with the Xml Configuration
	Camel Spring XML Schema's is defined at Xml Reference
	Camel supports a powerful version of Spring Remoting which can use powerful routing between the client and server side along with using all of the available Components for the transport
	Camel provides powerful Bean Integration with any bean defined in a Spring ApplicationContext
	Camel integrates with various Spring helper classes; such as providing Type Converter support for Spring Resources etc
	Allows Spring to dependency inject Component instances or the CamelContext instance itself and auto-expose Spring beans as components and endpoints.
	Allows you to reuse the Spring Testing framework to simplify your unit and integration testing using Enterprise Integration Patterns and Camel's powerful Mock and Test endpoints



Using Spring to configure the CamelContext

You can configure a CamelContext inside any spring.xml using the CamelContextFactoryBean. This will automatically start the CamelContext along with any referenced Routes along any referenced Component and Endpoint instances.


	Adding Camel schema
	Configure Routes in two ways:
	
		Using Java Code
		Using Spring XML
	
	



Adding Camel Schema
For Camel 1.x you need to use the following namespace:


http://activemq.apache.org/camel/schema/spring


with the following schema location:


http://activemq.apache.org/camel/schema/spring/camel-spring.xsd


You need to add Camel to the schemaLocation declaration


http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd



So the XML file looks like this:


beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"



Using camel: namespace
Or you can refer to camel XSD in the XML declaration:


xmlns:camel="http://camel.apache.org/schema/spring"


... so the declaration is:

beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:camel="http://camel.apache.org/schema/spring"
   xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"


... and then use the camel: namespace prefix, and you can omit the inline namespace declaration:

camel:camelContext id="camel5"
  

[CONF] Apache Camel Spring Testing

2011-12-13 Thread confluence







Spring Testing
Page edited by Claus Ibsen


 Changes (1)
 




...
{code}  
You can overload the method {{createApplicationContext}} to provide the Spring ApplicationContext that isnt following the above default. For instance: {code:java}   protected AbstractXmlApplicationContext createApplicationContext() { return new ClassPathXmlApplicationContext(/config/MySpringConfig.xml);   } {code}  Then the test method will then run which invokes the [MockEndpoint.assertIsSatisfied(camelContext) method|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#assertIsSatisfied(org.apache.camel.CamelContext)] which asserts that all of the [Mock] and [Test] endpoints have their expectations met.  xml}  
h3. Spring Test with Java Config Example  
...


Full Content

Spring Testing

Testing is a crucial part of any development or integration work. The Spring Framework offers a number of features that makes it easy to test while using Spring for Inversion of Control which works with JUnit 3.x, JUnit 4.x or TestNG.

We can reuse Spring for IoC and the Camel Mock and Test endpoints to create sophisticated integration tests that are easy to run and debug inside your IDE.

For example here is a simple unit test



import org.apache.camel.CamelContext;
import org.apache.camel.component.mock.MockEndpoint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;

@ContextConfiguration
public class MyCamelTest extends AbstractJUnit38SpringContextTests {

@Autowired
protected CamelContext camelContext;

public void testMocksAreValid() throws Exception {
MockEndpoint.assertIsSatisfied(camelContext);
}
}



This test will load a Spring XML configuration file called MyCamelTest-context.xml from the classpath in the same package structure as the MyCamelTest class and initialize it along with any Camel routes we define inside it, then inject the CamelContext instance into our test case.

For instance, like this maven folder layout:


src/main/java/com/mycompany/MyCamelTest.class
src/main/resources/com/mycompany/MyCamelTest-context.xml



Spring Test with Java Config Example

You can completely avoid using an XML configuration file by using Spring Java Config.

Here is an example using Java Config.


@ContextConfiguration(
locations = "org.apache.camel.spring.javaconfig.patterns.FilterTest$ContextConfig",
loader = JavaConfigContextLoader.class)
public class FilterTest extends AbstractJUnit4SpringContextTests {

@EndpointInject(uri = "mock:result")
protected MockEndpoint resultEndpoint;

@Produce(uri = "direct:start")
protected ProducerTemplate template;

@DirtiesContext
@Test
public void testSendMatchingMessage() throws Exception {
String expectedBody = "matched/";

resultEndpoint.expectedBodiesReceived(expectedBody);

template.sendBodyAndHeader(expectedBody, "foo", "bar");

resultEndpoint.assertIsSatisfied();
}

@DirtiesContext
@Test
public void testSendNotMatchingMessage() throws Exception {
resultEndpoint.expectedMessageCount(0);

template.sendBodyAndHeader("notMatched/", "foo", "notMatchedHeaderValue");

resultEndpoint.assertIsSatisfied();
}

@Configuration
public static class ContextConfig extends SingleRouteCamelConfiguration {
@Bean
public RouteBuilder route() {
return new RouteBuilder() {
public void configure() {
from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
}
};
}
}
}



This is similar to the XML Config example above except that there is no XML file and instead the nested ContextConfig class does all of the configuration; so your entire test case is contained in a single Java class. We currently have to reference by class name this class in the @ContextConfiguration which is a bit ugly. Please vote for SJC-238 to address this and make Spring Test work more cleanly with Spring JavaConfig.

Adding more Mock expectations

If you wish to programmatically add any new assertions to your test you can easily do so with the following. Notice how we use @EndpointInject to inject a Camel endpoint into our code then the Mock API to add an expectation on a specific message.



@ContextConfiguration
public class MyCamelTest extends AbstractJUnit38SpringContextTests {

@Autowired
protected CamelContext camelContext;

@EndpointInject(uri = "mock:foo")
protected MockEndpoint foo;

  

[CONF] Apache Camel Spring Web Services

2011-03-02 Thread confluence







Spring Web Services
Page edited by Christian Mueller


Comment:
Reverted from v. 18


 Changes (3)
 




...
{code}  
{warning:title=running Spring Web Services Component 2.7 in OSGI} Because of issue [SWS-681|https://jira.springsource.org/browse/SWS-681] in Spring-WS, this component cannot be used in an OSGI environment out of the box. When the Spring guys fixed this issue, announced for 2.0.1.RELEASE, you have to update the dependent OSGI bundle org.springframework.ws/spring-ws-core to 2.0.1.RELEASE or newer. {warning} 
{info:title=Dependencies}This component offers support for Spring-WS 1.5.9 which is compatible with Spring 2.5.x and 3.0.x. In order to run camel-spring-ws on Spring 2.5.x you need to add the spring-webmvc module from Spring 2.5.x. 
 
In order to run Spring-WS 1.5.9 on Spring 3.0 you need to exclude the OXM module from Spring 3.0 as this module is also included in Spring-WS 1.5.9 (see [this post|http://stackoverflow.com/questions/3313314/can-spring-ws-1-5-be-used-with-spring-3]) {info}  
h3. URI format  
...


Full Content

Spring Web Services Component
Available as of Camel 2.6

The spring-ws: component allows you to integrate with Spring Web Services. It offers both client-side support, for accessing web services, and server-side support for creating your own contract-first web services.

Maven users will need to add the following dependency to their pom.xml for this component:



dependency
	groupIdorg.apache.camel/groupId
	artifactIdcamel-spring-ws/artifactId
	versionx.x.x/version
	!-- use the same version as your Camel core version --
/dependency



DependenciesThis component offers support for Spring-WS 1.5.9 which is compatible with Spring 2.5.x and 3.0.x.
In order to run camel-spring-ws on Spring 2.5.x you need to add the spring-webmvc module from Spring 2.5.x.

In order to run Spring-WS 1.5.9 on Spring 3.0 you need to exclude the OXM module from Spring 3.0 as this module is also included in Spring-WS 1.5.9 (see this post)

URI format

The URI scheme for this component is as follows



spring-ws:[mapping-type:]address[?options]



To expose a web service mapping-type needs to be set to any of the following:




 Mapping type 
 Description 


 rootqname 
 Offers the option to map web service requests based on the qualified name of the root element contained in the message. 


 soapaction 
 Used to map web service requests based on the SOAP action specified in the header of the message. 


 uri 
 In order to map web service requests that target a specific URI. 


 xpathresult 
 Used to map web service requests based on the evaluation of an XPath _expression_ against the incoming message. The result of the evaluation should match the XPath result specified in the endpoint URI. 


 beanname 
 Allows you to reference a org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher in order to integrate with existing (legacy) endpoint mappings like PayloadRootQNameEndpointMapping, SoapActionEndpointMapping, etc 





As a consumer the address should contain a value relevant to the specified mapping-type (e.g. a SOAP action, XPath _expression_). As a producer the address should be set to the URI of the web service your calling upon.

You can append query options to the URI in the following format, ?option=valueoption=value...

Options




 Name 
 Required? 
 Description 


 soapAction 
 No 
 SOAP action to include inside a SOAP request when accessing remote web services 


 wsAddressingAction 
 No 
 WS-Addressing 1.0 action header to include when accessing web services. The To header is set to the address of the web service as specified in the endpoint URI (default Spring-WS behavior). 


 _expression_ 
 Only when mapping-type is xpathresult 
 XPath _expression_ to use in the process of mapping web service requests, should match the result specified by xpathresult 





Registry based options

The following options can be specified in the registry (most likely a Spring ApplicationContext) and referenced from the endpoint URI using the # notation.




 Name 
 Required? 
 Description 


 webServiceTemplate 
 No 
 Option to provide a custom WebServiceTemplate. This allows for full control over  client-side web services handling; like adding a custom interceptor or specifying a fault resolver, message sender or message factory. 


 messageSender 
 No 
 Option to provide a custom WebServiceMessageSender. For example to perform authentication or use alternative transports 


 messageFactory 
 No 
 Option to provide a custom WebServiceMessageFactory. For example when you want Apache Axiom to handle web service messages instead of SAAJ 


 transformerFactory 
 No 
 Option to 

[CONF] Apache Camel spring ws example

2011-01-08 Thread confluence







spring ws example
Page  added by Richard Kettelerij

 

 todo


   
Change Notification Preferences
   
   View Online
  |
   Add Comment
   








[CONF] Apache Camel Spring Web Services

2011-01-08 Thread confluence







Spring Web Services
Page edited by Richard Kettelerij


Comment:
CAMEL-3472 add example of Spring Web Services component


 Changes (1)
 



...
{code}  
More information on setting up Spring-WS can be found in [Writing Contract-First Web Services|http://static.springsource.org/spring-ws/sites/1.5/reference/html/tutorial.html]. Basically paragraph 3.6 Implementing the Endpoint is handled by this component (specifically paragraph 3.6.2 Routing the Message to the Endpoint is where {{CamelEndpointMapping}} comes in). Also dont forget to check out the [Spring Web Services Example|spring ws example] included in the Camel distribution. 
 h3. Endpoint mapping in routes 
...

Full Content

Spring Web Services Component
Available as of Camel 2.6

The spring-ws: component allows you to integrate with Spring Web Services. It offers both client-side support, for accessing web services, and server-side support for creating your own contract-first web services.

Maven users will need to add the following dependency to their pom.xml for this component:



dependency
	groupIdorg.apache.camel/groupId
	artifactIdcamel-spring-ws/artifactId
	versionx.x.x/version
	!-- use the same version as your Camel core version --
/dependency



DependenciesThis component offers support for Spring-WS 1.5.9 which is compatible with Spring 2.5.x and 3.0.x.
In order to run camel-spring-ws on Spring 2.5.x you need to add the spring-webmvc module from Spring 2.5.x.

In order to run Spring-WS 1.5.9 on Spring 3.0 you need to exclude the OXM module from Spring 3.0 as this module is also included in Spring-WS 1.5.9 (see this post)

URI format

The URI scheme for this component is as follows



spring-ws:[mapping-type:]address[?options]



To expose a web service mapping-type needs to be set to any of the following:




 Mapping type 
 Description 


 rootqname 
 Offers the option to map web service requests based on the qualified name of the root element contained in the message. 


 soapaction 
 Used to map web service requests based on the SOAP action specified in the header of the message. 


 uri 
 In order to map web service requests that target a specific URI. 


 xpathresult 
 Used to map web service requests based on the evaluation of an XPath _expression_ against the incoming message. The result of the evaluation should match the XPath result specified in the endpoint URI. 


 beanname 
 Allows you to reference a org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher in order to integrate with existing (legacy) endpoint mappings like PayloadRootQNameEndpointMapping, SoapActionEndpointMapping, etc 





As a consumer the address should contain a value relevant to the specified mapping-type (e.g. a SOAP action, XPath _expression_). As a producer the address should be set to the URI of the web service your calling upon.

You can append query options to the URI in the following format, ?option=valueoption=value...

Options




 Name 
 Required? 
 Description 


 soapAction 
 No 
 SOAP action to include inside a SOAP request when accessing remote web services 


 wsAddressingAction 
 No 
 WS-Addressing 1.0 action header to include when accessing web services. The To header is set to the address of the web service as specified in the endpoint URI (default Spring-WS behavior). 


 _expression_ 
 Only when mapping-type is xpathresult 
 XPath _expression_ to use in the process of mapping web service requests, should match the result specified by xpathresult 





Registry based options

The following options can be specified in the registry (most likely a Spring ApplicationContext) and referenced from the endpoint URI using the # notation.




 Name 
 Required? 
 Description 


 webServiceTemplate 
 No 
 Option to provide a custom WebServiceTemplate. This allows for full control over  client-side web services handling; like adding a custom interceptor or specifying a fault resolver, message sender or message factory. 


 messageSender 
 No 
 Option to provide a custom WebServiceMessageSender. For example to perform authentication or use alternative transports 


 messageFactory 
 No 
 Option to provide a custom WebServiceMessageFactory. For example when you want Apache Axiom to handle web service messages instead of SAAJ 


 transformerFactory 
 No 
 Option to override default TransformerFactory. The provided transformer factory must be of type javax.xml.transform.TransformerFactory 


 endpointMapping 
 Only when mapping-type is rootqname, soapaction, uri or xpathresult 
 Reference to org.apache.camel.component.spring.ws.bean.CamelEndpointMapping in the Registry/ApplicationContext. Only one bean is required in the registry to serve all Camel/Spring-WS endpoints. This bean is 

[CONF] Apache Camel spring ws example

2011-01-08 Thread confluence







spring ws example
Page edited by Richard Kettelerij


 Changes (3)
 



h2. Spring Web Services Example *Available as of Camel 2.6* 
todo   
This example shows how to expose a SOAP-based web service using Camel and Spring Web Services.  h3. Running the example  The example is included in the distribution at {{examples/camel-example-spring-ws}}. To start the example use Maven: {code} mvn clean install jetty:run {code} This will expose a web service on {{http://localhost:8080/increment}}. With the help of a tool such as [Soap-UI|http://www.soap-ui.org] its easy to sent messages to this endpoint. Theres a ready to use SOAP-UI project available at {{examples/camel-example-spring-ws/client}}.  h3. Code walk through  The Camel route exposing the above web service is defined as: {code:Java} JaxbDataFormat jaxb = new JaxbDataFormat(false); jaxb.setContextPath(org.apache.camel.example.server.model);  from(spring-ws:rootqname:{http://camel.apache.org/example/increment}incrementRequest?endpointMapping=#endpointMapping) .unmarshal(jaxb) .process(new IncrementProcessor()) .marshal(jaxb); {code}  Taking a closer look at the URI reveals that this route consumes messages with a certain {{rootqname}}. In this case it listens for messages with root element {{incrementRequest}} defined in the {{http://camel.apache.org/example/increment}} namespace. These XML messages are unmarshalled to objects using Camels [Data Format] support (JAXB in this case). After processing the resulting object is marshalled back to XML and returned to the client as a response.  Further notice that the URI contains a reference to an {{endpointMapping}} in the [Registry]. Since were using Spring the registry is a Spring ApplicationContext defined in {{spring-ws-servlet.xml}}. This file contains the following bean:  {code:XML} bean id=endpointMapping class=org.apache.camel.component.spring.ws.bean.CamelEndpointMapping 	property name=interceptors 		list 			ref local=validatingInterceptor / 			ref local=loggingInterceptor / 		/list 	/property /bean {code}  This bean is a Spring-WS [endpoint mapping|http://static.springsource.org/spring-ws/sites/1.5/reference/html/server.html#server-endpoint-mapping] that maps incoming messages to the appropriate Camel routes. Youll only need to define a single {{CamelEndpointMapping}}, regardless of the number of Camel routes implementing Spring-WS endpoints.   The above endpoint mapping bean is automatically picked up by the {{MessageDispatcherServlet}} declared in {{web.xml}}: {code:XML} servlet 	servlet-namespring-ws/servlet-name 	servlet-classorg.springframework.ws.transport.http.MessageDispatcherServlet/servlet-class /servlet {code} Since the servlet is named {{spring-ws}} it will look for a file named {{/WEB-INF/spring-ws-servlet.xml}}. 

Full Content

Spring Web Services Example
Available as of Camel 2.6

This example shows how to expose a SOAP-based web service using Camel and Spring Web Services.

Running the example

The example is included in the distribution at examples/camel-example-spring-ws. To start the example use Maven:


mvn clean install jetty:run


This will expose a web service on http://localhost:8080/increment. With the help of a tool such as Soap-UI it's easy to sent messages to this endpoint. There's a ready to use SOAP-UI project available at examples/camel-example-spring-ws/client.

Code walk through

The Camel route exposing the above web service is defined as:


JaxbDataFormat jaxb = new JaxbDataFormat(false);
jaxb.setContextPath("org.apache.camel.example.server.model");

from("spring-ws:rootqname:{http://camel.apache.org/example/increment}incrementRequest?endpointMapping=#endpointMapping")
.unmarshal(jaxb)
.process(new IncrementProcessor())
.marshal(jaxb);



Taking a closer look at the URI reveals that this route consumes messages with a certain rootqname. In this case it listens for messages with root element incrementRequest defined in the http://camel.apache.org/example/increment namespace. These XML messages are unmarshalled to objects using Camel's Data Format support (JAXB in this case). After processing the resulting object is marshalled back to XML and returned to the client as a response.

Further notice that the URI contains a reference to an endpointMapping in the Registry. Since we're using Spring the registry is a Spring ApplicationContext defined in spring-ws-servlet.xml. This file contains the following bean:



bean id="endpointMapping" class="org.apache.camel.component.spring.ws.bean.CamelEndpointMapping"
	property name="interceptors"
		list
			ref local="validatingInterceptor" /
			ref local="loggingInterceptor" /
		/list
	/property
/bean



This bean is a Spring-WS endpoint mapping that maps incoming messages to the appropriate Camel routes. You'll only need to 

[CONF] Apache Camel Spring WS Example

2011-01-08 Thread confluence







Spring WS Example
Page edited by Richard Kettelerij


 Changes (0)
 



...

Full Content

Spring Web Services Example
Available as of Camel 2.6

This example shows how to expose a SOAP-based web service using Camel and Spring Web Services.

Running the example

The example is included in the distribution at examples/camel-example-spring-ws. To start the example use Maven:


mvn clean install jetty:run


This will expose a web service on http://localhost:8080/increment. With help of a tool such as Soap-UI it's easy to sent messages to this endpoint. There's a ready to use SOAP-UI project available at examples/camel-example-spring-ws/client.

Code walk through

The Camel route that exposes the above web service is defined as:


JaxbDataFormat jaxb = new JaxbDataFormat(false);
jaxb.setContextPath("org.apache.camel.example.server.model");

from("spring-ws:rootqname:{http://camel.apache.org/example/increment}incrementRequest?endpointMapping=#endpointMapping")
.unmarshal(jaxb)
.process(new IncrementProcessor())
.marshal(jaxb);



Taking a closer look at the URI reveals that this route consumes messages with a certain rootqname. In this case it listens for messages with root element incrementRequest defined in the http://camel.apache.org/example/increment namespace. These XML messages are unmarshalled to Java objects using Camel's Data Format support. After processing the resulting object is marshalled back to XML and returned to the client.

Further notice that the URI contains a reference to an endpointMapping in the Registry. Since we're using Spring the registry is a Spring ApplicationContext defined in spring-ws-servlet.xml. This file contains the following bean:



bean id="endpointMapping" class="org.apache.camel.component.spring.ws.bean.CamelEndpointMapping"
	property name="interceptors"
		list
			ref local="validatingInterceptor" /
			ref local="loggingInterceptor" /
		/list
	/property
/bean



This bean is a Spring-WS endpoint mapping that maps incoming messages to appropriate Camel routes. You'll only need to define one CamelEndpointMapping regardless of the number of Camel routes that use Spring-WS endpoints. 

The above endpointMapping bean is automatically picked up by the MessageDispatcherServlet declared in web.xml:


servlet
	servlet-namespring-ws/servlet-name
	servlet-classorg.springframework.ws.transport.http.MessageDispatcherServlet/servlet-class
/servlet


Since the servlet is named spring-ws it will look for the file /WEB-INF/spring-ws-servlet.xml containing the earlier mentioned endpointMapping bean.



Change Notification Preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Spring Web Services

2010-11-04 Thread confluence







Spring Web Services
Page edited by Claus Ibsen


 Changes (12)
 



...
*Available as of Camel 2.6*  
The *spring-ws:* component allows you to integrate with [Spring Web Services|http://static.springsource.org/spring-ws/sites/1.5/]. It offers both _client_-side support, for accessing web services, and _server_-side support for creating your own contract-first web services. 
 Maven users will need to add the following dependency to their {{pom.xml}} for this component: 
...
 {code} 
spring-ws:[mapping-type:]address[?options] 
{code}  
...
To call a web service at {{http://foo.com/bar}} simply define a route: {code} 
from(direct:example).to(spring-ws:http://foo.com/bar) 
{code}  
...
{code} from(direct:example) 
.to(spring-ws:http://foo.com/bar?soapAction=http://foo.comwsAddressingAction=http://bar.com) 
{code}  
...
{code} from(direct:example) 
.to(spring-ws:http://foo.com/bar?messageFactory=#messageFactorymessageSender=#messageSender) 
{code}  
...
The following route will receive all web service requests that have a root element named GetFoo within the {{http://example.com/}} namespace. {code} 
from(spring-ws:rootqname:{http://example.com/}GetFoo?endpointMapping=#endpointMapping) 
.convertBodyTo(String.class).to(mock:example) {code} 
...
The following route will receive web service requests containing the {{http://example.com/GetFoo}} SOAP action. {code} 
from(spring-ws:soapaction:http://example.com/GetFoo?endpointMapping=#endpointMapping) 
.convertBodyTo(String.class).to(mock:example) {code} 
...
The following route will receive all requests sent to {{http://example.com/foobar}}. {code} 
from(spring-ws:uri:http://example.com/foobar?endpointMapping=#endpointMapping) 
.convertBodyTo(String.class).to(mock:example) {code} 
...
The route below will receive requests that contain the element {{foobarabc/foobar}} anywhere inside the message (and the default namespace). {code} 
from(spring-ws:xpathresult:abc?_expression_=//foobarendpointMapping=#endpointMapping) 
.convertBodyTo(String.class).to(mock:example) {code} 
...
camelContext xmlns=http://camel.apache.org/schema/spring 	route 
from uri=spring-ws:beanname:QuoteEndpointDispatcher / 
		to uri=mock:example / 	/route 
...
jaxb.setContextPath(com.example.model);  
from(direct:example).marshal(jaxb).to(spring-ws:http://foo.com/bar).unmarshal(jaxb); 
{code}  Similarly when _providing_ web services, you can unmarshal XML requests to POJOs and marshal the response message back to XML: {code} 
from(spring-ws:rootqname:{http://example.com/}GetFoo?endpointMapping=#endpointMapping).unmarshal(jaxb) 
.to(mock:example).marshal(jaxb); {code} 
...

Full Content

Spring Web Services Component
Available as of Camel 2.6

The spring-ws: component allows you to integrate with Spring Web Services. It offers both client-side support, for accessing web services, and server-side support for creating your own contract-first web services.

Maven users will need to add the following dependency to their pom.xml for this component:



dependency
	groupIdorg.apache.camel/groupId
	artifactIdcamel-spring-ws/artifactId
	versionx.x.x/version
	!-- use the same version as your Camel core version --
/dependency



DependenciesThis component offers support for Spring-WS 1.5.9 which is compatible with Spring 2.5.x and 3.0.x.
In order to run camel-spring-ws on Spring 2.5.x you need to add the spring-webmvc module from Spring 2.5.x.

In order to run Spring-WS 1.5.9 on Spring 3.0 you need to exclude the OXM module from Spring 3.0 as this module is also included in Spring-WS 1.5.9 (see this post)

URI format

The URI scheme for this component is as follows



spring-ws:[mapping-type:]address[?options]



To expose a web service mapping-type needs to be set to any of the following:




 Mapping type 
 Description 


 rootqname 
 Offers the option to map web service requests based on the qualified name of the root element contained in the message. 


 soapaction 
 Used to map web service requests based on the SOAP action specified in the header of the message. 


 uri 
 In order to map web service requests that target a specific URI. 


 xpathresult 
 Used to map web service requests based on the evaluation of an XPath _expression_ against the incoming message. The result of the 

[CONF] Apache Camel Spring Web Services

2010-10-27 Thread confluence







Spring Web Services
Page edited by Richard Kettelerij


Comment:
improved docs


 Changes (1)
 



...
{code}  
More information on setting up Spring-WS can be found in [Writing Contract-First Web Services|http://static.springsource.org/spring-ws/sites/1.5/reference/html/tutorial.html]. Basically paragraph 3.6 Implementing the Endpoint is handled by this component (specifically paragraph 3.6.2 Routing the Message to the Endpoint is where {{CamelEndpointMapping}} comes in). 
 h3. Endpoint mapping in routes 
...

Full Content

Spring Web Services Component
Available as of Camel 2.6

The springws: component allows you to integrate with Spring Web Services. It offers both client-side support, for accessing web services, and server-side support for creating your own contract-first web services.

Maven users will need to add the following dependency to their pom.xml for this component:



dependency
	groupIdorg.apache.camel/groupId
	artifactIdcamel-spring-ws/artifactId
	versionx.x.x/version
	!-- use the same version as your Camel core version --
/dependency



DependenciesThis component offers support for Spring-WS 1.5.9 which is compatible with Spring 2.5.x. In order to run Spring-WS 1.5.9 on Spring 3.0 you need to exclude the OXM module from Spring 3.0 as this module is also included in Spring-WS 1.5.9 (see this post)

URI format

The URI scheme for this component is as follows



springws:[mapping-type:]address[?options]



To expose a web service mapping-type needs to be set to any of the following:




 Mapping type 
 Description 


 rootqname 
 Offers the option to map web service requests based on the qualified name of the root element contained in the message. 


 soapaction 
 Used to map web service requests based on the SOAP action specified in the header of the message. 


 uri 
 In order to map web service requests that target a specific URI. 


 xpathresult 
 Used to map web service requests based on the evaluation of an XPath _expression_ against the incoming message. The result of the evaluation should match the XPath result specified in the endpoint URI. 


 beanname 
 Allows you to reference a org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher in order to integrate with existing (legacy) endpoint mappings like PayloadRootQNameEndpointMapping, SoapActionEndpointMapping, etc 





As a consumer the address should contain a value relevant to the specified mapping-type (e.g. a SOAP action, XPath _expression_). As a producer the address should be set to the URI of the web service your calling upon.

You can append query options to the URI in the following format, ?option=valueoption=value...

Options




 Name 
 Required? 
 Description 


 soapAction 
 No 
 SOAP action to include inside a SOAP request when accessing remote web services 


 wsAddressingAction 
 No 
 WS-Addressing 1.0 action header to include when accessing web services. The To header is set to the address of the web service as specified in the endpoint URI (default Spring-WS behavior). 


 _expression_ 
 Only when mapping-type is xpathresult 
 XPath _expression_ to use in the process of mapping web service requests, should match the result specified by xpathresult 





Registry based options

The following options can be specified in the registry (most likely a Spring ApplicationContext) and referenced from the endpoint URI using the # notation.




 Name 
 Required? 
 Description 


 webServiceTemplate 
 No 
 Option to provide a custom WebServiceTemplate. This allows for full control over  client-side web services handling; like adding a custom interceptor or specifying a fault resolver, message sender or message factory. 


 messageSender 
 No 
 Option to provide a custom WebServiceMessageSender. For example to perform authentication or use alternative transports 


 messageFactory 
 No 
 Option to provide a custom WebServiceMessageFactory. For example when you want Apache Axiom to handle web service messages instead of SAAJ 


 transformerFactory 
 No 
 Option to override default TransformerFactory. The provided transformer factory must be of type javax.xml.transform.TransformerFactory 


 endpointMapping 
 Only when mapping-type is rootqname, soapaction, uri or xpathresult 
 Reference to org.apache.camel.component.spring.ws.bean.CamelEndpointMapping in the Registry/ApplicationContext. Only one bean is required in the registry to serve all Camel/Spring-WS endpoints. This bean is auto-discovered by the MessageDispatcher and used to map requests to Camel endpoints based on characteristics specified on the endpoint (like root QName, SOAP action, etc) 





Message headers




 Name 
 Type 
 Description 


 CamelSpringWebserviceEndpointUri 
 String 
 URI of the 

[CONF] Apache Camel Spring Web Services

2010-10-26 Thread confluence







Spring Web Services
Page  added by R. Kettelerij

 

 Spring Web Services Component
Available as of Camel 2.6

The springws: component allows you to integrate with Spring Web Services It offers both client-side support, for accessing web services, and server-side support for creating your own contract-first web services.

Maven users will need to add the following dependency to their pom.xml for this component:



dependency
	groupIdorg.apache.camel/groupId
	artifactIdcamel-spring-ws/artifactId
	versionx.x.x/version
	!-- use the same version as your Camel core version --
/dependency



DependenciesThis component offers support for Spring-WS 1.5.9 which is compatible with Spring 2.5.x. In order to run Spring-WS 1.5.9 on Spring 3.0 you need to exclude the OXM module from Spring 3.0 as this module is also included in Spring-WS 1.5.9 (see this post)

URI format

The URI scheme for this component is as follows



springws:[mapping-type:]address[?options]



To expose a web service mapping-type needs to be set to any of the following:




 Mapping type 
 Description 


 rootqname 
 Offers the option to map web service requests based on the qualified name of the root element contained in the message. 


 soapaction 
 Used to map web service requests based on the SOAP action specified in the header of the message. 


 uri 
 In order to map web service requests that target a specific URI. 


 xpathresult 
 Used to map web service requests based on the evaluation of an XPath _expression_ against the incoming message. The result of the evaluation should match the XPath result specified in the endpoint URI. 


 beanname 
 Allows you to reference a org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher in order to integrate with existing (legacy) endpoint mappings like PayloadRootQNameEndpointMapping, SoapActionEndpointMapping, etc 





As a consumer the address should contain a value relevant to the specified mapping-type (e.g. a SOAP action, XPath _expression_). As a provider the address should be set to the URI of the web service your calling upon.

You can append query options to the URI in the following format, ?option=valueoption=value...

Options




 Name 
 Required? 
 Description 


 soapAction 
 No 
 SOAP action to include inside a SOAP request when accessing remote web services 


 wsAddressingAction 
 No 
 WS-Addressing 1.0 action header to include when accessing web services. The To header is set to the address of the web service as specified in the endpoint URI (default Spring-WS behavior). 


 _expression_ 
 Only when mapping-type is xpathresult 
 XPath _expression_ to use in the process of mapping web service requests, should match the result specified by xpathresult 





Registry based options

The following options can be specified in the registry (most likely a Spring ApplicationContext) and referenced from the endpoint URI using the # notation.




 Name 
 Required? 
 Description 


 webServiceTemplate 
 No 
 Option to provide a custom WebServiceTemplate. This allows for full control over  client-side web services handling; like adding a custom interceptor or specifying a fault resolver, message sender or message factory. 


 messageSender 
 No 
 Option to provide a custom WebServiceMessageSender. For example to perform authentication or use alternative transports 


 messageFactory 
 No 
 Option to provide a custom WebServiceMessageFactory. For example when you want Apache Axiom to handle web service messages instead of SAAJ 


 transformerFactory 
 No 
 Option to override default TransformerFactory. The provided transformer factory must be of type javax.xml.transform.TransformerFactory 


 endpointMapping 
 Only when mapping-type is rootqname, soapaction, uri or xpathresult 
 Reference to org.apache.camel.component.spring.ws.bean.CamelEndpointMapping in the Registry/ApplicationContext. Only one bean is required in the registry to serve all Camel/Spring-WS endpoints. This bean is auto-discovered by the MessageDispatcher and used to map requests to Camel endpoints based on characteristics specified on the endpoint (like root QName, SOAP action, etc) 





Message headers




 Name 
 Type 
 Description 


 CamelSpringWebserviceEndpointUri 
 String 
 URI of the web service your accessing as a client, overrides address part of the endpoint URI 


 CamelSpringWebserviceSoapAction 
 String 
 Header to specify the SOAP action of the message, overrides soapAction option if present 


 CamelSpringWebserviceAddressingAction 
 URI 
 Use this header to specify the WS-Addressing action of the message, overrides wsAddressingAction option if present 





Accessing web services

To call a web service at http://foo.com/bar simply define a route:


from("direct:example").to("springws:http://foo.com/bar")



And sent a message:


template.requestBody("direct:example", "foobar xmlns=\"http://foo.com\"msgtest message/msg/foobar");



Sending SOAP and 

[CONF] Apache Camel Spring Security

2010-07-22 Thread confluence







Spring Security
Page edited by willem jiang


Comment:
CAMEL-2984


 Changes (31)
 



h2. Spring Security *Available as of Camel 2.3* 
h3. Creating authorization policies 
 
[Spring Security|http://static.springsource.org/spring-security/site/index.html] is a poplar security framework to provides the authentication and authorization for the Spring application. It allows together with Camel to provide authorization support for the camel process by configuring the authorizationPolicy.  
Access to a route is controlled by an instance of a {{SpringSecurityAuthorizationPolicy}} object.  A policy object contains the name of the Spring Security authority (role) required to run a set of endpoints and references to Spring Security {{AuthenticationManager}} and {{AccessDecisionManager}} objects used to determine whether the current principal has been assigned that role.  Policy objects may be configured as Spring beans or by using an {{authorizationPolicy}} element in Spring XML. 
 
h3. Using SpringSecurityAuthorizationPolicy camel-spring-security component can take the authentication token which is set by Spring Security or other security framework, and check authentication token with the access information which is configured by SpringSecurityAuthorizationPolicy. SpringSecurityAuthorizationPolicy will check the message header with CamelAuthentication and turned the security subject into the spring authentication token, you can specify your customer authenticationAdapter by configure this policy. If there is no security subject in the message header, and the policys attribute useThreadSecurityContext is true, the policy will use SecurityContextHolder.getContext().getAuthentication() to get the authentication token. If the authentication token is authorized, the camel exchange will be passed to the next processor, otherwise CamelAuthorizationException will be thrown with the exchange. 
The {{authorizationPolicy}} element may contain the following attributes: 
 
You can configure the SpringSecurityAuthorizationPolicy with normal Spring beans configuration, and you can also configure it with the customer authorizationPolicy element.   
||Name||Default Value||Description|| |{{id}}|{{null}}|The unique Spring bean identifier which is used to reference the policy in routes (required)| |{{access}}|{{null}}|The Spring Security authority name that is passed to the access decision manager (required)| |{{authenticationManager}}|{{authenticationManager}}|The name of the Spring Security {{AuthenticationManager}} object in the context| |{{accessDecisionManager}}|{{accessDecisionManager}}|The name of the Spring Security {{AccessDecisionManager}} object in the context| |{{authenticationAdapter}}|DefaultAuthenticationAdapter|*Camel 2.4* The name of a *camel-spring-security* {{AuthenticationAdapter}} object in the context that is used to convert a {{javax.security.auth.Subject}} into a Spring Security {{Authentication}} instance.| |{{useThreadSecurityContext}}|{{true}}|If a {{javax.security.auth.Subject}} cannot be found in the In message header under Exchange.AUTHENTICATION, check the Spring Security {{SecurityContextHolder}} for an {{Authentication}} object.| |{{alwaysReauthenticate}}|{{false}}|If set to true, the {{SpringSecurityAuthorizationPolicy}} will always call {{AuthenticationManager.authenticate()}} each time the policy is accessed.| 
 
authorizationPolicy element has below attributes: || Attribut || Type ||  Description || | {{id}} | String | The bean id which is common used for the bean which is managed by Spring| | {{access}} | String | The access policy that you want to use authorization | | {{authenticationManager}} | String | The id of the authentication manager which is used for reauthentication within the SpringSecurityAuthorizationPolicy. If you dont specify it, SpringSecurityAuthorizationPolicy will set it value with authenticationManager | | {{accessDecisionManager}} | String | The id of the access decision manager which is used for checking the access attribute with authentication token. If you dont specify it, SpringSecurityAuthorizationPolicy will set it value with accessDecisionManager | | {{authenticationAdapter}} | String | New to Camel 2.4, The id of AuthenticationAdapter that SpringSecurityAuthorizationPolicy uses to turn a security subject into Spring authentication token | | {{useThreadSecurityContext}} | boolean | SpringSecurityAuthorizationPolicy will try to get the authentication token from message header with the key CamelAuthentication, if it cant get it and the this attribute is true, it will try to get authentication from SecurityContextHolder (the thread local context).  The default value of this 

[CONF] Apache Camel Spring

2010-06-15 Thread confluence







Spring
Page edited by Claus Ibsen


 Changes (2)
 



...
{warning}  
{info:title=Will ignore already instantiated classes} The package and packageScan will skip any classes which has already been created by Spring etc. So if you define a route builder as a spring bean tag then that class will be skipped. You can include those beans using {{routeBuilder ref=theBeanId/}} or the {{contextScan/}} feature. {info}  
h4. Using packageScan  
...
\*\*.??cluded\* would match org.simple.IncludedRoute, org.simple.Excluded but not match org.simple.PrecludedRoute  
h4. Using contextScan *Available as of Camel 2.4*  You can allow Camel to scan the container context, e.g. the Spring {{ApplicationContext}} for route builder instances. This allow you to use the Spring {{component-scan}} feature and have Camel pickup any RouteBuilder instances which was created by Spring in its scan process.  {snippet:id=e1|lang=xml|url=""  This allows you to just annotate your routes using the Spring {...@component}} and have those routes included by Camel {code} @Component public class MyRoute extends SpringRouteBuilder {  @Override public void configure() throws Exception { from(direct:start).to(mock:result); } } {code}  You can also use the ANT style for inclusion and exclusion, as mentioned above in the {{packageScan}} documentation.   
h4. Test time exclusion.   
...

Full Content

Spring Support

Apache Camel is designed to work nicely with the Spring Framework in a number of ways.

	Camel uses Spring Transactions as the default transaction handling in components like JMS and JPA
	Camel works with Spring 2 XML processing with the Xml Configuration
	Camel Spring XML Schema's is defined at Xml Reference
	Camel supports a powerful version of Spring Remoting which can use powerful routing between the client and server side along with using all of the available Components for the transport
	Camel provides powerful Bean Integration with any bean defined in a Spring ApplicationContext
	Camel integrates with various Spring helper classes; such as providing Type Converter support for Spring Resources etc
	Allows Spring to dependency inject Component instances or the CamelContext instance itself and auto-expose Spring beans as components and endpoints.
	Allows you to reuse the Spring Testing framework to simplify your unit and integration testing using Enterprise Integration Patterns and Camel's powerful Mock and Test endpoints



Using Spring to configure the CamelContext

You can configure a CamelContext inside any spring.xml using the CamelContextFactoryBean. This will automatically start the CamelContext along with any referenced Routes along any referenced Component and Endpoint instances.


	Adding Camel schema
	Configure Routes in two ways:
	
		Using Java Code
		Using Spring XML
	
	



Adding Camel Schema
For Camel 1.x you need to use the following namespace:


http://activemq.apache.org/camel/schema/spring


with the following schema location:


http://activemq.apache.org/camel/schema/spring/camel-spring.xsd


You need to add Camel to the schemaLocation declaration


http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd



So the XML file looks like this:


beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"



Using camel: namespace
Or you can refer to camel XSD in the XML declaration:


xmlns:camel="http://activemq.apache.org/camel/schema/spring"


... so the declaration is:

beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:camel="http://camel.apache.org/schema/spring"
   xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"


... and then use the camel: namespace prefix, and you can omit the inline namespace declaration:

camel:camelContext id="camel5"
  camel:packageorg.apache.camel.spring.example/camel:package
/camel:camelContext



Advanced configuration using Spring
See more details at Advanced configuration of CamelContext using Spring

Using Java Code

You can use Java Code to define your RouteBuilder implementations. These can be defined as beans in spring and then referenced in your camel context e.g.

  

[CONF] Apache Camel Spring Security

2010-06-06 Thread confluence







Spring Security
Page edited by willem jiang


Comment:
CAMEL-2793 update the wiki doc of camel-spring-security


 Changes (5)
 



...
 h3. Using SpringSecurityAuthorizationPolicy 
camel-spring-security component can take the authentication token which is set by Spring Security or other security framework, and check authentication token with the access information which is configured by SpringSecurityAuthorizationPolicy. If the authentication token is authorized, the camel exchange will be passed to the next processor, otherwise CamelAuthorizationException will be thrown with the exchange. 
SpringSecurityAuthorizationPolicy will check the message header with CamelAuthentication and turned the security subject into the spring authentication token, you can specify your customer authenticationAdapter by configure this policy. If there is no security subject in the message header, and the policys attribute useThreadSecurityContext is true, the policy will use SecurityContextHolder.getContext().getAuthentication() to get the authentication token. If the authentication token is authorized, the camel exchange will be passed to the next processor, otherwise CamelAuthorizationException will be thrown with the exchange. 
 You can configure the SpringSecurityAuthorizationPolicy with normal Spring beans configuration, and you can also configure it with the customer authorizationPolicy element.   
...
| {{authenticationManager}} | String | The id of the authentication manager which is used for reauthentication within the SpringSecurityAuthorizationPolicy. If you dont specify it, SpringSecurityAuthorizationPolicy will set it value with authenticationManager | | {{accessDecisionManager}} | String | The id of the access decision manager which is used for checking the access attribute with authentication token. If you dont specify it, SpringSecurityAuthorizationPolicy will set it value with accessDecisionManager | 
| {{authenticationAdapter}} | String | New to Camel 2.4, The id of AuthenticationAdapter that SpringSecurityAuthorizationPolicy uses to turn a security subject into Spring authentication token | 
| {{useThreadSecurityContext}} | String boolean | SpringSecurityAuthorizationPolicy will try to get the authentication token from exchange, message header with the key CamelAuthentication, if it cant get it and the this attribute is true, it will try to get authentication from SecurityContextHolder (the thread local context).  The default value of this attribute is true. | 
| {{alwaysReauthenticate}} | String boolean | If this attribute is true, SpringSecurityAuthorizationPolicy will aways reauthenticate the authentication token. The default value of this attribute is false. | 
 h4. Using SpringSecurityAuthorizationPolicy in Spring XML 
...

Full Content

Spring Security
Available as of Camel 2.3

Spring Security is a poplar security framework to provides the authentication and authorization for the Spring application. It allows together with Camel to provide authorization support for the camel process by configuring the authorizationPolicy. 

Using SpringSecurityAuthorizationPolicy
camel-spring-security component can take the authentication token which is set by Spring Security or other security framework, and check authentication token with the access information which is configured by SpringSecurityAuthorizationPolicy.
SpringSecurityAuthorizationPolicy will check the message header with "CamelAuthentication" and turned the security subject into the spring authentication token, you can specify your customer authenticationAdapter by configure this policy. If there is no security subject in the message header, and the policy's attribute "useThreadSecurityContext" is true, the policy will use SecurityContextHolder.getContext().getAuthentication() to get the authentication token.
If the authentication token is authorized, the camel exchange will be passed to the next processor, otherwise CamelAuthorizationException will be thrown with the exchange.

You can configure the SpringSecurityAuthorizationPolicy with normal Spring bean's configuration, and you can also configure it with the customer authorizationPolicy element.  

authorizationPolicy element has below attributes:



 Attribut 
 Type 
  Description 


 id 
 String 
 The bean id which is common used for the bean which is managed by Spring


 access 
 String 
 The access policy that you want to use authorization 


 authenticationManager 
 String 
 The id of the authentication manager which is used for reauthentication within the SpringSecurityAuthorizationPolicy. If you don't specify it, SpringSecurityAuthorizationPolicy 

[CONF] Apache Camel Spring Security

2010-04-15 Thread confluence







Spring Security
Page  added by willem jiang

 

 Spring Security
Available as of Camel 2.3

Spring Security is a poplar security framework to provides the authentication and authorization for the Spring application. It allows together with Camel to provide authorization support for the camel process by configuring the authorizationPolicy. 

Using SpringSecurityAuthorizationPolicy
camel-spring-security component can take the authentication token which is set by Spring Security or other security framework, and check authentication token with the access information which is configured by SpringSecurityAuthorizationPolicy. If the authentication token is authorized, the camel exchange will be passed to the next processor, otherwise CamelAuthorizationException will be thrown with the exchange.

You can configure the SpringSecurityAuthorizationPolicy with normal Spring bean's configuration, and you can also configure it with the customer authorizationPolicy element.  

authorizationPolicy element has below attributes:


 Attribut 
 Type 
  Description 


 id 
 String 
 The bean id which is common used for the bean which is managed by Spring


 access 
 String 
 The access policy that you want to use authorization 


 authenticationManager 
 String 
 The id of the authentication manager which is used for reauthentication within the SpringSecurityAuthorizationPolicy. If you don't specify it, SpringSecurityAuthorizationPolicy will set it value with "authenticationManager" 


 accessDecisionManager 
 String 
 The id of the access decision manager which is used for checking the access attribute with authentication token. If you don't specify it, SpringSecurityAuthorizationPolicy will set it value with "accessDecisionManager" 


 useThreadSecurityContext 
 String 
 SpringSecurityAuthorizationPolicy will try to get the authentication token from exchange, if it can't get it and the this attribute is true, it will try to get authentication from SecurityContextHolder (the thread local context).  The default value of this attribute is true. 


 alwaysReauthenticate 
 String 
 If this attribute is true, SpringSecurityAuthorizationPolicy will aways reauthenticate the authentication token. The default value of this attribute is false. 



Using SpringSecurityAuthorizationPolicy in Spring XML
In this example we want to make sure exchange send to mock:end should be authenticated with the role of admin.





The spring security configure looks like this





Dependencies

To use Spring Security in your camel routes you need to add the a dependency on camel-spring-security. 

If you use maven you could just add the following to your pom.xml, substituting the version number for the latest  greatest release (see the download page for the latest versions).






See Also

	Configuring Camel
	Component
	Endpoint
	Getting Started



	Components




   
Change Notification Preferences
   
   View Online
  |
   Add Comment
   








[CONF] Apache Camel Spring Security Example

2010-04-15 Thread confluence







Spring Security Example
Page  added by willem jiang

 

 Spring Security Example

This example shows you how to leverage the Spring Security already provides authentication mechanism and authoriationPolicy which is provided in camel-spring-security module to implement a role based authorization application. 

This example consumes messages from a servlet endpoint which is secured by Spring Security with http basic authentication, there are two service:




You will need to compile this example first:




To run the example, you need to start up the server by typing



To stop the server hit ctrl + c

Then you can use the script in the client directory to send the request and check the response.

Here is the camel route configuration
Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20 

You can find how to configure the camel-servlet with http basic authentication by check the files in WEB-INF 


   
Change Notification Preferences
   
   View Online
  |
   Add Comment
   








[CONF] Apache Camel Spring Security Example

2010-04-15 Thread confluence







 Spring Security Example
 Page edited by willem jiang

 
  
 
 Spring Security Example

This example shows you how to leverage the Spring Security already provides authentication mechanism and authoriationPolicy which is provided in camel-spring-security module to implement a role based authorization application. 

This example consumes messages from a servlet endpoint which is secured by Spring Security with http basic authentication, there are two service:




You will need to compile this example first:




To run the example, you need to start up the server by typing



To stop the server hit ctrl + c

Then you can use the script in the client directory to send the request and check the response, or use browser to access upper service with the user/password ("jim/jimspassword" with the admin and user role  or "rob/robspassword" with user role).

Here is the camel route configuration:





You can find how to configure the camel-servlet with http basic authentication by check the files in WEB-INF 
 
 
   
Change Notification Preferences
   

   View Online
   |
   View Change
  |
   Add Comment









[CONF] Apache Camel Spring

2010-01-06 Thread confluence







 Spring
 Page edited by Claus Ibsen

 
  
 
 Spring Support

Apache Camel is designed to work nicely with the Spring Framework in a number of ways.

	Camel uses Spring Transactions as the default transaction handling in components like JMS and JPA
	Camel works with Spring 2 XML processing with the Xml Configuration
	Camel Spring XML Schema's is defined at Xml Reference
	Camel supports a powerful version of Spring Remoting which can use powerful routing between the client and server side along with using all of the available Components for the transport
	Camel provides powerful Bean Integration with any bean defined in a Spring ApplicationContext
	Camel integrates with various Spring helper classes; such as providing Type Converter support for Spring Resources etc
	Allows Spring to dependency inject Component instances or the CamelContext instance itself and auto-expose Spring beans as components and endpoints.
	Allows you to reuse the Spring Testing framework to simplify your unit and integration testing using Enterprise Integration Patterns and Camel's powerful Mock and Test endpoints



Using Spring to configure the CamelContext

You can configure a CamelContext inside any spring.xml using the CamelContextFactoryBean. This will automatically start the CamelContext along with any referenced Routes along any referenced Component and Endpoint instances.


	Adding Camel schema
	Configure Routes in two ways:
	
		Using Java Code
		Using Spring XML
	
	



Adding Camel Schema
For Camel 1.x you need to use the following namespace:


http://activemq.apache.org/camel/schema/spring


with the following schema location:


http://activemq.apache.org/camel/schema/spring/camel-spring.xsd


You need to add Camel to the schemaLocation declaration


http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd



So the XML file looks like this:


beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"



Using camel: namespace
Or you can refer to camel XSD in the XML declaration:


xmlns:camel="http://activemq.apache.org/camel/schema/spring"


... so the declaration is:

beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:camel="http://camel.apache.org/schema/spring"
   xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"


... and then use the camel: namespace prefix, and you can omit the inline namespace declaration:

camel:camelContext id="camel5"
  camel:packageorg.apache.camel.spring.example/camel:package
/camel:camelContext



Advanced configuration using Spring
See more details at Advanced configuration of CamelContext using Spring

Using Java Code

You can use Java Code to define your RouteBuilder implementations. These can be defined as beans in spring and then referenced in your camel context e.g.

  camelContext id="camel5" xmlns="http://camel.apache.org/schema/spring"
routeBuilder ref="myBuilder" /
  /camelContext
  
  bean id="myBuilder" class="org.apache.camel.spring.example.test1.MyRouteBuilder"/
  
/beans



Using package
Camel also provides a powerful feature that allows for the automatic discovery and initialization of routes in given packages. This is configured by adding tags to the camel context in your spring context definition, specifying the packages to be recursively searched for RouteBuilder implementations. To use this feature in 1.X, requires a package/package tag specifying a comma separated list of packages that should be searched e.g.


  camelContext http://activemq.apache.org/camel/schema/spring"
packageorg.apache.camel.spring.config.scan.route/package
  /camelContext



Use caution when specifying the package name as org.apache.camel or a sub package of this. This causes Camel to search in its own packages for your routes which could cause problems. 

Using packageScan

In Camel 2.0 this has been extended to allow selective inclusion and exclusion of discovered route classes using Ant like path matching. In spring this is specified by adding a packageScan/ tag. The tag must contain one or more 'package' elements (similar to 1.x), and optionally one or more 'includes' or 'excludes' elements specifying patterns to be applied to the fully qualified names of the discovered classes. e.g.


  camelContext xmlns="http://camel.apache.org/schema/spring"
packageScan
  packageorg.example.routes/package
  

[CONF] Apache Camel Spring Java Config

2009-12-29 Thread confluence







 Spring Java Config
 Page edited by willem jiang

 
  
 
 Spring Java Config

Spring started life using XML Config to wire beans together. However some folks don't like using XML and would rather use Java code which led to the creation of Guice along with the Spring JavaConfig project.

You can use either the XML or Java config approachs with Camel; its your choice really on which you prefer.

NOTE: From Camel 2.2.0 camel-spring-javaconfig is moved to Spring 3.x, which means you can't run it with spring 2.x.

Using Spring Java Config

To use Spring Java Config in your Camel project the easiest thing to do is add the following to your pom.xml



dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring-javaconfig/artifactId
  version${camel-version}/version
/dependency



This will then add the dependencies on the Spring JavaConfig library along with some helper classes for configuring Camel inside Spring.

Note that this library is totally optional; you could just wire Camel together yourself with Java Config.

Example

The following example using Java Config is actually a Spring Testing based unit test.


@ContextConfiguration(
locations = "org.apache.camel.spring.javaconfig.patterns.FilterTest$ContextConfig",
loader = JavaConfigContextLoader.class)
public class FilterTest extends AbstractJUnit4SpringContextTests {

@EndpointInject(uri = "mock:result")
protected MockEndpoint resultEndpoint;

@Produce(uri = "direct:start")
protected ProducerTemplate template;

@DirtiesContext
@Test
public void testSendMatchingMessage() throws Exception {
String expectedBody = "matched/";

resultEndpoint.expectedBodiesReceived(expectedBody);

template.sendBodyAndHeader(expectedBody, "foo", "bar");

resultEndpoint.assertIsSatisfied();
}

@DirtiesContext
@Test
public void testSendNotMatchingMessage() throws Exception {
resultEndpoint.expectedMessageCount(0);

template.sendBodyAndHeader("notMatched/", "foo", "notMatchedHeaderValue");

resultEndpoint.assertIsSatisfied();
}

@Configuration
public static class ContextConfig extends SingleRouteCamelConfiguration {
@Bean
public RouteBuilder route() {
return new RouteBuilder() {
public void configure() {
from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
}
};
}
}
}



The @ContextConfiguration annotation tells the Spring Testing framework to load the ContextConfig class as the configuration to use. This class derives from SingleRouteCamelConfiguration which is a helper Spring Java Config class which will configure the CamelContext for us and then register the RouteBuilder we create.

If you wish to create a collection of RouteBuilder instances then derive from the CamelConfiguration helper class and implement the routes() method.
 
 
   
Change Notification Preferences
   

   View Online
   |
   View Change
  |
   Add Comment









[CONF] Apache Camel Spring Java Config Example

2009-12-29 Thread confluence







 Spring Java Config Example
 Page edited by willem jiang

 
  
 
 Spring Java Config Example 

The spring java config example is a simple refactor of the spring example since Camel 2.0 to show how to use the Spring JavaConfig approach to working with Camel. In this example we just write RouteBuilder implementations, then Camel will find it through your configuration.
NOTE From Camel 2.2.0, camel-example-spring-javaconfig can only work with Spring 3.x.

To run the example we use the Camel Maven Plugin. For example from the source or binary distribution the following should work



cd examples/camel-example-spring-javaconfig
mvn camel:run



You need to add camel-spring-javaconfig dependency into pom.xml and also set the configure class or base package in the camel plugin configuration. 


dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring/artifactId
/dependency

dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring-javaconfig/artifactId
/dependency



Here is the configuration for camel plugin.


plugins
  !-- Allows the routes to be run via 'mvn camel:run' --
  plugin
groupIdorg.apache.camel/groupId
artifactIdcamel-maven-plugin/artifactId
version${project.version}/version
configuration
duration5s/duration
configClassesorg.apache.camel.example.spring.javaconfig.MyRouteConfig/configClasses
!--You could set the base package directory and let spring to find the config classes for you 
basedPackagesorg.apache.camel.example.spring.javaconfig/basedPackages 
 --
/configuration
  /plugin
/plugins



What this does is boot up the Spring ApplicationContext defined in the file MyRouteConfig class on the classpath. This is a regular Java file which has the Spring JavaConfig annotation to configure a CamelContext.


/**
 * A simple example router from a file system to an ActiveMQ queue and then to a file system
 *
 * @version $Revision$
 */
@Configuration
public class MyRouteConfig extends SingleRouteCamelConfiguration implements InitializingBean, BundleContextAware {

private BundleContext bundleContext;

/**
 * Allow this route to be run as an application
 *
 * @param args
 * @throws Exception 
 */
public static void main(String[] args) throws Exception {
new Main().run(args);
}

public BundleContext getBundleContext() {
return bundleContext;
}

public void setBundleContext(BundleContext bundleContext) { 
this.bundleContext = bundleContext;
}


/**
 * Returns the CamelContext which support OSGi
 */
@Override
protected CamelContext createCamelContext() throws Exception {
SpringCamelContextFactory factory = new SpringCamelContextFactory();
factory.setApplicationContext(getApplicationContext());
factory.setBundleContext(getBundleContext());
return factory.createContext();
}

@Override
// setup the ActiveMQ component and register it into the camel context
protected void setupCamelContext(CamelContext camelContext) throws Exception {
JmsComponent answer = new JmsComponent();
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL("vm://localhost.spring.javaconfig?marshal=falsebroker.persistent=falsebroker.useJmx=false");
answer.setConnectionFactory(connectionFactory);
camelContext.addComponent("jms", answer);
}


public static class SomeBean {
public void someMethod(String body) {
System.out.println("Received: " + body);
}
}

@Bean
@Override
// you can confige the route rule with Java DSL here
public RouteBuilder route() {
return new RouteBuilder() {
public void configure() {
// populate the message queue with some messages
from("file:src/data?noop=true").
to("jms:test.MyQueue");

from("jms:test.MyQueue").
to("file://target/test?noop=true");

// set up a listener on the file component
from("file://target/test?noop=true").
bean(new SomeBean());
}
};
}

public void afterPropertiesSet() throws Exception {
// just to make SpringDM happy do nothing here
}
}



In the method of setupCamelContext(CamelContext camelContext), we setup the JMS component's connection factory and register the component into the camelcontext. You can override this method if you want to setup the another connection factory or start up a JMS broker here.

You can write the route rule with Java DSL in the route() method.

This approach, of using Java code to write the routes in the DSL and Spring will help your configure the 

[CONF] Apache Camel Spring

2009-11-15 Thread confluence







 Spring
 Page edited by Jonathan Anstey

 
  
 
 Spring Support

Apache Camel is designed to work nicely with the Spring Framework in a number of ways.

	Camel uses Spring Transactions as the default transaction handling in components like JMS and JPA
	Camel works with Spring 2 XML processing with the Xml Configuration
	Camel Spring XML Schema's is defined at Xml Reference
	Camel supports a powerful version of Spring Remoting which can use powerful routing between the client and server side along with using all of the available Components for the transport
	Camel provides powerful Bean Integration with any bean defined in a Spring ApplicationContext
	Camel integrates with various Spring helper classes; such as providing Type Converter support for Spring Resources etc
	Allows Spring to dependency inject Component instances or the CamelContext instance itself and auto-expose Spring beans as components and endpoints.
	Allows you to reuse the Spring Testing framework to simplify your unit and integration testing using Enterprise Integration Patterns and Camel's powerful Mock and Test endpoints



Using Spring to configure the CamelContext

You can configure a CamelContext inside any spring.xml using the CamelContextFactoryBean. This will automatically start the CamelContext along with any referenced Routes along any referenced Component and Endpoint instances.


	Adding Camel schema
	Configure Routes in two ways:
	
		Using Java Code
		Using Spring XML
	
	



Adding Camel Schema
For Camel 1.x you need to use the following namespace:


http://activemq.apache.org/camel/schema/spring


with the following schema location:


http://activemq.apache.org/camel/schema/spring/camel-spring.xsd


You need to add Camel to the schemaLocation declaration


http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd



So the XML file looks like this:


beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"



Using camel: namespace
Or you can refer to camel XSD in the XML declaration:


xmlns:camel="http://activemq.apache.org/camel/schema/spring"


... so the declaration is:

beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:camel="http://camel.apache.org/schema/spring"
   xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"


... and then use the camel: namespace prefix, and you can omit the inline namespace declaration:

camel:camelContext id="camel5"
  camel:packageorg.apache.camel.spring.example/camel:package
/camel:camelContext



Advanced configuration using Spring
See more details at Advanced configuration of CamelContext using Spring

Using Java Code

You can use Java Code to define your RouteBuilder implementations. These can be defined as beans in spring and then referenced in your camel context e.g.

  camelContext id="camel5" xmlns="http://camel.apache.org/schema/spring"
routeBuilder ref="myBuilder" /
  /camelContext
  
  bean id="myBuilder" class="org.apache.camel.spring.example.test1.MyRouteBuilder"/
  
/beans



Using package
Camel also provides a powerful feature that allows for the automatic discovery and initialization of routes in given packages. This is configured by adding tags to the camel context in your spring context definition, specifying the packages to be recursively searched for RouteBuilder implementations. To use this feature in 1.X, requires a package/package tag specifying a comma separated list of packages that should be searched e.g.


  camelContext http://activemq.apache.org/camel/schema/spring"
packageorg.apache.camel.spring.config.scan.route/package
  /camelContext



Use caution when specifying the package name as org.apache.camel or a sub package of this. This causes Camel to search in its own packages for your routes which could cause problems. 

The package tag has been @deprecated and replaced with the more powerful packageScan tag. See below.
It will remain in Camel 2.x but will be removed in Camel 3.0

Using packageScan

In 2.X this has been extended to allow selective inclusion and exclusion of discovered route classes using Ant like path matching. In spring this is specified by adding a packageScan/ tag. The tag must contain one or more 'package' elements (similar to 1.x), and optionally one or more 'includes' or 'excludes' elements specifying patterns to be applied to the fully qualified names of 

[CONF] Apache Camel: Spring (page edited)

2009-06-22 Thread confluence










Page Edited :
CAMEL :
Spring



 
Spring
has been edited by Claus Ibsen
(Jun 22, 2009).
 

 
 (View changes)
 

Content:
Spring Support

Apache Camel is designed to work nicely with the Spring Framework in a number of ways.

	Camel uses Spring Transactions as the default transaction handling in components like JMS and JPA
	Camel works with Spring 2 XML processing with the Xml Configuration
	Camel Spring XML Schema's is defined at Xml Reference
	Camel supports a powerful version of Spring Remoting which can use powerful routing between the client and server side along with using all of the available Components for the transport
	Camel provides powerful Bean Integration with any bean defined in a Spring ApplicationContext
	Camel integrates with various Spring helper classes; such as providing Type Converter support for Spring Resources etc
	Allows Spring to dependency inject Component instances or the CamelContext instance itself and auto-expose Spring beans as components and endpoints.
	Allows you to reuse the Spring Testing framework to simplify your unit and integration testing using Enterprise Integration Patterns and Camel's powerful Mock and Test endpoints



Using Spring to configure the CamelContext

You can configure a CamelContext inside any spring.xml using the CamelContextFactoryBean. This will automatically start the CamelContext along with any referenced Routes along any referenced Component and Endpoint instances.


	Adding Camel schema
	Configure Routes in two ways:
	
		Using Java Code
		Using Spring XML
	
	



Adding Camel Schema

For Camel 1.x you need to use the following namespace:

http://activemq.apache.org/camel/schema/spring

with the following schema location:

http://activemq.apache.org/camel/schema/spring/camel-spring.xsd

You need to add Camel to the schemaLocation declaration

http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd


So the XML file looks like this:

beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"


Using camel: namespace
Or you can refer to camel XSD in the XML declaration:

xmlns:camel="http://activemq.apache.org/camel/schema/spring"

... so the declaration is:

beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:camel="http://camel.apache.org/schema/spring"
   xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"

... and then use the camel: namespace prefix, and you can omit the inline namespace declaration:

camel:camelContext id="camel5"
  camel:packageorg.apache.camel.spring.example/camel:package
/camel:camelContext


Advanced configuration using Spring
See more details at Advanced configuration of CamelContext using Spring

Using Java Code

You can use Java Code to define your RouteBuilder implementations. These can be defined as beans in spring and then referenced in your camel context e.g.

camelContext id="camel5" xmlns="http://camel.apache.org/schema/spring"
routeBuilder ref="myBuilder" /
  /camelContext
  
  bean id="myBuilder" class="org.apache.camel.spring.example.test1.MyRouteBuilder"/
  
/beans


Using package
Camel also provides a powerful feature that allows for the automatic discovery and initialization of routes in given packages. This is configured by adding tags to the camel context in your spring context definition, specifying the packages to be recursively searched for RouteBuilder implementations. To use this feature in 1.X, requires a package/package tag specifying a comma separated list of packages that should be searched e.g.

camelContext http://activemq.apache.org/camel/schema/spring"
packageorg.apache.camel.spring.config.scan.route/package
  /camelContext



Use caution when specifying the package name as org.apache.camel or a sub package of this. This causes Camel to search in its own packages for your routes which could cause problems. 


The package tag has been @deprecated and replaced with the more powerful packageScan tag. See below.
It will remain in Camel 2.x but will be removed in Camel 3.0

Using packageScan

In 2.X this has been extended to allow selective inclusion and exclusion of discovered route classes using Ant like path matching. In spring this is specified by adding a packageScan/ tag. The tag must contain one or more 'packages' 

[CONF] Apache Camel: Spring (page edited)

2009-06-21 Thread confluence










Page Edited :
CAMEL :
Spring



 
Spring
has been edited by Stephen Gargan
(Jun 21, 2009).
 

 
 (View changes)
 

Content:
Spring Support

Apache Camel is designed to work nicely with the Spring Framework in a number of ways.

	Camel uses Spring Transactions as the default transaction handling in components like JMS and JPA
	Camel works with Spring 2 XML processing with the Xml Configuration
	Camel Spring XML Schema's is defined at Xml Reference
	Camel supports a powerful version of Spring Remoting which can use powerful routing between the client and server side along with using all of the available Components for the transport
	Camel provides powerful Bean Integration with any bean defined in a Spring ApplicationContext
	Camel integrates with various Spring helper classes; such as providing Type Converter support for Spring Resources etc
	Allows Spring to dependency inject Component instances or the CamelContext instance itself and auto-expose Spring beans as components and endpoints.
	Allows you to reuse the Spring Testing framework to simplify your unit and integration testing using Enterprise Integration Patterns and Camel's powerful Mock and Test endpoints



Using Spring to configure the CamelContext

You can configure a CamelContext inside any spring.xml using the CamelContextFactoryBean. This will automatically start the CamelContext along with any referenced Routes along any referenced Component and Endpoint instances.


	Adding Camel schema
	Configure Routes in two ways:
	
		Using Java Code
		Using Spring XML
	
	



Adding Camel Schema

For Camel 1.x you need to use the following namespace:

http://activemq.apache.org/camel/schema/spring

with the following schema location:

http://activemq.apache.org/camel/schema/spring/camel-spring.xsd

You need to add Camel to the schemaLocation declaration

http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd


So the XML file looks like this:

beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"


Using camel: namespace
Or you can refer to camel XSD in the XML declaration:

xmlns:camel="http://activemq.apache.org/camel/schema/spring"

... so the declaration is:

beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:camel="http://camel.apache.org/schema/spring"
   xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"

... and then use the camel: namespace prefix, and you can omit the inline namespace declaration:

camel:camelContext id="camel5"
  camel:packageorg.apache.camel.spring.example/camel:package
/camel:camelContext


Advanced configuration using Spring
See more details at Advanced configuration of CamelContext using Spring

Using Java Code

You can use Java Code to define your RouteBuilder implementations. These can be defined as beans in spring and then referenced in your camel context e.g.

camelContext id="camel5" xmlns="http://camel.apache.org/schema/spring"
routeBuilder ref="myBuilder" /
  /camelContext
  
  bean id="myBuilder" class="org.apache.camel.spring.example.test1.MyRouteBuilder"/
  
/beans


Camel also provides a powerful feature that allows for the automatic discovery and initialization of routes in given packages. This is configured by adding tags to the camel context in your spring context definition, specifing the packages to be recursively searched for RouteBuilder implementations. To use this feature in 1.X, requires a package/package tag specifying a comma separated list of packages that should be searched e.g.

camelContext http://activemq.apache.org/camel/schema/spring"
packageorg.apache.camel.spring.config.scan.route/package
  /camelContext



Use caution when specifying the package name as org.apache.camel or a sub package of this. This causes Camel to search in its own packages for your routes which could cause problems. 

In 2.X this has been extended to allow selective inclusion and exclusion of discovered route classes using Ant like path matching. In spring this is specified by adding a packageScan/ tag. The tag must contain one or more 'packages' elements (similar to 1.x), and optionally one or more 'includes' or 'excludes' elements specifying patterns to be applied to the fully qualified names of the discovered classes. e.g.


[CONF] Apache Camel: Spring Java Config Example (page created)

2009-04-02 Thread confluence










Page Created :
CAMEL :
Spring Java Config Example



 
Spring Java Config Example
has been created by willem jiang
(Apr 02, 2009).
 

Content:
Spring Java Config Example 

The spring java config example is a simple refactor of the spring example since Camel 2.0 to show how to use the Spring JavaConfig approach to working with Camel. In this example we just write RouteBuilder implementations, then Camel will find it through your configuration.

To run the example we use the Camel Maven Plugin. For example from the source or binary distribution the following should work


cd examples/camel-example-spring-javaconfig
mvn camel:run


You need to add camel-spring-javaconfig dependency into pom.xml and also set the configure class or base package in the camel plugin configuration. 

dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring/artifactId
/dependency

dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring-javaconfig/artifactId
/dependency


Here is the configuration for camel plugin.


plugins
  !-- Allows the routes to be run via 'mvn camel:run' --
  plugin
groupIdorg.apache.camel/groupId
artifactIdcamel-maven-plugin/artifactId
version${pom.version}/version
configuration
duration5s/duration
configClassesorg.apache.camel.example.spring.javaconfig.MyRouteConfig/configClasses
!--You could set the base package directory and let spring to find the config classes for you 
basedPackagesorg.apache.camel.example.spring.javaconfig/basedPackages 
 --
/configuration
  /plugin
/plugins


What this does is boot up the Spring ApplicationContext defined in the file MyRouteConfig class on the classpath. This is a regular Java file which has the Spring JavaConfig annotation to configure a CamelContext.


/**
 * A simple example router from a file system to an ActiveMQ queue and then to a file system
 *
 * @version $Revision$
 */
@Configuration
public class MyRouteConfig extends SingleRouteCamelConfiguration {
/**
 * Allow this route to be run as an application
 *
 * @param args
 */
public static void main(String[] args) {
new Main().run(args);
}

@Override
// setup the ActiveMQ component and regist it into the camel context
public void setupCamelContext(CamelContext camelContext) throws Exception {
JmsComponent answer = new JmsComponent();
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL("vm://localhost?broker.persistent=falsebroker.useJmx=false");
answer.setConnectionFactory(connectionFactory);
camelContext.addComponent("jms", answer);
}


public static class SomeBean {

public void someMethod(String body) {
System.out.println("Received: " + body);
}
}

@Bean
@Override
// you can confige the route rule with Java DSL here
public RouteBuilder route() {
return new RouteBuilder() {
public void configure() {
// populate the message queue with some messages
from("file:src/data?noop=true").
to("jms:test.MyQueue");

from("jms:test.MyQueue").
to("file://target/test?noop=true");

// set up a listener on the file component
from("file://target/test?noop=true").
bean(new SomeBean());
}
};
}
}


In the method of setupCamelContext(CamelContext camelContext), we setup the JMS component's connection factory and register the component into the camelcontext. You can override this method if you want to setup the another connection factory or start up a JMS broker here.

You can write the route rule with Java DSL in the route() method.

This approach, of using Java code to write the routes in the DSL and Spring will help your configure the Camel context as the Spring Java Config Example shows. 












Powered by
Atlassian Confluence
(Version: 2.2.9 Build:#527 Sep 07, 2006)
-
Bug/feature request

Unsubscribe or edit your notifications preferences