Return-Path: X-Original-To: apmail-avro-dev-archive@www.apache.org Delivered-To: apmail-avro-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1D161D34C for ; Thu, 1 Nov 2012 20:27:13 +0000 (UTC) Received: (qmail 11805 invoked by uid 500); 1 Nov 2012 20:27:12 -0000 Delivered-To: apmail-avro-dev-archive@avro.apache.org Received: (qmail 11723 invoked by uid 500); 1 Nov 2012 20:27:12 -0000 Mailing-List: contact dev-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@avro.apache.org Delivered-To: mailing list dev@avro.apache.org Received: (qmail 11664 invoked by uid 99); 1 Nov 2012 20:27:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Nov 2012 20:27:12 +0000 Date: Thu, 1 Nov 2012 20:27:12 +0000 (UTC) From: "Doug Cutting (JIRA)" To: dev@avro.apache.org Message-ID: <1611432626.57655.1351801632614.JavaMail.jiratomcat@arcas> In-Reply-To: <593003561.44682.1351606574153.JavaMail.jiratomcat@arcas> Subject: [jira] [Updated] (AVRO-1186) Java Annotations via IDL MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AVRO-1186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Doug Cutting updated AVRO-1186: ------------------------------- Status: Patch Available (was: Open) I'll commit this soon unless someone objects. > Java Annotations via IDL > ------------------------ > > Key: AVRO-1186 > URL: https://issues.apache.org/jira/browse/AVRO-1186 > Project: Avro > Issue Type: New Feature > Components: java > Reporter: Sharmarke Aden > Assignee: Doug Cutting > Fix For: 1.7.3 > > Attachments: AVRO-1186.patch, AVRO-1186.patch > > > We would like to have the ability to add Java annotations to fields in the Avro IDL (i.e. JSR 303 Bean Validation annotations). From a protocol stand point these annotations may not mean much (or could they?) but from the application stand point having this feature would allow developers to use Avro generated beans application wide. From view layer all the way to the data layer. To support this feature an IDL file could look something like this: > {code} > @namespace("test.annotations") > protocol TestProto { > record User { > //declare the annotations that are imported in the generated record class > @header{ > import org.hibernate.validator.constraints.NotBlank; > import org.hibernate.validator.constraints.Email; > } > > //for each field one can specify an annotation they would like to use. > @{@NotBlank} string username; > string password; > @{@Email} string email; > } > } > {code} > The above IDL would generate a Java class that looks something like this: > {code} > /** > * Autogenerated by Avro > * > * DO NOT EDIT DIRECTLY > */ > package com.simvia.mode.avro; > import org.hibernate.validator.constraints.NotBlank; > import org.hibernate.validator.constraints.Email; > @SuppressWarnings("all") > public class User extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { > ... > @Deprecated @NotBlank public java.lang.CharSequence username; > @Deprecated public java.lang.CharSequence password; > @Deprecated @Email public java.lang.CharSequence email; > ... > } > {code} > Perhaps this is too language specific but IMO the benefits of this feature in the Java world is worth the effort and the exception. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira