You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Takahide Nogayama <NO...@jp.ibm.com> on 2006/11/09 18:19:19 UTC
Re: Request for XML Filter (AXIS2-1085)
All,
I inspect the Handler solution, the following is pros and cons.
pros) There is no layer mixing.
pros) There are no filter related code in AXIS2.
cons) Need to change StAXBuilder to replace XMLStreamReader by Filter.
To replace XMLStreamReader of builder by Filter, we have to add
"setParser" method to "StAXBuilder".
(we can get builder instance in handler by using
((OMElementImpl)msgctx.getEnvelope()).getBuilder() )
Apache community had already disscussed about this method ever.
They concluded that they will never
add this method to StAXBuilder. Because if some one tries to
changes the parser, while the object
model is being built or partially build, everything will get
screwed.
I heard this from
Eran.http://issues.apache.org/jira/browse/WSCOMMONS-76#action_12434318
cons) Filter can not see SOAPHeader StAXEvents. SOAPHeader part is
probably already built at the time by SOAPEnvelope.getBody().
For Example, (if we can add setParser to StAXBuilder) WSS
specification says that two wsu:Id attributes within
an XML document MUST NOT have the same value. So
Id-Uniqueness-check-Filter must check Id-Uniqueness against entire XML
document. However, at the top of Handler chain, the elements
before <soapenv:Body> have already been build by
SOAPEnvelope.getBody(). That is, its StAX events are consumed and
trashed. Id-Uniqueness-check-Filter which is inserted by handler
can check the StAX events of <soapenv:Body> and its descendant
elements, but it can not check entire Id-Uniqueness.
---------------------------
Takahide Nogayama
Re: Request for XML Filter (AXIS2-1085)
Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
On Tue, 2006-12-05 at 01:25 +0900, Takahide Nogayama wrote:
>
> Hi Sanjiva,
>
> I am hoping to resume this discussion with you.
> Please give us comment about these alternative solution's pros and
> cons or let me know what is your concrete worry.
Sorry for dropping the ball on this; will review thread and reply to old
messages now. My apologies.
Sanjiva.
--
Sanjiva Weerawarana, Ph.D.
Founder & Director; Lanka Software Foundation; http://www.opensource.lk/
Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
Director; Open Source Initiative; http://www.opensource.org/
Member; Apache Software Foundation; http://www.apache.org/
Visiting Lecturer; University of Moratuwa; http://www.cse.mrt.ac.lk/
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org
Re: Request for XML Filter (AXIS2-1085)
Posted by Takahide Nogayama <NO...@jp.ibm.com>.
Hi Sanjiva,
I am hoping to resume this discussion with you.
Please give us comment about these alternative solution's pros and cons or
let me know what is your concrete worry.
Regards,
---------------------------
Takahide Nogayama
Re: Request for XML Filter (AXIS2-1085)
Posted by Takahide Nogayama <NO...@jp.ibm.com>.
Look back at original solution, Filter configuration , filter is
enabled/disabled, is written in axis2.xml and stored in
axis2configuration.
At transport layer compornent, Filter configuration is read and filter
instance is created, if it is enabled. MessageContext and XMLStreamReader
are passed to the filter, and XMLStreamReader is replaced by the filter.
Then, StAXOMBuilder is created from the filter.
Original solution solves an issue of Handler solution "need to change
StAXBuilder." In Handler solution, filter is inserted after builder is
created.
So StAXBuilder is needed to change to replace XMLStreamReader, In original
solution, filter is inserted before builder is created. filter is passed
to StAXBuilder constructor instead of XMLStreamReader. We can avoid to add
setParser(XMLStreamReader) method to StAXBuilder. And original
solution solves an issue of XMLInputFactory solution, MessageContext is
passed to filter explicitly by using input parameter. It is easy to
understand
and keeps consistency because there is no use of static reference or
Thread Local strage. I believe this origianal solution is most reasnable
if we introduce
filter framework.
The following is code snippet of transport layer compornent.
// replace xmlreader by filter if filter is enabled.
xmlreader =
msgContext.getConfigurationContext().getAxisConfiguration().getFilterRegistry().enableFilter(xmlreader,
msgContext);
builder = new StAXSOAPModelBuilder(xmlreader,
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
envelope = (SOAPEnvelope) builder.getDocumentElement();
The points of original solution are
- Pass MessageContext to filter at transport layer components
explicitly. (write the passing code on each transport layer components)
- Insert filter at transport layer components explicitly. (write
inserting code on each transport layer components)
- Filter configuration is stored in axis2.xml
pros)
- Filter can see all StAXEvents of the message. Because filter is
inserted before OM tree is built.
- It is easy to understand about passing MessageContext. because it is
passed explicitly as an input parameter to filter.
- We can avoid to change StAXBuilder (add setParser(XMLStreamReader)
method to StAXBuilder).
cons)
- There is layer mixing. (User can do QOS related processing in
parsing layer.)
- Need to change AXIS2 transport layer components.
Regards,
---------------------------
Takahide Nogayama
Re: Request for XML Filter (AXIS2-1085)
Posted by Takahide Nogayama <NO...@jp.ibm.com>.
And We also inspect another solution which uses XMLInputFactory.
In this solution, Filter is inserted at XMLInputFactory which is written
by us.
The XMLInputFactory returns Filter instance. The filter wraps
XMLStreamReader
(Filter -> XMLStreamReader). And the filter goes into builder (StAXBuilder
->
Filter -> XMLStreamReader). Here, filter configuration is stored in
XMLInputFactory.
We expect that the ode which pass MessageContext to XMLInputFactory will
be too complex,
because XMLInputFactory is wrapped by StAXUtils and StaxUtils reuses
several XMLInputFactory.
To avoid this complex, we can use ThreadLocal-Storage. We store
MessageContext immediately to the
ThreadLocal-Storage when it is created, then filter which is in the same
thread can get
MessageContext by the ThreadLocal-Storage. (In current implementation,
MessageContext is stored
on ThreadLocal-Storage at receiver layer. That is, MessageContext is not
stored when the message
processed in transport layer and handler layer. To archieve this
XMLInputFactory solution,
we have to change transport layer to store MC to TLS.)
# We do not think this solution is good. because TLS is used.
The points of XMLInputFactory solution are
- Insert filter inside of XMLInputFactory
- Filter configuration is stored in the XMLInputFactory
- Pass MessageContext by using ThreadLocal-Storage
pros) There are no filter related code in AXIS2.
cons) Need to change to AXIS2 transport layer component to store
MessageContext on ThreadLocal-Storage when it is created.
cons) This seems contradict to MC design. We put context information
in Axis Service/Operation/Message context because there is no control of
when there is a thread switch.
Regards,
---------------------------
Takahide Nogayama