[ http://mc4j.org/jira/browse/STS-316?page=all ]

Ignacio Coloma updated STS-316:
-------------------------------

    Attachment: jpa-v2.zip

Added jpa-v2.zip. Things added:

* Fixed two NPE because it was not fully tested. Now it is,  afaik.
* Added full configuration support for the AnnotationConverter, like:
                <init-param>
                     <param-name>AnnotationConverter.Classes</param-name>
                     <param-value>
                        
net.sourceforge.stripes.validation.ValidateAnnotationConverter,
                        
net.sourceforge.stripes.validation.ValidateJpaAnnotationConverter,
                        
net.sourceforge.stripes.validation.ValidateNestedPropertiesAnnotationConverter
                     </param-value>
* Added an attribute "on" to @ValidateJpa that works like @Validate, for 
example:
@ValidateJpa(on="save")
private PersistentObject myObject;

The only bug that still remains and breaks 
InheritanceTests.testInheritedValidations() is that I don't know how to treat 
overriding validations with the 'required' and 'ignores' attributes set/unset, 
because they are boolean and not Boolean. 

To see the new annotation support working, go to 
ValidateJpaAnnotationConverterTest. I am right now using this with a real-world 
project and works fine. 

Cheers.

> Patch: pluggable annotation support for stripes
> -----------------------------------------------
>
>                 Key: STS-316
>                 URL: http://mc4j.org/jira/browse/STS-316
>             Project: Stripes
>          Issue Type: New Feature
>          Components: Validation
>            Reporter: Ignacio Coloma
>         Assigned To: Tim Fennell
>         Attachments: jpa-v2.zip, pluggable-annotation-support.zip
>
>
> This is an attempt to give support for JPA annotations from inside Stripes. 
> Enclosed is a patch that does the following:
> 1.- Convert the annotation mechanism of stripes to be pluggable, and 
> therefore not limited to @Validate and @ValidateNestedProperties. In the line 
> of scratching my itch, I have implemented a @ValidateNestedJpaProperties (I 
> know the name sucks). 
> 2.- There is an AnnotationConverter interface that translates any kind of 
> annotation to the internal Stripes representation (ValidationMetadata). For 
> example, the tag above will seek the nested attributes and convert standard 
> JPA annotations (required, length, etc) into stripes internal representation.
> 3.- These annotation converters are stackable, but I still have to figure the 
> desired behaviour. The idea is to allow this kind of situation:
> @ValidateNestedJpaProperties
> @ValidateNestedProperties(<fine tuning here>)
> private PersistentObject instance;
> Where the second annotation would override the first one(for example, 
> changing length or required of certain attributes). It is more or less 
> implemented, but I still don't have a very clear idea of the expected 
> behaviour.
> If this works, annotations would be pluggable: you can give support to 
> Hibernate Annotations, JPA annotations, webwork annotations, all inside 
> stripes and override certain parts.
> Caveats: configuration is not finished (only provided a default config with 
> Validate and ValidateNestedProperties annotations) and haven't checked fully 
> if something broke. Some more tests should be implemented, but they are easy. 
> Anyways, I wanted to submit this to get some feedback (this is only a 
> proposal that might not be accepted). The big size is because I need an ejb3 
> jar file to be able to test annotation support.
> Tim, your code is great!! Amazingly easy to understand.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://mc4j.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to