ws-commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r791968 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/om/ axiom-api/src/main/java/org/apache/axiom/om/impl/ axiom-api/src/main/java/org/apache/axiom/om/impl/builder/ axiom-api/src/main/java/...
Date Tue, 07 Jul 2009 20:25:01 GMT
Author: veithen
Date: Tue Jul  7 20:25:01 2009
New Revision: 791968

URL: http://svn.apache.org/viewvc?rev=791968&view=rev
Log:
WSCOMMONS-487: Implemented a new extension mechanism to retrieve DataHandler objects from an XMLStreamReader implementation. This supersedes the existing IS_DATA_HANDLERS_AWARE extension, but compatibility is maintained (tested with Axis2).

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/DataHandlerReaderUtil.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/ext/
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/ext/DataHandlerProvider.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/ext/DataHandlerReader.java   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTextTestBase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java?rev=791968&r1=791967&r2=791968&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java Tue Jul  7 20:25:01 2009
@@ -59,30 +59,23 @@
             "xml";
     
     /**
-     * {@link javax.xml.stream.XMLStreamReader} property used to check if a given
-     * {@link javax.xml.stream.XMLStreamConstants#CHARACTERS} event represents
-     * base64 encoded binary data exposed as a {@link javax.activation.DataHandler}.
+     * @deprecated
      * 
-     * @see org.apache.axiom.om.impl.builder.StAXOMBuilder
+     * @see org.apache.axiom.om.impl.builder.DataHandlerReaderUtil
      */
     String IS_BINARY = "Axiom.IsBinary";
     
     /**
-     * {@link javax.xml.stream.XMLStreamReader} property used to retrieve the
-     * {@link javax.activation.DataHandler} for a
-     * {@link javax.xml.stream.XMLStreamConstants#CHARACTERS} event representing
-     * base64 encoded binary data.
+     * @deprecated
      * 
-     * @see org.apache.axiom.om.impl.builder.StAXOMBuilder
+     * @see org.apache.axiom.om.impl.builder.DataHandlerReaderUtil
      */
     String DATA_HANDLER = "Axiom.DataHandler";
     
     /**
-     * {@link javax.xml.stream.XMLStreamReader} property indicating that the
-     * reader is capable of exposing base64 encoded binary content as
-     * {@link javax.activation.DataHandler} objects.
+     * @deprecated
      * 
-     * @see org.apache.axiom.om.impl.builder.StAXOMBuilder
+     * @see org.apache.axiom.om.impl.builder.DataHandlerReaderUtil
      */
     String IS_DATA_HANDLERS_AWARE = "IsDatahandlersAwareParsing"; 
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java?rev=791968&r1=791967&r2=791968&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java Tue Jul  7 20:25:01 2009
@@ -21,6 +21,8 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.axiom.stax.ext.DataHandlerProvider;
+
 /** Class OMFactory */
 public interface OMFactory {
 
@@ -177,6 +179,21 @@
     OMText createOMText(OMContainer parent, String s, String mimeType,
                                boolean optimize);
 
+    /**
+     * Create a binary {@link OMText} node supporting deferred loading of the content.
+     * 
+     * @param contentID
+     *            the content ID identifying the binary content; may be <code>null</code>
+     * @param dataHandlerProvider
+     *            used to load the {@link DataHandler} when requested from the returned
+     *            {@link OMText} node
+     * @param optimize
+     *            determines whether the binary content should be optimized
+     * @return
+     */
+    OMText createOMText(String contentID, DataHandlerProvider dataHandlerProvider,
+            boolean optimize);
+
     OMText createOMText(String contentID, OMContainer parent,
                                OMXMLParserWrapper builder);
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java?rev=791968&r1=791967&r2=791968&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java Tue Jul  7 20:25:01 2009
@@ -37,7 +37,6 @@
 import org.apache.axiom.om.OMAttachmentAccessor;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMComment;
-import org.apache.axiom.om.OMConstants;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMDocument;
 import org.apache.axiom.om.OMElement;
@@ -50,10 +49,13 @@
 import org.apache.axiom.om.OMXMLStreamReader;
 import org.apache.axiom.om.impl.EmptyOMLocation;
 import org.apache.axiom.om.impl.OMNavigator;
+import org.apache.axiom.om.impl.builder.DataHandlerReaderUtil;
 import org.apache.axiom.om.impl.builder.StAXBuilder;
 import org.apache.axiom.om.impl.exception.OMStreamingException;
 import org.apache.axiom.om.impl.util.NamespaceContextImpl;
 import org.apache.axiom.stax.AbstractXMLStreamReader;
+import org.apache.axiom.stax.ext.DataHandlerProvider;
+import org.apache.axiom.stax.ext.DataHandlerReader;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -62,7 +64,7 @@
  * constants.
  */
 public class OMStAXWrapper extends AbstractXMLStreamReader
-    implements OMXMLStreamReader, XMLStreamConstants {
+    implements OMXMLStreamReader, DataHandlerReader, XMLStreamConstants {
     
     private static final Log log = LogFactory.getLog(OMStAXWrapper.class);
     private static boolean DEBUG_ENABLED = log.isDebugEnabled();
@@ -75,6 +77,13 @@
 
     /** Field parser */
     private XMLStreamReader parser;
+    
+    /**
+     * The {@link DataHandlerReader} extension of the underlying parser, or <code>null</code>
+     * if the parser doesn't support this extension.
+     */
+    private DataHandlerReader dataHandlerReader;
+    
     private boolean _isClosed = false;              // Indicate if parser is closed
     private boolean _releaseParserOnClose = false;  // Defaults to legacy behavior, which is keep the reference
 
@@ -851,7 +860,7 @@
         if (builder != null && builder instanceof StAXBuilder) {
             StAXBuilder staxBuilder = (StAXBuilder) builder;
             staxBuilder.close();
-            parser = null;
+            setParser(null);
         } else {
             if (parser != null) {
                 try {
@@ -862,7 +871,7 @@
                     _isClosed = true;
                     // Release the parser so that it can be GC'd or reused.
                     if (_releaseParserOnClose) {
-                        parser = null;
+                        setParser(null);
                     }
                 }
             }
@@ -950,7 +959,7 @@
 
                 // load the parser
                 try {
-                    parser = (XMLStreamReader) builder.getParser();
+                    setParser((XMLStreamReader) builder.getParser());
                 } catch (Exception e) {
                     throw new XMLStreamException("problem accessing the parser. " + e.getMessage(),
                                                  e);
@@ -990,25 +999,9 @@
      * @throws IllegalArgumentException
      */
     public Object getProperty(String s) throws IllegalArgumentException {
-        if (OMConstants.IS_DATA_HANDLERS_AWARE.equals(s)) {
-            return Boolean.TRUE;
-        }
-        if (OMConstants.IS_BINARY.equals(s)) {
-            if (getNode() instanceof OMText) {
-                OMText text = (OMText) getNode();
-                return new Boolean(text.isBinary());
-            }
-            return Boolean.FALSE;
-        } else if (OMConstants.DATA_HANDLER.equals(s)) {
-            if (getNode() instanceof OMText) {
-                OMText text = (OMText) getNode();    
-                if (text.isBinary())
-                    return text.getDataHandler();
-            }
-        }
-        // Per spec, throw IllegalArgumentException
-        if (s == null) {
-            throw new IllegalArgumentException();
+        Object value = DataHandlerReaderUtil.processGetProperty(this, s);
+        if (value != null) {
+            return value;
         }
         if (parser != null) {
             return parser.getProperty(s);
@@ -1236,6 +1229,94 @@
     /*
      *
      * ################################################################
+     * DataHandlerReader extension methods
+     * ################################################################
+     *
+     */
+
+    public boolean isBinary() {
+        if (parser != null) {
+            if (dataHandlerReader != null) {
+                return dataHandlerReader.isBinary();
+            } else {
+                return false;
+            }
+        } else {
+            OMNode node = getNode();
+            if (node instanceof OMText) {
+                return ((OMText)node).isBinary();
+            } else {
+                return false;
+            }
+        }
+    }
+
+    public boolean isDeferred() {
+        if (parser != null) {
+            if (dataHandlerReader != null) {
+                return dataHandlerReader.isDeferred();
+            } else {
+                throw new IllegalStateException();
+            }
+        } else {
+            if (getNode() instanceof OMText) {
+                // TODO: we should support deferred building of the DataHandler
+                return false;
+            } else {
+                throw new IllegalStateException();
+            }
+        }
+    }
+
+    public String getContentID() {
+        if (parser != null) {
+            if (dataHandlerReader != null) {
+                return dataHandlerReader.getContentID();
+            } else {
+                throw new IllegalStateException();
+            }
+        } else {
+            OMNode node = getNode();
+            if (node instanceof OMText) {
+                return ((OMText)node).getContentID();
+            } else {
+                throw new IllegalStateException();
+            }
+        }
+    }
+
+    public DataHandler getDataHandler() {
+        if (parser != null) {
+            if (dataHandlerReader != null) {
+                return dataHandlerReader.getDataHandler();
+            } else {
+                throw new IllegalStateException();
+            }
+        } else {
+            OMNode node = getNode();
+            if (node instanceof OMText) {
+                return (DataHandler)((OMText)node).getDataHandler();
+            } else {
+                throw new IllegalStateException();
+            }
+        }
+    }
+
+    public DataHandlerProvider getDataHandlerProvider() {
+        if (parser != null) {
+            if (dataHandlerReader != null) {
+                return dataHandlerReader.getDataHandlerProvider();
+            } else {
+                throw new IllegalStateException();
+            }
+        } else {
+            throw new IllegalStateException();
+        }
+    }
+
+    /*
+     *
+     * ################################################################
      * Generator methods for the OMNodes returned by the navigator
      * ################################################################
      *
@@ -1459,6 +1540,8 @@
 
     public void setParser(XMLStreamReader parser) {
         this.parser = parser;
+        dataHandlerReader =
+                parser == null ? null : DataHandlerReaderUtil.getDataHandlerReader(parser);
     }
 
     private Map getAllNamespaces(OMNode contextNode) {
@@ -1523,13 +1606,13 @@
         if (builder != null && builder instanceof StAXBuilder) {
             ((StAXBuilder) builder).releaseParserOnClose(value);
             if (isClosed() && value) {
-                parser = null;
+                setParser(null);
             }
             return;
         } else {
             // Release parser if already closed
             if (isClosed() && value) {
-                parser = null;
+                setParser(null);
             }
             _releaseParserOnClose = value;
         }

Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/DataHandlerReaderUtil.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/DataHandlerReaderUtil.java?rev=791968&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/DataHandlerReaderUtil.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/DataHandlerReaderUtil.java Tue Jul  7 20:25:01 2009
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axiom.om.impl.builder;
+
+import javax.activation.DataHandler;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMConstants;
+import org.apache.axiom.stax.ext.DataHandlerProvider;
+import org.apache.axiom.stax.ext.DataHandlerReader;
+
+/**
+ * Utility class to work with the {@link XMLStreamReader} extension defined by
+ * {@link DataHandlerReader}. In addition to {@link DataHandlerReader} support, this class also
+ * provides support for the legacy extension mechanism described below.
+ * 
+ * <h3>Legacy XMLStreamReader extensions for optimized base64 handling</h3>
+ * 
+ * <p>
+ * {@link XMLStreamReader} instances supporting the legacy extension must conform to the following
+ * requirements:
+ * </p>
+ * <ol>
+ * <li>{@link XMLStreamReader#getProperty(String)} must return {@link Boolean#TRUE} for the
+ * property identified by {@link org.apache.axiom.om.OMConstants#IS_DATA_HANDLERS_AWARE},
+ * regardless of the current event. The property is assumed to be immutable and its value must not
+ * change during the lifetime of the {@link XMLStreamReader} implementation.</li>
+ * <li>
+ * <p>
+ * If the {@link XMLStreamReader} wishes to expose base64 encoded content using a
+ * {@link javax.activation.DataHandler} object, it must do so using a single
+ * {@link XMLStreamConstants#CHARACTERS} event.
+ * </p>
+ * <p>
+ * To maintain compatibility with consumers that are unaware of the extensions described here, the
+ * implementation should make sure that {@link XMLStreamReader#getText()},
+ * {@link XMLStreamReader#getTextStart()}, {@link XMLStreamReader#getTextLength()},
+ * {@link XMLStreamReader#getTextCharacters()},
+ * {@link XMLStreamReader#getTextCharacters(int, char[], int, int)} and
+ * {@link XMLStreamReader#getElementText()} behave as expected for this type of event, i.e. return
+ * the base64 representation of the binary content.
+ * </p>
+ * </li>
+ * <li>{@link XMLStreamReader#getProperty(String)} must return {@link Boolean#TRUE} for the
+ * property identified by {@link org.apache.axiom.om.OMConstants#IS_BINARY} if the current event is
+ * a {@link XMLStreamConstants#CHARACTERS} event representing base64 encoded binary content and for
+ * which a {@link javax.activation.DataHandler} is available. For all other events, the returned
+ * value must be {@link Boolean#FALSE}.</li>
+ * <li>
+ * <p>
+ * If for a given event, the implementation returned {@link Boolean#TRUE} for the
+ * {@link org.apache.axiom.om.OMConstants#IS_BINARY} property, then a call to
+ * {@link XMLStreamReader#getProperty(String)} with argument
+ * {@link org.apache.axiom.om.OMConstants#DATA_HANDLER} must return the corresponding
+ * {@link javax.activation.DataHandler} object.
+ * </p>
+ * <p>
+ * The {@link org.apache.axiom.om.OMConstants#DATA_HANDLER} property is undefined for any other type
+ * of event. This implies that the consumer of the {@link XMLStreamReader} must check the
+ * {@link org.apache.axiom.om.OMConstants#IS_BINARY} property before retrieving the
+ * {@link org.apache.axiom.om.OMConstants#DATA_HANDLER} property.
+ * </p>
+ * </li>
+ * </ol>
+ * The extension mechanism described here has been deprecated mainly because it doesn't support
+ * deferred loading of the binary content.
+ */
+public class DataHandlerReaderUtil {
+    private DataHandlerReaderUtil() {}
+    
+    /**
+     * Get the {@link DataHandlerReader} extension for a given {@link XMLStreamReader}, if
+     * available. If the {@link XMLStreamReader} only supports the legacy extension (as described
+     * above), then this method will return a compatibility wrapper. Note that this wrapper doesn't
+     * support deferred loading of the binary content.
+     * 
+     * @param reader
+     *            the stream reader to get the {@link DataHandlerReader} extension from
+     * @return the implementation of the extension, or <code>null</code> if the
+     *         {@link XMLStreamReader} doesn't expose base64 encoded binary content as
+     *         {@link DataHandler} objects.
+     */
+    public static DataHandlerReader getDataHandlerReader(final XMLStreamReader reader) {
+        try {
+            DataHandlerReader dhr = (DataHandlerReader)reader.getProperty(
+                    DataHandlerReader.PROPERTY);
+            if (dhr != null) {
+                return dhr;
+            }
+        } catch (IllegalArgumentException ex) {
+            // Just continue
+        }
+        Boolean isDataHandlerAware;
+        try {
+            isDataHandlerAware = (Boolean)reader.getProperty(OMConstants.IS_DATA_HANDLERS_AWARE);
+        } catch (IllegalArgumentException ex) {
+            return null;
+        }
+        if (isDataHandlerAware != null && isDataHandlerAware.booleanValue()) {
+            return new DataHandlerReader() {
+                public boolean isBinary() {
+                    return ((Boolean)reader.getProperty(OMConstants.IS_BINARY)).booleanValue();
+                }
+
+                public boolean isDeferred() {
+                    return false;
+                }
+
+                public String getContentID() {
+                    return null;
+                }
+
+                public DataHandler getDataHandler() {
+                    return (DataHandler)reader.getProperty(OMConstants.DATA_HANDLER);
+                }
+
+                public DataHandlerProvider getDataHandlerProvider() {
+                    throw new UnsupportedOperationException();
+                }
+            };
+        } else {
+            return null;
+        }
+    }
+    
+    /**
+     * Helper method to implement {@link XMLStreamReader#getProperty(String)}. This method
+     * processed the properties defined by {@link DataHandlerReader#PROPERTY} and the legacy
+     * extension mechanism (as described above). It can therefore be used to make a
+     * {@link XMLStreamReader} implementation compatible with code that expects it to implement this
+     * legacy extension.
+     * 
+     * @param extension
+     *            the reference to the {@link DataHandlerReader} extension for the
+     *            {@link XMLStreamReader} implementation
+     * @param propertyName
+     *            the name of the property, as passed to the
+     *            {@link XMLStreamReader#getProperty(String)} method
+     * @return the property value as specified by the {@link DataHandlerReader} or legacy extension;
+     *         <code>null</code> if the property is not specified by any of these two extensions
+     */
+    public static Object processGetProperty(DataHandlerReader extension, String propertyName) {
+        if (extension == null || propertyName == null) {
+            throw new IllegalArgumentException();
+        } else if (propertyName.equals(DataHandlerReader.PROPERTY)) {
+            return extension;
+        } else if (propertyName.equals(OMConstants.IS_DATA_HANDLERS_AWARE)) {
+            return Boolean.TRUE;
+        } else if (propertyName.equals(OMConstants.IS_BINARY)) {
+            return Boolean.valueOf(extension.isBinary());
+        } else if (propertyName.equals(OMConstants.DATA_HANDLER)) {
+            return extension.getDataHandler();
+        } else {
+            return null;
+        }
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/DataHandlerReaderUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java?rev=791968&r1=791967&r2=791968&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java Tue Jul  7 20:25:01 2009
@@ -35,6 +35,7 @@
 import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.util.OMSerializerUtil;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.stax.ext.DataHandlerReader;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -93,14 +94,10 @@
     protected int maxDepthForCustomBuilders = -1;
     
     /**
-     * Field showing whether the parser is datahandler-aware or not. Client should not directly access this field. 
-     * Instead, they should use {@link #setIsDataHandlerAware(Boolean)} and {@link #isDataHandlerAware()}.
-     * 
-     * @deprecated
-     * @see #isDataHandlerAware()
-     * @see #setIsDataHandlerAware(Boolean)
+     * Reference to the {@link DataHandlerReader} extension of the parser, or <code>null</code> if
+     * the parser doesn't support this extension.
      */
-    protected Boolean isDataHandlerAware = null; // property of parser, https://issues.apache.org/jira/browse/WSCOMMONS-300
+    protected DataHandlerReader dataHandlerReader;
     
     /**
      * Element level is the depth of the element. 
@@ -148,6 +145,7 @@
         if (parser instanceof BuilderAwareReader) {
             ((BuilderAwareReader) parser).setBuilder(this);
         }
+        dataHandlerReader = DataHandlerReaderUtil.getDataHandlerReader(parser);
         this.parser = new SafeXMLStreamReader(parser);
     }
 
@@ -259,21 +257,17 @@
      * @return omNode
      */
     private OMNode createOMText(OMContainer omContainer, int textType) {
-        try {
-            if (isDataHandlerAware() &&
-                    Boolean.TRUE.equals(parser.getProperty(OMConstants.IS_BINARY))) {
-                Object dataHandler = parser.getProperty(OMConstants.DATA_HANDLER);
-                OMText text = omfactory.createOMText(dataHandler, true);
-                text.setBinary(true);
-                omContainer.addChild(text);
-                return text;
-            } 
-        } catch (IllegalArgumentException e) { 
-        	//parser.getProperty may throw illegalArgument exception, ignore
-        } catch (IllegalStateException e) {	
-        	//parser.getProperty may throw illegalState exceptions, ignore
+        if (dataHandlerReader != null && dataHandlerReader.isBinary()) {
+            Object dataHandlerObject =
+                dataHandlerReader.isDeferred() ? (Object)dataHandlerReader.getDataHandlerProvider()
+                                               : (Object)dataHandlerReader.getDataHandler();
+            OMText text = omfactory.createOMText(dataHandlerObject, true);
+            text.setBinary(true);
+            omContainer.addChild(text);
+            return text;
+        } else {
+            return omfactory.createOMText(omContainer, parser.getText(), textType);
         }
-        return omfactory.createOMText(omContainer, parser.getText(), textType);
     }
 
     /**
@@ -667,49 +661,6 @@
     }
 
     /**
-     * Check if the underlying parse is aware of data handlers. (example ADB generated code)
-     *
-     * @return true if the parser is aware of data handlers, otherwise false
-     */
-    protected boolean isDataHandlerAware() {
-        
-        // Is datahandler is immutable for a parser's lifetime.  Thus it should
-        // only be checked one time.
-        if (isDataHandlerAware == null) {
-            // check whether data handlers are treated seperately
-            try {
-                if (parser != null &&
-                        (Boolean.TRUE == parser.getProperty(OMConstants.IS_DATA_HANDLERS_AWARE))) {
-                    isDataHandlerAware = Boolean.TRUE;
-                } else {
-                    isDataHandlerAware = Boolean.FALSE;
-                }
-            } catch (IllegalArgumentException e) {
-                // according to the parser api, get property will return IllegalArgumentException, when that
-                // property is not found.
-                isDataHandlerAware = Boolean.FALSE;
-            } catch (IllegalStateException e) {
-                // it will also throw illegalStateExceptions if in wrong state, ignore
-            }
-        }
-
-        if (Boolean.TRUE.equals(isDataHandlerAware)) {
-            return true;
-        }
-
-        return false;
-    }
-
-    /**
-     * Sets the isDataHandlerAware state of this {@link StAXBuilder}.
-     * 
-     * @param value a boolean value - may be null
-     */
-    protected void setIsDataHandlerAware(Boolean value) {
-        this.isDataHandlerAware = value;
-    }
-    
-    /**
      * Returns the encoding style of the XML data
      * @return the character encoding, defaults to "UTF-8"
      */

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java?rev=791968&r1=791967&r2=791968&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java Tue Jul  7 20:25:01 2009
@@ -47,55 +47,10 @@
 
 /**
  * StAX based builder that produces a pure XML infoset compliant object model.
- * 
- * <h3>XMLStreamReader extensions for optimized base64 handling</h3>
- * 
- * <p>This class supports {@link XMLStreamReader} instances that expose base64 encoded binary
- * content as {@link javax.activation.DataHandler} objects. For this to work, the
- * {@link XMLStreamReader} must conform to the following requirements:</p>
- * <ol>
- *   <li>{@link XMLStreamReader#getProperty(String)} must return {@link Boolean#TRUE}
- *       for the property identified by
- *       {@link org.apache.axiom.om.OMConstants#IS_DATA_HANDLERS_AWARE}, regardless of
- *       the current event. The property is assumed to be immutable and its value must
- *       not change during the lifetime of the {@link XMLStreamReader} implementation.</li>
- *   <li><p>If the {@link XMLStreamReader} wishes to expose base64 encoded content using
- *       a {@link javax.activation.DataHandler} object, it must do so using a single
- *       {@link XMLStreamConstants#CHARACTERS} event.</p>
- *       <p>To maintain compatibility with consumers that are unaware of the extensions
- *       described here, the implementation should make sure that
- *       {@link XMLStreamReader#getText()}, {@link XMLStreamReader#getTextStart()},
- *       {@link XMLStreamReader#getTextLength()}, {@link XMLStreamReader#getTextCharacters()},
- *       {@link XMLStreamReader#getTextCharacters(int, char[], int, int)} and
- *       {@link XMLStreamReader#getElementText()} behave as expected for this type of event,
- *       i.e. return the base64 representation of the binary content.</p></li>
- *   <li>{@link XMLStreamReader#getProperty(String)} must return {@link Boolean#TRUE}
- *       for the property identified by
- *       {@link org.apache.axiom.om.OMConstants#IS_BINARY} if the current event is a
- *       {@link XMLStreamConstants#CHARACTERS} event representing base64 encoded binary
- *       content and for which a {@link javax.activation.DataHandler} is available.
- *       For all other events, the returned value must be {@link Boolean#FALSE}.</li>
- *   <li><p>If for a given event, the implementation returned {@link Boolean#TRUE} for the
- *       {@link org.apache.axiom.om.OMConstants#IS_BINARY} property, then a call to
- *       {@link XMLStreamReader#getProperty(String)} with argument
- *       {@link org.apache.axiom.om.OMConstants#DATA_HANDLER} must return the
- *       corresponding {@link javax.activation.DataHandler} object.</p>
- *       <p>The {@link org.apache.axiom.om.OMConstants#DATA_HANDLER} property is undefined
- *       for any other type of event. This implies that the consumer of the
- *       {@link XMLStreamReader} must check the {@link org.apache.axiom.om.OMConstants#IS_BINARY}
- *       property before retrieving the {@link org.apache.axiom.om.OMConstants#DATA_HANDLER}
- *       property.</p></li>
- * </ol>
- * <p>The extension described will typically be implemented by {@link XMLStreamReader} instances
- * provided by databinding frameworks or {@link XMLStreamReader} proxies that enrich a stream of
- * StAX events with binary data existing outside of the XML document. Another example is
- * {@link org.apache.axiom.om.impl.OMStAXWrapper}.</p>
- * <p>One may ask why this extension is defined using {@link XMLStreamReader} properties and not
- * simply as an extension interface that the reader may implement. The reason is that the property
- * based approach continues to work if the {@link XMLStreamReader} implementing the extension
- * is accessed through a proxy implementing the {@link XMLStreamReader} interface but unaware
- * of the extension, at least if the proxy correctly delegates calls to the
- * {@link XMLStreamReader#getProperty(String)} method.</p>
+ * <p>
+ * This class supports the {@link XMLStreamReader} extension defined by
+ * {@link org.apache.axiom.stax.ext.DataHandlerReader} as well as the legacy extension mechanism
+ * defined in the documentation of {@link DataHandlerReaderUtil}.
  */
 public class StAXOMBuilder extends StAXBuilder {
     /** Field document */

Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/ext/DataHandlerProvider.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/ext/DataHandlerProvider.java?rev=791968&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/ext/DataHandlerProvider.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/ext/DataHandlerProvider.java Tue Jul  7 20:25:01 2009
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axiom.stax.ext;
+
+import javax.activation.DataHandler;
+
+/**
+ * Interface used for deferred loading of binary content.
+ * 
+ * @see DataHandlerReader#isDeferred()
+ * @see DataHandlerReader#getDataHandlerProvider()
+ */
+public interface DataHandlerProvider {
+    /**
+     * Get the {@link DataHandler} object for the binary content.
+     * 
+     * @return the binary content
+     */
+    DataHandler getDataHandler();
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/ext/DataHandlerProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/ext/DataHandlerReader.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/ext/DataHandlerReader.java?rev=791968&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/ext/DataHandlerReader.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/ext/DataHandlerReader.java Tue Jul  7 20:25:01 2009
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axiom.stax.ext;
+
+import javax.activation.DataHandler;
+
+/**
+ * Extension interface for {@link javax.xml.stream.XMLStreamReader} implementations that expose
+ * base64 encoded binary content as {@link DataHandler} objects.
+ * <p>
+ * The {@link javax.xml.stream.XMLStreamReader} MAY implement this interface directly, but a
+ * consumer MUST use {@link javax.xml.stream.XMLStreamReader#getProperty(String)} with the property
+ * name defined by {@link #PROPERTY} to get a reference to this extension interface. The rationale
+ * for this requirement is that a property based approach continues to work even if the
+ * {@link javax.xml.stream.XMLStreamReader} implementing the extension is accessed indirectly
+ * through a proxy implementing the {@link javax.xml.stream.XMLStreamReader} interface but unaware
+ * of the extension. Note that this assumes that the proxy correctly delegates calls to the
+ * {@link javax.xml.stream.XMLStreamReader#getProperty(String)} method.
+ * <p>
+ * The property defined by {@link #PROPERTY} MUST be available regardless of the current state of
+ * the {@link javax.xml.stream.XMLStreamReader}. In addition it is assumed to be immutable, i.e.
+ * its value MUST NOT not change during the lifetime of the {@link javax.xml.stream.XMLStreamReader}
+ * implementation. For a consumer it is therefore sufficient to look up the extension once and to
+ * continue using the reference returned by
+ * {@link javax.xml.stream.XMLStreamReader#getProperty(String)} during the entire lifetime of the
+ * {@link javax.xml.stream.XMLStreamReader}.
+ * <p>
+ * If the {@link javax.xml.stream.XMLStreamReader} wishes to expose base64 encoded content using
+ * this extension interface, it MUST do so using a single
+ * {@link javax.xml.stream.XMLStreamConstants#CHARACTERS} event. To maintain compatibility with
+ * consumers that are unaware of the extension, the implementation SHOULD make sure that
+ * {@link javax.xml.stream.XMLStreamReader#getText()},
+ * {@link javax.xml.stream.XMLStreamReader#getTextStart()},
+ * {@link javax.xml.stream.XMLStreamReader#getTextLength()},
+ * {@link javax.xml.stream.XMLStreamReader#getTextCharacters()},
+ * {@link javax.xml.stream.XMLStreamReader#getTextCharacters(int, char[], int, int)} and
+ * {@link javax.xml.stream.XMLStreamReader#getElementText()} behave as expected for this type of
+ * event, i.e. return the base64 representation of the binary content.
+ * <p>
+ * The extension described by this interface will typically be implemented by XMLStreamReader
+ * instances provided by databinding frameworks or XMLStreamReader proxies that enrich a stream of
+ * StAX events with binary data existing outside of the XML document (e.g. an XOP/MTOM decoder).
+ */
+public interface DataHandlerReader {
+    /**
+     * The name of the property used to look up this extension interface from a
+     * {@link javax.xml.stream.XMLStreamReader} implementation.
+     */
+    String PROPERTY = DataHandlerReader.class.getName();
+    
+    /**
+     * Check whether the current event is a {@link javax.xml.stream.XMLStreamConstants#CHARACTERS}
+     * event representing base64 encoded binary content and for which a
+     * {@link javax.activation.DataHandler} is available.
+     * 
+     * @return <code>true</code> if the current event is a
+     *         {@link javax.xml.stream.XMLStreamConstants#CHARACTERS} event representing base64
+     *         encoded binary content and for which a {@link javax.activation.DataHandler} is
+     *         available; <code>false</code> for all other types of events.
+     */
+    boolean isBinary();
+    
+    /**
+     * Check whether the {@link javax.xml.stream.XMLStreamReader} supports deferred loading of the
+     * binary content for the current event. If this method returns <code>true</code> then a
+     * consumer MAY call {@link #getDataHandlerProvider()} and retrieve the
+     * {@link javax.activation.DataHandler} later using {@link DataHandlerProvider#getDataHandler()}.
+     * Calling this method is only meaningful if {@link #isBinary()} returns <code>true</code> for
+     * the current event. The behavior of this method is undefined if this is not the case.
+     * 
+     * @return <code>true</code> if deferred loading is supported; <code>false</code> otherwise
+     */
+    boolean isDeferred();
+    
+    /**
+     * Get the content ID of the binary content for the current event, if available. The result of
+     * this method is defined if and only if {@link #isBinary()} returns <code>true</code> for the
+     * current event.
+     * <p>
+     * The implementation SHOULD only return a non null value if the content ID has been used
+     * previously in an interaction with another component or system. The implementation SHOULD NOT
+     * generate a new content ID solely for the purpose of this method.
+     * <p>
+     * If available, the returned value MUST be a raw content ID. In particular:
+     * <ul>
+     * <li>If the content ID has been extracted from an <tt>href</tt> attribute, it MUST NOT
+     * contain the <tt>cid:</tt> prefix.</li>
+     * <li>If it has been extracted from a <tt>Content-ID</tt> MIME header, it MUST NOT be
+     * enclosed in angles (<tt>&lt;></tt>).</li>
+     * </ul>
+     * <p>
+     * A consumer MAY use the return value of this method in contexts where it is desirable to
+     * preserve the original content ID used by another system or component to identify the binary
+     * content. However, the consumer MUST NOT make any assumption about the uniqueness or validity
+     * of the content ID (with respect to relevant standards such as RFC822) and SHOULD make
+     * provision to sanitize the value if necessary.
+     * 
+     * @return any content ID used previously to identify the binary content, or <code>null</code>
+     *         if no content ID is known
+     */
+    String getContentID();
+    
+    /**
+     * Get the {@link DataHandler} with the binary content for the current event. The behavior of
+     * this method is only defined for events for which {@link #isBinary()} returns
+     * <code>true</code>. For events of this type the method MUST return a valid
+     * {@link DataHandler}, regardless of the return value of {@link #isDeferred()}. If
+     * {@link #isDeferred()} returns <code>true</code>, then the consumer may use this method to
+     * force the implementation to load the binary content immediately.
+     * 
+     * @return the binary content for the current event
+     */
+    DataHandler getDataHandler();
+    
+    /**
+     * Get a {@link DataHandlerProvider} instance for deferred loading of the binary content for the
+     * current event. The behavior of this method is defined if and only if {@link #isDeferred()}
+     * returns <code>true</code> for the current event. The returned reference MUST remain valid
+     * after the current event has been consumed. It is up to the implementation to specify the
+     * exact lifecycle of the returned instance, in particular until when the binary content can be
+     * retrieved.
+     * 
+     * @return the {@link DataHandlerProvider} instance the consumer can use to load the binary
+     *         content at a later time
+     */
+    DataHandlerProvider getDataHandlerProvider();
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/ext/DataHandlerReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTextTestBase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTextTestBase.java?rev=791968&r1=791967&r2=791968&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTextTestBase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTextTestBase.java Tue Jul  7 20:25:01 2009
@@ -19,7 +19,26 @@
 
 package org.apache.axiom.om;
 
+import javax.activation.DataHandler;
+
+import org.apache.axiom.stax.ext.DataHandlerProvider;
+
 public class OMTextTestBase extends AbstractTestCase {
+    static class TestDataHandlerProvider implements DataHandlerProvider {
+        private DataHandler dh;
+        
+        public DataHandler getDataHandler() {
+            if (dh == null) {
+                dh = new DataHandler("Data", "text/plain");
+            }
+            return dh;
+        }
+        
+        public boolean isDataHandlerCreated() {
+            return dh != null;
+        }
+    }
+    
     protected final OMMetaFactory omMetaFactory;
 
     public OMTextTestBase(OMMetaFactory omMetaFactory) {
@@ -41,6 +60,15 @@
                 text.equals(omText.getText()));
 
     }
+    
+    public void testCreateFromDataHandlerProvider() throws Exception {
+        TestDataHandlerProvider prov = new TestDataHandlerProvider();
+        OMFactory factory = omMetaFactory.getOMFactory();
+        OMText text = factory.createOMText(null, prov, true);
+        assertFalse(prov.isDataHandlerCreated());
+        assertEquals(((DataHandler)text.getDataHandler()).getContent(), "Data");
+        assertTrue(prov.isDataHandlerCreated());
+    }
 
     public void testSetText() {
         OMFactory factory = omMetaFactory.getOMFactory();

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java?rev=791968&r1=791967&r2=791968&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java Tue Jul  7 20:25:01 2009
@@ -26,6 +26,7 @@
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.stax.ext.DataHandlerProvider;
 import org.w3c.dom.Node;
 
 public class TextImpl extends TextNodeImpl {
@@ -39,6 +40,11 @@
         super(ownerNode, dataHandler, optimize, factory);
     }
 
+    public TextImpl(DocumentImpl ownerNode, String contentID,
+            DataHandlerProvider dataHandlerProvider, boolean optimize, OMFactory factory) {
+        super(ownerNode, contentID, dataHandlerProvider, optimize, factory);
+    }
+
     public TextImpl(DocumentImpl ownerNode, OMFactory factory) {
         super(ownerNode, factory);
     }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java?rev=791968&r1=791967&r2=791968&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java Tue Jul  7 20:25:01 2009
@@ -33,6 +33,7 @@
 import org.apache.axiom.om.impl.builder.XOPBuilder;
 import org.apache.axiom.om.util.TextHelper;
 import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axiom.stax.ext.DataHandlerProvider;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Node;
 import org.w3c.dom.Text;
@@ -185,6 +186,24 @@
         this.ns = XOP_NS;
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param contentID
+     * @param dataHandlerProvider
+     * @param optimize
+     * @param factory
+     */
+    public TextNodeImpl(DocumentImpl ownerNode, String contentID, DataHandlerProvider
+            dataHandlerProvider, boolean optimize, OMFactory factory) {
+        super(ownerNode, factory);
+        this.contentID = contentID;
+        dataHandlerObject = dataHandlerProvider;
+        isBinary = true;
+        this.optimize = optimize;
+        done = true;
+    }
+
     /** @param ownerNode  */
     public TextNodeImpl(DocumentImpl ownerNode, OMFactory factory) {
         super(ownerNode, factory);
@@ -427,6 +446,8 @@
                 }
                 dataHandlerObject = ((XOPBuilder) builder)
                         .getDataHandler(contentID);
+            } else if (dataHandlerObject instanceof DataHandlerProvider) {
+                dataHandlerObject = ((DataHandlerProvider)dataHandlerObject).getDataHandler();
             }
             return dataHandlerObject;
         }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java?rev=791968&r1=791967&r2=791968&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java Tue Jul  7 20:25:01 2009
@@ -49,6 +49,7 @@
 import org.apache.axiom.om.impl.dom.ProcessingInstructionImpl;
 import org.apache.axiom.om.impl.dom.TextImpl;
 import org.apache.axiom.om.impl.dom.TextNodeImpl;
+import org.apache.axiom.stax.ext.DataHandlerProvider;
 import org.w3c.dom.Node;
 
 import javax.xml.namespace.QName;
@@ -339,6 +340,11 @@
         return new TextImpl(this.document, dataHandler, optimize, this);
     }
 
+    public OMText createOMText(String contentID, DataHandlerProvider dataHandlerProvider,
+            boolean optimize) {
+        return new TextImpl(this.document, contentID, dataHandlerProvider, optimize, this);
+    }
+
     /**
      * Creates an OMDOM Text node, adds it to the give parent element and returns it.
      *

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java?rev=791968&r1=791967&r2=791968&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java Tue Jul  7 20:25:01 2009
@@ -35,6 +35,7 @@
 import org.apache.axiom.om.impl.util.OMSerializerUtil;
 import org.apache.axiom.om.util.TextHelper;
 import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axiom.stax.ext.DataHandlerProvider;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -217,6 +218,24 @@
     }
 
     /**
+     * Constructor.
+     * 
+     * @param dataHandlerProvider
+     * @param optimize
+     * @param factory
+     */
+    public OMTextImpl(String contentID, DataHandlerProvider dataHandlerProvider, boolean optimize,
+            OMFactory factory) {
+        super(factory);
+        this.contentID = contentID;
+        dataHandlerObject = dataHandlerProvider;
+        isBinary = true;
+        this.optimize = optimize;
+        done = true;
+        nodeType = TEXT_NODE;
+    }
+
+    /**
      * @param contentID
      * @param parent
      * @param builder   Used when the builder is encountered with a XOP:Include tag Stores a
@@ -364,6 +383,8 @@
                 }
                 dataHandlerObject = ((XOPBuilder) builder)
                         .getDataHandler(contentID);
+            } else if (dataHandlerObject instanceof DataHandlerProvider) {
+                dataHandlerObject = ((DataHandlerProvider)dataHandlerObject).getDataHandler();
             }
             return dataHandlerObject;
         }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java?rev=791968&r1=791967&r2=791968&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java Tue Jul  7 20:25:01 2009
@@ -42,6 +42,7 @@
 import org.apache.axiom.om.impl.llom.OMProcessingInstructionImpl;
 import org.apache.axiom.om.impl.llom.OMSourcedElementImpl;
 import org.apache.axiom.om.impl.llom.OMTextImpl;
+import org.apache.axiom.stax.ext.DataHandlerProvider;
 
 import javax.xml.namespace.QName;
 import java.util.Hashtable;
@@ -258,6 +259,11 @@
         return new OMTextImpl(dataHandler, optimize, this);
     }
 
+    public OMText createOMText(String contentID, DataHandlerProvider dataHandlerProvider,
+            boolean optimize) {
+        return new OMTextImpl(contentID, dataHandlerProvider, optimize, this);
+    }
+
     public OMText createOMText(String contentID, OMContainer parent,
                                OMXMLParserWrapper builder) {
         return new OMTextImpl(contentID, parent, builder, this);



Mime
View raw message