[ 
https://issues.apache.org/jira/browse/AVRO-1762?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Matheus Santana updated AVRO-1762:
----------------------------------
    Attachment: AVRO-1762.patch

This [sample application|https://github.com/geteloquent/avro-extension-sample] 
illustrates the usage of applied improvements. It uses [POM-based 
configuration|https://github.com/geteloquent/avro-extension-sample/blob/master/pom.xml#L48-L60]
 to achieve complete customization of [generated source 
code|https://github.com/geteloquent/avro-extension-sample/blob/master/target/generated-sources/avro/Person.java]
 through [custom Velocity 
template|https://github.com/geteloquent/avro-extension-sample/blob/master/src/main/velocity-templates/record.vm]
 and a [custom 
object|https://github.com/geteloquent/velocity-tools-avro/blob/master/src/main/java/br/com/me/CustomTool.java]
 which gets injected into template's context.

Notes: i) I intend to gather feedback about the given modification's 
suggestions, which may be improved, refactored and provided in the proper 
{{.path}} format.

ii) Suggested modification is also available in this [Github 
repository|https://github.com/geteloquent/avro/tree/AVRO-1762-velocity-custom-objects]
 and the diff is accessible 
[here|https://github.com/apache/avro/compare/trunk...geteloquent:AVRO-1762-velocity-custom-objects].

> Allow putting additional objects into the Velocity template
> -----------------------------------------------------------
>
>                 Key: AVRO-1762
>                 URL: https://issues.apache.org/jira/browse/AVRO-1762
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>            Reporter: Matheus Santana
>         Attachments: AVRO-1762.patch
>
>
> This JIRA proposes the ability to inject custom POJOs into the Velocity 
> template.
> It is possible [to override template directory 
> configuration|https://issues.apache.org/jira/browse/AVRO-963?jql=project%20%3D%20AVRO%20AND%20component%20%3D%20java%20AND%20text%20~%20%22template%22]
>  and thus make the compiler to generate customized code. However, 
> customization possibilities are constrained to [Velocity Template 
> Language|https://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html#velocity_template_language_vtl:_an_introduction]
>  and [objects 
> injected|https://github.com/apache/avro/blob/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java#L339-L340]
>  into the template's context.
> The ability of injecting custom objects into the template's context would 
> leverage customization possibilities to the whole Java language itself. The 
> patch I'm about to attach modifies both compiler and maven-plugin in order to 
> provide client applications with the ability of easy injecting custom Java 
> objects into the Velocity templates' context.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to