You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Sharmarke Aden (JIRA)" <ji...@apache.org> on 2012/10/30 15:16:14 UTC

[jira] [Created] (AVRO-1186) Java Annotations via IDL

Sharmarke Aden created AVRO-1186:
------------------------------------

             Summary: Java Annotations via IDL
                 Key: AVRO-1186
                 URL: https://issues.apache.org/jira/browse/AVRO-1186
             Project: Avro
          Issue Type: New Feature
            Reporter: Sharmarke Aden


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

[jira] [Updated] (AVRO-1186) Java Annotations via IDL

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-1186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting updated AVRO-1186:
-------------------------------

      Component/s: java
    Fix Version/s: 1.7.3
         Assignee: Doug Cutting
    
> 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
>
>
> 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

[jira] [Updated] (AVRO-1186) Java Annotations via IDL

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-1186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting updated AVRO-1186:
-------------------------------

    Resolution: Fixed
        Status: Resolved  (was: Patch Available)

I committed this.
                
> 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

[jira] [Updated] (AVRO-1186) Java Annotations via IDL

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-1186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting updated AVRO-1186:
-------------------------------

    Attachment: AVRO-1186.patch

Here's a patch that implements this.

The property "javaAnnotation" may have either a Json string or a Json array of strings as its value.  It may be on a schema, field, protocol or message.  The compiler will generate the provided annotation(s) on the generated class, field, interface or method, respectively.
                
> 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
>
>
> 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

[jira] [Commented] (AVRO-1186) Java Annotations via IDL

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AVRO-1186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13487090#comment-13487090 ] 

Doug Cutting commented on AVRO-1186:
------------------------------------

The IDL compiler already parses arbitrary annotations as JSON and adds them to the schema.  So the easiest way to implement this might be to change the specific compiler template to emit Java annotations for a particular "javaAnnotation" schema property.  The IDL might then look like:

{code}
record User {
  @javaAnnotation("org.hibernate.validator.constraints.NotBlank") string username;
}
{code}

For multiple annotations one might use a JSON array, e.g.:

{code}
record User {
  @javaAnnotations(["Deprecated", 
                    "org.hibernate.validator.constraints.NotBlank"])
    string username;
}
{code}

Would this suffice?

                
> Java Annotations via IDL
> ------------------------
>
>                 Key: AVRO-1186
>                 URL: https://issues.apache.org/jira/browse/AVRO-1186
>             Project: Avro
>          Issue Type: New Feature
>            Reporter: Sharmarke Aden
>
> 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

[jira] [Updated] (AVRO-1186) Java Annotations via IDL

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ 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

[jira] [Commented] (AVRO-1186) Java Annotations via IDL

Posted by "Sharmarke Aden (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AVRO-1186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13487106#comment-13487106 ] 

Sharmarke Aden commented on AVRO-1186:
--------------------------------------

This is perfect. What about also adding record/class level annotations support? For example: 

{code}
@javaAnnotation("com.company.MyClassAnnotation")
record User {
  @javaAnnotation("org.hibernate.validator.constraints.NotBlank") string username;
}
{code}

For multiple:

{code}
@javaAnnotation(["Deprecated", "com.company.MyClassAnnotation"])
record User {
  @javaAnnotations(["Deprecated", 
                    "org.hibernate.validator.constraints.NotBlank"])
    string username;
}
{code}
                
> Java Annotations via IDL
> ------------------------
>
>                 Key: AVRO-1186
>                 URL: https://issues.apache.org/jira/browse/AVRO-1186
>             Project: Avro
>          Issue Type: New Feature
>            Reporter: Sharmarke Aden
>
> 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

[jira] [Updated] (AVRO-1186) Java Annotations via IDL

Posted by "Sharmarke Aden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-1186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sharmarke Aden updated AVRO-1186:
---------------------------------

    Description: 
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.

  was:
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.

    
> Java Annotations via IDL
> ------------------------
>
>                 Key: AVRO-1186
>                 URL: https://issues.apache.org/jira/browse/AVRO-1186
>             Project: Avro
>          Issue Type: New Feature
>            Reporter: Sharmarke Aden
>
> 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

[jira] [Commented] (AVRO-1186) Java Annotations via IDL

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AVRO-1186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13488187#comment-13488187 ] 

Doug Cutting commented on AVRO-1186:
------------------------------------

> What about also adding record/class level annotations support?

Yes.  I'll include that too.
                
> 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
>
>
> 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

[jira] [Updated] (AVRO-1186) Java Annotations via IDL

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-1186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting updated AVRO-1186:
-------------------------------

    Attachment: AVRO-1186.patch

Here's a new version of the patch that has more tests.
                
> 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

[jira] [Commented] (AVRO-1186) Java Annotations via IDL

Posted by "Sharmarke Aden (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AVRO-1186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13489007#comment-13489007 ] 

Sharmarke Aden commented on AVRO-1186:
--------------------------------------

Wow, that was really quick. Thank you so much and keep up the great work.

                
> 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