diff --git a/build.gradle b/build.gradle index e7a2bca870..c85ef2d615 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { maven { url 'http://repo.springsource.org/plugins-release' } } dependencies { - classpath 'org.springframework.build.gradle:docbook-reference-plugin:0.2.6' + classpath 'org.springframework.build.gradle:docbook-reference-plugin:0.2.7' } } diff --git a/src/reference/docbook/index.xml b/src/reference/docbook/index.xml index 7ce0a9bcdf..7758606a0a 100644 --- a/src/reference/docbook/index.xml +++ b/src/reference/docbook/index.xml @@ -162,6 +162,7 @@ Advanced Topics and Additional Resources + diff --git a/src/reference/docbook/spel.xml b/src/reference/docbook/spel.xml new file mode 100644 index 0000000000..c3db2d4f42 --- /dev/null +++ b/src/reference/docbook/spel.xml @@ -0,0 +1,88 @@ + + + Spring Expression Language (SpEL) + +
+ Introduction + + Many Spring Integration components can be configured using expressions. These expressions + are written in the + Spring Expression Language. + + + In most cases, the #root object is the + Message which, of course, has two properties - headers and + payload - allowing such expressions as payload, payload.foo, + headers['my.header'] etc. + + + In some cases, additional variables are provided, for example the <int-http:inbound-gateway/> + provides #requestParams (parameters from the HTTP request) and #pathVariables + (values from path placeholders in the URI). + + + For all SpEL expressions, a BeanResolver is available, enabling references to + any bean in the application context. For example @myBean.foo(payload). In addition, two + PropertyAccessors are available; a MapAccessor + enables accessing values in a Map using a key, and a + ReflectivePropertyAccessor which allows access to fields and or JavaBean compliant + properties (using getters and setters). This is how the Message headers + and payload properties are accessible. + + + Starting with Spring Integration 3.0, it is possible to add additional + PropertyAccessors to the SpEL evaluation context. + In fact, the framework provides one such accessor, + the JsonPropertyAccessor which can be used (read-only) to access fields from + a JsonNode, or JSON in a String. Or you can create your + own PropertyAccessor if you have specific needs. + + + In addition, custom functions can be added. Custom functions are static methods + declared on a class. Functions and property accessors are available in any SpEL + expression used throughout the framework. + + + To configure your custom accessors and functions, add an + IntegrationEvaluationContextFactoryBean with + id="integrationEvaluationContext" + to your application context, with the appropriate configuration; for example: + + + + + + + + + + + + +]]> + + This factory bean definition will override the default integrationEvaluationContext + bean definition, adding the custom accessor to the list (which also includes the standard + accessors mentioned above), and one custom function. + + + Note that custom functions are static methods. + In the above example, the custom function is a static method calc on class + MyFunctions and takes a single parameter of type MyBar. + + + Say you have a Message with a payload that has a type MyFoo + on which you need to perform some action to create a MyBar object from it, + and you then want to invoke a custom function calc on that object. + + + The standard property accessors wouldn't know how to get a MyBar + from a MyFoo so you could write + and configure a custom property accessor to do so. So, your final expression might be + "#barcalc(payload.myBar)". + +
+
diff --git a/src/reference/docbook/whats-new.xml b/src/reference/docbook/whats-new.xml index d70f96318d..b9c512e73b 100644 --- a/src/reference/docbook/whats-new.xml +++ b/src/reference/docbook/whats-new.xml @@ -68,6 +68,14 @@ . +
+ Spring Expression Language (SpEL) Configuration + + A new factory bean is provided to allow + configuration of custom PropertyAccessors and functions for + use in SpEL expressions throughout the framework. For more information see . + +
diff --git a/src/reference/docbook/xmpp.xml b/src/reference/docbook/xmpp.xml index ffd6db4221..d3b8156603 100644 --- a/src/reference/docbook/xmpp.xml +++ b/src/reference/docbook/xmpp.xml @@ -201,8 +201,8 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/xmpp
-
- Appendices +
+ Advanced Configuration Since Spring Integration XMPP support is based on the Smack 3.1 API (http://www.igniterealtime.org/downloads/index.jsp), it is important