users@jaxb.java.net

Re: How to register a custom ValidationEventHandler with XmlJavaTypeAdapter

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Tue, 08 Feb 2011 10:15:51 +0100

Hello Rajesh,

1)
see http://jaxb.java.net/tutorial/section_3_3-Validation.html#Validation
and
http://jaxb.java.net/tutorial/section_3_4-Validation-Event-Handling.html#Validation%20Event%20Handling

2) no

Pavel

On 02/07/2011 11:02 PM, Mandava, Rajesh wrote:
>
> I have a sample EJB Web Service that uses java.sql.Date. So, I
> used the
>
> XmlJavaTypeAdapter to overcome the problem with no default constructor
>
> (as suggested in the blog
> http://weblogs.java.net/blog/kohsuke/archive/2005/09/using_jaxb_20s.html).
>
> This application is deployed to JBoss 5.1.0 (JRE build 1.6.0_20-b02).
>
> For a date "2011013", my SqlDateAdaptor.unmarshal throws an
> UnmarshalException.
>
> But, the UnmarshallerImpl.handleEvent ignores this exception.
>
> So, I want to add a custom handler MyCustomValidationEventHandler
>
> overriding the handleEvent as follows:
>
> public class MyCustomValidationEventHandler implements
> ValidationEventHandler {
>
> public boolean handleEvent(ValidationEvent event) {
>
> return event.getSeverity()!=ValidationEvent.ERROR &&
>
> event.getSeverity()!=ValidationEvent.FATAL_ERROR;
>
> }
>
> }
>
> How do I register the custom handler MyCustomValidationEventHandler?
>
> 1. Should it be done inside the package-info.java?
>
> 2. Is there a way to get JAXBContext from within SqlDateAdaptor?
>
> Your help will be greatly appreciated.
>
> Thanks and Regards,
>
> *Rajesh Mandava*
> CA Technologies
> Principal Software Engineer
> Tel: +214-473-1334
> Fax: +214-473-1323
> Rajesh.Mandava_at_ca.com <mailto:Rajesh.Mandava_at_ca.com>Marcella.Nunns_at_ca.com
> <mailto:Marcella.Nunns_at_ca.com>cid:image002.gif_at_01CB0303.F65E6E00
> <http://www.ca.com/>
>