Hi all,

When creating an OMSourcedElementImpl object, we should provide the expected
local name and the namespace of the OMElement which will be built by
consuming the OMDataSource inside.

public OMSourcedElementImpl(java.lang.String string,
org.apache.axiom.om.OMNamespace omNamespace,
org.apache.axiom.om.OMFactoryomFactory,
org.apache.axiom.om.OMDataSource omDataSource)

I'm using this OMSourcedElementImpl in JSON implementation of Axis2, in the
receiving side to build the OMElement. I keep the JSON input stream in the
DataSource and consume it only when the OMElement needs to be built. If the
service is a Javascript one, it can understand JSON and I let the user to
access the JSON string directly through DataSource, without building the
OMElement.

But there is a problem of knowing the local name and the namespace of the
OMElement at the time we instantiate the OMSourcedElementImpl, because the
input stream is not consumed at that time. Whole input stream should be
passed in order to get the namespace of the incoming message. If we use a
wrong local name and a namespace, it throws an exception stating that the
local name and the namespace are not expected ones.

I think the usage of providing the local name and the namespace at the time
of instantiation exists in the case of someone calling getLocalName() method
or getNamespace() method before the DataSource is consumed.

As a solution for the above problem, can we have another constructor in
OMSourcedElementImpl which doesn't need the local name and namesapace? If
someone will call getLocalName() or getNamespace() we can let it build the
OMElement in the case of local name and namespace are not given through the
constructor. In our case regarding JSON, getLocalName() and getNamespace()
are called very rarely. So even if we use this method, the advantage of
using the OMSourcedElementImpl will remain as it was earlier.

regards,
~Isuru

Reply via email to