Hi Paul,
please create a new feature request in Jira and attach your patch to it.
Regards
Ralf
philion schrieb:
> I have recently discovered the need for a factory during
> unmarshalling. The usecase is accessing data that is not contained in
> the XML document (like stuff stored in the HttpSession).
>
> I noticed the ObjectFactory in the UnmarshalHandler, so I added
> setters for it in both the UnmarshalHandler and Unmarshaller (the only
> way to get to it).
>
> Other changes that might be useful: Expose more information about the
> state of the unmarshaller to the factory, to allow it to be more
> flexible in the creation.
>
> I have attached a suggested patch. This is working for us, but I would
> be happy to revise if someone has suggestions.
>
> Should I create a feature request in Jira?
>
> - Paul
>
>
> ------------------------------------------------------------------------
>
>
> Property changes on: C:\workplace\.eclipse\thorn-workspace\castor\src
> ___________________________________________________________________
> Name: svn:ignore
> - Debug
> Release
>
> +
> Debug
> Release
> .ant-targets-build.xml
>
>
> Index:
> C:/workplace/.eclipse/thorn-workspace/castor/src/main/java/org/exolab/castor/xml/UnmarshalHandler.java
> ===================================================================
> ---
> C:/workplace/.eclipse/thorn-workspace/castor/src/main/java/org/exolab/castor/xml/UnmarshalHandler.java
> (revision 6325)
> +++
> C:/workplace/.eclipse/thorn-workspace/castor/src/main/java/org/exolab/castor/xml/UnmarshalHandler.java
> (working copy)
> @@ -3846,5 +3846,13 @@
>
> } //-- ArrayHandler
>
> + public ObjectFactory getObjectFactory() {
> + return _objectFactory;
> + }
> +
> + public void setObjectFactory(ObjectFactory objectFactory) {
> + _objectFactory = objectFactory;
> + }
> +
> } //-- Unmarshaller
>
> Index:
> C:/workplace/.eclipse/thorn-workspace/castor/src/main/java/org/exolab/castor/xml/Unmarshaller.java
> ===================================================================
> ---
> C:/workplace/.eclipse/thorn-workspace/castor/src/main/java/org/exolab/castor/xml/Unmarshaller.java
> (revision 6325)
> +++
> C:/workplace/.eclipse/thorn-workspace/castor/src/main/java/org/exolab/castor/xml/Unmarshaller.java
> (working copy)
> @@ -54,6 +54,7 @@
> import org.exolab.castor.mapping.MappingLoader;
> import org.exolab.castor.util.Configuration;
> import org.exolab.castor.util.LocalConfiguration;
> +import org.exolab.castor.util.ObjectFactory;
> import org.exolab.castor.xml.util.*;
>
> //-- misc xml related imports
> @@ -71,7 +72,6 @@
> import java.util.HashMap;
> import java.util.Iterator;
> import java.util.StringTokenizer;
> -
> /**
> * An unmarshaller to allowing unmarshalling of XML documents to
> * Java Objects. The Class must specify
> @@ -185,6 +185,11 @@
> * A list of namespace To Package Mappings
> */
> private HashMap _namespaceToPackage = null;
> +
> + /**
> + * An optional factory for unmarshalling objects
> + */
> + private ObjectFactory _objectFactory;
>
> //----------------/
> //- Constructors -/
> @@ -337,6 +342,11 @@
> handler.setIgnoreExtraElements(_ignoreExtraElements);
> handler.setConfiguration(_config);
> handler.setWhitespacePreserve(_wsPreserve);
> +
> + // If the object factory has been set, set it on the handler
> + if (this._objectFactory != null) {
> + handler.setObjectFactory(this._objectFactory);
> + }
>
> //-- copy namespaceToPackageMappings
> if (_namespaceToPackage != null) {
> @@ -861,5 +871,16 @@
>
> return unmarshaller.unmarshal(node);
> } //-- void unmarshal(Writer)
> +
> + /**
> + * Set an object factory for the unmarshaller. This
> + * factory will be used to construct the objects being
> + * unmarshalled.
> + * @param objectFactory Factory used for constructing objects
> + * during unmarshalling.
> + */
> + public void setObjectFactory(ObjectFactory objectFactory) {
> + this._objectFactory = objectFactory;
> + } // -- setObjectFactory
> } //-- Unmarshaller
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
> http://xircles.codehaus.org/manage_email
--
Syscon Ingenieurbüro für
Meß- und Datentechnik GmbH
Ralf Joachim
Raiffeisenstraße 11
D-72127 Kusterdingen
Germany
Tel. +49 7071 3690 52
Mobil: +49 173 9630135
Fax +49 7071 3690 98
Email: [EMAIL PROTECTED]
Web: www.syscon-informatics.de
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email