spring-projects / spring-integration

Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns (EIP)
http://projects.spring.io/spring-integration/
Apache License 2.0
1.54k stars 1.11k forks source link

Add templating support to ObjectToStringTransformer [INT-1036] #5031

Open spring-operator opened 14 years ago

spring-operator commented 14 years ago

Keith Donald opened INT-1036 and commented

As a user I'd like the ability to reference a template to use to generate the transformed String, where the model for the template would be the payload.

Example usage:

<object-to-string-transformer input-channel="newAppointmentsChannel" template="classpath:templates/new-appointment-email.st" output-channel="doctorEmailChannel" /> 

Code attached using foundational bits in SPR-6987.


Affects: 2.0 M2

Attachments:

Issue Links:

spring-operator commented 14 years ago

Dave Syer commented

Maybe we could use a filename suffix convention to determine the template type (String Template, Freemarker, Velocity)? Or plug in a template engine strategy? AFAIR the template support in Spring is not web specific so it should be possible to plug into that (with immediate support in existing releases of Spring and String Template support once SPR-6987 is resolved).

spring-operator commented 14 years ago

Mark Fisher commented

I think the template strategy is the way to go. This would be analogous to the Serializer strategy for the payload-serializing-transformer. Like that transformer, this one would rely on basic Java (toString) for the default, but allow the configuration of the strategy. We should probably support StringTemplate, Freemarker, and Velocity. Any others?

spring-operator commented 14 years ago

Keith Donald commented

I really think we should get Andy to do our own Spel-based StringTemplate and then just support that.

spring-operator commented 14 years ago

Mark Fisher commented

Relying on SpEL alone would be ideal. However, I'm also considering cases where someone needs to reference a template for a significant piece of text (e.g. an email message body). Furthermore, they might have existing Velocity or Freemarker templates for that. Do you think we would even want to support all of that via strategies within SpEL?

spring-operator commented 14 years ago

Keith Donald commented

SpEL templating similiar to StringTemplate should cover email templating requirements with no problem. If someone wanted to reuse their existing templates, I'd say they'd just plugin Freemarker or Velocity then.

spring-operator commented 12 years ago

Gunnar Hillert commented

With #5031 on my plate for one of the upcoming Sprints, I was wondering how sophisticated we may want to go with the Templating support. Would SpEL templating be sufficient or should we add support for other templating mechanisms such as Scalate [2], Freemarker[3] or Velocity [4]?

Scalate might be interesting as well, as it would introduce Scala-based templating. This might be something that also feeds into creating Scala-based adapters.

If you spin the thought-process further, there might also be use-cases for providing foundational support for document transformers. As I am in the process of creating a Print component [5], I am wondering if down the road, we may consider document transformers e.g. for Pdf, Excel, Word etc. This could be modeled based (borrowed from) on the respective Spring MVC support classes [6] [7].

Wanted to start the discussion to determine the scope of the Jira and or additional Jiras to be created. Any thoughts are extremely welcome!

[1] https://jira.springsource.org/browse/INT-1036 [2] http://scalate.fusesource.org/ [3] http://freemarker.sourceforge.net/ [4] http://velocity.apache.org/ [5] https://jira.springsource.org/browse/INTEXT-1 [6] http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/view.html#view-document-configsubclasspdf [7] http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/view.html#view-document-configsubclasses

spring-operator commented 9 years ago

Gary Russell commented

I just whipped up a Freemarker transformer for a question on StackOverflow.

I wasn't aware of this issue, so I opened #7771.