[
https://issues.jboss.org/browse/CDI-572?page=com.atlassian.jira.plugin.sy...
]
Mark Struberg commented on CDI-572:
-----------------------------------
[~mkouba] yes, @Inject might be needed. But one could also use @PostConstruct to init this
field. Or use Method injection. All that doesn't matter. Point is that _after_ all the
injection was done and the instance is fully initialized it could be useful to invoke
JSR-303 on it.
Also what should happen if a validation fails?
Well that's
a good question. What happens if there is some Exception in @PostConstruct? Guess the same
should happen here as well. Or even throw a nice validation Exception.
I agree with [[~Sven Linstaedt] that those checks only make sense at runtime. It might as
well be that it fails for one request but passes for another one... If you think about
business data producers this also makes perfect sense.
support JSR-303 bean validation in CDI beans
--------------------------------------------
Key: CDI-572
URL:
https://issues.jboss.org/browse/CDI-572
Project: CDI Specification Issues
Issue Type: Epic
Reporter: Mark Struberg
Consider a bean like
{code}
@SessionScoped
public class CurrentUser {
@javax.validation.constraint.NotNull
@javax.validation.constraint.Length(10)
private String userId;
...
}
{code}
We could easily check this and invoke JSR-303 (if available) in the Producer<T>.
Please note that for a custom Producer they have to care for it themselves.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)