views:

410

answers:

6

Are there any commonly usable annotations available? Similar to commons-lang?

If not, have you seen any effective use of annontations (not built-in annotations) as part of any open source application development.

I remember Mifos was using it for Transaction.

Mohan

+3  A: 

i think Hibernate Validator has really good and reusable annotations for any kind of validation. it is based on a the reference implementation for JSR 303: Bean Validation.

01
+3  A: 

Only non-standard annotations I've used more than once outside my testing project have been WicketStuff Annotations which are very useful in their own context.

Another interesting annotation set which is also the basis for JSR-305 is FindBugs' annotations which also may prove useful in the future - we'll see how that goes.

Esko
A: 

there really needs to be a set of common annotationsin the core jre which are used in similar ways in multiple frameworks.

for example ATTransactional ATNullable - SO does not the the AT char

Andreas Petersson
+2  A: 

Check out my Bean annotations

http://code.google.com/p/javadude/wiki/Annotations

Things like

@Bean(
    cloneable=true,
    defineSimpleEqualsAndHashCode=true,
    properties={
        @Property(name="name", bound=true),
        @Property(name="age", type=int.class, bound=true),
        @Property(name="friend", type=Person.class, kind=PropertyKind.LIST)
    },
    observers={
        @Observer(type=FeverListener.class)
    }
)
public class Person extends PersonGen { }

The annotation processor generates the PersonGen superclass.

Note that I'm currently working on a major change to them and the API is changing (I'll still leave the current version available, but the 3.x.x version stream will be breaking)

I'm trying to get the new version done in the next couple of weeks.

Scott Stanchfield
This looks interesting, but I would really prefer not generating additional classes, or having to sub-class/implement anything. To keep POJOs as POJOs. Is it possible to just validate using annotations without code generation?
StaxMan
They really are POJOs (just a two-class POJO instead of one). Much nicer than writing all that boilerplate...Also -- you can specify @Bean(superclass=SomeClass.class...) and the generated superclass will extend that class, interting itself inbetween.
Scott Stanchfield
A: 

JAXB defines annotations (javax.xml.bind.annotation) that are reused to some degree -- although they are named to indicate they only related to XML serialization, most of metadata has to do with annotating properties to serialize, so they can be used for serializing to other data formats (such as JSON) too. Jackson JSON processor supports them, along its own 'native' annotations, since there are no really standardizes non-data-format specific annotations (AFAIK).

StaxMan
A: 

I like and Oval http://oval.sourceforge.net/ and JAXB

Adam Gent