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

 


Help: OASIS Mailing Lists Help | MarkMail Help

wsrp message

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


Subject: Re: [wsrp] Event payload's root element name


I agree with the mismatch. Therefor I also think that option 3. is not the
right way to do it. Annotated classes with a root name namespace and name
declaration contradict the reuse of classes acting as payloads to different
events.
As said below the JAXB serializing result should never be visible to
portlets/portlet programmers.
Therefor I would prefer option 2. which would cause portlet containers to
generate a XML fragment with the event's qname as the root element name.
Additionally containers shouldn't care about the root element name but
rather map the incomming event qname to a portlet class declared in the
event-definition in the portlet DD.
We tried that out and JAXB allows to handle it that way.

However I'm worried about event payload generated somewhere else in the
system which might not use the WSRP spec defined convention and choose yet
another root element name.
This would require producers to change the root element name before
emitting an event. But as said the information what the original event
payload root element name was gets lost.
Therefor such backend systems relying on their generated root element name
might not be able to deserialize an event payload received via WSRP
(bacause the producer was forced to change the root element name).

Therefor I would ask from an interoperability standpoint if anyone realy
cares about the root element name in the WSRP event payload. I would assume
most implementations to use a qname to class mapping or the type
information in the event meta data to deserialize the event payload
accordingly.

Mit freundlichen Gruessen / best regards,

        Richard Jacob
______________________________________________________
IBM Lab Boeblingen, Germany
Dept. 2289, WebSphere Portal Server Development 1
WSRP Team Lead
WSRP Architecture & Standardization
Phone: ++49 7031 16-3469  -  Fax: ++49 7031 16-4888

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Herbert Kircher
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


|------------>
| From:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Rich Thompson <richt2@us.ibm.com>                                                                                                                 |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |wsrp@lists.oasis-open.org, wsrp-interop@lists.oasis-open.org                                                                                      |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |10/16/2007 06:28 PM                                                                                                                               |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Re: [wsrp] Event payload's root element name                                                                                                      |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|






Digging a bit deeper, it appears the fundamental issue is a mismatch
between JAXB and XML. XML has complete separation between semantics
(element name) and syntax (element type) while JAXB embeds annotations
about semantic naming into the syntactic layer (in this case Java class
definition) such that one can not use annotations and have two different
elements be of the same type.

One might argue that we could have said the type name would be the root
element since we already carry the event name in a separate field (required
to cover use cases without a payload), but that would leave an issue when
the type is not supplied (i.e. opaque payload). My preference would be to
leave the spec as is and solve this in those layers which need to provide
JAXB mapping ... is that possible?

Rich

                                                                       
 Richard Jacob                                                         
 <richard.jacob@de.ibm.com>                                            
                                                                       
                                                                        To
 10/16/2007 08:21 AM                                 wsrp-interop@lists.oa
                                                     sis-open.org      
                                                                        cc
                                                     wsrp@lists.oasis-open
                                                     .org              
                                                                   Subject
                                                     [wsrp] Event      
                                                     payload's root    
                                                     element name      
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       






In 4.1.11 EventDescriptionType we mandate that the event's payload root
element name becomes the event's (q)name.
Although this is not a conformance statement, I would ask if this is really
necessary although I can see some use to it.
I would be greatly interested in opinions and perhaps implementation
choices you have choosen here for the sake of interoperability.

The current problem that I see is that JSR286 does not mandate to have the
class definition be annotated with a namespace and name element.
E.g. the following class could be defined by a portlet programmer:

@XmlRootElement
class foo {
 @XmlAttribute
 String attribute;
 @XmlElement
 String value;
}

A typical JAXB serializer would serialize this to:

<foo attribute="someASttributeValue">
 <value>someValue</value>
</foo>

This means that for WSRP the Producer would have to change the root element
name to match the event name, e.g.:
<fooEvent xmlns:x="http://example.org/eventnamespace";
attribute="someASttributeValue">
 <value>someValue</value>
</foo>

In this case when a portlet would receive <fooEvent>, it might not be able
to deserialize that event payload, because the JAXB unmarshaller would
expect <foo> as the root element name.
Note that when transforming the root element's name, the initial name gets
lost on event distribution.

I see the following solutions to this problem:

1. do no require/mandate that the root element has a certain name
The root element is of no meaning because typically the event source would
match the event's type from it's definition which is a 1:1 relation of name
and type.
So unmarshallers need to be prepared to cope with payloads with arbitrary
root element names - the type is important here. This is explicitly allowed
by the JAXB spec to unmarshall XML strings which have a different root name
element.
And since the target portlet would need to have the same class defined I
guess this way would be easiser for portlet programmers as well as for
container developers.

2. make sure that container implementation always marshal java classes with
a root element who's namespace and name is the event's qname defined in the
DD.
This would make the transformation to wsrp payload easy, producer would
just need to stuff in the JAXB serialized XML String as the event payload.
The same applies here to unmashalling as in 1. The unmarshalling code needs
to invoke the JAXB unmarshaller with the XML String and class name (type
information) which would then generate the according portlet class
referenced in the DD. I would presume most implementation would do that
anyway and don't care about the root element's name because they have a)
the event qname and b) the matching class at hand.

3. mandate in the JSR286 spec that JAXB annotated classes need to annoted
the root element with namespace & name matching the event name, e.g.:
@XmlRootElement(namespace="http://example.org/eventnamespace";,
name="fooEvent")
class foo {
 @XmlAttribute
 String attribute;
 @XmlElement
 String value;
}
If the root element annotation contains no namespace and name attributes,
then the JSR286 container's JAXB serializer would create the root element
according to above rules.
Note that some convention like this is also necessary for JSR286 event
payloads consisting of simple types like java.lang.String.
There is no definition about what the root name will be in this case in the
JAXB spec, I guess JAXB implementation can choose an arbitrary naming
algorithm here.
I guess a similar convention would come handy in the JSR286 spec, too.
Although I realize that this is more a directive to container
implementations rather than portlet programmers.
Typically portlet programmers will never need to deal with the form the
JAXB serializer chooses.

Mit freundlichen Gruessen / best regards,

       Richard Jacob
______________________________________________________
IBM Lab Boeblingen, Germany
Dept. 2289, WebSphere Portal Server Development 1
WSRP Team Lead
WSRP Architecture & Standardization
Phone: ++49 7031 16-3469  -  Fax: ++49 7031 16-4888

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Herbert Kircher
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294





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