-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Wrong method signature for Constraint initalization?
PostPosted: Wed Jan 07, 2009 7:05 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

I am wondering about constraint initialization, especially in the context of composite constraints. The current interface for Constraint looks like this:
Code:
public interface Constraint<A extends Annotation> {
   void initialize(A constraintAnnotation);
   boolean isValid(Object object, ConstraintContext constraintContext);
}

Effectively you are passing the constraint annotation itself into initialize(). This works fine for constraints defined on beans. However, in the case of composing constraints it makes things harder since parameters can be overridden. Woudln't it be better to pass a map into initalize()?
Another reason why I think this is useful is that one could in this case instantiate and initialize a constraint using ConstraintDescriptor information only ( ConstraintDescriptor contains getConstraintClass() and getParameters() which returns the parameters as map). This is otherwise not possible.

Any comments?

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 10:16 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't like the Map approach very much
But what you can do is build the annotation instance using a dynamic proxy. Remember that an annotation is an interface.
The dynamic proxy can itself use the Map<String, Object>.
Check commons annotations we do just that.
That way the BV user still see a type safe annotation and not the messy Map.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.