Dear Gurus:
I have an XML request coming in, I don't know what specific type. I have to parse it in order to determine that.
I have the following classes:
abstract XMLRequest
inherited by:
XMLRequestA
XMLRequestB
XMLRequestC
XMLRequest has an abstract method that all children override:
parseRequestMeat() [each one is different, of course.]
and a non-abstract method:
loadAndValidateRequestEnvelope(Document doc)
that sets a whole bunch of things in the XMLRequest, BEFORE setting up the transactionId.
loadAndValidateRequestEnvelope then calls the child's overriden parseRequestMeat(Element MEAT).
-------------------------------------------------------------------------
Now, this worked very well for XMLResponse architecture, since I knew ahead of time which object to make. But this does not work at all in the Request:
When Document comes in, I want to instantiate something and pass it the XML Document for parsing. Trouble is, I can not instantiate the XMLRequest object, nor can I instantiate the XMLRequestA or B because I do not know ahead of time which object it will be... not until I can get the transactionId, to get which I must call loadAndValidateRequestEnvelope(Document doc) on something.
I can use the static XMLRequest req = XMLRequestFactory.getXMLRequest(Document doc);
and then cast it as the appropriate object:
(XMLRequestA)req
but I can't seem to set up anything in the loadAndValidateRequestEnvelope before I instantiate the correct Request. I guess I can write another method and get the transactionId first, then have a case statement in the factory which decides which (A, B, C) to create. Is this the "only" way? Or am I missing something "trivial" in the design?
Any ideas/hints are appreciated.
Greg
To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm