OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

wsrp-interop message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [wsrp-interop] WSRP event payloads with "simple" types

Hi Kevin,

I agree with your observation here.
As far as I understood your problem description this interop issue arises when portlets start to throw events for which they didn't declare any type definition neither in the WSRP description nor in the JSR deployment descriptor (which both specs allow).
Let it try to describe it in my words to see if we have a common understanding:
For the JSR case not specifying the type possible because the container would just pass around the serializable object and portlets knowing the type could cast explizitly and they are done, right?
Now as soon as we go over the wire we can serialize the object because it is either a JAXB-annotated complext type or an implicitly supported simple type.
So serialization just works.
Now, when the event is distributed as the WSRP payload (with no type annotation), then the producer/consumer which want to deserialize that payload can not reliably do so, because the root element qname does not provide any hint of the type. And since the type in this case is not specified in the deployment descriptor this should fail....
I guess this is not only a problem for simple types (which could be solved e.g. in a manner you proposed) but also for complex types.
How would you point JAXB to the right annotated class allowing to create the complex bean object?

I think this problem goes away if portlets in the JSR case always declare the type definition in the portlet.xml.
Maybe this is also worth mentioning as a best interop practice, even in the local case.

Another option besides definiting root element Qnames indicating the type could be to have the event flow with a type qname, which the spec alread has.
So if you would have a simple string being serialized, the event would flow as (simplified):

<event name="someNS:localPart" type="xsd:string">

This way the wsrp-to-jsr bridge could pass the correct type class to the JAXB deserializer and retrieve the correct object (provided it has a type to class mapping at hand).
Mit freundlichen Grüßen / Kind regards
Richard Jacob
Team Lead Portal Standards & WCM development
WSRP Standardization Lead
IBM Software Group, WPLC
WSS Websphere Portal Foundation Development 1
Phone: +49-7031-16-3469  IBM Deutschland
E-Mail: richard.jacob@de.ibm.com  Schoenaicher Str. 220
     71032 Boeblingen
IBM Deutschland Research & Development GmbH / Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Erich Baier
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294


From: Kevin Frender <kevin.frender@oracle.com>
To: Nader Oteifa <nader2@netunitysoftware.com>
Cc: wsrp-interop@lists.oasis-open.org
Date: 10/15/2009 05:45 PM
Subject: Re: [wsrp-interop] WSRP event payloads with "simple" types

Hello Nader,

I may be misunderstanding your suggestion, but my original statement of
the problem wasn't entirely clear either.

Yes, I know that JAXB can be set up so that arbitrary objects can be
marshalled and unmarshalled (as DOM elements), but the problem as I see
it is that for the simplest of data types explicitly supported by the
JSR286 spec as event payloads, there is no obvious, inter-operable way
to marshal these event payloads so that they will be guaranteed to show
up in the receiving portlet as the same simple type that was sent.

For example, if portlet A sends an event:

