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 Glen Daniels <gd...@macromedia.com> on 2003/07/02 19:01:48 UTC
RE: cvs commit: xml-axis/java/src/org/apache/axis/encoding TypeMa
ppingImpl.java
Argh - I don't have time to get into this right now (sorry, am still slammed with internal stuff), but this looks weird to me - it seems to actually remove the hooks for autoTyping to work in the first place (i.e. the check for the trigger namespace). Am I missing something here?
--Glen
> -----Original Message-----
> From: dims@apache.org [mailto:dims@apache.org]
> Sent: Wednesday, July 02, 2003 12:48 PM
> To: xml-axis-cvs@apache.org
> Subject: cvs commit:
> xml-axis/java/src/org/apache/axis/encoding TypeMappingImpl.java
>
>
> dims 2003/07/02 09:47:32
>
> Modified: java/src/org/apache/axis/encoding TypeMappingImpl.java
> Log:
> Fix for Bug 18084 - Auto Typing in TypeMappingImpl only
> puts types in the default namespace
> from dan@envoisolutions.com (Dan Diephouse)
>
> Revision Changes Path
> 1.42 +56 -53
> xml-axis/java/src/org/apache/axis/encoding/TypeMappingImpl.java
>
> Index: TypeMappingImpl.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMappi
> ngImpl.java,v
> retrieving revision 1.41
> retrieving revision 1.42
> diff -u -r1.41 -r1.42
> --- TypeMappingImpl.java 22 Apr 2003 19:34:25 -0000 1.41
> +++ TypeMappingImpl.java 2 Jul 2003 16:47:32 -0000 1.42
> @@ -57,10 +57,13 @@
>
> import org.apache.axis.Constants;
> import org.apache.axis.components.logger.LogFactory;
> +import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
> +import org.apache.axis.encoding.ser.ArraySerializerFactory;
> import org.apache.axis.encoding.ser.BeanDeserializerFactory;
> import org.apache.axis.encoding.ser.BeanSerializerFactory;
> -import org.apache.axis.utils.ClassUtils;
> import org.apache.axis.utils.Messages;
> +import org.apache.axis.wsdl.fromJava.Namespaces;
> +import org.apache.axis.wsdl.fromJava.Types;
> import org.apache.commons.logging.Log;
>
> import javax.xml.namespace.QName;
> @@ -139,10 +142,6 @@
> protected TypeMapping delegate; // Pointer to
> delegate or null
> private ArrayList namespaces; // Supported namespaces
>
> - /**
> - * Should we "auto-type" classes we don't recognize
> into the "java:"
> - * namespace?
> - */
> private boolean doAutoTypes = false;
>
> /**
> @@ -327,13 +326,6 @@
> if (xmlType == null) {
> return null;
> }
> -
> - // If we're doing autoTyping, and we got a
> type in the right
> - // namespace, we can use the default serializer.
> - if (doAutoTypes &&
> -
> xmlType.getNamespaceURI().equals(Constants.NS_URI_JAVA)) {
> - return new BeanSerializerFactory(javaType,
> xmlType);
> - }
> }
>
> // Try to get the serializer associated with this pair
> @@ -393,12 +385,6 @@
> if (xmlType == null) {
> return null;
> }
> -
> - // If we're doing autoTyping, we can use the default.
> - if (doAutoTypes &&
> -
> xmlType.getNamespaceURI().equals(Constants.NS_URI_JAVA)) {
> - return xmlType;
> - }
> }
>
> // Try to get the serializer associated with this pair
> @@ -458,16 +444,6 @@
> if (javaType == null) {
> return null;
> }
> -
> - if (doAutoTypes &&
> -
> Constants.NS_URI_JAVA.equals(xmlType.getNamespaceURI())) {
> - try {
> - javaType =
> ClassUtils.forName(xmlType.getLocalPart());
> - } catch (ClassNotFoundException e) {
> - return null;
> - }
> - return new
> BeanDeserializerFactory(javaType, xmlType);
> - }
> }
>
> Pair pair = new Pair(javaType, xmlType);
> @@ -567,27 +543,63 @@
> xmlType = pair.xmlType;
> }
>
> - if (xmlType == null && doAutoTypes) {
> - xmlType = new QName(Constants.NS_URI_JAVA,
> - javaType.getName());
> - }
> -
> // Can only detect arrays via code
> if (xmlType == null && (javaType.isArray() ||
> - javaType == List.class ||
> - List.class.isAssignableFrom(javaType))) {
> + javaType == List.class ||
> + List.class.isAssignableFrom(javaType))) {
>
> - // get the registered array if any
> - pair = (Pair) class2Pair.get(Object[].class);
> - // TODO: it always returns the last registered one,
> - // so that's why the soap 1.2 typemappings have to
> - // move to an other registry to differentiate them
> - if (pair != null) {
> - xmlType = pair.xmlType;
> - } else {
> - xmlType = Constants.SOAP_ARRAY;
> + /* If auto-typing is on, generate a namespace
> for this array
> + * intelligently, then register it's javaType
> and xmlType. Also
> + * make sure the class isn't derived from
> List, because they
> + * should be serialized as an anyType array.
> + */
> + if ( doAutoTypes &&
> + javaType != List.class &&
> + !List.class.isAssignableFrom(javaType) )
> + {
> + xmlType = new QName(
> + Namespaces.makeNamespace( javaType.getName() ),
> + Types.getLocalNameFromFullName(
> javaType.getName() ) );
> +
> + register( javaType,
> + xmlType,
> + new ArraySerializerFactory(),
> + new ArrayDeserializerFactory() );
> + }
> + else
> + {
> + // get the registered array if any
> + pair = (Pair) class2Pair.get(Object[].class);
> + // TODO: it always returns the last registered one,
> + // so that's why the soap 1.2
> typemappings have to
> + // move to an other registry to differentiate them
> + if (pair != null) {
> + xmlType = pair.xmlType;
> + } else {
> + xmlType = Constants.SOAP_ARRAY;
> + }
> }
> }
> +
> + /* If the class isn't an array or List and
> auto-typing is turned on,
> + * register the class and it's type as beans.
> + */
> + if (xmlType == null && doAutoTypes)
> + {
> + xmlType = new QName(
> + Namespaces.makeNamespace( javaType.getName() ),
> + Types.getLocalNameFromFullName(
> javaType.getName() ) );
> +
> + /* If doAutoTypes is set, register a new type
> mapping for the
> + * java class with the above QName. This way,
> when getSerializer()
> + * and getDeserializer() are called, this
> QName is returned and
> + * these methods do not need to worry about
> creating a serializer.
> + */
> + register( javaType,
> + xmlType,
> + new BeanSerializerFactory(javaType, xmlType),
> + new
> BeanDeserializerFactory(javaType, xmlType) );
> + }
>
> //log.debug("getTypeQName xmlType =" + xmlType);
> return xmlType;
> @@ -609,15 +621,6 @@
> javaType = delegate.getClassForQName(xmlType);
> } else if (pair != null) {
> javaType = pair.javaType;
> - }
> -
> - if (javaType == null && doAutoTypes &&
> -
> Constants.NS_URI_JAVA.equals(xmlType.getNamespaceURI())) {
> - // Classloader?
> - try {
> - javaType =
> ClassUtils.forName(xmlType.getLocalPart());
> - } catch (ClassNotFoundException e) {
> - }
> }
>
> //log.debug("getClassForQName javaType =" + javaType);
>
>
>
>
AutoTyping Patch Explanation
Posted by Dan Diephouse <da...@envoisolutions.com>.
Basically this patch does three things:
1) Changes the namespace from http://xml.apache.org/axis/java to one
generated with the Namespace utils for auto-typed classes.
2) Instead of create serializers each time, it registers the serializers
with Axis for future lookups.
3) Localizes all the type-mapping related functions into getTypeQName(Class)
Classes are auto-typed on the conditions that auto-typing is turned on
and there exists no previously defined type mapping for the class.
Now, I believe Glen's question is how can you just throw everything into
getTypeQName and expect it to work? I removed the auto-tying references
from getSerializer/getDeserializer. This isn't a problem for
getSerializer() because it calls getTypeQName directly. However, it
does, as Glen pointed out, totally remove all direct reference to
auto-typing from the getDeserializer method.
Now why did I do this? :) When a service is created which contains
types that don't exist, ServiceDesc.createOperationForMethod calls
getTypeQName before the service is up and running, thereby registering
the serializers before getSerializer/getDeserializer are ever called.
Knowing this, do you see problems with this approach?
- Dan
Dan Diephouse wrote:
> Hi,
> I don't know if you're missing something or not. Probably not since you
> know much more about Axis than I do. I have free time today, so I will
> work on a fix for the test breakage and a test case for auto-typing the
> rest of the afternoon. I will let you know as soon as I have something.
>
> - Dan
>
> Glen Daniels wrote:
>
>> Argh - I don't have time to get into this right now (sorry, am still
>> slammed with internal stuff), but this looks weird to me - it seems to
>> actually remove the hooks for autoTyping to work in the first place
>> (i.e. the check for the trigger namespace). Am I missing something here?
>>
>> --Glen
>>
>>
>>> -----Original Message-----
>>> From: dims@apache.org [mailto:dims@apache.org] Sent: Wednesday, July
>>> 02, 2003 12:48 PM
>>> To: xml-axis-cvs@apache.org
>>> Subject: cvs commit: xml-axis/java/src/org/apache/axis/encoding
>>> TypeMappingImpl.java
>
>
>
>
Re: cvs commit: xml-axis/java/src/org/apache/axis/encoding TypeMa
ppingImpl.java
Posted by Dan Diephouse <da...@envoisolutions.com>.
Dims,
Thanks for checking this stuff in. Hope it's useful for people beside
myself!
- Dan
Davanum Srinivas wrote:
> Dan,
>
> FYI, the breakage was from other check-in's. Your patch is already in cvs and the current cvs
> passes "all-tests". Right now, we need a test case to make sure that what you think as Auto-Typing
> matches what Glen had started coding :) (and to make sure that no one breaks the functionality).
>
> Thanks,
> dims
>
Re: cvs commit: xml-axis/java/src/org/apache/axis/encoding TypeMa ppingImpl.java
Posted by Davanum Srinivas <di...@yahoo.com>.
Dan,
FYI, the breakage was from other check-in's. Your patch is already in cvs and the current cvs
passes "all-tests". Right now, we need a test case to make sure that what you think as Auto-Typing
matches what Glen had started coding :) (and to make sure that no one breaks the functionality).
Thanks,
dims
--- Dan Diephouse <da...@envoisolutions.com> wrote:
> Hi,
> I don't know if you're missing something or not. Probably not since you
> know much more about Axis than I do. I have free time today, so I will
> work on a fix for the test breakage and a test case for auto-typing the
> rest of the afternoon. I will let you know as soon as I have something.
>
> - Dan
>
> Glen Daniels wrote:
> > Argh - I don't have time to get into this right now (sorry, am still slammed with internal
> stuff), but this looks weird to me - it seems to actually remove the hooks for autoTyping to
> work in the first place (i.e. the check for the trigger namespace). Am I missing something
> here?
> >
> > --Glen
> >
> >
> >>-----Original Message-----
> >>From: dims@apache.org [mailto:dims@apache.org]
> >>Sent: Wednesday, July 02, 2003 12:48 PM
> >>To: xml-axis-cvs@apache.org
> >>Subject: cvs commit:
> >>xml-axis/java/src/org/apache/axis/encoding TypeMappingImpl.java
>
>
=====
Davanum Srinivas - http://webservices.apache.org/~dims/
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
Re: cvs commit: xml-axis/java/src/org/apache/axis/encoding TypeMa
ppingImpl.java
Posted by Dan Diephouse <da...@envoisolutions.com>.
Hi,
I don't know if you're missing something or not. Probably not since you
know much more about Axis than I do. I have free time today, so I will
work on a fix for the test breakage and a test case for auto-typing the
rest of the afternoon. I will let you know as soon as I have something.
- Dan
Glen Daniels wrote:
> Argh - I don't have time to get into this right now (sorry, am still slammed with internal stuff), but this looks weird to me - it seems to actually remove the hooks for autoTyping to work in the first place (i.e. the check for the trigger namespace). Am I missing something here?
>
> --Glen
>
>
>>-----Original Message-----
>>From: dims@apache.org [mailto:dims@apache.org]
>>Sent: Wednesday, July 02, 2003 12:48 PM
>>To: xml-axis-cvs@apache.org
>>Subject: cvs commit:
>>xml-axis/java/src/org/apache/axis/encoding TypeMappingImpl.java
RE: cvs commit: xml-axis/java/src/org/apache/axis/encoding TypeMa ppingImpl.java
Posted by Davanum Srinivas <di...@yahoo.com>.
Glen,
I'll let Dan comment on the patch.
-- dims
--- Glen Daniels <gd...@macromedia.com> wrote:
>
> Argh - I don't have time to get into this right now (sorry, am still slammed with internal
> stuff), but this looks weird to me - it seems to actually remove the hooks for autoTyping to
> work in the first place (i.e. the check for the trigger namespace). Am I missing something
> here?
>
> --Glen
>
> > -----Original Message-----
> > From: dims@apache.org [mailto:dims@apache.org]
> > Sent: Wednesday, July 02, 2003 12:48 PM
> > To: xml-axis-cvs@apache.org
> > Subject: cvs commit:
> > xml-axis/java/src/org/apache/axis/encoding TypeMappingImpl.java
> >
> >
> > dims 2003/07/02 09:47:32
> >
> > Modified: java/src/org/apache/axis/encoding TypeMappingImpl.java
> > Log:
> > Fix for Bug 18084 - Auto Typing in TypeMappingImpl only
> > puts types in the default namespace
> > from dan@envoisolutions.com (Dan Diephouse)
> >
> > Revision Changes Path
> > 1.42 +56 -53
> > xml-axis/java/src/org/apache/axis/encoding/TypeMappingImpl.java
> >
> > Index: TypeMappingImpl.java
> > ===================================================================
> > RCS file:
> > /home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMappi
> > ngImpl.java,v
> > retrieving revision 1.41
> > retrieving revision 1.42
> > diff -u -r1.41 -r1.42
> > --- TypeMappingImpl.java 22 Apr 2003 19:34:25 -0000 1.41
> > +++ TypeMappingImpl.java 2 Jul 2003 16:47:32 -0000 1.42
> > @@ -57,10 +57,13 @@
> >
> > import org.apache.axis.Constants;
> > import org.apache.axis.components.logger.LogFactory;
> > +import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
> > +import org.apache.axis.encoding.ser.ArraySerializerFactory;
> > import org.apache.axis.encoding.ser.BeanDeserializerFactory;
> > import org.apache.axis.encoding.ser.BeanSerializerFactory;
> > -import org.apache.axis.utils.ClassUtils;
> > import org.apache.axis.utils.Messages;
> > +import org.apache.axis.wsdl.fromJava.Namespaces;
> > +import org.apache.axis.wsdl.fromJava.Types;
> > import org.apache.commons.logging.Log;
> >
> > import javax.xml.namespace.QName;
> > @@ -139,10 +142,6 @@
> > protected TypeMapping delegate; // Pointer to
> > delegate or null
> > private ArrayList namespaces; // Supported namespaces
> >
> > - /**
> > - * Should we "auto-type" classes we don't recognize
> > into the "java:"
> > - * namespace?
> > - */
> > private boolean doAutoTypes = false;
> >
> > /**
> > @@ -327,13 +326,6 @@
> > if (xmlType == null) {
> > return null;
> > }
> > -
> > - // If we're doing autoTyping, and we got a
> > type in the right
> > - // namespace, we can use the default serializer.
> > - if (doAutoTypes &&
> > -
> > xmlType.getNamespaceURI().equals(Constants.NS_URI_JAVA)) {
> > - return new BeanSerializerFactory(javaType,
> > xmlType);
> > - }
> > }
> >
> > // Try to get the serializer associated with this pair
> > @@ -393,12 +385,6 @@
> > if (xmlType == null) {
> > return null;
> > }
> > -
> > - // If we're doing autoTyping, we can use the default.
> > - if (doAutoTypes &&
> > -
> > xmlType.getNamespaceURI().equals(Constants.NS_URI_JAVA)) {
> > - return xmlType;
> > - }
> > }
> >
> > // Try to get the serializer associated with this pair
> > @@ -458,16 +444,6 @@
> > if (javaType == null) {
> > return null;
> > }
> > -
> > - if (doAutoTypes &&
> > -
> > Constants.NS_URI_JAVA.equals(xmlType.getNamespaceURI())) {
> > - try {
> > - javaType =
> > ClassUtils.forName(xmlType.getLocalPart());
> > - } catch (ClassNotFoundException e) {
> > - return null;
> > - }
> > - return new
> > BeanDeserializerFactory(javaType, xmlType);
> > - }
> > }
> >
> > Pair pair = new Pair(javaType, xmlType);
> > @@ -567,27 +543,63 @@
> > xmlType = pair.xmlType;
> > }
> >
> > - if (xmlType == null && doAutoTypes) {
> > - xmlType = new QName(Constants.NS_URI_JAVA,
> > - javaType.getName());
> > - }
> > -
> > // Can only detect arrays via code
> > if (xmlType == null && (javaType.isArray() ||
> > - javaType == List.class ||
> > - List.class.isAssignableFrom(javaType))) {
> > + javaType == List.class ||
> > + List.class.isAssignableFrom(javaType))) {
> >
> > - // get the registered array if any
> > - pair = (Pair) class2Pair.get(Object[].class);
> > - // TODO: it always returns the last registered one,
> > - // so that's why the soap 1.2 typemappings have to
> > - // move to an other registry to differentiate them
> > - if (pair != null) {
> > - xmlType = pair.xmlType;
> > - } else {
> > - xmlType = Constants.SOAP_ARRAY;
> > + /* If auto-typing is on, generate a namespace
> > for this array
> > + * intelligently, then register it's javaType
> > and xmlType. Also
> > + * make sure the class isn't derived from
> > List, because they
> > + * should be serialized as an anyType array.
> > + */
> > + if ( doAutoTypes &&
> > + javaType != List.class &&
> > + !List.class.isAssignableFrom(javaType) )
> > + {
> > + xmlType = new QName(
> > + Namespaces.makeNamespace( javaType.getName() ),
> > + Types.getLocalNameFromFullName(
> > javaType.getName() ) );
> > +
> > + register( javaType,
> > + xmlType,
> > + new ArraySerializerFactory(),
> > + new ArrayDeserializerFactory() );
> > + }
> > + else
> > + {
> > + // get the registered array if any
> > + pair = (Pair) class2Pair.get(Object[].class);
> > + // TODO: it always returns the last registered one,
> > + // so that's why the soap 1.2
> > typemappings have to
> > + // move to an other registry to differentiate them
> > + if (pair != null) {
> > + xmlType = pair.xmlType;
> > + } else {
> > + xmlType = Constants.SOAP_ARRAY;
> > + }
> > }
> > }
> > +
> > + /* If the class isn't an array or List and
> > auto-typing is turned on,
> > + * register the class and it's type as beans.
> > + */
> > + if (xmlType == null && doAutoTypes)
> > + {
> > + xmlType = new QName(
> > + Namespaces.makeNamespace( javaType.getName() ),
> > + Types.getLocalNameFromFullName(
> > javaType.getName() ) );
> > +
> > + /* If doAutoTypes is set, register a new type
> > mapping for the
> > + * java class with the above QName. This way,
> > when getSerializer()
> > + * and getDeserializer() are called, this
> > QName is returned and
> > + * these methods do not need to worry about
> > creating a serializer.
> > + */
> > + register( javaType,
>
=== message truncated ===
=====
Davanum Srinivas - http://webservices.apache.org/~dims/
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com