|
Replies:
5
-
Last Post:
Jul 17, 2008 11:17 PM
by: airwin
|
|
|
|
|
|
|
performance and validation
Posted:
Jul 3, 2008 8:53 PM
|
|
|
Hello,
I'm using Jax-ws 2.0 and trying to do schema validation of the incoming messages using the JAXB LogicalHandler, ValidationEventHandler and Unmarshaller. I have a few questions related to my design and performance issues.
1) The documentation mentions that a JAXBContext is expensive to create and designed to be thread safe, so as suggested I keep a Singleton version. However it also says that the Unmarshaller is not thread safe, yet I'd think it would be expensive to create due to the schemas that are required to be passed to it (I'm assuming it parses the schemas in prep for validation, please let me know if I'm wrong here). Is the normal design to create a new Unmarshaller for each call into the handler? Is this expensive?
2) In my LogicalHandler I make the call
unMarshaller.unmarshal(message.getPayload())
Which actually performs the unmarshalling and validation. Assuming the validation passes and the incoming call then proceeds to its final destination (endpoint) does the unmarshalling then happen again as the incoming data is passed to the endpoint? If that's the case, it would seem to me that I'd want just validation to happen in the Handler not unmarshalling as I wouldn't want unmarshalling to happen twice as I'd expect it's expensive. Any way to do that?
I apologize ahead of time if the answers to these questions are obvious and I've just missed them. Any insights are appreciated.
thanks!
|
|
|
|
|
|
|
Re: performance and validation
Posted:
Jul 17, 2008 10:55 PM
in response to: airwin
|
|
|
Over 300 views and no reply. Did I phrase the question badly? Leave out information? or does no one know?
|
|
|
|
|
|
|
|
Re: performance and validation
Posted:
Jul 17, 2008 10:58 PM
in response to: airwin
|
|
|
Why don't you use @SchemaValidation and SchemaValidationFeature ?
|
|
|
|
|
|
|
|
Re: performance and validation
Posted:
Jul 17, 2008 11:02 PM
in response to: jitu
|
|
|
I'm using JAX-WS 2.0, that's not available till a later version from my understanding.
|
|
|
|
|
|
|
|
Re: performance and validation
Posted:
Jul 17, 2008 11:04 PM
in response to: airwin
|
|
|
> Hello, > > I'm using Jax-ws 2.0 and trying to do schema > validation of the incoming messages using the JAXB > LogicalHandler, ValidationEventHandler and > Unmarshaller. I have a few questions related to my > design and performance issues. > > 1) The documentation mentions that a JAXBContext is > expensive to create and designed to be thread safe, > so as suggested I keep a Singleton version. However > it also says that the Unmarshaller is not thread > safe, yet I'd think it would be expensive to create > due to the schemas that are required to be passed to > it (I'm assuming it parses the schemas in prep for > validation, please let me know if I'm wrong here). > Is the normal design to create a new Unmarshaller > for each call into the handler? Is this expensive?
See https://jaxb.dev.java.net/guide/Performance_and_thread_safety.html
> > 2) In my LogicalHandler I make the call > > > Marshaller.unmarshal(message.getPayload()) > > Which actually performs the unmarshalling and > validation. Assuming the validation passes and the
Marshaller.unmarshal() doesn't do complete schema validation. To do the schema validation, you need to use JAXP API
> incoming call then proceeds to its final destination > (endpoint) does the unmarshalling then happen again > as the incoming data is passed to the endpoint? If > that's the case, it would seem to me that I'd want > just validation to happen in the Handler not > unmarshalling as I wouldn't want unmarshalling to > happen twice as I'd expect it's expensive. Any way > to do that? > > I apologize ahead of time if the answers to these > questions are obvious and I've just missed them. Any > insights are appreciated. > > thanks!
|
|
|
|
|
|
|
|
Re: performance and validation
Posted:
Jul 17, 2008 11:17 PM
in response to: jitu
|
|
|
Thank you very much for that link! I had seen it before but must have not read the last few lines.
I use the unMarshaller.setSchema call to set the schemas for the unmarshaller (this uses JAXP underneath believe) and then the call to unmarshaller.unmarshal actually validates against those schemas using JAXP underneath again. I believe that's correct as it seems to be working for me.
|
|
|
|
|