eventResponse.setEvent(new QName("namespace", "localpart"), "Simple
String payload");

and portlet B receives this event, I would expect portlet B to be able
to do this:

Event event = eventRequest.getEvent();
String payload = (String)event.getValue();

-- and not need to do anything like this:

String payload = ((Element)event.getValue()).getTextContent();

The problem isn't that I don't know of any way at all to marshal the
simple String payload into XML, or how to unmarshal that form back into
a String, but rather that I don't know how to distinguish between an
event payload coming from another (third-party) WSRP producer or
consumer that represents a marshalled simple payload type (like a
String) versus an event payload that was deliberately configured by the
portlet developer to be marshalled into XML.  For example, if I get an
event payload in the WSRP event that looks like this:

<samplePayload>Simple String payload</samplePayload>

I could assume that this means I should return an Event object to the
portlet developer whose payload is a java.lang.String object, as
outlined in the sample above.  However, if the portlet developer for
event-sending portlet "C" actually created their own event payload
object and gave it a valid JAXB binding, such as:

public class SamplePayload implements Serializable
   String value;
   public SamplePayload(String s)
      value = s;

eventResponse.setEvent(new QName("namespace", "localpart"), new
SamplePayload("Simple String payload"));

Then the developer actually intended for a "SamplePayload" object to be
sent, not a java.lang.String-- and a receiving portlet should probably
get an XML DOM element in the event payload instead of a simple
java.lang.String object (assuming that the receiving portlet's WSRP
implementation doesn't have a JAXB SamplePayload object configured).

So my proposal would be a set of extension elements for containing only
the simplest of event payload values-- the simple types explicitly
supported by the JSR286 specification-- so that various WSRP
implementations could recognize those elements as containing a simple
payload value (and ONLY a simple payload value).  I would propose that
arrays of simple values would not be supported, as they are not
explicitly supported by the JSR286 spec as payload types, but arrays of
simple values can still be handled by JSR286 portlet developers by
specifying their own JAXB bindings.

For example, we might define in the wsrp-extra namespace elements such as:

<element name="stringPayload" type="xsd:string"/>
<element name="intPayload" type="xsd:int"/>
<element name="longPayload" type="xsd:long"/>

By being in the WSRP namespace (and being well-known elements) it would
be easy to distinguish these "simple" event payload types from "complex"
marshalled objects.  I can create such schema definitions for sending
simple payload types myself and put them in our proprietary namespace,
and they would work just fine as long as the events were not delivered
to a third-party WSRP producer, which wouldn't recognize them as
intending to be "naked", simple values.

So that is the point of my post- for at least the simplest of event
payload types it seems like a WSRP-standard solution for encoding these
payload types would be beneficial for interop purposes.


Nader Oteifa wrote:
> Kevin,
> Any of these links of help?
> tml#Elements%20With%20Any%20Type
> Element.html#Another%20Content%20Tree%20as%20Element
> ements-XmlAnyElement.html#Collecting%20Unspecified%20Elements:%20XmlAnyEleme
> nt
> I think dealing with an extension is probably more complex than trying to
> figure out how to make it work with primitive types without having to create
> a class. Do you expand payload to include all primitive types?  What about
> arrays of primitive types? I don't even think namedStringArray should be in
> payload and even in the specification it appeared like it originally was not
> there.
> I think you'll have to take the "Any" XML element use it as input to a new
> Unmarshaller but only when the value of the payload is requested with the
> given type.  When marshalling, you'll need to have an extra parameter to
> specify that a root should be created with same name as event or use
> overloaded methods.  Example:
> int x = myEvent.GetValue<int>(0); //parameter is default value for type
> myEvent.SetValue<int>(x, true); // parameter = true to create an element
> with same name as event name
> or
> int x = myEvent.GetValue(0); //overloaded methods for all primitive types
> myEvent.SetValue(x); //these create the element with same name as event
> or some variation on this theme.
> Nader
> -----Original Message-----
> From: Kevin Frender [
> Sent: Wednesday, October 14, 2009 3:58 PM
> To: wsrp-interop@lists.oasis-open.org
> Subject: [wsrp-interop] WSRP event payloads with "simple" types
> Hello all,
> For WSRP 2.0 events, the schema-supported event payload types are a
> NamedStringArray and "any" from a non-WSRP-types namespace.  This was a
> conscious decision at the time to not get into the details of
> standardizing event payload encoding.
> For JSR286 (Java Portlet specification version 2.0) event payloads can
> have any JAXB-bindable object type, or any of the JAXB primitive types,
> which include very basic things like java.lang.String, java.util.Date,
> etc. which have obvious mappings to XML data types.  The JAXB primitive
> types don't have @XmlRootElement annotations however, so they can't be
> marshalled directly (by themselves) to XML.
> So if a portlet wanted to send an event with a simple String payload,
> JSR286 allows that, but there is no obvious way to represent that in XML
> as a WSRP event payload in a manner that other WSRP containers could
> recognize.
> In the interest of interoperability, I was wondering how everyone
> handles the binding of these "primitive" types when they are used as an
> event payload.  We were thinking of creating a simple XML element for
> holding these types inside the event payload, but that wouldn't work too
> well for WSRP interoperability, unless the WSRP committee came up with a
> standard schema and XML namespace to hold these "simple" types.  So as a
> second question, I was wondering if there was interest in creating a
> standard WSRP extension for handling these simple data types.
> Thanks,
>   Kevin
> ---------------------------------------------------------------------
> To unsubscribe from this mail list, you must leave the OASIS TC that
> generates this mail.  Follow this link to all your TCs in OASIS at:
> ---------------------------------------------------------------------
> To unsubscribe from this mail list, you must leave the OASIS TC that
> generates this mail.  Follow this link to all your TCs in OASIS at:

To unsubscribe from this mail list, you must leave the OASIS TC that
generates this mail.  Follow this link to all your TCs in OASIS at:

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]