The DataHandler#getInputStream()
method basically delegates to DataSource#getInputStream()
and the contract of that method specifically requires that the content of the DataSource
can be read multiple times. Axiom is designed to conform to that contract.
Axiom defines an extension interface (DataHandlerExt
) that can be used in scenarios where one wants to "destructively" read the content.
There is however one thing you need to pay attention to: at the end of the request processing (i.e. after your service has been invoked), Axis2 is expected to instruct Axiom to destroy the temporary files related to DataHandler
instances created during the request. That means that if you store a reference to a DataHandler
and try to access it later (in another request, or in some background thread), then this may fail. Note that in a future version of Axiom it is planned to introduce an option that would let the garbage collector handle that cleanup, which would avoid this problem.