You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by "Rich Scheuerle (JIRA)" <ji...@apache.org> on 2007/11/15 13:18:43 UTC

[jira] Created: (WSCOMMONS-279) Performance: Avoid overuse of XMLStreamWriter.getNamespaceContext()

Performance: Avoid overuse of XMLStreamWriter.getNamespaceContext()
-------------------------------------------------------------------

                 Key: WSCOMMONS-279
                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-279
             Project: WS-Commons
          Issue Type: Bug
          Components: AXIOM
            Reporter: Rich Scheuerle
            Assignee: Rich Scheuerle


History:
An XMLStreamWriter is used to serialize Axiom trees.  The NamespaceContext of the XMLStreamWriter is queried to determine if a {prefix, namespace} pair is associated.
If not,"setPrefix(..)" or "setDefaultNamespace(...)" is invoked, which will cause the writer to write a namespace declaration.  
This code is complicated by the determination of whether setPrefix occurs before or after the start tag.

Problem:
Calling getNamespaceContext() is expensive.  Some XMLStreamWriter implementations construct new NamespaceContext objects.  Creating and garbage collection of these objects can cause performance degradations.

Solution:
I wrote an isAssociated(String prefix, String namespace) method in OMSerializerUtil.  This method has a two stage "association" check.  First it uses the writer.getPrefix(uri) call.  If this check fails, it falls back to the getNamespaceContext() check.  This two stage approach avoids unnecessary NamespaceContext construction.  It is also a convenient utility for debugging/support.



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


[jira] Resolved: (WSCOMMONS-279) Performance: Avoid overuse of XMLStreamWriter.getNamespaceContext()

Posted by "Rich Scheuerle (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WSCOMMONS-279?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rich Scheuerle resolved WSCOMMONS-279.
--------------------------------------

    Resolution: Fixed

Committed Revision 595335

> Performance: Avoid overuse of XMLStreamWriter.getNamespaceContext()
> -------------------------------------------------------------------
>
>                 Key: WSCOMMONS-279
>                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-279
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: AXIOM
>            Reporter: Rich Scheuerle
>            Assignee: Rich Scheuerle
>
> History:
> An XMLStreamWriter is used to serialize Axiom trees.  The NamespaceContext of the XMLStreamWriter is queried to determine if a {prefix, namespace} pair is associated.
> If not,"setPrefix(..)" or "setDefaultNamespace(...)" is invoked, which will cause the writer to write a namespace declaration.  
> This code is complicated by the determination of whether setPrefix occurs before or after the start tag.
> Problem:
> Calling getNamespaceContext() is expensive.  Some XMLStreamWriter implementations construct new NamespaceContext objects.  Creating and garbage collection of these objects can cause performance degradations.
> Solution:
> I wrote an isAssociated(String prefix, String namespace) method in OMSerializerUtil.  This method has a two stage "association" check.  First it uses the writer.getPrefix(uri) call.  If this check fails, it falls back to the getNamespaceContext() check.  This two stage approach avoids unnecessary NamespaceContext construction.  It is also a convenient utility for debugging/support.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org