users@jax-rpc.java.net

JAXRPC-INTEREST -- [Fwd: Re: Type Mappings]

From: Anita Jindal <Anita.Jindal_at_Sun.COM>
Date: Tue, 08 Jan 2002 16:39:04 -0800

Dale,

Are you planning to maintain a FAQ for JAXRPC?

- Anita

-------- Original Message --------
From: Arun Gupta <arun.gupta_at_Sun.COM>
Subject: Re: Type Mappings
To: JAXRPC-INTEREST_at_JAVA.SUN.COM

Hi Mike,

See my inline responses.

Mike Yawn wrote:
>
> I'm looking for more information about Type Mappings
> than I've been able to find in the tutorial and API docs.
>
> I have an RMI interface I'd like to convert to JAX-RPC.
> However, it uses some user-defined classes as parameters,
> and a java.util.List Collection as a return type (the
> List will always be an ArrayList, but I tried to allow
> for future changes). The List will contain user-defined
> types as well.
>
> It appears that support for members of the Collection
> classes is intended, but the xrpcc tool gives an error

I'd like to clarify here that Collection classes are not supported in
EA1, but *may* be supported in future releases. Where did you find the
support for Collection classes in the docs ?

> 'Invalid type for JAX-RPC structure'. I originally got
> the error on my user-defined parameter types; after

This error message makes sense because only JAX-RPC supported data types
can be used in your service definition interface. And JAX-RPC supported
data types are:

* One of the Java primitive types
* A subset of the standard Java classes
* An array of a supported Java type
* A JavaBeans class
* An exception class

If you have anything else in your service definition interface, this
error message will be thrown.

> removing these from the interface, I got the same error
> on java.util.List. I changed List to ArrayList since it
> isn't clear whether an interface type is legal, but
> ArrayList also gets the 'invalid type' error.

For the reason mentioned above, you got an 'invalid type' error for an
ArrayList as well.

>
> My questions:
> - What do I need to do to allow support for the List or
> ArrayList classes?

I would recommend using the standard Java arrays instead of ArrayList
classes. These are supported by JAXRPC runtime by default and there is
no extra effort involved in serializing/deserializing them. However for
including List or ArrayList classes support in your application, you
will have to write pluggable serializer and deserializers which is not a
trivial thing. Moreover pluggable serializer and deserializers will
limit the portability of your application since they are specific to an
implementation. Support for portable serializers and deserializers will
be addressed in the next version of the JAX-RPC specification.

> - What do I need to do to allow support for my own
> classes?

Please refer to section 5.3.5 of the spec. If your classes are
conformant to the javabean design pattern and also follow the rules as
given in this particular section, then JAXRPC runtime will take care of
serializing/deserializing your own class. FYI, following are the
requirements by JAXRPC:

* JavaBeans class must be serializable to and from the corresponding XML
representation at runtime. This means that a JavaBeans class must
contain properties
that are of the JAX-RPC supported Java types. If one or more properties
do not have
the JAX-RPC supported types, then the JavaBeans class is not mapped.
* JavaBeans class must have a default constructor.
* The Java type of a property must be a JAX-RPC 1.0 supported Java type
and be
mappable to the corresponding XML type.

The standard rules of mapping from a javabean are as well given in the
spec in the same section. It should be relatively straight forward to
conform your class to javabean design pattern.


>
> I believe I need to do something with defining typeMappings
> in the typeMappingRegistry, and also that the mappings for
> the Collection classes already exist somewhere, but this
> is as far as I've been able to get.

These are required only if you write pluggable serializers and
deserializers. Once you have the various artifacts required for
pluggability ready, then you specify the typeMappings in
typeMappingRegistry using the config.xml file.

Hope that helps.

Thanks for your interest in JAXRPC.

Regards,
-Arun

>
> Thanks for any help or suggestions,
> Mike Yawn

--
=============================================
There is only one me, I must live myself!
There is only one today, I must live itself!
=============================================
http://members.tripod.com/~apgupta/index.html
=============================================